linux_dsm_epyc7002/tools/testing/selftests/kvm/x86_64
Vitaly Kuznetsov cfb65c15d7 KVM: selftests: fix sync_with_host() in smm_test
It was reported that older GCCs compile smm_test in a way that breaks
it completely:

  kvm_exit:             reason EXIT_CPUID rip 0x4014db info 0 0
  func 7ffffffd idx 830 rax 0 rbx 0 rcx 0 rdx 0, cpuid entry not found
  ...
  kvm_exit:             reason EXIT_MSR rip 0x40abd9 info 0 0
  kvm_msr:              msr_read 487 = 0x0 (#GP)
  ...

Note, '7ffffffd' was supposed to be '80000001' as we're checking for
SVM. Dropping '-O2' from compiler flags help. Turns out, asm block in
sync_with_host() is wrong. We us 'in 0xe, %%al' instruction to sync
with the host and in 'AL' register we actually pass the parameter
(stage) but after sync 'AL' gets written to but GCC thinks the value
is still there and uses it to compute 'EAX' for 'cpuid'.

smm_test can't fully use standard ucall() framework as we need to
write a very simple SMI handler there. Fix the immediate issue by
making RAX input/output operand. While on it, make sync_with_host()
static inline.

Reported-by: Marcelo Bandeira Condotta <mcondotta@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20200610164116.770811-1-vkuznets@redhat.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-06-11 12:35:19 -04:00
..
cr4_cpuid_sync_test.c selftests: kvm: Uses TEST_FAIL in tests/utilities 2020-03-16 17:59:11 +01:00
debug_regs.c KVM: VMX: pass correct DR6 for GD userspace exit 2020-05-08 07:44:31 -04:00
evmcs_test.c KVM: selftests: Don't probe KVM_CAP_HYPERV_ENLIGHTENED_VMCS when nested VMX is unsupported 2020-06-11 12:35:18 -04:00
hyperv_cpuid.c KVM: selftests: Don't probe KVM_CAP_HYPERV_ENLIGHTENED_VMCS when nested VMX is unsupported 2020-06-11 12:35:18 -04:00
mmio_warning_test.c KVM: selftests: Use consistent message for test skipping 2020-03-16 17:59:05 +01:00
platform_info_test.c KVM: selftests: Use consistent message for test skipping 2020-03-16 17:59:05 +01:00
set_sregs_test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 482 2019-06-19 17:09:52 +02:00
smm_test.c KVM: selftests: fix sync_with_host() in smm_test 2020-06-11 12:35:19 -04:00
state_test.c KVM: selftests: do not substitute SVM/VMX check with KVM_CAP_NESTED_STATE check 2020-06-11 12:35:17 -04:00
svm_vmcall_test.c selftests: kvm: Uses TEST_FAIL in tests/utilities 2020-03-16 17:59:11 +01:00
sync_regs_test.c KVM: selftests: Use consistent message for test skipping 2020-03-16 17:59:05 +01:00
vmx_close_while_nested_test.c selftests: kvm: Uses TEST_FAIL in tests/utilities 2020-03-16 17:59:11 +01:00
vmx_dirty_log_test.c selftests: kvm: Uses TEST_FAIL in tests/utilities 2020-03-16 17:59:11 +01:00
vmx_preemption_timer_test.c KVM: selftests: fix vmx_preemption_timer_test build with GCC10 2020-06-08 07:59:43 -04:00
vmx_set_nested_state_test.c KVM: selftests: Use consistent message for test skipping 2020-03-16 17:59:05 +01:00
vmx_tsc_adjust_test.c selftests: kvm: Uses TEST_FAIL in tests/utilities 2020-03-16 17:59:11 +01:00
xss_msr_test.c KVM: selftests: Use consistent message for test skipping 2020-03-16 17:59:05 +01:00