[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.12] x86/ept: pass correct level to p2m_entry_modify



commit 50b91232c03f2a150e2aeed4a22227defae1ffb0
Author:     Roger Pau Monné <roger.pau@xxxxxxxxxx>
AuthorDate: Mon Sep 23 14:15:08 2019 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Sep 23 14:15:08 2019 +0200

    x86/ept: pass correct level to p2m_entry_modify
    
    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@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
    master commit: ec2ab491b52815c1daedfdf3d95d13cfe25fb38e
    master date: 2019-07-16 09:05:28 +0200
---
 xen/arch/x86/mm/p2m-ept.c | 2 +-
 xen/include/asm-x86/p2m.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index e3044bee2e..6b8468c793 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -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;
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index c551f4446c..1a38c05537 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -937,6 +937,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)) )
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.12

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.