stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, "Radim Krčmář" <rkrcmar@redhat.com>,
	"Jiri Slaby" <jslaby@suse.cz>
Subject: [PATCH 3.12 66/84] KVM: nVMX: postpone VMCS changes on MSR_IA32_APICBASE write
Date: Mon, 17 Oct 2016 09:51:53 +0200	[thread overview]
Message-ID: <f6829ed2fa5287b378c9bd0ad24d43861c69070c.1476690493.git.jslaby@suse.cz> (raw)
In-Reply-To: <2d291fde5f706ac081e8cfc0ebe7e31dd534dfe7.1476690493.git.jslaby@suse.cz>
In-Reply-To: <cover.1476690493.git.jslaby@suse.cz>

From: Radim Krčmář <rkrcmar@redhat.com>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

commit dccbfcf52cebb8963246eba5b177b77f26b34da0 upstream.

If vmcs12 does not intercept APIC_BASE writes, then KVM will handle the
write with vmcs02 as the current VMCS.
This will incorrectly apply modifications intended for vmcs01 to vmcs02
and L2 can use it to gain access to L0's x2APIC registers by disabling
virtualized x2APIC while using msr bitmap that assumes enabled.

Postpone execution of vmx_set_virtual_x2apic_mode until vmcs01 is the
current VMCS.  An alternative solution would temporarily make vmcs01 the
current VMCS, but it requires more care.

