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

[Xen-changelog] [xen stable-4.8] xen/arm: p2m: Fix incorrect mapping of superpages



commit c427a81dee142a0f7155b8ed7074e1f489336637
Author:     Julien Grall <julien.grall@xxxxxxx>
AuthorDate: Fri May 19 17:08:39 2017 +0100
Commit:     Stefano Stabellini <sstabellini@xxxxxxxxxx>
CommitDate: Mon Jun 12 14:39:54 2017 -0700

    xen/arm: p2m: Fix incorrect mapping of superpages
    
    The same set of functions is used to set as well as to clean P2M
    entries, except for clean operations (INVALID_MFN ~0UL) is passed as a
    parameter. Unfortunately, when calculating an appropriate target order
    for a particular mapping INVALID_MFN is taken into account which leads
    to 4K page target order being set each time even for 2MB and 1GB
    mappings.
    
    This will result to break down the superpage into 4K mappings and leave
    empty tables allocated.
    
    This was introduced by commit 2ef3e36ec7 "xen/arm: p2m: Introduce
    p2m_set_entry and __p2m_set_entry".
    
    Signed-off-by: Julien Grall <julien.grall@xxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
    master-commit-id: 3fafdc28eb98dc1cb686379d83270516fc38049d
---
 xen/arch/arm/p2m.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index c7c726b..f85424b 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1085,12 +1085,18 @@ int p2m_set_entry(struct p2m_domain *p2m,
 
     while ( nr )
     {
+        unsigned long mask;
+        unsigned long order;
+
         /*
+         * Don't take into account the MFN when removing mapping (i.e
+         * MFN_INVALID) to calculate the correct target order.
+         *
          * XXX: Support superpage mappings if nr is not aligned to a
          * superpage size.
          */
-        unsigned long mask = gfn_x(sgfn) | mfn_x(smfn) | nr;
-        unsigned long order;
+        mask = !mfn_eq(smfn, INVALID_MFN) ? mfn_x(smfn) : 0;
+        mask |= gfn_x(sgfn) | nr;
 
         /* Always map 4k by 4k when memaccess is enabled */
         if ( unlikely(p2m->mem_access_enabled) )
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.8

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
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®.