aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNadav Amit <namit@vmware.com>2020-06-23 01:41:32 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2020-06-24 02:47:10 -0400
commitd68a795a213ddcd224a80fb9e5015b57582bc625 (patch)
treecf068c6dd6752b041efbd221578aa8b926b0e905
parent1b9d2ef25d1758d3f1a12da0e43517e8e5e2ac78 (diff)
downloadkvm-unit-tests-d68a795a213ddcd224a80fb9e5015b57582bc625.tar.gz
x86: Initialize segment selectors
Currently, the BSP's segment selectors are not initialized in 32-bit (cstart.S). As a result the tests implicitly rely on the segment selector values that are set by the BIOS. If this assumption is not kept, the task-switch test fails. Fix it by initializing them. Signed-off-by: Nadav Amit <namit@vmware.com> Message-Id: <20200623084132.36213-1-namit@vmware.com> Reviewed-by: Jim Mattson <jmattson@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--x86/cstart.S17
1 files changed, 11 insertions, 6 deletions
diff --git a/x86/cstart.S b/x86/cstart.S
index fa62e09..5ad70b5 100644
--- a/x86/cstart.S
+++ b/x86/cstart.S
@@ -94,6 +94,15 @@ MSR_GS_BASE = 0xc0000101
wrmsr
.endm
+.macro setup_segments
+ mov $0x10, %ax
+ mov %ax, %ds
+ mov %ax, %es
+ mov %ax, %fs
+ mov %ax, %gs
+ mov %ax, %ss
+.endm
+
.globl start
start:
mov $stacktop, %esp
@@ -109,6 +118,7 @@ start:
prepare_32:
lgdtl gdt32_descr
+ setup_segments
mov %cr4, %eax
bts $4, %eax // pse
@@ -133,12 +143,7 @@ save_id:
retl
ap_start32:
- mov $0x10, %ax
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %fs
- mov %ax, %gs
- mov %ax, %ss
+ setup_segments
mov $-4096, %esp
lock/xaddl %esp, smp_stacktop
setup_percpu_area