Skip to contentSkip to conversation

pvh/dom0/shadow/amd fixes

PATCH Superseded Roger Pau Monne 4 participants 14 messages Feb 21, 2019 – Feb 26, 2019

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover pvh/dom0/shadow/amd fixes

The remaining set of patches contain changes to the p2m code that could affect HVM guests. Note that without those changes a PVH dom0 running on AMD hardware will be unable to create guests. Overall the patches are a nice cleanup to the handling of p2m_ioreq_server and p2m_map_foreign types IMO.

The series can also be found at:

git://xenbits.xen.org/people/royger/xen.git fixes-v5

Thanks, Roger.

Roger Pau Monne (5):
x86/p2m: pass the p2m to write_p2m_entry handlers x86/mm: split p2m ioreq server pages special handling into helper
p2m: change write_p2m_entry to return an error code x86/mm: handle foreign mappings in p2m_entry_modify npt/shadow: allow getting foreign page table entries

 xen/arch/x86/mm/hap/hap.c        |  17 ++++-
 xen/arch/x86/mm/hap/nested_hap.c |   4 +-
 xen/arch/x86/mm/p2m-ept.c        | 106 ++++++---------------------
 xen/arch/x86/mm/p2m-pt.c         | 118 ++++++++++++++++++-------------
 xen/arch/x86/mm/paging.c         |  12 ++--
 xen/arch/x86/mm/shadow/common.c  |  18 ++++-
 xen/arch/x86/mm/shadow/none.c    |   7 +-
 xen/arch/x86/mm/shadow/private.h |   6 +-
 xen/include/asm-x86/p2m.h        |  62 +++++++++++++++-
 xen/include/asm-x86/paging.h     |   9 +--
 10 files changed, 204 insertions(+), 155 deletions(-)
Signature · 7 lines
2.17.2 (Apple Git-113)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH v5 1/5 x86/p2m: pass the p2m to write_p2m_entry handlers

Current callers pass the p2m to paging_write_p2m_entry, but the implementation specific handlers of the write_p2m_entry hook instead of a p2m get a domain struct due to the handling done in paging_write_p2m_entry.

Change the code so that the implementations of write_p2m_entry take a p2m instead of a domain.

This is a non-functional change, but will be used by follow up patches.

---
Cc: George Dunlap <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Tim Deegan <[email protected]>
---
Changes since v4:
- New in this version.

---
 xen/arch/x86/mm/hap/hap.c        | 3 ++-
 xen/arch/x86/mm/paging.c         | 2 +-
 xen/arch/x86/mm/shadow/common.c  | 4 +++-
 xen/arch/x86/mm/shadow/none.c    | 2 +-
 xen/arch/x86/mm/shadow/private.h | 2 +-
 xen/include/asm-x86/paging.h     | 3 ++-
 6 files changed, 10 insertions(+), 6 deletions(-)
xen/arch/x86/mm/hap/hap.c +2 -1
index 3d651b94c3..28fe48d158 100644
@@ -709,9 +709,10 @@ static void hap_update_paging_modes(struct vcpu *v)
 }
 
 static void
-hap_write_p2m_entry(struct domain *d, unsigned long gfn, l1_pgentry_t *p,
+hap_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, l1_pgentry_t *p,
                     l1_pgentry_t new, unsigned int level)
 {
+    struct domain *d = p2m->domain;
     uint32_t old_flags;
     bool_t flush_nestedp2m = 0;
 
xen/arch/x86/mm/paging.c +1 -1
index d5836eb688..e6ed3006fe 100644
@@ -941,7 +941,7 @@ void paging_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
     if ( v->domain != d )
         v = d->vcpu ? d->vcpu[0] : NULL;
     if ( likely(v && paging_mode_enabled(d) && paging_get_hostmode(v) != NULL) )
-        paging_get_hostmode(v)->write_p2m_entry(d, gfn, p, new, level);
+        paging_get_hostmode(v)->write_p2m_entry(p2m, gfn, p, new, level);
     else
         safe_write_pte(p, new);
 }
xen/arch/x86/mm/shadow/common.c +3 -1
index 07840ff727..6c67ef4996 100644
@@ -3177,10 +3177,12 @@ static void sh_unshadow_for_p2m_change(struct domain *d, unsigned long gfn,
 }
 
 void
