From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Sean Christopherson <sean.j.christopherson@intel.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 5.7 099/112] x86/split_lock: Dont write MSR_TEST_CTRL on CPUs that arent whitelisted
Date: Tue, 7 Jul 2020 17:17:44 +0200 [thread overview]
Message-ID: <20200707145805.686653891@linuxfoundation.org> (raw)
In-Reply-To: <20200707145800.925304888@linuxfoundation.org>
From: Sean Christopherson <sean.j.christopherson@intel.com>
commit 009bce1df0bb5eb970b9eb98d963861f7fe353c7 upstream.
Choo! Choo! All aboard the Split Lock Express, with direct service to
Wreckage!
Skip split_lock_verify_msr() if the CPU isn't whitelisted as a possible
SLD-enabled CPU model to avoid writing MSR_TEST_CTRL. MSR_TEST_CTRL
exists, and is writable, on many generations of CPUs. Writing the MSR,
even with '0', can result in bizarre, undocumented behavior.
This fixes a crash on Haswell when resuming from suspend with a live KVM
guest. Because APs use the standard SMP boot flow for resume, they will
go through split_lock_init() and the subsequent RDMSR/WRMSR sequence,
which runs even when sld_state==sld_off to ensure SLD is disabled. On
Haswell (at least, my Haswell), writing MSR_TEST_CTRL with '0' will
succeed and _may_ take the SMT _sibling_ out of VMX root mode.
When KVM has an active guest, KVM performs VMXON as part of CPU onlining
(see kvm_starting_cpu()). Because SMP boot is serialized, the resulting
flow is effectively:
on_each_ap_cpu() {
WRMSR(MSR_TEST_CTRL, 0)
VMXON
}
As a result, the WRMSR can disable VMX on a different CPU that has
already done VMXON. This ultimately results in a #UD on VMPTRLD when
KVM regains control and attempt run its vCPUs.
The above voodoo was confirmed by reworking KVM's VMXON flow to write
MSR_TEST_CTRL prior to VMXON, and to serialize the sequence as above.
Further verification of the insanity was done by redoing VMXON on all
APs after the initial WRMSR->VMXON sequence. The additional VMXON,
which should VM-Fail, occasionally succeeded, and also eliminated the
unexpected #UD on VMPTRLD.
The damage done by writing MSR_TEST_CTRL doesn't appear to be limited
to VMX, e.g. after suspend with an active KVM guest, subsequent reboots
almost always hang (even when fudging VMXON), a #UD on a random Jcc was
observed, suspend/resume stability is qualitatively poor, and so on and
so forth.
kernel BUG at arch/x86/kvm/x86.c:386!
CPU: 1 PID: 2592 Comm: CPU 6/KVM Tainted: G D
Hardware name: ASUS Q87M-E/Q87M-E, BIOS 1102 03/03/2014
RIP: 0010:kvm_spurious_fault+0xf/0x20
Call Trace:
vmx_vcpu_load_vmcs+0x1fb/0x2b0
vmx_vcpu_load+0x3e/0x160
kvm_arch_vcpu_load+0x48/0x260
finish_task_switch+0x140/0x260
__schedule+0x460/0x720
_cond_resched+0x2d/0x40
kvm_arch_vcpu_ioctl_run+0x82e/0x1ca0
kvm_vcpu_ioctl+0x363/0x5c0
ksys_ioctl+0x88/0xa0
__x64_sys_ioctl+0x16/0x20
do_syscall_64+0x4c/0x170
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Fixes: dbaba47085b0c ("x86/split_lock: Rework the initialization flow of split lock detection")
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20200605192605.7439-1-sean.j.christopherson@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/kernel/cpu/intel.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -49,6 +49,13 @@ static enum split_lock_detect_state sld_
static u64 msr_test_ctrl_cache __ro_after_init;
/*
+ * With a name like MSR_TEST_CTL it should go without saying, but don't touch
+ * MSR_TEST_CTL unless the CPU is one of the whitelisted models. Writing it
+ * on CPUs that do not support SLD can cause fireworks, even when writing '0'.
+ */
+static bool cpu_model_supports_sld __ro_after_init;
+
+/*
* Processors which have self-snooping capability can handle conflicting
* memory type across CPUs by snooping its own cache. However, there exists
* CPU models in which having conflicting memory types still leads to
@@ -1064,7 +1071,8 @@ static void sld_update_msr(bool on)
static void split_lock_init(void)
{
- split_lock_verify_msr(sld_state != sld_off);
+ if (cpu_model_supports_sld)
+ split_lock_verify_msr(sld_state != sld_off);
}
static void split_lock_warn(unsigned long ip)
@@ -1167,5 +1175,6 @@ void __init cpu_set_core_cap_bits(struct
return;
}
+ cpu_model_supports_sld = true;
split_lock_setup();
}
next prev parent reply other threads:[~2020-07-07 15:27 UTC|newest]
Thread overview: 121+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 15:16 [PATCH 5.7 000/112] 5.7.8-rc1 review Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 001/112] exfat: Set the unused characters of FileName field to the value 0000h Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 002/112] exfat: add missing brelse() calls on error paths Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 003/112] exfat: call sync_filesystem for read-only remount Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 004/112] exfat: move setting VOL_DIRTY over exfat_remove_entries() Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 005/112] exfat: flush dirty metadata in fsync Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 006/112] btrfs: block-group: refactor how we delete one block group item Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 007/112] btrfs: fix race between block group removal and block group creation Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 008/112] mm: fix swap cache node allocation mask Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 009/112] drm/amd/display: Fix incorrectly pruned modes with deep color Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 010/112] drm/amd/display: Fix ineffective setting of max bpc property Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 011/112] seg6: fix seg6_validate_srh() to avoid slab-out-of-bounds Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 012/112] tipc: add test for Nagle algorithm effectiveness Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 013/112] tipc: fix kernel WARNING in tipc_msg_append() Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 014/112] usbnet: smsc95xx: Fix use-after-free after removal Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 015/112] tipc: Fix NULL pointer dereference in __tipc_sendstream() Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 016/112] drm/i915/gt: Mark timeline->cacheline as destroyed after rcu grace period Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 017/112] drm/amdgpu: disable ras query and iject during gpu reset Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 018/112] drm/amdgpu: fix non-pointer dereference for non-RAS supported Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 019/112] drm/amdgpu: fix kernel page fault issue by ras recovery on sGPU Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 020/112] sched/debug: Make sd->flags sysctl read-only Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 021/112] soc: ti: omap-prm: use atomic iopoll instead of sleeping one Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 022/112] powerpc/kvm/book3s: Add helper to walk partition scoped linux page table Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 023/112] powerpc/book3s64/kvm: Fix secondary page table walk warning during migration Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 024/112] mm/slub.c: fix corrupted freechain in deactivate_slab() Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 025/112] mm/slub: fix stack overruns with SLUB_STATS Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 026/112] mm, dump_page(): do not crash with invalid mapping pointer Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 027/112] io_uring: fix {SQ,IO}POLL with unsupported opcodes Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 028/112] rxrpc: Fix race between incoming ACK parser and retransmitter Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 029/112] usb: usbtest: fix missing kfree(dev->buf) in usbtest_disconnect Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 030/112] tools lib traceevent: Add append() function helper for appending strings Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 031/112] tools lib traceevent: Handle __attribute__((user)) in field names Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 032/112] s390/debug: avoid kernel warning on too large number of pages Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 033/112] io_uring: fix io_sq_thread no schedule when busy Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 034/112] nvme-multipath: set bdi capabilities once Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 035/112] nvme: fix possible deadlock when I/O is blocked Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 036/112] nvme-multipath: fix deadlock between ana_work and scan_work Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 037/112] nvme-multipath: fix deadlock due to head->lock Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 038/112] nvme-multipath: fix bogus request queue reference put Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 039/112] io_uring: fix current->mm NULL dereference on exit Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 040/112] kgdb: Avoid suspicious RCU usage warning Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 041/112] Revert "tpm: selftest: cleanup after unseal with wrong auth/policy test" Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 042/112] selftests: tpm: Use /bin/sh instead of /bin/bash Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 043/112] tpm: Fix TIS locality timeout problems Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 044/112] crypto: af_alg - fix use-after-free in af_alg_accept() due to bh_lock_sock() Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 045/112] task_work: teach task_work_add() to do signal_wake_up() Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 046/112] io_uring: use signal based task_work running Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 047/112] drm/msm/dpu: fix error return code in dpu_encoder_init Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 048/112] btrfs: fix RWF_NOWAIT writes blocking on extent locks and waiting for IO Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 049/112] rxrpc: Fix afs large storage transmission performance drop Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 050/112] mptcp: drop MP_JOIN request sock on syn cookies Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 051/112] net: enetc: add hw tc hw offload features for PSPF capability Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 052/112] enetc: Fix HW_VLAN_CTAG_TX|RX toggling Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 053/112] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.7 054/112] RDMA/counter: Query a counter before release Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 055/112] xfs: fix use-after-free on CIL context on shutdown Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 056/112] hsr: remove hsr interface if all slaves are removed Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 057/112] hsr: avoid to create proc file after unregister Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 058/112] cxgb4: use unaligned conversion for fetching timestamp Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 059/112] cxgb4: parse TC-U32 key values and masks natively Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 060/112] cxgb4: fix endian conversions for L4 ports in filters Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 061/112] cxgb4: use correct type for all-mask IP address comparison Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 062/112] cxgb4: fix SGE queue dump destination buffer context Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 063/112] security: Fix hook iteration and default value for inode_copy_up_xattr Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 064/112] hwmon: (max6697) Make sure the OVERT mask is set correctly Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 065/112] hwmon: (acpi_power_meter) Fix potential memory leak in acpi_power_meter_add() Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 066/112] scsi: qla2xxx: Fix a condition in qla2x00_find_all_fabric_devs() Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 067/112] thermal/drivers/mediatek: Fix bank number settings on mt8183 Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 068/112] thermal/drivers/sprd: Fix return value of sprd_thm_probe() Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 069/112] thermal/drivers/rcar_gen3: Fix undefined temperature if negative Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 070/112] kthread: save thread function Greg Kroah-Hartman
2020-07-07 15:32 ` J. Bruce Fields
2020-07-07 15:17 ` [PATCH 5.7 071/112] nfsd: clients dont need to break their own delegations Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 072/112] nfsd4: fix nfsdfs reference count loop Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 073/112] nfsd: fix nfsdfs inode reference count leak Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 074/112] drm: sun4i: hdmi: Remove extra HPD polling Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 075/112] virtio-blk: free vblk-vqs in error path of virtblk_probe() Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 076/112] SMB3: Honor posix flag for multiuser mounts Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 077/112] nvme: fix identify error status silent ignore Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 078/112] nvme: fix a crash in nvme_mpath_add_disk Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 079/112] tpm: ibmvtpm: Wait for ready buffer before probing for TPM2 attributes Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 080/112] samples/vfs: avoid warning in statx override Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 081/112] i2c: algo-pca: Add 0x78 as SCL stuck low status for PCA9665 Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 082/112] i2c: designware: platdrv: Set class based on DMI Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 083/112] i2c: mlxcpld: check correct size of maximum RECV_LEN packet Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 084/112] io_uring: fix regression with always ignoring signals in io_cqring_wait() Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 085/112] spi: spi-fsl-dspi: Fix external abort on interrupt in resume or exit paths Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 086/112] nfsd: apply umask on fs without ACL support Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 087/112] Revert "ALSA: usb-audio: Improve frames size computation" Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 088/112] padata: upgrade smp_mb__after_atomic to smp_mb in padata_do_serial Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 089/112] SMB3: Honor seal flag for multiuser mounts Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 090/112] SMB3: Honor persistent/resilient handle flags " Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 091/112] SMB3: Honor lease disabling " Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 092/112] SMB3: Honor handletimeout flag " Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 093/112] cifs: Fix the target file was deleted when rename failed Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 094/112] Drivers: hv: Change flag to write log level in panic msg to false Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 095/112] hwmon: (pmbus) Fix page vs. register when accessing fans Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 096/112] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 097/112] ACPI: fan: Fix Tiger Lake ACPI device ID Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 098/112] gfs2: fix trans slab error when withdraw occurs inside log_flush Greg Kroah-Hartman
2020-07-07 15:17 ` Greg Kroah-Hartman [this message]
2020-07-07 15:17 ` [PATCH 5.7 100/112] MIPS: lantiq: xway: sysctrl: fix the GPHY clock alias names Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 101/112] MIPS: Add missing EHB in mtc0 -> mfc0 sequence for DSPen Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 102/112] drm/i915: Include asm sources for {ivb, hsw}_clear_kernel.c Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 103/112] drm/amd/powerplay: Fix NULL dereference in lock_bus() on Vega20 w/o RAS Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 104/112] drm/amd/display: Only revalidate bandwidth on medium and fast updates Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 105/112] drm/amdgpu: use %u rather than %d for sclk/mclk Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 106/112] drm/amdgpu/atomfirmware: fix vram_info fetching for renoir Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 107/112] dma-buf: Move dma_buf_release() from fops to dentry_ops Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 108/112] irqchip/gic: Atomically update affinity Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 109/112] mm/hugetlb.c: fix pages per hugetlb calculation Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 110/112] mm/cma.c: use exact_nid true to fix possible per-numa cma leak Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 111/112] dm zoned: assign max_io_len correctly Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.7 112/112] efi: Make it possible to disable efivar_ssdt entirely Greg Kroah-Hartman
2020-07-08 5:08 ` [PATCH 5.7 000/112] 5.7.8-rc1 review Naresh Kamboju
2020-07-08 15:16 ` Greg Kroah-Hartman
2020-07-08 13:05 ` Shuah Khan
2020-07-08 15:28 ` Greg Kroah-Hartman
2020-07-08 15:33 ` Puranjay Mohan
2020-07-08 17:53 ` Guenter Roeck
2020-07-09 9:29 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200707145805.686653891@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sean.j.christopherson@intel.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox