Skip to content

Commit f9acf84

Browse files
committed
Patch OpenSSL 3.5 to hardcode the vlenb CSR address on RISC-V
Our GCC version doesn't know it, so replace the `vlenb` variable with `0xc22`. See openssl/openssl#23011.
1 parent cc6f971 commit f9acf84

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

cpython-unix/build-openssl-3.5.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ tar -xf openssl-${OPENSSL_3_5_VERSION}.tar.gz
1313

1414
pushd openssl-${OPENSSL_3_5_VERSION}
1515

16+
# hardcode the vlenb CSR address (0xc22) as our GCC version doesn't know it
17+
# https://github.com/riscv/riscv-isa-manual/blob/c001fa237cdd8b6079384044462a89eb0e3fd9cf/src/v-st-ext.adoc?plain=1#L74
18+
if [[ "${TARGET_TRIPLE}" = "riscv64-unknown-linux-gnu" ]]; then
19+
patch -p1 -i "${ROOT}/patch-openssl-3.5-riscv-vlenb-register.patch"
20+
fi
21+
1622
# Otherwise it gets set to /tools/deps/ssl by default.
1723
case "${TARGET_TRIPLE}" in
1824
*apple*)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/crypto/riscv64cpuid.pl b/crypto/riscv64cpuid.pl
2+
index 5dcdc5c584..7751ad50d9 100644
3+
--- a/crypto/riscv64cpuid.pl
4+
+++ b/crypto/riscv64cpuid.pl
5+
@@ -94,8 +94,8 @@ $code .= <<___;
6+
.globl riscv_vlen_asm
7+
.type riscv_vlen_asm,\@function
8+
riscv_vlen_asm:
9+
- csrr $ret, vlenb
10+
- slli $ret, $ret, 3
11+
+ csrr a0, 0xc22
12+
+ slli a0, a0, 3
13+
ret
14+
.size riscv_vlen_asm,.-riscv_vlen_asm
15+
___

0 commit comments

Comments
 (0)