Skip to content

Update QEMU implementation #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 175 commits into from
Jul 22, 2025

Conversation

loiclefort
Copy link

  • Add initial support for dynamic clock management (clocks can be modified at runtime rather than build time). Clock tree follows OpenTitan HW: AST --> Clock Manager --> Devices. Clock gating/hinting is not yet supported
  • Improve LC controller implementation
  • Add code execution disablement
  • Darjeeling KeyManager DPE with AES/KMAC/OTBN sideloading
  • Bug fixing

rivos-eblot and others added 30 commits July 7, 2025 12:45
Use the PMP implementation from v9.2.0

Signed-off-by: Rob Bradford <[email protected]>
When running in TOR mode (Top of Range) the next PMP entry controls
whether the entry is locked. However simply checking if the PMP_LOCK bit
is set is not sufficient with the Smepmp extension which now provides a
bit (mseccfg.RLB (Rule Lock Bypass)) to disregard the lock bits. In
order to respect this bit use the convenience pmp_is_locked() function
rather than directly checking PMP_LOCK since this function checks
mseccfg.RLB.

Signed-off-by: Rob Bradford <[email protected]>
When Smepmp is supported, mseccfg.RLB allows bypassing locks when writing CSRs
but should not affect interpretation of actual PMP rules.

This is not the case with the current implementation where pmp_hart_has_privs
calls pmp_is_locked which implements mseccfg.RLB bypass.

This commit implements the correct behavior by removing mseccfg.RLB bypass from
pmp_is_locked.

RLB bypass when writing CSRs is implemented by adding a new pmp_is_readonly
function that calls pmp_is_locked and check mseccfg.RLB. pmp_write_cfg and
pmpaddr_csr_write are changed to use this new function.

Signed-off-by: Loïc Lefort <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: LIU Zhiwei  <[email protected]>
Message-ID: <[email protected]>
…function

Signed-off-by: Loïc Lefort <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: LIU Zhiwei <[email protected]>
Message-ID: <[email protected]>
… MML mode

With Machine Mode Lockdown (mseccfg.MML) set and RLB not set, checks on pmpcfg
writes would match the wrong cases of Smepmp truth table.

The existing code allows writes for the following cases:
- L=1, X=0: cases 8, 10, 12, 14
- L=0, RWX!=WX: cases 0-2, 4-6
This leaves cases 3, 7, 9, 11, 13, 15 for which writes are ignored.

From the Smepmp specification: "Adding a rule with executable privileges that
either is M-mode-only or a locked Shared-Region is not possible (...)" This
description matches cases 9-11, 13 of the truth table.

This commit implements an explicit check for these cases by using
pmp_get_epmp_operation to convert between PMP configuration and Smepmp truth
table cases.

Signed-off-by: Loïc Lefort <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: LIU Zhiwei <[email protected]>
Message-ID: <[email protected]>
…hanged

Signed-off-by: Loïc Lefort <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: LIU Zhiwei <[email protected]>
Message-ID: <[email protected]>
Remove useless check in pmp_is_locked, the function will return 0 in either
case.

Signed-off-by: Loïc Lefort <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: LIU Zhiwei <[email protected]>
Message-ID: <[email protected]>
- re-organize code to follow the common function order for all OT devices
- prepare for clock management upgrade

Signed-off-by: Emmanuel Blot <[email protected]>
Some devices may disable instruction fetch while keeping data access.

Signed-off-by: Emmanuel Blot <[email protected]>
If no OTP file is in use, default to enabling execution from SRAM.

Signed-off-by: Emmanuel Blot <[email protected]>
Instruction fetch management is handled with ot_vmapper.

Signed-off-by: Emmanuel Blot <[email protected]>
Instruction fetch management is handled with ot_vmapper.

Signed-off-by: Emmanuel Blot <[email protected]>
* EG_252 matches EarlGrey 2.5.2-rc0, which is the first supported version
  of QEMU OpenTitan emulation
* DJ_PRE is the initial Darjeeling version based on EarlGrey 2.5.2-rc0

Signed-off-by: Emmanuel Blot <[email protected]>
* EG_252 matches EarlGrey 2.5.2-rc0, which is the first supported version
  of QEMU OpenTitan emulation
* DJ_PRE is the initial Darjeeling version based on EarlGrey 2.5.2-rc0

Signed-off-by: Emmanuel Blot <[email protected]>
…ontrol warning

Some SRAM controller may never be associated with an ot_vmapper, leading to
recurrent warnings.

Signed-off-by: Emmanuel Blot <[email protected]>
With multiple Debug Module, it is sometimes useful to track down where
DTM requests are routed to.

Signed-off-by: Emmanuel Blot <[email protected]>
Address a misunderstanding in RISC-V debug spec 0.13.2:

DMCONTROL.dmactive bit should not be automatically reverted back to 1
once is reset is completed: it seems it is up to the remote debugger to
release the DM from the reset state, which is now implemented as such.

Signed-off-by: Emmanuel Blot <[email protected]>
…dress

for debug/trace purposes

Signed-off-by: Emmanuel Blot <[email protected]>
rivos-eblot and others added 26 commits July 22, 2025 19:42
…methods

These should enable providing data extraction method to other modules.

Signed-off-by: Emmanuel Blot <[email protected]>
…ation

Not yet fully tested.

Signed-off-by: Emmanuel Blot <[email protected]>
It should be used to report an invalid parsed argument, to delegate
ArgumentParser validation to modules.

Signed-off-by: Emmanuel Blot <[email protected]>
… a single test

When define as a test option, the VCP port are also logged into an additional file.
It is possible to use a temporary file to perform post-analysis of the UART outputs

Signed-off-by: Emmanuel Blot <[email protected]>
Allow commit line to start with "FROMLIST:" to indicate a commit cherry-picked
from a mailing list.

Signed-off-by: Loïc Lefort <[email protected]>
@loiclefort loiclefort requested a review from rivos-eblot July 22, 2025 18:08
Copy link

@rivos-eblot rivos-eblot left a comment

Choose a reason for hiding this comment

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

See #156

@loiclefort loiclefort merged commit 0f1e87b into lowRISC:ot-earlgrey-9.2.0 Jul 22, 2025
14 checks passed
@loiclefort loiclefort deleted the dev/loic/resync_on_dj branch July 22, 2025 18:26
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.

3 participants