From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yang, Sheng" Subject: [PATCH] KVM: VMX: Move private memory slot position Date: Thu, 4 Sep 2008 11:30:20 +0800 Message-ID: <200809041130.20249.sheng.yang@intel.com> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_MZ1vIv7terGToXX" Cc: kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mga02.intel.com ([134.134.136.20]:21377 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753541AbYIDD1W (ORCPT ); Wed, 3 Sep 2008 23:27:22 -0400 Sender: kvm-owner@vger.kernel.org List-ID: --Boundary-00=_MZ1vIv7terGToXX Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =46rom ebe4ea311305d2910dcdcff2510662da0dc2c742 Mon Sep 17 00:00:00 2001 =46rom: Sheng Yang Date: Thu, 4 Sep 2008 03:11:48 +0800 Subject: [PATCH] KVM: VMX: Move private memory slot position PCI device assignment would map guest MMIO spaces as separate slot, so it is possible that the device has more than 2 MMIO spaces and overwrite current private memslot. The patch move private memory slot to the top of userspace visible memory=20 slots. Signed-off-by: Sheng Yang =2D-- arch/x86/kvm/vmx.c | 2 +- arch/x86/kvm/vmx.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 004d24a..27c3bb7 100644 =2D-- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2448,7 +2448,7 @@ static int vmx_set_tss_addr(struct kvm *kvm, unsigned= =20 int addr) { int ret; struct kvm_userspace_memory_region tss_mem =3D { =2D .slot =3D 8, + .slot =3D TSS_PRIVATE_MEMSLOT, .guest_phys_addr =3D addr, .memory_size =3D PAGE_SIZE * 3, .flags =3D 0, diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h index 16b3cfb..dd0eea9 100644 =2D-- a/arch/x86/kvm/vmx.h +++ b/arch/x86/kvm/vmx.h @@ -356,8 +356,9 @@ enum vmcs_field { #define IA32_FEATURE_CONTROL_LOCKED_BIT 0x1 #define IA32_FEATURE_CONTROL_VMXON_ENABLED_BIT 0x4 =2D#define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT 9 =2D#define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT 10 +#define TSS_PRIVATE_MEMSLOT (KVM_MEMORY_SLOTS + 0) +#define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT (KVM_MEMORY_SLOTS + 1) +#define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT (KVM_MEMORY_SLOTS + 2) #define VMX_NR_VPIDS (1 << 16) #define VMX_VPID_EXTENT_SINGLE_CONTEXT 1 =2D- 1.5.4.5 --Boundary-00=_MZ1vIv7terGToXX Content-Type: text/x-diff; charset="utf-8"; name="0001-KVM-VMX-Move-private-memory-slot-position.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-KVM-VMX-Move-private-memory-slot-position.patch" =46rom ebe4ea311305d2910dcdcff2510662da0dc2c742 Mon Sep 17 00:00:00 2001 =46rom: Sheng Yang Date: Thu, 4 Sep 2008 03:11:48 +0800 Subject: [PATCH] KVM: VMX: Move private memory slot position PCI device assignment would map guest MMIO spaces as separate slot, so it is possible that the device has more than 2 MMIO spaces and overwrite current private memslot. The patch move private memory slot to the top of userspace visible memory s= lots. Signed-off-by: Sheng Yang =2D-- arch/x86/kvm/vmx.c | 2 +- arch/x86/kvm/vmx.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 004d24a..27c3bb7 100644 =2D-- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2448,7 +2448,7 @@ static int vmx_set_tss_addr(struct kvm *kvm, unsigned= int addr) { int ret; struct kvm_userspace_memory_region tss_mem =3D { =2D .slot =3D 8, + .slot =3D TSS_PRIVATE_MEMSLOT, .guest_phys_addr =3D addr, .memory_size =3D PAGE_SIZE * 3, .flags =3D 0, diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h index 16b3cfb..dd0eea9 100644 =2D-- a/arch/x86/kvm/vmx.h +++ b/arch/x86/kvm/vmx.h @@ -356,8 +356,9 @@ enum vmcs_field { #define IA32_FEATURE_CONTROL_LOCKED_BIT 0x1 #define IA32_FEATURE_CONTROL_VMXON_ENABLED_BIT 0x4 =20 =2D#define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT 9 =2D#define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT 10 +#define TSS_PRIVATE_MEMSLOT (KVM_MEMORY_SLOTS + 0) +#define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT (KVM_MEMORY_SLOTS + 1) +#define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT (KVM_MEMORY_SLOTS + 2) =20 #define VMX_NR_VPIDS (1 << 16) #define VMX_VPID_EXTENT_SINGLE_CONTEXT 1 =2D-=20 1.5.4.5 --Boundary-00=_MZ1vIv7terGToXX--