Skip to content

Fix wrong v2 hashes on big-endian PPC64 with VSX - #345

Merged
SChernykh merged 2 commits into
tevador:masterfrom
thomasbuilds:fix-ppc64be-v2-casts
Oct 13, 2026
Merged

SChernykh merged 2 commits into
tevador:masterfrom
thomasbuilds:fix-ppc64be-v2-casts

Conversation

@thomasbuilds

Copy link
Copy Markdown
Contributor

On big-endian PPC64 builds with VSX (-mcpu=power7 or newer) the interpreter computes wrong RandomX v2 hashes. v1 is not affected.

The v2 F/E mixing converts registers between rx_vec_f128 and rx_vec_i128 with rx_cast_vec_f2i/rx_cast_vec_i2f, which the PPC64 branch implements as plain reinterpretations. On big-endian, rx_vec_f128 is built from 64-bit lanes and rx_vec_i128 from 32-bit lanes, so the reinterpretation swaps the two 32-bit halves of each 64-bit lane and the AES rounds operate on a permuted state.

This PR swaps the halves back on big-endian, adds a round-trip test for the casts, and removes two unused helpers (rx_vec_i128_vec_f128, rx_set1_long_vec_i128) that have the same big-endian bug.

@cyrozap is credited as co-author because I found afterwards the cast fix is identical to his commit ee98798 in #320, where it is bundled with the PPC64 JIT.

@SChernykh
SChernykh merged commit c866c15 into tevador:master Oct 13, 2026
10 of 18 checks passed
SChernykh pushed a commit to SChernykh/RandomX that referenced this pull request Oct 14, 2026
* Fix v2 F/E mixing on big-endian PPC64 with VSX

Co-authored-by: cyrozap <cyrozap@gmail.com>

* Remove unused vector helpers that are wrong on big-endian

---------

Co-authored-by: cyrozap <cyrozap@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants