[PATCH 25/35] KVM: VMX: move CR3/PDPTR update to vmx_set_cr3

2009-11-19 Thread Avi Kivity
From: Marcelo Tosatti mtosa...@redhat.com

GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 is modified from
outside guest context. Similarly pdptrs are updated via load_pdptrs.

Let kvm_set_cr3 perform the update, removing it from the vcpu_run
fast path.

Signed-off-by: Marcelo Tosatti mtosa...@redhat.com
Acked-by: Acked-by: Sheng Yang sh...@linux.intel.com
Signed-off-by: Avi Kivity a...@redhat.com
---
 arch/x86/kvm/vmx.c |5 +
 arch/x86/kvm/x86.c |4 +++-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index bf46253..a5f3f3e 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1737,6 +1737,7 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned 
long cr3)
vmcs_write64(EPT_POINTER, eptp);
guest_cr3 = is_paging(vcpu) ? vcpu-arch.cr3 :
vcpu-kvm-arch.ept_identity_map_addr;
+   ept_load_pdptrs(vcpu);
}
 
vmx_flush_tlb(vcpu);
@@ -3625,10 +3626,6 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 {
struct vcpu_vmx *vmx = to_vmx(vcpu);
 
-   if (enable_ept  is_paging(vcpu)) {
-   vmcs_writel(GUEST_CR3, vcpu-arch.cr3);
-   ept_load_pdptrs(vcpu);
-   }
/* Record the guest's net vcpu time for enforced NMI injections. */
if (unlikely(!cpu_has_virtual_nmis()  vmx-soft_vnmi_blocked))
vmx-entry_time = ktime_get();
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index dbddcc2..719f31e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4591,8 +4591,10 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
 
mmu_reset_needed |= vcpu-arch.cr4 != sregs-cr4;
kvm_x86_ops-set_cr4(vcpu, sregs-cr4);
-   if (!is_long_mode(vcpu)  is_pae(vcpu))
+   if (!is_long_mode(vcpu)  is_pae(vcpu)) {
load_pdptrs(vcpu, vcpu-arch.cr3);
+   mmu_reset_needed = 1;
+   }
 
if (mmu_reset_needed)
kvm_mmu_reset_context(vcpu);
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM: VMX: move CR3/PDPTR update to vmx_set_cr3

2009-11-01 Thread Avi Kivity
From: Marcelo Tosatti mtosa...@redhat.com

GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 is modified from
outside guest context. Similarly pdptrs are updated via load_pdptrs.

Let kvm_set_cr3 perform the update, removing it from the vcpu_run
fast path.

Signed-off-by: Marcelo Tosatti mtosa...@redhat.com
Acked-by: Acked-by: Sheng Yang sh...@linux.intel.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a1976c9..85f97d1 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1732,6 +1732,7 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned 
long cr3)
vmcs_write64(EPT_POINTER, eptp);
guest_cr3 = is_paging(vcpu) ? vcpu-arch.cr3 :
vcpu-kvm-arch.ept_identity_map_addr;
+   ept_load_pdptrs(vcpu);
}
 
