[PATCH 2/2] efi/runtime-wrappers: mark efi_runtime_lock_owner as __used

Breno Leitao <[email protected]> Mon, 13 Jul 2026 06:06:48 -0700
Newsgroups org.kernel.vger.linux-efi,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
efi_runtime_lock_owner is only ever read by efi_runtime_assert_lock_held().
When CONFIG_BUG=n, WARN_ON() collapses to a statement that discards its
condition, so the compiler drops that read, treats the variable as
write-only and eliminates it. Debug info still references the symbol, so a
build carrying it (e.g. CONFIG_DEBUG_INFO_SPLIT) fails to link:

  ld: drivers/firmware/efi/runtime-wrappers.o:(.debug_addr+0x104): undefined reference to `efi_runtime_lock_owner'

Mark the variable __used so its storage is always emitted. This seems to
be better than alternatives (READ_ONCE/__maybe_unused).

Fixes: a2860501203c ("efi/runtime-wrappers: Keep track of the efi_runtime_lock owner")
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Breno Leitao <[email protected]>
---
 drivers/firmware/efi/runtime-wrappers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
index 6f42da11a9178..2344b9d1e81f8 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -210,7 +210,7 @@ void efi_call_virt_check_flags(unsigned long flags, const void *caller)
  */
 static DEFINE_SEMAPHORE(efi_runtime_lock, 1);
 
-static struct task_struct *efi_runtime_lock_owner;
+static struct task_struct *efi_runtime_lock_owner __used;
 
 /*
  * Expose the EFI runtime lock to the UV platform

-- 
2.53.0-Meta