]> xenbits.xensource.com Git - xen.git/commitdiff
x86/mm: move compat descriptor table manipulation code
authorWei Liu <wei.liu2@citrix.com>
Wed, 13 Sep 2017 17:03:32 +0000 (18:03 +0100)
committerWei Liu <wei.liu2@citrix.com>
Fri, 22 Sep 2017 15:31:50 +0000 (16:31 +0100)
Move them alongside the non-compat variants.

Change u{32,64} to uint{32,64}_t and the type of ret from long to int
while moving.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/pv/descriptor-tables.c
xen/arch/x86/x86_64/compat/mm.c

index 04fb37f2ce9cc852a1843114006bcfe2c415163a..81973af124c8b6e264d919b00a924463399b8de1 100644 (file)
@@ -181,6 +181,46 @@ long do_update_descriptor(uint64_t pa, uint64_t desc)
     return ret;
 }
 
+int compat_set_gdt(XEN_GUEST_HANDLE_PARAM(uint) frame_list, unsigned int entries)
+{
+    unsigned int i, nr_pages = (entries + 511) / 512;
+    unsigned long frames[16];
+    int 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);
+    }
+
+    domain_lock(current->domain);
+
+    if ( (ret = pv_set_gdt(current, frames, entries)) == 0 )
+        flush_tlb_local();
+
+    domain_unlock(current->domain);
+
+    return ret;
+}
+
+int compat_update_descriptor(uint32_t pa_lo, uint32_t pa_hi,
+                             uint32_t desc_lo, uint32_t desc_hi)
+{
+    return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32),
+                                desc_lo | ((uint64_t)desc_hi << 32));
+}
+
 /*
  * Local variables:
  * mode: C
index 16ea2a80dfd519b34dbbb6f6577de6084cd21ff3..c2aa6f2fdb899a1d2a3deff65808e7406e10ec44 100644 (file)
@@ -8,45 +8,6 @@
 
 #include <asm/pv/mm.h>
 
-int compat_set_gdt(XEN_GUEST_HANDLE_PARAM(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);
-    }
-
-    domain_lock(current->domain);
-
-    if ( (ret = pv_set_gdt(current, frames, entries)) == 0 )
-        flush_tlb_local();
-
-    domain_unlock(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),
-                                desc_lo | ((u64)desc_hi << 32));
-}
-
 int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
     struct compat_machphys_mfn_list xmml;