@@ -317,7 +317,14 @@ static int create_p2m_entries(struct domain *d,
break;
case REMOVE:
{
- lpae_t pte;
+ lpae_t pte = third[third_table_offset(addr)];
+ unsigned long mfn = maddr >> PAGE_SHIFT;
+ p2m_type_t t = pte.p2m.type;
+
+ /* TODO: Handle other p2m type */
+ if ( mfn_valid(mfn) && p2m_is_foreign(t) )
+ put_page(mfn_to_page(mfn));
+
memset(&pte, 0x00, sizeof(pte));
write_pte(&third[third_table_offset(addr)], pte);
maddr += PAGE_SIZE;
@@ -380,6 +387,16 @@ void guest_physmap_remove_page(struct domain *d,
pfn_to_paddr(mfn), MATTR_MEM, p2m_invalid);
}
+int xenmem_rem_foreign_from_p2m(struct domain *d, unsigned long gpfn)
+{
+ unsigned long mfn = gmfn_to_mfn(d, gpfn);
+
+ ASSERT(mfn_valid(mfn));
+ guest_physmap_remove_page(d, gpfn, mfn, 0);
+
+ return 0;
+}
+
int p2m_alloc_table(struct domain *d)
{
struct p2m_domain *p2m = &d->arch.p2m;
@@ -144,11 +144,7 @@ static inline int get_page_and_type(struct page_info *page,
return rc;
}
-static inline int xenmem_rem_foreign_from_p2m(struct domain *d,
- unsigned long gpfn)
-{
- return -ENOSYS;
-}
+int xenmem_rem_foreign_from_p2m(struct domain *d, unsigned long gpfn);
#endif /* _XEN_P2M_H */
Signed-off-by: Julien Grall <julien.grall@linaro.org> --- Changes in v3: - Move put_page in create_p2m_entries - Move xenmem_rem_foreign_from_p2m in arch/arm/p2m.c Changes in v2: - Introduce the patch --- xen/arch/arm/p2m.c | 19 ++++++++++++++++++- xen/include/asm-arm/p2m.h | 6 +----- 2 files changed, 19 insertions(+), 6 deletions(-)