Bug 1128 - Find a way to check that the SFFS binaries have no VSX instructions.
Summary: Find a way to check that the SFFS binaries have no VSX instructions.
Status: RESOLVED FIXED
Alias: None
Product: Libre-SOC's first SoC
Classification: Unclassified
Component: Milestones (show other bugs)
Version: unspecified
Hardware: Other Linux
: --- normal
Deadline: 2023-10-31
Assignee: Sadoon Albader
URL:
Depends on: 999
Blocks:
  Show dependency treegraph
 
Reported: 2023-08-02 14:56 BST by Sadoon Albader
Modified: 2024-02-26 22:33 GMT (History)
4 users (show)

See Also:
NLnet milestone: NLnet.2022-08-107.ongoing
total budget (EUR) for completion of task and all subtasks: 2500
budget (EUR) for this task, excluding subtasks' budget: 2500
parent task for budget allocation: 999
child tasks for budget allocation:
The table of payments (in EUR) for this task; TOML format:
sadoon={amount=1700, submitted=2024-02-26} lkcl = {amount=800, submitted=2024-02-26}


Attachments
Incomplete list of AltiVec/VSX instructions (5.02 KB, text/plain)
2023-08-04 16:55 BST, Sadoon Albader
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sadoon Albader 2023-08-02 14:56:54 BST
We need a way to test whether binary object files contain any VSX instructions to make sure that the build flags from bug #1132 and bug #1131 are being applied by the build scripts.

This is a rudimentary test to help not waste time trying to simulate / run code that is guaranteed to not work in an SFFS compliant environment.
Comment 1 Luke Kenneth Casson Leighton 2023-08-02 16:32:35 BST
or, run in userspace OR simply do "istruction trace logging" and
check afterwards if any VSX instructios were included.

OR, perform an "objdump" disassembly on all binaries and examine
them to see if they have VSX.

it is not *actually* necessary to execute the binaries at all:
the actual task is "check if the binaries contain VSX instructions",
where executing under qemu is just one way to achieve that task.
Comment 2 Sadoon Albader 2023-08-02 16:36:03 BST
(In reply to Luke Kenneth Casson Leighton from comment #1)

> OR, perform an "objdump" disassembly on all binaries and examine
> them to see if they have VSX.

I'll add that as a worst case scenario if patching qemu proves very difficult
Comment 3 Luke Kenneth Casson Leighton 2023-08-02 16:36:28 BST
(In reply to Sadoon Albader from comment #0)

> and to fix whatever
> oddities we find in software that does not respect CFLAGs and various build
> toggles.

this is an additional task for which it is perfectly reasonable to
put in an additional (new) grant request.  the reason why is becausewe have no idea yet the scale of the task.  you could be letting yourself
in for 24 months worth of patching work for only EUR 5,000.
Comment 4 Sadoon Albader 2023-08-02 16:38:22 BST
(sadoon ihave edited ths comment to trim rxtraneous context.
 the reply comments are right above if anyne wants to see them.
 please be strict about this in bugreports, this server is not
 "unlimited resources" plus it wastes reader's valuable time)

(In reply to Luke Kenneth Casson Leighton from comment #3)

> this is an additional task for which it is perfectly reasonable to
> put in an additional (new) grant request.  the reason why is becausewe have
> no idea yet the scale of the task.  you could be letting yourself
> in for 24 months worth of patching work for only EUR 5,000.

Yes of course, that would be a separate task to fix all those oddities :)
What I meant was that task 1128 would enable us to find those outliers so they can be fixed later.
Comment 5 Luke Kenneth Casson Leighton 2023-08-02 16:40:13 BST
(In reply to Sadoon Albader from comment #2)
> (In reply to Luke Kenneth Casson Leighton from comment #1)
> 
> > OR, perform an "objdump" disassembly on all binaries and examine
> > them to see if they have VSX.
> 
> I'll add that as a worst case scenario if patching qemu proves very difficult

rather than do the difficult task first for which you will receive
exactly the same amount of money can i suggest doing the easy task
as a shell script with some "grep" commands in it then see if you
feel like doing qemu after that?

after all, if you *know* that the binaries have no VSX instuctions
because the scripts informed you of this why the go to the trouble of
executing them?

also the scripts will find untested codepaths that simply running
the binaries will not.
Comment 6 Luke Kenneth Casson Leighton 2023-08-02 16:46:19 BST
(In reply to Sadoon Albader from comment #4)


> What I meant was that task 1128 would enable us to find those outliers so
> they can be fixed later.

ah it reads ambiguously, can you edit comment #0 so it is clearer?
"...is proper.  this allows a future task to fix..." or other words
Comment 7 Sadoon Albader 2023-08-02 17:09:01 BST
(In reply to Luke Kenneth Casson Leighton from comment #5)
> rather than do the difficult task first for which you will receive
> exactly the same amount of money can i suggest doing the easy task
> as a shell script with some "grep" commands in it then see if you
> feel like doing qemu after that?
> 
> after all, if you *know* that the binaries have no VSX instuctions
> because the scripts informed you of this why the go to the trouble of
> executing them?
> 
> also the scripts will find untested codepaths that simply running
> the binaries will not.

Yes that sounds reasonable, thanks for the heads up!
Comment 8 Sadoon Albader 2023-08-04 16:55:53 BST
Created attachment 198 [details]
Incomplete list of AltiVec/VSX instructions

This list is based on https://git.libre-soc.org/?p=binutils-gdb.git&a=search&h=85f4cf41a852b5983ca436615a019315f6dc7301&st=grep&s=PPCVEC%7CPPCVSX&sr=1 (Thanks Jacob!)

we can use it to check our objdump'd binaries for any Vector instructions, example of default compiled hello.deb on Debian 12:

fgrep -of insns.txt hello.asm | sort | uniq -c | awk '{print $2 " " $1}'

lvx 1
lxvd2x 45
mfvrd 1
stvx 1
stxvd2x 49
vcmpequb 12
vgbbd 1
vsldoi 1
vspltisw 5
xxlorc 4
xxswapd 4

Example of our custom CFLAGS (see bug 999):

fgrep -of insns.txt hello.final.asm | sort | uniq -c | awk '{print $2 " " $1}'

*no output*
Comment 10 Sadoon Albader 2023-08-25 12:49:09 BST
Added sections in [debian_bootstrap](https://libre-soc.org/SFFS/debian_bootstrap) and [gentoo_bootstrap](https://libre-soc.org/SFFS/gentoo_boostrap) wiki pages for testing VSX instructions.
Task is completed.
Comment 11 Luke Kenneth Casson Leighton 2023-08-25 12:53:55 BST
what was the summary of why qemu could not be built to emulate SFFS
only? (notes for the basis of a future grant)
Comment 12 Sadoon Albader 2023-08-25 12:55:30 BST
(In reply to Luke Kenneth Casson Leighton from comment #11)
> what was the summary of why qemu could not be built to emulate SFFS
> only? (notes for the basis of a future grant)

I'll add a wiki page for that as well as attach a comment on bug #1132 as that is the bug for the QEMU task