public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: [PATCH kvm-unit-tests 2/4] startup: prepare CPU for floating point operation
Date: Mon, 13 Jun 2011 15:28:45 +0300	[thread overview]
Message-ID: <1307968127-22440-3-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1307968127-22440-1-git-send-email-avi@redhat.com>

- Clear cr0.ts
- Enable cr4.osxsave and cr4.osxmmexcpt (for sse)

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 lib/x86/smp.c  |    9 +++++++++
 x86/cstart.S   |    2 ++
 x86/cstart64.S |    2 ++
 3 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lib/x86/smp.c b/lib/x86/smp.c
index d41c332..5e91f1a 100644
--- a/lib/x86/smp.c
+++ b/lib/x86/smp.c
@@ -3,6 +3,7 @@
 #include "smp.h"
 #include "apic.h"
 #include "fwcfg.h"
+#include "processor.h"
 
 #define IPI_VECTOR 0x20
 
@@ -124,6 +125,14 @@ void on_cpu_async(int cpu, void (*function)(void *data), void *data)
     __on_cpu(cpu, function, data, 0);
 }
 
+void __setup_cpu(void *data)
+{
+    write_cr4(read_cr4()
+	      | 0x200 /* OSFXSR; for SSE */
+	      | 0x400 /* OSXMMEXCPT, ditto */
+	      );
+    asm volatile ("clts");
+}
 
 void smp_init(void)
 {
diff --git a/x86/cstart.S b/x86/cstart.S
index bc8d563..36ad01f 100644
--- a/x86/cstart.S
+++ b/x86/cstart.S
@@ -121,6 +121,7 @@ ap_start32:
 	sti
 	nop
 	lock incw cpu_online_count
+	call __setup_cpu
 
 1:	hlt
 	jmp 1b
@@ -172,6 +173,7 @@ smp_init:
 1:	pause
 	cmpw %ax, cpu_online_count
 	jne 1b
+	call __setup_cpu
 smp_init_done:
 	ret
 
diff --git a/x86/cstart64.S b/x86/cstart64.S
index 71014d8..7d88dc5 100644
--- a/x86/cstart64.S
+++ b/x86/cstart64.S
@@ -170,6 +170,7 @@ ap_start64:
 	call load_tss
 	call enable_apic
 	call enable_x2apic
+	call __setup_cpu
 	sti
 	nop
 	lock incw cpu_online_count
@@ -234,6 +235,7 @@ smp_init:
 1:	pause
 	cmpw %ax, cpu_online_count
 	jne 1b
+	call __setup_cpu
 smp_init_done:
 	ret
 
-- 
1.7.5.3


  parent reply	other threads:[~2011-06-13 12:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 12:28 [PATCH kvm-unit-tests 0/4] PMU tests Avi Kivity
2011-06-13 12:28 ` [PATCH kvm-unit-tests 1/4] Build tests with optimization enabled Avi Kivity
2011-06-13 12:28 ` Avi Kivity [this message]
2011-06-13 12:28 ` [PATCH kvm-unit-tests 3/4] Add rdpmc instruction accessor Avi Kivity
2011-06-13 12:28 ` [PATCH kvm-unit-tests 4/4] Add PMU test Avi Kivity

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=1307968127-22440-3-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@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