This was broken because it needed the 32-bit and 16-bit selectors. Add them back to cstart64.S, and change svm.c to use symbolic names. Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> --- lib/x86/desc.h | 15 +++++++++++++-- x86/cstart64.S | 10 +++++----- x86/svm.c | 15 +++++++++------ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/lib/x86/desc.h b/lib/x86/desc.h index 913ede6..553bce9 100644 --- a/lib/x86/desc.h +++ b/lib/x86/desc.h @@ -88,8 +88,19 @@ typedef struct __attribute__((packed)) { #define NP_SEL 0x18 #define USER_CS 0x23 #define USER_DS 0x2b -#define TSS_INTR 0x30 -#define FIRST_SPARE_SEL 0x38 +#ifdef __x86_64__ +#define KERNEL_CS64 KERNEL_CS +#define KERNEL_DS64 KERNEL_DS +#define KERNEL_CS32 0x30 +#define KERNEL_DS32 0x38 +#define KERNEL_CS16 0x40 +#define KERNEL_DS16 0x48 +#else +#define KERNEL_CS32 KERNEL_CS +#define KERNEL_DS32 KERNEL_DS +#endif +#define TSS_INTR 0x50 +#define FIRST_SPARE_SEL 0x58 #define TSS_MAIN 0x80 typedef struct { diff --git a/x86/cstart64.S b/x86/cstart64.S index 30f7eb5..8d0d95d 100644 --- a/x86/cstart64.S +++ b/x86/cstart64.S @@ -57,12 +57,12 @@ gdt64: .quad 0x00af1b000000ffff // 64-bit code segment, not present .quad 0x00affb000000ffff // 64-bit code segment (user) .quad 0x00cff3000000ffff // 64-bit data segment (user) + .quad 0x00cf9b000000ffff // 32-bit code segment + .quad 0x00cf92000000ffff // 32-bit data segment + .quad 0x008F9A000000FFFF // 16-bit code segment + .quad 0x008F92000000FFFF // 16-bit data segment - .quad 0 // 10 spare selectors - .quad 0 - .quad 0 - .quad 0 - .quad 0 + .quad 0 // 6 spare selectors .quad 0 .quad 0 .quad 0 diff --git a/x86/svm.c b/x86/svm.c index 5cfd77d..3e45426 100644 --- a/x86/svm.c +++ b/x86/svm.c @@ -1,6 +1,7 @@ #include "svm.h" #include "libcflat.h" #include "processor.h" +#include "desc.h" #include "msr.h" #include "vm.h" #include "smp.h" @@ -356,7 +357,7 @@ static void test_mode_switch(struct test *test) " ljmp *1f\n" /* jump to 32-bit code segment */ "1:\n" " .long 2f\n" - " .long 40\n" + " .long " xstr(KERNEL_CS32) "\n" ".code32\n" "2:\n" " movl %%cr0, %%eax\n" @@ -369,9 +370,9 @@ static void test_mode_switch(struct test *test) " movl %%cr4, %%eax\n" " btcl $5, %%eax\n" /* clear PAE */ " movl %%eax, %%cr4\n" - " movw $64, %%ax\n" + " movw %[ds16], %%ax\n" " movw %%ax, %%ds\n" - " ljmpl $56, $3f\n" /* jump to 16 bit protected-mode */ + " ljmpl %[cs16], $3f\n" /* jump to 16 bit protected-mode */ ".code16\n" "3:\n" " movl %%cr0, %%eax\n" @@ -383,7 +384,7 @@ static void test_mode_switch(struct test *test) " movl %%cr0, %%eax\n" " btsl $0, %%eax\n" /* set PE */ " movl %%eax, %%cr0\n" - " ljmpl $40, $5f\n" /* back to protected mode */ + " ljmpl %[cs32], $5f\n" /* back to protected mode */ ".code32\n" "5:\n" " movl %%cr4, %%eax\n" @@ -396,11 +397,13 @@ static void test_mode_switch(struct test *test) " movl %%cr0, %%eax\n" " btsl $31, %%eax\n" /* set PG */ " movl %%eax, %%cr0\n" - " ljmpl $8, $6f\n" /* back to long mode */ + " ljmpl %[cs64], $6f\n" /* back to long mode */ ".code64\n\t" "6:\n" " vmmcall\n" - ::: "rax", "rbx", "rcx", "rdx", "memory"); + :: [cs16] "i"(KERNEL_CS16), [ds16] "i"(KERNEL_DS16), + [cs32] "i"(KERNEL_CS32), [cs64] "i"(KERNEL_CS64) + : "rax", "rbx", "rcx", "rdx", "memory"); } static bool mode_switch_finished(struct test *test) -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html