x86: move compat_show_guest_statck near its non-compat variant
authorWei Liu <wei.liu2@citrix.com>
Thu, 8 Jun 2017 16:22:33 +0000 (17:22 +0100)
committerWei Liu <wei.liu2@citrix.com>
Fri, 23 Jun 2017 15:06:19 +0000 (16:06 +0100)
And make it static, remove the declaration in header.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/traps.c
xen/arch/x86/x86_64/compat/traps.c
xen/include/asm-x86/processor.h

index 6362fb9c6984493f0efb15f56fc9cf22a19d529f..8caa9255ed40df282e54142f03bb99f23530914b 100644 (file)
@@ -186,6 +186,70 @@ static void show_code(const struct cpu_user_regs *regs)
     printk("\n");
 }
 
+static void compat_show_guest_stack(struct vcpu *v,
+                                    const struct cpu_user_regs *regs,
+                                    int debug_stack_lines)
+{
+    unsigned int i, *stack, addr, mask = STACK_SIZE;
+
+    stack = (unsigned int *)(unsigned long)regs->esp;
+    printk("Guest stack trace from esp=%08lx:\n ", (unsigned long)stack);
+
+    if ( !__compat_access_ok(v->domain, stack, sizeof(*stack)) )
+    {
+        printk("Guest-inaccessible memory.\n");
+        return;
+    }
+
+    if ( v != current )
+    {
+        struct vcpu *vcpu;
+        unsigned long mfn;
+
+        ASSERT(guest_kernel_mode(v, regs));
+        mfn = read_cr3() >> PAGE_SHIFT;
+        for_each_vcpu( v->domain, vcpu )
+            if ( pagetable_get_pfn(vcpu->arch.guest_table) == mfn )
+                break;
+        if ( !vcpu )
+        {
+            stack = do_page_walk(v, (unsigned long)stack);
+            if ( (unsigned long)stack < PAGE_SIZE )
+            {
+                printk("Inaccessible guest memory.\n");
+                return;
+            }
+            mask = PAGE_SIZE;
+        }
+    }
+
+    for ( i = 0; i < debug_stack_lines * 8; i++ )
+    {
+        if ( (((long)stack - 1) ^ ((long)(stack + 1) - 1)) & mask )
+            break;
+        if ( __get_user(addr, stack) )
+        {
+            if ( i != 0 )
+                printk("\n    ");
+            printk("Fault while accessing guest memory.");
+            i = 1;
+            break;
+        }
+        if ( (i != 0) && ((i % 8) == 0) )
+            printk("\n ");
+        printk(" %08x", addr);
+        stack++;
+    }
+    if ( mask == PAGE_SIZE )
+    {
+        BUILD_BUG_ON(PAGE_SIZE == STACK_SIZE);
+        unmap_domain_page(stack);
+    }
+    if ( i == 0 )
+        printk("Stack empty.");
+    printk("\n");
+}
+
 static void show_guest_stack(struct vcpu *v, const struct cpu_user_regs *regs)
 {
     int i;
index b3fcc8c667105e6b3ce3c06bb3f0f2699ead2768..4594a321002b50466f4a67589eeae0ee196accc9 100644 (file)
@@ -3,69 +3,6 @@
 #include <compat/callback.h>
 #include <compat/arch-x86_32.h>
 
-void compat_show_guest_stack(struct vcpu *v, const struct cpu_user_regs *regs,
-                             int debug_stack_lines)
-{
-    unsigned int i, *stack, addr, mask = STACK_SIZE;
-
-    stack = (unsigned int *)(unsigned long)regs->esp;
-    printk("Guest stack trace from esp=%08lx:\n ", (unsigned long)stack);
-
-    if ( !__compat_access_ok(v->domain, stack, sizeof(*stack)) )
-    {
-        printk("Guest-inaccessible memory.\n");
-        return;
-    }
-
-    if ( v != current )
-    {
-        struct vcpu *vcpu;
-        unsigned long mfn;
-
-        ASSERT(guest_kernel_mode(v, regs));
-        mfn = read_cr3() >> PAGE_SHIFT;
-        for_each_vcpu( v->domain, vcpu )
-            if ( pagetable_get_pfn(vcpu->arch.guest_table) == mfn )
-                break;
-        if ( !vcpu )
-        {
-            stack = do_page_walk(v, (unsigned long)stack);
-            if ( (unsigned long)stack < PAGE_SIZE )
-            {
-                printk("Inaccessible guest memory.\n");
-                return;
-            }
-            mask = PAGE_SIZE;
-        }
-    }
-
-    for ( i = 0; i < debug_stack_lines * 8; i++ )
-    {
-        if ( (((long)stack - 1) ^ ((long)(stack + 1) - 1)) & mask )
-            break;
-        if ( __get_user(addr, stack) )
-        {
-            if ( i != 0 )
-                printk("\n    ");
-            printk("Fault while accessing guest memory.");
-            i = 1;
-            break;
-        }
-        if ( (i != 0) && ((i % 8) == 0) )
-            printk("\n ");
-        printk(" %08x", addr);
-        stack++;
-    }
-    if ( mask == PAGE_SIZE )
-    {
-        BUILD_BUG_ON(PAGE_SIZE == STACK_SIZE);
-        unmap_domain_page(stack);
-    }
-    if ( i == 0 )
-        printk("Stack empty.");
-    printk("\n");
-}
-
 static long compat_register_guest_callback(
     struct compat_callback_register *reg)
 {
index 6a335d3a61000a2da62577c453df9eef42e5d510..5bf56b45e111ddcf160d587d165598c7fbcfb0fe 100644 (file)
@@ -480,9 +480,6 @@ void show_execution_state(const struct cpu_user_regs *regs);
 void show_page_walk(unsigned long addr);
 void noreturn fatal_trap(const struct cpu_user_regs *regs, bool_t show_remote);
 
-void compat_show_guest_stack(struct vcpu *v,
-                             const struct cpu_user_regs *regs, int lines);
-
 extern void mtrr_ap_init(void);
 extern void mtrr_bp_init(void);