]> xenbits.xensource.com Git - people/ssmith/netchannel2-pvops.git/commitdiff
xen mtrr: Add xen_{get,set}_mtrr() implementations
authorMark McLoughlin <markmc@redhat.com>
Tue, 29 Jan 2008 17:43:25 +0000 (17:43 +0000)
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Fri, 19 Jun 2009 19:13:15 +0000 (12:13 -0700)
Straightforward apart from the hack to turn mtrr_ops->set()
into a no-op on all but one CPU.

[ Impact: complete Xen mtrr implementation ]

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
arch/x86/kernel/cpu/mtrr/xen.c

index 031331cf8dd0d6820134822490496e930a734647..c4e74846143af8625640b9d9a6a6f492d2c92145 100644 (file)
@@ -7,6 +7,52 @@
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypercall.h>
 
+static void xen_set_mtrr(unsigned int reg, unsigned long base,
+                        unsigned long size, mtrr_type type)
+{
+       struct xen_platform_op op;
+       int error;
+
+       /* mtrr_ops->set() is called once per CPU,
+        * but Xen's ops apply to all CPUs.
+        */
+       if (smp_processor_id())
+               return;
+
+       if (size == 0) {
+               op.cmd = XENPF_del_memtype;
+               op.u.del_memtype.handle = 0;
+               op.u.del_memtype.reg    = reg;
+       } else {
+               op.cmd = XENPF_add_memtype;
+               op.u.add_memtype.mfn     = base;
+               op.u.add_memtype.nr_mfns = size;
+               op.u.add_memtype.type    = type;
+       }
+
+       error = HYPERVISOR_dom0_op(&op);
+       BUG_ON(error != 0);
+}
+
+static void xen_get_mtrr(unsigned int reg, unsigned long *base,
+                        unsigned long *size, mtrr_type *type)
+{
+       struct xen_platform_op op;
+
+       op.cmd = XENPF_read_memtype;
+       op.u.read_memtype.reg = reg;
+       if (HYPERVISOR_dom0_op(&op) != 0) {
+               *base = 0;
+               *size = 0;
+               *type = 0;
+               return;
+       }
+
+       *size = op.u.read_memtype.nr_mfns;
+       *base = op.u.read_memtype.mfn;
+       *type = op.u.read_memtype.type;
+}
+
 static int __init xen_num_var_ranges(void)
 {
        int ranges;
@@ -29,7 +75,10 @@ static int __init xen_num_var_ranges(void)
 static struct mtrr_ops xen_mtrr_ops = {
        .vendor            = X86_VENDOR_UNKNOWN,
        .get_free_region   = generic_get_free_region,
+       .set               = xen_set_mtrr,
+       .get               = xen_get_mtrr,
        .have_wrcomb       = positive_have_wrcomb,
+       .validate_add_page = generic_validate_add_page,
        .use_intel_if      = 0,
        .num_var_ranges    = xen_num_var_ranges,
 };