-shadow_write_p2m_entry(struct domain *d, unsigned long gfn,
+shadow_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
                        l1_pgentry_t *p, l1_pgentry_t new,
                        unsigned int level)
 {
+    struct domain *d = p2m->domain;
+
     paging_lock(d);
 
     /* If there are any shadows, update them.  But if shadow_teardown()
xen/arch/x86/mm/shadow/none.c +1 -1
index 4de645a433..316002771d 100644
@@ -60,7 +60,7 @@ static void _update_paging_modes(struct vcpu *v)
     ASSERT_UNREACHABLE();
 }
 
-static void _write_p2m_entry(struct domain *d, unsigned long gfn,
+static void _write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
                              l1_pgentry_t *p, l1_pgentry_t new,
                              unsigned int level)
 {
xen/arch/x86/mm/shadow/private.h +1 -1
index e8ed7ac714..0aaed1edfc 100644
@@ -372,7 +372,7 @@ extern int sh_remove_write_access(struct domain *d, mfn_t readonly_mfn,
                                   unsigned long fault_addr);
 
 /* Functions that atomically write PT/P2M entries and update state */
-void shadow_write_p2m_entry(struct domain *d, unsigned long gfn,
+void shadow_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
                             l1_pgentry_t *p, l1_pgentry_t new,
                             unsigned int level);
 
xen/include/asm-x86/paging.h +2 -1
index fdcc22844b..7ec09d7b11 100644
@@ -124,7 +124,8 @@ struct paging_mode {
     void          (*update_cr3            )(struct vcpu *v, int do_locking,
                                             bool noflush);
     void          (*update_paging_modes   )(struct vcpu *v);
-    void          (*write_p2m_entry       )(struct domain *d, unsigned long gfn,
+    void          (*write_p2m_entry       )(struct p2m_domain *p2m,
+                                            unsigned long gfn,
                                             l1_pgentry_t *p, l1_pgentry_t new,
                                             unsigned int level);
 
Signature · 7 lines
2.17.2 (Apple Git-113)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v5 1/5
#2 lore raw

Re: [PATCH v5 1/5] x86/p2m: pass the p2m to write_p2m_entry handlers

Quoted 5 lines · Roger Pau Monne

Current callers pass the p2m to paging_write_p2m_entry, but the implementation specific handlers of the write_p2m_entry hook instead of a p2m get a domain struct due to the handling done in paging_write_p2m_entry.

Quoted 7 lines

Change the code so that the implementations of write_p2m_entry take a p2m instead of a domain.

This is a non-functional change, but will be used by follow up patches.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v5 1/5
#3 lore raw

Re: [PATCH v5 1/5] x86/p2m: pass the p2m to write_p2m_entry handlers

In reply to Roger Pau Monne
Quoted 5 lines · Roger Pau Monne

Current callers pass the p2m to paging_write_p2m_entry, but the implementation specific handlers of the write_p2m_entry hook instead of a p2m get a domain struct due to the handling done in paging_write_p2m_entry.

Quoted 7 lines

Change the code so that the implementations of write_p2m_entry take a p2m instead of a domain.

This is a non-functional change, but will be used by follow up patches.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

PATCH v5 2/5 x86/mm: split p2m ioreq server pages special handling into helper

In reply to Roger Pau Monne

So that it can be shared by both ept, npt and shadow code, instead of duplicating it.

No change in functionality intended.

---
Cc: George Dunlap <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: Tim Deegan <[email protected]>
---
Changes since v4:
- Remove the p2m_get_hostp2m from callers of p2m_entry_modify.

Changes since v1:
- Remove unused p2mt_old from p2m_pt_set_entry.

---
 xen/arch/x86/mm/hap/hap.c       |  3 ++
 xen/arch/x86/mm/p2m-ept.c       | 55 +++++++++++----------------------
 xen/arch/x86/mm/p2m-pt.c        | 24 --------------
 xen/arch/x86/mm/shadow/common.c |  3 ++
 xen/include/asm-x86/p2m.h       | 32 +++++++++++++++++++
 5 files changed, 56 insertions(+), 61 deletions(-)
xen/arch/x86/mm/hap/hap.c +3 -0
index 28fe48d158..2db7f2c04a 100644
@@ -735,6 +735,9 @@ hap_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, l1_pgentry_t *p,
             && perms_strictly_increased(old_flags, l1e_get_flags(new)) );
     }
 
+    p2m_entry_modify(p2m, p2m_flags_to_type(l1e_get_flags(new)),
+                     p2m_flags_to_type(old_flags), level);
+
     safe_write_pte(p, new);
     if ( old_flags & _PAGE_PRESENT )
         flush_tlb_mask(d->dirty_cpumask);
xen/arch/x86/mm/p2m-ept.c +18 -37

146 lines not on this page · raw message

xen/arch/x86/mm/p2m-pt.c +0 -24
index 52eaa24b18..04e9d81cf6 100644
@@ -436,13 +436,6 @@ static int do_recalc(struct p2m_domain *p2m, unsigned long gfn)
                 flags |= _PAGE_PSE;
             }
 
