]>
Commit | Line | Data |
---|---|---|
7e0563de VK |
1 | #include <linux/pfn.h> |
2 | #include <asm/xen/page.h> | |
3 | #include <asm/xen/hypercall.h> | |
4 | #include <xen/interface/memory.h> | |
70e61199 | 5 | |
7e0563de VK |
6 | #include "multicalls.h" |
7 | #include "mmu.h" | |
70e61199 | 8 | |
7e0563de | 9 | unsigned long arbitrary_virt_to_mfn(void *vaddr) |
70e61199 | 10 | { |
7e0563de | 11 | xmaddr_t maddr = arbitrary_virt_to_machine(vaddr); |
70e61199 | 12 | |
7e0563de | 13 | return PFN_DOWN(maddr.maddr); |
70e61199 JG |
14 | } |
15 | ||
7e0563de | 16 | xmaddr_t arbitrary_virt_to_machine(void *vaddr) |
5b5c1af1 | 17 | { |
7e0563de VK |
18 | unsigned long address = (unsigned long)vaddr; |
19 | unsigned int level; | |
20 | pte_t *pte; | |
21 | unsigned offset; | |
5b5c1af1 IC |
22 | |
23 | /* | |
7e0563de VK |
24 | * if the PFN is in the linear mapped vaddr range, we can just use |
25 | * the (quick) virt_to_machine() p2m lookup | |
5b5c1af1 | 26 | */ |
7e0563de VK |
27 | if (virt_addr_valid(vaddr)) |
28 | return virt_to_machine(vaddr); | |
20f36e03 | 29 | |
7e0563de | 30 | /* otherwise we have to do a (slower) full page-table walk */ |
d2cb2145 | 31 | |
7e0563de VK |
32 | pte = lookup_address(address, &level); |
33 | BUG_ON(pte == NULL); | |
34 | offset = address & ~PAGE_MASK; | |
35 | return XMADDR(((phys_addr_t)pte_mfn(*pte) << PAGE_SHIFT) + offset); | |
030cb6c0 | 36 | } |
7e0563de | 37 | EXPORT_SYMBOL_GPL(arbitrary_virt_to_machine); |
319f3ba5 | 38 | |
9a032e39 | 39 | /* Returns: 0 success */ |
a13d7201 | 40 | int xen_unmap_domain_gfn_range(struct vm_area_struct *vma, |
ec4001c3 | 41 | int nr, struct page **pages) |
9a032e39 | 42 | { |
ec4001c3 PD |
43 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
44 | return xen_xlate_unmap_gfn_range(vma, nr, pages); | |
45 | ||
46 | if (!pages) | |
9a032e39 IC |
47 | return 0; |
48 | ||
49 | return -EINVAL; | |
50 | } | |
a13d7201 | 51 | EXPORT_SYMBOL_GPL(xen_unmap_domain_gfn_range); |