2017-04-04 06:48:17 -06:00
|
|
|
#include <linux/pfn.h>
|
|
|
|
#include <asm/xen/page.h>
|
|
|
|
#include <asm/xen/hypercall.h>
|
|
|
|
#include <xen/interface/memory.h>
|
2015-07-16 22:51:35 -06:00
|
|
|
|
2017-04-04 06:48:17 -06:00
|
|
|
#include "multicalls.h"
|
|
|
|
#include "mmu.h"
|
2015-07-16 22:51:35 -06:00
|
|
|
|
2017-04-04 06:48:17 -06:00
|
|
|
unsigned long arbitrary_virt_to_mfn(void *vaddr)
|
2015-07-16 22:51:35 -06:00
|
|
|
{
|
2017-04-04 06:48:17 -06:00
|
|
|
xmaddr_t maddr = arbitrary_virt_to_machine(vaddr);
|
2015-07-16 22:51:35 -06:00
|
|
|
|
2017-04-04 06:48:17 -06:00
|
|
|
return PFN_DOWN(maddr.maddr);
|
2015-07-16 22:51:35 -06:00
|
|
|
}
|
|
|
|
|
2017-04-04 06:48:17 -06:00
|
|
|
xmaddr_t arbitrary_virt_to_machine(void *vaddr)
|
2010-11-24 05:09:41 -07:00
|
|
|
{
|
2017-04-04 06:48:17 -06:00
|
|
|
unsigned long address = (unsigned long)vaddr;
|
|
|
|
unsigned int level;
|
|
|
|
pte_t *pte;
|
|
|
|
unsigned offset;
|
2010-11-24 05:09:41 -07:00
|
|
|
|
|
|
|
/*
|
2017-04-04 06:48:17 -06:00
|
|
|
* if the PFN is in the linear mapped vaddr range, we can just use
|
|
|
|
* the (quick) virt_to_machine() p2m lookup
|
2010-11-24 05:09:41 -07:00
|
|
|
*/
|
2017-04-04 06:48:17 -06:00
|
|
|
if (virt_addr_valid(vaddr))
|
|
|
|
return virt_to_machine(vaddr);
|
2015-12-12 17:25:55 -07:00
|
|
|
|
2017-04-04 06:48:17 -06:00
|
|
|
/* otherwise we have to do a (slower) full page-table walk */
|
2010-03-26 16:37:50 -06:00
|
|
|
|
2017-04-04 06:48:17 -06:00
|
|
|
pte = lookup_address(address, &level);
|
|
|
|
BUG_ON(pte == NULL);
|
|
|
|
offset = address & ~PAGE_MASK;
|
|
|
|
return XMADDR(((phys_addr_t)pte_mfn(*pte) << PAGE_SHIFT) + offset);
|
2009-08-20 06:30:02 -06:00
|
|
|
}
|
2017-04-04 06:48:17 -06:00
|
|
|
EXPORT_SYMBOL_GPL(arbitrary_virt_to_machine);
|
2009-01-28 15:35:01 -07:00
|
|
|
|
2012-10-17 14:37:49 -06:00
|
|
|
/* Returns: 0 success */
|
2015-08-07 10:34:41 -06:00
|
|
|
int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
|
2017-11-03 11:04:11 -06:00
|
|
|
int nr, struct page **pages)
|
2012-10-17 14:37:49 -06:00
|
|
|
{
|
2017-11-03 11:04:11 -06:00
|
|
|
if (xen_feature(XENFEAT_auto_translated_physmap))
|
|
|
|
return xen_xlate_unmap_gfn_range(vma, nr, pages);
|
|
|
|
|
|
|
|
if (!pages)
|
2012-10-17 14:37:49 -06:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-08-07 10:34:41 -06:00
|
|
|
EXPORT_SYMBOL_GPL(xen_unmap_domain_gfn_range);
|