Bug 454346

Summary: [PATCH] ARM fixes from the Yocto project
Product: [Developer tools] valgrind Reporter: Alexander Kanavin <alex.kanavin>
Component: generalAssignee: Paul Floyd <pjfloyd>
Status: REPORTED ---    
Severity: normal CC: pjfloyd, raj.khem, rwmacleod, sam
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=456200
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: use appropriate -march/-mcpu/-mfpu for ARM test apps
avoid neon for targets which don't support it
makefiles: Drop setting -mcpu to cortex-a8 on arm architecture
proposed fix.
potential fix 2

Description Alexander Kanavin 2022-05-24 17:14:00 UTC
Created attachment 149172 [details]
use appropriate -march/-mcpu/-mfpu for ARM test apps

Yocto has been carrying these patches for a while; please evaluate whether they're still appropriate.
Comment 1 Alexander Kanavin 2022-05-24 17:14:26 UTC
Created attachment 149173 [details]
avoid neon for targets which don't support it
Comment 2 Alexander Kanavin 2022-05-24 17:14:51 UTC
Created attachment 149174 [details]
makefiles: Drop setting -mcpu to cortex-a8 on arm  architecture
Comment 3 Paul Floyd 2024-02-08 09:33:15 UTC
Are the yocto patches specific to any hardware?

I think that part of the problem is that the current options are too specific. I'm afraid that these patches will just make it specific for something else.
Comment 4 Paul Floyd 2024-02-08 09:35:13 UTC
(And I have made some changes recently - have the patches been rebased?)
Comment 5 Alexander Kanavin 2024-02-08 09:46:21 UTC
The patches weren't written by me, so it's difficult to answer about their specifics. I only wanted to check if the fixes are obvious and suitable, and it's fine if they're not. 

We run the tests in qemu arm64 virtual machine. I added Khem at least if he would like to comment (he knows more about the area).

