Skip to content

riscv: fix RV32 issues found during validation#30733

Open
cmuellner wants to merge 3 commits intoopenssl:masterfrom
cmuellner:rv32-fixes
Open

riscv: fix RV32 issues found during validation#30733
cmuellner wants to merge 3 commits intoopenssl:masterfrom
cmuellner:rv32-fixes

Conversation

@cmuellner
Copy link
Copy Markdown
Contributor

This PR fixes several RV32 issues found while validating the RISC-V crypto backends on current master.

Changes:

  • fix size_t formatting for the reported RISC-V vector length
  • fix an RV32 AES-XTS function-pointer assignment that fails under strict/pedantic builds
  • add OPENSSL_riscvcap(3) RV32 example

The first two changes are real build/portability fixes for RV32.
The documentation cleanup is small, but came out of the same validation pass.

Validation:

  • local RV32/RV64 RISC-V matrix passed after these fixes

Note that RV32 is not fully supported as a target because Ubuntu lacks an RV32 cross-toolchain package.
Also, I don't think there are many real HW RV32 SoCs targeting Linux.
However, we should still keep an eye on it.

Checklist
  • documentation is added or updated
  • tests are added or updated

Use %zu when formatting riscv_vlen() in the CPU info string.
On RV32, riscv_vlen() returns size_t backed by unsigned int,
so %lu triggers -Werror=format during the build.

This keeps the RV32 build aligned with the existing size_t
interface.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
@github-actions github-actions Bot added the severity: fips change The pull request changes FIPS provider sources label Apr 8, 2026
Cast the XTS stream selection operands to OSSL_xts_stream_fn
before assigning them to the provider context.

On RV32, the Zknd/Zkne XTS paths pass NULL stream callbacks.
Without the cast, the conditional expression is treated as void *
and fails under -Werror=pedantic.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
This adds an example that shows how to set OPENSSL_riscvcap
for an "rv32gc" ISA string.
This documents that the mechanism works for RV32 as well as RV64.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
@openssl-machine openssl-machine added the approval: review pending This pull request needs review by a committer label Apr 8, 2026
@cmuellner
Copy link
Copy Markdown
Contributor Author

CI/CD failed because of formatting issues.
I will fix this, but the diff for the AES-XTS commit will grow as I need to address the formatting issue in the original code.

@cmuellner
Copy link
Copy Markdown
Contributor Author

@ZenithalHourlyRate and @paulidale, please review.

@esyr
Copy link
Copy Markdown
Member

esyr commented Apr 8, 2026

I guess it is worth adding RV32 to the CI matrix as well.

@cmuellner
Copy link
Copy Markdown
Contributor Author

I guess it is worth adding RV32 to the CI matrix as well.

There is no RV32 cross compiler in Ubuntu.
Building our own toolchain in a CI/CD test run feels like overkill.

Copy link
Copy Markdown
Contributor

@ZenithalHourlyRate ZenithalHourlyRate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the code changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: review pending This pull request needs review by a committer severity: fips change The pull request changes FIPS provider sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants