From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Greg KH <gregkh@linuxfoundation.org>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Marcelo Tosatti <mtosatti@redhat.com>,
Orit Wasserman <owasserm@rehdat.com>, Avi Kivity <avi@redhat.com>
Subject: [ 44/46] KVM: VMX: Fix KVM_SET_SREGS with big real mode segments
Date: Sun, 19 Aug 2012 20:59:20 -0700 [thread overview]
Message-ID: <20120820035838.375306085@linuxfoundation.org> (raw)
In-Reply-To: <20120820035832.274275502@linuxfoundation.org>
From: Greg KH <gregkh@linuxfoundation.org>
3.5-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orit Wasserman <owasserm@redhat.com>
(cherry picked from commit b246dd5df139501b974bd6b28f7815e53b3a792f)
For example migration between Westmere and Nehelem hosts, caught in big real mode.
The code that fixes the segments for real mode guest was moved from enter_rmode
to vmx_set_segments. enter_rmode calls vmx_set_segments for each segment.
Signed-off-by: Orit Wasserman <owasserm@rehdat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/kvm/vmx.c | 74 ++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 60 insertions(+), 14 deletions(-)
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -615,6 +615,10 @@ static void kvm_cpu_vmxon(u64 addr);
static void kvm_cpu_vmxoff(void);
static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3);
static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr);
+static void vmx_set_segment(struct kvm_vcpu *vcpu,
+ struct kvm_segment *var, int seg);
+static void vmx_get_segment(struct kvm_vcpu *vcpu,
+ struct kvm_segment *var, int seg);
static DEFINE_PER_CPU(struct vmcs *, vmxarea);
static DEFINE_PER_CPU(struct vmcs *, current_vmcs);
@@ -2763,6 +2767,7 @@ static void enter_rmode(struct kvm_vcpu
{
unsigned long flags;
struct vcpu_vmx *vmx = to_vmx(vcpu);
+ struct kvm_segment var;
if (enable_unrestricted_guest)
return;
@@ -2806,20 +2811,23 @@ static void enter_rmode(struct kvm_vcpu
if (emulate_invalid_guest_state)
goto continue_rmode;
- vmcs_write16(GUEST_SS_SELECTOR, vmcs_readl(GUEST_SS_BASE) >> 4);
- vmcs_write32(GUEST_SS_LIMIT, 0xffff);
- vmcs_write32(GUEST_SS_AR_BYTES, 0xf3);
-
- vmcs_write32(GUEST_CS_AR_BYTES, 0xf3);
- vmcs_write32(GUEST_CS_LIMIT, 0xffff);
- if (vmcs_readl(GUEST_CS_BASE) == 0xffff0000)
- vmcs_writel(GUEST_CS_BASE, 0xf0000);
- vmcs_write16(GUEST_CS_SELECTOR, vmcs_readl(GUEST_CS_BASE) >> 4);
-
- fix_rmode_seg(VCPU_SREG_ES, &vmx->rmode.es);
- fix_rmode_seg(VCPU_SREG_DS, &vmx->rmode.ds);
- fix_rmode_seg(VCPU_SREG_GS, &vmx->rmode.gs);
- fix_rmode_seg(VCPU_SREG_FS, &vmx->rmode.fs);
+ vmx_get_segment(vcpu, &var, VCPU_SREG_SS);
+ vmx_set_segment(vcpu, &var, VCPU_SREG_SS);
+
+ vmx_get_segment(vcpu, &var, VCPU_SREG_CS);
+ vmx_set_segment(vcpu, &var, VCPU_SREG_CS);
+
+ vmx_get_segment(vcpu, &var, VCPU_SREG_ES);
+ vmx_set_segment(vcpu, &var, VCPU_SREG_ES);
+
+ vmx_get_segment(vcpu, &var, VCPU_SREG_DS);
+ vmx_set_segment(vcpu, &var, VCPU_SREG_DS);
+
+ vmx_get_segment(vcpu, &var, VCPU_SREG_GS);
+ vmx_set_segment(vcpu, &var, VCPU_SREG_GS);
+
+ vmx_get_segment(vcpu, &var, VCPU_SREG_FS);
+ vmx_set_segment(vcpu, &var, VCPU_SREG_FS);
continue_rmode:
kvm_mmu_reset_context(vcpu);
@@ -3222,6 +3230,44 @@ static void vmx_set_segment(struct kvm_v
vmcs_write32(sf->ar_bytes, ar);
__clear_bit(VCPU_EXREG_CPL, (ulong *)&vcpu->arch.regs_avail);
+
+ /*
+ * Fix segments for real mode guest in hosts that don't have
+ * "unrestricted_mode" or it was disabled.
+ * This is done to allow migration of the guests from hosts with
+ * unrestricted guest like Westmere to older host that don't have
+ * unrestricted guest like Nehelem.
+ */
+ if (!enable_unrestricted_guest && vmx->rmode.vm86_active) {
+ switch (seg) {
+ case VCPU_SREG_CS:
+ vmcs_write32(GUEST_CS_AR_BYTES, 0xf3);
+ vmcs_write32(GUEST_CS_LIMIT, 0xffff);
+ if (vmcs_readl(GUEST_CS_BASE) == 0xffff0000)
+ vmcs_writel(GUEST_CS_BASE, 0xf0000);
+ vmcs_write16(GUEST_CS_SELECTOR,
+ vmcs_readl(GUEST_CS_BASE) >> 4);
+ break;
+ case VCPU_SREG_ES:
+ fix_rmode_seg(VCPU_SREG_ES, &vmx->rmode.es);
+ break;
+ case VCPU_SREG_DS:
+ fix_rmode_seg(VCPU_SREG_DS, &vmx->rmode.ds);
+ break;
+ case VCPU_SREG_GS:
+ fix_rmode_seg(VCPU_SREG_GS, &vmx->rmode.gs);
+ break;
+ case VCPU_SREG_FS:
+ fix_rmode_seg(VCPU_SREG_FS, &vmx->rmode.fs);
+ break;
+ case VCPU_SREG_SS:
+ vmcs_write16(GUEST_SS_SELECTOR,
+ vmcs_readl(GUEST_SS_BASE) >> 4);
+ vmcs_write32(GUEST_SS_LIMIT, 0xffff);
+ vmcs_write32(GUEST_SS_AR_BYTES, 0xf3);
+ break;
+ }
+ }
}
static void vmx_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l)
next prev parent reply other threads:[~2012-08-20 4:03 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-20 3:58 [ 00/46] 3.5.3-stable review Greg Kroah-Hartman
2012-08-20 3:58 ` [ 01/46] s390/compat: fix compat wrappers for process_vm system calls Greg Kroah-Hartman
2012-08-20 3:58 ` [ 02/46] s390/compat: fix mmap compat " Greg Kroah-Hartman
2012-08-20 3:58 ` [ 03/46] nouveau: fixup scanout enable in nvc0_pm Greg Kroah-Hartman
2012-08-20 3:58 ` [ 04/46] drm/mgag200: fix G200ER pll picking algorithm Greg Kroah-Hartman
2012-08-20 3:58 ` [ 05/46] dma: imx-dma: Fix kernel crash due to missing clock conversion Greg Kroah-Hartman
2012-08-20 3:58 ` [ 06/46] fuse: verify all ioctl retry iov elements Greg Kroah-Hartman
2012-08-20 3:58 ` [ 07/46] xen/p2m: Reserve 8MB of _brk space for P2M leafs when populating back Greg Kroah-Hartman
2012-08-20 3:58 ` [ 08/46] drm/i915: prefer wide & slow to fast & narrow in DP configs Greg Kroah-Hartman
2012-08-20 3:58 ` [ 09/46] drm/nvd0/disp: mask off high 16 bit of negative cursor x-coordinate Greg Kroah-Hartman
2012-08-20 3:58 ` [ 10/46] drm/i915: correctly order the ring init sequence Greg Kroah-Hartman
2012-08-20 3:58 ` [ 11/46] drm/i915: ignore eDP bpc settings from vbt Greg Kroah-Hartman
2012-08-20 3:58 ` [ 12/46] drm/i915: reorder edp disabling to fix ivb MacBook Air Greg Kroah-Hartman
2012-08-20 3:58 ` [ 13/46] drm/radeon: properly handle crtc powergating Greg Kroah-Hartman
2012-08-20 3:58 ` [ 14/46] drm/radeon: do not reenable crtc after moving vram start address Greg Kroah-Hartman
2012-08-20 3:58 ` [ 15/46] drm/i915: make rc6 in sysfs functions conditional Greg Kroah-Hartman
2012-08-20 3:58 ` [ 16/46] drm/radeon: add some new SI pci ids Greg Kroah-Hartman
2012-08-20 3:58 ` [ 17/46] drm/radeon: fix bank tiling parameters on cayman Greg Kroah-Hartman
2012-08-20 3:58 ` [ 18/46] drm/radeon: fix bank tiling parameters on SI Greg Kroah-Hartman
2012-08-20 3:58 ` [ 19/46] drm/radeon: fix bank tiling parameters on evergreen Greg Kroah-Hartman
2012-08-20 3:58 ` [ 20/46] drm/radeon/kms: allow "invalid" DB formats as a means to disable DB Greg Kroah-Hartman
2012-08-20 3:58 ` [ 21/46] Yama: access task_struct->comm directly Greg Kroah-Hartman
2012-08-20 3:58 ` [ 22/46] ext4: make sure the journal sb is written in ext4_clear_journal_err() Greg Kroah-Hartman
2012-08-20 3:58 ` [ 23/46] ext4: avoid kmemcheck complaint from reading uninitialized memory Greg Kroah-Hartman
2012-08-20 3:59 ` [ 24/46] ext4: dont call ext4_error while block group is locked Greg Kroah-Hartman
2012-08-20 3:59 ` [ 25/46] ext4: fix long mount times on very big file systems Greg Kroah-Hartman
2012-08-20 3:59 ` [ 26/46] ext4: fix kernel BUG on large-scale rm -rf commands Greg Kroah-Hartman
2012-08-20 3:59 ` [ 27/46] xhci: Add Etron XHCI_TRUST_TX_LENGTH quirk Greg Kroah-Hartman
2012-08-20 3:59 ` [ 28/46] xhci: Increase reset timeout for Renesas 720201 host Greg Kroah-Hartman
2012-08-20 3:59 ` [ 29/46] xhci: Switch PPT ports to EHCI on shutdown Greg Kroah-Hartman
2012-08-20 3:59 ` [ 30/46] xhci: Fix bug after deq ptr set to link TRB Greg Kroah-Hartman
2012-08-20 3:59 ` [ 31/46] drivers-core: make structured logging play nice with dynamic-debug Greg Kroah-Hartman
2012-08-20 3:59 ` [ 32/46] staging: comedi: Fix reversed test in comedi_device_attach() Greg Kroah-Hartman
2012-08-20 3:59 ` [ 33/46] USB: add USB_VENDOR_AND_INTERFACE_INFO() macro Greg Kroah-Hartman
2012-08-20 3:59 ` [ 34/46] USB: support the new interfaces of Huawei Data Card devices in option driver Greg Kroah-Hartman
2012-08-20 3:59 ` [ 35/46] USB: option: add ZTE K5006-Z Greg Kroah-Hartman
2012-08-20 3:59 ` [ 36/46] USB: ftdi_sio: Add VID/PID for Kondo Serial USB Greg Kroah-Hartman
2012-08-20 3:59 ` [ 37/46] usb: serial: mos7840: Fixup mos7840_chars_in_buffer() Greg Kroah-Hartman
2012-08-20 3:59 ` [ 38/46] usb: gadget: u_ether: fix kworker 100% CPU issue with still used interfaces in eth_stop Greg Kroah-Hartman
2012-08-20 3:59 ` [ 39/46] rt2x00: Add support for BUFFALO WLI-UC-GNM2 to rt2800usb Greg Kroah-Hartman
2012-08-20 3:59 ` [ 40/46] KVM: PIC: call ack notifiers for irqs that are dropped form irr Greg Kroah-Hartman
2012-08-23 0:02 ` Ben Hutchings
2012-08-26 2:30 ` Greg Kroah-Hartman
2012-08-20 3:59 ` [ 41/46] KVM: x86: apply kvmclock offset to guest wall clock time Greg Kroah-Hartman
2012-08-20 3:59 ` [ 42/46] KVM: VMX: Fix ds/es corruption on i386 with preemption Greg Kroah-Hartman
2012-08-20 3:59 ` [ 43/46] KVM: x86 emulator: fix byte-sized MOVZX/MOVSX Greg Kroah-Hartman
2012-08-23 0:04 ` Ben Hutchings
2012-08-20 3:59 ` Greg Kroah-Hartman [this message]
2012-08-20 3:59 ` [ 45/46] pmac_zilog,kdb: Fix console poll hook to return instead of loop Greg Kroah-Hartman
2012-08-20 3:59 ` [ 46/46] IB/srp: Fix a race condition Greg Kroah-Hartman
2012-08-20 8:26 ` [ 00/46] 3.5.3-stable review Holger Hoffstaette
2012-08-20 14:46 ` Greg KH
2012-08-20 15:01 ` J. Bruce Fields
2012-08-21 17:08 ` Heinz Diehl
2012-08-25 8:50 ` Heinz Diehl
2012-08-21 19:26 ` Sven Joachim
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=20120820035838.375306085@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=avi@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=owasserm@rehdat.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.