-            if ( ot == p2m_ioreq_server )
-            {
-                ASSERT(p2m->ioreq.entry_count > 0);
-                ASSERT(level == 0);
-                p2m->ioreq.entry_count--;
-            }
-
             e = l1e_from_pfn(mfn, flags);
             p2m_add_iommu_flags(&e, level,
                                 (nt == p2m_ram_rw)
@@ -616,8 +609,6 @@ p2m_pt_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn,
 
     if ( page_order == PAGE_ORDER_4K )
     {
-        p2m_type_t p2mt_old;
-
         rc = p2m_next_level(p2m, &table, &gfn_remainder, gfn,
                             L2_PAGETABLE_SHIFT - PAGE_SHIFT,
                             L2_PAGETABLE_ENTRIES, 1, 1);
@@ -641,21 +632,6 @@ p2m_pt_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn,
         if ( entry_content.l1 != 0 )
             p2m_add_iommu_flags(&entry_content, 0, iommu_pte_flags);
 
-        p2mt_old = p2m_flags_to_type(l1e_get_flags(*p2m_entry));
-
-        /*
-         * p2m_ioreq_server is only used for 4K pages, so
-         * the count is only done for level 1 entries.
-         */
-        if ( p2mt == p2m_ioreq_server )
-            p2m->ioreq.entry_count++;
-
-        if ( p2mt_old == p2m_ioreq_server )
-        {
-            ASSERT(p2m->ioreq.entry_count > 0);
-            p2m->ioreq.entry_count--;
-        }
-
         /* level 1 entry */
         p2m->write_p2m_entry(p2m, gfn, p2m_entry, entry_content, 1);
         /* NB: paging_write_p2m_entry() handles tlb flushes properly */
xen/arch/x86/mm/shadow/common.c +3 -0
index 6c67ef4996..de7abf7150 100644
@@ -3190,6 +3190,9 @@ shadow_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
     if ( likely(d->arch.paging.shadow.total_pages != 0) )
          sh_unshadow_for_p2m_change(d, gfn, p, new, level);
 
+    p2m_entry_modify(p2m, p2m_flags_to_type(l1e_get_flags(new)),
+                     p2m_flags_to_type(l1e_get_flags(*p)), level);
+
     /* Update the entry with new content */
     safe_write_pte(p, new);
 
xen/include/asm-x86/p2m.h +32 -0
index 2095076556..834d49d2d4 100644
@@ -932,6 +932,38 @@ int p2m_set_ioreq_server(struct domain *d, unsigned int flags,
 struct hvm_ioreq_server *p2m_get_ioreq_server(struct domain *d,
                                               unsigned int *flags);
 
+static inline void p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt,
+                                    p2m_type_t ot, unsigned int level)
+{
+    if ( level != 1 || nt == ot )
+        return;
+
+    switch ( nt )
+    {
+    case p2m_ioreq_server:
+        /*
+         * p2m_ioreq_server is only used for 4K pages, so
+         * the count is only done for level 1 entries.
+         */
+        p2m->ioreq.entry_count++;
+        break;
+
+    default:
+        break;
+    }
+
+    switch ( ot )
+    {
+    case p2m_ioreq_server:
+        ASSERT(p2m->ioreq.entry_count > 0);
+        p2m->ioreq.entry_count--;
+        break;
+
+    default:
+        break;
+    }
+}
+
 #endif /* _XEN_ASM_X86_P2M_H */
 
 /*
Signature · 7 lines
2.17.2 (Apple Git-113)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw

PATCH v5 3/5 p2m: change write_p2m_entry to return an error code

In reply to Roger Pau Monne

This is in preparation for also changing p2m_entry_modify to return an error code.

No functional change intended.

---
Cc: George Dunlap <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Tim Deegan <[email protected]>
---
Changes since v4:
- Handle errors in loops to avoid overwriting the variable containing the error code in non-debug builds.
- Change error handling in p2m_next_level so it's done in a single place.

Changes since v3:
- Use asserts instead of bugs to check return code from write_p2m_entry from callers that don't support or expect write_p2m_entry to fail.

Changes since v2:
- New in this version.

---
 xen/arch/x86/mm/hap/hap.c        |  4 +-
 xen/arch/x86/mm/hap/nested_hap.c |  4 +-
 xen/arch/x86/mm/p2m-pt.c         | 83 ++++++++++++++++++++++++++------
 xen/arch/x86/mm/paging.c         | 12 +++--
 xen/arch/x86/mm/shadow/common.c  |  4 +-
 xen/arch/x86/mm/shadow/none.c    |  7 +--
 xen/arch/x86/mm/shadow/private.h |  6 +--
 xen/include/asm-x86/p2m.h        |  4 +-
 xen/include/asm-x86/paging.h     |  8 +--
 9 files changed, 97 insertions(+), 35 deletions(-)
xen/arch/x86/mm/hap/hap.c +3 -1
index 2db7f2c04a..fdf77c59a5 100644
@@ -708,7 +708,7 @@ static void hap_update_paging_modes(struct vcpu *v)
     put_gfn(d, cr3_gfn);
 }
 
-static void
+static int
 hap_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, l1_pgentry_t *p,
                     l1_pgentry_t new, unsigned int level)
 {
@@ -746,6 +746,8 @@ hap_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, l1_pgentry_t *p,
 
     if ( flush_nestedp2m )
         p2m_flush_nestedp2m(d);
+
+    return 0;
 }
 
 static unsigned long hap_gva_to_gfn_real_mode(
xen/arch/x86/mm/hap/nested_hap.c +3 -1
index d2a07a5c79..abe5958a52 100644
@@ -71,7 +71,7 @@
 /*        NESTED VIRT P2M FUNCTIONS         */
 /********************************************/
 
-void
+int
 nestedp2m_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
     l1_pgentry_t *p, l1_pgentry_t new, unsigned int level)
 {
@@ -87,6 +87,8 @@ nestedp2m_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
         flush_tlb_mask(p2m->dirty_cpumask);
 
     paging_unlock(d);
+
+    return 0;
 }
 
 /********************************************/
xen/arch/x86/mm/p2m-pt.c +67 -16

171 lines not on this page · raw message

xen/arch/x86/mm/paging.c +8 -4
index e6ed3006fe..21db3eceb6 100644
@@ -932,18 +932,22 @@ void paging_update_nestedmode(struct vcpu *v)
 }
 #endif
 
-void paging_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
-                            l1_pgentry_t *p, l1_pgentry_t new,
-                            unsigned int level)
+int paging_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
+                           l1_pgentry_t *p, l1_pgentry_t new,
+                           unsigned int level)
 {
     struct domain *d = p2m->domain;
     struct vcpu *v = current;
+    int rc = 0;
+
     if ( v->domain != d )
         v = d->vcpu ? d->vcpu[0] : NULL;
     if ( likely(v && paging_mode_enabled(d) && paging_get_hostmode(v) != NULL) )
-        paging_get_hostmode(v)->write_p2m_entry(p2m, gfn, p, new, level);
+        rc = paging_get_hostmode(v)->write_p2m_entry(p2m, gfn, p, new, level);
     else
         safe_write_pte(p, new);
+
+    return rc;
 }
 
 int paging_set_allocation(struct domain *d, unsigned int pages, bool *preempted)
xen/arch/x86/mm/shadow/common.c +3 -1
index de7abf7150..c818112360 100644
@@ -3176,7 +3176,7 @@ static void sh_unshadow_for_p2m_change(struct domain *d, unsigned long gfn,
     }
 }
 
-void
+int
 shadow_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
                        l1_pgentry_t *p, l1_pgentry_t new,
                        unsigned int level)
@@ -3211,6 +3211,8 @@ shadow_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
 #endif
 
     paging_unlock(d);
+
+    return 0;
 }
 
 /**************************************************************************/
xen/arch/x86/mm/shadow/none.c +4 -3
index 316002771d..1b54ec05a8 100644
@@ -60,11 +60,12 @@ static void _update_paging_modes(struct vcpu *v)
     ASSERT_UNREACHABLE();
 }
 
-static void _write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
-                             l1_pgentry_t *p, l1_pgentry_t new,
-                             unsigned int level)
+static int _write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
+                            l1_pgentry_t *p, l1_pgentry_t new,
+                            unsigned int level)
 {
     ASSERT_UNREACHABLE();
+    return -ENOSYS;
 }
 
 static const struct paging_mode sh_paging_none = {
xen/arch/x86/mm/shadow/private.h +3 -3
index 0aaed1edfc..580ef3e29e 100644
@@ -372,9 +372,9 @@ extern int sh_remove_write_access(struct domain *d, mfn_t readonly_mfn,
                                   unsigned long fault_addr);
 
 /* Functions that atomically write PT/P2M entries and update state */
-void shadow_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
-                            l1_pgentry_t *p, l1_pgentry_t new,
-                            unsigned int level);
+int shadow_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
+                           l1_pgentry_t *p, l1_pgentry_t new,
+                           unsigned int level);
 
 /* Update all the things that are derived from the guest's CR0/CR3/CR4.
  * Called to initialize paging structures if the paging mode
xen/include/asm-x86/p2m.h +2 -2
index 834d49d2d4..f4ec2becbd 100644
@@ -265,7 +265,7 @@ struct p2m_domain {
                                                   unsigned long last_gfn);
     void               (*memory_type_changed)(struct p2m_domain *p2m);
     
-    void               (*write_p2m_entry)(struct p2m_domain *p2m,
+    int                (*write_p2m_entry)(struct p2m_domain *p2m,
                                           unsigned long gfn, l1_pgentry_t *p,
                                           l1_pgentry_t new, unsigned int level);
     long               (*audit_p2m)(struct p2m_domain *p2m);
@@ -837,7 +837,7 @@ void p2m_flush_nestedp2m(struct domain *d);
 /* Flushes the np2m specified by np2m_base (if it exists) */
 void np2m_flush_base(struct vcpu *v, unsigned long np2m_base);
 
-void nestedp2m_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
+int nestedp2m_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
     l1_pgentry_t *p, l1_pgentry_t new, unsigned int level);
 
 /*
xen/include/asm-x86/paging.h +4 -4
index 7ec09d7b11..18a7eaeca4 100644
@@ -124,7 +124,7 @@ struct paging_mode {
     void          (*update_cr3            )(struct vcpu *v, int do_locking,
                                             bool noflush);
     void          (*update_paging_modes   )(struct vcpu *v);
-    void          (*write_p2m_entry       )(struct p2m_domain *p2m,
+    int           (*write_p2m_entry       )(struct p2m_domain *p2m,
                                             unsigned long gfn,
                                             l1_pgentry_t *p, l1_pgentry_t new,
                                             unsigned int level);
@@ -340,9 +340,9 @@ static inline void safe_write_pte(l1_pgentry_t *p, l1_pgentry_t new)
  * we are writing. */
 struct p2m_domain;
 
