]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'xen-two/linux-next'
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 7 Nov 2012 02:21:46 +0000 (13:21 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 7 Nov 2012 02:21:46 +0000 (13:21 +1100)
29 files changed:
arch/arm/include/asm/xen/interface.h
arch/arm/xen/enlighten.c
arch/x86/include/asm/xen/hypercall.h
arch/x86/include/asm/xen/interface.h
arch/x86/include/asm/xen/page.h
arch/x86/xen/Kconfig
arch/x86/xen/enlighten.c
arch/x86/xen/irq.c
arch/x86/xen/mmu.c
arch/x86/xen/mmu.h
arch/x86/xen/p2m.c
arch/x86/xen/setup.c
arch/x86/xen/smp.c
arch/x86/xen/xen-head.S
drivers/net/xen-netback/netback.c
drivers/xen/Kconfig
drivers/xen/Makefile
drivers/xen/balloon.c
drivers/xen/cpu_hotplug.c
drivers/xen/events.c
drivers/xen/fallback.c [new file with mode: 0644]
drivers/xen/gntdev.c
drivers/xen/grant-table.c
drivers/xen/privcmd.c
drivers/xen/xenbus/xenbus_client.c
include/xen/grant_table.h
include/xen/interface/memory.h
include/xen/interface/physdev.h
include/xen/xen-ops.h

index 5000397134b4e5ceb06521ecf1d22622a0918a82..1151188bcd83c391c0ba0ca3d51b4b32226aa4be 100644 (file)
@@ -49,6 +49,7 @@ DEFINE_GUEST_HANDLE(void);
 DEFINE_GUEST_HANDLE(uint64_t);
 DEFINE_GUEST_HANDLE(uint32_t);
 DEFINE_GUEST_HANDLE(xen_pfn_t);
+DEFINE_GUEST_HANDLE(xen_ulong_t);
 
 /* Maximum number of virtual CPUs in multi-processor guests. */
 #define MAX_VIRT_CPUS 1
index 59bcb96ac3692446989501f363301daa81674d5b..f28fc1ac87600d4cb25d323b2a6e7aabf19e8849 100644 (file)
@@ -8,6 +8,8 @@
 #include <xen/features.h>
 #include <xen/platform_pci.h>
 #include <xen/xenbus.h>
+#include <xen/page.h>
+#include <xen/xen-ops.h>
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypercall.h>
 #include <linux/interrupt.h>
@@ -17,6 +19,8 @@
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
 
+#include <linux/mm.h>
+
 struct start_info _xen_start_info;
 struct start_info *xen_start_info = &_xen_start_info;
 EXPORT_SYMBOL_GPL(xen_start_info);
@@ -29,6 +33,10 @@ struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info;
 
 DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
 
+/* These are unused until we support booting "pre-ballooned" */
+unsigned long xen_released_pages;
+struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
+
 /* TODO: to be removed */
 __read_mostly int xen_have_vector_callback;
 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
@@ -38,15 +46,106 @@ EXPORT_SYMBOL_GPL(xen_platform_pci_unplug);
 
 static __read_mostly int xen_events_irq = -1;
 
+/* map fgmfn of domid to lpfn in the current domain */
+static int map_foreign_page(unsigned long lpfn, unsigned long fgmfn,
+                           unsigned int domid)
+{
+       int rc;
+       struct xen_add_to_physmap_range xatp = {
+               .domid = DOMID_SELF,
+               .foreign_domid = domid,
+               .size = 1,
+               .space = XENMAPSPACE_gmfn_foreign,
+       };
+       xen_ulong_t idx = fgmfn;
+       xen_pfn_t gpfn = lpfn;
+
+       set_xen_guest_handle(xatp.idxs, &idx);
+       set_xen_guest_handle(xatp.gpfns, &gpfn);
+
+       rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp);
+       if (rc) {
+               pr_warn("Failed to map pfn to mfn rc:%d pfn:%lx mfn:%lx\n",
+                       rc, lpfn, fgmfn);
+               return 1;
+       }
+       return 0;
+}
+
+struct remap_data {
+       xen_pfn_t fgmfn; /* foreign domain's gmfn */
+       pgprot_t prot;
+       domid_t  domid;
+       struct vm_area_struct *vma;
+       int index;
+       struct page **pages;
+       struct xen_remap_mfn_info *info;
+};
+
+static int remap_pte_fn(pte_t *ptep, pgtable_t token, unsigned long addr,
+                       void *data)
+{
+       struct remap_data *info = data;
+       struct page *page = info->pages[info->index++];
+       unsigned long pfn = page_to_pfn(page);
+       pte_t pte = pfn_pte(pfn, info->prot);
+
+       if (map_foreign_page(pfn, info->fgmfn, info->domid))
+               return -EFAULT;
+       set_pte_at(info->vma->vm_mm, addr, ptep, pte);
+
+       return 0;
+}
+
 int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
                               unsigned long addr,
-                              unsigned long mfn, int nr,
-                              pgprot_t prot, unsigned domid)
+                              xen_pfn_t mfn, int nr,
+                              pgprot_t prot, unsigned domid,
+                              struct page **pages)
 {
-       return -ENOSYS;
+       int err;
+       struct remap_data data;
+
+       /* TBD: Batching, current sole caller only does page at a time */
+       if (nr > 1)
+               return -EINVAL;
+
+       data.fgmfn = mfn;
+       data.prot = prot;
+       data.domid = domid;
+       data.vma = vma;
+       data.index = 0;
+       data.pages = pages;
+       err = apply_to_page_range(vma->vm_mm, addr, nr << PAGE_SHIFT,
+                                 remap_pte_fn, &data);
+       return err;
 }
 EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
 
+int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
+                              int nr, struct page **pages)
+{
+       int i;
+
+       for (i = 0; i < nr; i++) {
+               struct xen_remove_from_physmap xrp;
+               unsigned long rc, pfn;
+
+               pfn = page_to_pfn(pages[i]);
+
+               xrp.domid = DOMID_SELF;
+               xrp.gpfn = pfn;
+               rc = HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrp);
+               if (rc) {
+                       pr_warn("Failed to unmap pfn:%lx rc:%ld\n",
+                               pfn, rc);
+                       return rc;
+               }
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range);
+
 /*
  * see Documentation/devicetree/bindings/arm/xen.txt for the
  * documentation of the Xen Device Tree format.
@@ -148,21 +247,3 @@ static int __init xen_init_events(void)
        return 0;
 }
 postcore_initcall(xen_init_events);
-
-/* XXX: only until balloon is properly working */
-int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem)
-{
-       *pages = alloc_pages(highmem ? GFP_HIGHUSER : GFP_KERNEL,
-                       get_order(nr_pages));
-       if (*pages == NULL)
-               return -ENOMEM;
-       return 0;
-}
-EXPORT_SYMBOL_GPL(alloc_xenballooned_pages);
-
-void free_xenballooned_pages(int nr_pages, struct page **pages)
-{
-       kfree(*pages);
-       *pages = NULL;
-}
-EXPORT_SYMBOL_GPL(free_xenballooned_pages);
index 59c226d120cdeccb6d8615e396f65b3ff2d4c050..40554218da08465d15fdb4a6a369c5423f86bbb6 100644 (file)
@@ -359,18 +359,14 @@ HYPERVISOR_update_va_mapping(unsigned long va, pte_t new_val,
                return _hypercall4(int, update_va_mapping, va,
                                   new_val.pte, new_val.pte >> 32, flags);
 }
+extern int __must_check xen_HYPERVISOR_event_channel_op_compat(int, void *);
 
 static inline int
 HYPERVISOR_event_channel_op(int cmd, void *arg)
 {
        int rc = _hypercall2(int, event_channel_op, cmd, arg);
-       if (unlikely(rc == -ENOSYS)) {
-               struct evtchn_op op;
-               op.cmd = cmd;
-               memcpy(&op.u, arg, sizeof(op.u));
-               rc = _hypercall1(int, event_channel_op_compat, &op);
-               memcpy(arg, &op.u, sizeof(op.u));
-       }
+       if (unlikely(rc == -ENOSYS))
+               rc = xen_HYPERVISOR_event_channel_op_compat(cmd, arg);
        return rc;
 }
 
@@ -386,17 +382,14 @@ HYPERVISOR_console_io(int cmd, int count, char *str)
        return _hypercall3(int, console_io, cmd, count, str);
 }
 
+extern int __must_check xen_HYPERVISOR_physdev_op_compat(int, void *);
+
 static inline int
 HYPERVISOR_physdev_op(int cmd, void *arg)
 {
        int rc = _hypercall2(int, physdev_op, cmd, arg);
-       if (unlikely(rc == -ENOSYS)) {
-               struct physdev_op op;
-               op.cmd = cmd;
-               memcpy(&op.u, arg, sizeof(op.u));
-               rc = _hypercall1(int, physdev_op_compat, &op);
-               memcpy(arg, &op.u, sizeof(op.u));
-       }
+       if (unlikely(rc == -ENOSYS))
+               rc = xen_HYPERVISOR_physdev_op_compat(cmd, arg);
        return rc;
 }
 
index 54d52ff1304a3496bc240ef193030adbb73ec4bb..20e738a907632a465e69b519a8b9fe3abd5e29dd 100644 (file)
@@ -63,6 +63,7 @@ DEFINE_GUEST_HANDLE(void);
 DEFINE_GUEST_HANDLE(uint64_t);
 DEFINE_GUEST_HANDLE(uint32_t);
 DEFINE_GUEST_HANDLE(xen_pfn_t);
+DEFINE_GUEST_HANDLE(xen_ulong_t);
 #endif
 
 #ifndef HYPERVISOR_VIRT_START
@@ -144,7 +145,16 @@ struct vcpu_guest_context {
     struct cpu_user_regs user_regs;         /* User-level CPU registers     */
     struct trap_info trap_ctxt[256];        /* Virtual IDT                  */
     unsigned long ldt_base, ldt_ents;       /* LDT (linear address, # ents) */
-    unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
+    union {
+       struct {
+               /* PV: GDT (machine frames, # ents).*/
+               unsigned long gdt_frames[16], gdt_ents;
+       } pv;
+       struct {
+               /* PVH: GDTR addr and size */
+               unsigned long gdtaddr, gdtsz;
+       } pvh;
+    } u;
     unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only SS1/SP1)   */
     /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
     unsigned long ctrlreg[8];               /* CR0-CR7 (control registers)  */
index 472b9b783019a2e2f7c7b273ab7b13b96ec257b9..6af440d5a53315f5ebc5e54e211f5e22f705f96b 100644 (file)
@@ -159,6 +159,9 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)
 static inline unsigned long mfn_to_local_pfn(unsigned long mfn)
 {
        unsigned long pfn = mfn_to_pfn(mfn);
+
+       if (xen_feature(XENFEAT_auto_translated_physmap))
+               return mfn;
        if (get_phys_to_machine(pfn) != mfn)
                return -1; /* force !pfn_valid() */
        return pfn;
index fdce49c7aff6cf2ce931f25154d8e7c0ada8338c..7e938baa576d583f06e3375f9402cbe4b134e366 100644 (file)
@@ -6,6 +6,7 @@ config XEN
        bool "Xen guest support"
        select PARAVIRT
        select PARAVIRT_CLOCK
+       select XEN_HAVE_PVMMU
        depends on X86_64 || (X86_32 && X86_PAE && !X86_VISWS)
        depends on X86_CMPXCHG && X86_TSC
        help
@@ -50,3 +51,13 @@ config XEN_DEBUG_FS
          Enable statistics output and various tuning options in debugfs.
          Enabling this option may incur a significant performance overhead.
 
+config XEN_X86_PVH
+       bool "Support for running as a PVH guest (EXPERIMENTAL)"
+       depends on X86_64 && XEN && EXPERIMENTAL
+       default n
+       help
+          This option enables support for running as a PVH guest (PV guest
+          using hardware extensions) under a suitably capable hypervisor.
+          This option is EXPERIMENTAL because the hypervisor interfaces
+          which it uses is not yet considered stable therefore backwards and
+          forwards compatibility is not yet guaranteed.  If unsure, say N.
index 586d83812b67b64f96594f1eebdc859bdcb12adc..4c694a7ec44f10b7aae0083d4e56875f28578a7a 100644 (file)
@@ -105,6 +105,9 @@ RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
 __read_mostly int xen_have_vector_callback;
 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
 
+#define xen_pvh_domain() (xen_pv_domain() && \
+                         xen_feature(XENFEAT_auto_translated_physmap) && \
+                         xen_have_vector_callback)
 /*
  * Point at some empty memory to start with. We map the real shared_info
  * page as soon as fixmap is up and running.
@@ -217,8 +220,9 @@ static void __init xen_banner(void)
        struct xen_extraversion extra;
        HYPERVISOR_xen_version(XENVER_extraversion, &extra);
 
-       printk(KERN_INFO "Booting paravirtualized kernel on %s\n",
-              pv_info.name);
+       pr_info("Booting paravirtualized kernel %son %s\n",
+               xen_feature(XENFEAT_auto_translated_physmap) ?
+                       "with PVH extensions " : "", pv_info.name);
        printk(KERN_INFO "Xen version: %d.%d%s%s\n",
               version >> 16, version & 0xffff, extra.extraversion,
               xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "");
@@ -271,12 +275,15 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
                break;
        }
 
-       asm(XEN_EMULATE_PREFIX "cpuid"
-               : "=a" (*ax),
-                 "=b" (*bx),
-                 "=c" (*cx),
-                 "=d" (*dx)
-               : "0" (*ax), "2" (*cx));
+       if (xen_pvh_domain())
+               native_cpuid(ax, bx, cx, dx);
+       else
+               asm(XEN_EMULATE_PREFIX "cpuid"
+                       : "=a" (*ax),
+                       "=b" (*bx),
+                       "=c" (*cx),
+                       "=d" (*dx)
+                       : "0" (*ax), "2" (*cx));
 
        *bx &= maskebx;
        *cx &= maskecx;
@@ -1053,6 +1060,10 @@ void xen_setup_shared_info(void)
                HYPERVISOR_shared_info =
                        (struct shared_info *)__va(xen_start_info->shared_info);
 
+       /* PVH TBD/FIXME: vcpu info placement in phase 2 */
+       if (xen_pvh_domain())
+               return;
+
 #ifndef CONFIG_SMP
        /* In UP this is as good a place as any to set up shared info */
        xen_setup_vcpu_info_placement();
@@ -1290,6 +1301,11 @@ static const struct machine_ops xen_machine_ops __initconst = {
  */
 static void __init xen_setup_stackprotector(void)
 {
+       /* PVH TBD/FIXME: investigate setup_stack_canary_segment */
+       if (xen_feature(XENFEAT_auto_translated_physmap)) {
+               switch_to_new_gdt(0);
+               return;
+       }
        pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry_boot;
        pv_cpu_ops.load_gdt = xen_load_gdt_boot;
 
@@ -1300,6 +1316,19 @@ static void __init xen_setup_stackprotector(void)
        pv_cpu_ops.load_gdt = xen_load_gdt;
 }
 
+static void __init xen_pvh_early_guest_init(void)
+{
+       if (xen_feature(XENFEAT_hvm_callback_vector))
+               xen_have_vector_callback = 1;
+
+#ifdef CONFIG_X86_32
+       if (xen_feature(XENFEAT_auto_translated_physmap)) {
+               xen_raw_printk("ERROR: 32bit PVH guests are not supported\n");
+               BUG();
+       }
+#endif
+}
+
 /* First C function to be called on Xen boot */
 asmlinkage void __init xen_start_kernel(void)
 {
@@ -1311,13 +1340,18 @@ asmlinkage void __init xen_start_kernel(void)
 
        xen_domain_type = XEN_PV_DOMAIN;
 
+       xen_setup_features();
+       xen_pvh_early_guest_init();
        xen_setup_machphys_mapping();
 
        /* Install Xen paravirt ops */
        pv_info = xen_info;
        pv_init_ops = xen_init_ops;
-       pv_cpu_ops = xen_cpu_ops;
        pv_apic_ops = xen_apic_ops;
+       if (xen_pvh_domain())
+               pv_cpu_ops.cpuid = xen_cpuid;
+       else
+               pv_cpu_ops = xen_cpu_ops;
 
        x86_init.resources.memory_setup = xen_memory_setup;
        x86_init.oem.arch_setup = xen_arch_setup;
@@ -1349,8 +1383,6 @@ asmlinkage void __init xen_start_kernel(void)
        /* Work out if we support NX */
        x86_configure_nx();
 
-       xen_setup_features();
-
        /* Get mfn list */
        if (!xen_feature(XENFEAT_auto_translated_physmap))
                xen_build_dynamic_phys_to_machine();
@@ -1421,14 +1453,18 @@ asmlinkage void __init xen_start_kernel(void)
        /* set the limit of our address space */
        xen_reserve_top();
 
-       /* We used to do this in xen_arch_setup, but that is too late on AMD
-        * were early_cpu_init (run before ->arch_setup()) calls early_amd_init
-        * which pokes 0xcf8 port.
-        */
-       set_iopl.iopl = 1;
-       rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
-       if (rc != 0)
-               xen_raw_printk("physdev_op failed %d\n", rc);
+       /* PVH: runs at default kernel iopl of 0 */
+       if (!xen_pvh_domain()) {
+               /*
+                * We used to do this in xen_arch_setup, but that is too late
+                * on AMD were early_cpu_init (run before ->arch_setup()) calls
+                * early_amd_init which pokes 0xcf8 port.
+                */
+               set_iopl.iopl = 1;
+               rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
+               if (rc != 0)
+                       xen_raw_printk("physdev_op failed %d\n", rc);
+       }
 
 #ifdef CONFIG_X86_32
        /* set up basic CPUID stuff */
@@ -1495,6 +1531,8 @@ asmlinkage void __init xen_start_kernel(void)
 #endif
 }
 
+/* Use a pfn in RAM, may move to MMIO before kexec.
+ * This function also called for PVH dom0 */
 void __ref xen_hvm_init_shared_info(void)
 {
        int cpu;
index 01a4dc015ae1e37206469df5ea45b3437da19cad..fcbe56acd88c063af110b5a9112be4a7f502e905 100644 (file)
@@ -5,6 +5,7 @@
 #include <xen/interface/xen.h>
 #include <xen/interface/sched.h>
 #include <xen/interface/vcpu.h>
+#include <xen/features.h>
 #include <xen/events.h>
 
 #include <asm/xen/hypercall.h>
@@ -129,6 +130,8 @@ static const struct pv_irq_ops xen_irq_ops __initconst = {
 
 void __init xen_init_irq_ops(void)
 {
-       pv_irq_ops = xen_irq_ops;
+       /* For PVH we use default pv_irq_ops settings */
+       if (!xen_feature(XENFEAT_hvm_callback_vector))
+               pv_irq_ops = xen_irq_ops;
        x86_init.irqs.intr_init = xen_init_IRQ;
 }
index dcf5f2dd91ec4fd91d814d46c7d6dbd6c5312a61..4a05b398cf7d19688a2b703429dc90fec6c7a17a 100644 (file)
@@ -74,6 +74,7 @@
 #include <xen/interface/version.h>
 #include <xen/interface/memory.h>
 #include <xen/hvc-console.h>
+#include <xen/balloon.h>
 
 #include "multicalls.h"
 #include "mmu.h"
@@ -332,6 +333,20 @@ static void xen_set_pte(pte_t *ptep, pte_t pteval)
        __xen_set_pte(ptep, pteval);
 }
 
+void xen_set_clr_mmio_pvh_pte(unsigned long pfn, unsigned long mfn,
+                             int nr_mfns, int add_mapping)
+{
+       struct physdev_map_iomem iomem;
+
+       iomem.first_gfn = pfn;
+       iomem.first_mfn = mfn;
+       iomem.nr_mfns = nr_mfns;
+       iomem.add_mapping = add_mapping;
+
+       if (HYPERVISOR_physdev_op(PHYSDEVOP_map_iomem, &iomem))
+               BUG();
+}
+
 static void xen_set_pte_at(struct mm_struct *mm, unsigned long addr,
                    pte_t *ptep, pte_t pteval)
 {
@@ -1221,6 +1236,8 @@ static void __init xen_pagetable_init(void)
 #endif
        paging_init();
        xen_setup_shared_info();
+       if (xen_feature(XENFEAT_auto_translated_physmap))
+               return;
 #ifdef CONFIG_X86_64
        if (!xen_feature(XENFEAT_auto_translated_physmap)) {
                unsigned long new_mfn_list;
@@ -1547,6 +1564,10 @@ static void __init xen_set_pte_init(pte_t *ptep, pte_t pte)
 static void pin_pagetable_pfn(unsigned cmd, unsigned long pfn)
 {
        struct mmuext_op op;
+
+       if (xen_feature(XENFEAT_writable_page_tables))
+               return;
+
        op.cmd = cmd;
        op.arg1.mfn = pfn_to_mfn(pfn);
        if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF))
@@ -1744,6 +1765,10 @@ static void set_page_prot(void *addr, pgprot_t prot)
        unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
        pte_t pte = pfn_pte(pfn, prot);
 
+       /* recall for PVH, page tables are native. */
+       if (xen_feature(XENFEAT_auto_translated_physmap))
+               return;
+
        if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
                BUG();
 }
@@ -1821,6 +1846,9 @@ static void convert_pfn_mfn(void *v)
        pte_t *pte = v;
        int i;
 
+       if (xen_feature(XENFEAT_auto_translated_physmap))
+               return;
+
        /* All levels are converted the same way, so just treat them
           as ptes. */
        for (i = 0; i < PTRS_PER_PTE; i++)
@@ -1840,6 +1868,7 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
                (*pt_end)--;
        }
 }
+
 /*
  * Set up the initial kernel pagetable.
  *
@@ -1850,6 +1879,7 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
  * but that's enough to get __va working.  We need to fill in the rest
  * of the physical mapping once some sort of allocator has been set
  * up.
+ * NOTE: for PVH, the page tables are native.
  */
 void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
 {
@@ -1927,10 +1957,13 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
         * structure to attach it to, so make sure we just set kernel
         * pgd.
         */
-       xen_mc_batch();
-       __xen_write_cr3(true, __pa(init_level4_pgt));
-       xen_mc_issue(PARAVIRT_LAZY_CPU);
-
+       if (xen_feature(XENFEAT_writable_page_tables)) {
+               native_write_cr3(__pa(init_level4_pgt));
+       } else {
+               xen_mc_batch();
+               __xen_write_cr3(true, __pa(init_level4_pgt));
+               xen_mc_issue(PARAVIRT_LAZY_CPU);
+       }
        /* We can't that easily rip out L3 and L2, as the Xen pagetables are
         * set out this way: [L4], [L1], [L2], [L3], [L1], [L1] ...  for
         * the initial domain. For guests using the toolstack, they are in:
@@ -2197,8 +2230,13 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
 
 void __init xen_init_mmu_ops(void)
 {
-       x86_init.mapping.pagetable_reserve = xen_mapping_pagetable_reserve;
        x86_init.paging.pagetable_init = xen_pagetable_init;
+
+       if (xen_feature(XENFEAT_auto_translated_physmap)) {
+               pv_mmu_ops.flush_tlb_others = xen_flush_tlb_others;
+               return;
+       }
+       x86_init.mapping.pagetable_reserve = xen_mapping_pagetable_reserve;
        pv_mmu_ops = xen_mmu_ops;
 
        memset(dummy_mapping, 0xff, PAGE_SIZE);
@@ -2474,6 +2512,95 @@ void __init xen_hvm_init_mmu_ops(void)
 }
 #endif
 
+/* Map foreign gmfn, fgmfn, to local pfn, lpfn. This for the user space
+ * creating new guest on PVH dom0 and needs to map domU pages.
+ */
+static int pvh_add_to_xen_p2m(unsigned long lpfn, unsigned long fgmfn,
+                             unsigned int domid)
+{
+       int rc;
+       struct xen_add_to_physmap_range xatp = {
+               .domid = DOMID_SELF,
+               .foreign_domid = domid,
+               .size = 1,
+               .space = XENMAPSPACE_gmfn_foreign,
+       };
+       xen_ulong_t idx = fgmfn;
+       xen_pfn_t gpfn = lpfn;
+
+       set_xen_guest_handle(xatp.idxs, &idx);
+       set_xen_guest_handle(xatp.gpfns, &gpfn);
+
+       rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp);
+       if (rc)
+               pr_warn("d0: Failed to map pfn (0x%lx) to mfn (0x%lx) rc:%d\n",
+                       lpfn, fgmfn, rc);
+       return rc;
+}
+
+static int pvh_rem_xen_p2m(unsigned long spfn, int count)
+{
+       struct xen_remove_from_physmap xrp;
+       int i, rc;
+
+       for (i = 0; i < count; i++) {
+               xrp.domid = DOMID_SELF;
+               xrp.gpfn = spfn+i;
+               rc = HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrp);
+               if (rc) {
+                       pr_warn("Failed to unmap pfn:%lx rc:%d done:%d\n",
+                               spfn+i, rc, i);
+                       return 1;
+               }
+       }
+       return 0;
+}
+
+struct pvh_remap_data {
+       unsigned long fgmfn;            /* foreign domain's gmfn */
+       pgprot_t prot;
+       domid_t  domid;
+       int      index;
+       struct page **pages;
+};
+
+static int pvh_map_pte_fn(pte_t *ptep, pgtable_t token, unsigned long addr,
+                       void *data)
+{
+       int rc;
+       struct pvh_remap_data *remap = data;
+       unsigned long pfn = page_to_pfn(remap->pages[remap->index++]);
+       pte_t pteval = pte_mkspecial(pfn_pte(pfn, remap->prot));
+
+       rc = pvh_add_to_xen_p2m(pfn, remap->fgmfn, remap->domid);
+       if (rc)
+               return rc;
+       native_set_pte(ptep, pteval);
+
+       return 0;
+}
+
+static int pvh_remap_gmfn_range(struct vm_area_struct *vma,
+                               unsigned long addr, unsigned long mfn, int nr,
+                               pgprot_t prot, unsigned domid,
+                               struct page **pages)
+{
+       int err;
+       struct pvh_remap_data pvhdata;
+
+       BUG_ON(!pages);
+
+       pvhdata.fgmfn = mfn;
+       pvhdata.prot = prot;
+       pvhdata.domid = domid;
+       pvhdata.index = 0;
+       pvhdata.pages = pages;
+       err = apply_to_page_range(vma->vm_mm, addr, nr << PAGE_SHIFT,
+                                 pvh_map_pte_fn, &pvhdata);
+       flush_tlb_all();
+       return err;
+}
+
 #define REMAP_BATCH_SIZE 16
 
 struct remap_data {
@@ -2497,8 +2624,10 @@ static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,
 
 int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
                               unsigned long addr,
-                              unsigned long mfn, int nr,
-                              pgprot_t prot, unsigned domid)
+                              xen_pfn_t mfn, int nr,
+                              pgprot_t prot, unsigned domid,
+                              struct page **pages)
+
 {
        struct remap_data rmd;
        struct mmu_update mmu_update[REMAP_BATCH_SIZE];
@@ -2513,6 +2642,10 @@ int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
 
        BUG_ON(!((vma->vm_flags & (VM_PFNMAP | VM_IO)) == (VM_PFNMAP | VM_IO)));
 
+       if (xen_feature(XENFEAT_auto_translated_physmap)) {
+               /* We need to update the local page tables and the xen HAP */
+               return pvh_remap_gmfn_range(vma, addr, mfn, nr, prot, domid, pages);
+       }
        rmd.mfn = mfn;
        rmd.prot = prot;
 
@@ -2542,3 +2675,26 @@ out:
        return err;
 }
 EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
+
+/* Returns: 0 success */
+int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
+                              int numpgs, struct page **pages)
+{
+       if (!pages || !xen_feature(XENFEAT_auto_translated_physmap))
+               return 0;
+
+       while (numpgs--) {
+
+               /* the mmu has already cleaned up the process mmu resources at
+                * this point (lookup_address will return NULL). */
+               unsigned long pfn = page_to_pfn(pages[numpgs]);
+
+               pvh_rem_xen_p2m(pfn, 1);
+       }
+       /* We don't need to flush tlbs because as part of pvh_rem_xen_p2m(),
+        * the hypervisor will do tlb flushes after removing the p2m entries
+        * from the EPT/NPT */
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range);
index 73809bb951b40a7b8baf73773260276ed575c623..6d0bb56a6e829c48ba1f7be96d24c9363fc02ca8 100644 (file)
@@ -23,4 +23,6 @@ unsigned long xen_read_cr2_direct(void);
 
 extern void xen_init_mmu_ops(void);
 extern void xen_hvm_init_mmu_ops(void);
+extern void xen_set_clr_mmio_pvh_pte(unsigned long pfn, unsigned long mfn,
+                                    int nr_mfns, int add_mapping);
 #endif /* _XEN_MMU_H */
index 95fb2aa5927efc4678eccd8a51d91044b4dd9adb..ea553c864ff3f46d6fd5f6c2c075c34d283c803f 100644 (file)
@@ -798,7 +798,7 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 {
        unsigned topidx, mididx, idx;
 
-       if (unlikely(xen_feature(XENFEAT_auto_translated_physmap))) {
+       if (xen_feature(XENFEAT_auto_translated_physmap)) {
                BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
                return true;
        }
index 8971a26d21abb943d5c9e23b5c6630a207f43536..8cce47b98d5efe9435ba4432e0bf9ae51d9ba7e9 100644 (file)
@@ -27,6 +27,7 @@
 #include <xen/interface/memory.h>
 #include <xen/interface/physdev.h>
 #include <xen/features.h>
+#include "mmu.h"
 #include "xen-ops.h"
 #include "vdso.h"
 
@@ -78,6 +79,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
        memblock_reserve(start, size);
 
+       if (xen_feature(XENFEAT_auto_translated_physmap))
+               return;
+
        xen_max_p2m_pfn = PFN_DOWN(start + size);
        for (pfn = PFN_DOWN(start); pfn < xen_max_p2m_pfn; pfn++) {
                unsigned long mfn = pfn_to_mfn(pfn);
@@ -100,6 +104,7 @@ static unsigned long __init xen_do_chunk(unsigned long start,
                .domid        = DOMID_SELF
        };
        unsigned long len = 0;
+       int xlated_phys = xen_feature(XENFEAT_auto_translated_physmap);
        unsigned long pfn;
        int ret;
 
@@ -113,7 +118,7 @@ static unsigned long __init xen_do_chunk(unsigned long start,
                                continue;
                        frame = mfn;
                } else {
-                       if (mfn != INVALID_P2M_ENTRY)
+                       if (!xlated_phys && mfn != INVALID_P2M_ENTRY)
                                continue;
                        frame = pfn;
                }
@@ -230,6 +235,27 @@ static void __init xen_set_identity_and_release_chunk(
        *identity += set_phys_range_identity(start_pfn, end_pfn);
 }
 
+/* For PVH, the pfns [0..MAX] are mapped to mfn's in the EPT/NPT. The mfns
+ * are released as part of this 1:1 mapping hypercall back to the dom heap.
+ * Also, we map the entire IO space, ie, beyond max_pfn_mapped.
+ */
+static void __init xen_pvh_identity_map_chunk(unsigned long start_pfn,
+               unsigned long end_pfn, unsigned long *released,
+               unsigned long *identity, unsigned long max_pfn)
+{
+       unsigned long pfn;
+       int numpfns = 1, add_mapping = 1;
+
+       for (pfn = start_pfn; pfn < end_pfn; pfn++)
+               xen_set_clr_mmio_pvh_pte(pfn, pfn, numpfns, add_mapping);
+
+       if (start_pfn <= max_pfn) {
+               unsigned long end = min(max_pfn_mapped, end_pfn);
+               *released += end - start_pfn;
+       }
+       *identity += end_pfn - start_pfn;
+}
+
 static unsigned long __init xen_set_identity_and_release(
        const struct e820entry *list, size_t map_size, unsigned long nr_pages)
 {
@@ -238,6 +264,7 @@ static unsigned long __init xen_set_identity_and_release(
        unsigned long identity = 0;
        const struct e820entry *entry;
        int i;
+       int xlated_phys = xen_feature(XENFEAT_auto_translated_physmap);
 
        /*
         * Combine non-RAM regions and gaps until a RAM region (or the
@@ -259,11 +286,17 @@ static unsigned long __init xen_set_identity_and_release(
                        if (entry->type == E820_RAM)
                                end_pfn = PFN_UP(entry->addr);
 
-                       if (start_pfn < end_pfn)
-                               xen_set_identity_and_release_chunk(
-                                       start_pfn, end_pfn, nr_pages,
-                                       &released, &identity);
-
+                       if (start_pfn < end_pfn) {
+                               if (xlated_phys) {
+                                       xen_pvh_identity_map_chunk(start_pfn,
+                                               end_pfn, &released, &identity,
+                                               nr_pages);
+                               } else {
+                                       xen_set_identity_and_release_chunk(
+                                               start_pfn, end_pfn, nr_pages,
+                                               &released, &identity);
+                               }
+                       }
                        start = end;
                }
        }
@@ -526,16 +559,14 @@ void __cpuinit xen_enable_syscall(void)
 #endif /* CONFIG_X86_64 */
 }
 
-void __init xen_arch_setup(void)
+/* Non auto translated PV domain, ie, it's not PVH. */
+static __init void xen_pvmmu_arch_setup(void)
 {
-       xen_panic_handler_init();
-
        HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
        HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
 
-       if (!xen_feature(XENFEAT_auto_translated_physmap))
-               HYPERVISOR_vm_assist(VMASST_CMD_enable,
-                                    VMASST_TYPE_pae_extended_cr3);
+       HYPERVISOR_vm_assist(VMASST_CMD_enable,
+                            VMASST_TYPE_pae_extended_cr3);
 
        if (register_callback(CALLBACKTYPE_event, xen_hypervisor_callback) ||
            register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback))
@@ -543,6 +574,15 @@ void __init xen_arch_setup(void)
 
        xen_enable_sysenter();
        xen_enable_syscall();
+}
+
+/* This function not called for HVM domain */
+void __init xen_arch_setup(void)
+{
+       xen_panic_handler_init();
+
+       if (!xen_feature(XENFEAT_auto_translated_physmap))
+               xen_pvmmu_arch_setup();
 
 #ifdef CONFIG_ACPI
        if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
index 353c50f18702cfc2ff93118ce3a18b50c6dfdd5c..448f737c64257d1e2f0813ea9280e652f1cf3988 100644 (file)
@@ -68,9 +68,11 @@ static void __cpuinit cpu_bringup(void)
        touch_softlockup_watchdog();
        preempt_disable();
 
-       xen_enable_sysenter();
-       xen_enable_syscall();
-
+       /* PVH runs in ring 0 and allows us to do native syscalls. Yay! */
+       if (!xen_feature(XENFEAT_supervisor_mode_kernel)) {
+               xen_enable_sysenter();
+               xen_enable_syscall();
+       }
        cpu = smp_processor_id();
        smp_store_cpu_info(cpu);
        cpu_data(cpu).x86_max_cores = 1;
@@ -230,10 +232,11 @@ static void __init xen_smp_prepare_boot_cpu(void)
        BUG_ON(smp_processor_id() != 0);
        native_smp_prepare_boot_cpu();
 
-       /* We've switched to the "real" per-cpu gdt, so make sure the
-          old memory can be recycled */
-       make_lowmem_page_readwrite(xen_initial_gdt);
-
+       if (!xen_feature(XENFEAT_writable_page_tables)) {
+               /* We've switched to the "real" per-cpu gdt, so make sure the
+                * old memory can be recycled */
+               make_lowmem_page_readwrite(xen_initial_gdt);
+       }
        xen_filter_cpu_maps();
        xen_setup_vcpu_info_placement();
 }
@@ -300,8 +303,6 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
        gdt = get_cpu_gdt_table(cpu);
 
        ctxt->flags = VGCF_IN_KERNEL;
-       ctxt->user_regs.ds = __USER_DS;
-       ctxt->user_regs.es = __USER_DS;
        ctxt->user_regs.ss = __KERNEL_DS;
 #ifdef CONFIG_X86_32
        ctxt->user_regs.fs = __KERNEL_PERCPU;
@@ -310,35 +311,57 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
        ctxt->gs_base_kernel = per_cpu_offset(cpu);
 #endif
        ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle;
-       ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
 
        memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
 
-       xen_copy_trap_info(ctxt->trap_ctxt);
+       if (xen_feature(XENFEAT_auto_translated_physmap) &&
+           xen_feature(XENFEAT_supervisor_mode_kernel)) {
+               /* Note: PVH is not supported on x86_32. */
+#ifdef CONFIG_X86_64
+               ctxt->user_regs.ds = __KERNEL_DS;
+               ctxt->user_regs.es = 0;
+               ctxt->user_regs.gs = 0;
+
+               /* GUEST_GDTR_BASE and */
+               ctxt->u.pvh.gdtaddr = (unsigned long)gdt;
+               /* GUEST_GDTR_LIMIT in the VMCS. */
+               ctxt->u.pvh.gdtsz = (unsigned long)(GDT_SIZE - 1);
+
+               ctxt->gs_base_user = (unsigned long)
+                                       per_cpu(irq_stack_union.gs_base, cpu);
+#endif
+       } else {
+               ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
+               ctxt->user_regs.ds = __USER_DS;
+               ctxt->user_regs.es = __USER_DS;
 
-       ctxt->ldt_ents = 0;
+               xen_copy_trap_info(ctxt->trap_ctxt);
 
-       BUG_ON((unsigned long)gdt & ~PAGE_MASK);
+               ctxt->ldt_ents = 0;
 
-       gdt_mfn = arbitrary_virt_to_mfn(gdt);
-       make_lowmem_page_readonly(gdt);
-       make_lowmem_page_readonly(mfn_to_virt(gdt_mfn));
+               BUG_ON((unsigned long)gdt & ~PAGE_MASK);
 
-       ctxt->gdt_frames[0] = gdt_mfn;
-       ctxt->gdt_ents      = GDT_ENTRIES;
+               gdt_mfn = arbitrary_virt_to_mfn(gdt);
+               make_lowmem_page_readonly(gdt);
+               make_lowmem_page_readonly(mfn_to_virt(gdt_mfn));
 
-       ctxt->user_regs.cs = __KERNEL_CS;
-       ctxt->user_regs.esp = idle->thread.sp0 - sizeof(struct pt_regs);
+               ctxt->u.pv.gdt_frames[0] = gdt_mfn;
+               ctxt->u.pv.gdt_ents      = GDT_ENTRIES;
 
-       ctxt->kernel_ss = __KERNEL_DS;
-       ctxt->kernel_sp = idle->thread.sp0;
+               ctxt->kernel_ss = __KERNEL_DS;
+               ctxt->kernel_sp = idle->thread.sp0;
 
 #ifdef CONFIG_X86_32
-       ctxt->event_callback_cs     = __KERNEL_CS;
-       ctxt->failsafe_callback_cs  = __KERNEL_CS;
+               ctxt->event_callback_cs     = __KERNEL_CS;
+               ctxt->failsafe_callback_cs  = __KERNEL_CS;
 #endif
-       ctxt->event_callback_eip    = (unsigned long)xen_hypervisor_callback;
-       ctxt->failsafe_callback_eip = (unsigned long)xen_failsafe_callback;
+               ctxt->event_callback_eip    =
+                                       (unsigned long)xen_hypervisor_callback;
+               ctxt->failsafe_callback_eip =
+                                       (unsigned long)xen_failsafe_callback;
+       }
+       ctxt->user_regs.cs = __KERNEL_CS;
+       ctxt->user_regs.esp = idle->thread.sp0 - sizeof(struct pt_regs);
 
        per_cpu(xen_cr3, cpu) = __pa(swapper_pg_dir);
        ctxt->ctrlreg[3] = xen_pfn_to_cr3(virt_to_mfn(swapper_pg_dir));
index 7faed5869e5bf215cafe4c0fdbe24ba38fcd66d0..1a6bca11cc287ccaf0abf938b54a6b2f1cabeb5b 100644 (file)
 #include <xen/interface/elfnote.h>
 #include <asm/xen/interface.h>
 
+#ifdef CONFIG_XEN_X86_PVH
+#define FEATURES_PVH "|writable_descriptor_tables" \
+                    "|auto_translated_physmap" \
+                    "|supervisor_mode_kernel" \
+                    "|hvm_callback_vector"
+#else
+#define FEATURES_PVH /* Not supported */
+#endif
+
        __INIT
 ENTRY(startup_xen)
        cld
@@ -95,7 +104,7 @@ NEXT_HYPERCALL(arch_6)
 #endif
        ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
        ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
-       ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz "!writable_page_tables|pae_pgdir_above_4gb")
+       ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz "!writable_page_tables|pae_pgdir_above_4gb"FEATURES_PVH)
        ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
        ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
        ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
index f2d6b78d901d92d3965fe3bd849751f04fb7ccf3..aab86772facfef3465d9fc59aab0e9bca45ccd3e 100644 (file)
@@ -666,7 +666,9 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
                return;
 
        BUG_ON(npo.copy_prod > ARRAY_SIZE(netbk->grant_copy_op));
-       gnttab_batch_copy(netbk->grant_copy_op, npo.copy_prod);
+       ret = HYPERVISOR_grant_table_op(GNTTABOP_copy, &netbk->grant_copy_op,
+                                       npo.copy_prod);
+       BUG_ON(ret != 0);
 
        while ((skb = __skb_dequeue(&rxq)) != NULL) {
                sco = (struct skb_cb_overlay *)skb->cb;
@@ -1489,15 +1491,18 @@ static void xen_netbk_tx_submit(struct xen_netbk *netbk)
 static void xen_netbk_tx_action(struct xen_netbk *netbk)
 {
        unsigned nr_gops;
+       int ret;
 
        nr_gops = xen_netbk_tx_build_gops(netbk);
 
        if (nr_gops == 0)
                return;
-
-       gnttab_batch_copy(netbk->tx_copy_ops, nr_gops);
+       ret = HYPERVISOR_grant_table_op(GNTTABOP_copy,
+                                       netbk->tx_copy_ops, nr_gops);
+       BUG_ON(ret);
 
        xen_netbk_tx_submit(netbk);
+
 }
 
 static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx)
index 126d8ce591ce5fc7e69348f746e91e60b04bc4ee..cabfa97f4674ef12c1fcd13d1a55c4affd47f635 100644 (file)
@@ -206,4 +206,7 @@ config XEN_MCE_LOG
          Allow kernel fetching MCE error from Xen platform and
          converting it into Linux mcelog format for mcelog tools
 
+config XEN_HAVE_PVMMU
+       bool
+
 endmenu
index 0e86370354572ac7d4116eb70cf6e41d1a52cf35..23d3737e8b78ecb5d5c79937bdd9385ae3e0a0fe 100644 (file)
@@ -1,8 +1,8 @@
 ifneq ($(CONFIG_ARM),y)
-obj-y  += manage.o balloon.o
+obj-y  += manage.o
 obj-$(CONFIG_HOTPLUG_CPU)              += cpu_hotplug.o
 endif
-obj-y  += grant-table.o features.o events.o
+obj-y  += grant-table.o features.o events.o balloon.o fallback.o
 obj-y  += xenbus/
 
 nostackp := $(call cc-option, -fno-stack-protector)
index d6886d90ccfd53eed62773a755ee282e9553a55f..d42da3b9a58a99d1a0c46742c31a79b85dce68b4 100644 (file)
@@ -359,8 +359,11 @@ static enum bp_state increase_reservation(unsigned long nr_pages)
 
                set_phys_to_machine(pfn, frame_list[i]);
 
+#ifdef CONFIG_XEN_HAVE_PVMMU
                /* Link back into the page tables if not highmem. */
-               if (xen_pv_domain() && !PageHighMem(page)) {
+               if (xen_pv_domain() && !PageHighMem(page) &&
+                   !xen_feature(XENFEAT_auto_translated_physmap)) {
+
                        int ret;
                        ret = HYPERVISOR_update_va_mapping(
                                (unsigned long)__va(pfn << PAGE_SHIFT),
@@ -368,6 +371,7 @@ static enum bp_state increase_reservation(unsigned long nr_pages)
                                0);
                        BUG_ON(ret);
                }
+#endif
 
                /* Relinquish the page back to the allocator. */
                ClearPageReserved(page);
@@ -416,13 +420,16 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
 
                scrub_page(page);
 
+#ifdef CONFIG_XEN_HAVE_PVMMU
                if (xen_pv_domain() && !PageHighMem(page)) {
-                       ret = HYPERVISOR_update_va_mapping(
-                               (unsigned long)__va(pfn << PAGE_SHIFT),
-                               __pte_ma(0), 0);
-                       BUG_ON(ret);
+                       if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+                               ret = HYPERVISOR_update_va_mapping(
+                                       (unsigned long)__va(pfn << PAGE_SHIFT),
+                                       __pte_ma(0), 0);
+                               BUG_ON(ret);
+                       }
                }
-
+#endif
        }
 
        /* Ensure that ballooned highmem pages don't have kmaps. */
