Skip to contentSkip to conversation

32-on-64 trap table setup

RFC PATCH In review Jan Beulich 1 participant 1 message Oct 4, 2006

lore
Share & tools
lore
#0 lore raw

RFC PATCH 13/17 32-on-64 trap table setup

xen/arch/x86/x86_64/compat/entry.S +0 -2
Index: 2006-10-04/xen/arch/x86/x86_64/compat/entry.S
===================================================================
@@ -278,8 +278,6 @@ CFIX14:
 
 .section .rodata, "a", @progbits
 
-#define compat_set_trap_table domain_crash_synchronous
-#define compat_set_gdt domain_crash_synchronous
 #define compat_platform_op domain_crash_synchronous
 #define compat_multicall domain_crash_synchronous
 #define compat_set_timer_op domain_crash_synchronous
xen/arch/x86/x86_64/compat/mm.c +33 -0
Index: 2006-10-04/xen/arch/x86/x86_64/compat/mm.c
===================================================================
@@ -4,6 +4,39 @@
 #include <compat/memory.h>
 #include <compat/xen.h>
 
+int compat_set_gdt(XEN_GUEST_HANDLE(uint) frame_list, unsigned int entries)
+{
+    unsigned int i, nr_pages = (entries + 511) / 512;
+    unsigned long frames[16];
+    long ret;
+
+    /* Rechecked in set_gdt, but ensures a sane limit for copy_from_user(). */
+    if ( entries > FIRST_RESERVED_GDT_ENTRY )
+        return -EINVAL;
+
+    if ( !guest_handle_okay(frame_list, nr_pages) )
+        return -EFAULT;
+
+    for ( i = 0; i < nr_pages; ++i )
+    {
+        unsigned int frame;
+
+        if ( __copy_from_guest(&frame, frame_list, 1) )
+            return -EFAULT;
+        frames[i] = frame;
+        guest_handle_add_offset(frame_list, 1);
+    }
+
+    LOCK_BIGLOCK(current->domain);
+
+    if ( (ret = set_gdt(current, frames, entries)) == 0 )
+        local_flush_tlb();
+
+    UNLOCK_BIGLOCK(current->domain);
+
+    return ret;
+}
+
 int compat_update_descriptor(u32 pa_lo, u32 pa_hi, u32 desc_lo, u32 desc_hi)
 {
     return do_update_descriptor(pa_lo | ((u64)pa_hi << 32),
xen/arch/x86/x86_64/compat/traps.c +49 -0

61 lines not on this page · raw message