Skip to content

Commit c4e1a84

Browse files
pratiksampatsean-jc
authored andcommitted
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 <[email protected]> Reviewed-by: Pankaj Gupta <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 68ed692 commit c4e1a84

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tools/testing/selftests/kvm/include/x86/sev.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ kvm_static_assert(SEV_RET_SUCCESS == 0);
7171
void sev_vm_init(struct kvm_vm *vm);
7272
void sev_es_vm_init(struct kvm_vm *vm);
7373

74+
static inline void vmgexit(void)
75+
{
76+
__asm__ __volatile__("rep; vmmcall");
77+
}
78+
7479
static inline void sev_register_encrypted_memory(struct kvm_vm *vm,
7580
struct userspace_mem_region *region)
7681
{

tools/testing/selftests/kvm/x86/sev_smoke_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static void guest_sev_es_code(void)
2727
* force "termination" to signal "done" via the GHCB MSR protocol.
2828
*/
2929
wrmsr(MSR_AMD64_SEV_ES_GHCB, GHCB_MSR_TERM_REQ);
30-
__asm__ __volatile__("rep; vmmcall");
30+
vmgexit();
3131
}
3232

3333
static void guest_sev_code(void)

0 commit comments

Comments
 (0)