index 4dcfced107f50e41c518405b28747064d62d78bc..de6bcf9353ba552243db58464e27b4fa1668d3a6 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <xen/xen.h>
 #include <xen/xenbus.h>
+#include <xen/features.h>
 
 #include <asm/xen/hypervisor.h>
 #include <asm/cpu.h>
@@ -100,7 +101,8 @@ static int __init setup_vcpu_hotplug_event(void)
        static struct notifier_block xsn_cpu = {
                .notifier_call = setup_cpu_watcher };
 
-       if (!xen_pv_domain())
+       /* PVH TBD/FIXME: future work */
+       if (!xen_pv_domain() || xen_feature(XENFEAT_auto_translated_physmap))
                return -ENODEV;
 
        register_xenstore_notifier(&xsn_cpu);
index 912ac81b6dbff5e2b9f48c2b2662083bf00ce476..51780b6c184b536dad3d24329e4e0befcdff24f7 100644 (file)
@@ -1778,7 +1778,7 @@ int xen_set_callback_via(uint64_t via)
 }
 EXPORT_SYMBOL_GPL(xen_set_callback_via);
 
-#ifdef CONFIG_XEN_PVHVM
+#ifdef CONFIG_X86
 /* Vector callbacks are better than PCI interrupts to receive event
  * channel notifications because we can receive vector callbacks on any
  * vcpu and we don't need PCI support or APIC interactions. */
