Skip to contentSkip to conversation

fix MTRR dom0 interface

PATCH New Jan Beulich 1 participant 1 message Jan 4, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix MTRR dom0 interface

The dom0_ops implementation wasn't matching the interface definition, leading to ill messages when X starts up (and potentially to other problems). The attached patch fixes that. However, it also points out that there is a potential disagreement between the dom0_ops interface and the internal MTRR interface - the former expects an unsigned register number from the domain, the latter wants a signed one and does a lookup when it's negative. I would think that the lookup code should just be ripped out of xen/arch/x86/mtrr/main.c.

Jan

xen/arch/x86/dom0_ops.c renamed from home/jbeulich/src/xen/unstable/2005-12-20/xen/arch/x86/dom0_ops.c +16 -1
@@ -102,12 +102,27 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
             op->u.add_memtype.nr_pfns,
             op->u.add_memtype.type,
             1);
+        if (ret > 0)
+        {
+            (void)__put_user(0, &u_dom0_op->u.add_memtype.handle);
+            (void)__put_user(ret, &u_dom0_op->u.add_memtype.reg);
+            ret = 0;
+        }
     }
     break;
 
     case DOM0_DEL_MEMTYPE:
     {
-        ret = mtrr_del_page(op->u.del_memtype.reg, 0, 0);
+        if (op->u.del_memtype.handle == 0
+            /* mtrr/main.c otherwise does a lookup */
+            && (int)op->u.del_memtype.reg >= 0)
+        {
+            ret = mtrr_del_page(op->u.del_memtype.reg, 0, 0);
+            if (ret > 0)
+                ret = 0;
+        }
+        else
+            ret = -EINVAL;
     }
     break;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel