]> xenbits.xensource.com Git - xtf.git/commitdiff
IDT Vector allocation and infrastructure
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 15 Jul 2016 15:31:58 +0000 (15:31 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 12 Aug 2016 12:19:04 +0000 (13:19 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/entry_32.S
arch/x86/entry_64.S
arch/x86/hvm/traps.c
arch/x86/pv/traps.c
include/arch/x86/idt.h [new file with mode: 0644]

index 1ffedb7e624a48f9420e51f2defb6d54354cb641..ee3c6b01a675845e043e605caaa1f890e6042126 100644 (file)
@@ -1,3 +1,4 @@
+#include <arch/x86/idt.h>
 #include <arch/x86/processor.h>
 #include <arch/x86/segment.h>
 #include <xtf/asm_macros.h>
@@ -86,7 +87,7 @@ handle_exception:
 ENDFUNC(handle_exception)
 
 
-ENTRY(entry_ret_to_kernel)      /* int $0x20 (return to kernel) */
+ENTRY(entry_ret_to_kernel)      /* int $X86_VEC_RET2KERN */
 
         /* User required to ensure this is called from CPL > KERNEL_RPL */
 
@@ -114,7 +115,7 @@ ENTRY(exec_user)                /* void (*fn)(void) */
 1:
         call *4(%esp)           /* fn() */
 
-        int $0x20               /* Return to kernel privilege. */
+        int $X86_VEC_RET2KERN   /* Return to kernel privilege. */
         ret
 
 ENDFUNC(exec_user)
index 1154d9ce500a00f8485e2f472ecc29d081715eab..01b0156f4bb29b7accf91b7d4fd4b79b86b3741c 100644 (file)
@@ -1,3 +1,4 @@
+#include <arch/x86/idt.h>
 #include <arch/x86/processor.h>
 #include <arch/x86/segment.h>
 #include <xtf/asm_macros.h>
@@ -100,7 +101,7 @@ handle_exception:
 ENDFUNC(handle_exception)
 
 
-ENTRY(entry_ret_to_kernel)      /* int $0x20 (return to kernel) */
+ENTRY(entry_ret_to_kernel)      /* int $X86_VEC_RET2KERN */
         env_ADJUST_FRAME
 
         mov 0*8(%rsp), %rax     /* Stash %rip from iret frame */
@@ -127,7 +128,7 @@ ENTRY(exec_user)                /* void (*fn)(void) */
 1:
         call *%rdi              /* fn() */
 
-        int $0x20               /* Return to kernel privilege. */
+        int $X86_VEC_RET2KERN   /* Return to kernel privilege. */
         ret
 
 ENDFUNC(exec_user)
index 6d3673684bb91e108e885033d254bf0c48fb0bb0..f1f78c75df5ccbba6f91da985fbea0802171f433 100644 (file)
@@ -1,6 +1,7 @@
 #include <xtf/traps.h>
 #include <xtf/lib.h>
 
+#include <arch/x86/idt.h>
 #include <arch/x86/lib.h>
 #include <arch/x86/processor.h>
 #include <arch/x86/desc.h>
@@ -103,7 +104,7 @@ void arch_init_traps(void)
     setup_gate(X86_EXC_XM,  &entry_XM,  0);
     setup_gate(X86_EXC_VE,  &entry_VE,  0);
 
-    setup_gate(0x20, &entry_ret_to_kernel, 3);
+    setup_gate(X86_VEC_RET2KERN, &entry_ret_to_kernel, 3);
 
     asm volatile ("lidt idt_ptr");
 
index 5b50eed9f1a912367bc9a87d62dfe6fa6f3aeec8..6c2405cfe32d556bec317bf5cd36ca3f802f5d83 100644 (file)
@@ -3,6 +3,7 @@
 #include <xtf/hypercall.h>
 #include <xtf/test.h>
 
+#include <arch/x86/idt.h>
 #include <arch/x86/lib.h>
 #include <arch/x86/processor.h>
 #include <arch/x86/segment.h>
@@ -53,7 +54,7 @@ struct xen_trap_info pv_default_trap_info[] =
     { X86_EXC_XM,  0|4, __KERN_CS, (unsigned long)&entry_XM  },
     { X86_EXC_VE,  0|4, __KERN_CS, (unsigned long)&entry_VE  },
 
-    { 0x20, 3|4, __KERN_CS, (unsigned long)&entry_ret_to_kernel },
+    { X86_VEC_RET2KERN, 3|4, __KERN_CS, (unsigned long)&entry_ret_to_kernel },
 
     { 0, 0, 0, 0 }, /* Sentinel. */
 };
diff --git a/include/arch/x86/idt.h b/include/arch/x86/idt.h
new file mode 100644 (file)
index 0000000..5c7399d
--- /dev/null
@@ -0,0 +1,27 @@
+/**
+ * @file include/arch/x86/idt.h
+ *
+ * %x86 IDT vector infrastructure.
+ */
+
+#ifndef XTF_X86_IDT_H
+#define XTF_X86_IDT_H
+
+/**
+ * Return to kernel mode.
+ *
+ * To enable easy transition between user and kernel mode for tests.
+ */
+#define X86_VEC_RET2KERN 0x20
+
+#endif /* XTF_X86_IDT_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */