Bug in PMP register region bound checking #585
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
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:
cv32e40p/rtl/cv32e40p_pmp.sv
Line 600 in 2b7cd10
cv32e40p/rtl/cv32e40p_pmp.sv
Line 615 in 2b7cd10
cv32e40p/rtl/cv32e40p_pmp.sv
Line 730 in 2b7cd10
cv32e40p/rtl/cv32e40p_pmp.sv
Line 744 in 2b7cd10
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.
The text was updated successfully, but these errors were encountered: