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

[pentest] Make iCache/dummy instr. enable/disable configurable #26535

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

nasahlpa
Copy link
Member

@nasahlpa nasahlpa commented Mar 6, 2025

Previously, in all pentests, the icache as well as the dummy instructions were disabled to achieve constant timing between test runs. However, for certain tests, we want to test with iCache or with dummy instructions enabled. Make this configurable in the init function of the tests.

@nasahlpa nasahlpa marked this pull request as ready for review March 6, 2025 13:52
@nasahlpa nasahlpa requested a review from a team as a code owner March 6, 2025 13:52
@nasahlpa nasahlpa requested review from engdoreis and vogelpi and removed request for a team March 6, 2025 13:52
Copy link
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

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

LGTM with one question. Thanks @nasahlpa !

Comment on lines -316 to +326
cpuctrl_csr = bitfield_field32_write(
cpuctrl_csr, (bitfield_field32_t){.mask = 0x1, .index = 0}, 0);
if (disable_icache) {
cpuctrl_csr = bitfield_field32_write(
cpuctrl_csr, (bitfield_field32_t){.mask = 0x1, .index = 0}, 0);
}

// Disable dummy instructions.
cpuctrl_csr = bitfield_field32_write(
cpuctrl_csr, (bitfield_field32_t){.mask = 0x1, .index = 2}, 0);
if (disable_dummy_instr) {
cpuctrl_csr = bitfield_field32_write(
cpuctrl_csr, (bitfield_field32_t){.mask = 0x1, .index = 2}, 0);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

The reset value for this register is all 0: https://ibex-core.readthedocs.io/en/latest/03_reference/cs_registers.html#cpu-control-and-status-register-cpuctrlsts

I guess there is maybe some ROM code to enable the iCache and Dummy instructions. Or should we actually change the function here to enable it if the disable is not set? I would like to avoid that we don't set the disable (and think the cache is enabled) while it's actually disabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are totally right, this is a bit misleading. Yes, the iCache and dummy instructions are configured in the ROM.

In our case, the security evaluator is interested in the following:

  • Test the chip without iCache and/or dummy instructions
  • Test the chip with the configuration set in the ROM

So the evaluator does not necessarily know the default configuration. Hence, I'd leave it as it is (you only can disable it or keep the default config) and update the description of the function.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is reasonable. Thanks for explaining!

@nasahlpa nasahlpa force-pushed the pentest_icache_dummy branch 2 times, most recently from e546e0b to 396a98d Compare March 6, 2025 15:53
Previously, in all pentests, the icache as well as the dummy instructions
were disabled to achieve constant timing between test runs. However, for
certain tests, we want to test the default iCache and dummy instruction
configuration that has been set in the ROM.

Signed-off-by: Pascal Nasahl <[email protected]>
@nasahlpa nasahlpa force-pushed the pentest_icache_dummy branch from 396a98d to 6980ffc Compare March 6, 2025 15:56
@nasahlpa nasahlpa merged commit e4cccb7 into lowRISC:master Mar 6, 2025
42 checks passed
@nasahlpa nasahlpa deleted the pentest_icache_dummy branch March 6, 2025 21:16
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