Skip to contentSkip to conversation

Test 32-bit ljmp emulation

PATCH Superseded Jim Mattson 1 participant 2 messages Nov 28, 2016 – Nov 30, 2016 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Test 32-bit ljmp emulation

em_jmp_far and em_ret_far assumed that setting IP can only fail in 64 bit mode, but syzkaller proved otherwise (and SDM agrees). This test exercises the bug.

---
 lib/x86/desc.h      |   1 +
 lib/x86/processor.h |   5 +++
 x86/cstart64.S      |   1 +
 x86/emulator.c      | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 115 insertions(+)
lib/x86/desc.h +1 -0
index be52fd4..17c7960 100644
@@ -142,6 +142,7 @@ void set_intr_task_gate(int vec, void *fn);
 void setup_tss32(void);
 #else
 extern tss64_t tss;
+extern gdt_entry_t gdt64[];
 #endif
 
 unsigned exception_vector(void);
lib/x86/processor.h +5 -0
index ee7f180..6cb7937 100644
@@ -46,6 +46,11 @@ struct descriptor_table_ptr {
     ulong base;
 } __attribute__((packed));
 
+struct far_pointer32 {
+    u32 offset;
+    u16 selector;
+} __attribute__((packed));
+
 static inline void barrier(void)
 {
     asm volatile ("" : : : "memory");
x86/cstart64.S +1 -0
index e947888..8bb7af3 100644
@@ -7,6 +7,7 @@ boot_idt = 0
 .globl idt_descr
 .globl tss_descr
 .globl gdt64_desc
+.globl gdt64
 
 ipi_vector = 0x20
 
x86/emulator.c +108 -0

132 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH v2 1/1 Test 32-bit ljmp emulation

em_jmp_far and em_ret_far assumed that setting IP can only fail in 64 bit mode, but syzkaller proved otherwise (and SDM agrees). This test exercises the bug.

---
 lib/x86/desc.h      |   1 +
 lib/x86/processor.h |   5 +++
 x86/cstart64.S      |   1 +
 x86/emulator.c      | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 117 insertions(+)
lib/x86/desc.h +1 -0
index be52fd4..17c7960 100644
@@ -142,6 +142,7 @@ void set_intr_task_gate(int vec, void *fn);
 void setup_tss32(void);
 #else
 extern tss64_t tss;
+extern gdt_entry_t gdt64[];
 #endif
 
 unsigned exception_vector(void);
lib/x86/processor.h +5 -0
index ee7f180..6cb7937 100644
@@ -46,6 +46,11 @@ struct descriptor_table_ptr {
     ulong base;
 } __attribute__((packed));
 
+struct far_pointer32 {
+    u32 offset;
+    u16 selector;
+} __attribute__((packed));
+
 static inline void barrier(void)
 {
     asm volatile ("" : : : "memory");
x86/cstart64.S +1 -0
index e947888..8bb7af3 100644
@@ -7,6 +7,7 @@ boot_idt = 0
 .globl idt_descr
 .globl tss_descr
 .globl gdt64_desc
+.globl gdt64
 
 ipi_vector = 0x20
 
x86/emulator.c +110 -0

134 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3.226.g39d4020