-void paging_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
-                            l1_pgentry_t *p, l1_pgentry_t new,
-                            unsigned int level);
+int paging_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
+                           l1_pgentry_t *p, l1_pgentry_t new,
+                           unsigned int level);
 
 /*
  * Called from the guest to indicate that the a process is being
Signature · 7 lines
2.17.2 (Apple Git-113)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw

Re: [PATCH v5 3/5] p2m: change write_p2m_entry to return an error code

On Thu, Feb 21, 2019 at 05:50:39PM +0100, Roger Pau Monne wrote:
[...]

xen/arch/x86/mm/p2m-pt.c p2m_next_level(struct p2m_domain *p2m, void **table, · line 187

Quoted 9 lines
xen/arch/x86/mm/p2m-pt.c +1 -0
index 04e9d81cf6..254c5dfd19 100644
@@ -184,6 +184,8 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
     l1_pgentry_t *p2m_entry, new_entry;
     void *next;
     unsigned int flags;
+    int rc;

Shouldn't rc be initialised to 0 here? There seems to be a path which can leave rc uninitialised without calling write_p2m_entry.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw

Re: [PATCH v5 3/5] p2m: change write_p2m_entry to return an error code

In reply to Roger Pau Monne

xen/arch/x86/mm/p2m-pt.c p2m_next_level(struct p2m_domain *p2m, void **table, · line 209

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 21.02.19 at 17:50, <[email protected]> wrote:
xen/arch/x86/mm/p2m-pt.c +3 -1
@@ -202,13 +204,14 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
         new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
 
         p2m_add_iommu_flags(&new_entry, level, IOMMUF_readable|IOMMUF_writable);
-        p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
+        rc = p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
+        if ( rc )
+            ASSERT_UNREACHABLE();

Why not simply ASSERT(!rc)? Also further down then.

Quoted 5 lines
xen/arch/x86/mm/shadow/none.c +0 -0
@@ -60,11 +60,12 @@ static void _update_paging_modes(struct vcpu *v)
     ASSERT_UNREACHABLE();
 }

xen/arch/x86/mm/shadow/none.c static void _update_paging_modes(struct vcpu *v) · line 68

Quoted 10 lines
xen/arch/x86/mm/shadow/none.c +4 -3
 
-static void _write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
-                             l1_pgentry_t *p, l1_pgentry_t new,
-                             unsigned int level)
+static int _write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
+                            l1_pgentry_t *p, l1_pgentry_t new,
+                            unsigned int level)
 {
     ASSERT_UNREACHABLE();
+    return -ENOSYS;

-EOPNOTSUPP or basically anything else, but not -ENOSYS please.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw

Re: [PATCH v5 3/5] p2m: change write_p2m_entry to return an error code

In reply to Roger Pau Monne
Quoted 7 lines · Roger Pau Monne

This is in preparation for also changing p2m_entry_modify to return an error code.

No functional change intended.

---

[snip]

Quoted 68 lines
xen/arch/x86/mm/p2m-pt.c +22 -7
index 04e9d81cf6..254c5dfd19 100644
@@ -184,6 +184,8 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
     l1_pgentry_t *p2m_entry, new_entry;
     void *next;
     unsigned int flags;
+    int rc;
+    mfn_t mfn = INVALID_MFN;
 
     if ( !(p2m_entry = p2m_find_entry(*table, gfn_remainder, gfn,
                                       shift, max)) )
@@ -194,7 +196,7 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
     /* PoD/paging: Not present doesn't imply empty. */
     if ( !flags )
     {
-        mfn_t mfn = p2m_alloc_ptp(p2m, level);
+        mfn = p2m_alloc_ptp(p2m, level);
 
         if ( mfn_eq(mfn, INVALID_MFN) )
             return -ENOMEM;
@@ -202,13 +204,14 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
         new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
 
         p2m_add_iommu_flags(&new_entry, level, IOMMUF_readable|IOMMUF_writable);
-        p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
+        rc = p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
+        if ( rc )
+            ASSERT_UNREACHABLE();
     }
     else if ( flags & _PAGE_PSE )
     {
         /* Split superpages pages into smaller ones. */
         unsigned long pfn = l1e_get_pfn(*p2m_entry);
-        mfn_t mfn;
         l1_pgentry_t *l1_entry;
         unsigned int i;
 
@@ -250,18 +253,37 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
         {
             new_entry = l1e_from_pfn(pfn | (i << ((level - 1) * PAGETABLE_ORDER)),
                                      flags);
-            p2m->write_p2m_entry(p2m, gfn, l1_entry + i, new_entry, level);
+            rc = p2m->write_p2m_entry(p2m, gfn, l1_entry + i, new_entry, level);
+            if ( rc )
+            {
+                ASSERT_UNREACHABLE();
+                break;
+            }
         }
 
         unmap_domain_page(l1_entry);
 
-        new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
-        p2m_add_iommu_flags(&new_entry, level, IOMMUF_readable|IOMMUF_writable);
-        p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
+        if ( !rc )
+        {
+            new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
+            p2m_add_iommu_flags(&new_entry, level,
+                                IOMMUF_readable|IOMMUF_writable);
+            rc = p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry,
+                                      level + 1);
+            if ( rc )
+                ASSERT_UNREACHABLE();
+        }
     }

xen/arch/x86/mm/p2m-pt.c p2m_next_level(struct p2m_domain *p2m, void **table, · line 286

Quoted 10 lines
xen/arch/x86/mm/p2m-pt.c +7 -0
     else
         ASSERT(flags & _PAGE_PRESENT);
 
+    if ( rc )
+    {
+        ASSERT(mfn_valid(mfn));
+        p2m_free_ptp(p2m, mfn_to_page(mfn));
+        return rc;
+    }
+

I think the idiomatic way to deal with this would be to have a label at the end that everything jumps to something like the attached? That way you don't have to spend mental effort making sure that nothing happens between the error and the clean-up call.

Everything else looks good to me; thanks for doing this.

-George

xen/arch/x86/mm/p2m-pt.c +18 -17
index 254c5dfd19..1eb22bd06e 100644
@@ -206,7 +206,10 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
         p2m_add_iommu_flags(&new_entry, level, IOMMUF_readable|IOMMUF_writable);
         rc = p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
         if ( rc )
+        {
             ASSERT_UNREACHABLE();
+            goto free_ptp;
+        }
     }
     else if ( flags & _PAGE_PSE )
     {
@@ -257,39 +260,37 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
             if ( rc )
             {
                 ASSERT_UNREACHABLE();
-                break;
+                unmap_domain_page(l1_entry);
+                goto free_ptp;
             }
         }
 
         unmap_domain_page(l1_entry);
 
