freebsd-dev/sys
Konstantin Belousov bc3ad3a179 Add kernel interfaces to call EFI Runtime Services.
Runtime services require special execution environment for the call.
Besides that, OS must inform firmware about runtime virtual memory map
which will be active during the calls, with the SetVirtualAddressMap()
runtime call, done while the 1:1 mapping is still used.  There are two
complication: the SetVirtualAddressMap() effectively must be done from
loader, which needs to know kernel address map in advance.  More,
despite not explicitely mentioned in the specification, both 1:1 and
the map passed to SetVirtualAddressMap() must be active during the
SetVirtualAddressMap() call.  Second, there are buggy BIOSes which
require both mappings active during runtime calls as well, most likely
because they fail to identify all relocations to perform.

On amd64, we can get rid of both problems by providing 1:1 mapping for
the duration of runtime calls, by temprorary remapping user addresses.
As result, we avoid the need for loader to know about future kernel
address map, and avoid bugs in BIOSes.  Typically BIOS only maps
something in low 4G.  If not runtime bugs, we would take advantage of
the DMAP, as previous versions of this patch did.

Similar but more complicated trick can be used even for i386 and 32bit
runtime, if and when the EFI boot on i386 is supported.  We would need
a trampoline page, since potentially whole 4G of VA would be switched
on calls, instead of only userspace portion on amd64.

Context switches are disabled for the duration of the call, FPU access
is granted, and interrupts are not disabled.  The later is possible
because kernel is mapped during calls.

To test, the sysctl mib debug.efi_time is provided, setting it to 1
makes one call to EFI get_time() runtime service, on success the efitm
structure is printed to the control terminal.  Load efirt.ko, or add
EFIRT option to the kernel config, to enable code.

Discussed with:	emaste, imp
Tested by:	emaste (mac, qemu)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2016-09-21 11:31:58 +00:00
..
amd64 Add kernel interfaces to call EFI Runtime Services. 2016-09-21 11:31:58 +00:00
arm Add a way for the architecture to specify the calling ABI for methods 2016-09-21 10:35:44 +00:00
arm64 Add a way for the architecture to specify the calling ABI for methods 2016-09-21 10:35:44 +00:00
boot Simple post-mortem reporter for amd64 loader.efi. 2016-09-21 10:22:46 +00:00
bsm
cam Protect ccbq access with devq->send_mtx in the XPT_ABORT handler. 2016-09-21 00:08:42 +00:00
cddl MFV r268120: 2016-09-11 17:48:06 +00:00
compat Add PROC_TRAPCAP procctl(2) controls and global sysctl kern.trap_enocap. 2016-09-21 08:23:33 +00:00
conf Add kernel interfaces to call EFI Runtime Services. 2016-09-21 11:31:58 +00:00
contrib Update Annapurna Alpine HAL 2016-09-20 09:19:22 +00:00
crypto Fix typo in skein amd64 assembly 2016-09-08 02:38:55 +00:00
ddb Silently ignore unexpected single-step traps (except for turning 2016-09-17 11:43:51 +00:00
dev hyperv/hn: Put debug messages under bootverbose 2016-09-21 06:54:26 +00:00
fs Change the getnewvnode(9) tag for nullfs from "null" to "nullfs". 2016-09-15 13:57:37 +00:00
gdb
geom Follow up r305988 by removing g_bio_run_task and related code. 2016-09-20 09:18:33 +00:00
gnu Update the device tree source files to a Linux 4.7-RC. 2016-09-21 08:54:08 +00:00
i386 Remove all kernel uses of pcb_psl, but keep in in the struct to 2016-09-17 14:00:52 +00:00
isa
kern Make resettodr_lock accessible outside subr_rtc.c. Protect 2016-09-21 10:15:08 +00:00
kgssapi
libkern
mips Split bcm_mipscore.c into bcm_bmips (BMIPS32/BMIPS3300) and bcm_mips74k 2016-09-18 21:28:09 +00:00
modules Add kernel interfaces to call EFI Runtime Services. 2016-09-21 11:31:58 +00:00
net Remove the 4.3BSD compatible macro m_copy(), use m_copym() instead. 2016-09-15 07:41:48 +00:00
net80211 [net80211] add a HT method to populate HTCAP based on IBSS requirements. 2016-09-17 05:44:57 +00:00
netgraph Avoid panic from ng_uncallout when unpluggin ethernet cable with active 2016-08-08 19:31:01 +00:00
netinet Fix the handling of unordered fragmented user messages using DATA chunks. 2016-09-21 08:28:18 +00:00
netinet6 Reduce code duplication around NDP message handlers in icmp6_input(). 2016-09-20 18:08:17 +00:00
netipsec Remove the 4.3BSD compatible macro m_copy(), use m_copym() instead. 2016-09-15 07:41:48 +00:00
netnatm
netpfil Move opcode rewriter init and destroy handlers into non-VENT code. 2016-09-18 17:35:17 +00:00
netsmb
nfs Hide the boottime and bootimebin globals, provide the getboottime(9) 2016-07-27 11:08:59 +00:00
nfsclient
nfsserver
nlm When sleeping waiting for either local or remote advisory lock, 2016-06-26 20:08:42 +00:00
ofed Do not free an uninitialized pointer on soaccept failure in the iWARP 2016-08-26 08:25:28 +00:00
opencrypto opencrypto AES-ICM: Fix heap corruption typo 2016-08-01 22:57:03 +00:00
pc98 Remove the ie(4) driver for Intel 82586 ISA Ethernet adapters. 2016-08-20 00:49:29 +00:00
powerpc Move ofw_parse_bootargs to the correct place. 2016-09-21 03:10:41 +00:00
riscv Various changes to pmap_ts_referenced() 2016-09-10 16:49:25 +00:00
rpc Hide the boottime and bootimebin globals, provide the getboottime(9) 2016-07-27 11:08:59 +00:00
security Don't check aq64_minfree which is unsigned for negative values. 2016-09-08 19:47:57 +00:00
sparc64 Various changes to pmap_ts_referenced() 2016-09-10 16:49:25 +00:00
sys Rename efi_systbl to efi_systbl_phys, the variable contains the 2016-09-21 10:55:28 +00:00
teken
tests
tools Consider CROSS_BINUTILS_PREFIX environment variable so we use correct 2016-08-10 13:49:17 +00:00
ufs Be more strict when selecting between snapshot/regular mount. 2016-09-19 15:58:33 +00:00
vm Various changes to pmap_ts_referenced() 2016-09-10 16:49:25 +00:00
x86 Detect x2APIC mode on boot and obey it. 2016-09-19 15:58:45 +00:00
xdr
xen
Makefile