OpenCloudOS-Kernel/tools/testing/selftests/kvm/include
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 KVM: selftests: Purge vm+vcpu_id == vcpu silliness 2022-06-11 11:47:22 -04:00
riscv KVM: selftests: Consolidate KVM_{G,S}ET_ONE_REG helpers 2022-06-11 11:47:10 -04:00
s390x KVM: selftests: Define cpu_relax() helpers for s390 and x86 2022-03-08 10:59:11 -05:00
x86_64 KVM: selftests: Fix ambiguous mov in KVM_ASM_SAFE() 2022-08-19 07:38:05 -04:00
guest_modes.h KVM: selftests: Factor out guest mode code 2021-01-07 18:07:29 -05:00
kvm_util.h kvm: selftests: move ucall declarations into ucall_common.h 2022-01-07 13:25:33 -05:00
kvm_util_base.h KVM: selftests: Cache CPUID in struct kvm_vcpu 2022-07-13 18:14:15 -07:00
numaif.h KVM: selftests: Add missing header file needed by xAPIC IPI tests 2021-02-11 08:02:08 -05:00
perf_test_util.h KVM: selftests: Stop conflating vCPU index and ID in perf tests 2022-06-11 11:47:20 -04:00
sparsebit.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 482 2019-06-19 17:09:52 +02:00
test_util.h KVM: selftests: Use TAP-friendly ksft_exit_skip() in __TEST_REQUIRE 2022-06-11 11:47:29 -04:00
ucall_common.h KVM: selftests: Fix filename reporting in guest asserts 2022-07-13 18:14:08 -07:00