x86: realmode: fixes
cover x86: realmode: fixes
Some fixes for realmode tests.
Nadav Amit (3):
x86: realmode: initialize idtr
x86: realmode: hlt loop as fallback on exit
x86: realmode: fix lss test
x86/realmode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/3 x86: realmode: initialize idtr
The realmode test does not initialize the IDTR, assuming that its base is zero and its limit 0x3ff. Initialize it, as the BIOS might not set it as such.
--- x86/realmode.c | 2 ++ 1 file changed, 2 insertions(+)
x86/realmode.c +2 -0
@@ -1799,6 +1799,7 @@ void realmode_start(void)unsigned long long r_gdt[] = {0 ,0x9b000000ffff ,0x93000000ffff };struct table_descr r_gdt_descr = {sizeof (r_gdt) -1 , &r_gdt }; +struct table_descr r_idt_descr = {0x3ff ,0 }; asm( ".section .init \n\t"
@@ -1819,6 +1820,7 @@ asm(".text \n\t" "start: \n\t" "lgdt r_gdt_descr \n\t" +"lidt r_idt_descr \n\t" "ljmp $8, $1f; 1: \n\t" ".code16gcc \n\t" "mov $16, %eax \n\t"
Signature · 1 line
2.20.1
Paolo Bonzini
maintainerRe: [kvm-unit-tests PATCH 1/3] x86: realmode: initialize idtr
Quoted 3 lines · Nadav Amit
The realmode test does not initialize the IDTR, assuming that its base is zero and its limit
0x3ff. Initialize it, as the BIOS might not set it as such.
Rather the bootloader: realmode.flat is started as multiboot, that is in a 32-bit protected mode environment---which includes an IDT.
Paolo
Quoted 26 lines
Signed-off-by Nadav Amit <[email protected]>--- x86/realmode.c | 2 ++ 1 file changed, 2 insertions(+)x86/realmode.c +2
-0@@ -1799,6 +1799,7 @@ void realmode_start(void)unsigned long long r_gdt[] = {0 ,0x9b000000ffff ,0x93000000ffff };struct table_descr r_gdt_descr = {sizeof (r_gdt) -1 , &r_gdt }; +struct table_descr r_idt_descr = {0x3ff ,0 }; asm( ".section .init \n\t"@@ -1819,6 +1820,7 @@ asm(".text \n\t" "start: \n\t" "lgdt r_gdt_descr \n\t" +"lidt r_idt_descr \n\t" "ljmp $8, $1f; 1: \n\t" ".code16gcc \n\t" "mov $16, %eax \n\t"
PATCH 2/3 x86: realmode: hlt loop as fallback on exit
In reply to Nadav AmitFor systems without emulated devices (e.g., bare-metal), use halt-loop when exiting the realmode test.
--- x86/realmode.c | 4 ++++ 1 file changed, 4 insertions(+)
x86/realmode.c +4 -0
@@ -115,6 +115,10 @@ static int failed;static void exit (int code) {outb (code,0xf4 ); + +while (1 ) { + asmvolatile ("hlt" :::"memory" ); + } }struct regs {
Signature · 1 line
2.20.1
PATCH 3/3 x86: realmode: fix lss test
In reply to Nadav AmitRunning lss with some random descriptor and then performing pop does not work so well. Use mov instructions instead of push/pop pair.
--- x86/realmode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
x86/realmode.c +2 -2
@@ -1378,10 +1378,10 @@ static void test_lds_lss(void) outregs.eax == (unsigned long )desc.address && outregs.ebx == desc.sel); -MK_INSN (lss,"pushl %ss\n\t" +MK_INSN (lss,"mov %ss, %dx\n\t" "lss (%ebx), %eax\n\t" "mov %ss, %ebx\n\t" -"popl %ss\n\t" ); +"mov %dx, %ss\n\t" );exec_in_big_real_mode (&insn_lss); report("lss", R_AX | R_BX, outregs.eax == (unsigned long)desc.address &&
Signature · 1 line
2.20.1
Quoted 10 lines · Nadav Amit
Some fixes for realmode tests.
Nadav Amit (3):
x86: realmode: initialize idtr
x86: realmode: hlt loop as fallback on exit
x86: realmode: fix lss testx86/realmode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Queued, thanks.
Paolo