SVM: Add Support for Nested Paging in AMD Fam16 CPUs
RFC PATCH 1/1 SVM: Add Support for Nested Paging in AMD Fam16 CPUs
Hi,
here is the first release of patches for KVM to support the Nested Paging (NPT) feature of AMD QuadCore CPUs for comments and public testing. This feature improves the guest performance significantly. I measured an improvement of around 17% using kernbench in my first tests.
This patch series is basically tested with Linux guests (32 bit legacy paging, 32 bit PAE paging and 64 bit Long Mode). Also tested with Windows Vista 32 bit and 64 bit. All these guests ran successfully with these patches. The patch series only enables NPT for 64 bit Linux hosts at the moment.
Please give these patches a good and deep testing. I hope we have this patchset ready for merging soon.
Joerg
Here is the diffstat:
arch/x86/kvm/mmu.c | 81 +++++++++++++++++++++++++++++++++++--- arch/x86/kvm/mmu.h | 6 +++ arch/x86/kvm/svm.c | 94 +++++++++++++++++++++++++++++++++++++++++-- arch/x86/kvm/vmx.c | 7 +++ arch/x86/kvm/x86.c | 1 + include/asm-x86/kvm_host.h | 4 ++ 6 files changed, 182 insertions(+), 11 deletions(-)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 1/8 SVM: move feature detection to hardware setup code
By moving the SVM feature detection from the each_cpu code to the hardware setup code it runs only once. As an additional advance the feature check is now available earlier in the module setup process.
--- arch/x86/kvm/svm.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
arch/x86/kvm/svm.c +3 -1
@@ -302,7 +302,6 @@ static void svm_hardware_enable(void *garbage) svm_data->asid_generation =1 ; svm_data->max_asid =cpuid_ebx (SVM_CPUID_FUNC ) -1 ; svm_data->next_asid = svm_data->max_asid +1 ; - svm_features =cpuid_edx (SVM_CPUID_FUNC ); asmvolatile ("sgdt %0" :"=m" (gdt_descr)); gdt = (struct desc_struct *)gdt_descr.address;
@@ -408,6 +407,9 @@ static __init int svm_hardware_setup(void)if (r) goto err_2; } + + svm_features =cpuid_edx (SVM_CPUID_FUNC ); +return 0 ; err_2:
Signature · 9 lines
1.5.3.7 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 2/8 SVM: add detection of Nested Paging feature
In reply to Joerg RoedelLet SVM detect if the Nested Paging feature is available on the hardware. Disable it to keep this patch series bisectable.
--- arch/x86/kvm/svm.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
arch/x86/kvm/svm.c +8 -0
@@ -47,6 +47,8 @@ MODULE_LICENSE("GPL");#define SVM_FEATURE_LBRV (1 << 1)#define SVM_DEATURE_SVML (1 << 2) +static bool npt_enabled = false; +static void kvm_reput_irq (struct vcpu_svm *svm);static inline struct vcpu_svm *to_svm (struct kvm_vcpu *vcpu)
@@ -410,6 +412,12 @@ static __init int svm_hardware_setup(void) svm_features =cpuid_edx (SVM_CPUID_FUNC ); +if (!svm_has (SVM_FEATURE_NPT )) + npt_enabled = false; + +if (npt_enabled) +printk (KERN_INFO "kvm: Nested Paging enabled\n" ); +return 0 ; err_2:
Signature · 9 lines
1.5.3.7 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 3/8 SVM: add module parameter to disable Nested Paging
In reply to Joerg RoedelTo disable the use of the Nested Paging feature even if it is available in hardware this patch adds a module parameter. Nested Paging can be disabled by passing npt=off to the kvm_amd module.
--- arch/x86/kvm/svm.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
arch/x86/kvm/svm.c +8 -0
@@ -48,6 +48,9 @@ MODULE_LICENSE("GPL");#define SVM_DEATURE_SVML (1 << 2)static bool npt_enabled = false; +static char *npt ="on" ; + +module_param (npt, charp,S_IRUGO );static void kvm_reput_irq (struct vcpu_svm *svm);
@@ -415,6 +418,11 @@ static __init int svm_hardware_setup(void)if (!svm_has (SVM_FEATURE_NPT )) npt_enabled = false; +if (npt_enabled &&strncmp (npt,"off" ,3 ) ==0 ) { +printk (KERN_INFO "kvm: Nested Paging disabled\n" ); + npt_enabled = false; + } +if (npt_enabled)printk (KERN_INFO "kvm: Nested Paging enabled\n" );
Signature · 1 line
1.5.3.7
Re: [kvm-devel] [PATCH 3/8] SVM: add module parameter to disable Nested Paging
Quoted 14 lines · Joerg Roedel
To disable the use of the Nested Paging feature even if it is available in hardware this patch adds a module parameter. Nested Paging can be disabled by passing npt=off to the
kvm_amdmodule.Signed-off-by Joerg Roedel <[email protected]>--- arch/x86/kvm/svm.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)arch/x86/kvm/svm.c +0
-0
arch/x86/kvm/svm.c MODULE_LICENSE("GPL"); · line 54
Quoted 7 lines
arch/x86/kvm/svm.c +3
-0@@ -48,6 +48,9 @@ MODULE_LICENSE("GPL");#define SVM_DEATURE_SVML (1 << 2)static bool npt_enabled = false; +static char *npt ="on" ; + +module_param (npt, charp,S_IRUGO );
This would probably be better as an integer. Then we don't have to do nasty things like implicitly cast a literal to a char *.
Regards,
Anthony Liguori
Quoted 5 lines
arch/x86/kvm/svm.c +0
-0static void kvm_reput_irq (struct vcpu_svm *svm);@@ -415,6 +418,11 @@ static __init int svm_hardware_setup(void)if (!svm_has (SVM_FEATURE_NPT ))
arch/x86/kvm/svm.c static __init int svm_hardware_setup(void) · line 428
Quoted 10 lines
arch/x86/kvm/svm.c +5
-0npt_enabled = false; +if (npt_enabled &&strncmp (npt,"off" ,3 ) ==0 ) { +printk (KERN_INFO "kvm: Nested Paging disabled\n" ); + npt_enabled = false; + } +if (npt_enabled)printk (KERN_INFO "kvm: Nested Paging enabled\n" );
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 3/8] SVM: add module parameter to disable Nested Paging
Quoted 10 lines · Anthony Liguori
Quoted 9 lines · Joerg Roedel
To disable the use of the Nested Paging feature even if it is available in hardware this patch adds a module parameter. Nested Paging can be disabled by passing npt=off to the
kvm_amdmodule.Signed-off-by Joerg Roedel <[email protected]>---
arch/x86/kvm/svm.c| 8 ++++++++1 files changed, 8 insertions(+), 0 deletions(-)
Quoted 14 lines
arch/x86/kvm/svm.c MODULE_LICENSE("GPL"); · line 53
Quoted 11 lines
arch/x86/kvm/svm.c +3
-0@@ -48,6 +48,9 @@ MODULE_LICENSE("GPL");#define SVM_DEATURE_SVML (1 << 2)static bool npt_enabled = false; +static char *npt ="on" ; + +module_param (npt, charp,S_IRUGO );This would probably be better as an integer. Then we don't have to do nasty things like implicitly cast a literal to a char *.
Hmm, I used int for that first but typing npt=off seemed more userfriendly to me than npt=0. So I used char* for it.
Joerg
Signature · 13 lines
| AMD Saxony Limited Liability Company & Co. KG
Operating | Wilschdorfer Landstr. 101, 01109 Dresden, Germany
System | Register Court Dresden: HRA 4896
Research | General Partner authorized to represent:
Center | AMD Saxony LLC (Wilmington, Delaware, US)
| General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/Re: [kvm-devel] [PATCH 3/8] SVM: add module parameter to disable Nested Paging
Quoted 9 lines · Joerg Roedel
Quoted 8 lines
arch/x86/kvm/svm.c MODULE_LICENSE("GPL"); · line 53
Quoted 5 lines
arch/x86/kvm/svm.c +3
-0+static char *npt ="on" ; + +module_param (npt, charp,S_IRUGO );This would probably be better as an integer. Then we don't have to do nasty things like implicitly cast a literal to a char *.
Quoted 3 lines
Hmm, I used int for that first but typing npt=off seemed more userfriendly to me than npt=0. So I used char* for it.
I expect this to be rarely used by users, so the simpler int is preferable (and also consistent with vmx's bypass_guest_pf and enable_vpid).
Signature · 7 lines
Any sufficiently difficult bug is indistinguishable from a feature. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
RE: [kvm-devel] [PATCH 3/8] SVM: add module parameter to disable NestedPaging
In reply to Joerg RoedelQuoted 1 line · Joerg Roedel
To disable the use of the Nested Paging feature even if it is
available in
Quoted 1 line
hardware this patch adds a module parameter. Nested Paging can be
disabled by
Quoted 1 line
passing npt=off to the
kvm_amdmodule.
I think it's better to use a (common) parameter to qemu. That way you can control on/off for each VM.
Jun
---
Intel Open Source Technology Center
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 3/8] SVM: add module parameter to disable NestedPaging
Quoted 9 lines · Jun
Quoted 1 line · Joerg Roedel
To disable the use of the Nested Paging feature even if it is
available in
Quoted 1 line
hardware this patch adds a module parameter. Nested Paging can be
disabled by
Quoted 1 line
passing npt=off to the
kvm_amdmodule.I think it's better to use a (common) parameter to qemu. That way you can control on/off for each VM.
Generally I see no problem with it. But at least for NPT I don't see a reason why someone should want to disable it on a VM basis (as far as it works stable). Avi, what do you think?
Joerg
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 3/8] SVM: add module parameter to disable NestedPaging
Quoted 4 lines
Generally I see no problem with it. But at least for NPT I don't see a reason why someone should want to disable it on a VM basis (as far as it works stable). Avi, what do you think?
1. This is more user-friendly and easier-to-find
2. A lot of people would like to view (and Demo) it side-by-side.
3. Useful for BETA-testing of KVM.
Signature · 6 lines
-Alexey Eremenko "Technologov" ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 3/8] SVM: add module parameter to disable NestedPaging
Quoted 10 lines · Alexey Eremenko
Quoted 4 lines
Generally I see no problem with it. But at least for NPT I don't see a reason why someone should want to disable it on a VM basis (as far as it works stable). Avi, what do you think?
1. This is more user-friendly and easier-to-find
2. A lot of people would like to view (and Demo) it side-by-side.
3. Useful for BETA-testing of KVM.
Ok, agreed. I will add this feature.
Joerg
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 3/8] SVM: add module parameter to disable NestedPaging
In reply to Alexey EremenkoQuoted 8 lines · Alexey Eremenko
Quoted 5 lines
Generally I see no problem with it. But at least for NPT I don't see a reason why someone should want to disable it on a VM basis (as far as it works stable). Avi, what do you think?
1. This is more user-friendly and easier-to-find
I'm inclined to disagree. Why add an additional thing for people to tune if they really shouldn't need to. Once NPT/EPT support are stable, is there any reason to want to disable it?
Regards,
Anthony Liguori
Quoted 5 lines
2. A lot of people would like to view (and Demo) it side-by-side.
3. Useful for BETA-testing of KVM.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 3/8] SVM: add module parameter to disable NestedPaging
In reply to Joerg RoedelQuoted 4 lines · Joerg Roedel
Generally I see no problem with it. But at least for NPT I don't see a reason why someone should want to disable it on a VM basis (as far as it works stable). Avi, what do you think?
Unless there is a real-life workload that benefits from npt=0, I see no reason to have per-vm npt control. The module parameter is helpful, for to isolate npt problems and for development, but I don't see a need for users to fiddle with it.
Signature · 1 line
Any sufficiently difficult bug is indistinguishable from a feature.
PATCH 4/8 X86: export information about NPT to generic x86 code
In reply to Joerg RoedelThe generic x86 code has to know if the specific implementation uses Nested Paging. In the generic code Nested Paging is called Hardware Assisted Paging (HAP) to avoid confusion with (future) HAP implementations of other vendors. This patch exports the availability of HAP to the generic x86 code.
--- arch/x86/kvm/svm.c | 7 +++++++ arch/x86/kvm/vmx.c | 7 +++++++ include/asm-x86/kvm_host.h | 2 ++ 3 files changed, 16 insertions(+), 0 deletions(-)
arch/x86/kvm/svm.c +7 -0
@@ -1678,6 +1678,11 @@ static bool svm_cpu_has_accelerated_tpr(void)return false; } +static bool svm_hap_enabled (void ) +{ +return npt_enabled; +} +static struct kvm_x86_ops svm_x86_ops = { .cpu_has_kvm_support = has_svm, .disabled_by_bios = is_disabled,
@@ -1734,6 +1739,8 @@ static struct kvm_x86_ops svm_x86_ops = { .inject_pending_vectors = do_interrupt_requests, .set_tss_addr = svm_set_tss_addr, + + .hap_enabled = svm_hap_enabled, };static int __init svm_init (void )
arch/x86/kvm/vmx.c +7 -0
@@ -2631,6 +2631,11 @@ static void __init vmx_check_processor_compat(void *rtn) } } +static bool vmx_hap_enabled (void ) +{ +return false; +} +static struct kvm_x86_ops vmx_x86_ops = { .cpu_has_kvm_support = cpu_has_kvm_support, .disabled_by_bios = vmx_disabled_by_bios,
@@ -2688,6 +2693,8 @@ static struct kvm_x86_ops vmx_x86_ops = { .inject_pending_vectors = do_interrupt_requests, .set_tss_addr = vmx_set_tss_addr, + + .hap_enabled = vmx_hap_enabled, };static int __init vmx_init (void )
include/asm-x86/kvm_host.h +2 -0
@@ -392,6 +392,8 @@ struct kvm_x86_ops { struct kvm_run *run);int (*set_tss_addr)(struct kvm *kvm,unsigned int addr); + +bool (*hap_enabled)(void ); };extern struct kvm_x86_ops *kvm_x86_ops;
Signature · 9 lines
1.5.3.7 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 4/8] X86: export information about NPT to generic x86 code
Quoted 17 lines · Joerg Roedel
The generic x86 code has to know if the specific implementation uses Nested Paging. In the generic code Nested Paging is called Hardware Assisted Paging (HAP) to avoid confusion with (future) HAP implementations of other vendors. This patch exports the availability of HAP to the generic x86 code.
Signed-off-by Joerg Roedel <[email protected]>--- arch/x86/kvm/svm.c | 7 +++++++ arch/x86/kvm/vmx.c | 7 +++++++ include/asm-x86/kvm_host.h | 2 ++ 3 files changed, 16 insertions(+), 0 deletions(-)arch/x86/kvm/svm.c +0
-0
arch/x86/kvm/svm.c static bool svm_cpu_has_accelerated_tpr(void) · line 1686
Quoted 9 lines
arch/x86/kvm/svm.c +5
-0@@ -1678,6 +1678,11 @@ static bool svm_cpu_has_accelerated_tpr(void)return false; } +static bool svm_hap_enabled (void ) +{ +return npt_enabled; +} +
To help with bisecting, you should probably return false here until the patch that actually implements NPT support. Otherwise, the 7th patch in this series breaks KVM for SVM.
Regards,
Anthony Liguori
Quoted 43 lines
arch/x86/kvm/svm.c +0
-0static struct kvm_x86_ops svm_x86_ops = { .cpu_has_kvm_support = has_svm,arch/x86/kvm/svm.c +2
-0.disabled_by_bios = is_disabled,@@ -1734,6 +1739,8 @@ static struct kvm_x86_ops svm_x86_ops = { .inject_pending_vectors = do_interrupt_requests, .set_tss_addr = svm_set_tss_addr, + + .hap_enabled = svm_hap_enabled, };static int __init svm_init (void )arch/x86/kvm/vmx.c +7
-0@@ -2631,6 +2631,11 @@ static void __init vmx_check_processor_compat(void *rtn) } } +static bool vmx_hap_enabled (void ) +{ +return false; +} +static struct kvm_x86_ops vmx_x86_ops = { .cpu_has_kvm_support = cpu_has_kvm_support, .disabled_by_bios = vmx_disabled_by_bios,@@ -2688,6 +2693,8 @@ static struct kvm_x86_ops vmx_x86_ops = { .inject_pending_vectors = do_interrupt_requests, .set_tss_addr = vmx_set_tss_addr, + + .hap_enabled = vmx_hap_enabled, };static int __init vmx_init (void )include/asm-x86/kvm_host.h +0
-0
include/asm-x86/kvm_host.h struct kvm_x86_ops { · line 399
Quoted 8 lines
include/asm-x86/kvm_host.h +2
-0@@ -392,6 +392,8 @@ struct kvm_x86_ops { struct kvm_run *run);int (*set_tss_addr)(struct kvm *kvm,unsigned int addr); + +bool (*hap_enabled)(void ); };extern struct kvm_x86_ops *kvm_x86_ops;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 4/8] X86: export information about NPT to generic x86 code
Quoted 24 lines · Anthony Liguori
Quoted 23 lines · Joerg Roedel
The generic x86 code has to know if the specific implementation uses Nested
Paging. In the generic code Nested Paging is called Hardware Assisted Paging
(HAP) to avoid confusion with (future) HAP implementations of other vendors.
This patch exports the availability of HAP to the generic x86 code.Signed-off-by Joerg Roedel <[email protected]>--- arch/x86/kvm/svm.c | 7 +++++++ arch/x86/kvm/vmx.c | 7 +++++++ include/asm-x86/kvm_host.h | 2 ++ 3 files changed, 16 insertions(+), 0 deletions(-)arch/x86/kvm/svm.c +0
-0@@ -1678,6 +1678,11 @@ static bool svm_cpu_has_accelerated_tpr(void)return false; }
Quoted 10 lines
arch/x86/kvm/svm.c static bool svm_cpu_has_accelerated_tpr(void)
Quoted 6 lines
arch/x86/kvm/svm.c +5
-0+static bool svm_hap_enabled (void ) +{ +return npt_enabled; +} +To help with bisecting, you should probably return false here until the patch that actually implements NPT support. Otherwise, the 7th patch in this series breaks KVM for SVM.
Ignore this, you're already doing the right thing :-)
Regards,
Anthony Liguori
Quoted 49 lines
Regards,
Anthony Liguori
Quoted 45 lines
arch/x86/kvm/svm.c +0
-0static struct kvm_x86_ops svm_x86_ops = { .cpu_has_kvm_support = has_svm,.disabled_by_bios =
is_disabled,arch/x86/kvm/svm.c +2
-0@@ -1734,6 +1739,8 @@ static struct kvm_x86_ops svm_x86_ops = { .inject_pending_vectors = do_interrupt_requests, .set_tss_addr = svm_set_tss_addr, + + .hap_enabled = svm_hap_enabled, };static int __init svm_init (void )arch/x86/kvm/vmx.c +5
-0@@ -2631,6 +2631,11 @@ static void __init vmx_check_processor_compat(void *rtn) } } +static bool vmx_hap_enabled (void ) +{ +return false; +} +static struct kvm_x86_ops vmx_x86_ops = { .cpu_has_kvm_support = cpu_has_kvm_support,.disabled_by_bios =
vmx_disabled_by_bios,arch/x86/kvm/vmx.c +2
-0@@ -2688,6 +2693,8 @@ static struct kvm_x86_ops vmx_x86_ops = { .inject_pending_vectors = do_interrupt_requests, .set_tss_addr = vmx_set_tss_addr, + + .hap_enabled = vmx_hap_enabled, };static int __init vmx_init (void )include/asm-x86/kvm_host.h +0
-0@@ -392,6 +392,8 @@ struct kvm_x86_ops { struct kvm_run *run);
Quoted 8 lines
include/asm-x86/kvm_host.h struct kvm_x86_ops { · line 399
Quoted 7 lines
include/asm-x86/kvm_host.h +2
-0int (*set_tss_addr)(struct kvm *kvm,unsigned int addr); + +bool (*hap_enabled)(void ); };extern struct kvm_x86_ops *kvm_x86_ops;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 4/8] X86: export information about NPT to generic x86 code
In reply to Joerg Roedelinclude/asm-x86/kvm_host.h struct kvm_x86_ops { · line 397
Quoted 11 lines · Joerg Roedel
The generic x86 code has to know if the specific implementation uses Nested Paging. In the generic code Nested Paging is called Hardware Assisted Paging (HAP) to avoid confusion with (future) HAP implementations of other vendors. This patch exports the availability of HAP to the generic x86 code.
include/asm-x86/kvm_host.h +2
-0int (*set_tss_addr)(struct kvm *kvm,unsigned int addr); + +bool (*hap_enabled)(void ); };
Since the value doesn't change during the lifetime of the VM, it can be a data field instead of a function. Or, if we find that npt/ept is always a win, a static field in mmu.c.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 5/8 MMU: make the __nonpaging_map function generic
In reply to Joerg RoedelThe mapping function for the nonpaging case in the softmmu does basically the same as required for Nested Paging. Make this function generic so it can be used for both.
--- arch/x86/kvm/mmu.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
arch/x86/kvm/mmu.c +3 -4
@@ -956,10 +956,9 @@ static void nonpaging_new_cr3(struct kvm_vcpu *vcpu) { } -static int __nonpaging_map (struct kvm_vcpu *vcpu,gva_t v,int write, -gfn_t gfn,struct page *page) +static int __direct_map (struct kvm_vcpu *vcpu,gpa_t v,int write, +gfn_t gfn,struct page *page,int level) { -int level =PT32E_ROOT_LEVEL ;hpa_t table_addr = vcpu->arch.mmu.root_hpa;int pt_write =0 ;
@@ -1017,7 +1016,7 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write, gfn_t gfn)spin_lock (&vcpu->kvm->mmu_lock);kvm_mmu_free_some_pages (vcpu); - r =__nonpaging_map (vcpu, v, write, gfn, page); + r =__direct_map (vcpu, v, write, gfn, page,PT32E_ROOT_LEVEL );spin_unlock (&vcpu->kvm->mmu_lock);up_read (¤t->mm->mmap_sem);
Signature · 9 lines
1.5.3.7 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 6/8 X86: export the load_pdptrs() function to modules
In reply to Joerg RoedelThe load_pdptrs() function is required in the SVM module for NPT support.
--- arch/x86/kvm/x86.c | 1 + include/asm-x86/kvm_host.h | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
arch/x86/kvm/x86.c +1 -0
@@ -202,6 +202,7 @@ out:return ret; } +EXPORT_SYMBOL_GPL (load_pdptrs);static bool pdptrs_changed (struct kvm_vcpu *vcpu) {
include/asm-x86/kvm_host.h +2 -0
@@ -412,6 +412,8 @@ void kvm_mmu_zap_all(struct kvm *kvm);unsigned int kvm_mmu_calculate_mmu_pages (struct kvm *kvm);void kvm_mmu_change_mmu_pages (struct kvm *kvm,unsigned int kvm_nr_mmu_pages); +int load_pdptrs (struct kvm_vcpu *vcpu,unsigned long cr3); +enum emulation_result {EMULATE_DONE ,/* no further processing */ EMULATE_DO_MMIO ,/* kvm_run filled with mmio request */
Signature · 9 lines
1.5.3.7 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 7/8 MMU: add HAP support to the KVM MMU
In reply to Joerg RoedelThis patch contains the changes to the KVM MMU necessary for support of the Nested Paging feature in AMD Barcelona and Phenom Processors.
--- arch/x86/kvm/mmu.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++- arch/x86/kvm/mmu.h | 6 ++++ 2 files changed, 78 insertions(+), 2 deletions(-)
arch/x86/kvm/mmu.c +72 -2
@@ -1072,6 +1072,7 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)int i;gfn_t root_gfn;struct kvm_mmu_page *sp; +int metaphysical =0 ; root_gfn = vcpu->arch.cr3 >>PAGE_SHIFT ;
@@ -1080,8 +1081,11 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)hpa_t root = vcpu->arch.mmu.root_hpa;ASSERT (!VALID_PAGE (root)); +if (kvm_x86_ops->hap_enabled ()) + metaphysical =1 ; sp =kvm_mmu_get_page (vcpu, root_gfn,0 , -PT64_ROOT_LEVEL ,0 ,ACC_ALL ,NULL ,NULL ); +PT64_ROOT_LEVEL , metaphysical, +ACC_ALL ,NULL ,NULL ); root =__pa (sp->spt); ++sp->root_count; vcpu->arch.mmu.root_hpa = root;
@@ -1135,6 +1139,36 @@ static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva, error_code & PFERR_WRITE_MASK, gfn); } +static int hap_page_fault (struct kvm_vcpu *vcpu,gva_t gpa, +u32 error_code) +{ +struct page *page; +int r; + +ASSERT (vcpu); +ASSERT (VALID_PAGE (vcpu->arch.mmu.root_hpa)); + + r =mmu_topup_memory_caches (vcpu); +if (r) +return r; + +down_read (¤t->mm->mmap_sem); + page =gfn_to_page (vcpu->kvm, gpa >>PAGE_SHIFT ); +if (is_error_page (page)) { +kvm_release_page_clean (page); +up_read (¤t->mm->mmap_sem); +return 1 ; + } +spin_lock (&vcpu->kvm->mmu_lock); +kvm_mmu_free_some_pages (vcpu); + r =__direct_map (vcpu, gpa, error_code &PFERR_WRITE_MASK , + gpa >>PAGE_SHIFT , page,HAP_ROOT_LEVEL ); +spin_unlock (&vcpu->kvm->mmu_lock); +up_read (¤t->mm->mmap_sem); + +return r; +} +static void nonpaging_free (struct kvm_vcpu *vcpu) {mmu_free_roots (vcpu);
@@ -1228,7 +1262,35 @@ static int paging32E_init_context(struct kvm_vcpu *vcpu)return paging64_init_context_common (vcpu,PT32E_ROOT_LEVEL ); } -static int init_kvm_mmu (struct kvm_vcpu *vcpu) +static int init_kvm_hap_mmu (struct kvm_vcpu *vcpu) +{ +struct kvm_mmu *context = &vcpu->arch.mmu; + + context->new_cr3 = nonpaging_new_cr3; + context->page_fault = hap_page_fault; + context->free = nonpaging_free; + context->prefetch_page = nonpaging_prefetch_page; + context->shadow_root_level =HAP_ROOT_LEVEL ; + context->root_hpa =INVALID_PAGE ; + +if (!is_paging (vcpu)) { + context->gva_to_gpa = nonpaging_gva_to_gpa; + context->root_level =0 ; + }else if (is_long_mode (vcpu)) { + context->gva_to_gpa = paging64_gva_to_gpa; + context->root_level =PT64_ROOT_LEVEL ; + }else if (is_pae (vcpu)) { + context->gva_to_gpa = paging64_gva_to_gpa; + context->root_level =PT32E_ROOT_LEVEL ; + }else { + context->gva_to_gpa = paging32_gva_to_gpa; + context->root_level =PT32_ROOT_LEVEL ; + } + +return 0 ; +} + +static int init_kvm_softmmu (struct kvm_vcpu *vcpu) {ASSERT (vcpu);ASSERT (!VALID_PAGE (vcpu->arch.mmu.root_hpa));
@@ -1243,6 +1305,14 @@ static int init_kvm_mmu(struct kvm_vcpu *vcpu)return paging32_init_context (vcpu); } +static int init_kvm_mmu (struct kvm_vcpu *vcpu) +{ +if (kvm_x86_ops->hap_enabled ()) +return init_kvm_hap_mmu (vcpu); +else +return init_kvm_softmmu (vcpu); +} +static void destroy_kvm_mmu (struct kvm_vcpu *vcpu) {ASSERT (vcpu);
arch/x86/kvm/mmu.h +6 -0
@@ -3,6 +3,12 @@#include <linux/kvm_host.h> +#ifdef CONFIG_X86_64 +#define HAP_ROOT_LEVEL PT64_ROOT_LEVEL +#else +#define HAP_ROOT_LEVEL PT32E_ROOT_LEVEL +#endif +static inline void kvm_mmu_free_some_pages (struct kvm_vcpu *vcpu) {if (unlikely (vcpu->kvm->arch.n_free_mmu_pages <KVM_MIN_FREE_MMU_PAGES ))
Signature · 9 lines
1.5.3.7 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 8/8 SVM: add support for Nested Paging
In reply to Joerg RoedelThis patch contains the SVM architecture dependent changes for KVM to enable support for the Nested Paging feature of AMD Barcelona and Phenom processors.
--- arch/x86/kvm/svm.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 63 insertions(+), 4 deletions(-)
arch/x86/kvm/svm.c +63 -4
@@ -47,7 +47,12 @@ MODULE_LICENSE("GPL");#define SVM_FEATURE_LBRV (1 << 1)#define SVM_DEATURE_SVML (1 << 2) +#ifdef CONFIG_X86_64 +static bool npt_enabled = true; +#else static bool npt_enabled = false; +#endif +static char *npt ="on" ;module_param (npt, charp,S_IRUGO );
@@ -187,7 +192,7 @@ static inline void flush_guest_tlb(struct kvm_vcpu *vcpu)static void svm_set_efer (struct kvm_vcpu *vcpu,u64 efer) { -if (!(efer &EFER_LMA )) +if (!npt_enabled && !(efer &EFER_LMA )) efer &= ~EFER_LME ;to_svm (vcpu)->vmcb->save.efer = efer |MSR_EFER_SVME_MASK ;
@@ -568,6 +573,24 @@ static void init_vmcb(struct vmcb *vmcb) save->cr0 =0x00000010 |X86_CR0_PG |X86_CR0_WP ; save->cr4 =X86_CR4_PAE ;/* rdx = ?? */ + +if (npt_enabled) { +/* Setup VMCB for Nested Paging */ + control->nested_ctl =1 ; + control->intercept_exceptions &= ~(1 <<PF_VECTOR ); + control->intercept_cr_read &= ~(INTERCEPT_CR0_MASK | +INTERCEPT_CR3_MASK | +INTERCEPT_CR4_MASK ); + control->intercept_cr_write &= ~(INTERCEPT_CR0_MASK | +INTERCEPT_CR3_MASK | +INTERCEPT_CR4_MASK ); + save->g_pat =0x0007040600070406ULL ; +/* enable caching because the QEMU Bios doesn't enable it */ + save->cr0 =X86_CR0_ET ; + save->cr3 =0 ; + save->cr4 =0 ; + } + }static int svm_vcpu_reset (struct kvm_vcpu *vcpu)
@@ -789,6 +812,15 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) {struct vcpu_svm *svm =to_svm (vcpu); +if (npt_enabled) { +/* +* re-enable caching here because the QEMU bios +* does not do it - this results in some delay at +* reboot +*/ + cr0 &= ~(X86_CR0_CD |X86_CR0_NW ); + goto set; + }#ifdef CONFIG_X86_64 if (vcpu->arch.shadow_efer &EFER_LME ) {if (!is_paging (vcpu) && (cr0 &X86_CR0_PG )) {
@@ -812,13 +844,16 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) cr0 &= ~(X86_CR0_CD |X86_CR0_NW );if (!vcpu->fpu_active) cr0 |=X86_CR0_TS ; +set: svm->vmcb->save.cr0 = cr0; }static void svm_set_cr4 (struct kvm_vcpu *vcpu,unsigned long cr4) { vcpu->arch.cr4 = cr4; -to_svm (vcpu)->vmcb->save.cr4 = cr4 |X86_CR4_PAE ; +if (!npt_enabled) + cr4 |=X86_CR4_PAE ; +to_svm (vcpu)->vmcb->save.cr4 = cr4; } static void svm_set_segment(struct kvm_vcpu *vcpu,
@@ -1284,14 +1319,31 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm, [SVM_EXIT_WBINVD] = emulate_on_interception, [SVM_EXIT_MONITOR] = invalid_op_interception, [SVM_EXIT_MWAIT] = invalid_op_interception, + [SVM_EXIT_NPF] = pf_interception, }; -static int handle_exit (struct kvm_run *kvm_run,struct kvm_vcpu *vcpu) {struct vcpu_svm *svm =to_svm (vcpu);u32 exit_code = svm->vmcb->control.exit_code; +if (npt_enabled) { +int mmu_reload =0 ; +if (((vcpu->arch.cr0 ^ svm->vmcb->save.cr0) &X86_CR0_PG ) + || ((vcpu->arch.cr4 ^ svm->vmcb->save.cr4) & + (X86_CR4_PGE |X86_CR4_PAE ))) + mmu_reload =1 ; + vcpu->arch.cr0 = svm->vmcb->save.cr0; + vcpu->arch.cr4 = svm->vmcb->save.cr4; + vcpu->arch.cr3 = svm->vmcb->save.cr3; +if (mmu_reload) { +kvm_mmu_reset_context (vcpu); +kvm_mmu_load (vcpu); + } +if (is_pae (vcpu) && !is_long_mode (vcpu)) +load_pdptrs (vcpu, vcpu->arch.cr3); + } +kvm_reput_irq (svm);if (svm->vmcb->control.exit_code ==SVM_EXIT_ERR ) {
@@ -1302,7 +1354,8 @@ static int handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) }if (is_external_interrupt (svm->vmcb->control.exit_int_info) && - exit_code !=SVM_EXIT_EXCP_BASE +PF_VECTOR ) + exit_code !=SVM_EXIT_EXCP_BASE +PF_VECTOR && + exit_code !=SVM_EXIT_NPF ) printk(KERN_ERR "%s: unexpected exit_ini_info 0x%x " "exit_code 0x%x\n", __FUNCTION__, svm->vmcb->control.exit_int_info,
@@ -1636,6 +1689,12 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root) {struct vcpu_svm *svm =to_svm (vcpu); +if (npt_enabled) { + svm->vmcb->control.nested_cr3 = root; +force_new_asid (vcpu); +return ; + } + svm->vmcb->save.cr3 = root;force_new_asid (vcpu);
Signature · 9 lines
1.5.3.7 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 8/8] SVM: add support for Nested Paging
arch/x86/kvm/svm.c MODULE_LICENSE("GPL"); · line 54
Quoted 9 lines · Joerg Roedel
This patch contains the SVM architecture dependent changes for KVM to enable support for the Nested Paging feature of AMD Barcelona and Phenom processors.
arch/x86/kvm/svm.c +4
-0+#ifdef CONFIG_X86_64 +static bool npt_enabled = true; +#else static bool npt_enabled = false; +#endif
I think that i386 + pae can also support npt, with no changes, no?
So we should check CONFIG_X86_PAE, not X86_64.
arch/x86/kvm/svm.c static void init_vmcb(struct vmcb *vmcb) · line 586
Quoted 12 lines
arch/x86/kvm/svm.c +11
-0+ +if (npt_enabled) { +/* Setup VMCB for Nested Paging */ + control->nested_ctl =1 ; + control->intercept_exceptions &= ~(1 <<PF_VECTOR ); + control->intercept_cr_read &= ~(INTERCEPT_CR0_MASK | +INTERCEPT_CR3_MASK | +INTERCEPT_CR4_MASK ); + control->intercept_cr_write &= ~(INTERCEPT_CR0_MASK | +INTERCEPT_CR3_MASK | +INTERCEPT_CR4_MASK );
What happens to lazy fpu if we don't trap cr0 changes?
Perhaps it's worth disabling lazy fpu with npt.
Quoted 18 lines
static int
svm_vcpu_reset(struct kvm_vcpu *vcpu)arch/x86/kvm/svm.c +9
-0@@ -789,6 +812,15 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) {struct vcpu_svm *svm =to_svm (vcpu); +if (npt_enabled) { +/* +* re-enable caching here because the QEMU bios +* does not do it - this results in some delay at +* reboot +*/ + cr0 &= ~(X86_CR0_CD |X86_CR0_NW ); + goto set; + }#ifdef CONFIG_X86_64 if (vcpu->arch.shadow_efer &EFER_LME ) {if (!is_paging (vcpu) && (cr0 &X86_CR0_PG )) {
arch/x86/kvm/svm.c static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) · line 850
Quoted 7 lines
arch/x86/kvm/svm.c +1
-0@@ -812,13 +844,16 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) cr0 &= ~(X86_CR0_CD |X86_CR0_NW );if (!vcpu->fpu_active) cr0 |=X86_CR0_TS ; +set: svm->vmcb->save.cr0 = cr0; }
You could move 'cr0 &= ~(X86_CR0_CD | X86_CR0_NW);' from three lines above the 'set' label downwards, and avoid it in the if () above.
arch/x86/kvm/svm.c static int (*svm_exit_handlers[])(struct vcpu_svm *svm, · line 1348
Quoted 8 lines
arch/x86/kvm/svm.c +2
-0static int handle_exit (struct kvm_run *kvm_run,struct kvm_vcpu *vcpu) {struct vcpu_svm *svm =to_svm (vcpu);u32 exit_code = svm->vmcb->control.exit_code; +if (npt_enabled) { +int mmu_reload =0 ;
blank line
Quoted 4 lines
arch/x86/kvm/svm.c +3
-0+if (((vcpu->arch.cr0 ^ svm->vmcb->save.cr0) &X86_CR0_PG ) + || ((vcpu->arch.cr4 ^ svm->vmcb->save.cr4) & + (X86_CR4_PGE |X86_CR4_PAE )))
arch/x86/kvm/svm.c static int (*svm_exit_handlers[])(struct vcpu_svm *svm, · line 1344
Quoted 10 lines
arch/x86/kvm/svm.c +10
-0+ mmu_reload =1 ; + vcpu->arch.cr0 = svm->vmcb->save.cr0; + vcpu->arch.cr4 = svm->vmcb->save.cr4; + vcpu->arch.cr3 = svm->vmcb->save.cr3; +if (mmu_reload) { +kvm_mmu_reset_context (vcpu); +kvm_mmu_load (vcpu); + } +if (is_pae (vcpu) && !is_long_mode (vcpu)) +load_pdptrs (vcpu, vcpu->arch.cr3);
load_pdptrs() may fail; you need to check that.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 8/8] SVM: add support for Nested Paging
Quoted 13 lines · Avi Kivity
arch/x86/kvm/svm.c MODULE_LICENSE("GPL"); · line 54
Quoted 9 lines · Joerg Roedel
This patch contains the SVM architecture dependent changes for KVM to enable support for the Nested Paging feature of AMD Barcelona and Phenom processors.
arch/x86/kvm/svm.c +4
-0+#ifdef CONFIG_X86_64 +static bool npt_enabled = true; +#else static bool npt_enabled = false; +#endif I think that i386 + pae can also support npt, with no changes, no?
Quoted 1 line
So we should check
CONFIG_X86_PAE, notX86_64.
Yes, I think that too. But its completly untested so I disabled it for the first post of this patchset.
Quoted 15 lines
arch/x86/kvm/svm.c static void init_vmcb(struct vmcb *vmcb) · line 586
Quoted 12 lines
arch/x86/kvm/svm.c +11
-0+ +if (npt_enabled) { +/* Setup VMCB for Nested Paging */ + control->nested_ctl =1 ; + control->intercept_exceptions &= ~(1 <<PF_VECTOR ); + control->intercept_cr_read &= ~(INTERCEPT_CR0_MASK | +INTERCEPT_CR3_MASK | +INTERCEPT_CR4_MASK ); + control->intercept_cr_write &= ~(INTERCEPT_CR0_MASK | +INTERCEPT_CR3_MASK | +INTERCEPT_CR4_MASK );What happens to lazy fpu if we don't trap cr0 changes?
Quoted 1 line
Perhaps it's worth disabling lazy fpu with npt.
It should be implicitly disabled with npt because accesses to cr3 are not intercepted anymore. The svm_set_cr3 function is the only place which disables fpu switching.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 8/8] SVM: add support for Nested Paging
Quoted 10 lines · Joerg Roedel
Quoted 5 lines
What happens to lazy fpu if we don't trap cr0 changes?
Perhaps it's worth disabling lazy fpu with npt.
It should be implicitly disabled with npt because accesses to cr3 are not intercepted anymore. The
svm_set_cr3function is the only place which disables fpu switching.
Okay. We may want to investigate enabling it later, but no hurry now.
On the other hand, we want to trap cr0 so the guest can't control the cache disable bits. Also cr4.pce and cr4.mce.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 8/8] SVM: add support for Nested Paging
Quoted 12 lines · Avi Kivity
Quoted 10 lines · Joerg Roedel
Quoted 5 lines
What happens to lazy fpu if we don't trap cr0 changes?
Perhaps it's worth disabling lazy fpu with npt.
It should be implicitly disabled with npt because accesses to cr3 are not intercepted anymore. The
svm_set_cr3function is the only place which disables fpu switching.
Quoted 4 lines
Okay. We may want to investigate enabling it later, but no hurry now.
On the other hand, we want to trap cr0 so the guest can't control the cache disable bits. Also cr4.pce and cr4.mce.
Is it a problem when the guest disables caching? It disables it only in its own context because it has its own copy of cr0. Cr4.pce can be accessible for the guests because there is no way for them to access the performance counter MSRs. But I am not sure about MCE, I will check that.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [kvm-devel] [PATCH 8/8] SVM: add support for Nested Paging
Quoted 6 lines · Joerg Roedel
Quoted 3 lines
On the other hand, we want to trap cr0 so the guest can't control the cache disable bits. Also cr4.pce and cr4.mce.
Is it a problem when the guest disables caching? It disables it only in its own context because it has its own copy of cr0.
Some Intel processors have a mode where cache coherency is no longer preserved, and we need to prevent that. However from my reading of the AMD manuals, cache coherency is preserved even with caching disabled, so no real issue with disabling the cache.
Quoted 3 lines
Cr4.pce can be
accessible for the guests because there is no way for them to access the performance counter MSRs.
Yes. This was a red herring, cr0.pce only affects userspace rdpmc.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 7 lines · Joerg Roedel
Hi,
here is the first release of patches for KVM to support the Nested Paging (NPT) feature of AMD QuadCore CPUs for comments and public testing. This feature improves the guest performance significantly. I measured an improvement of around 17% using kernbench in my first tests.
Quoted 8 lines
This patch series is basically tested with Linux guests (32 bit legacy paging, 32 bit PAE paging and 64 bit Long Mode). Also tested with Windows Vista 32 bit and 64 bit. All these guests ran successfully with these patches. The patch series only enables NPT for 64 bit Linux hosts at the moment.
Please give these patches a good and deep testing. I hope we have this patchset ready for merging soon.
A quick sniff test and things look pretty good. I was able to start running the install CDs for 32-bit and 64-bit Ubuntu, 32-bit OpenSuSE, 64-bit Fedora, and 32-bit Win2k8. I'll do a more thorough run of kvm-test on Monday when I have a better connection to my machine.
Nice work!
Regards,
Anthony Liguori
Quoted 16 lines
Joerg
Here is the diffstat:
arch/x86/kvm/mmu.c | 81 +++++++++++++++++++++++++++++++++++--- arch/x86/kvm/mmu.h | 6 +++ arch/x86/kvm/svm.c | 94 +++++++++++++++++++++++++++++++++++++++++-- arch/x86/kvm/vmx.c | 7 +++ arch/x86/kvm/x86.c | 1 + include/asm-x86/kvm_host.h | 4 ++ 6 files changed, 182 insertions(+), 11 deletions(-)
Quoted 9 lines
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 4 lines · Anthony Liguori
A quick sniff test and things look pretty good. I was able to start running the install CDs for 32-bit and 64-bit Ubuntu, 32-bit OpenSuSE, 64-bit Fedora, and 32-bit Win2k8. I'll do a more thorough run of kvm-test on Monday when I have a better connection to my machine.
Great. We will do more tests too next week. Life migration is completly untested for now. SMP guests worked also fine with this patches.
Quoted 1 line
Nice work!
Thanks :-)
Joerg
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 3 lines · Joerg Roedel
Hi,
here is the first release of patches for KVM to support the Nested
Paging
Quoted 1 line
(NPT) feature of AMD QuadCore CPUs for comments and public testing.
This
Quoted 5 lines
feature improves the guest performance significantly. I measured an improvement of around 17% using kernbench in my first tests.
This patch series is basically tested with Linux guests (32 bit legacy paging, 32 bit PAE paging and 64 bit Long Mode). Also tested with
Windows
Quoted 2 lines
Vista 32 bit and 64 bit. All these guests ran successfully with these patches. The patch series only enables NPT for 64 bit Linux hosts at
the
Quoted 4 lines
moment.
Please give these patches a good and deep testing. I hope we have this patchset ready for merging soon.
Good. We also ported the EPT patch for Xen to KVM, which we submitted last year. We've been cleaning up the patch with Avi. We are working on live migration support now, and we'll submit the patch once it's done. So please stay tuned.
Quoted 3 lines
Joerg
Jun
---
Intel Open Source Technology Center
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 7 lines · Joerg Roedel
Hi,
here is the first release of patches for KVM to support the Nested Paging (NPT) feature of AMD QuadCore CPUs for comments and public testing. This feature improves the guest performance significantly. I measured an improvement of around 17% using kernbench in my first tests.
Quoted 5 lines
This patch series is basically tested with Linux guests (32 bit legacy paging, 32 bit PAE paging and 64 bit Long Mode). Also tested with Windows Vista 32 bit and 64 bit. All these guests ran successfully with these patches. The patch series only enables NPT for 64 bit Linux hosts at the moment.
Very nice patchset; small, simple, and clean. Apart from the comments I already posted, I'd like to avoid the term 'hap': I find it non-descriptive, and it reminds me of another hypervisor. I suggest 'tlp' for two-level paging.
Since it re-uses non-npt real-mode paging, live migration and swapping will likely work without further changes.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 15 lines · Avi Kivity
Quoted 7 lines · Joerg Roedel
Hi,
here is the first release of patches for KVM to support the Nested Paging (NPT) feature of AMD QuadCore CPUs for comments and public testing. This feature improves the guest performance significantly. I measured an improvement of around 17% using kernbench in my first tests.
Quoted 5 lines
This patch series is basically tested with Linux guests (32 bit legacy paging, 32 bit PAE paging and 64 bit Long Mode). Also tested with Windows Vista 32 bit and 64 bit. All these guests ran successfully with these patches. The patch series only enables NPT for 64 bit Linux hosts at the moment.
Quoted 7 lines
Very nice patchset; small, simple, and clean. Apart from the comments I already posted, I'd like to avoid the term 'hap': I find it non-descriptive, and it reminds me of another hypervisor. I suggest 'tlp' for two-level paging.
Since it re-uses non-npt real-mode paging, live migration and swapping will likely work without further changes.
Yes, I think so too. Thank you for your comments. I will work them into the patchset and run some larger tests on it next week (test with many kinds of guests and some stress testing) to be sure that there are no regressions. I would like to enable NPT per default when the patchset is merged. I will post a new version of the patchset maybe on Thursday or Friday.
Joerg
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 2 lines · Avi Kivity
I find it non-descriptive, and it reminds me of another hypervisor.
I suggest 'tlp' for two-level paging.
That has its own ambiguity; without other context it reads like "two-level pagetable". Anyway, using the same term for the same thing is not a bad idea.
J
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 11 lines · Jeremy Fitzhardinge
Quoted 3 lines · Avi Kivity
I find it non-descriptive, and it reminds me of another hypervisor.
I suggest 'tlp' for two-level paging.That has its own ambiguity; without other context it reads like "two-level pagetable". Anyway, using the same term for the same thing is not a bad idea.
What annoys me about hap and hvm is that it comes from a paravirtualization viewpoint, where pv is the default model, and hardware extensions are an optional addition. With kvm it's the other way round: the base model is full virtualization, and paravirtualization is an optional add-on. I'd rather call traditional shadow paging "software-assisted paging".
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 4 lines · Avi Kivity
Very nice patchset; small, simple, and clean. Apart from the comments I already posted, I'd like to avoid the term 'hap': I find it non-descriptive, and it reminds me of another hypervisor. I suggest 'tlp' for two-level paging.
I renamed HAP to TDP. This stands for Two-Dimensional Paging and is the term which descibes best what happens in my opinion.
Joerg
Signature · 13 lines
| AMD Saxony Limited Liability Company & Co. KG
Operating | Wilschdorfer Landstr. 101, 01109 Dresden, Germany
System | Register Court Dresden: HRA 4896
Research | General Partner authorized to represent:
Center | AMD Saxony LLC (Wilmington, Delaware, US)
| General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/Quoted 12 lines · Joerg Roedel
Quoted 5 lines · Avi Kivity
Very nice patchset; small, simple, and clean. Apart from the comments I already posted, I'd like to avoid the term 'hap': I find it non-descriptive, and it reminds me of another hypervisor. I suggest 'tlp' for two-level paging.
I renamed HAP to TDP. This stands for Two-Dimensional Paging and is the term which descibes best what happens in my opinion.
Yes, it actually describes what is going on in there.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/