void entry_XM(void);
void entry_VE(void);
+hw_tss tss __aligned(16) =
+{
+#if defined(__i386__)
+
+ .esp0 = (unsigned long)&boot_stack[2 * PAGE_SIZE],
+ .ss0 = __KERN_DS,
+
+#elif defined(__x86_64__)
+
+ .rsp0 = (unsigned long)&boot_stack[2 * PAGE_SIZE],
+
+#endif
+
+ .iopb = X86_TSS_INVALID_IO_BITMAP,
+};
+
void pack_gate32(struct seg_gate32 *gate, unsigned type, uint32_t func,
unsigned dpl, unsigned seg)
{
setup_gate(X86_EXC_VE, &entry_VE, 0);
asm volatile ("lidt idt_ptr");
+
+ gdt[GDTE_TSS] = (typeof(*gdt))INIT_GDTE_RAW((unsigned long)&tss, 0x67, 0x89);
+ asm volatile ("ltr %w0" :: "rm" (GDTE_TSS * 8));
}
void __noreturn arch_crash_hard(void)
uint32_t base;
};
+struct __packed hw_tss32 {
+ uint16_t link; uint16_t _r0;
+
+ uint32_t esp0;
+ uint16_t ss0; uint16_t _r1;
+
+ uint32_t esp1;
+ uint16_t ss1; uint16_t _r2;
+
+ uint32_t esp2;
+ uint16_t ss2; uint16_t _r3;
+
+ uint32_t cr3;
+ uint32_t eip;
+ uint32_t eflags;
+ uint32_t eax;
+ uint32_t ecx;
+ uint32_t edx;
+ uint32_t ebx;
+ uint32_t esp;
+ uint32_t ebp;
+ 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;
+};
+
+struct __packed hw_tss64 {
+ uint16_t link; uint16_t _r0;
+
+ uint64_t rsp0;
+ uint64_t rsp1;
+ uint64_t rsp2;
+
+ uint64_t _r1;
+
+ uint64_t ist[7]; /* 1-based structure */
+
+ uint64_t _r2;
+
+ uint16_t t;
+ uint16_t iopb;
+};
+
+#define X86_TSS_INVALID_IO_BITMAP 0x8000
+
#if defined(__x86_64__)
typedef struct desc_ptr64 desc_ptr;
typedef struct seg_desc32 user_desc;
typedef struct seg_gate64 gate_desc;
+typedef struct hw_tss64 hw_tss;
#elif defined(__i386__)
typedef struct desc_ptr32 desc_ptr;
typedef struct seg_desc32 user_desc;
typedef struct seg_gate32 gate_desc;
+typedef struct hw_tss32 hw_tss;
#else
# error Bad architecture for descriptor infrastructure
#if defined(CONFIG_ENV_hvm)
extern gate_desc idt[256];
extern desc_ptr idt_ptr;
+
+extern hw_tss tss;
#endif
#endif /* XTF_X86_DESC_H */