Use a straight MOV instead of an XOR to zero R9 in the non-faulting path of __KVM_ASM_SAFE() so as not to clobber RFLAGS. XOR generates smaller code, but optimizing performance by minimizing the code footprint is just about the last thing that KVM selftests care about. The bug is relatively benign in the current code base, e.g. it marginally degrades the coverage in the fastops test, but otherwise does no harm. But the bug will become actively problematic if/when the "safe assembly" macros are used for instructions that communicate results via RFLAGS, e.g. for VMX instructions, which signal failure via RFLAGS.CF and RFLAGS.ZF. Opportunistically use R9D instead of the full R9, as bits 63:32 of GPRs are zeroed on writes to bit 31:0. Reported-by: Sashiko Bot Closes: https://lore.kernel.org/all/20260818165258.2613603-5-vkuznets@redhat.com Cc: Vitaly Kuznetsov Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/include/x86/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing/selftests/kvm/include/x86/processor.h index 6e6f70035508..282b8aaff799 100644 --- a/tools/testing/selftests/kvm/include/x86/processor.h +++ b/tools/testing/selftests/kvm/include/x86/processor.h @@ -1318,7 +1318,7 @@ gva_t vm_alloc_stack(struct kvm_vm *vm, int nr_pages); "lea 1f(%%rip), %%r10\n\t" \ "lea 2f(%%rip), %%r11\n\t" \ fep "1: " insn "\n\t" \ - "xor %%r9, %%r9\n\t" \ + "mov $0, %%r9d\n\t" \ "2:\n\t" \ "mov %%r9b, %[vector]\n\t" \ "mov %%r10, %[error_code]\n\t" -- 2.55.0.887.g758fc8c411-goog