From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yang, Sheng" Subject: [PATCH 3/8] KVM: Add kvm_x86_ops get_tdp_level() Date: Fri, 25 Apr 2008 16:24:47 +0800 Message-ID: <200804251624.47984.sheng.yang@intel.com> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_PVZEI2aGCPu8AJ+" Cc: kvm-devel To: Avi Kivity Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org --Boundary-00=_PVZEI2aGCPu8AJ+ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =46rom 143c1240c5e5391f4e108aedfeb4491e6347d04e Mon Sep 17 00:00:00 2001 =46rom: Sheng Yang Date: Fri, 25 Apr 2008 10:20:22 +0800 Subject: [PATCH 3/8] KVM: Add kvm_x86_ops get_tdp_level() The function get_tdp_level() provided the number of tdp level for EPT and NPT rather than the NPT specific macro. Signed-off-by: Sheng Yang =2D-- arch/x86/kvm/mmu.h | 6 ------ arch/x86/kvm/svm.c | 10 ++++++++++ arch/x86/kvm/vmx.c | 6 ++++++ arch/x86/kvm/vmx.h | 1 + include/asm-x86/kvm_host.h | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index a4fcb78..1730757 100644 =2D-- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -3,12 +3,6 @@ #include =2D#ifdef CONFIG_X86_64 =2D#define TDP_ROOT_LEVEL PT64_ROOT_LEVEL =2D#else =2D#define TDP_ROOT_LEVEL PT32E_ROOT_LEVEL =2D#endif =2D #define PT64_PT_BITS 9 #define PT64_ENT_PER_PAGE (1 << PT64_PT_BITS) #define PT32_PT_BITS 10 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 89e0be2..ab22615 100644 =2D-- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1863,6 +1863,15 @@ static bool svm_cpu_has_accelerated_tpr(void) return false; } +static int get_npt_level(void) +{ +#ifdef CONFIG_X86_64 + return PT64_ROOT_LEVEL; +#else + return PT32E_ROOT_LEVEL; +#endif +} + static struct kvm_x86_ops svm_x86_ops =3D { .cpu_has_kvm_support =3D has_svm, .disabled_by_bios =3D is_disabled, @@ -1920,6 +1929,7 @@ static struct kvm_x86_ops svm_x86_ops =3D { .inject_pending_vectors =3D do_interrupt_requests, .set_tss_addr =3D svm_set_tss_addr, + .get_tdp_level =3D get_npt_level, }; static int __init svm_init(void) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index d93250d..98e4f2b 100644 =2D-- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2788,6 +2788,11 @@ static void __init vmx_check_processor_compat(void=20 *rtn) } } +static int get_ept_level(void) +{ + return VMX_EPT_DEFAULT_GAW + 1; +} + static struct kvm_x86_ops vmx_x86_ops =3D { .cpu_has_kvm_support =3D cpu_has_kvm_support, .disabled_by_bios =3D vmx_disabled_by_bios, @@ -2844,6 +2849,7 @@ static struct kvm_x86_ops vmx_x86_ops =3D { .inject_pending_vectors =3D do_interrupt_requests, .set_tss_addr =3D vmx_set_tss_addr, + .get_tdp_level =3D get_ept_level, }; static int __init vmx_init(void) diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h index 5f7fdc9..093b085 100644 =2D-- a/arch/x86/kvm/vmx.h +++ b/arch/x86/kvm/vmx.h @@ -351,5 +351,6 @@ enum vmcs_field { #define VMX_EPT_EXTENT_INDIVIDUAL_BIT (1ull << 24) #define VMX_EPT_EXTENT_CONTEXT_BIT (1ull << 25) #define VMX_EPT_EXTENT_GLOBAL_BIT (1ull << 26) +#define VMX_EPT_DEFAULT_GAW 3 #endif diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h index 9d963cd..65b27c9 100644 =2D-- a/include/asm-x86/kvm_host.h +++ b/include/asm-x86/kvm_host.h @@ -422,8 +422,8 @@ struct kvm_x86_ops { struct kvm_run *run); int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); + int (*get_tdp_level)(void); }; =2D extern struct kvm_x86_ops *kvm_x86_ops; int kvm_mmu_module_init(void); =2D- 1.5.4.5 --Boundary-00=_PVZEI2aGCPu8AJ+ Content-Type: text/x-diff; charset="utf-8"; name="0003-KVM-Add-kvm_x86_ops-get_tdp_level.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0003-KVM-Add-kvm_x86_ops-get_tdp_level.patch" =46rom 143c1240c5e5391f4e108aedfeb4491e6347d04e Mon Sep 17 00:00:00 2001 =46rom: Sheng Yang Date: Fri, 25 Apr 2008 10:20:22 +0800 Subject: [PATCH 3/8] KVM: Add kvm_x86_ops get_tdp_level() The function get_tdp_level() provided the number of tdp level for EPT and NPT rather than the NPT specific macro. Signed-off-by: Sheng Yang =2D-- arch/x86/kvm/mmu.h | 6 ------ arch/x86/kvm/svm.c | 10 ++++++++++ arch/x86/kvm/vmx.c | 6 ++++++ arch/x86/kvm/vmx.h | 1 + include/asm-x86/kvm_host.h | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index a4fcb78..1730757 100644 =2D-- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -3,12 +3,6 @@ =20 #include =20 =2D#ifdef CONFIG_X86_64 =2D#define TDP_ROOT_LEVEL PT64_ROOT_LEVEL =2D#else =2D#define TDP_ROOT_LEVEL PT32E_ROOT_LEVEL =2D#endif =2D #define PT64_PT_BITS 9 #define PT64_ENT_PER_PAGE (1 << PT64_PT_BITS) #define PT32_PT_BITS 10 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 89e0be2..ab22615 100644 =2D-- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1863,6 +1863,15 @@ static bool svm_cpu_has_accelerated_tpr(void) return false; } =20 +static int get_npt_level(void) +{ +#ifdef CONFIG_X86_64 + return PT64_ROOT_LEVEL; +#else + return PT32E_ROOT_LEVEL; +#endif +} + static struct kvm_x86_ops svm_x86_ops =3D { .cpu_has_kvm_support =3D has_svm, .disabled_by_bios =3D is_disabled, @@ -1920,6 +1929,7 @@ static struct kvm_x86_ops svm_x86_ops =3D { .inject_pending_vectors =3D do_interrupt_requests, =20 .set_tss_addr =3D svm_set_tss_addr, + .get_tdp_level =3D get_npt_level, }; =20 static int __init svm_init(void) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index d93250d..98e4f2b 100644 =2D-- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2788,6 +2788,11 @@ static void __init vmx_check_processor_compat(void *= rtn) } } =20 +static int get_ept_level(void) +{ + return VMX_EPT_DEFAULT_GAW + 1; +} + static struct kvm_x86_ops vmx_x86_ops =3D { .cpu_has_kvm_support =3D cpu_has_kvm_support, .disabled_by_bios =3D vmx_disabled_by_bios, @@ -2844,6 +2849,7 @@ static struct kvm_x86_ops vmx_x86_ops =3D { .inject_pending_vectors =3D do_interrupt_requests, =20 .set_tss_addr =3D vmx_set_tss_addr, + .get_tdp_level =3D get_ept_level, }; =20 static int __init vmx_init(void) diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h index 5f7fdc9..093b085 100644 =2D-- a/arch/x86/kvm/vmx.h +++ b/arch/x86/kvm/vmx.h @@ -351,5 +351,6 @@ enum vmcs_field { #define VMX_EPT_EXTENT_INDIVIDUAL_BIT (1ull << 24) #define VMX_EPT_EXTENT_CONTEXT_BIT (1ull << 25) #define VMX_EPT_EXTENT_GLOBAL_BIT (1ull << 26) +#define VMX_EPT_DEFAULT_GAW 3 =20 #endif diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h index 9d963cd..65b27c9 100644 =2D-- a/include/asm-x86/kvm_host.h +++ b/include/asm-x86/kvm_host.h @@ -422,8 +422,8 @@ struct kvm_x86_ops { struct kvm_run *run); =20 int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); + int (*get_tdp_level)(void); }; =2D extern struct kvm_x86_ops *kvm_x86_ops; =20 int kvm_mmu_module_init(void); =2D-=20 1.5.4.5 --Boundary-00=_PVZEI2aGCPu8AJ+ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone --Boundary-00=_PVZEI2aGCPu8AJ+ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel --Boundary-00=_PVZEI2aGCPu8AJ+--