Skip to contentSkip to conversation

KVM: MMU: fix check the reserved bits on the gpte of L2

PATCH Applied Xiao Guangrong 3 participants 3 messages Aug 5, 2013 – Aug 7, 2013

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

PATCH 1/1 KVM: MMU: fix check the reserved bits on the gpte of L2

Current code always uses arch.mmu to check the reserved bits on guest gpte which is valid only for L1 guest, we should use arch.nested_mmu instead when we translate gva to gpa for the L2 guest

Fix it by using @mmu instead since it is adapted to the current mmu mode automatically

The bug can be triggered when nested npt is used and L1 guest and L2 guest use different mmu mode

---
 arch/x86/kvm/paging_tmpl.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/paging_tmpl.h +1 -2
index 7769699..3a75828 100644
@@ -218,8 +218,7 @@ retry_walk:
 		if (unlikely(!is_present_gpte(pte)))
 			goto error;
 
-		if (unlikely(is_rsvd_bits_set(&vcpu->arch.mmu, pte,
-					      walker->level))) {
+		if (unlikely(is_rsvd_bits_set(mmu, pte, walker->level))) {
 			errcode |= PFERR_RSVD_MASK | PFERR_PRESENT_MASK;
 			goto error;
 		}
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Xiao Guangrong

Current code always uses arch.mmu to check the reserved bits on guest gpte which is valid only for L1 guest, we should use arch.nested_mmu instead when we translate gva to gpa for the L2 guest

Quoted 8 lines

Fix it by using @mmu instead since it is adapted to the current mmu mode automatically

The bug can be triggered when nested npt is used and L1 guest and L2 guest use different mmu mode

Quoted 20 lines
---
 arch/x86/kvm/paging_tmpl.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/paging_tmpl.h +1 -2
index 7769699..3a75828 100644
@@ -218,8 +218,7 @@ retry_walk:
 		if (unlikely(!is_present_gpte(pte)))
 			goto error;
 
-		if (unlikely(is_rsvd_bits_set(&vcpu->arch.mmu, pte,
-					      walker->level))) {
+		if (unlikely(is_rsvd_bits_set(mmu, pte, walker->level))) {
 			errcode |= PFERR_RSVD_MASK | PFERR_PRESENT_MASK;
 			goto error;
 		}
Signature · 1 line
1.8.1.4

--
Gleb.

maintainer Applied
#2 lore raw
In reply to Xiao Guangrong
Quoted 22 lines · Xiao Guangrong

Current code always uses arch.mmu to check the reserved bits on guest gpte which is valid only for L1 guest, we should use arch.nested_mmu instead when we translate gva to gpa for the L2 guest

Fix it by using @mmu instead since it is adapted to the current mmu mode automatically

The bug can be triggered when nested npt is used and L1 guest and L2 guest use different mmu mode

---
  arch/x86/kvm/paging_tmpl.h | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/paging_tmpl.h +0 -0
index 7769699..3a75828 100644

arch/x86/kvm/paging_tmpl.h retry_walk: · line 224

Quoted 9 lines
arch/x86/kvm/paging_tmpl.h +1 -2
@@ -218,8 +218,7 @@ retry_walk:
  		if (unlikely(!is_present_gpte(pte)))
  			goto error;
 
-		if (unlikely(is_rsvd_bits_set(&vcpu->arch.mmu, pte,
-					      walker->level))) {
+		if (unlikely(is_rsvd_bits_set(mmu, pte, walker->level))) {
  			errcode |= PFERR_RSVD_MASK | PFERR_PRESENT_MASK;
  			goto error;
  		}

Applied, thanks.

Paolo