有一些关于在 ARM 上实现steal_page() 的补丁
int steal_page(
struct domain *d, struct page_info *page, unsigned int memflags)
{
unsigned long x, y;
bool_t drop_dom_ref = 0;
const struct domain *owner = dom_xen;
spin_lock(&d->page_alloc_lock);
if ( is_xen_heap_page(page) || ((owner = page_get_owner(page)) != d) )
goto fail;
/*
* We require there is just one reference (PGC_allocated). We temporarily
* drop this reference now so that we can safely swizzle the owner.
*/
y = page->count_info;
do {
x = y;
if ( (x & (PGC_count_mask|PGC_allocated)) != (1 | PGC_allocated) )
goto fail;
y = cmpxchg(&page->count_info, x, x & ~PGC_count_mask);
} while ( y != x );
/* Swizzle the owner then reinstate the PGC_allocated reference. */
page_set_owner(page, NULL);
y = page->count_info;
do {
x = y;
BUG_ON((x & (PGC_count_mask|PGC_allocated)) != PGC_allocated);
} while ( (y = cmpxchg(&page->count_info, x, x | 1)) != x );
/* Unlink from original owner. */
if ( !(memflags & MEMF_no_refcount) && !domain_adjust_tot_pages(d, -1) )
drop_dom_ref = 1;
page_list_del(page, &d->page_list);
spin_unlock(&d->page_alloc_lock);
if ( unlikely(drop_dom_ref) )
put_domain(d);
return 0;
fail:
spin_unlock(&d->page_alloc_lock);
gdprintk(XENLOG_WARNING,
"Bad page %lx: ed=%d sd=%d caf=%08lx taf=%" PRtype_info,
page_to_mfn(page), d->domain_id,
owner ? owner->domain_id : DOMID_INVALID,
page->count_info, page->u.inuse.type_info);
return -1;
}
https://patchwork.kernel.org/patch/7874301/
还有一些有趣的邮件列表:
目前 ARM 不支持 XENMEM_exchange,因为steal_page 未实现。
但是,即使实现了steal_page,hypercall 也不能用于ARM,因为:
- 不支持直接映射域
- ARM 没有 M2P,因此使用 mfn_to_gmfn 无效
从这个https://lists.gt.net/xen/devel/411530
希望我对您的问题有所了解。