From: Andrew Cooper Date: Fri, 15 Jul 2016 15:31:58 +0000 (+0000) Subject: IDT Vector allocation and infrastructure X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=4ca41a26a3fdf183ca8ccf801d60671074b39cb3;p=people%2Fandrewcoop%2Fxen-test-framework.git IDT Vector allocation and infrastructure Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/entry_32.S b/arch/x86/entry_32.S index 1ffedb7..ee3c6b0 100644 --- a/arch/x86/entry_32.S +++ b/arch/x86/entry_32.S @@ -1,3 +1,4 @@ +#include #include #include #include @@ -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) diff --git a/arch/x86/entry_64.S b/arch/x86/entry_64.S index 1154d9c..01b0156 100644 --- a/arch/x86/entry_64.S +++ b/arch/x86/entry_64.S @@ -1,3 +1,4 @@ +#include #include #include #include @@ -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) diff --git a/arch/x86/hvm/traps.c b/arch/x86/hvm/traps.c index 6d36736..f1f78c7 100644 --- a/arch/x86/hvm/traps.c +++ b/arch/x86/hvm/traps.c @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -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"); diff --git a/arch/x86/pv/traps.c b/arch/x86/pv/traps.c index 5b50eed..6c2405c 100644 --- a/arch/x86/pv/traps.c +++ b/arch/x86/pv/traps.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -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 index 0000000..5c7399d --- /dev/null +++ b/include/arch/x86/idt.h @@ -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: + */