Monday, January 16, 2023

x11/qt5/qtwebengine: amd64 assembly fixes.

Move constants in perl generated BoringSSL assembly from .text to
.rodata. This fixes the build (and only the build) on x-only amd64.
I'll look into fixes for the aarch64 perlasm later. There the build
succeeds, but runtime failures are likely.

Similar fixes will be needed by anything that embeds BoringSSL sources
such as the chromium derivatives and the ring crate.

I edited the .S files directly instead of the .pl files since the .pl
files seem to be unused by the build system (also in chromium).


As mentioned, this is unfortunately only good enough to fix the build.
Runtime testing shows that there are other x-only violation in this code
base. Apparently V8 (also used by chrome & friends) has an assembly
generator. When using otter-browser QtWebEngineProcess segfaults with
things such as:

Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00000c8392f76fa5 in v8::internal::EmbeddedData::InstructionStartOfBuiltin(int) const ()
from /usr/local/lib/qt5/libQt5WebEngineCore.so.1.0

otter-browser works fine when qtwebengine is built with USE_NOEXECONLY.
One step at a time.

Index: Makefile
===================================================================
RCS file: /cvs/ports/x11/qt5/qtwebengine/Makefile,v
retrieving revision 1.29
diff -u -p -r1.29 Makefile
--- Makefile 5 Nov 2022 17:07:33 -0000 1.29
+++ Makefile 16 Jan 2023 13:31:22 -0000
@@ -15,7 +15,7 @@ VERSION = ${QT5_WEBENGINE_VERSION}
DIST_VERSION = ${QT5_WEBENGINE_VERSION}
DISTNAME = ${QT5NAME:L}-everywhere-src-${DIST_VERSION}
PKGNAME ?= ${DISTNAME:C/-everywhere-src//:C/-${DIST_VERSION}/-${VERSION}/}
-REVISION = 8
+REVISION = 9

MASTER_SITES ?= https://download.qt.io/official_releases/qt/${QT5_WEBENGINE_VERSION:R}/${QT5_WEBENGINE_VERSION}/submodules/ \
https://mirrors.ocf.berkeley.edu/qt/official_releases/qt/${QT5_WEBENGINE_VERSION:R}/${QT5_WEBENGINE_VERSION}/submodules/
Index: patches/patch-src_3rdparty_chromium_third_party_boringssl_linux-x86_64_crypto_chacha_chacha-x86_64_S
===================================================================
RCS file: patches/patch-src_3rdparty_chromium_third_party_boringssl_linux-x86_64_crypto_chacha_chacha-x86_64_S
diff -N patches/patch-src_3rdparty_chromium_third_party_boringssl_linux-x86_64_crypto_chacha_chacha-x86_64_S
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_3rdparty_chromium_third_party_boringssl_linux-x86_64_crypto_chacha_chacha-x86_64_S 16 Jan 2023 09:04:33 -0000
@@ -0,0 +1,19 @@
+Index: src/3rdparty/chromium/third_party/boringssl/linux-x86_64/crypto/chacha/chacha-x86_64.S
+--- src/3rdparty/chromium/third_party/boringssl/linux-x86_64/crypto/chacha/chacha-x86_64.S.orig
++++ src/3rdparty/chromium/third_party/boringssl/linux-x86_64/crypto/chacha/chacha-x86_64.S
+@@ -16,6 +16,7 @@
+ .extern OPENSSL_ia32cap_P
+ .hidden OPENSSL_ia32cap_P
+
++.rodata
+ .align 64
+ .Lzero:
+ .long 0,0,0,0
+@@ -45,6 +46,7 @@
+ .Lsixteen:
+ .long 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
+ .byte 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
++.previous
+ .globl ChaCha20_ctr32
+ .hidden ChaCha20_ctr32
+ .type ChaCha20_ctr32,@function
Index: patches/patch-src_3rdparty_chromium_third_party_boringssl_linux-x86_64_crypto_fipsmodule_aesni-gcm-x86_64_S
===================================================================
RCS file: patches/patch-src_3rdparty_chromium_third_party_boringssl_linux-x86_64_crypto_fipsmodule_aesni-gcm-x86_64_S
diff -N patches/patch-src_3rdparty_chromium_third_party_boringssl_linux-x86_64_crypto_fipsmodule_aesni-gcm-x86_64_S
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_3rdparty_chromium_third_party_boringssl_linux-x86_64_crypto_fipsmodule_aesni-gcm-x86_64_S 16 Jan 2023 09:04:33 -0000
@@ -0,0 +1,19 @@
+Index: src/3rdparty/chromium/third_party/boringssl/linux-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S
+--- src/3rdparty/chromium/third_party/boringssl/linux-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S.orig
++++ src/3rdparty/chromium/third_party/boringssl/linux-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S
+@@ -835,6 +835,7 @@ aesni_gcm_encrypt:
+ .byte 0xf3,0xc3
+ .cfi_endproc
+ .size aesni_gcm_encrypt,.-aesni_gcm_encrypt
++.rodata
+ .align 64
+ .Lbswap_mask:
+ .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
+@@ -847,6 +848,7 @@ aesni_gcm_encrypt:
+ .Lone_lsb:
+ .byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+ .byte 65,69,83,45,78,73,32,71,67,77,32,109,111,100,117,108,101,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
++.previous
+ .align 64
+

No comments:

Post a Comment