Skip to content

Commit

Permalink
Revert "KVM: selftests: Fix nested SVM tests when built with clang"
Browse files Browse the repository at this point in the history
Revert back to using memset() in generic_svm_setup() now that KVM
selftests override memset() and friends specifically to prevent the
compiler from generating fancy code and/or linking to the libc
implementation.

This reverts commit ed290e1.

Suggested-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220928233652.783504-8-seanjc@google.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Sean Christopherson authored and Paolo Bonzini committed Sep 30, 2022
1 parent 53c9bdb commit c96409d
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions tools/testing/selftests/kvm/lib/x86_64/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,6 @@ static void vmcb_set_seg(struct vmcb_seg *seg, u16 selector,
seg->base = base;
}

/*
* Avoid using memset to clear the vmcb, since libc may not be
* available in L1 (and, even if it is, features that libc memset may
* want to use, like AVX, may not be enabled).
*/
static void clear_vmcb(struct vmcb *vmcb)
{
int n = sizeof(*vmcb) / sizeof(u32);

asm volatile ("rep stosl" : "+c"(n), "+D"(vmcb) : "a"(0) : "memory");
}

void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rsp)
{
struct vmcb *vmcb = svm->vmcb;
Expand All @@ -88,7 +76,7 @@ void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_r
wrmsr(MSR_EFER, efer | EFER_SVME);
wrmsr(MSR_VM_HSAVE_PA, svm->save_area_gpa);

clear_vmcb(vmcb);
memset(vmcb, 0, sizeof(*vmcb));
asm volatile ("vmsave %0\n\t" : : "a" (vmcb_gpa) : "memory");
vmcb_set_seg(&save->es, get_es(), 0, -1U, data_seg_attr);
vmcb_set_seg(&save->cs, get_cs(), 0, -1U, code_seg_attr);
Expand Down

0 comments on commit c96409d

Please sign in to comment.