From 18735b09c490c145bf9174e438a2408bfbd66b76 Mon Sep 17 00:00:00 2001 From: Avi Kivity <avi@redhat.com> Date: Sun, 18 Jul 2010 12:54:31 -0300 Subject: [PATCH] KVM: MMU: fix conflict access permissions in direct sp RH-Author: Avi Kivity <avi@redhat.com> Message-id: <1279457671-16095-1-git-send-email-avi@redhat.com> Patchwork-id: 10778 O-Subject: [PATCH RHEL5.6 RHEL5.5.z] KVM: MMU: fix conflict access permissions in direct sp Bugzilla: 615225 RH-Acked-by: Andrea Arcangeli <aarcange@redhat.com> RH-Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com> RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com> From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Bugzilla: 615225 (R6B crashes as a guest on R6B) Upstream: kvm.git 06f334e2b509b4c9f6c4cec7e0e56444a2730922 In no-direct mapping, we mark sp is 'direct' when we mapping the guest's larger page, but its access is encoded form upper page-struct entire not include the last mapping, it will cause access conflict. For example, have this mapping: [W] / PDE1 -> |---| P[W] | | LPA \ PDE2 -> |---| [R] P have two children, PDE1 and PDE2, both PDE1 and PDE2 mapping the same lage page(LPA). The P's access is WR, PDE1's access is WR, PDE2's access is RO(just consider read-write permissions here) When guest access PDE1, we will create a direct sp for LPA, the sp's access is from P, is W, then we will mark the ptes is W in this sp. Then, guest access PDE2, we will find LPA's shadow page, is the same as PDE's, and mark the ptes is RO. So, if guest access PDE1, the incorrect #PF is occured. Fixed by encode the last mapping access into direct shadow page Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com> --- arch/x86/kvm/paging_tmpl.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- arch/x86/kvm/paging_tmpl.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 3edb7c4..078dae4 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -326,6 +326,7 @@ static int FNAME(shadow_walk_entry)(struct kvm_shadow_walk *_sw, if (!is_dirty_pte(gw->ptes[level - 1])) access &= ~ACC_WRITE_MASK; table_gfn = gpte_to_gfn(gw->ptes[level - 1]); + access &= gw->pte_access; } else { metaphysical = 0; table_gfn = gw->table_gfn[level - 2]; -- 1.7.0.3