freebl: Unconditional use of "-mcrypto" and "-mvsx" breaks older POWER systems
Categories
(NSS :: Libraries, defect, P5)
Tracking
(Not tracked)
People
(Reporter: glaubitz, Assigned: beurdouche)
References
Details
(Whiteboard: [nss-nofx])
Attachments
(1 file, 1 obsolete file)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0
Steps to reproduce:
The fix in #1642174 is incomplete since the Makefile still unconditionally passes "-mcrypto" and "-mvsx" during build which results in freebl being compiled with instructions incompatible with older POWER systems as reported in [1].
[1] https://lists.debian.org/debian-powerpc/2021/01/msg00037.html
Comment 1•5 years ago
|
||
I added -mvsx, because I was informed that nss actually can't make use of altivec and it can only use vsx, which NSS_DISABLE_ALTIVEC=1 can disable.
Is this not true?
| Reporter | ||
Comment 2•5 years ago
|
||
(In reply to Piotr Kubaj from comment #1)
I added -mvsx, because I was informed that nss actually can't make use of altivec and it can only use vsx, which NSS_DISABLE_ALTIVEC=1 can disable.
Is this not true?
I would suggest then to rename the configure flag to NSS_DISABLE_VSX then and only enable it when LITTLE_ENDIAN is defined.
See the output of "echo | gcc -E -dM -"
| Assignee | ||
Comment 3•5 years ago
|
||
Hi Piotr, Hi John,
Unfortunately we don't have a machine to test this, but we would welcome a patch if you have a good solution... : )
B.
| Reporter | ||
Comment 4•5 years ago
|
||
The GCC compile farm has big-endian PowerPC machines available running Debian unstable, see: https://gcc.gnu.org/wiki/CompileFarm Anyone can request access to these machines.
I maintain the machine gcc203, so I can install additional packages if necessary. But I can also try to provide a patch the next days if I find the time. Shouldn't be too difficult.
Comment 5•5 years ago
|
||
Here is an example of a patch that I use to still run Thunderbird and Firefox on my G5:
--- ./nss/lib/freebl/Makefile.orig 2020-12-11 16:32:40.000000000 +0100
+++ ./nss/lib/freebl/Makefile 2021-01-15 23:04:21.000000000 +0100
@@ -757,10 +757,10 @@ifeq ($(CPU_ARCH),ppc)
ifndef NSS_DISABLE_ALTIVEC
-$(OBJDIR)/$(PROG_PREFIX)gcm-ppc$(OBJ_SUFFIX): CFLAGS += -mcrypto -maltivec -mvsx
-$(OBJDIR)/$(PROG_PREFIX)gcm$(OBJ_SUFFIX): CFLAGS += -mcrypto -maltivec -mvsx
-$(OBJDIR)/$(PROG_PREFIX)rijndael$(OBJ_SUFFIX): CFLAGS += -mcrypto -maltivec -mvsx
-$(OBJDIR)/$(PROG_PREFIX)sha512$(OBJ_SUFFIX): CFLAGS += -mcrypto -maltivec -mvsx
+$(OBJDIR)/$(PROG_PREFIX)gcm-ppc$(OBJ_SUFFIX): CFLAGS += -maltivec
+$(OBJDIR)/$(PROG_PREFIX)gcm$(OBJ_SUFFIX): CFLAGS += -maltivec
+$(OBJDIR)/$(PROG_PREFIX)rijndael$(OBJ_SUFFIX): CFLAGS += -maltivec
+$(OBJDIR)/$(PROG_PREFIX)sha512$(OBJ_SUFFIX): CFLAGS += -maltivec
-funroll-loops -fpeel-loops
endif
endif
And there should indeed be a distinction between ALTIVEC, VSX and CRYPTO as those features were introduced with different levels of the Power-ISA (Altivec is already available for good old G4/G5 Power-Macs whereas for VSX you'll need Power-7 and CRYPTO requires an even higher level (Power-8)).
| Reporter | ||
Comment 6•5 years ago
|
||
It shouldn't be too difficult to fix this.
Basically, we want to split AltiVec off from the Crypto/VSX stuff because the latter is available on POWER8 and newer only.
I would suggest to have something like disable_vsx or disable_crypto which are set on target_arch="ppc64" but not on target_arch="ppc64le".
While VSX and the Crypto extensions can be used on big-endian ppc64 as well, the majority of users with a big-endian target will be on an older baseline which doesn't support these.
I can create a patch once I have figured out how the build system works. I haven't dealt with GYP before.
Comment 7•5 years ago
|
||
Hi John(In reply to John Paul Adrian Glaubitz from comment #6)
It shouldn't be too difficult to fix this.
Basically, we want to split AltiVec off from the Crypto/VSX stuff because the latter is available on POWER8 and newer only.
I would suggest to have something like disable_vsx or disable_crypto which are set on target_arch="ppc64" but not on target_arch="ppc64le".
While VSX and the Crypto extensions can be used on big-endian ppc64 as well, the majority of users with a big-endian target will be on an older baseline which doesn't support these.
I can create a patch once I have figured out how the build system works. I haven't dealt with GYP before.
Hi John,
for gyp you can take a look at my patch where I’ve added NSS_DISABLE_ALTIVEC:
https://hg.mozilla.org/projects/nss/rev/f2d9478178505d24da34f2e694bdd05e0e6395c6
| Reporter | ||
Comment 8•4 years ago
|
||
Thanks, I will be sending a PR shortly once I remember how the review system works ;-).
Btw, it seems your change enables Altivec for 64-bit PowerPC only but 32-bit PowerPC targets support Altivec as well - such as PowerMac G4.
Comment 9•4 years ago
|
||
(In reply to John Paul Adrian Glaubitz from comment #8)
Thanks, I will be sending a PR shortly once I remember how the review system works ;-).
Btw, it seems your change enables Altivec for 64-bit PowerPC only but 32-bit PowerPC targets support Altivec as well - such as PowerMac G4.
Yes, I had to handle every case for every ppc extension but that was enough at the time :-)
Look forward for you patch, with Buildroot then every case should be built so if any problem exists it comes out.
Thank you!
| Reporter | ||
Comment 10•4 years ago
|
||
Gotcha. I'm currently build-testing (powerpc, ppc64, ppc64le) everything to make sure I don't break anything.
| Reporter | ||
Comment 11•4 years ago
|
||
(In reply to Giulio Benetti from comment #9)
Look forward for you patch, with Buildroot then every case should be built so if any problem exists it comes out.
One question: Do you know whether any config defines such as NSS_DISABLE_ALTIVEC are automatically translated into Gyp defines such as "disable_altivec"?
Comment 12•4 years ago
|
||
(In reply to John Paul Adrian Glaubitz from comment #11)
(In reply to Giulio Benetti from comment #9)
Look forward for you patch, with Buildroot then every case should be built so if any problem exists it comes out.
One question: Do you know whether any config defines such as NSS_DISABLE_ALTIVEC are automatically translated into Gyp defines such as "disable_altivec"?
No it's automatic, you have to take care of lib/freebl/freebl.gyp. There you check gyp variables and then define NSS_DISABLE_ALTIVEC or something
like that. Try to imitate what I've done in this patch lines:
https://hg.mozilla.org/projects/nss/rev/f2d9478178505d24da34f2e694bdd05e0e6395c6#l4.12
| Reporter | ||
Comment 13•4 years ago
|
||
Currently, NSS assumes that every PowerPC target supports the crypto
and VSX extensions of the PowerPC ABI. However, VSX was only introduced
with ISA version 2.06 and the crypto extensions with ISA version 2.07
and enabling them on older PowerPC targets will result in a SIGILL. Thus,
make their use configurable and enable them by default on ppc64le only.
| Reporter | ||
Comment 14•4 years ago
|
||
Just submitted it. To my surprise, neither jcj nor kjacobs were available as reviewers, so I picked bbeurdouche. Let me know if I shall pick someone else.
I have verified the changes on ppc64 and ppc64le. I can verify them on 32-bit PowerPC tomorrow as it's late here already.
Comment 15•4 years ago
|
||
(In reply to John Paul Adrian Glaubitz from comment #14)
Just submitted it. To my surprise, neither jcj nor kjacobs were available as reviewers, so I picked bbeurdouche. Let me know if I shall pick someone else.
I have verified the changes on ppc64 and ppc64le. I can verify them on 32-bit PowerPC tomorrow as it's late here already.
I’ve taken a look at the patch, is there any ppc that has crypto but not VSX?
If yes then I would introduce a variable for VSX too.
Also the reviewer I think you should leave it undefined and then Mozilla crew set it, at least I’ve done that way every time.
| Assignee | ||
Comment 16•4 years ago
|
||
(In reply to John Paul Adrian Glaubitz from comment #14)
Just submitted it. To my surprise, neither jcj nor kjacobs were available as reviewers, so I picked bbeurdouche. Let me know if I shall pick someone else.
I have verified the changes on ppc64 and ppc64le. I can verify them on 32-bit PowerPC tomorrow as it's late here already.
Hi all, thanks for submitting the patch,
You were correct to pick me as the reviewer. JC and Kevin left for new adventures which leaves only me on the Mozilla side.
As Giulio noted, it is better not to assign a reviewer yourself, but that's fine in this case.
I've pushed your patch to our CI and it seem to be failing right now. (I've put the link in the test plan of the phabricator patch.)
Feel free to needinfo me here, when you have updated the patch and you think it is ready for review... : )
| Assignee | ||
Updated•4 years ago
|
| Reporter | ||
Comment 17•4 years ago
|
||
Thanks Benjamin for the helpful input. I'm calling it a day for today and will get back to this tomorrow.
| Reporter | ||
Comment 18•4 years ago
|
||
(In reply to Giulio Benetti from comment #15)
I’ve taken a look at the patch, is there any ppc that has crypto but not VSX?
Yes, there are although those systems are not commonly used as a baseline.
See: https://en.wikipedia.org/wiki/Power_ISA
VSX was introduced with ISA version 2.06, the crypto instructions with ISA version 2.07.
If yes then I would introduce a variable for VSX too.
I first wanted to avoid that because I thought it would become too complex. But I think I have a rough idea now on how to construct the CFLAGS and will hopefully push a much better patch the next days.
Also the reviewer I think you should leave it undefined and then Mozilla crew set it, at least I’ve done that way every time.
Seems that Benjamin is fine with being picked as the reviewer.
Comment 19•4 years ago
|
||
(In reply to John Paul Adrian Glaubitz from comment #18)
(In reply to Giulio Benetti from comment #15)
I’ve taken a look at the patch, is there any ppc that has crypto but not VSX?
Yes, there are although those systems are not commonly used as a baseline.
See: https://en.wikipedia.org/wiki/Power_ISA
VSX was introduced with ISA version 2.06, the crypto instructions with ISA version 2.07.
IMHO this is worth having 2 patches, 1 for disabling VSX and 1 for disabling CRYPTO.
If yes then I would introduce a variable for VSX too.
I first wanted to avoid that because I thought it would become too complex. But I think I have a rough idea now on how to construct the CFLAGS and will hopefully push a much better patch the next days.
Also the reviewer I think you should leave it undefined and then Mozilla crew set it, at least I’ve done that way every time.
Seems that Benjamin is fine with being picked as the reviewer.
| Reporter | ||
Comment 20•4 years ago
|
||
I think I won't make two separate patches, but we'll see. I'm busy this week but I will be on vacation from next week, so plenty of time to work on this :-).
| Reporter | ||
Comment 21•4 years ago
|
||
There is even more breakage now with the recent changes:
[566/1215] SOLINK /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so
FAILED: /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC
if [ ! -e /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so -o ! -e /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC ]; then cc -shared -Wl,-Bsymbolic -Wl,--version-script,obj/lib/freebl/freeblpriv3.gen/out.freebl_hash_vector.def -Wl,--gc-sections -Wl,-z,defs -z noexecstack -o /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so -Wl,-soname=libfreeblpriv3.so @/home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.rsp && { readelf -d /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so | grep SONAME ; nm -gD -f p /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so | cut -f1-2 -d' '; } > /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC; else cc -shared -Wl,-Bsymbolic -Wl,--version-script,obj/lib/freebl/freeblpriv3.gen/out.freebl_hash_vector.def -Wl,--gc-sections -Wl,-z,defs -z noexecstack -o /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so -Wl,-soname=libfreeblpriv3.so @/home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.rsp && { readelf -d /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so | grep SONAME ; nm -gD -f p /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so | cut -f1-2 -d' '; } > /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.tmp && if ! cmp -s /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.tmp /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC; then mv /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.tmp /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC ; fi; fi
/usr/bin/ld: libgcm-aes-ppc_c_lib.a(gcm-aes-ppc_c_lib.sha512-p8.o): ABI version 2 is not compatible with ABI version 1 output
/usr/bin/ld: failed to merge target specific data of file libgcm-aes-ppc_c_lib.a(gcm-aes-ppc_c_lib.sha512-p8.o)
collect2: error: ld returned 1 exit status
[583/1215] CC obj/lib/sqlite/sqlite.sqlite3.o
ninja: build stopped: subcommand failed.[566/1215] SOLINK /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so
FAILED: /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC
if [ ! -e /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so -o ! -e /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC ]; then cc -shared -Wl,-Bsymbolic -Wl,--version-script,obj/lib/freebl/freeblpriv3.gen/out.freebl_hash_vector.def -Wl,--gc-sections -Wl,-z,defs -z noexecstack -o /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so -Wl,-soname=libfreeblpriv3.so @/home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.rsp && { readelf -d /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so | grep SONAME ; nm -gD -f p /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so | cut -f1-2 -d' '; } > /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC; else cc -shared -Wl,-Bsymbolic -Wl,--version-script,obj/lib/freebl/freeblpriv3.gen/out.freebl_hash_vector.def -Wl,--gc-sections -Wl,-z,defs -z noexecstack -o /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so -Wl,-soname=libfreeblpriv3.so @/home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.rsp && { readelf -d /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so | grep SONAME ; nm -gD -f p /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so | cut -f1-2 -d' '; } > /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.tmp && if ! cmp -s /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.tmp /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC; then mv /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.tmp /home/glaubitz/dist/Debug/lib/libfreeblpriv3.so.TOC ; fi; fi
/usr/bin/ld: libgcm-aes-ppc_c_lib.a(gcm-aes-ppc_c_lib.sha512-p8.o): ABI version 2 is not compatible with ABI version 1 output
/usr/bin/ld: failed to merge target specific data of file libgcm-aes-ppc_c_lib.a(gcm-aes-ppc_c_lib.sha512-p8.o)
collect2: error: ld returned 1 exit status
[583/1215] CC obj/lib/sqlite/sqlite.sqlite3.o
ninja: build stopped: subcommand failed.
Frustrating.
| Reporter | ||
Comment 22•4 years ago
|
||
(In reply to John Paul Adrian Glaubitz from comment #21)
There is even more breakage now with the recent changes:
(...)
Frustrating.
OK, I managed to get it building again. Will try to push an updated revision of the patch later today.
| Reporter | ||
Comment 23•4 years ago
|
||
Currently, NSS assumes that every PowerPC target supports the crypto
and VSX extensions of the PowerPC ABI. However, VSX was only introduced
with ISA version 2.06 and the crypto extensions with ISA version 2.07
and enabling them on older PowerPC targets will result in a SIGILL. Thus,
make their use configurable and enable them by default on ppc64le only.
Updated•4 years ago
|
Comment 24•4 years ago
|
||
(In reply to John Paul Adrian Glaubitz from comment #22)
(In reply to John Paul Adrian Glaubitz from comment #21)
There is even more breakage now with the recent changes:
(...)
Frustrating.OK, I managed to get it building again. Will try to push an updated revision of the patch later today.
Hi John,
this patch looks good, but it should add 2 different NSS_DISABLE'S_
NSS_DISABLE_CRYPTO and NSS_DISABLE_VSX, since as you've written there are ISA 2.06 where only VSX is present and
ISA 2.07 where also CRYPTO is present.
I'm adding those 2 options to Buildroot:
BR2_POWERPC_CPU_HAS_VSX
BR2_POWERPC_CPU_HAS_CRYPTO
But I need 2 different patches with such macros to disable them.
Basically this unique patch is partly wrong based. Since you're doing a great job, let's do it until the end!
Otherwise I can take over it, no problem.
Thank you very much!
| Reporter | ||
Comment 25•4 years ago
|
||
(In reply to Giulio Benetti from comment #24)
this patch looks good, but it should add 2 different NSS_DISABLE'S_
NSS_DISABLE_CRYPTO and NSS_DISABLE_VSX, since as you've written there are ISA 2.06 where only VSX is present and
ISA 2.07 where also CRYPTO is present.I'm adding those 2 options to Buildroot:
BR2_POWERPC_CPU_HAS_VSX
BR2_POWERPC_CPU_HAS_CRYPTOBut I need 2 different patches with such macros to disable them.
Basically this unique patch is partly wrong based. Since you're doing a great job, let's do it until the end!
Otherwise I can take over it, no problem.
Well, I don't think anything without VSX and with CRYPTO exists in the wild. So I don't see a reason to separate those.
I mean, currently have all under the Altivec conditional, so that's definitely an improvement.
Users have either POWER8 or greater or POWER5 on ppc64, the latter with or without Altivec.
Comment 26•4 years ago
|
||
(In reply to John Paul Adrian Glaubitz from comment #25)
(In reply to Giulio Benetti from comment #24)
this patch looks good, but it should add 2 different NSS_DISABLE'S_
NSS_DISABLE_CRYPTO and NSS_DISABLE_VSX, since as you've written there are ISA 2.06 where only VSX is present and
ISA 2.07 where also CRYPTO is present.I'm adding those 2 options to Buildroot:
BR2_POWERPC_CPU_HAS_VSX
BR2_POWERPC_CPU_HAS_CRYPTOBut I need 2 different patches with such macros to disable them.
Basically this unique patch is partly wrong based. Since you're doing a great job, let's do it until the end!
Otherwise I can take over it, no problem.Well, I don't think anything without VSX and with CRYPTO exists in the wild. So I don't see a reason to separate those.
I mean, currently have all under the Altivec conditional, so that's definitely an improvement.
Users have either POWER8 or greater or POWER5 on ppc64, the latter with or without Altivec.
Under Buildroot we still have POWER4/5/6/7 and 4/5/6 has not the VSX nor CRYPTO, while POWER7 has VSX only.
And we also have e500-mc and e5500 that are in the same state, this is why. You can check it here:
https://git.buildroot.net/buildroot/tree/arch/Config.in.powerpc
And they are part of the autobuilders. At this point I think it would make sense to complete this using the 2 DISABLES_VSX/CRYPTO.
| Reporter | ||
Comment 27•4 years ago
|
||
(In reply to Giulio Benetti from comment #26)
Under Buildroot we still have POWER4/5/6/7 and 4/5/6 has not the VSX nor CRYPTO, while POWER7 has VSX only.
And we also have e500-mc and e5500 that are in the same state, this is why. You can check it here:
https://git.buildroot.net/buildroot/tree/arch/Config.in.powerpc
And they are part of the autobuilders. At this point I think it would make sense to complete this using the 2 DISABLES_VSX/CRYPTO.
The code already uses NSS_DISABLE_CRYPTO_VSX:
https://hg.mozilla.org/projects/nss/file/tip/lib/freebl/chacha20poly1305.c#l222
I see no reason to change that at the moment as POWER5 with or without Altivec and POWER8 or greater (which supports all) covers 99% of all usecases.
If someone reports they are actually using a combination where VSX is enabled but CRYPTO not or vice versa, we can still change that. For now, I just want to unbreak nss on Debian/ppc64 because users have reported that Firefox currently crashes with SIGILL for them because of this bug.
Comment 28•4 years ago
|
||
(In reply to John Paul Adrian Glaubitz from comment #27)
(In reply to Giulio Benetti from comment #26)
Under Buildroot we still have POWER4/5/6/7 and 4/5/6 has not the VSX nor CRYPTO, while POWER7 has VSX only.
And we also have e500-mc and e5500 that are in the same state, this is why. You can check it here:
https://git.buildroot.net/buildroot/tree/arch/Config.in.powerpc
And they are part of the autobuilders. At this point I think it would make sense to complete this using the 2 DISABLES_VSX/CRYPTO.The code already uses NSS_DISABLE_CRYPTO_VSX:
https://hg.mozilla.org/projects/nss/file/tip/lib/freebl/chacha20poly1305.c#l222
I see no reason to change that at the moment as POWER5 with or without Altivec and POWER8 or greater (which supports all) covers 99% of all usecases.
If someone reports they are actually using a combination where VSX is enabled but CRYPTO not or vice versa, we can still change that. For now, I just want to unbreak nss on Debian/ppc64 because users have reported that Firefox currently crashes with SIGILL for them because of this bug.
Ok I see, if I'll find that combination I'll submit another patch then. Thank you very much!
| Assignee | ||
Comment 29•4 years ago
|
||
| Assignee | ||
Comment 30•4 years ago
|
||
Thanks @glaubitz !! : )
Description
•