]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Improvements to, and new TSS infrastructure
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 2 Jun 2017 12:33:58 +0000 (13:33 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Jun 2017 10:47:39 +0000 (11:47 +0100)
 * Rename hw_tss to env_tss, to highlight that it is the TSS appropriate for
   the current environment
 * Rename hw_tss{32,64} to x86_tss{32,64} to highlight that it is a structure
   specified by x86
 * Replace reserved fields with empty bitfields
 * Remove erroneous link field from x86_tss64
 * Introduce dump_x86_tss{32,64}() to neatly format a TSS.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/hvm/traps.c
arch/x86/include/arch/desc.h
arch/x86/include/arch/x86-tss.h
arch/x86/x86-tss.c [new file with mode: 0644]
build/files.mk
tests/xsa-192/main.c

index 076d207f1e843afc5b12bce2a694d1ab8ba585bf..17ca66e24ddc110bfacd0d76e8657b65351c3939 100644 (file)
@@ -29,7 +29,7 @@ void entry_XM(void);
 void entry_VE(void);
 void entry_ret_to_kernel(void);
 
-hw_tss tss __aligned(16) =
+env_tss tss __aligned(16) =
 {
 #if defined(__i386__)
 
@@ -47,7 +47,7 @@ hw_tss tss __aligned(16) =
 };
 
 #if defined(__i386__)
-static hw_tss tss_DF __aligned(16) =
+static env_tss tss_DF __aligned(16) =
 {
     .esp  = _u(&boot_stack[3 * PAGE_SIZE]),
     .ss   = __KERN_DS,
index 7908db609f3aed5d2e5a768800c493abeaacbbfe..bea79114c4219cf6d8d53c6ff7c8e26658dfc41f 100644 (file)
@@ -169,7 +169,7 @@ extern desc_ptr  gdt_ptr;
 extern gate_desc idt[256];
 extern desc_ptr  idt_ptr;
 
-extern hw_tss tss;
+extern env_tss tss;
 #endif
 
 #endif /* XTF_X86_DESC_H */
index a95d94841a5f7a4b5a79990f80dc03d09994edf6..4e13f00c7ebaa3da4ca207409deb7e64693eb892 100644 (file)
 #include <xtf/types.h>
 #include <xtf/compiler.h>
 
-struct __packed hw_tss32 {
-    uint16_t link; uint16_t _r0;
+struct __packed x86_tss32 {
+    uint16_t link; uint16_t :16;
 
     uint32_t esp0;
-    uint16_t ss0; uint16_t _r1;
+    uint16_t ss0; uint16_t :16;
 
     uint32_t esp1;
-    uint16_t ss1; uint16_t _r2;
+    uint16_t ss1; uint16_t :16;
 
     uint32_t esp2;
-    uint16_t ss2; uint16_t _r3;
+    uint16_t ss2; uint16_t :16;
 
     uint32_t cr3;
     uint32_t eip;
@@ -34,42 +34,57 @@ struct __packed hw_tss32 {
     uint32_t esi;
     uint32_t edi;
 
-    uint16_t es; uint16_t _r4;
-    uint16_t cs; uint16_t _r5;
-    uint16_t ss; uint16_t _r6;
-    uint16_t ds; uint16_t _r7;
-    uint16_t fs; uint16_t _r8;
-    uint16_t gs; uint16_t _r9;
-    uint16_t ldtr; uint16_t _r10;
-    uint16_t t; uint16_t iopb;
+    uint16_t es; uint16_t :16;
+    uint16_t cs; uint16_t :16;
+    uint16_t ss; uint16_t :16;
+    uint16_t ds; uint16_t :16;
+    uint16_t fs; uint16_t :16;
+    uint16_t gs; uint16_t :16;
+    uint16_t ldtr; uint16_t :16;
+
+    uint16_t trace:1, :15;
+    uint16_t iopb;
 };
 
-struct __packed hw_tss64 {
-    uint16_t link; uint16_t _r0;
+struct __packed x86_tss64 {
+    uint32_t :32;
 
     uint64_t rsp0;
     uint64_t rsp1;
     uint64_t rsp2;
 
-    uint64_t _r1;
+    uint64_t :64;
 
     uint64_t ist[7]; /* 1-based structure */
 
-    uint64_t _r2;
+    uint64_t :64;
 
-    uint16_t t;
+    uint16_t trace:1, :15;
     uint16_t iopb;
 };
 
 #define X86_TSS_INVALID_IO_BITMAP 0x8000
 
+void dump_x86_tss32(const struct x86_tss32 *t);
+void dump_x86_tss64(const struct x86_tss64 *t);
+
 #if defined(__x86_64__)
 
-typedef struct hw_tss64 hw_tss;
+typedef struct x86_tss64 env_tss;
+
+static inline void dump_env_tss(const env_tss *t)
+{
+    dump_x86_tss64(t);
+}
 
 #elif defined(__i386__)
 
-typedef struct hw_tss32 hw_tss;
+typedef struct x86_tss32 env_tss;
+
+static inline void dump_env_tss(const env_tss *t)
+{
+    dump_x86_tss32(t);
+}
 
 #else
 # error Bad architecture for TSS infrastructure
diff --git a/arch/x86/x86-tss.c b/arch/x86/x86-tss.c
new file mode 100644 (file)
index 0000000..5dd2487
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * @file arch/x86/x86-tss.c
+ *
+ * %x86 Task State Segment helper routines.
+ */
+#include <xtf/console.h>
+
+#include <arch/x86-tss.h>
+
+void dump_x86_tss32(const struct x86_tss32 *t)
+{
+    printk("Dump x86_tss32 at %p {\n"
+           "  link %04x\n"
+           "  r0 %04x:%08x\n"
+           "  r1 %04x:%08x\n"
+           "  r2 %04x:%08x\n"
+           "  cr3 %08x\n"
+           "  eip %08x, eflags %08x\n"
+           "  eax %08x, ecx %08x\n"
+           "  edx %08x, ebx %08x\n"
+           "  esp %08x, ebp %08x\n"
+           "  esi %08x, edi %08x\n"
+           "  es %04x, cs %04x, ss %04x\n"
+           "  ds %04x, fs %04x, gs %04x\n"
+           "  ldtr %04x, trace %u, iobp %04x\n"
+           "}\n",
+           t,
+           t->link,
+           t->ss0, t->esp0,
+           t->ss1, t->esp1,
+           t->ss2, t->esp2,
+           t->cr3,
+           t->eip, t->eflags,
+           t->eax, t->ecx,
+           t->edx, t->ebx,
+           t->esp, t->ebp,
+           t->esi, t->edi,
+           t->es, t->cs, t->ss,
+           t->ds, t->fs, t->gs,
+           t->ldtr, t->trace, t->iopb);
+}
+
+void dump_x86_tss64(const struct x86_tss64 *t)
+{
+    printk("Dump x86_tss64 at %p {\n"
+           "  rsp0 %016"PRIx64", rsp1 %016"PRIx64"\n"
+           "  rsp2 %016"PRIx64", ist1 %016"PRIx64"\n"
+           "  ist2 %016"PRIx64", ist3 %016"PRIx64"\n"
+           "  ist4 %016"PRIx64", ist5 %016"PRIx64"\n"
+           "  ist6 %016"PRIx64", ist7 %016"PRIx64"\n"
+           "  trace %u, iobp %04x\n"
+           "}\n",
+           t,
+           t->rsp0, t->rsp1,
+           t->rsp2, t->ist[0],
+           t->ist[1], t->ist[2],
+           t->ist[3], t->ist[4],
+           t->ist[5], t->ist[6],
+           t->trace, t->iopb);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index a179f27b67ec84d5e3bda10da4ede1e562d2b35e..8ffd6e7d709709514042abe0c14ee61368580b25 100644 (file)
@@ -26,6 +26,10 @@ obj-perenv += $(ROOT)/arch/x86/traps.o
 # HVM specific objects
 obj-hvm += $(ROOT)/arch/x86/hvm/pagetables.o
 obj-hvm += $(ROOT)/arch/x86/hvm/traps.o
+
+# Arguably common objects, but PV guests will have no interest in them.
+obj-hvm += $(ROOT)/arch/x86/x86-tss.o
+
 $(foreach env,$(HVM_ENVIRONMENTS),$(eval obj-$(env) += $(obj-hvm)))
 
 
index 7e5b10b7f94a218595f84d5d3a5a91ad37869052..28c208bb2aefaad2ca2304b757ee447b4a631d95 100644 (file)
@@ -41,7 +41,7 @@ asm(".align 16;"
     );
 
 /* Virtual 8068 task. */
-hw_tss vm86_tss __aligned(16) =
+env_tss vm86_tss __aligned(16) =
 {
     .eflags = X86_EFLAGS_VM | X86_EFLAGS_IOPL | X86_EFLAGS_MBS,
     .eip    = 0x1000,