After enabling SVE (the "new" SIMD instruction set on arm64) there is
a bit more perlasm that needs to be adjusted.  The machine I'm testing
on also implements the SM3 and SM4 instructions and the perlasm for
that needs fixes as well.  Diff below fixes all three openssl
versions.  The fixes are identical for all of them.  Will commit as
separate commits though.

ok?


Index: security/openssl/3.3/Makefile
===================================================================
RCS file: /cvs/ports/security/openssl/3.3/Makefile,v
diff -u -p -r1.10 Makefile
--- security/openssl/3.3/Makefile       18 Jan 2025 08:58:18 -0000      1.10
+++ security/openssl/3.3/Makefile       6 Feb 2025 20:27:32 -0000
@@ -11,7 +11,7 @@ V=            3.3.2
 PKGNAME=       openssl-${V}
 PKGSPEC=       openssl->=3.3v0,<3.4v0
 EPOCH=         0
-REVISION=      2
+REVISION=      3
 
 SHLIBVER=      27.0
 SHARED_LIBS=   crypto ${SHLIBVER} \
Index: security/openssl/3.3/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl
===================================================================
RCS file: 
security/openssl/3.3/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl
diff -N security/openssl/3.3/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ security/openssl/3.3/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl    
6 Feb 2025 20:27:32 -0000
@@ -0,0 +1,41 @@
+Index: crypto/chacha/asm/chacha-armv8-sve.pl
+--- crypto/chacha/asm/chacha-armv8-sve.pl.orig
++++ crypto/chacha/asm/chacha-armv8-sve.pl
+@@ -720,12 +720,16 @@ $code.=<<___;
+ .extern       OPENSSL_armcap_P
+ .hidden       OPENSSL_armcap_P
+ 
+-.text
++.rodata
++
+ .align        5
+ .Lchacha20_consts:
+ .quad 0x3320646e61707865,0x6b20657479622d32           // endian-neutral
+ .Lrot8:
+       .word 0x02010003,0x04040404,0x02010003,0x04040404
++
++.text
++
+ .globl        ChaCha20_ctr32_sve
+ .type ChaCha20_ctr32_sve,%function
+ .align        5
+@@ -744,7 +748,8 @@ ChaCha20_ctr32_sve:
+ 1:
+       cmp     $veclen,4
+       b.le    .Lreturn
+-      adr     $tmp,.Lrot8
++      adrp    $tmp,.Lrot8
++      add     $tmp,$tmp,:lo12:.Lrot8
+       ldp     $tmpw0,$tmpw1,[$tmp]
+       index   $rot8.s,$tmpw0,$tmpw1
+ 2:
+@@ -762,7 +767,8 @@ ChaCha20_ctr32_sve:
+       stp     x28,x29,[sp,160]
+       str     x30,[sp,176]
+ 
+-      adr     $tmp,.Lchacha20_consts
++      adrp    $tmp,.Lchacha20_consts
++      add     $tmp,$tmp,:lo12:.Lchacha20_consts
+       ldp     @K[0],@K[1],[$tmp]
+       ldp     @K[2],@K[3],[$key]
+       ldp     @K[4],@K[5],[$key, 16]
Index: security/openssl/3.3/patches/patch-crypto_sm3_asm_sm3-armv8_pl
===================================================================
RCS file: security/openssl/3.3/patches/patch-crypto_sm3_asm_sm3-armv8_pl
diff -N security/openssl/3.3/patches/patch-crypto_sm3_asm_sm3-armv8_pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ security/openssl/3.3/patches/patch-crypto_sm3_asm_sm3-armv8_pl      6 Feb 
2025 20:27:32 -0000
@@ -0,0 +1,21 @@
+Index: crypto/sm3/asm/sm3-armv8.pl
+--- crypto/sm3/asm/sm3-armv8.pl.orig
++++ crypto/sm3/asm/sm3-armv8.pl
+@@ -136,7 +136,8 @@ ossl_hwsm3_block_data_order:
+       ext     $state1.16b, $state1.16b, $state1.16b, #8
+       ext     $state2.16b, $state2.16b, $state2.16b, #8
+ 
+-      adr     $constaddr, .Tj
++      adrp    $constaddr, .Tj
++      add     $constaddr, $constaddr, :lo12:.Tj
+       ldp     $sconst1, $sconst2, [$constaddr]
+ 
+ .Loop:
+@@ -210,6 +211,7 @@ $code.=<<___;
+       ret
+ .size ossl_hwsm3_block_data_order,.-ossl_hwsm3_block_data_order
+ 
++.rodata
+ .align        3
+ .Tj:
+ .word 0x79cc4519, 0x9d8a7a87
Index: security/openssl/3.3/patches/patch-crypto_sm4_asm_sm4-armv8_pl
===================================================================
RCS file: security/openssl/3.3/patches/patch-crypto_sm4_asm_sm4-armv8_pl
diff -N security/openssl/3.3/patches/patch-crypto_sm4_asm_sm4-armv8_pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ security/openssl/3.3/patches/patch-crypto_sm4_asm_sm4-armv8_pl      6 Feb 
2025 20:27:32 -0000
@@ -0,0 +1,47 @@
+Index: crypto/sm4/asm/sm4-armv8.pl
+--- crypto/sm4/asm/sm4-armv8.pl.orig
++++ crypto/sm4/asm/sm4-armv8.pl
+@@ -113,7 +113,7 @@ ___
+ $code=<<___;
+ #include "arm_arch.h"
+ .arch armv8-a+crypto
+-.text
++.rodata
+ ___
+ 
+ {{{
+@@ -140,15 +140,18 @@ my ($key0,$key1,$key2,$key3,$key4,$key5,$key6,$key7)=m
+ my 
($const0,$const1,$const2,$const3,$const4,$const5,$const6,$const7)=map("v$_",(16..23));
+ my ($fkconst) = ("v24");
+ $code.=<<___;
++.text
+ .globl        ${prefix}_set_encrypt_key
+ .type ${prefix}_set_encrypt_key,%function
+ .align        5
+ ${prefix}_set_encrypt_key:
+       AARCH64_VALID_CALL_TARGET
+       ld1     {$key0.4s},[$key]
+-      adr     $tmp,.Lfk
++      adrp    $tmp,.Lfk
++      add     $tmp,$tmp,:lo12:.Lfk
+       ld1     {$fkconst.4s},[$tmp]
+-      adr     $tmp,.Lck
++      adrp    $tmp,.Lck
++      add     $tmp,$tmp,:lo12:.Lck
+       ld1     {$const0.4s,$const1.4s,$const2.4s,$const3.4s},[$tmp],64
+ ___
+       &rev32($key0, $key0);
+@@ -183,9 +186,11 @@ $code.=<<___;
+ ${prefix}_set_decrypt_key:
+       AARCH64_VALID_CALL_TARGET
+       ld1     {$key0.4s},[$key]
+-      adr     $tmp,.Lfk
++      adrp    $tmp,.Lfk
++      add     $tmp,$tmp,:lo12:.Lfk
+       ld1     {$fkconst.4s},[$tmp]
+-      adr     $tmp, .Lck
++      adrp    $tmp,.Lck
++      add     $tmp,$tmp,:lo12:.Lck
+       ld1     {$const0.4s,$const1.4s,$const2.4s,$const3.4s},[$tmp],64
+ ___
+       &rev32($key0, $key0);
Index: security/openssl/3.4/Makefile
===================================================================
RCS file: /cvs/ports/security/openssl/3.4/Makefile,v
diff -u -p -r1.2 Makefile
--- security/openssl/3.4/Makefile       7 Dec 2024 11:35:35 -0000       1.2
+++ security/openssl/3.4/Makefile       6 Feb 2025 20:27:32 -0000
@@ -8,7 +8,7 @@ V=              3.4.0
 PKGNAME=       openssl-${V}
 PKGSPEC=       openssl->=3.4v0,<3.5v0
 EPOCH=         0
-REVISION=      0
+REVISION=      1
 
 SHLIBVER=      32.0
 SHARED_LIBS=   crypto ${SHLIBVER} \
Index: security/openssl/3.4/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl
===================================================================
RCS file: 
security/openssl/3.4/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl
diff -N security/openssl/3.4/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ security/openssl/3.4/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl    
6 Feb 2025 20:27:32 -0000
@@ -0,0 +1,41 @@
+Index: crypto/chacha/asm/chacha-armv8-sve.pl
+--- crypto/chacha/asm/chacha-armv8-sve.pl.orig
++++ crypto/chacha/asm/chacha-armv8-sve.pl
+@@ -720,12 +720,16 @@ $code.=<<___;
+ .extern       OPENSSL_armcap_P
+ .hidden       OPENSSL_armcap_P
+ 
+-.text
++.rodata
++
+ .align        5
+ .Lchacha20_consts:
+ .quad 0x3320646e61707865,0x6b20657479622d32           // endian-neutral
+ .Lrot8:
+       .word 0x02010003,0x04040404,0x02010003,0x04040404
++
++.text
++
+ .globl        ChaCha20_ctr32_sve
+ .type ChaCha20_ctr32_sve,%function
+ .align        5
+@@ -744,7 +748,8 @@ ChaCha20_ctr32_sve:
+ 1:
+       cmp     $veclen,4
+       b.le    .Lreturn
+-      adr     $tmp,.Lrot8
++      adrp    $tmp,.Lrot8
++      add     $tmp,$tmp,:lo12:.Lrot8
+       ldp     $tmpw0,$tmpw1,[$tmp]
+       index   $rot8.s,$tmpw0,$tmpw1
+ 2:
+@@ -762,7 +767,8 @@ ChaCha20_ctr32_sve:
+       stp     x28,x29,[sp,160]
+       str     x30,[sp,176]
+ 
+-      adr     $tmp,.Lchacha20_consts
++      adrp    $tmp,.Lchacha20_consts
++      add     $tmp,$tmp,:lo12:.Lchacha20_consts
+       ldp     @K[0],@K[1],[$tmp]
+       ldp     @K[2],@K[3],[$key]
+       ldp     @K[4],@K[5],[$key, 16]
Index: security/openssl/3.4/patches/patch-crypto_sm3_asm_sm3-armv8_pl
===================================================================
RCS file: security/openssl/3.4/patches/patch-crypto_sm3_asm_sm3-armv8_pl
diff -N security/openssl/3.4/patches/patch-crypto_sm3_asm_sm3-armv8_pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ security/openssl/3.4/patches/patch-crypto_sm3_asm_sm3-armv8_pl      6 Feb 
2025 20:27:32 -0000
@@ -0,0 +1,21 @@
+Index: crypto/sm3/asm/sm3-armv8.pl
+--- crypto/sm3/asm/sm3-armv8.pl.orig
++++ crypto/sm3/asm/sm3-armv8.pl
+@@ -136,7 +136,8 @@ ossl_hwsm3_block_data_order:
+       ext     $state1.16b, $state1.16b, $state1.16b, #8
+       ext     $state2.16b, $state2.16b, $state2.16b, #8
+ 
+-      adr     $constaddr, .Tj
++      adrp    $constaddr, .Tj
++      add     $constaddr, $constaddr, :lo12:.Tj
+       ldp     $sconst1, $sconst2, [$constaddr]
+ 
+ .Loop:
+@@ -210,6 +211,7 @@ $code.=<<___;
+       ret
+ .size ossl_hwsm3_block_data_order,.-ossl_hwsm3_block_data_order
+ 
++.rodata
+ .align        3
+ .Tj:
+ .word 0x79cc4519, 0x9d8a7a87
Index: security/openssl/3.4/patches/patch-crypto_sm4_asm_sm4-armv8_pl
===================================================================
RCS file: security/openssl/3.4/patches/patch-crypto_sm4_asm_sm4-armv8_pl
diff -N security/openssl/3.4/patches/patch-crypto_sm4_asm_sm4-armv8_pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ security/openssl/3.4/patches/patch-crypto_sm4_asm_sm4-armv8_pl      6 Feb 
2025 20:27:32 -0000
@@ -0,0 +1,47 @@
+Index: crypto/sm4/asm/sm4-armv8.pl
+--- crypto/sm4/asm/sm4-armv8.pl.orig
++++ crypto/sm4/asm/sm4-armv8.pl
+@@ -113,7 +113,7 @@ ___
+ $code=<<___;
+ #include "arm_arch.h"
+ .arch armv8-a+crypto
+-.text
++.rodata
+ ___
+ 
+ {{{
+@@ -140,15 +140,18 @@ my ($key0,$key1,$key2,$key3,$key4,$key5,$key6,$key7)=m
+ my 
($const0,$const1,$const2,$const3,$const4,$const5,$const6,$const7)=map("v$_",(16..23));
+ my ($fkconst) = ("v24");
+ $code.=<<___;
++.text
+ .globl        ${prefix}_set_encrypt_key
+ .type ${prefix}_set_encrypt_key,%function
+ .align        5
+ ${prefix}_set_encrypt_key:
+       AARCH64_VALID_CALL_TARGET
+       ld1     {$key0.4s},[$key]
+-      adr     $tmp,.Lfk
++      adrp    $tmp,.Lfk
++      add     $tmp,$tmp,:lo12:.Lfk
+       ld1     {$fkconst.4s},[$tmp]
+-      adr     $tmp,.Lck
++      adrp    $tmp,.Lck
++      add     $tmp,$tmp,:lo12:.Lck
+       ld1     {$const0.4s,$const1.4s,$const2.4s,$const3.4s},[$tmp],64
+ ___
+       &rev32($key0, $key0);
+@@ -183,9 +186,11 @@ $code.=<<___;
+ ${prefix}_set_decrypt_key:
+       AARCH64_VALID_CALL_TARGET
+       ld1     {$key0.4s},[$key]
+-      adr     $tmp,.Lfk
++      adrp    $tmp,.Lfk
++      add     $tmp,$tmp,:lo12:.Lfk
+       ld1     {$fkconst.4s},[$tmp]
+-      adr     $tmp, .Lck
++      adrp    $tmp,.Lck
++      add     $tmp,$tmp,:lo12:.Lck
+       ld1     {$const0.4s,$const1.4s,$const2.4s,$const3.4s},[$tmp],64
+ ___
+       &rev32($key0, $key0);
Index: security/openssl/quictls/Makefile
===================================================================
RCS file: /cvs/ports/security/openssl/quictls/Makefile,v
diff -u -p -r1.13 Makefile
--- security/openssl/quictls/Makefile   7 Dec 2024 11:35:35 -0000       1.13
+++ security/openssl/quictls/Makefile   6 Feb 2025 20:27:32 -0000
@@ -9,7 +9,7 @@ V=              3.3.0
 DISTNAME=      openssl-${V}-quic1
 WRKDIST=       ${WRKDIR}/openssl-${DISTNAME}
 EOPENSSL_V=    qopenssl33
-REVISION=      0
+REVISION=      1
 
 SITES=         https://github.com/quictls/openssl/archive/refs/tags/
 PKGNAME=       quictls-${V}
Index: 
security/openssl/quictls/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl
===================================================================
RCS file: 
security/openssl/quictls/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl
diff -N 
security/openssl/quictls/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 
security/openssl/quictls/patches/patch-crypto_chacha_asm_chacha-armv8-sve_pl    
    6 Feb 2025 20:27:32 -0000
@@ -0,0 +1,41 @@
+Index: crypto/chacha/asm/chacha-armv8-sve.pl
+--- crypto/chacha/asm/chacha-armv8-sve.pl.orig
++++ crypto/chacha/asm/chacha-armv8-sve.pl
+@@ -720,12 +720,16 @@ $code.=<<___;
+ .extern       OPENSSL_armcap_P
+ .hidden       OPENSSL_armcap_P
+ 
+-.text
++.rodata
++
+ .align        5
+ .Lchacha20_consts:
+ .quad 0x3320646e61707865,0x6b20657479622d32           // endian-neutral
+ .Lrot8:
+       .word 0x02010003,0x04040404,0x02010003,0x04040404
++
++.text
++
+ .globl        ChaCha20_ctr32_sve
+ .type ChaCha20_ctr32_sve,%function
+ .align        5
+@@ -744,7 +748,8 @@ ChaCha20_ctr32_sve:
+ 1:
+       cmp     $veclen,4
+       b.le    .Lreturn
+-      adr     $tmp,.Lrot8
++      adrp    $tmp,.Lrot8
++      add     $tmp,$tmp,:lo12:.Lrot8
+       ldp     $tmpw0,$tmpw1,[$tmp]
+       index   $rot8.s,$tmpw0,$tmpw1
+ 2:
+@@ -762,7 +767,8 @@ ChaCha20_ctr32_sve:
+       stp     x28,x29,[sp,160]
+       str     x30,[sp,176]
+ 
+-      adr     $tmp,.Lchacha20_consts
++      adrp    $tmp,.Lchacha20_consts
++      add     $tmp,$tmp,:lo12:.Lchacha20_consts
+       ldp     @K[0],@K[1],[$tmp]
+       ldp     @K[2],@K[3],[$key]
+       ldp     @K[4],@K[5],[$key, 16]
Index: security/openssl/quictls/patches/patch-crypto_sm3_asm_sm3-armv8_pl
===================================================================
RCS file: security/openssl/quictls/patches/patch-crypto_sm3_asm_sm3-armv8_pl
diff -N security/openssl/quictls/patches/patch-crypto_sm3_asm_sm3-armv8_pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ security/openssl/quictls/patches/patch-crypto_sm3_asm_sm3-armv8_pl  6 Feb 
2025 20:27:32 -0000
@@ -0,0 +1,21 @@
+Index: crypto/sm3/asm/sm3-armv8.pl
+--- crypto/sm3/asm/sm3-armv8.pl.orig
++++ crypto/sm3/asm/sm3-armv8.pl
+@@ -136,7 +136,8 @@ ossl_hwsm3_block_data_order:
+       ext     $state1.16b, $state1.16b, $state1.16b, #8
+       ext     $state2.16b, $state2.16b, $state2.16b, #8
+ 
+-      adr     $constaddr, .Tj
++      adrp    $constaddr, .Tj
++      add     $constaddr, $constaddr, :lo12:.Tj
+       ldp     $sconst1, $sconst2, [$constaddr]
+ 
+ .Loop:
+@@ -210,6 +211,7 @@ $code.=<<___;
+       ret
+ .size ossl_hwsm3_block_data_order,.-ossl_hwsm3_block_data_order
+ 
++.rodata
+ .align        3
+ .Tj:
+ .word 0x79cc4519, 0x9d8a7a87
Index: security/openssl/quictls/patches/patch-crypto_sm4_asm_sm4-armv8_pl
===================================================================
RCS file: security/openssl/quictls/patches/patch-crypto_sm4_asm_sm4-armv8_pl
diff -N security/openssl/quictls/patches/patch-crypto_sm4_asm_sm4-armv8_pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ security/openssl/quictls/patches/patch-crypto_sm4_asm_sm4-armv8_pl  6 Feb 
2025 20:27:32 -0000
@@ -0,0 +1,47 @@
+Index: crypto/sm4/asm/sm4-armv8.pl
+--- crypto/sm4/asm/sm4-armv8.pl.orig
++++ crypto/sm4/asm/sm4-armv8.pl
+@@ -113,7 +113,7 @@ ___
+ $code=<<___;
+ #include "arm_arch.h"
+ .arch armv8-a+crypto
+-.text
++.rodata
+ ___
+ 
+ {{{
+@@ -140,15 +140,18 @@ my ($key0,$key1,$key2,$key3,$key4,$key5,$key6,$key7)=m
+ my 
($const0,$const1,$const2,$const3,$const4,$const5,$const6,$const7)=map("v$_",(16..23));
+ my ($fkconst) = ("v24");
+ $code.=<<___;
++.text
+ .globl        ${prefix}_set_encrypt_key
+ .type ${prefix}_set_encrypt_key,%function
+ .align        5
+ ${prefix}_set_encrypt_key:
+       AARCH64_VALID_CALL_TARGET
+       ld1     {$key0.4s},[$key]
+-      adr     $tmp,.Lfk
++      adrp    $tmp,.Lfk
++      add     $tmp,$tmp,:lo12:.Lfk
+       ld1     {$fkconst.4s},[$tmp]
+-      adr     $tmp,.Lck
++      adrp    $tmp,.Lck
++      add     $tmp,$tmp,:lo12:.Lck
+       ld1     {$const0.4s,$const1.4s,$const2.4s,$const3.4s},[$tmp],64
+ ___
+       &rev32($key0, $key0);
+@@ -183,9 +186,11 @@ $code.=<<___;
+ ${prefix}_set_decrypt_key:
+       AARCH64_VALID_CALL_TARGET
+       ld1     {$key0.4s},[$key]
+-      adr     $tmp,.Lfk
++      adrp    $tmp,.Lfk
++      add     $tmp,$tmp,:lo12:.Lfk
+       ld1     {$fkconst.4s},[$tmp]
+-      adr     $tmp, .Lck
++      adrp    $tmp,.Lck
++      add     $tmp,$tmp,:lo12:.Lck
+       ld1     {$const0.4s,$const1.4s,$const2.4s,$const3.4s},[$tmp],64
+ ___
+       &rev32($key0, $key0);

Reply via email to