]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: selftests: Add vmgexit helper
authorPratik R. Sampat <prsampat@amd.com>
Wed, 5 Mar 2025 22:59:53 +0000 (16:59 -0600)
committerSean Christopherson <seanjc@google.com>
Fri, 2 May 2025 19:32:32 +0000 (12:32 -0700)
Abstract rep vmmcall coded into the vmgexit helper for the sev
library.

No functional change intended.

Signed-off-by: Pratik R. Sampat <prsampat@amd.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Link: https://lore.kernel.org/r/20250305230000.231025-4-prsampat@amd.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/include/x86/sev.h
tools/testing/selftests/kvm/x86/sev_smoke_test.c

index 82c11c81a956323d54ea1b27d8b88dbc5eb6db6e..3003dc837fb708d8397a92894fcf4f8a15be956f 100644 (file)
@@ -71,6 +71,11 @@ kvm_static_assert(SEV_RET_SUCCESS == 0);
 void sev_vm_init(struct kvm_vm *vm);
 void sev_es_vm_init(struct kvm_vm *vm);
 
+static inline void vmgexit(void)
+{
+       __asm__ __volatile__("rep; vmmcall");
+}
+
 static inline void sev_register_encrypted_memory(struct kvm_vm *vm,
                                                 struct userspace_mem_region *region)
 {
index d97816dc476a272e8961bd6f716b5de91154b1e9..b990034ea5a531c4133aa855d104b39c42ff68c1 100644 (file)
@@ -27,7 +27,7 @@ static void guest_sev_es_code(void)
         * force "termination" to signal "done" via the GHCB MSR protocol.
         */
        wrmsr(MSR_AMD64_SEV_ES_GHCB, GHCB_MSR_TERM_REQ);
-       __asm__ __volatile__("rep; vmmcall");
+       vmgexit();
 }
 
 static void guest_sev_code(void)