Skip to contentSkip to conversation

Fix pusha tests

PATCH Applied Avi Kivity 2 participants 5 messages Jul 25, 2010 – Jul 27, 2010 KVM

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

cover Fix pusha tests

The pusha tests fail on AMD, which virtualizes real mode correctly. Fix the tests.

Avi Kivity (3):
test: realmode: fix pusha test
test: realmode: initialize all bits of esp
test: realmode: fix pusha test stack

 kvm/test/x86/realmode.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
author
#1 lore raw

PATCH 1/3 test: realmode: fix pusha test

'pop esp' destroys the stack, avoid it

---
 kvm/test/x86/realmode.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
kvm/test/x86/realmode.c +2 -3
index bd79348..d0cc3dc 100644
@@ -828,12 +828,11 @@ void test_pusha_popa()
 		       "pop %edi\n\t"
 		       "pop %esi\n\t"
 		       "pop %ebp\n\t"
-		       "pop %eax\n\t"
+		       "add $4, %esp\n\t"
 		       "pop %ebx\n\t"
 		       "pop %edx\n\t"
 		       "pop %ecx\n\t"
-		       "pop %esp\n\t"
-		       "xchg %esp, %eax\n\t"
+		       "pop %eax\n\t"
 		       );
 
 	MK_INSN(popa, "push %eax\n\t"
Signature · 1 line
1.7.1
author
#2 lore raw

PATCH 2/3 test: realmode: initialize all bits of esp

In reply to Avi Kivity

Initializing just sp can leave the high bits of esp uninitialized.

---
 kvm/test/x86/realmode.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kvm/test/x86/realmode.c +1 -1
index d0cc3dc..c4a2e1e 100644
@@ -936,7 +936,7 @@ asm(
 	"mov %ax, %ss \n\t"
 	"mov %ax, %fs \n\t"
 	"mov %ax, %gs \n\t"
-	"mov $stacktop, %sp\n\t"
+	"mov $stacktop, %esp\n\t"
 	"ljmp $0, $realmode_start \n\t"
 
 	".code16gcc \n\t"
Signature · 1 line
1.7.1
author
#3 lore raw

PATCH 3/3 test: realmode: fix pusha test stack

In reply to Avi Kivity

pusha needs some stack space, or it will fault. The supplied value of 7 is too small.

Provide a real stack for pusha.

---
 kvm/test/x86/realmode.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
kvm/test/x86/realmode.c +6 -1
index c4a2e1e..587f331 100644
@@ -820,9 +820,14 @@ void test_null(void)
 		print_serial("null test: PASS\n");
 }
 
+struct {
+    char stack[500];
+    char top[];
+} tmp_stack;
+
 void test_pusha_popa()
 {
-	struct regs inregs = { .eax = 0, .ebx = 1, .ecx = 2, .edx = 3, .esi = 4, .edi = 5, .ebp = 6, .esp = 7}, outregs;
+	struct regs inregs = { .eax = 0, .ebx = 1, .ecx = 2, .edx = 3, .esi = 4, .edi = 5, .ebp = 6, .esp = (unsigned long)&tmp_stack.top }, outregs;
 
 	MK_INSN(pusha, "pusha\n\t"
 		       "pop %edi\n\t"
Signature · 1 line
1.7.1
#4 lore raw
In reply to Avi Kivity
Quoted 10 lines · Avi Kivity

The pusha tests fail on AMD, which virtualizes real mode correctly. Fix the tests.

Avi Kivity (3):
test: realmode: fix pusha test
test: realmode: initialize all bits of esp
test: realmode: fix pusha test stack

 kvm/test/x86/realmode.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

Applied, thanks.