test: Add IDT framework
PATCH v3 1/1 test: Add IDT framework
Signed-off-by Sheng Yang <[email protected]>
Signed-off-by Avi Kivity <[email protected]>
---
v3: rearrange printf()s
v2: accurate instruction boundary tests
avoid playing with the stack; use exception tables instead
kvm/test/config-x86-common.mak | 2 + kvm/test/config-x86_64.mak | 2 +- kvm/test/flat.lds | 7 ++- kvm/test/lib/x86/idt.h | 19 +++++ kvm/test/x86/idt.c | 150 ++++++++++++++++++++++++++++++++++++++++ kvm/test/x86/idt_test.c | 49 +++++++++++++ 6 files changed, 227 insertions(+), 2 deletions(-) create mode 100644 kvm/test/lib/x86/idt.h create mode 100644 kvm/test/x86/idt.c create mode 100644 kvm/test/x86/idt_test.c
kvm/test/config-x86-common.mak +2 -0
@@ -59,6 +59,8 @@ $(TEST_DIR)/realmode.o: bits = 32 $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o +$(TEST_DIR)/idt_test.flat: $(cstart.o) $(TEST_DIR)/idt.o $(TEST_DIR)/idt_test.o + arch_clean: $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \ $(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o
kvm/test/config-x86_64.mak +1 -1
@@ -5,6 +5,6 @@ ldarch = elf64-x86-64 CFLAGS += -D__x86_64__ tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \ - $(TEST_DIR)/emulator.flat + $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat include config-x86-common.mak
kvm/test/flat.lds +6 -1
@@ -4,7 +4,12 @@ SECTIONS stext = .; .text : { *(.init) *(.text) *(.text.*) } . = ALIGN(4K); - .data : { *(.data) } + .data : { + *(.data) + exception_table_start = .; + *(.data.ex) + exception_table_end = .; + } . = ALIGN(16); .rodata : { *(.rodata) } . = ALIGN(16);
kvm/test/lib/x86/idt.h new file +19 -0
@@ -0,0 +1,19 @@ +#ifndef __IDT_TEST__ +#define __IDT_TEST__ + +void setup_idt (void ); + +#define ASM_TRY (catch) \ + "movl $0, %%gs:4 \n\t" \ + ".pushsection .data.ex \n\t" \ + ".quad 1111f, " catch "\n\t" \ + ".popsection \n\t" \ + "1111:" + +#define UD_VECTOR 6 +#define GP_VECTOR 13 + +unsigned exception_vector (void ); +unsigned exception_error_code (void ); + +#endif
kvm/test/x86/idt.c new file +150 -0
150 lines not on this page · raw message
kvm/test/x86/idt_test.c new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
1.7.1
Marcelo Tosatti
AppliedQuoted 8 lines · Avi Kivity
Signed-off-by Sheng Yang <[email protected]>Signed-off-by Avi Kivity <[email protected]>---
v3: rearrange printf()s
v2: accurate instruction boundary tests
avoid playing with the stack; use exception tables instead
Applied, thanks.