aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/xen/mmu.c
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2009-05-21 05:09:46 -0400
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>2010-10-20 19:22:34 -0400
commitde1ef2065c4675ab1062ebc8d1cb6c5f42b61d04 (patch)
tree8091769ae22659277e43df69a7101c17e19530fa /arch/x86/xen/mmu.c
parentf020e2905166e12f9a8f109fe968cb5a9db887e9 (diff)
xen/privcmd: move remap_domain_mfn_range() to core xen code and export.
This allows xenfs to be built as a module, previously it required flush_tlb_all and arbitrary_virt_to_machine to be exported. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch/x86/xen/mmu.c')
-rw-r--r--arch/x86/xen/mmu.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 1ceb0f2fa0af..f08ea045620f 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2265,6 +2265,72 @@ void __init xen_hvm_init_mmu_ops(void)
2265} 2265}
2266#endif 2266#endif
2267 2267
2268#define REMAP_BATCH_SIZE 16
2269
2270struct remap_data {
2271 unsigned long mfn;
2272 pgprot_t prot;
2273 struct mmu_update *mmu_update;
2274};
2275
2276static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,
2277 unsigned long addr, void *data)
2278{
2279 struct remap_data *rmd = data;
2280 pte_t pte = pte_mkspecial(pfn_pte(rmd->mfn++, rmd->prot));
2281
2282 rmd->mmu_update->ptr = arbitrary_virt_to_machine(ptep).maddr;
2283 rmd->mmu_update->val = pte_val_ma(pte);
2284 rmd->mmu_update++;
2285
2286 return 0;
2287}
2288
2289int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
2290 unsigned long addr,
2291 unsigned long mfn, int nr,
2292 pgprot_t prot, unsigned domid)
2293{
2294 struct remap_data rmd;
2295 struct mmu_update mmu_update[REMAP_BATCH_SIZE];
2296 int batch;
2297 unsigned long range;
2298 int err = 0;
2299
2300 prot = __pgprot(pgprot_val(prot) | _PAGE_IOMAP);
2301
2302 vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP;
2303
2304 rmd.mfn = mfn;
2305 rmd.prot = prot;
2306
2307 while (nr) {
2308 batch = min(REMAP_BATCH_SIZE, nr);
2309 range = (unsigned long)batch << PAGE_SHIFT;
2310
2311 rmd.mmu_update = mmu_update;
2312 err = apply_to_page_range(vma->vm_mm, addr, range,
2313 remap_area_mfn_pte_fn, &rmd);
2314 if (err)
2315 goto out;
2316
2317 err = -EFAULT;
2318 if (HYPERVISOR_mmu_update(mmu_update, batch, NULL, domid) < 0)
2319 goto out;
2320
2321 nr -= batch;
2322 addr += range;
2323 }
2324
2325 err = 0;
2326out:
2327
2328 flush_tlb_all();
2329
2330 return err;
2331}
2332EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
2333
2268#ifdef CONFIG_XEN_DEBUG_FS 2334#ifdef CONFIG_XEN_DEBUG_FS
2269 2335
2270static struct dentry *d_mmu_debug; 2336static struct dentry *d_mmu_debug;