From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH kvm-unit-tests 2/4] startup: prepare CPU for floating point operation Date: Mon, 13 Jun 2011 15:28:45 +0300 Message-ID: <1307968127-22440-3-git-send-email-avi@redhat.com> References: <1307968127-22440-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:61870 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752572Ab1FMM2v (ORCPT ); Mon, 13 Jun 2011 08:28:51 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5DCSpAt018449 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Jun 2011 08:28:51 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5DCSoEp002308 for ; Mon, 13 Jun 2011 08:28:50 -0400 In-Reply-To: <1307968127-22440-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: - Clear cr0.ts - Enable cr4.osxsave and cr4.osxmmexcpt (for sse) Signed-off-by: Avi Kivity --- 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