Fixes: 8d14695f9542 ("x86, apicv: add virtual x2apic support")
Reported-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/x86/kvm/vmx.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 92f9e2abf710..b81c81bce181 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -366,6 +366,7 @@ struct nested_vmx {
 	struct list_head vmcs02_pool;
 	int vmcs02_num;
 	u64 vmcs01_tsc_offset;
+	bool change_vmcs01_virtual_x2apic_mode;
 	/* L2 must run next, and mustn't decide to exit to L1. */
 	bool nested_run_pending;
 	/*
@@ -6861,6 +6862,12 @@ static void vmx_set_virtual_x2apic_mode(struct kvm_vcpu *vcpu, bool set)
 {
 	u32 sec_exec_control;
 
+	/* Postpone execution until vmcs01 is the current VMCS. */
+	if (is_guest_mode(vcpu)) {
+		to_vmx(vcpu)->nested.change_vmcs01_virtual_x2apic_mode = true;
+		return;
+	}
+
 	/*
 	 * There is not point to enable virtualize x2apic without enable
 	 * apicv
@@ -8367,6 +8374,12 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu)
 	/* Update TSC_OFFSET if TSC was changed while L2 ran */
 	vmcs_write64(TSC_OFFSET, vmx->nested.vmcs01_tsc_offset);
 
+	if (vmx->nested.change_vmcs01_virtual_x2apic_mode) {
+		vmx->nested.change_vmcs01_virtual_x2apic_mode = false;
+		vmx_set_virtual_x2apic_mode(vcpu,
+				vcpu->arch.apic_base & X2APIC_ENABLE);
+	}
+
 	/* This is needed for same reason as it was needed in prepare_vmcs02 */
 	vmx->host_rsp = 0;
 
-- 
2.10.1

  parent reply	other threads:[~2016-10-17  7:51 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161017075200uscas1p10599639cc97e9b6e31f03c62f9c628c3@uscas1p1.samsung.com>
2016-10-17  7:51 ` [PATCH 3.12 00/84] 3.12.65-stable review Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 01/84] gcov: disable tree-loop-im to reduce stack usage Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 02/84] reiserfs: fix "new_insert_key may be used uninitialized ..." Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 03/84] crypto: skcipher - Fix blkcipher walk OOM crash Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 04/84] ocfs2/dlm: fix race between convert and migration Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 05/84] ocfs2: fix start offset to ocfs2_zero_range_for_truncate() Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 06/84] kbuild: Do not run modules_install and install in paralel Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 07/84] Makefile: revert "Makefile: Document ability to make file.lst and file.S" partially Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 08/84] kbuild: forbid kernel directory to contain spaces and colons Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 09/84] Kbuild: disable 'maybe-uninitialized' warning for CONFIG_PROFILE_ALL_BRANCHES Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 10/84] gcov: disable -Wmaybe-uninitialized warning Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 11/84] Disable "maybe-uninitialized" warning globally Jiri Slaby
2016-10-17  7:50   ` [PATCH 3.12 12/84] Disable "frame-address" warning Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 13/84] Makefile: Mute warning for __builtin_return_address(>0) for tracing only Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 14/84] net: caif: fix misleading indentation Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 15/84] iwlegacy: avoid warning about missing braces Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 16/84] Staging: iio: adc: fix indent on break statement Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 17/84] fix fault_in_multipages_...() on architectures with no-op access_ok() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 18/84] mtd: pmcmsp-flash: Allocating too much in init_msp_flash() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 19/84] fix memory leaks in tracing_buffers_splice_read() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 20/84] tracing: Move mutex to protect against resetting of seq data Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 21/84] can: flexcan: fix resume function Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 22/84] btrfs: ensure that file descriptor used with subvol ioctls is a dir Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 23/84] i2c-eg20t: fix race between i2c init and interrupt enable Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 24/84] qxl: check for kmap failures Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 25/84] hostfs: Freeing an ERR_PTR in hostfs_fill_sb_common() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 26/84] sched/core: Fix a race between try_to_wake_up() and a woken up task Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 27/84] CRIS: Fix headers_install Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 28/84] powerpc/ps3: Remove unused os_area_db_id_video_mode Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 29/84] powerpc/ptrace: Fix out of bounds array access warning Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 30/84] ppp: defer netns reference release for ppp channel Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 31/84] iommu/amd: Update Alias-DTE in update_device_table() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 32/84] clockevents: export clockevents_unbind_device instead of clockevents_unbind Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 33/84] kernel/fork: fix CLONE_CHILD_CLEARTID regression in nscd Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 34/84] NFSD: Using free_conn free connection Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 35/84] kaweth: fix firmware download Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 36/84] IB/srpt: Simplify srpt_handle_tsk_mgmt() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 37/84] xfs: fixed signedness of error code in xfs_inode_buf_verify Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 38/84] sched/core: Fix an SMP ordering race in try_to_wake_up() vs. schedule() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 39/84] powerpc: Add macros for the ibm_architecture_vec[] lengths Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 40/84] mtd: nand: davinci: Reinitialize the HW ECC engine in 4bit hwctl Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 41/84] mm,ksm: fix endless looping in allocating memory when ksm enable Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 42/84] can: dev: fix deadlock reported after bus-off Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 43/84] drm/radeon/si/dpm: add workaround for for Jet parts Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 44/84] ARM: 8616/1: dt: Respect property size when parsing CPUs Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 45/84] tools/vm/slabinfo: fix an unintentional printf Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 46/84] hwmon: (adt7411) set bit 3 in CFG1 register Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 47/84] iwlwifi: pcie: fix access to scratch buffer Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 48/84] usb: gadget: fsl_qe_udc: signedness bug in qe_get_frame() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 49/84] ARM: 8618/1: decompressor: reset ttbcr fields to use TTBR0 on ARMv7 Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 50/84] arm64: debug: avoid resetting stepping state machine when TIF_SINGLESTEP Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 51/84] MIPS: Malta: Fix IOCU disable switch read for MIPS64 Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 52/84] printk: fix parsing of "brl=" option Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 53/84] ARM: sa1100: clear reset status prior to reboot Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 54/84] ARM: sa1111: fix pcmcia suspend/resume Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 55/84] hwrng: omap - Fix assumption that runtime_get_sync will always succeed Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 56/84] tile: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 57/84] em28xx-i2c: rt_mutex_trylock() returns zero on failure Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 58/84] gspca: avoid unused variable warnings Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 59/84] avr32: off by one in at32_init_pio() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 60/84] svc: Avoid garbage replies when pc_func() returns rpc_drop_reply Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 61/84] NFS: Don't drop CB requests with invalid principals Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 62/84] brcmsmac: Free packet if dma_mapping_error() fails in dma_rxfill Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 63/84] brcmsmac: Initialize power in brcms_c_stf_ss_algo_channel_get() Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 64/84] powerpc/prom: Fix sub-processor option passed to ibm, client-architecture-support Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 65/84] ASoC: omap-mcpdm: Fix irq resource handling Jiri Slaby
2016-10-17  7:51   ` Jiri Slaby [this message]
2016-10-17  7:51   ` [PATCH 3.12 67/84] IB/ipoib: Fix memory corruption in ipoib cm mode connect flow Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 68/84] IB/core: Fix use after free in send_leave function Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 69/84] IB/ipoib: Don't allow MC joins during light MC flush Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 70/84] IB/mlx4: Fix incorrect MC join state bit-masking on SR-IOV Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 71/84] USB: serial: cp210x: fix hardware flow-control disable Jiri Slaby
2016-10-17  7:51   ` [PATCH 3.12 72/84] usb: misc: legousbtower: Fix NULL pointer deference Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 73/84] USB: serial: cp210x: Add ID for a Juniper console Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 74/84] Revert "usbtmc: convert to devm_kzalloc" Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 75/84] ACPICA: acpi_get_sleep_type_data: Reduce warnings Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 76/84] security: let security modules use PTRACE_MODE_* with bitmasks Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 77/84] KVM: PPC: Book3S PR: Ignore PMU SPRs Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 78/84] KVM: PPC: Book3S PR: Emulate TIR register Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 79/84] ALSA: ali5451: Fix out-of-bound position reporting Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 80/84] ALSA: usb-line6: use the same declaration as definition in header for MIDI manufacturer ID Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 81/84] mfd: 88pm80x: Double shifting bug in suspend/resume Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 82/84] mfd: wm8350-i2c: Make sure the i2c regmap functions are compiled Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 83/84] KVM: PPC: Book3s PR: Allow access to unprivileged MMCR2 register Jiri Slaby
2016-10-17  7:52   ` [PATCH 3.12 84/84] KVM: MIPS: Drop other CPU ASIDs on guest MMU changes Jiri Slaby
2016-10-17 18:29   ` [PATCH 3.12 00/84] 3.12.65-stable review Guenter Roeck
2016-10-17 22:10   ` Shuah Khan

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=f6829ed2fa5287b378c9bd0ad24d43861c69070c.1476690493.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    --cc=stable@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).