Skip to content
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

[ot] Define (unused) OTP scrambling properties for EG #122

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

jwnrt
Copy link

@jwnrt jwnrt commented Jan 28, 2025

Earl Grey does not support OTP scrambling and does not have these parameters declared. QEMU complains when they are provided by the INI file generated by `cfggen.py.

This PR declares the properties but does not use them to silence this warning. It also removes the default values set in ot_{darjeeling,earlgrey} to avoid silent misconfigurations if these change.

I did not notice that this was an issue before because I've been erroneously using -T earlgrey and not EarlGrey so the table was called ot-otp-e and wasn't being used.

@jwnrt jwnrt requested a review from rivos-eblot January 28, 2025 13:16
@rivos-eblot
Copy link

rivos-eblot commented Jan 28, 2025

I did not notice that this was an issue before because I've been erroneously using -T earlgrey and not EarlGrey so the table was called ot-otp-e and wasn't being used.

Have you tried with the latest cfggen.py version? There was a leftover opentitan[0] in the initial change for #117 but it has been addressed before the merge. If not, there is another issue :-(

@rivos-eblot
Copy link

Temporarily disable these constants for Earl Grey.

Would it be better to define and not use yet those properties in ot_otp_eg rather than adding a special case in the script (I may have miss something though)?

@jwnrt
Copy link
Author

jwnrt commented Jan 28, 2025

Have you tried with the latest cfggen.py version?

Yes, here's the generated file from the latest ot-earlgrey-9.1.0 and OpenTitan master:

$ scripts/opentitan/cfggen.py ~/projects/opentitan -T earlgrey -o cfg.ini
[ot_device "ot-otp-eg"]
  digest_const = "e95f517cb98955b4d5a89aa9109294a"
  digest_iv = "bead91d5fa4e0915"
  sram_const = "4a22d4b78fe0266fbee3958332f2939b"
  sram_iv = "f98c48b1f9377284"

[ot_device "ot-lc_ctrl"]
  lc_state_first = "ee75b407d2314d2ef84185ac8c990f536071632c086d4c924070be92d2948d6228b2711e9b2d8c4d"
  lc_state_last = "ee75fe0ffe7b6f3ffc5f9ffd9ff96fdb7f736f6c9e6fdcd35277fef2d3bdcd6ffbb2f59fdf3fbedd"
  lc_trscnt_first = "dfb6c45a241f85ce9f42229e8627462fdb02c6701242f14b41891180045c09c26c52744267c04aa055921b9461bb07da"
  lc_trscnt_last = "dfb6f4fabf1fefcebf5ba2ffc677c6afdbabcefeb672f36b4fbdb3988dfe1be67e7e77ca77c76af7ddde3b9e7fbfe7de"
  ownership_first = "3c61398d626885931da660ed2ab18a0f"
  ownership_last = "bc757dbdeaf9b7d35de7e9efabfbbecf"
  raw_unlock_token = "ea2b3f32cbe77554e43c8ea7ebf197c2"
  socdbg_first = "440af80d"
  socdbg_last = "6c9ef9cf"

I also noticed that:

  • the ot-rom_ctrl table has been removed, is that intentional?
  • the ot-otp-eg.scrmbl_key field has been removed. This might be due to upstream OpenTitan changes moving this to another file?

@jwnrt
Copy link
Author

jwnrt commented Jan 28, 2025

Temporarily disable these constants for Earl Grey.

Would it be better to define and not use yet those properties in ot_otp_eg rather than adding a special case in the script (I may have miss something though)?

Yes, this is probably a better solution, I just went with a quicker hack. I can do this properly if you'd prefer.

@rivos-eblot
Copy link

Yes

No sure to what it applies :) Is it ok now?

  • the ot-rom_ctrl table has been removed, is that intentional?
  • the ot-otp-eg.scrmbl_key field has been removed. This might be due to upstream OpenTitan changes moving this to another file?

No, not intentional. I'll have a look at both these issues.

@rivos-eblot
Copy link

rivos-eblot commented Jan 28, 2025

Yes, this is probably a better solution, I just went with a quicker hack. I can do this properly if you'd prefer.

Since we want to deliver it to the master branch, I think it would be better yes, thanks.
I think it would be also safer to remove the default values in the ot_earlgrey.c as well, so that if no config file is provided, OTP fails rather than massaging data with the wrong values, which could cause some debug headaches :). I initially kept them so the command line was simpler, but there are now too many configuration parameters for OTP. This was a bad idea :)

@jwnrt
Copy link
Author

jwnrt commented Jan 28, 2025

No sure to what it applies :) Is it ok now?

I've fixed my original comment

@jwnrt jwnrt force-pushed the cfggen-disable-ot-otp-eg branch from 66bc941 to b3d41a9 Compare January 28, 2025 13:55
@jwnrt
Copy link
Author

jwnrt commented Jan 28, 2025

I've updated the PR, the properties are now declared but not used in EG and I've removed the default values for DJ. I haven't tested DJ, but I can see warnings in otp_ctrl_dj.c already so I think this is handled.

hw/opentitan/ot_otp_eg.c Outdated Show resolved Hide resolved
hw/opentitan/ot_otp_eg.c Outdated Show resolved Hide resolved
jwnrt added 2 commits January 28, 2025 14:13
These are currently unused but we should declare them so that the table
of constants generated by `cfggen.py` continues working.

Signed-off-by: James Wainwright <[email protected]>
Providing defaults here could be error prone. Instead, require that
these properties are set by the `cfggen.py` INI file.

There is already a trace in `ot_otp_dj_configure_scrmbl_key` and
`ot_otp_dj_configure_digest` when these properties are not set.

Signed-off-by: James Wainwright <[email protected]>
@jwnrt jwnrt force-pushed the cfggen-disable-ot-otp-eg branch from b3d41a9 to b883eec Compare January 28, 2025 14:13
@jwnrt jwnrt requested a review from rivos-eblot January 28, 2025 14:13
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.

LGTM

@jwnrt jwnrt requested a review from AlexJones0 January 28, 2025 14:19
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.

LGTM, thanks @jwnrt.

@jwnrt jwnrt merged commit b102b7c into lowRISC:ot-earlgrey-9.1.0 Jan 28, 2025
7 checks passed
@rivos-eblot
Copy link

nit pick: maybe update the PR title, as there is no more changes in cfggen.py

@rivos-eblot
Copy link

No, not intentional. I'll have a look at both these issues.

Both are due to a regression I've unfortunately added with #117. Working in on a patch

@jwnrt jwnrt changed the title [ot] scripts/opentitan: cfggen: disable OTP consts for EG [ot] Define (unused) OTP scrambling properties for EG Jan 28, 2025
@rivos-eblot
Copy link

Both are due to a regression I've unfortunately added with #117. Working in on a patch

#124

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