From 0bf9c766cff09d09aa684f5184cad4b5a24e723b Mon Sep 17 00:00:00 2001 From: kevans Date: Mon, 6 Aug 2018 03:58:56 +0000 Subject: [PATCH] MFC r336919, r336924 r336919: efirt: Add tunable to allow disabling EFI Runtime Services Leading up to enabling EFIRT in GENERIC, allow runtime services to be disabled with a new tunable: efi.rt_disabled. This makes it so that EFIRT can be disabled easily in case we run into some buggy UEFI implementation and fail to boot. r336924: Follow up to r336919 and r336921: s/efi.rt_disabled/efi.rt.disabled/ The latter matches the rest of the tree better [0]. The UPDATING entry has been updated to reflect this, and the new tunable is now documented in loader(8) [1]. Reported by: imp [0], Shawn Webb [1] --- stand/man/loader.8 | 6 +++++- sys/dev/efidev/efirt.c | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/stand/man/loader.8 b/stand/man/loader.8 index 7af7343d99d..75e5d1a73d8 100644 --- a/stand/man/loader.8 +++ b/stand/man/loader.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 18, 2015 +.Dd July 30, 2018 .Dt LOADER 8 .Os .Sh NAME @@ -588,6 +588,10 @@ explicitly. Other variables are used to override kernel tunable parameters. The following tunables are available: .Bl -tag -width Va +.It Va efi.rt.disabled +Disable UEFI runtime services in the kernel, if applicable. +Runtime services are only available and used if the kernel is booted in a UEFI +environment. .It Va hw.physmem Limit the amount of physical memory the system will use. By default the size is in bytes, but the diff --git a/sys/dev/efidev/efirt.c b/sys/dev/efidev/efirt.c index 0e99bde48fe..52fc9569bb4 100644 --- a/sys/dev/efidev/efirt.c +++ b/sys/dev/efidev/efirt.c @@ -133,7 +133,12 @@ efi_init(void) struct efi_md *map; caddr_t kmdp; size_t efisz; + int rt_disabled; + rt_disabled = 0; + TUNABLE_INT_FETCH("efi.rt.disabled", &rt_disabled); + if (rt_disabled == 1) + return (0); mtx_init(&efi_lock, "efi", NULL, MTX_DEF); if (efi_systbl_phys == 0) { @@ -217,6 +222,9 @@ static void efi_uninit(void) { + /* Most likely disabled by tunable */ + if (efi_runtime == NULL) + return; efi_destroy_1t1_map(); efi_systbl = NULL; -- 2.45.0