Skip to content

Commit 293fa72

Browse files
Ricardo Kollergregkh
authored andcommitted
KVM: selftests: Add operand to vmsave/vmload/vmrun in svm.c
[ Upstream commit 47bc726 ] Building the KVM selftests with LLVM's integrated assembler fails with: $ CFLAGS=-fintegrated-as make -C tools/testing/selftests/kvm CC=clang lib/x86_64/svm.c:77:16: error: too few operands for instruction asm volatile ("vmsave\n\t" : : "a" (vmcb_gpa) : "memory"); ^ <inline asm>:1:2: note: instantiated into assembly here vmsave ^ lib/x86_64/svm.c:134:3: error: too few operands for instruction "vmload\n\t" ^ <inline asm>:1:2: note: instantiated into assembly here vmload ^ This is because LLVM IAS does not currently support calling vmsave, vmload, or vmload without an explicit %rax operand. Add an explicit operand to vmsave, vmload, and vmrum in svm.c. Fixing this was suggested by Sean Christopherson. Tested: building without this error in clang 11. The following patch (not queued yet) needs to be applied to solve the other remaining error: "selftests: kvm: remove reassignment of non-absolute variables". Suggested-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/kvm/X+Df2oQczVBmwEzi@google.com/ Reviewed-by: Jim Mattson <jmattson@google.com> Signed-off-by: Ricardo Koller <ricarkol@google.com> Message-Id: <20210210031719.769837-1-ricarkol@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d337537 commit 293fa72

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • tools/testing/selftests/kvm/lib/x86_64

‎tools/testing/selftests/kvm/lib/x86_64/svm.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_r
7474
wrmsr(MSR_VM_HSAVE_PA, svm->save_area_gpa);
7575

7676
memset(vmcb, 0, sizeof(*vmcb));
77-
asm volatile ("vmsave\n\t" : : "a" (vmcb_gpa) : "memory");
77+
asm volatile ("vmsave %0\n\t" : : "a" (vmcb_gpa) : "memory");
7878
vmcb_set_seg(&save->es, get_es(), 0, -1U, data_seg_attr);
7979
vmcb_set_seg(&save->cs, get_cs(), 0, -1U, code_seg_attr);
8080
vmcb_set_seg(&save->ss, get_ss(), 0, -1U, data_seg_attr);
@@ -131,19 +131,19 @@ void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_r
131131
void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa)
132132
{
133133
asm volatile (
134-
"vmload\n\t"
134+
"vmload %[vmcb_gpa]\n\t"
135135
"mov rflags, %%r15\n\t" // rflags
136136
"mov %%r15, 0x170(%[vmcb])\n\t"
137137
"mov guest_regs, %%r15\n\t" // rax
138138
"mov %%r15, 0x1f8(%[vmcb])\n\t"
139139
LOAD_GPR_C
140-
"vmrun\n\t"
140+
"vmrun %[vmcb_gpa]\n\t"
141141
SAVE_GPR_C
142142
"mov 0x170(%[vmcb]), %%r15\n\t" // rflags
143143
"mov %%r15, rflags\n\t"
144144
"mov 0x1f8(%[vmcb]), %%r15\n\t" // rax
145145
"mov %%r15, guest_regs\n\t"
146-
"vmsave\n\t"
146+
"vmsave %[vmcb_gpa]\n\t"
147147
: : [vmcb] "r" (vmcb), [vmcb_gpa] "a" (vmcb_gpa)
148148
: "r15", "memory");
149149
}

0 commit comments

Comments
 (0)