linux-stable/arch
Vitaly Kuznetsov 4736d85f0d KVM: x86: Use actual kvm_cpuid.base for clearing KVM_FEATURE_PV_UNHALT
Commit ee3a5f9e3d ("KVM: x86: Do runtime CPUID update before updating
vcpu->arch.cpuid_entries") moved tweaking of the supplied CPUID
data earlier in kvm_set_cpuid() but __kvm_update_cpuid_runtime() actually
uses 'vcpu->arch.kvm_cpuid' (though __kvm_find_kvm_cpuid_features()) which
gets set later in kvm_set_cpuid(). In some cases, e.g. when kvm_set_cpuid()
is called for the first time and 'vcpu->arch.kvm_cpuid' is clear,
__kvm_find_kvm_cpuid_features() fails to find KVM PV feature entry and the
logic which clears KVM_FEATURE_PV_UNHALT after enabling
KVM_X86_DISABLE_EXITS_HLT does not work.

The logic, introduced by the commit ee3a5f9e3d ("KVM: x86: Do runtime
CPUID update before updating vcpu->arch.cpuid_entries") must stay: the
supplied CPUID data is tweaked by KVM first (__kvm_update_cpuid_runtime())
and checked later (kvm_check_cpuid()) and the actual data
(vcpu->arch.cpuid_*, vcpu->arch.kvm_cpuid, vcpu->arch.xen.cpuid,..) is only
updated on success.

Switch to searching for KVM_SIGNATURE in the supplied CPUID data to
discover KVM PV feature entry instead of using stale 'vcpu->arch.kvm_cpuid'.

While on it, drop pointless "&& (best->eax & (1 << KVM_FEATURE_PV_UNHALT)"
check when clearing KVM_FEATURE_PV_UNHALT bit.

Fixes: ee3a5f9e3d ("KVM: x86: Do runtime CPUID update before updating vcpu->arch.cpuid_entries")
Reported-and-tested-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://lore.kernel.org/r/20240228101837.93642-3-vkuznets@redhat.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
2024-03-06 09:50:15 -08:00
..
alpha RTC for 6.8 2024-01-18 17:25:39 -08:00
arc IOMMU Updates for Linux v6.8 2024-01-18 15:16:57 -08:00
arm Samsung fixes for v6.8 2024-01-25 18:23:10 +01:00
arm64 Samsung fixes for v6.8 2024-01-25 18:23:10 +01:00
csky vfs-6.8.netfs 2024-01-19 09:10:23 -08:00
hexagon asm-generic cleanups for 6.8 2024-01-10 18:13:44 -08:00
loongarch LoongArch: KVM: Add returns to SIMD stubs 2024-01-26 16:22:07 +08:00
m68k percpu: 2024-01-18 15:01:28 -08:00
microblaze Microblaze patches for 6.8-rc1 2024-01-17 11:27:23 -08:00
mips mips: Call lose_fpu(0) before initializing fcr31 in mips_set_personality_nan 2024-01-27 11:08:04 +01:00
nios2 percpu: 2024-01-18 15:01:28 -08:00
openrisc
parisc percpu: 2024-01-18 15:01:28 -08:00
powerpc powerpc fixes for 6.8 #2 2024-01-21 11:04:29 -08:00
riscv Arm SoC fixes for 6.8, part 1 2024-01-26 13:09:38 -08:00
s390 vfs-6.8.netfs 2024-01-19 09:10:23 -08:00
sh sh updates for v6.8 2024-01-20 09:24:06 -08:00
sparc sparc: Use device_get_match_data() 2024-01-19 08:08:53 -06:00
um TTY/Serial changes for 6.8-rc1 2024-01-18 11:37:24 -08:00
x86 KVM: x86: Use actual kvm_cpuid.base for clearing KVM_FEATURE_PV_UNHALT 2024-03-06 09:50:15 -08:00
xtensa percpu: 2024-01-18 15:01:28 -08:00
.gitignore
Kconfig IOMMU Updates for Linux v6.8 2024-01-18 15:16:57 -08:00