aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/efidev
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2018-03-22 15:32:57 +0000
committerAndrew Turner <andrew@FreeBSD.org>2018-03-22 15:32:57 +0000
commit112b88e3919511f01d186b5b455b760f113a6d2e (patch)
tree4202b753ca01ca45e4dae3a0d987c8d735d72a61 /sys/dev/efidev
parentc5149a4979654c1e92bdc1305ec31f9f82b06d13 (diff)
downloadsrc-112b88e3919511f01d186b5b455b760f113a6d2e.tar.gz
src-112b88e3919511f01d186b5b455b760f113a6d2e.zip
Enter into the EFI environment before dereferencing the runtime services
pointer. This may be within the EFI address space and not the FreeBSD kernel address space. X-MFC-With: r330868 Sponsored by: DARPA, AFRL
Notes
Notes: svn path=/head/; revision=331361
Diffstat (limited to 'sys/dev/efidev')
-rw-r--r--sys/dev/efidev/efirt.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/dev/efidev/efirt.c b/sys/dev/efidev/efirt.c
index f1c543b116de..a1ed4d214e43 100644
--- a/sys/dev/efidev/efirt.c
+++ b/sys/dev/efidev/efirt.c
@@ -88,6 +88,9 @@ static int efi_status2err[25] = {
EPROTO /* EFI_PROTOCOL_ERROR */
};
+static int efi_enter(void);
+static void efi_leave(void);
+
static int
efi_status_to_errno(efi_status status)
{
@@ -190,9 +193,14 @@ efi_init(void)
* call RS->SetVirtualAddressMap. As this is not always the case, e.g.
* with an old loader.efi, check if the RS->GetTime function is within
* the EFI map, and fail to attach if not.
+ *
+ * We need to enter into the EFI environment as efi_runtime may point
+ * to an EFI address.
*/
+ efi_enter();
if (!efi_is_in_map(map, efihdr->memory_size / efihdr->descriptor_size,
efihdr->descriptor_size, (vm_offset_t)efi_runtime->rt_gettime)) {
+ efi_leave();
if (bootverbose)
printf(
"EFI runtime services table has an invalid pointer\n");
@@ -200,6 +208,7 @@ efi_init(void)
efi_destroy_1t1_map();
return (ENXIO);
}
+ efi_leave();
return (0);
}