Skip to contentSkip to conversation

test: Add IDT framework

PATCH Applied Avi Kivity 2 participants 2 messages Jun 13, 2010 – Jun 14, 2010 KVM

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH v3 1/1 test: Add IDT framework

---

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
index c97de52..800b635 100644
@@ -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
index d8fd2b5..f9cd121 100644
@@ -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
index 4120595..4888f3a 100644
@@ -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
new file mode 100644
index 0000000..6babcb4
@@ -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