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

Signed-off-by: Avi Kivity <a...@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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to