We're now in the process of updating to latest valgrind release, so when that's done, I can review again what if anything needs to be rebased to valgrind trunk and re-submitted, with more detailed explanations/logs of the errors we get if the respective patch is not applied.
Comment 6 Khem Raj 2024-05-13 17:31:44 UTC
Created attachment 169451 [details]
proposed fix.
Comment 7 Khem Raj 2024-05-13 17:45:55 UTC
Created attachment 169452 [details]
potential fix 2
Comment 8 Khem Raj 2024-05-13 17:52:43 UTC
(In reply to Paul Floyd from comment #4)
> (And I have made some changes recently - have the patches been rebased?)

@paul, I have rebased on master and uploaded latest 2 patches, dropping -mcpu makes it working on wider arm systems ( it seems to work on
different versions of rpi boards ).
Comment 9 Paul Floyd 2024-05-14 06:57:53 UTC
On my RPi 5 with Raspberry Pi OS
Linux raspberrypi 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux

Build fails with

m_dispatch/dispatch-arm-linux.S:102: Error: selected processor does not support `movw r1,#47' in ARM mode
m_dispatch/dispatch-arm-linux.S:103: Error: selected processor does not support `movw r2,#0' in ARM mode
m_dispatch/dispatch-arm-linux.S:155: Error: selected processor does not support `movw r4,#:lower16:vgPlain_stats__n_xIndirs_32' in ARM mode
m_dispatch/dispatch-arm-linux.S:156: Error: selected processor does not support `movt r4,#:upper16:vgPlain_stats__n_xIndirs_32' in ARM mode
m_dispatch/dispatch-arm-linux.S:173: Error: selected processor does not support `ubfx r6,r6,#0,#13' in ARM mode
m_dispatch/dispatch-arm-linux.S:176: Error: selected processor does not support `movw r4,#:lower16:vgPlain_tt_fast' in ARM mode
m_dispatch/dispatch-arm-linux.S:177: Error: selected processor does not support `movt r4,#:upper16:vgPlain_tt_fast' in ARM mode
m_dispatch/dispatch-arm-linux.S:204: Error: selected processor does not support `movw r4,#:lower16:vgPlain_stats__n_xIndir_hits1_32' in ARM mode
m_dispatch/dispatch-arm-linux.S:205: Error: selected processor does not support `movt r4,#:upper16:vgPlain_stats__n_xIndir_hits1_32' in ARM mode
m_dispatch/dispatch-arm-linux.S:226: Error: selected processor does not support `movw r4,#:lower16:vgPlain_stats__n_xIndir_hits2_32' in ARM mode
m_dispatch/dispatch-arm-linux.S:227: Error: selected processor does not support `movt r4,#:upper16:vgPlain_stats__n_xIndir_hits2_32' in ARM mode
m_dispatch/dispatch-arm-linux.S:248: Error: selected processor does not support `movw r4,#:lower16:vgPlain_stats__n_xIndir_hits3_32' in ARM mode
m_dispatch/dispatch-arm-linux.S:249: Error: selected processor does not support `movt r4,#:upper16:vgPlain_stats__n_xIndir_hits3_32' in ARM mode
m_dispatch/dispatch-arm-linux.S:258: Error: selected processor does not support `movw r4,#:lower16:vgPlain_stats__n_xIndir_misses_32' in ARM mode
m_dispatch/dispatch-arm-linux.S:259: Error: selected processor does not support `movt r4,#:upper16:vgPlain_stats__n_xIndir_misses_32' in ARM mode

and also

gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../include -I../include -I../VEX/pub -I../VEX/pub -DVGA_arm=1 -DVGO_linux=1 -DVGP_arm_linux=1 -DVGPV_arm_linux_vanilla=1    -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wcast-qual -Wwrite-strings -Wempty-body -Wformat -Wformat-signedness -Wformat-security -Wignored-qualifiers -Wmissing-parameter-type -Wlogical-op -Wenum-conversion -Wimplicit-fallthrough=2 -Wold-style-declaration -finline-functions -fno-stack-protector -fno-strict-aliasing -fno-builtin   -marm -O2  -MT memcheck_arm_linux-mc_main.o -MD -MP -MF .deps/memcheck_arm_linux-mc_main.Tpo -c -o memcheck_arm_linux-mc_main.o `test -f 'mc_main.c' || echo './'`mc_main.c
/tmp/ccY1NRlM.s: Assembler messages:
/tmp/ccY1NRlM.s:27: Error: selected processor does not support `movw r3,#:lower16:primary_map' in ARM mode
/tmp/ccY1NRlM.s:29: Error: selected processor does not support `movt r3,#:upper16:primary_map' in ARM mode
/tmp/ccY1NRlM.s:68: Error: selected processor does not support `movw r3,#:lower16:primary_map' in ARM mode
/tmp/ccY1NRlM.s:70: Error: selected processor does not support `movt r3,#:upper16:primary_map' in ARM mode

gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../include -I../include -I../VEX/pub -I../VEX/pub -DVGA_arm=1 -DVGO_linux=1 -DVGP_arm_linux=1 -DVGPV_arm_linux_vanilla=1    -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wcast-qual -Wwrite-strings -Wempty-body -Wformat -Wformat-signedness -Wformat-security -Wignored-qualifiers -Wmissing-parameter-type -Wlogical-op -Wenum-conversion -Wimplicit-fallthrough=2 -Wold-style-declaration -finline-functions -fno-stack-protector -fno-strict-aliasing -fno-builtin   -marm -O2  -MT memcheck_arm_linux-mc_main_asm.o -MD -MP -MF .deps/memcheck_arm_linux-mc_main_asm.Tpo -c -o memcheck_arm_linux-mc_main_asm.o `test -f 'mc_main_asm.c' || echo './'`mc_main_asm.c
/tmp/cclkrIER.s: Assembler messages:
/tmp/cclkrIER.s:25: Error: selected processor does not support `movw r3,#:lower16:primary_map' in ARM mode
/tmp/cclkrIER.s:28: Error: selected processor does not support `movt r3,#:upper16:primary_map' in ARM mode
/tmp/cclkrIER.s:31: Error: selected processor does not support `movw r3,#0xAAAA' in ARM mode
/tmp/cclkrIER.s:40: Error: selected processor does not support `movw r3,#0x5555' in ARM mode
/tmp/cclkrIER.s:61: Error: selected processor does not support `movw r3,#:lower16:primary_map' in ARM mode
/tmp/cclkrIER.s:64: Error: selected processor does not support `movt r3,#:upper16:primary_map' in ARM mode
Comment 10 Khem Raj 2024-05-14 17:20:35 UTC
(In reply to Paul Floyd from comment #9)
> On my RPi 5 with Raspberry Pi OS
> Linux raspberrypi 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1
> (2024-01-25) aarch64 GNU/Linux
> 
> Build fails with
> 
> m_dispatch/dispatch-arm-linux.S:102: Error: selected processor does not
> support `movw r1,#47' in ARM mode
> m_dispatch/dispatch-arm-linux.S:103: Error: selected processor does not
> support `movw r2,#0' in ARM mode
> m_dispatch/dispatch-arm-linux.S:155: Error: selected processor does not
> support `movw r4,#:lower16:vgPlain_stats__n_xIndirs_32' in ARM mode
> m_dispatch/dispatch-arm-linux.S:156: Error: selected processor does not
> support `movt r4,#:upper16:vgPlain_stats__n_xIndirs_32' in ARM mode
> m_dispatch/dispatch-arm-linux.S:173: Error: selected processor does not
> support `ubfx r6,r6,#0,#13' in ARM mode
> m_dispatch/dispatch-arm-linux.S:176: Error: selected processor does not
> support `movw r4,#:lower16:vgPlain_tt_fast' in ARM mode
> m_dispatch/dispatch-arm-linux.S:177: Error: selected processor does not
> support `movt r4,#:upper16:vgPlain_tt_fast' in ARM mode
> m_dispatch/dispatch-arm-linux.S:204: Error: selected processor does not
> support `movw r4,#:lower16:vgPlain_stats__n_xIndir_hits1_32' in ARM mode
> m_dispatch/dispatch-arm-linux.S:205: Error: selected processor does not
> support `movt r4,#:upper16:vgPlain_stats__n_xIndir_hits1_32' in ARM mode
> m_dispatch/dispatch-arm-linux.S:226: Error: selected processor does not
> support `movw r4,#:lower16:vgPlain_stats__n_xIndir_hits2_32' in ARM mode
> m_dispatch/dispatch-arm-linux.S:227: Error: selected processor does not
> support `movt r4,#:upper16:vgPlain_stats__n_xIndir_hits2_32' in ARM mode
> m_dispatch/dispatch-arm-linux.S:248: Error: selected processor does not
> support `movw r4,#:lower16:vgPlain_stats__n_xIndir_hits3_32' in ARM mode
> m_dispatch/dispatch-arm-linux.S:249: Error: selected processor does not
> support `movt r4,#:upper16:vgPlain_stats__n_xIndir_hits3_32' in ARM mode
> m_dispatch/dispatch-arm-linux.S:258: Error: selected processor does not
> support `movw r4,#:lower16:vgPlain_stats__n_xIndir_misses_32' in ARM mode
> m_dispatch/dispatch-arm-linux.S:259: Error: selected processor does not
> support `movt r4,#:upper16:vgPlain_stats__n_xIndir_misses_32' in ARM mode
> 
> and also
> 
> gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../include -I../include -I../VEX/pub
> -I../VEX/pub -DVGA_arm=1 -DVGO_linux=1 -DVGP_arm_linux=1
> -DVGPV_arm_linux_vanilla=1    -O2 -g -Wall -Wmissing-prototypes -Wshadow
> -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wcast-qual
> -Wwrite-strings -Wempty-body -Wformat -Wformat-signedness -Wformat-security
> -Wignored-qualifiers -Wmissing-parameter-type -Wlogical-op -Wenum-conversion
> -Wimplicit-fallthrough=2 -Wold-style-declaration -finline-functions
> -fno-stack-protector -fno-strict-aliasing -fno-builtin   -marm -O2  -MT
> memcheck_arm_linux-mc_main.o -MD -MP -MF
> .deps/memcheck_arm_linux-mc_main.Tpo -c -o memcheck_arm_linux-mc_main.o
> `test -f 'mc_main.c' || echo './'`mc_main.c
> /tmp/ccY1NRlM.s: Assembler messages:
> /tmp/ccY1NRlM.s:27: Error: selected processor does not support `movw
> r3,#:lower16:primary_map' in ARM mode
> /tmp/ccY1NRlM.s:29: Error: selected processor does not support `movt
> r3,#:upper16:primary_map' in ARM mode
> /tmp/ccY1NRlM.s:68: Error: selected processor does not support `movw
> r3,#:lower16:primary_map' in ARM mode
> /tmp/ccY1NRlM.s:70: Error: selected processor does not support `movt
> r3,#:upper16:primary_map' in ARM mode
> 
> gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../include -I../include -I../VEX/pub
> -I../VEX/pub -DVGA_arm=1 -DVGO_linux=1 -DVGP_arm_linux=1
> -DVGPV_arm_linux_vanilla=1    -O2 -g -Wall -Wmissing-prototypes -Wshadow
> -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wcast-qual
> -Wwrite-strings -Wempty-body -Wformat -Wformat-signedness -Wformat-security
> -Wignored-qualifiers -Wmissing-parameter-type -Wlogical-op -Wenum-conversion
> -Wimplicit-fallthrough=2 -Wold-style-declaration -finline-functions
> -fno-stack-protector -fno-strict-aliasing -fno-builtin   -marm -O2  -MT
> memcheck_arm_linux-mc_main_asm.o -MD -MP -MF
> .deps/memcheck_arm_linux-mc_main_asm.Tpo -c -o
> memcheck_arm_linux-mc_main_asm.o `test -f 'mc_main_asm.c' || echo
> './'`mc_main_asm.c
> /tmp/cclkrIER.s: Assembler messages:
> /tmp/cclkrIER.s:25: Error: selected processor does not support `movw
> r3,#:lower16:primary_map' in ARM mode
> /tmp/cclkrIER.s:28: Error: selected processor does not support `movt
> r3,#:upper16:primary_map' in ARM mode
> /tmp/cclkrIER.s:31: Error: selected processor does not support `movw
> r3,#0xAAAA' in ARM mode
> /tmp/cclkrIER.s:40: Error: selected processor does not support `movw
> r3,#0x5555' in ARM mode
> /tmp/cclkrIER.s:61: Error: selected processor does not support `movw
> r3,#:lower16:primary_map' in ARM mode
> /tmp/cclkrIER.s:64: Error: selected processor does not support `movt
> r3,#:upper16:primary_map' in ARM mode

Hmm, I think we need to use -march=armv7ve instead of -mcpu=cortex-a8, I did realize that all distros
will not tune the compiler like yocto does.
Comment 11 Paul Floyd 2024-05-14 19:54:51 UTC
(In reply to Khem Raj from comment #10)

> Hmm, I think we need to use -march=armv7ve instead of -mcpu=cortex-a8, I did
> realize that all distros
> will not tune the compiler like yocto does.

The build and tests need to run with just autogen.sh, configure (without compiler options), make, make check and make regtest.