-        if ( !rc )
-        {
-            new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
-            p2m_add_iommu_flags(&new_entry, level,
-                                IOMMUF_readable|IOMMUF_writable);
-            rc = p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry,
-                                      level + 1);
-            if ( rc )
-                ASSERT_UNREACHABLE();
+        new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
+        p2m_add_iommu_flags(&new_entry, level,
+                            IOMMUF_readable|IOMMUF_writable);
+        rc = p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry,
+                                  level + 1);
+        if ( rc ) {
+            ASSERT_UNREACHABLE();
+            goto free_ptp;
         }
     }
     else
         ASSERT(flags & _PAGE_PRESENT);
 
-    if ( rc )
-    {
-        ASSERT(mfn_valid(mfn));
-        p2m_free_ptp(p2m, mfn_to_page(mfn));
-        return rc;
-    }
-
     next = map_domain_page(l1e_get_mfn(*p2m_entry));
     if ( unmap )
         unmap_domain_page(*table);
     *table = next;
 
     return 0;
+
+ free_ptp:
+    ASSERT(mfn_valid(mfn));
+    p2m_free_ptp(p2m, mfn_to_page(mfn));
+    return rc;
 }
 
 /*

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#9 lore raw

Re: [PATCH v5 3/5] p2m: change write_p2m_entry to return an error code

Quoted 80 lines · George Dunlap
Quoted 7 lines · Roger Pau Monne

This is in preparation for also changing p2m_entry_modify to return an error code.

No functional change intended.

---

[snip]

Quoted 71 lines
xen/arch/x86/mm/p2m-pt.c +22 -7
index 04e9d81cf6..254c5dfd19 100644
@@ -184,6 +184,8 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
     l1_pgentry_t *p2m_entry, new_entry;
     void *next;
     unsigned int flags;
+    int rc;
+    mfn_t mfn = INVALID_MFN;
 
     if ( !(p2m_entry = p2m_find_entry(*table, gfn_remainder, gfn,
                                       shift, max)) )
@@ -194,7 +196,7 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
     /* PoD/paging: Not present doesn't imply empty. */
     if ( !flags )
     {
-        mfn_t mfn = p2m_alloc_ptp(p2m, level);
+        mfn = p2m_alloc_ptp(p2m, level);
 
         if ( mfn_eq(mfn, INVALID_MFN) )
             return -ENOMEM;
@@ -202,13 +204,14 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
         new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
 
         p2m_add_iommu_flags(&new_entry, level, IOMMUF_readable|IOMMUF_writable);
-        p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
+        rc = p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
+        if ( rc )
+            ASSERT_UNREACHABLE();
     }
     else if ( flags & _PAGE_PSE )
     {
         /* Split superpages pages into smaller ones. */
         unsigned long pfn = l1e_get_pfn(*p2m_entry);
-        mfn_t mfn;
         l1_pgentry_t *l1_entry;
         unsigned int i;
 
@@ -250,18 +253,37 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
         {
             new_entry = l1e_from_pfn(pfn | (i << ((level - 1) * PAGETABLE_ORDER)),
                                      flags);
-            p2m->write_p2m_entry(p2m, gfn, l1_entry + i, new_entry, level);
+            rc = p2m->write_p2m_entry(p2m, gfn, l1_entry + i, new_entry, level);
+            if ( rc )
+            {
+                ASSERT_UNREACHABLE();
+                break;
+            }
         }
 
         unmap_domain_page(l1_entry);
 
-        new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
-        p2m_add_iommu_flags(&new_entry, level, IOMMUF_readable|IOMMUF_writable);
-        p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
+        if ( !rc )
+        {
+            new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
+            p2m_add_iommu_flags(&new_entry, level,
+                                IOMMUF_readable|IOMMUF_writable);
+            rc = p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry,
+                                      level + 1);
+            if ( rc )
+                ASSERT_UNREACHABLE();
+        }
     }
     else
         ASSERT(flags & _PAGE_PRESENT);
 
Quoted 12 lines

