acrn-kernel/arch/x86
Tao Su 43cea54109 KVM: x86: Clear bit12 of ICR after APIC-write VM-exit
commit 629d3698f6958ee6f8131ea324af794f973b12ac upstream.

When IPI virtualization is enabled, a WARN is triggered if bit12 of ICR
MSR is set after APIC-write VM-exit. The reason is kvm_apic_send_ipi()
thinks the APIC_ICR_BUSY bit should be cleared because KVM has no delay,
but kvm_apic_write_nodecode() doesn't clear the APIC_ICR_BUSY bit.

Under the x2APIC section, regarding ICR, the SDM says:

  It remains readable only to aid in debugging; however, software should
  not assume the value returned by reading the ICR is the last written
  value.

I.e. the guest is allowed to set bit 12.  However, the SDM also gives KVM
free reign to do whatever it wants with the bit, so long as KVM's behavior
doesn't confuse userspace or break KVM's ABI.

Clear bit 12 so that it reads back as '0'. This approach is safer than
"do nothing" and is consistent with the case where IPI virtualization is
disabled or not supported, i.e.,

  handle_fastpath_set_x2apic_icr_irqoff() -> kvm_x2apic_icr_write()

Opportunistically replace the TODO with a comment calling out that eating
the write is likely faster than a conditional branch around the busy bit.

Link: https://lore.kernel.org/all/ZPj6iF0Q7iynn62p@google.com/
Fixes: 5413bcba7e ("KVM: x86: Add support for vICR APIC-write VM-Exits in x2APIC mode")
Cc: stable@vger.kernel.org
Signed-off-by: Tao Su <tao1.su@linux.intel.com>
Tested-by: Yi Lai <yi1.lai@intel.com>
Reviewed-by: Chao Gao <chao.gao@intel.com>
Link: https://lore.kernel.org/r/20230914055504.151365-1-tao1.su@linux.intel.com
[sean: tweak changelog, replace TODO with comment, drop local "val"]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:07:08 +00:00
..
boot x86/sev: Check for user-space IOIO pointing to kernel space 2023-10-25 12:03:04 +02:00
coco x86/tdx: Fix race between set_memory_encrypted() and load_unaligned_zeropad() 2023-07-19 16:21:00 +02:00
configs
crypto crypto: x86/sha - load modules based on CPU features 2023-11-28 17:07:07 +00:00
entry x86/mm: Fix VDSO and VVAR placement on 5-level paging machines 2023-08-16 18:27:25 +02:00
events perf/x86/lbr: Filter vsyscall addresses 2023-10-19 23:08:56 +02:00
hyperv x86/hyperv: Disable IBT when hypercall page lacks ENDBR instruction 2023-08-11 12:08:21 +02:00
ia32
include KVM: x86: Ignore MSR_AMD64_TW_CFG access 2023-11-28 17:07:08 +00:00
kernel x86/cpu/hygon: Fix the CPU topology evaluation for real 2023-11-28 17:07:07 +00:00
kvm KVM: x86: Clear bit12 of ICR after APIC-write VM-exit 2023-11-28 17:07:08 +00:00
lib iov_iter, x86: Be consistent about the __user tag on copy_mc_to_user() 2023-11-20 11:51:49 +01:00
math-emu
mm x86/mm: Drop the 4 MB restriction on minimal NUMA node memory size 2023-11-28 17:06:55 +00:00
net bpf: Remove prog->active check for bpf_lsm and bpf_iter 2023-09-19 12:28:03 +02:00
pci
platform x86/efi: Make efi_set_virtual_address_map IBT safe 2023-07-19 16:21:45 +02:00
power
purgatory x86/purgatory: Remove LTO flags 2023-09-23 11:11:09 +02:00
ras
realmode
tools
um
video
virt/vmx/tdx
xen x86/xen: Fix secondary processors' FPU initialization 2023-08-08 20:03:49 +02:00
.gitignore
Kbuild
Kconfig x86/srso: Add a Speculative RAS Overflow mitigation 2023-08-08 20:03:50 +02:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug
Makefile
Makefile.um
Makefile_32.cpu