@@ -1839,6 +1839,13 @@ void __init xen_init_IRQ(void)
                if (xen_initial_domain())
                        pci_xen_initial_domain();
 
+               if (xen_feature(XENFEAT_hvm_callback_vector)) {
+                       xen_callback_vector();
+                       return;
+               }
+
+               /* PVH: TBD/FIXME: debug and fix eio map to work with pvh */
+
                pirq_eoi_map = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
                eoi_gmfn.gmfn = virt_to_mfn(pirq_eoi_map);
                rc = HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn);
diff --git a/drivers/xen/fallback.c b/drivers/xen/fallback.c
new file mode 100644 (file)
index 0000000..b29ce32
--- /dev/null
@@ -0,0 +1,81 @@
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/bug.h>
+#include <linux/export.h>
+#include <asm/hypervisor.h>
+#include <asm/xen/hypercall.h>
+
+int xen_HYPERVISOR_event_channel_op_compat(int cmd, void *arg)
+{
+       struct evtchn_op op;
+       int rc;
+
+       op.cmd = cmd;
+       memcpy(&op.u, arg, sizeof(op.u));
+       rc = _hypercall1(int, event_channel_op_compat, &op);
+
+       switch (cmd) {
+       case EVTCHNOP_close:
+       case EVTCHNOP_send:
+       case EVTCHNOP_bind_vcpu:
+       case EVTCHNOP_unmask:
+               /* no output */
+               break;
+
+#define COPY_BACK(eop) \
+       case EVTCHNOP_##eop: \
+               memcpy(arg, &op.u.eop, sizeof(op.u.eop)); \
+               break
+
+       COPY_BACK(bind_interdomain);
+       COPY_BACK(bind_virq);
+       COPY_BACK(bind_pirq);
+       COPY_BACK(status);
+       COPY_BACK(alloc_unbound);
+       COPY_BACK(bind_ipi);
+#undef COPY_BACK
+
+       default:
+               WARN_ON(rc != -ENOSYS);
+               break;
+       }
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(xen_HYPERVISOR_event_channel_op_compat);
+
+int xen_HYPERVISOR_physdev_op_compat(int cmd, void *arg)
+{
+       struct physdev_op op;
+       int rc;
+
+       op.cmd = cmd;
+       memcpy(&op.u, arg, sizeof(op.u));
+       rc = _hypercall1(int, physdev_op_compat, &op);
+
+       switch (cmd) {
+       case PHYSDEVOP_IRQ_UNMASK_NOTIFY:
+       case PHYSDEVOP_set_iopl:
+       case PHYSDEVOP_set_iobitmap:
+       case PHYSDEVOP_apic_write:
+               /* no output */
+               break;
+
+#define COPY_BACK(pop, fld) \
+       case PHYSDEVOP_##pop: \
+               memcpy(arg, &op.u.fld, sizeof(op.u.fld)); \
+               break
+
+       COPY_BACK(irq_status_query, irq_status_query);
+       COPY_BACK(apic_read, apic_op);
+       COPY_BACK(ASSIGN_VECTOR, irq_op);
+#undef COPY_BACK
+
+       default:
+               WARN_ON(rc != -ENOSYS);
+               break;
+       }
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(xen_HYPERVISOR_physdev_op_compat);
index 2e22df2f7a3f8b57fe44ce8842b825602a012658..1a077a3521594d28ae3439c3c5f39e0e2beebee1 100644 (file)
@@ -805,7 +805,8 @@ static int __init gntdev_init(void)
        if (!xen_domain())
                return -ENODEV;
 
-       use_ptemod = xen_pv_domain();
+       use_ptemod = xen_pv_domain() &&
+                    !xen_feature(XENFEAT_auto_translated_physmap);
 
        err = misc_register(&gntdev_miscdev);
        if (err != 0) {
index b91f14e831648e68093a02f804f82e4113325360..043bf07ae56a396251058bffe4857830cca2b79e 100644 (file)
@@ -38,7 +38,6 @@
 #include <linux/vmalloc.h>
 #include <linux/uaccess.h>
 #include <linux/io.h>
-#include <linux/delay.h>
 #include <linux/hardirq.h>
 
 #include <xen/xen.h>
@@ -824,52 +823,6 @@ unsigned int gnttab_max_grant_frames(void)
 }
 EXPORT_SYMBOL_GPL(gnttab_max_grant_frames);
 
-/* Handling of paged out grant targets (GNTST_eagain) */
-#define MAX_DELAY 256
-static inline void
-gnttab_retry_eagain_gop(unsigned int cmd, void *gop, int16_t *status,
-                                               const char *func)
-{
-       unsigned delay = 1;
-
-       do {
-               BUG_ON(HYPERVISOR_grant_table_op(cmd, gop, 1));
-               if (*status == GNTST_eagain)
-                       msleep(delay++);
-       } while ((*status == GNTST_eagain) && (delay < MAX_DELAY));
-
-       if (delay >= MAX_DELAY) {
-               printk(KERN_ERR "%s: %s eagain grant\n", func, current->comm);
-               *status = GNTST_bad_page;
-       }
-}
-
-void gnttab_batch_map(struct gnttab_map_grant_ref *batch, unsigned count)
-{
-       struct gnttab_map_grant_ref *op;
-
-       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, batch, count))
-               BUG();
-       for (op = batch; op < batch + count; op++)
-               if (op->status == GNTST_eagain)
-                       gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, op,
-                                               &op->status, __func__);
-}
-EXPORT_SYMBOL_GPL(gnttab_batch_map);
-
-void gnttab_batch_copy(struct gnttab_copy *batch, unsigned count)
-{
-       struct gnttab_copy *op;
-
-       if (HYPERVISOR_grant_table_op(GNTTABOP_copy, batch, count))
-               BUG();
-       for (op = batch; op < batch + count; op++)
-               if (op->status == GNTST_eagain)
-                       gnttab_retry_eagain_gop(GNTTABOP_copy, op,
-                                               &op->status, __func__);
-}
-EXPORT_SYMBOL_GPL(gnttab_batch_copy);
-
 int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
                    struct gnttab_map_grant_ref *kmap_ops,
                    struct page **pages, unsigned int count)
