WSL2-Linux-Kernel/arch/x86
Paolo Bonzini e3cdaab5ff KVM: x86: SVM: fix nested PAUSE filtering when L0 intercepts PAUSE
Commit 74fd41ed16 ("KVM: x86: nSVM: support PAUSE filtering when L0
doesn't intercept PAUSE") introduced passthrough support for nested pause
filtering, (when the host doesn't intercept PAUSE) (either disabled with
kvm module param, or disabled with '-overcommit cpu-pm=on')

Before this commit, L1 KVM didn't intercept PAUSE at all; afterwards,
the feature was exposed as supported by KVM cpuid unconditionally, thus
if L1 could try to use it even when the L0 KVM can't really support it.

In this case the fallback caused KVM to intercept each PAUSE instruction;
in some cases, such intercept can slow down the nested guest so much
that it can fail to boot.  Instead, before the problematic commit KVM
was already setting both thresholds to 0 in vmcb02, but after the first
userspace VM exit shrink_ple_window was called and would reset the
pause_filter_count to the default value.

To fix this, change the fallback strategy - ignore the guest threshold
values, but use/update the host threshold values unless the guest
specifically requests disabling PAUSE filtering (either simple or
advanced).

Also fix a minor bug: on nested VM exit, when PAUSE filter counter
were copied back to vmcb01, a dirty bit was not set.

Thanks a lot to Suravee Suthikulpanit for debugging this!

Fixes: 74fd41ed16 ("KVM: x86: nSVM: support PAUSE filtering when L0 doesn't intercept PAUSE")
Reported-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Tested-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Co-developed-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20220518072709.730031-1-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-06-09 10:52:21 -04:00
..
boot Follow-up tweaks for the EFI changes in v5.19 2022-06-03 13:39:30 -07:00
coco
configs
crypto
entry
events Two small perf updates: 2022-06-05 10:40:31 -07:00
hyperv
ia32
include KVM: x86: inhibit APICv/AVIC on changes to APIC ID or APIC base 2022-06-09 10:52:18 -04:00
kernel Hot fixes for 5.19-rc1. 2022-06-05 17:05:38 -07:00
kvm KVM: x86: SVM: fix nested PAUSE filtering when L0 intercepts PAUSE 2022-06-09 10:52:21 -04:00
lib Not a lot of material this cycle. Many singleton patches against various 2022-05-27 11:22:03 -07:00
math-emu
mm Use PAGE_ALIGNED() instead of open coding it in the x86/mm code. 2022-06-05 10:57:35 -07:00
net
pci pci-v5.19-changes 2022-05-27 15:25:10 -07:00
platform arch/x86: replace cpumask_weight with cpumask_empty where appropriate 2022-06-03 06:52:57 -07:00
power
purgatory
ras
realmode
tools
um um: Fix out-of-bounds read in LDT setup 2022-05-27 09:03:41 +02:00
video
virt/vmx/tdx
xen More power management updates for 5.19-rc1 2022-05-30 11:37:26 -07:00
.gitignore
Kbuild
Kconfig X86 microcode updates: 2022-06-05 10:55:23 -07:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug
Makefile Kbuild updates for v5.19 2022-05-26 12:09:50 -07:00
Makefile.um
Makefile_32.cpu