linux-stable/arch/x86/kvm
Maciej S. Szmigiero 01d004afbe KVM: x86: Ignore MSR_AMD64_TW_CFG access
commit 2770d47220 upstream.

Hyper-V enabled Windows Server 2022 KVM VM cannot be started on Zen1 Ryzen
since it crashes at boot with SYSTEM_THREAD_EXCEPTION_NOT_HANDLED +
STATUS_PRIVILEGED_INSTRUCTION (in other words, because of an unexpected #GP
in the guest kernel).

This is because Windows tries to set bit 8 in MSR_AMD64_TW_CFG and can't
handle receiving a #GP when doing so.

Give this MSR the same treatment that commit 2e32b71906
("x86, kvm: Add MSR_AMD64_BU_CFG2 to the list of ignored MSRs") gave
MSR_AMD64_BU_CFG2 under justification that this MSR is baremetal-relevant
only.
Although apparently it was then needed for Linux guests, not Windows as in
this case.

With this change, the aforementioned guest setup is able to finish booting
successfully.

This issue can be reproduced either on a Summit Ridge Ryzen (with
just "-cpu host") or on a Naples EPYC (with "-cpu host,stepping=1" since
EPYC is ordinarily stepping 2).

Alternatively, userspace could solve the problem by using MSR filters, but
forcing every userspace to define a filter isn't very friendly and doesn't
add much, if any, value.  The only potential hiccup is if one of these
"baremetal-only" MSRs ever requires actual emulation and/or has F/M/S
specific behavior.  But if that happens, then KVM can still punt *that*
handling to userspace since userspace MSR filters "win" over KVM's default
handling.

Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/1ce85d9c7c9e9632393816cf19c902e0a3f411f1.1697731406.git.maciej.szmigiero@oracle.com
[sean: call out MSR filtering alternative]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 16:45:44 +00:00
..
cpuid.c KVM: x86: Mask off reserved bits in CPUID.80000008H 2022-11-10 15:47:23 +01:00
cpuid.h x86/cpufeatures: Combine word 11 and 12 into a new scattered features word 2019-08-06 19:05:29 +02:00
debugfs.c
emulate.c KVM: x86: emulator: update the emulation mode after CR0 write 2022-11-10 15:47:24 +01:00
hyperv.c KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq 2022-08-25 11:11:29 +02:00
hyperv.h
i8254.c
i8254.h
i8259.c KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks 2020-02-14 16:32:15 -05:00
ioapic.c Revert "x86/kvm: fix vcpu-id indexed array sizes" 2021-11-12 14:28:23 +01:00
ioapic.h Revert "x86/kvm: fix vcpu-id indexed array sizes" 2021-11-12 14:28:23 +01:00
irq.c
irq.h
irq_comm.c KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI 2020-02-28 16:36:12 +01:00
Kconfig
kvm_cache_regs.h KVM: x86: Mark CR4.TSD as being possibly owned by the guest 2020-07-22 09:22:18 +02:00
lapic.c KVM: x86: Mask LVTPC when handling a PMI 2023-10-25 11:13:31 +02:00
lapic.h kvm: vmx: Introduce lapic_mode enumeration 2019-10-29 09:17:46 +01:00
Makefile
mmu.c KVM: x86/mmu: Treat NX as used (not reserved) for all !TDP shadow MMUs 2021-09-03 09:56:26 +02:00
mmu.h KVM: x86: fix shift out of bounds reported by UBSAN 2021-01-12 20:09:14 +01:00
mmu_audit.c
mmutrace.h KVM: x86: fix incorrect comparison in trace event 2020-10-01 13:12:35 +02:00
mtrr.c KVM: x86: Protect MSR-based index computations in fixed_msr_to_seg_unit() from Spectre-v1/L1TF attacks 2020-02-14 16:32:16 -05:00
page_track.c
paging_tmpl.h KVM: X86: MMU: Use the correct inherited permissions to get shadow page 2021-09-03 09:56:26 +02:00
pmu.c KVM: x86/pmu: Use AMD64_RAW_EVENT_MASK for PERF_TYPE_RAW 2022-02-23 11:57:36 +01:00
pmu.h KVM: x86: Protect MSR-based index computations in pmu.h from Spectre-v1/L1TF attacks 2020-02-14 16:32:15 -05:00
pmu_amd.c KVM: x86/svm: Clear reserved bits written to PerfEvtSeln MSRs 2022-04-20 09:08:26 +02:00
pmu_intel.c KVM: x86/pmu: Fix HW_REF_CPU_CYCLES event pseudo-encoding in intel_arch_events[] 2021-02-03 23:22:21 +01:00
svm.c x86/cpu: Restore AMD's DE_CFG MSR after resume 2022-11-25 17:36:48 +01:00
trace.h KVM: x86: avoid misreporting level-triggered irqs as edge-triggered in tracing 2019-05-16 19:42:22 +02:00
tss.h
vmx.c x86/speculation: Add RSB VM Exit protections 2022-11-01 19:14:46 +01:00
x86.c KVM: x86: Ignore MSR_AMD64_TW_CFG access 2023-11-28 16:45:44 +00:00
x86.h KVM: x86: introduce is_pae_paging 2019-11-20 17:59:23 +01:00