OpenCloudOS-Kernel/tools/testing/selftests/kvm
David Matlack 372d070845 KVM: selftests: Fix ambiguous mov in KVM_ASM_SAFE()
Change the mov in KVM_ASM_SAFE() that zeroes @vector to a movb to
make it unambiguous.

This fixes a build failure with Clang since, unlike the GNU assembler,
the LLVM integrated assembler rejects ambiguous X86 instructions that
don't have suffixes:

  In file included from x86_64/hyperv_features.c:13:
  include/x86_64/processor.h:825:9: error: ambiguous instructions require an explicit suffix (could be 'movb', 'movw', 'movl', or 'movq')
          return kvm_asm_safe("wrmsr", "a"(val & -1u), "d"(val >> 32), "c"(msr));
                 ^
  include/x86_64/processor.h:802:15: note: expanded from macro 'kvm_asm_safe'
          asm volatile(KVM_ASM_SAFE(insn)                 \
                       ^
  include/x86_64/processor.h:788:16: note: expanded from macro 'KVM_ASM_SAFE'
          "1: " insn "\n\t"                                       \
                        ^
  <inline asm>:5:2: note: instantiated into assembly here
          mov $0, 15(%rsp)
          ^

It seems like this change could introduce undesirable behavior in the
future, e.g. if someone used a type larger than a u8 for @vector, since
KVM_ASM_SAFE() will only zero the bottom byte. I tried changing the type
of @vector to an int to see what would happen. GCC failed to compile due
to a size mismatch between `movb` and `%eax`. Clang succeeded in
compiling, but the generated code looked correct, so perhaps it will not
be an issue. That being said it seems like there could be a better
solution to this issue that does not assume @vector is a u8.

Fixes: 3b23054cd3 ("KVM: selftests: Add x86-64 support for exception fixup")
Signed-off-by: David Matlack <dmatlack@google.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220722234838.2160385-3-dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-08-19 07:38:05 -04:00
..
aarch64 Merge tag 'kvmarm-5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD 2022-08-01 03:24:12 -04:00
include KVM: selftests: Fix ambiguous mov in KVM_ASM_SAFE() 2022-08-19 07:38:05 -04:00
lib selftests: kvm: set rax before vmcall 2022-08-01 08:43:05 -04:00
s390x KVM: selftests: Fix filename reporting in guest asserts 2022-07-13 18:14:08 -07:00
x86_64 KVM: selftests: Test all possible "invalid" PERF_CAPABILITIES.LBR_FMT vals 2022-08-10 15:08:29 -04:00
.gitignore KVM: selftests: Verify VMX MSRs can be restored to KVM-supported values 2022-07-28 13:25:24 -04:00
Makefile KVM: selftests: Make rseq compatible with glibc-2.35 2022-08-10 15:08:29 -04:00
access_tracking_perf_test.c KVM: selftests: Add TEST_REQUIRE macros to reduce skipping copy+paste 2022-06-11 11:47:29 -04:00
config selftests: kvm: Adding config fragments 2019-08-09 16:52:38 +02:00
demand_paging_test.c KVM: selftests: Purge vm+vcpu_id == vcpu silliness 2022-06-11 11:47:22 -04:00
dirty_log_perf_test.c KVM: selftests: Add an option to run vCPUs while disabling dirty logging 2022-07-28 13:22:24 -04:00
dirty_log_test.c KVM: selftests: Add kvm_has_cap() to provide syntactic sugar 2022-06-11 11:47:28 -04:00
hardware_disable_test.c KVM: selftests: Move per-VM/per-vCPU nr pages calculation to __vm_create() 2022-06-11 11:47:26 -04:00
kvm_binary_stats_test.c selftests: KVM: Add exponent check for boolean stats 2022-08-01 08:01:23 -04:00
kvm_create_max_vcpus.c KVM: selftests: Add TEST_REQUIRE macros to reduce skipping copy+paste 2022-06-11 11:47:29 -04:00
kvm_page_table_test.c KVM: selftests: Drop @num_percpu_pages from __vm_create_with_vcpus() 2022-06-11 11:47:25 -04:00
max_guest_memory_test.c KVM: selftests: Open code and drop 'struct kvm_vm' accessors 2022-06-11 11:47:24 -04:00
memslot_modification_stress_test.c KVM: selftests: Open code and drop 'struct kvm_vm' accessors 2022-06-11 11:47:24 -04:00
memslot_perf_test.c KVM: selftests: Fix filename reporting in guest asserts 2022-07-13 18:14:08 -07:00
rseq_test.c KVM: selftests: Use getcpu() instead of sched_getcpu() in rseq_test 2022-08-10 15:08:29 -04:00
set_memory_region_test.c KVM: selftests: Fix filename reporting in guest asserts 2022-07-13 18:14:08 -07:00
settings selftests: kvm: Raise the default timeout to 120 seconds 2021-02-09 08:17:08 -05:00
steal_time.c KVM: selftests: Use kvm_cpu_has() for KVM's PV steal time 2022-07-13 18:14:13 -07:00
system_counter_offset_test.c KVM: selftests: Fix filename reporting in guest asserts 2022-07-13 18:14:08 -07:00