@@ -883,12 +836,6 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
        if (ret)
                return ret;
 
-       /* Retry eagain maps */
-       for (i = 0; i < count; i++)
-               if (map_ops[i].status == GNTST_eagain)
-                       gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-                                               &map_ops[i].status, __func__);
-
        if (xen_feature(XENFEAT_auto_translated_physmap))
                return ret;
 
@@ -1029,14 +976,20 @@ static void gnttab_unmap_frames_v2(void)
 static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
 {
        struct gnttab_setup_table setup;
+       unsigned long start_gpfn;
        xen_pfn_t *frames;
        unsigned int nr_gframes = end_idx + 1;
        int rc;
 
-       if (xen_hvm_domain()) {
+       if (xen_hvm_domain() || xen_feature(XENFEAT_auto_translated_physmap)) {
                struct xen_add_to_physmap xatp;
                unsigned int i = end_idx;
                rc = 0;
+
+               if (xen_hvm_domain())
+                       start_gpfn = xen_hvm_resume_frames >> PAGE_SHIFT;
+               else
+                       start_gpfn = virt_to_pfn(gnttab_shared.addr);
                /*
                 * Loop backwards, so that the first hypercall has the largest
                 * index, ensuring that the table will grow only once.
@@ -1045,7 +998,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
                        xatp.domid = DOMID_SELF;
                        xatp.idx = i;
                        xatp.space = XENMAPSPACE_grant_table;
-                       xatp.gpfn = (xen_hvm_resume_frames >> PAGE_SHIFT) + i;
+                       xatp.gpfn = start_gpfn + i;
                        rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp);
                        if (rc != 0) {
                                printk(KERN_WARNING
@@ -1108,7 +1061,7 @@ static void gnttab_request_version(void)
        int rc;
        struct gnttab_set_version gsv;
 
-       if (xen_hvm_domain())
+       if (xen_hvm_domain() || xen_feature(XENFEAT_auto_translated_physmap))
                gsv.version = 1;
        else
                gsv.version = 2;
@@ -1136,12 +1089,25 @@ static void gnttab_request_version(void)
 int gnttab_resume(void)
 {
        unsigned int max_nr_gframes;
+       char *kmsg = "Failed to kmalloc pages for pv in hvm grant frames\n";
 
        gnttab_request_version();
        max_nr_gframes = gnttab_max_grant_frames();
        if (max_nr_gframes < nr_grant_frames)
                return -ENOSYS;
 
+       /* PVH note: xen will free existing kmalloc'd mfn in
+        * XENMEM_add_to_physmap. TBD/FIXME: use xen ballooning instead of
+        * kmalloc(). */
+       if (xen_pv_domain() && xen_feature(XENFEAT_auto_translated_physmap) &&
+           !gnttab_shared.addr) {
+               gnttab_shared.addr =
+                       kmalloc(max_nr_gframes * PAGE_SIZE, GFP_KERNEL);
+               if (!gnttab_shared.addr) {
+                       pr_warn("%s", kmsg);
+                       return -ENOMEM;
+               }
+       }
        if (xen_pv_domain())
                return gnttab_map(0, nr_grant_frames - 1);
 
index 8adb9cc267f96e201ade041441ef8a317ce336d8..b9d08987a5a5183648cca5c83d6788cf7e0eaaf5 100644 (file)
 #include <xen/features.h>
 #include <xen/page.h>
 #include <xen/xen-ops.h>
+#include <xen/balloon.h>
 
 #include "privcmd.h"
 
 MODULE_LICENSE("GPL");
 
+#define PRIV_VMA_LOCKED ((void *)1)
+
 #ifndef HAVE_ARCH_PRIVCMD_MMAP
 static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma);
 #endif
@@ -178,7 +181,7 @@ static int mmap_mfn_range(void *data, void *state)
                                        msg->va & PAGE_MASK,
                                        msg->mfn, msg->npages,
                                        vma->vm_page_prot,
-                                       st->domain);
+                                       st->domain, NULL);
        if (rc < 0)
                return rc;
 
@@ -199,6 +202,10 @@ static long privcmd_ioctl_mmap(void __user *udata)
        if (!xen_initial_domain())
                return -EPERM;
 
+       /* We only support privcmd_ioctl_mmap_batch for auto translated. */
+       if (xen_feature(XENFEAT_auto_translated_physmap))
+               return -ENOSYS;
+
        if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd)))
                return -EFAULT;
 
@@ -246,6 +253,7 @@ struct mmap_batch_state {
        domid_t domain;
        unsigned long va;
        struct vm_area_struct *vma;
+       int index;
        /* A tristate:
         *      0 for no errors
         *      1 if at least one error has happened (and no
@@ -260,14 +268,24 @@ struct mmap_batch_state {
        xen_pfn_t __user *user_mfn;
 };
 
+/* auto translated dom0 note: if domU being created is PV, then mfn is
+ * mfn(addr on bus). If it's auto xlated, then mfn is pfn (input to HAP).
+ */
 static int mmap_batch_fn(void *data, void *state)
 {
        xen_pfn_t *mfnp = data;
        struct mmap_batch_state *st = state;
+       struct vm_area_struct *vma = st->vma;
+       struct page **pages = vma->vm_private_data;
+       struct page *cur_page = NULL;
        int ret;
 
+       if (xen_feature(XENFEAT_auto_translated_physmap))
+               cur_page = pages[st->index++];
+
        ret = xen_remap_domain_mfn_range(st->vma, st->va & PAGE_MASK, *mfnp, 1,
-                                        st->vma->vm_page_prot, st->domain);
+                                        st->vma->vm_page_prot, st->domain,
+                                        &cur_page);
 
        /* Store error code for second pass. */
        *(st->err++) = ret;
@@ -303,6 +321,32 @@ static int mmap_return_errors_v1(void *data, void *state)
        return __put_user(*mfnp, st->user_mfn++);
 }
 
+/* Allocate pfns that are then mapped with gmfns from foreign domid. Update
+ * the vma with the page info to use later.
+ * Returns: 0 if success, otherwise -errno
+ */
+static int alloc_empty_pages(struct vm_area_struct *vma, int numpgs)
+{
+       int rc;
+       struct page **pages;
+
+       pages = kcalloc(numpgs, sizeof(pages[0]), GFP_KERNEL);
+       if (pages == NULL)
+               return -ENOMEM;
+
+       rc = alloc_xenballooned_pages(numpgs, pages, 0);
+       if (rc != 0) {
+               pr_warn("%s Could not alloc %d pfns rc:%d\n", __func__,
+                       numpgs, rc);
+               kfree(pages);
+               return -ENOMEM;
+       }
+       BUG_ON(vma->vm_private_data != PRIV_VMA_LOCKED);
+       vma->vm_private_data = pages;
+
+       return 0;
+}
+
 static struct vm_operations_struct privcmd_vm_ops;
 
 static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
