[PATCH v3 09/12] x86: Enable SSE in 64-bit mode

Simon Glass sjg at chromium.org
Mon Oct 2 03:14:44 CEST 2023


This is needed to support Truetype fonts. In any case, the compiler
expects SSE to be available in 64-bit mode. Enable it.

Signed-off-by: Simon Glass <sjg at chromium.org>
Suggested-by: Bin Meng <bmeng.cn at gmail.com>
---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 26ec1af2f0b0..b038b132985a 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -27,7 +27,6 @@ ifeq ($(IS_32BIT),y)
 PLATFORM_CPPFLAGS += -march=i386 -m32
 else
 PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -march=core2 -m64
-PLATFORM_CPPFLAGS += -mno-mmx -mno-sse
 endif
 
 PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
index 2647bff891f8..54dc31bf6b71 100644
--- a/arch/x86/cpu/x86_64/cpu.c
+++ b/arch/x86/cpu/x86_64/cpu.c
@@ -10,6 +10,7 @@
 #include <init.h>
 #include <asm/cpu.h>
 #include <asm/global_data.h>
+#include <asm/processor-flags.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -39,11 +40,21 @@ int x86_mp_init(void)
 	return 0;
 }
 
+/* enable SSE features */
+static void setup_cpu_features(void)
+{
+	asm ("mov %%cr4, %%rax\n" \
+	"or  %0, %%rax\n" \
+	"mov %%rax, %%cr4\n" \
+	: : "i" (X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT) : "eax");
+}
+
 int x86_cpu_reinit_f(void)
 {
 	/* set the vendor to Intel so that native_calibrate_tsc() works */
 	gd->arch.x86_vendor = X86_VENDOR_INTEL;
 	gd->arch.has_mtrr = true;
+	setup_cpu_features();
 
 	return 0;
 }
-- 
2.42.0.582.g8ccd20d70d-goog



More information about the U-Boot mailing list