
Hi Bin,
U-Boot 64-bit on x86 disables sse, but when enabling Truetype I get a compiler error:
drivers/video/console_truetype.c: In function 'frac': drivers/video/console_truetype.c:30:15: error: SSE register return with SSE disabled 30 | static double frac(double val)
Do you know how to enable SSE for 64-bit?
Regards, Simon

On 9/28/23 04:41, Simon Glass wrote:
Hi Bin,
U-Boot 64-bit on x86 disables sse, but when enabling Truetype I get a compiler error:
drivers/video/console_truetype.c: In function 'frac': drivers/video/console_truetype.c:30:15: error: SSE register return with SSE disabled 30 | static double frac(double val)
Do you know how to enable SSE for 64-bit?
How could this occur if x86 disables SSE? There must be some inconsistency in how this module is built.
We a need a clarification of the used ABI per architecture and write this into our documentation.
The RISC-V profile specification does not foresee float and double in S-mode (see RVA20S64 and RVAS22S64 profiles in https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc#52-rva20s64-...).
We should convert drivers/video/console_truetype.c to use integers (where low bits are used for the fractional part) instead of float and double to make the driver compatible to non-x86 platforms.
Best regards
Heinrich

Hi Heinrich,
On Thu, 28 Sept 2023 at 00:26, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
On 9/28/23 04:41, Simon Glass wrote:
Hi Bin,
U-Boot 64-bit on x86 disables sse, but when enabling Truetype I get a compiler error:
drivers/video/console_truetype.c: In function 'frac': drivers/video/console_truetype.c:30:15: error: SSE register return with SSE disabled 30 | static double frac(double val)
Do you know how to enable SSE for 64-bit?
How could this occur if x86 disables SSE? There must be some inconsistency in how this module is built.
We disable SSE on 64-bit x86, even though the CPU always supports it. The compiler assumes it is available, so presumably emits SSE things.
I suspect there is some CPU init missing after U-Boot changes to 64-bit long mode.
We a need a clarification of the used ABI per architecture and write this into our documentation.
The RISC-V profile specification does not foresee float and double in S-mode (see RVA20S64 and RVAS22S64 profiles in https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc#52-rva20s64-...).
We should convert drivers/video/console_truetype.c to use integers (where low bits are used for the fractional part) instead of float and double to make the driver compatible to non-x86 platforms.
Good luck with that :-) It uses STB for Truetype...probably there is an integer implementation somewhere but I'm not sure.
Regards, Simon

Hi Simon,
On Thu, Sep 28, 2023 at 10:41 AM Simon Glass sjg@chromium.org wrote:
Hi Bin,
U-Boot 64-bit on x86 disables sse, but when enabling Truetype I get a compiler error:
drivers/video/console_truetype.c: In function 'frac': drivers/video/console_truetype.c:30:15: error: SSE register return with SSE disabled 30 | static double frac(double val)
Do you know how to enable SSE for 64-bit?
The following patch could enable SSE for 64-bit:
diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 26ec1af2f0..250d7c9948 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -27,7 +27,7 @@ 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 +PLATFORM_CPPFLAGS += -mno-mmx endif
However as Heinrich mentioned, U-Boot codes should be written in a "floating point free" way.
The fix should really be updating console_truetype.c to use integers instead of using float/double.
Regards, Bin

Hi Bin,
On Thu, 28 Sept 2023 at 08:15, Bin Meng bmeng.cn@gmail.com wrote:
Hi Simon,
On Thu, Sep 28, 2023 at 10:41 AM Simon Glass sjg@chromium.org wrote:
Hi Bin,
U-Boot 64-bit on x86 disables sse, but when enabling Truetype I get a compiler error:
drivers/video/console_truetype.c: In function 'frac': drivers/video/console_truetype.c:30:15: error: SSE register return with SSE disabled 30 | static double frac(double val)
Do you know how to enable SSE for 64-bit?
The following patch could enable SSE for 64-bit:
diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 26ec1af2f0..250d7c9948 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -27,7 +27,7 @@ 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 +PLATFORM_CPPFLAGS += -mno-mmx endif
However as Heinrich mentioned, U-Boot codes should be written in a "floating point free" way.
The fix should really be updating console_truetype.c to use integers instead of using float/double.
Yes, I can do that, but it hangs going into 64-bit mode, which is presumably why the flag was added. In fact it was your commit!
Is there some missing init somewhere?
Regards, Simon

Hi Simon,
On Thu, Sep 28, 2023 at 10:20 PM Simon Glass sjg@chromium.org wrote:
Hi Bin,
On Thu, 28 Sept 2023 at 08:15, Bin Meng bmeng.cn@gmail.com wrote:
Hi Simon,
On Thu, Sep 28, 2023 at 10:41 AM Simon Glass sjg@chromium.org wrote:
Hi Bin,
U-Boot 64-bit on x86 disables sse, but when enabling Truetype I get a compiler error:
drivers/video/console_truetype.c: In function 'frac': drivers/video/console_truetype.c:30:15: error: SSE register return with SSE disabled 30 | static double frac(double val)
Do you know how to enable SSE for 64-bit?
The following patch could enable SSE for 64-bit:
diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 26ec1af2f0..250d7c9948 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -27,7 +27,7 @@ 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 +PLATFORM_CPPFLAGS += -mno-mmx endif
However as Heinrich mentioned, U-Boot codes should be written in a "floating point free" way.
The fix should really be updating console_truetype.c to use integers instead of using float/double.
Yes, I can do that, but it hangs going into 64-bit mode, which is presumably why the flag was added. In fact it was your commit!
Yeah, indeed it was commit dd4611dea435 ("x86: Ensure no instruction sets of MMX/SSE are generated in 64-bit build") and the commit message said the reason.
Is there some missing init somewhere?
I believe we should turn on X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT on CR4 to enable SSE.
Regards, Bin

Hi Bin,
On Thu, 28 Sept 2023 at 08:41, Bin Meng bmeng.cn@gmail.com wrote:
Hi Simon,
On Thu, Sep 28, 2023 at 10:20 PM Simon Glass sjg@chromium.org wrote:
Hi Bin,
On Thu, 28 Sept 2023 at 08:15, Bin Meng bmeng.cn@gmail.com wrote:
Hi Simon,
On Thu, Sep 28, 2023 at 10:41 AM Simon Glass sjg@chromium.org wrote:
Hi Bin,
U-Boot 64-bit on x86 disables sse, but when enabling Truetype I get a compiler error:
drivers/video/console_truetype.c: In function 'frac': drivers/video/console_truetype.c:30:15: error: SSE register return with SSE disabled 30 | static double frac(double val)
Do you know how to enable SSE for 64-bit?
The following patch could enable SSE for 64-bit:
diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 26ec1af2f0..250d7c9948 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -27,7 +27,7 @@ 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 +PLATFORM_CPPFLAGS += -mno-mmx endif
However as Heinrich mentioned, U-Boot codes should be written in a "floating point free" way.
The fix should really be updating console_truetype.c to use integers instead of using float/double.
Yes, I can do that, but it hangs going into 64-bit mode, which is presumably why the flag was added. In fact it was your commit!
Yeah, indeed it was commit dd4611dea435 ("x86: Ensure no instruction sets of MMX/SSE are generated in 64-bit build") and the commit message said the reason.
Is there some missing init somewhere?
I believe we should turn on X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT on CR4 to enable SSE.
OK thank you, that worked. I will send a few patches.
Regards, Simon
participants (3)
-
Bin Meng
-
Heinrich Schuchardt
-
Simon Glass