From 1edf879037cbe915dffc9fa9341a1279564c2e1e Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Thu, 22 Mar 2018 14:09:17 +0000 Subject: [PATCH] Enter into the EFI environment before check the GetTime pointer --- sys/dev/efidev/efirt.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/dev/efidev/efirt.c b/sys/dev/efidev/efirt.c index f1c543b116d..a1ed4d214e4 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); } -- 2.15.1