public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Nadav Amit <namit@vmware.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: <kvm@vger.kernel.org>, Nadav Amit <namit@vmware.com>
Subject: [kvm-unit-tests PATCH] x86: Initialize segment selectors
Date: Tue, 23 Jun 2020 01:41:32 -0700	[thread overview]
Message-ID: <20200623084132.36213-1-namit@vmware.com> (raw)

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>
---
 x86/cstart.S | 17 +++++++++++------
 1 file 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
-- 
2.20.1


             reply	other threads:[~2020-06-23  8:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  8:41 Nadav Amit [this message]
2020-06-23 18:28 ` [kvm-unit-tests PATCH] x86: Initialize segment selectors Jim Mattson
2020-06-24  6:42 ` Paolo Bonzini
2020-06-24 12:52 ` Thomas Huth
2020-06-24 14:10   ` Paolo Bonzini
2020-06-24 17:28     ` Nadav Amit
2020-06-25  7:53       ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200623084132.36213-1-namit@vmware.com \
    --to=namit@vmware.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox