diff options
| author | Pratik R. Sampat <prsampat@amd.com> | 2025-03-05 16:59:53 -0600 |
|---|---|---|
| committer | Sean Christopherson <seanjc@google.com> | 2025-05-02 12:32:32 -0700 |
| commit | c4e1a848d72179136f6ea9626933cb26c9d35eb5 (patch) | |
| tree | b1f58ed329458b3b78afa87f8c7ce8be37f72b0a /tools | |
| parent | KVM: selftests: SEV-SNP test for KVM_SEV_INIT2 (diff) | |
| download | linux-c4e1a848d72179136f6ea9626933cb26c9d35eb5.tar.gz linux-c4e1a848d72179136f6ea9626933cb26c9d35eb5.zip | |
KVM: selftests: Add vmgexit helper
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>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/testing/selftests/kvm/include/x86/sev.h | 5 | ||||
| -rw-r--r-- | tools/testing/selftests/kvm/x86/sev_smoke_test.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/include/x86/sev.h b/tools/testing/selftests/kvm/include/x86/sev.h index 82c11c81a956..3003dc837fb7 100644 --- a/tools/testing/selftests/kvm/include/x86/sev.h +++ b/tools/testing/selftests/kvm/include/x86/sev.h @@ -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) { diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c b/tools/testing/selftests/kvm/x86/sev_smoke_test.c index d97816dc476a..b990034ea5a5 100644 --- a/tools/testing/selftests/kvm/x86/sev_smoke_test.c +++ b/tools/testing/selftests/kvm/x86/sev_smoke_test.c @@ -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) |