xen/arch/x86/mm/p2m-pt.c p2m_next_level(struct p2m_domain *p2m, void **table, · line 286

Quoted 7 lines
xen/arch/x86/mm/p2m-pt.c +7 -0
+    if ( rc )
+    {
+        ASSERT(mfn_valid(mfn));
+        p2m_free_ptp(p2m, mfn_to_page(mfn));
+        return rc;
+    }
+

I think the idiomatic way to deal with this would be to have a label at the end that everything jumps to something like the attached? That way you don't have to spend mental effort making sure that nothing happens between the error and the clean-up call.

Jan explicitly asked to not use a label. I can change it, but I would like to have consensus first.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#10 lore raw

Re: [PATCH v5 3/5] p2m: change write_p2m_entry to return an error code

In reply to George Dunlap
Quoted 34 lines
Quoted 1 line
Quoted 1 line · On 25.02.19 at 18:42, <[email protected]> wrote:
Quoted 32 lines · Roger Pau Monne
xen/arch/x86/mm/p2m-pt.c +16 -4
@@ -250,18 +253,37 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
         {
             new_entry = l1e_from_pfn(pfn | (i << ((level - 1) * PAGETABLE_ORDER)),
                                      flags);
-            p2m->write_p2m_entry(p2m, gfn, l1_entry + i, new_entry, level);
+            rc = p2m->write_p2m_entry(p2m, gfn, l1_entry + i, new_entry, level);
+            if ( rc )
+            {
+                ASSERT_UNREACHABLE();
+                break;
+            }
         }
 
         unmap_domain_page(l1_entry);
 
-        new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
-        p2m_add_iommu_flags(&new_entry, level, IOMMUF_readable|IOMMUF_writable);
-        p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1);
+        if ( !rc )
+        {
+            new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW);
+            p2m_add_iommu_flags(&new_entry, level,
+                                IOMMUF_readable|IOMMUF_writable);
+            rc = p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry,
+                                      level + 1);
+            if ( rc )
+                ASSERT_UNREACHABLE();
+        }
     }
     else
         ASSERT(flags & _PAGE_PRESENT);
 
Quoted 12 lines

Review p2m_next_level(struct p2m_domain *p2m, void **table, · line 286

Quoted 7 lines
(quoted diff) +7 -0
+    if ( rc )
+    {
+        ASSERT(mfn_valid(mfn));
+        p2m_free_ptp(p2m, mfn_to_page(mfn));
+        return rc;
+    }
+

I think the idiomatic way to deal with this would be to have a label at the end that everything jumps to something like the attached? That way you don't have to spend mental effort making sure that nothing happens between the error and the clean-up call.

Well, as Roger has said already, this not being a classical end-of-the-function error path, I did ask to get away without a label. But you're the maintainer of the code, so if you want it that way, then I guess I did misguide Roger.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#11 lore raw

PATCH v5 4/5 x86/mm: handle foreign mappings in p2m_entry_modify

In reply to Roger Pau Monne

So that the specific handling can be removed from atomic_write_ept_entry and be shared with npt and shadow code.

This commit also removes the check that prevent non-ept PVH dom0 from mapping foreign pages.

---
Cc: George Dunlap <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>
Cc: Tim Deegan <[email protected]>
---
Changes since v3:
- Replace the mfn_valid BUG_ONs with an assert & return.

Changes since v2:
- Return an error code from p2m_entry_modify and propagate it to the callers.

Changes since v1:
- Simply code since mfn_to_page cannot return NULL.
- Check if the mfn is valid before getting/dropping the page reference.
- Use BUG_ON instead of ASSERTs, since getting the reference counting wrong is more dangerous than a DoS.

---
 xen/arch/x86/mm/hap/hap.c       | 11 +++++--
 xen/arch/x86/mm/p2m-ept.c       | 55 +++------------------------------
 xen/arch/x86/mm/p2m-pt.c        |  9 +-----
 xen/arch/x86/mm/shadow/common.c | 11 +++++--
 xen/include/asm-x86/p2m.h       | 34 +++++++++++++++++---
 5 files changed, 54 insertions(+), 66 deletions(-)
xen/arch/x86/mm/hap/hap.c +9 -2
index fdf77c59a5..412a442b6a 100644
@@ -715,6 +715,7 @@ hap_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, l1_pgentry_t *p,
     struct domain *d = p2m->domain;
     uint32_t old_flags;
     bool_t flush_nestedp2m = 0;
+    int rc;
 
     /* We know always use the host p2m here, regardless if the vcpu
      * is in host or guest mode. The vcpu can be in guest mode by
@@ -735,8 +736,14 @@ hap_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, l1_pgentry_t *p,
             && perms_strictly_increased(old_flags, l1e_get_flags(new)) );
     }
 
-    p2m_entry_modify(p2m, p2m_flags_to_type(l1e_get_flags(new)),
-                     p2m_flags_to_type(old_flags), level);
+    rc = p2m_entry_modify(p2m, p2m_flags_to_type(l1e_get_flags(new)),
+                          p2m_flags_to_type(old_flags), l1e_get_mfn(new),
+                          l1e_get_mfn(*p), level);
+    if ( rc )
+    {
+        paging_unlock(d);
+        return rc;
+    }
 
     safe_write_pte(p, new);
     if ( old_flags & _PAGE_PRESENT )
xen/arch/x86/mm/p2m-ept.c +5 -50

65 lines not on this page · raw message

xen/arch/x86/mm/p2m-pt.c +1 -8
index 254c5dfd19..7f94fdb6a3 100644
@@ -184,7 +184,7 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
     l1_pgentry_t *p2m_entry, new_entry;
     void *next;
     unsigned int flags;
-    int rc;
+    int rc = 0;
     mfn_t mfn = INVALID_MFN;
 
     if ( !(p2m_entry = p2m_find_entry(*table, gfn_remainder, gfn,
@@ -578,13 +578,6 @@ p2m_pt_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn,
         __trace_var(TRC_MEM_SET_P2M_ENTRY, 0, sizeof(t), &t);
     }
 
-    if ( unlikely(p2m_is_foreign(p2mt)) )
-    {
-        /* hvm fixme: foreign types are only supported on ept at present */
-        gdprintk(XENLOG_WARNING, "Unimplemented foreign p2m type.\n");
-        return -EINVAL;
-    }
-
     /* Carry out any eventually pending earlier changes first. */
     rc = do_recalc(p2m, gfn);
     if ( rc < 0 )