vmx_flush_tlb(vcpu);
@@ -3620,10 +3621,6 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 {
struct vcpu_vmx *vmx = to_vmx(vcpu);
 
-   if (enable_ept  is_paging(vcpu)) {
-   vmcs_writel(GUEST_CR3, vcpu-arch.cr3);
-   ept_load_pdptrs(vcpu);
-   }
/* Record the guest's net vcpu time for enforced NMI injections. */
if (unlikely(!cpu_has_virtual_nmis()  vmx-soft_vnmi_blocked))
vmx-entry_time = ktime_get();
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 2ef3906..1b27fc8 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4593,8 +4593,10 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
 
mmu_reset_needed |= vcpu-arch.cr4 != sregs-cr4;
kvm_x86_ops-set_cr4(vcpu, sregs-cr4);
-   if (!is_long_mode(vcpu)  is_pae(vcpu))
+   if (!is_long_mode(vcpu)  is_pae(vcpu)) {
load_pdptrs(vcpu, vcpu-arch.cr3);
+   mmu_reset_needed = 1;
+   }
 
if (mmu_reset_needed)
kvm_mmu_reset_context(vcpu);
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: KVM: VMX: move CR3/PDPTR update to vmx_set_cr3

2009-10-27 Thread Avi Kivity

On 10/26/2009 08:48 PM, Marcelo Tosatti wrote:

GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 is modified from
outside guest context. Similarly pdptrs are updated via load_pdptrs.

Let kvm_set_cr3 perform the update, removing it from the vcpu_run
fast path.
   


Applied, thanks.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


KVM: VMX: move CR3/PDPTR update to vmx_set_cr3

2009-10-26 Thread Marcelo Tosatti

GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 is modified from
outside guest context. Similarly pdptrs are updated via load_pdptrs.

Let kvm_set_cr3 perform the update, removing it from the vcpu_run
fast path.

Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

Index: b/arch/x86/kvm/vmx.c
===
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1748,6 +1748,7 @@ static void vmx_set_cr3(struct kvm_vcpu 
vmcs_write64(EPT_POINTER, eptp);
guest_cr3 = is_paging(vcpu) ? vcpu-arch.cr3 :
vcpu-kvm-arch.ept_identity_map_addr;
+   ept_load_pdptrs(vcpu);
}
 
vmx_flush_tlb(vcpu);
@@ -3638,10 +3639,6 @@ static void vmx_vcpu_run(struct kvm_vcpu
 {
struct vcpu_vmx *vmx = to_vmx(vcpu);
 
-   if (enable_ept  is_paging(vcpu)) {
-   vmcs_writel(GUEST_CR3, vcpu-arch.cr3);
-   ept_load_pdptrs(vcpu);
-   }
/* Record the guest's net vcpu time for enforced NMI injections. */
if (unlikely(!cpu_has_virtual_nmis()  vmx-soft_vnmi_blocked))
vmx-entry_time = ktime_get();
Index: b/arch/x86/kvm/x86.c
===
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4517,8 +4517,10 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct
 
mmu_reset_needed |= vcpu-arch.cr4 != sregs-cr4;
kvm_x86_ops-set_cr4(vcpu, sregs-cr4);
-   if (!is_long_mode(vcpu)  is_pae(vcpu))
+   if (!is_long_mode(vcpu)  is_pae(vcpu)) {
load_pdptrs(vcpu, vcpu-arch.cr3);
+   mmu_reset_needed = 1;
+   }
 
if (mmu_reset_needed)
kvm_mmu_reset_context(vcpu);
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: KVM: VMX: move CR3/PDPTR update to vmx_set_cr3

2009-10-26 Thread Yang, Sheng
On Tuesday 27 October 2009 02:48:33 Marcelo Tosatti wrote:
 GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 is modified from
 outside guest context. Similarly pdptrs are updated via load_pdptrs.

 Let kvm_set_cr3 perform the update, removing it from the vcpu_run
 fast path.

Looks fine to me.

Acked-by: Sheng Yang sh...@linux.intel.com

-- 
regards
Yang, Sheng

 Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

 Index: b/arch/x86/kvm/vmx.c
 ===
 --- a/arch/x86/kvm/vmx.c
 +++ b/arch/x86/kvm/vmx.c
 @@ -1748,6 +1748,7 @@ static void vmx_set_cr3(struct kvm_vcpu
   vmcs_write64(EPT_POINTER, eptp);
   guest_cr3 = is_paging(vcpu) ? vcpu-arch.cr3 :
   vcpu-kvm-arch.ept_identity_map_addr;
 + ept_load_pdptrs(vcpu);
   }

   vmx_flush_tlb(vcpu);
 @@ -3638,10 +3639,6 @@ static void vmx_vcpu_run(struct kvm_vcpu
  {
   struct vcpu_vmx *vmx = to_vmx(vcpu);

 - if (enable_ept  is_paging(vcpu)) {
 - vmcs_writel(GUEST_CR3, vcpu-arch.cr3);
 - ept_load_pdptrs(vcpu);
 - }
   /* Record the guest's net vcpu time for enforced NMI injections. */
   if (unlikely(!cpu_has_virtual_nmis()  vmx-soft_vnmi_blocked))
   vmx-entry_time = ktime_get();
 Index: b/arch/x86/kvm/x86.c
 ===
 --- a/arch/x86/kvm/x86.c
 +++ b/arch/x86/kvm/x86.c
 @@ -4517,8 +4517,10 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct

   mmu_reset_needed |= vcpu-arch.cr4 != sregs-cr4;
   kvm_x86_ops-set_cr4(vcpu, sregs-cr4);
 - if (!is_long_mode(vcpu)  is_pae(vcpu))
 + if (!is_long_mode(vcpu)  is_pae(vcpu)) {
   load_pdptrs(vcpu, vcpu-arch.cr3);
 + mmu_reset_needed = 1;
 + }

   if (mmu_reset_needed)
   kvm_mmu_reset_context(vcpu);

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html