Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * runtime-wrappers.c - Runtime Services function call wrappers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Implementation summary:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * 1. When user/kernel thread requests to execute efi_runtime_service(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * enqueue work to efi_rts_wq.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * 2. Caller thread waits for completion until the work is finished
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * because it's dependent on the return status and execution of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * efi_runtime_service().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * For instance, get_variable() and get_next_variable().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * Split off from arch/x86/platform/efi/efi.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * Copyright (C) 1999 VA Linux Systems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * Copyright (C) 1999-2002 Hewlett-Packard Co.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * Copyright (C) 2005-2008 Intel Co.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * Copyright (C) 2013 SuSE Labs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define pr_fmt(fmt)	"efi: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/efi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <linux/irqflags.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/semaphore.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <linux/stringify.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <asm/efi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * Wrap around the new efi_call_virt_generic() macros so that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * code doesn't get too cluttered:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define efi_call_virt(f, args...)   \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	efi_call_virt_pointer(efi.runtime, f, args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define __efi_call_virt(f, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	__efi_call_virt_pointer(efi.runtime, f, args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) struct efi_runtime_work efi_rts_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * efi_queue_work:	Queue efi_runtime_service() and wait until it's done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * @rts:		efi_runtime_service() function identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * @rts_arg<1-5>:	efi_runtime_service() function arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * Accesses to efi_runtime_services() are serialized by a binary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * semaphore (efi_runtime_lock) and caller waits until the work is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * finished, hence _only_ one work is queued at a time and the caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * thread waits for completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define efi_queue_work(_rts, _arg1, _arg2, _arg3, _arg4, _arg5)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) ({									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	efi_rts_work.status = EFI_ABORTED;				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	if (!efi_enabled(EFI_RUNTIME_SERVICES)) {			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		pr_warn_once("EFI Runtime Services are disabled!\n");	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		goto exit;						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	}								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	init_completion(&efi_rts_work.efi_rts_comp);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	INIT_WORK(&efi_rts_work.work, efi_call_rts);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	efi_rts_work.arg1 = _arg1;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	efi_rts_work.arg2 = _arg2;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	efi_rts_work.arg3 = _arg3;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	efi_rts_work.arg4 = _arg4;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	efi_rts_work.arg5 = _arg5;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	efi_rts_work.efi_rts_id = _rts;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	/*								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	 * queue_work() returns 0 if work was already on queue,         \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	 * _ideally_ this should never happen.                          \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 */								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (queue_work(efi_rts_wq, &efi_rts_work.work))			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		wait_for_completion(&efi_rts_work.efi_rts_comp);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	else								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		pr_err("Failed to queue work to efi_rts_wq.\n");	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) exit:									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	efi_rts_work.efi_rts_id = EFI_NONE;				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	efi_rts_work.status;						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #ifndef arch_efi_save_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #define arch_efi_save_flags(state_flags)	local_save_flags(state_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #define arch_efi_restore_flags(state_flags)	local_irq_restore(state_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) unsigned long efi_call_virt_save_flags(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	arch_efi_save_flags(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	return flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) void efi_call_virt_check_flags(unsigned long flags, const char *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	unsigned long cur_flags, mismatch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	cur_flags = efi_call_virt_save_flags();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	mismatch = flags ^ cur_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (!WARN_ON_ONCE(mismatch & ARCH_EFI_IRQ_FLAGS_MASK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_NOW_UNRELIABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	pr_err_ratelimited(FW_BUG "IRQ flags corrupted (0x%08lx=>0x%08lx) by EFI %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			   flags, cur_flags, call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	arch_efi_restore_flags(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * According to section 7.1 of the UEFI spec, Runtime Services are not fully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  * reentrant, and there are particular combinations of calls that need to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * serialized. (source: UEFI Specification v2.4A)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * Table 31. Rules for Reentry Into Runtime Services
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * +------------------------------------+-------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * | If previous call is busy in	| Forbidden to call		|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * +------------------------------------+-------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * | Any				| SetVirtualAddressMap()	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * +------------------------------------+-------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * | ConvertPointer()			| ConvertPointer()		|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * +------------------------------------+-------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * | SetVariable()			| ResetSystem()			|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * | UpdateCapsule()			|				|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * | SetTime()				|				|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  * | SetWakeupTime()			|				|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * | GetNextHighMonotonicCount()	|				|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * +------------------------------------+-------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  * | GetVariable()			| GetVariable()			|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * | GetNextVariableName()		| GetNextVariableName()		|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * | SetVariable()			| SetVariable()			|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * | QueryVariableInfo()		| QueryVariableInfo()		|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * | UpdateCapsule()			| UpdateCapsule()		|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * | QueryCapsuleCapabilities()		| QueryCapsuleCapabilities()	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * | GetNextHighMonotonicCount()	| GetNextHighMonotonicCount()	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * +------------------------------------+-------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * | GetTime()				| GetTime()			|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  * | SetTime()				| SetTime()			|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * | GetWakeupTime()			| GetWakeupTime()		|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * | SetWakeupTime()			| SetWakeupTime()		|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * +------------------------------------+-------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * Due to the fact that the EFI pstore may write to the variable store in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * interrupt context, we need to use a lock for at least the groups that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * contain SetVariable() and QueryVariableInfo(). That leaves little else, as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * none of the remaining functions are actually ever called at runtime.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * So let's just use a single lock to serialize all Runtime Services calls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static DEFINE_SEMAPHORE(efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * Expose the EFI runtime lock to the UV platform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #ifdef CONFIG_X86_UV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) extern struct semaphore __efi_uv_runtime_lock __alias(efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * Calls the appropriate efi_runtime_service() with the appropriate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * Semantics followed by efi_call_rts() to understand efi_runtime_work:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  * 1. If argument was a pointer, recast it from void pointer to original
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * pointer type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  * 2. If argument was a value, recast it from void pointer to original
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * pointer type and dereference it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static void efi_call_rts(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	void *arg1, *arg2, *arg3, *arg4, *arg5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	efi_status_t status = EFI_NOT_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	arg1 = efi_rts_work.arg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	arg2 = efi_rts_work.arg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	arg3 = efi_rts_work.arg3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	arg4 = efi_rts_work.arg4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	arg5 = efi_rts_work.arg5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	switch (efi_rts_work.efi_rts_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	case EFI_GET_TIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		status = efi_call_virt(get_time, (efi_time_t *)arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 				       (efi_time_cap_t *)arg2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	case EFI_SET_TIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		status = efi_call_virt(set_time, (efi_time_t *)arg1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	case EFI_GET_WAKEUP_TIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		status = efi_call_virt(get_wakeup_time, (efi_bool_t *)arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 				       (efi_bool_t *)arg2, (efi_time_t *)arg3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	case EFI_SET_WAKEUP_TIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		status = efi_call_virt(set_wakeup_time, *(efi_bool_t *)arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 				       (efi_time_t *)arg2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	case EFI_GET_VARIABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		status = efi_call_virt(get_variable, (efi_char16_t *)arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 				       (efi_guid_t *)arg2, (u32 *)arg3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 				       (unsigned long *)arg4, (void *)arg5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	case EFI_GET_NEXT_VARIABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		status = efi_call_virt(get_next_variable, (unsigned long *)arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 				       (efi_char16_t *)arg2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 				       (efi_guid_t *)arg3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	case EFI_SET_VARIABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		status = efi_call_virt(set_variable, (efi_char16_t *)arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 				       (efi_guid_t *)arg2, *(u32 *)arg3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 				       *(unsigned long *)arg4, (void *)arg5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	case EFI_QUERY_VARIABLE_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		status = efi_call_virt(query_variable_info, *(u32 *)arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 				       (u64 *)arg2, (u64 *)arg3, (u64 *)arg4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	case EFI_GET_NEXT_HIGH_MONO_COUNT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		status = efi_call_virt(get_next_high_mono_count, (u32 *)arg1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	case EFI_UPDATE_CAPSULE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		status = efi_call_virt(update_capsule,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 				       (efi_capsule_header_t **)arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 				       *(unsigned long *)arg2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 				       *(unsigned long *)arg3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	case EFI_QUERY_CAPSULE_CAPS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		status = efi_call_virt(query_capsule_caps,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 				       (efi_capsule_header_t **)arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 				       *(unsigned long *)arg2, (u64 *)arg3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 				       (int *)arg4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		 * Ideally, we should never reach here because a caller of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		 * function should have put the right efi_runtime_service()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		 * function identifier into efi_rts_work->efi_rts_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		pr_err("Requested executing invalid EFI Runtime Service.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	efi_rts_work.status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	complete(&efi_rts_work.efi_rts_comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	status = efi_queue_work(EFI_GET_TIME, tm, tc, NULL, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static efi_status_t virt_efi_set_time(efi_time_t *tm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	status = efi_queue_work(EFI_SET_TIME, tm, NULL, NULL, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 					     efi_bool_t *pending,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 					     efi_time_t *tm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	status = efi_queue_work(EFI_GET_WAKEUP_TIME, enabled, pending, tm, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 				NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	status = efi_queue_work(EFI_SET_WAKEUP_TIME, &enabled, tm, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 				NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) static efi_status_t virt_efi_get_variable(efi_char16_t *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 					  efi_guid_t *vendor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 					  u32 *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 					  unsigned long *data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 					  void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	status = efi_queue_work(EFI_GET_VARIABLE, name, vendor, attr, data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 				data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static efi_status_t virt_efi_get_next_variable(unsigned long *name_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 					       efi_char16_t *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 					       efi_guid_t *vendor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	status = efi_queue_work(EFI_GET_NEXT_VARIABLE, name_size, name, vendor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 				NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static efi_status_t virt_efi_set_variable(efi_char16_t *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 					  efi_guid_t *vendor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 					  u32 attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 					  unsigned long data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 					  void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	status = efi_queue_work(EFI_SET_VARIABLE, name, vendor, &attr, &data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 				data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static efi_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) virt_efi_set_variable_nonblocking(efi_char16_t *name, efi_guid_t *vendor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 				  u32 attr, unsigned long data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 				  void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	if (down_trylock(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		return EFI_NOT_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	status = efi_call_virt(set_variable, name, vendor, attr, data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 			       data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) static efi_status_t virt_efi_query_variable_info(u32 attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 						 u64 *storage_space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 						 u64 *remaining_space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 						 u64 *max_variable_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		return EFI_UNSUPPORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	status = efi_queue_work(EFI_QUERY_VARIABLE_INFO, &attr, storage_space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 				remaining_space, max_variable_size, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) static efi_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) virt_efi_query_variable_info_nonblocking(u32 attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 					 u64 *storage_space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 					 u64 *remaining_space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 					 u64 *max_variable_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		return EFI_UNSUPPORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	if (down_trylock(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		return EFI_NOT_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	status = efi_call_virt(query_variable_info, attr, storage_space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			       remaining_space, max_variable_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) static efi_status_t virt_efi_get_next_high_mono_count(u32 *count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	status = efi_queue_work(EFI_GET_NEXT_HIGH_MONO_COUNT, count, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 				NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) static void virt_efi_reset_system(int reset_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 				  efi_status_t status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 				  unsigned long data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 				  efi_char16_t *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	if (down_trylock(&efi_runtime_lock)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		pr_warn("failed to invoke the reset_system() runtime service:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			"could not get exclusive access to the firmware\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	efi_rts_work.efi_rts_id = EFI_RESET_SYSTEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	__efi_call_virt(reset_system, reset_type, status, data_size, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 					    unsigned long count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 					    unsigned long sg_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		return EFI_UNSUPPORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	status = efi_queue_work(EFI_UPDATE_CAPSULE, capsules, &count, &sg_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 				NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 						unsigned long count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 						u64 *max_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 						int *reset_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	efi_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		return EFI_UNSUPPORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	if (down_interruptible(&efi_runtime_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 		return EFI_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	status = efi_queue_work(EFI_QUERY_CAPSULE_CAPS, capsules, &count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 				max_size, reset_type, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	up(&efi_runtime_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) void efi_native_runtime_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	efi.get_time = virt_efi_get_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	efi.set_time = virt_efi_set_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	efi.get_wakeup_time = virt_efi_get_wakeup_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	efi.set_wakeup_time = virt_efi_set_wakeup_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	efi.get_variable = virt_efi_get_variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	efi.get_next_variable = virt_efi_get_next_variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	efi.set_variable = virt_efi_set_variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	efi.set_variable_nonblocking = virt_efi_set_variable_nonblocking;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	efi.reset_system = virt_efi_reset_system;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	efi.query_variable_info = virt_efi_query_variable_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	efi.query_variable_info_nonblocking = virt_efi_query_variable_info_nonblocking;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	efi.update_capsule = virt_efi_update_capsule;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	efi.query_capsule_caps = virt_efi_query_capsule_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) }