[PATCH v2 08/36] KVM: arm64: Introduce kvm_call_hyp_nvhe_res()

Sascha Bischoff Sascha.Bischoff at arm.com
Fri Dec 19 07:52:38 PST 2025


There are times when it is desirable to have more than one return
value for a hyp call. Split out kvm_call_hyp_nvhe_res from
kvm_call_hyp_nvhe such that it is possible to directly provide struct
arm_smccc_res from the calling code. Thereby, additional return values
can be stored in res.a2, etc.

Suggested-by: Marc Zyngier <maz at kernel.org>
Signed-off-by: Sascha Bischoff <sascha.bischoff at arm.com>
---
 arch/arm64/include/asm/kvm_host.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index b552a1e03848c..971b153b0a3fa 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -1208,14 +1208,19 @@ void kvm_arm_resume_guest(struct kvm *kvm);
 #define vcpu_has_run_once(vcpu)	(!!READ_ONCE((vcpu)->pid))
 
 #ifndef __KVM_NVHE_HYPERVISOR__
-#define kvm_call_hyp_nvhe(f, ...)						\
+#define kvm_call_hyp_nvhe_res(res, f, ...)				\
 	({								\
-		struct arm_smccc_res res;				\
-									\
+		struct arm_smccc_res *__res = res;			\
 		arm_smccc_1_1_hvc(KVM_HOST_SMCCC_FUNC(f),		\
-				  ##__VA_ARGS__, &res);			\
-		WARN_ON(res.a0 != SMCCC_RET_SUCCESS);			\
+				  ##__VA_ARGS__, __res);		\
+		WARN_ON(__res->a0 != SMCCC_RET_SUCCESS);		\
+	})
+
+#define kvm_call_hyp_nvhe(f, ...)					\
+	({								\
+		struct arm_smccc_res res;				\
 									\
+		kvm_call_hyp_nvhe_res(&res, f, ##__VA_ARGS__);		\
 		res.a1;							\
 	})
 
-- 
2.34.1



More information about the linux-arm-kernel mailing list