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

Bug in PMP register region bound checking #585

Open
kangoojim opened this issue Nov 20, 2020 · 1 comment
Open

Bug in PMP register region bound checking #585

kangoojim opened this issue Nov 20, 2020 · 1 comment
Labels
Component:RTL For issues in the RTL (e.g. for files in the rtl directory) Type:Bug For bugs in the RTL, Documentation, Verification environment or Tool and Build system WAIVED:CV32E40P Issue does not impact a major release of CV32E40P and is waived

Comments

@kangoojim
Copy link

Hi,
I revisited the core since I reported this issue #392 in the PMP and I found a new bug/incompliance, also in the PMP. I know, it is not part of the current design, but maybe a report is still valuable for future secure versions of the core.

The ISA (Privileged Spec v. 20190608) states (on pages 49 and 50) that the contents of the (32 bit) PMP address registers encode bits [33:2] of a 34 bit physical address.
The PMP implementation, however, checks for NA4 and NAPOT only whether an address of a current access matches bits [29:0] of the configured region bounds. See the following lines:

if ( data_addr_i[31:2] == start_addr[j][29:0] )

if ( (data_addr_i[31:2] & mask_addr[j][29:0]) == start_addr[j][29:0] )

if ( instr_addr_i[31:2] == start_addr[k][29:0] )

if ( (instr_addr_i[31:2] & mask_addr[k][29:0]) == start_addr[k][29:0] )

By ignoring the two most significant bits of the PMP address registers, entries with the most significant bits != 2'b00 can match addresses outside of their regions. The issue can be easily fixed by replacing the lines with:

if ( {2'b00, data_addr_i[31:2]} == start_addr[j] )
and
if ( {2'b00, (data_addr_i[31:2] & mask_addr[j][29:0])} == start_addr[j] )
etc.

@Silabs-ArjanB
Copy link
Contributor

Hi @kangoojim , thank you for the detailed bug report. We will certainly address it in a core including PMP.

@Silabs-ArjanB Silabs-ArjanB added Component:RTL For issues in the RTL (e.g. for files in the rtl directory) Type:Bug For bugs in the RTL, Documentation, Verification environment or Tool and Build system WAIVED:CV32E40P Issue does not impact a major release of CV32E40P and is waived labels Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component:RTL For issues in the RTL (e.g. for files in the rtl directory) Type:Bug For bugs in the RTL, Documentation, Verification environment or Tool and Build system WAIVED:CV32E40P Issue does not impact a major release of CV32E40P and is waived
Projects
None yet
Development

No branches or pull requests

2 participants