Skip to contentSkip to conversation

x86: adjust microcode handling interface

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: adjust microcode handling interface

Confine the knowledge that the buffer gets accessed without use of proper guest handle accessors to a single file.

xen/arch/x86/microcode.c +8 -3
Index: 2006-09-21/xen/arch/x86/microcode.c
===================================================================
@@ -455,7 +455,7 @@ static int do_microcode_update (void)
 	return error;
 }
 
-int microcode_update(void *buf, unsigned long len)
+int microcode_update(XEN_GUEST_HANDLE(void) buf, unsigned long len)
 {
 	int ret;
 
@@ -464,10 +464,15 @@ int microcode_update(void *buf, unsigned
 		return -EINVAL;
 	}
 
+	if (len != (typeof(user_buffer_size))len) {
+		printk(KERN_ERR "microcode: too much data\n");
+		return -E2BIG;
+	}
+
 	mutex_lock(&microcode_mutex);
 
-	user_buffer = (void __user *) buf;
-	user_buffer_size = (int) len;
+	user_buffer = buf.p;
+	user_buffer_size = len;
 
 	ret = do_microcode_update();
 
xen/arch/x86/platform_hypercall.c +2 -2
Index: 2006-09-21/xen/arch/x86/platform_hypercall.c
===================================================================
@@ -104,8 +104,8 @@ long do_platform_op(XEN_GUEST_HANDLE(xen
 
     case XENPF_microcode_update:
     {
-        extern int microcode_update(void *buf, unsigned long len);
-        ret = microcode_update(op->u.microcode.data.p,
+        extern int microcode_update(XEN_GUEST_HANDLE(void), unsigned long len);
+        ret = microcode_update(op->u.microcode.data,
                                op->u.microcode.length);
     }
     break;