Skip to content

Conversation

@rivos-eblot
Copy link

Support ot_entropy_src v2 and v3, using a property to select the emulated version.

Rework & clean up random/noise sources management, now that both tops are using the same entropy stack.

@rivos-eblot rivos-eblot force-pushed the dev/ebl/entropy_src_fixes branch from 30ea9b6 to 48d5715 Compare October 23, 2025 17:58
@rivos-eblot rivos-eblot requested review from AlexJones0, jwnrt, loiclefort and ziuziakowska and removed request for AlexJones0 and jwnrt October 24, 2025 07:15
@rivos-eblot rivos-eblot force-pushed the dev/ebl/entropy_src_fixes branch from 48d5715 to a44f0ba Compare October 24, 2025 07:35
Copy link

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

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

(only looked at the first commit for now because I didn't realise it was still a draft)

@rivos-eblot
Copy link
Author

(only looked at the first commit for now because I didn't realise it was still a draft)

I was eagerly waiting for the results from the EG CI before removing the flag :-)

@rivos-eblot rivos-eblot marked this pull request as ready for review October 24, 2025 12:25
@rivos-eblot
Copy link
Author

It seems there is one single test failing:

//sw/device/silicon_creator/rom_ext/e2e/ownership:invalid_key_alg_activate_request_test_sim_qemu_rom_ext

@rivos-eblot rivos-eblot force-pushed the dev/ebl/entropy_src_fixes branch from a44f0ba to e765107 Compare October 28, 2025 13:19
@rivos-eblot
Copy link
Author

(rebase after OT_OTP update)

@rivos-eblot rivos-eblot changed the title ot_entropy_src unify implementations from EarlGrey and Darjeeling ot_entropy_src: unify implementations from EarlGrey and Darjeeling Oct 28, 2025
@rivos-eblot rivos-eblot force-pushed the dev/ebl/entropy_src_fixes branch from e765107 to 4f0d11b Compare October 29, 2025 09:57
…ions

- remove deprecated Darjeeling version
- rename EarlGrey version as unique entropy src implementation
- update machine definitions and dependencies

Note that EarlGrey-1.0.0 version uses v2 while Darjeeling master uses v3,
so execution of Darjeeling machine is broken for now, till the implementation
also supports v3

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
@rivos-eblot rivos-eblot force-pushed the dev/ebl/entropy_src_fixes branch from 4f0d11b to d078d01 Compare October 29, 2025 10:04
Copy link

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

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

Thanks, this LGTM. The CI failure in newversion_pq_downgrade_test looks unrelated (albeit I'm not sure why it failed, it doesn't look like the normal timing error) as it passes fine when I test locally.

Support either version 2 or 3. Both versions are mostly similar, however a "REV" register
has been added in v2 then removed in v3. This register stands at the 8th register slot.
This causes most of the register map to shift down on v3 compared to v2. The version
upgrade also introduces a couple of bitfield permutations and width changes in other
registers.

Add a new property to select the version to use.

To address the register map shifting, split the register map in 3 segments:
* lo: for registers before the REV register, whose base address is the same for both
  versions
* rev: for the register which has been introduced in v2 and removed in v3
* hi: for the registers located after the REV register, whose base address depends
  on the presence of the REV register, i.e. whether emulutating v2 or v3
Use QEMU sub memory regions to map each register segment to the proper location based
on the selected version. The addresses of each segment defined with REG32 macros are
made relative to the start location of the matching segment. Traces reporting addresses
are updated with the base address of each segment to preserve the "natural" address of
each register. In order to avoid many offset computations and degrade code readability,
also split the register array to support on array for each segment.

Update macros to use the select the proper segment while addressing the register content.

To address the register bitfield permutations/widening, as the scope of these changes is
limited, simply dispatch handling based on the selected version.

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
Both EarlGrey and Darjeeling now use the EntropySrc to obtain entropy,
whereas previous Darjeeling implementation was collecting entropy from
the AST.

Rework the EntropySrc class to expose a method to provide entropy to the
CSRNG, and update CSRNG to use this "unique" entropy source.

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
Remove deprecated states, update state magic values

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
…ct ot_entropy_src calls

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
…vider

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
replace the direct ot_ast_eg calls with the new abstract interface

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
…tation

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
it is no longer useful

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
- configure entropy src version
- replace random src interface with entropy src
- replace entropy src noise source

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
- configure entropy src version
- replace random src interface with entropy src
- replace entropy src noise source

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
Move the en_csrng_sw_app_read field to where it belongs: OtOTPHWCfg

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
…bit booleans

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
…oke test

Introduced in 5d9dfd6

Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
@rivos-eblot rivos-eblot force-pushed the dev/ebl/entropy_src_fixes branch from d078d01 to cf90a32 Compare October 29, 2025 12:44
@rivos-eblot rivos-eblot merged commit 0999199 into lowRISC:ot-9.2.0 Oct 29, 2025
9 of 10 checks passed
@rivos-eblot rivos-eblot deleted the dev/ebl/entropy_src_fixes branch October 29, 2025 13:29
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