xen/arch/x86/mm/shadow/common.c +9 -2
index c818112360..025071a163 100644
@@ -3182,6 +3182,7 @@ shadow_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
                        unsigned int level)
 {
     struct domain *d = p2m->domain;
+    int rc;
 
     paging_lock(d);
 
@@ -3190,8 +3191,14 @@ shadow_write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn,
     if ( likely(d->arch.paging.shadow.total_pages != 0) )
          sh_unshadow_for_p2m_change(d, gfn, p, new, level);
 
-    p2m_entry_modify(p2m, p2m_flags_to_type(l1e_get_flags(new)),
-                     p2m_flags_to_type(l1e_get_flags(*p)), level);
+    rc = p2m_entry_modify(p2m, p2m_flags_to_type(l1e_get_flags(new)),
+                          p2m_flags_to_type(l1e_get_flags(*p)),
+                          l1e_get_mfn(new), l1e_get_mfn(*p), level);
+    if ( rc )
+    {
+        paging_unlock(d);
+        return rc;
+    }
 
     /* Update the entry with new content */
     safe_write_pte(p, new);
xen/include/asm-x86/p2m.h +30 -4
index f4ec2becbd..2801a8ccca 100644
@@ -932,11 +932,14 @@ int p2m_set_ioreq_server(struct domain *d, unsigned int flags,
 struct hvm_ioreq_server *p2m_get_ioreq_server(struct domain *d,
                                               unsigned int *flags);
 
-static inline void p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt,
-                                    p2m_type_t ot, unsigned int level)
+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)
 {
-    if ( level != 1 || nt == ot )
-        return;
+    BUG_ON(level > 1 && (nt == p2m_ioreq_server || nt == p2m_map_foreign));
+
+    if ( level != 1 || (nt == ot && mfn_eq(nfn, ofn)) )
+        return 0;
 
     switch ( nt )
     {
@@ -948,6 +951,18 @@ static inline void p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt,
         p2m->ioreq.entry_count++;
         break;
 
+    case p2m_map_foreign:
+        if ( !mfn_valid(nfn) )
+        {
+            ASSERT_UNREACHABLE();
+            return -EINVAL;
+        }
+
+        if ( !page_get_owner_and_reference(mfn_to_page(nfn)) )
+            return -EBUSY;
+
+        break;
+
     default:
         break;
     }
@@ -959,9 +974,20 @@ static inline void p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt,
         p2m->ioreq.entry_count--;
         break;
 
+    case p2m_map_foreign:
+        if ( !mfn_valid(ofn) )
+        {
+            ASSERT_UNREACHABLE();
+            return -EINVAL;
+        }
+        put_page(mfn_to_page(ofn));
+        break;
+
     default:
         break;
     }
+
+    return 0;
 }
 
 #endif /* _XEN_ASM_X86_P2M_H */
Signature · 7 lines
2.17.2 (Apple Git-113)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#12 lore raw

Re: [PATCH v5 4/5] x86/mm: handle foreign mappings in p2m_entry_modify

xen/arch/x86/mm/p2m-pt.c p2m_next_level(struct p2m_domain *p2m, void **table, · line 187

Quoted 12 lines · Roger Pau Monne

static void ept_p2m_type_to_flags(struct p2m_domain *p2m, ept_entry_t *entry,

xen/arch/x86/mm/p2m-pt.c +1 -1
index 254c5dfd19..7f94fdb6a3 100644
@@ -184,7 +184,7 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
     l1_pgentry_t *p2m_entry, new_entry;
     void *next;
     unsigned int flags;
-    int rc;
+    int rc = 0;

Oh here it is. It should be moved to previous patch.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#13 lore raw

PATCH v5 5/5 npt/shadow: allow getting foreign page table entries

In reply to Roger Pau Monne

Current npt and shadow code to get an entry will always return INVALID_MFN for foreign entries. Allow to return the entry mfn for foreign entries, like it's done for grant table entries.

---
Cc: George Dunlap <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
---
Changes since v2:
- Use p2m_is_any_ram.

---
 xen/arch/x86/mm/p2m-pt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/mm/p2m-pt.c +2 -2
index 7f94fdb6a3..bbc9a3e278 100644
@@ -907,8 +907,8 @@ pod_retry_l1:
     *t = p2m_recalc_type(recalc || _needs_recalc(flags), l1t, p2m, gfn);
     unmap_domain_page(l1e);
 
-    ASSERT(mfn_valid(mfn) || !p2m_is_ram(*t) || p2m_is_paging(*t));
-    return (p2m_is_valid(*t) || p2m_is_grant(*t)) ? mfn : INVALID_MFN;
+    ASSERT(mfn_valid(mfn) || !p2m_is_any_ram(*t) || p2m_is_paging(*t));
+    return (p2m_is_valid(*t) || p2m_is_any_ram(*t)) ? mfn : INVALID_MFN;
 }
 
 static void p2m_pt_change_entry_type_global(struct p2m_domain *p2m,
Signature · 7 lines
2.17.2 (Apple Git-113)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel