]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
x86/ept: pass correct level to p2m_entry_modify
authorRoger Pau Monné <roger.pau@citrix.com>
Tue, 16 Jul 2019 07:05:28 +0000 (09:05 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 16 Jul 2019 07:05:28 +0000 (09:05 +0200)
EPT differs from NPT and shadow when translating page orders to levels
in the physmap page tables. EPT page tables level for order 0 pages is
0, while NPT and shadow instead use 1, ie: EPT page tables levels
starts at 0 while NPT and shadow starts at 1.

Fix the p2m_entry_modify call in atomic_write_ept_entry to always add
one to the level, in order to match NPT and shadow usage.

While there also add a check to ensure p2m_entry_modify is never
called with level == 0. That should allow to catch future errors
related to the level parameter.

Fixes: c7a4c088ad1c ('x86/mm: split p2m ioreq server pages special handling into helper')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/mm/p2m-ept.c
xen/include/asm-x86/p2m.h

index e3044bee2eb1e24c12510eef159e81218315ac61..6b8468c79319d6fc1909c1f5b8805608270c2bcc 100644 (file)
@@ -51,7 +51,7 @@ static int atomic_write_ept_entry(struct p2m_domain *p2m,
                                   int level)
 {
     int rc = p2m_entry_modify(p2m, new.sa_p2mt, entryptr->sa_p2mt,
-                              _mfn(new.mfn), _mfn(entryptr->mfn), level);
+                              _mfn(new.mfn), _mfn(entryptr->mfn), level + 1);
 
     if ( rc )
         return rc;
index 09ef7e02fd0cae85d6b55cb7fdcff216fea1bd64..aff34e3adfbd852a044d0a13c53edb6bc28e101f 100644 (file)
@@ -946,6 +946,7 @@ static inline int p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt,
                                    p2m_type_t ot, mfn_t nfn, mfn_t ofn,
                                    unsigned int level)
 {
+    BUG_ON(!level);
     BUG_ON(level > 1 && (nt == p2m_ioreq_server || nt == p2m_map_foreign));
 
     if ( level != 1 || (nt == ot && mfn_eq(nfn, ofn)) )