forked from bluespec/Flute
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of cap PTE bits
- Loading branch information
Showing
3 changed files
with
45 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,7 +270,8 @@ Integer pte_U_offset = 4; // Accessible-to-user-mode | |
Integer pte_G_offset = 5; // Global mapping | ||
Integer pte_A_offset = 6; // Accessed | ||
Integer pte_D_offset = 7; // Dirty | ||
Integer pte_RSW_offset = 8; // Reserved for supervisor SW | ||
Integer pte_cap_W_offset = 8; | ||
Integer pte_cap_R_offset = 9; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
PeterRugg
Author
Collaborator
|
||
|
||
`ifdef RV32 | ||
Integer pte_PPN_0_offset = 10; | ||
|
@@ -313,6 +314,14 @@ function Bit #(1) fn_PTE_to_D (PTE pte); | |
return pte [pte_D_offset]; | ||
endfunction | ||
|
||
function Bit #(1) fn_PTE_to_cap_W (PTE pte); | ||
return pte [pte_cap_W_offset]; | ||
endfunction | ||
|
||
function Bit #(1) fn_PTE_to_cap_R (PTE pte); | ||
return pte [pte_cap_R_offset]; | ||
endfunction | ||
|
||
function PPN fn_PTE_to_PPN (PTE pte); | ||
return pte [ppn_sz + pte_PPN_0_offset - 1 : pte_PPN_0_offset]; | ||
endfunction | ||
|
@@ -355,6 +364,7 @@ endfunction | |
|
||
function Bool is_pte_denial (Bool dmem_not_imem, // load-store or fetch? | ||
Bool read_not_write, | ||
Bool capability, | ||
Priv_Mode priv, | ||
Bit #(1) sstatus_SUM, | ||
Bit #(1) mstatus_MXR, | ||
|
@@ -365,21 +375,28 @@ function Bool is_pte_denial (Bool dmem_not_imem, // load-store or f | |
let pte_w = fn_PTE_to_W (pte); | ||
let pte_r = fn_PTE_to_R (pte); | ||
|
||
let pte_cap_w = fn_PTE_to_cap_W(pte); | ||
// pte_cap_r would not cause a denial | ||
|
||
Bool priv_deny = ( ((priv == u_Priv_Mode) && (pte_u == 1'b0)) | ||
|| ((priv == s_Priv_Mode) && (pte_u == 1'b1) && (sstatus_SUM == 1'b0))); | ||
|
||
Bool access_fetch = ((! dmem_not_imem) && read_not_write); | ||
Bool access_load = (dmem_not_imem && read_not_write); | ||
Bool access_store = (dmem_not_imem && (! read_not_write)); | ||
Bool access_cap = (dmem_not_imem && capability); | ||
|
||
let pte_r_mxr = (pte_r | (mstatus_MXR & pte_x)); | ||
|
||
Bool access_ok = ( (access_fetch && (pte_x == 1'b1)) | ||
|| (access_load && (pte_r_mxr == 1'b1)) | ||
|| (access_store && (pte_w == 1'b1))); | ||
|
||
|
||
return (priv_deny || (! access_ok)); | ||
Bool access_cap_ok = (! capability) | ||
|| (access_load) | ||
|| (access_store && (pte_cap_w == 1'b1)); | ||
|
||
return (priv_deny || (! access_ok) || (! access_cap_ok)); | ||
endfunction | ||
|
||
// ---------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These disagree with Sail (CTSRD-CHERI/sail-cheri-riscv@6fcae43), which places the StoreCap permission at 63 and the LoadCap permission at 62 in the PTE and leaves the RSW field alone. Confusingly, those (bits 63 and 62) are offsets 9 and 8 in the extended PTE flags field (
extPte
) in Sail, while RSW is offsets 9 and 8 in the base field (pteAttribs
).CTSRD-CHERI/sail-cheri-riscv#18 negates the sense of the StoreCap and LoadCap permissions to be inhibits, as done on CHERI-MIPS.
I don't particularly mind where the bits end up, really, but we should be consistent. (Though I think I like the high end a little better as it seems to me that a RSW field is likely a kind thing to provide for SW.)