@@ -370,10 +414,18 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
                up_write(&mm->mmap_sem);
                goto out;
        }
+       if (xen_feature(XENFEAT_auto_translated_physmap)) {
+               ret = alloc_empty_pages(vma, m.num);
+               if (ret < 0) {
+                       up_write(&mm->mmap_sem);
+                       goto out;
+               }
+       }
 
        state.domain        = m.dom;
        state.vma           = vma;
        state.va            = m.addr;
+       state.index         = 0;
        state.global_error  = 0;
        state.err           = err_array;
 
@@ -438,6 +490,19 @@ static long privcmd_ioctl(struct file *file,
        return ret;
 }
 
+static void privcmd_close(struct vm_area_struct *vma)
+{
+       struct page **pages = vma->vm_private_data;
+       int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+
+       if (!xen_feature(XENFEAT_auto_translated_physmap || !numpgs || !pages))
+               return;
+
+       xen_unmap_domain_mfn_range(vma, numpgs, pages);
+       free_xenballooned_pages(numpgs, pages);
+       kfree(pages);
+}
+
 static int privcmd_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        printk(KERN_DEBUG "privcmd_fault: vma=%p %lx-%lx, pgoff=%lx, uv=%p\n",
@@ -448,6 +513,7 @@ static int privcmd_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 }
 
 static struct vm_operations_struct privcmd_vm_ops = {
+       .close = privcmd_close,
        .fault = privcmd_fault
 };
 
@@ -465,7 +531,7 @@ static int privcmd_mmap(struct file *file, struct vm_area_struct *vma)
 
 static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma)
 {
-       return (xchg(&vma->vm_private_data, (void *)1) == NULL);
+       return !cmpxchg(&vma->vm_private_data, NULL, PRIV_VMA_LOCKED);
 }
 
 const struct file_operations xen_privcmd_fops = {
index bcf3ba4a6ec1543a7500ef0de36269dec1ff728d..1bac743c1a1865e4ae444a6885c17b244fd376f9 100644 (file)
@@ -44,6 +44,7 @@
 #include <xen/grant_table.h>
 #include <xen/xenbus.h>
 #include <xen/xen.h>
+#include <xen/features.h>
 
 #include "xenbus_probe.h"
 
@@ -490,7 +491,8 @@ static int xenbus_map_ring_valloc_pv(struct xenbus_device *dev,
 
        op.host_addr = arbitrary_virt_to_machine(pte).maddr;
 
-       gnttab_batch_map(&op, 1);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+               BUG();
 
        if (op.status != GNTST_okay) {
                free_vm_area(area);
@@ -571,7 +573,8 @@ int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
        gnttab_set_map_op(&op, (unsigned long)vaddr, GNTMAP_host_map, gnt_ref,
                          dev->otherend_id);
 
-       gnttab_batch_map(&op, 1);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+               BUG();
 
        if (op.status != GNTST_okay) {
                xenbus_dev_fatal(dev, op.status,
@@ -741,7 +744,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = {
 
 void __init xenbus_ring_ops_init(void)
 {
-       if (xen_pv_domain())
+       if (xen_pv_domain() && !xen_feature(XENFEAT_auto_translated_physmap))
                ring_ops = &ring_ops_pv;
        else
                ring_ops = &ring_ops_hvm;
index 694dcaf266e635335dfdaf22994624d3d5e3d9d4..8e39879fd6fd06a908d9bd4d7c98112adabb9b9c 100644 (file)
@@ -190,16 +190,4 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
                      struct gnttab_map_grant_ref *kunmap_ops,
                      struct page **pages, unsigned int count);
 
-/* Perform a batch of grant map/copy operations. Retry every batch slot
- * for which the hypervisor returns GNTST_eagain. This is typically due
- * to paged out target frames.
- *
- * Will retry for 1, 2, ... 255 ms, i.e. 256 times during 32 seconds.
- *
- * Return value in each iand every status field of the batch guaranteed
- * to not be GNTST_eagain.
- */
-void gnttab_batch_map(struct gnttab_map_grant_ref *batch, unsigned count);
-void gnttab_batch_copy(struct gnttab_copy *batch, unsigned count);
-
 #endif /* __ASM_GNTTAB_H__ */
index 90712e2072d57ba6c6154549352266d253ab3615..b40a4315cb8b0724a7ff373570c5526800dceee5 100644 (file)
@@ -153,6 +153,14 @@ struct xen_machphys_mapping {
 };
 DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);
 
+#define XENMAPSPACE_shared_info  0 /* shared info page */
+#define XENMAPSPACE_grant_table  1 /* grant table page */
+#define XENMAPSPACE_gmfn         2 /* GMFN */
+#define XENMAPSPACE_gmfn_range   3 /* GMFN range, XENMEM_add_to_physmap only. */
+#define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
+                                   * XENMEM_add_to_physmap_range only.
+                                   */
+
 /*
  * Sets the GPFN at which a particular page appears in the specified guest's
  * pseudophysical address space.
@@ -167,8 +175,6 @@ struct xen_add_to_physmap {
     uint16_t    size;
 
     /* Source mapping space. */
-#define XENMAPSPACE_shared_info 0 /* shared info page */
-#define XENMAPSPACE_grant_table 1 /* grant table page */
     unsigned int space;
 
     /* Index into source mapping space. */
@@ -182,6 +188,24 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
 /*** REMOVED ***/
 /*#define XENMEM_translate_gpfn_list  8*/
 
+#define XENMEM_add_to_physmap_range 23
+struct xen_add_to_physmap_range {
+    /* Which domain to change the mapping for. */
+    domid_t domid;
+    uint16_t space; /* => enum phys_map_space */
+
+    /* Number of pages to go through */
+    uint16_t size;
+    domid_t foreign_domid; /* IFF gmfn_foreign */
+
+    /* Indexes into space being mapped. */
+    GUEST_HANDLE(xen_ulong_t) idxs;
+
+    /* GPFN in domid where the source mapping page should appear. */
+    GUEST_HANDLE(xen_pfn_t) gpfns;
+};
+DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap_range);
+
 /*
  * Returns the pseudo-physical memory map as it was when the domain
  * was started (specified by XENMEM_set_memory_map).
@@ -217,4 +241,20 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map);
  * during a driver critical region.
  */
 extern spinlock_t xen_reservation_lock;
+
+/*
+ * Unmaps the page appearing at a particular GPFN from the specified guest's
+ * pseudophysical address space.
+ * arg == addr of xen_remove_from_physmap_t.
+ */
+#define XENMEM_remove_from_physmap      15
+struct xen_remove_from_physmap {
+    /* Which domain to change the mapping for. */
+    domid_t domid;
+
+    /* GPFN of the current mapping of the page. */
+    xen_pfn_t gpfn;
+};
+DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap);
+
 #endif /* __XEN_PUBLIC_MEMORY_H__ */
index 1844d31f45520fef57c93be90ba7e247e1a0b042..83050d32bf46243f9b09bfc494a7de98b0420c94 100644 (file)
@@ -274,6 +274,16 @@ struct physdev_dbgp_op {
     } u;
 };
 
+#define PHYSDEVOP_map_iomem        30
+struct physdev_map_iomem {
+    /* IN */
+    uint64_t first_gfn;
+    uint64_t first_mfn;
+    uint32_t nr_mfns;
+    uint32_t add_mapping; /* 1 == add mapping;  0 == unmap */
+
+};
+
 /*
  * Notify that some PIRQ-bound event channels have been unmasked.
  * ** This command is obsolete since interface version 0x00030202 and is **
index 6a198e46ab6e1c50cdff7fe76d58b3a4afb43d43..a50e7bee891203e52cf489763327face535d8d30 100644 (file)
@@ -2,6 +2,7 @@
 #define INCLUDE_XEN_OPS_H
 
 #include <linux/percpu.h>
+#include <asm/xen/interface.h>
 
 DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
 
@@ -26,7 +27,10 @@ void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
 struct vm_area_struct;
 int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
                               unsigned long addr,
-                              unsigned long mfn, int nr,
-                              pgprot_t prot, unsigned domid);
+                              xen_pfn_t mfn, int nr,
+                              pgprot_t prot, unsigned domid,
+                              struct page **pages);
+int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
+                              int numpgs, struct page **pages);
 
 #endif /* INCLUDE_XEN_OPS_H */