linux/arch/x86/kernel/cpu
Sean Christopherson bf09fb6cba KVM: VMX: Stop context switching MSR_IA32_UMWAIT_CONTROL
Remove support for context switching between the guest's and host's
desired UMWAIT_CONTROL.  Propagating the guest's value to hardware isn't
required for correct functionality, e.g. KVM intercepts reads and writes
to the MSR, and the latency effects of the settings controlled by the
MSR are not architecturally visible.

As a general rule, KVM should not allow the guest to control power
management settings unless explicitly enabled by userspace, e.g. see
KVM_CAP_X86_DISABLE_EXITS.  E.g. Intel's SDM explicitly states that C0.2
can improve the performance of SMT siblings.  A devious guest could
disable C0.2 so as to improve the performance of their workloads at the
detriment to workloads running in the host or on other VMs.

Wholesale removal of UMWAIT_CONTROL context switching also fixes a race
condition where updates from the host may cause KVM to enter the guest
with the incorrect value.  Because updates are are propagated to all
CPUs via IPI (SMP function callback), the value in hardware may be
stale with respect to the cached value and KVM could enter the guest
with the wrong value in hardware.  As above, the guest can't observe the
bad value, but it's a weird and confusing wart in the implementation.

Removal also fixes the unnecessary usage of VMX's atomic load/store MSR
lists.  Using the lists is only necessary for MSRs that are required for
correct functionality immediately upon VM-Enter/VM-Exit, e.g. EFER on
old hardware, or for MSRs that need to-the-uop precision, e.g. perf
related MSRs.  For UMWAIT_CONTROL, the effects are only visible in the
kernel via TPAUSE/delay(), and KVM doesn't do any form of delay in
vcpu_vmx_run().  Using the atomic lists is undesirable as they are more
expensive than direct RDMSR/WRMSR.

Furthermore, even if giving the guest control of the MSR is legitimate,
e.g. in pass-through scenarios, it's not clear that the benefits would
outweigh the overhead.  E.g. saving and restoring an MSR across a VMX
roundtrip costs ~250 cycles, and if the guest diverged from the host
that cost would be paid on every run of the guest.  In other words, if
there is a legitimate use case then it should be enabled by a new
per-VM capability.

Note, KVM still needs to emulate MSR_IA32_UMWAIT_CONTROL so that it can
correctly expose other WAITPKG features to the guest, e.g. TPAUSE,
UMWAIT and UMONITOR.

Fixes: 6e3ba4abce ("KVM: vmx: Emulate MSR IA32_UMWAIT_CONTROL")
Cc: stable@vger.kernel.org
Cc: Jingqi Liu <jingqi.liu@intel.com>
Cc: Tao Xu <tao3.xu@intel.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Message-Id: <20200623005135.10414-1-sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-06-22 20:54:57 -04:00
..
mce x86/mce/dev-mcelog: Fix -Wstringop-truncation warning about strncpy() 2020-06-11 15:19:17 +02:00
microcode x86/microcode: Fix return value for microcode late loading 2020-04-22 19:55:50 +02:00
mtrr x86/tlb: Move __flush_tlb() out of line 2020-04-26 11:00:05 +02:00
resctrl mmap locking API: convert mmap_sem comments 2020-06-09 09:39:14 -07:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
acrn.c x86/entry: Convert various hypervisor vectors to IDTENTRY_SYSVEC 2020-06-11 15:15:15 +02:00
amd.c Misc updates: 2020-06-01 13:57:51 -07:00
aperfmperf.c x86/cpu: Disable frequency requests via aperfmperf IPI for nohz_full CPUs 2019-06-22 17:23:48 +02:00
bugs.c A set of fixes and updates for x86: 2020-06-11 15:54:31 -07:00
cacheinfo.c x86/cacheinfo: Fix a -Wtype-limits warning 2019-06-19 19:21:32 +02:00
centaur.c x86/cpu: Remove redundant cpu_detect_cache_sizes() call 2020-01-20 16:32:35 +01:00
common.c x86/entry: Remove debug IDT frobbing 2020-06-11 15:15:23 +02:00
cpu.h x86/speculation: Add Special Register Buffer Data Sampling (SRBDS) mitigation 2020-04-20 12:19:22 +02:00
cpuid-deps.c x86/cpufeatures: Enable a new AVX512 CPU feature 2019-07-22 10:38:25 +02:00
cyrix.c x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors 2019-03-21 12:28:50 +01:00
feat_ctl.c x86/cpu: Fix a -Wmissing-prototypes warning for init_ia32_feat_ctl() 2020-03-23 12:01:59 +01:00
hygon.c x86: Remove X86_FEATURE_MFENCE_RDTSC 2019-07-22 12:00:51 +02:00
hypervisor.c x86/paravirt: Remove const mark from x86_hyper_xen_hvm variable 2019-07-17 08:09:59 +02:00
intel.c A set of fixes and updates for x86: 2020-06-11 15:54:31 -07:00
intel_epb.c x86: intel_epb: Do not build when CONFIG_PM is unset 2019-05-30 10:58:36 +02:00
intel_pconfig.c x86/pconfig: Detect PCONFIG targets 2018-03-12 12:10:54 +01:00
Makefile Merge branch 'x86/kdump' into locking/kcsan, to resolve conflicts 2020-03-21 09:24:41 +01:00
match.c x86/cpu: Add a steppings field to struct x86_cpu_id 2020-04-20 12:19:21 +02:00
mkcapflags.sh x86/cpu: Print VMX flags in /proc/cpuinfo using VMX_FEATURES_* 2020-01-13 18:36:02 +01:00
mshyperv.c x86/entry: Convert various hypervisor vectors to IDTENTRY_SYSVEC 2020-06-11 15:15:15 +02:00
perfctr-watchdog.c x86/perf: Add hardware performance events support for Zhaoxin CPU. 2020-04-30 20:14:35 +02:00
powerflags.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
proc.c x86/cpu: Print VMX flags in /proc/cpuinfo using VMX_FEATURES_* 2020-01-13 18:36:02 +01:00
rdrand.c x86/rdrand: Sanity-check RDRAND output 2019-10-01 19:55:32 +02:00
scattered.c x86/mm/pat: Rename <asm/pat.h> => <asm/memtype.h> 2019-12-10 10:12:55 +01:00
topology.c x86/mm/pat: Rename <asm/pat.h> => <asm/memtype.h> 2019-12-10 10:12:55 +01:00
transmeta.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tsx.c Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 12:46:42 -08:00
umc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
umwait.c KVM: VMX: Stop context switching MSR_IA32_UMWAIT_CONTROL 2020-06-22 20:54:57 -04:00
vmware.c x86/vmware: Use bool type for vmw_sched_clock 2020-03-24 10:29:22 +01:00
zhaoxin.c x86/cpu: Remove redundant cpu_detect_cache_sizes() call 2020-01-20 16:32:35 +01:00