In preparation for reusing the code for nVMX tests, move the guest_regs array declaration as well as GPR switching macro to processor.h. No functional change intended. Signed-off-by: Yosry Ahmed --- tools/testing/selftests/kvm/include/x86/processor.h | 5 +++++ tools/testing/selftests/kvm/lib/x86/processor.c | 2 ++ tools/testing/selftests/kvm/lib/x86/svm.c | 4 ---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing/selftests/kvm/include/x86/processor.h index 535f26e077570..28edeab74e0e6 100644 --- a/tools/testing/selftests/kvm/include/x86/processor.h +++ b/tools/testing/selftests/kvm/include/x86/processor.h @@ -414,6 +414,11 @@ static inline unsigned int x86_model(unsigned int eax) #define GUEST_REGS_R15 15 #define NR_GUEST_REGS (GUEST_REGS_R15 + 1) +extern u64 guest_regs[NR_GUEST_REGS]; + +#define GUEST_SWITCH_GPR_ASM(reg, idx) \ + "xchg %%" #reg ", guest_regs + 8 *" XSTR(idx) "\n\t" + struct desc64 { u16 limit0; u16 base0; diff --git a/tools/testing/selftests/kvm/lib/x86/processor.c b/tools/testing/selftests/kvm/lib/x86/processor.c index ef56dcefe0119..0d66aff04939b 100644 --- a/tools/testing/selftests/kvm/lib/x86/processor.c +++ b/tools/testing/selftests/kvm/lib/x86/processor.c @@ -29,6 +29,8 @@ bool host_cpu_is_amd_compatible; bool is_forced_emulation_enabled; u64 guest_tsc_khz; +u64 guest_regs[NR_GUEST_REGS]; + const char *ex_str(int vector) { switch (vector) { diff --git a/tools/testing/selftests/kvm/lib/x86/svm.c b/tools/testing/selftests/kvm/lib/x86/svm.c index 8e392e0451123..d07f10b5dc963 100644 --- a/tools/testing/selftests/kvm/lib/x86/svm.c +++ b/tools/testing/selftests/kvm/lib/x86/svm.c @@ -13,7 +13,6 @@ #define SEV_DEV_PATH "/dev/sev" -u64 guest_regs[NR_GUEST_REGS]; u64 rflags; /* Allocate memory regions for nested SVM tests. @@ -133,9 +132,6 @@ void generic_svm_setup(struct svm_test_data *svm, void *guest_rip) } } -#define GUEST_SWITCH_GPR_ASM(reg, idx) \ - "xchg %%" #reg ", guest_regs + 8 *" XSTR(idx) "\n\t" - /* * save/restore 64-bit general registers except rax, rip, rsp * which are directly handed through the VMCB guest processor state -- 2.55.0.rc0.799.gd6f94ed593-goog