Skip to contentSkip to conversation

KVM: VMX: remove GUEST_CR3 write from vmx_vcpu_run

PATCH Marcelo Tosatti 3 participants 6 messages Oct 20, 2009 – Oct 22, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 value changes.

arch/x86/kvm/vmx.c +2 -3
index 364263a..325075f 100644
@@ -3638,10 +3638,9 @@ 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);
+	if (enable_ept && is_paging(vcpu))
 		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();
#1 lore raw
Quoted 11 lines · Marcelo Tosatti

GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 value changes.

arch/x86/kvm/vmx.c +0 -0
index 364263a..325075f 100644
@@ -3638,10 +3638,9 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
  {
  	struct vcpu_vmx *vmx = to_vmx(vcpu);

arch/x86/kvm/vmx.c static void vmx_vcpu_run(struct kvm_vcpu *vcpu) · line 3646

Quoted 10 lines
arch/x86/kvm/vmx.c +2 -3
 
-	if (enable_ept&&  is_paging(vcpu)) {
-		vmcs_writel(GUEST_CR3, vcpu->arch.cr3);
+	if (enable_ept&&  is_paging(vcpu))
  		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();

Nice. Any reason why ept_load_pdptrs() couldn't go the same way?

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#2 lore raw
Quoted 12 lines · Avi Kivity
Quoted 11 lines · Marcelo Tosatti

GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 value changes.

arch/x86/kvm/vmx.c +0 -0
index 364263a..325075f 100644
@@ -3638,10 +3638,9 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
  {
  	struct vcpu_vmx *vmx = to_vmx(vcpu);
 
Quoted 12 lines

arch/x86/kvm/vmx.c static void vmx_vcpu_run(struct kvm_vcpu *vcpu) · line 3646

Quoted 10 lines
arch/x86/kvm/vmx.c +2 -3
-	if (enable_ept&&  is_paging(vcpu)) {
-		vmcs_writel(GUEST_CR3, vcpu->arch.cr3);
+	if (enable_ept&&  is_paging(vcpu))
  		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();

Nice. Any reason why ept_load_pdptrs() couldn't go the same way?

Its already protected by VCPU_EXREG_PDPTR caching, so it does not buy much.

The advantage would symmetry to cr3.

#3 lore raw
Quoted 10 lines · Marcelo Tosatti
Quoted 4 lines

Nice. Any reason why ept_load_pdptrs() couldn't go the same way?

Its already protected by VCPU_EXREG_PDPTR caching, so it does not buy much.

The advantage would symmetry to cr3.

Yes, the PDPTRs fulfil exactly the same role as cr3, so the same rules should apply.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#4 lore raw
In reply to Marcelo Tosatti
Quoted 2 lines · On Tuesday 20 October 2009 20:37:20 Marcelo Tosatti wrote:

GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 value changes.

The description is not that accuracy... If CR3 value change in guest when EPT enabled, no VM Exit would happen, then no kvm_set_cr3...

Signature · 2 lines
regards
Yang, Sheng
Quoted 24 lines
arch/x86/kvm/vmx.c +2 -4
index 364263a..325075f 100644
@@ -3638,10 +3638,9 @@ 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);
+	if (enable_ept && is_paging(vcpu))
 		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();
--

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

#5 lore raw
Quoted 8 lines · Sheng Yang
Quoted 3 lines · On Tuesday 20 October 2009 20:37:20 Marcelo Tosatti wrote:

GUEST_CR3 is updated via kvm_set_cr3 whenever CR3 value changes.

The description is not that accuracy... If CR3 value change in guest when EPT enabled, no VM Exit would happen, then no kvm_set_cr3...

True, should be 'changed from userspace'.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.