KVM: MMU: Fix inherited permissions for emulated guest pte updates

When we emulate a guest pte write, we fail to apply the correct inherited
permissions from the parent ptes.  Now that we store inherited permissions
in the shadow page, we can use that to update the pte permissions correctly.

Signed-off-by: Avi Kivity <avi@qumranet.com>
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h
index 1fc4f9b..211fef8 100644
--- a/drivers/kvm/paging_tmpl.h
+++ b/drivers/kvm/paging_tmpl.h
@@ -327,6 +327,7 @@
 			      int offset_in_pte)
 {
 	pt_element_t gpte;
+	unsigned pte_access;
 
 	gpte = *(const pt_element_t *)pte;
 	if (~gpte & (PT_PRESENT_MASK | PT_ACCESSED_MASK)) {
@@ -337,7 +338,8 @@
 	if (bytes < sizeof(pt_element_t))
 		return;
 	pgprintk("%s: gpte %llx spte %p\n", __FUNCTION__, (u64)gpte, spte);
-	FNAME(set_pte)(vcpu, gpte, spte, ACC_ALL, ACC_ALL,
+	pte_access = page->role.access & FNAME(gpte_access)(vcpu, gpte);
+	FNAME(set_pte)(vcpu, gpte, spte, page->role.access, pte_access,
 		       0, 0, NULL, NULL, gpte_to_gfn(gpte));
 }