linux_dsm_epyc7002/tools/testing/selftests/kvm
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
..
include KVM: selftests: do not substitute SVM/VMX check with KVM_CAP_NESTED_STATE check 2020-06-11 12:35:17 -04:00
lib KVM: selftests: do not substitute SVM/VMX check with KVM_CAP_NESTED_STATE check 2020-06-11 12:35:17 -04:00
s390x selftests: KVM: s390: check for registers to NOT change on reset 2020-03-16 17:59:09 +01:00
x86_64 KVM: selftests: fix sync_with_host() in smm_test 2020-06-11 12:35:19 -04:00
.gitignore KVM: selftests: Add x86_64/debug_regs to .gitignore 2020-06-08 07:59:42 -04:00
clear_dirty_log_test.c kvm: selftests: Support dirty log initial-all-set test 2020-03-16 17:57:41 +01:00
config selftests: kvm: Adding config fragments 2019-08-09 16:52:38 +02:00
demand_paging_test.c KVM: selftests: Rework timespec functions and usage 2020-03-18 14:08:56 +01:00
dirty_log_test.c selftests: kvm: Uses TEST_FAIL in tests/utilities 2020-03-16 17:59:11 +01:00
kvm_create_max_vcpus.c KVM: selftests: Convert some printf's to pr_info's 2020-03-16 17:57:07 +01:00
Makefile KVM: selftests: Fix build with "make ARCH=x86_64" 2020-06-05 11:15:55 -04:00
set_memory_region_test.c selftests: kvm/set_memory_region_test: do not check RIP if the guest shuts down 2020-04-21 09:13:13 -04:00
steal_time.c KVM: selftests: Rework timespec functions and usage 2020-03-18 14:08:56 +01:00