-
Notifications
You must be signed in to change notification settings - Fork 29
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
Added STIDC and UTIDC registers #247
base: qemu-cheri
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,25 +50,35 @@ | |
enum SCRAccessMode { | ||
SCR_Invalid = 0, | ||
ASR_Flag = 1, | ||
U_Always = (PRV_U + 1) << 1, | ||
U_ASR = U_Always | ASR_Flag, | ||
S_Always = (PRV_S + 1) << 1, | ||
S_ASR = S_Always | ASR_Flag, | ||
H_Always = (PRV_H + 1) << 1, | ||
H_ASR = H_Always | ASR_Flag, | ||
M_Always = (PRV_M + 1) << 1, | ||
M_ASR = M_Always | ASR_Flag, | ||
ASR_W_Flag = 2, | ||
U_Always = (PRV_U + 1) << 2, | ||
U_ASR_W = U_Always | ASR_W_Flag, | ||
U_ASR = U_ASR_W | ASR_Flag, | ||
S_Always = (PRV_S + 1) << 2, | ||
S_ASR_W = S_Always | ASR_W_Flag, | ||
S_ASR = S_ASR_W | ASR_Flag, | ||
H_Always = (PRV_H + 1) << 2, | ||
H_ASR_W = H_Always | ASR_W_Flag, | ||
H_ASR = H_ASR_W | ASR_Flag, | ||
M_Always = (PRV_M + 1) << 2, | ||
M_ASR_W = M_Always | ASR_W_Flag, | ||
M_ASR = M_ASR_W | ASR_Flag, | ||
}; | ||
|
||
static inline int scr_min_priv(enum SCRAccessMode mode) | ||
{ | ||
return ((int)mode >> 1) - 1; | ||
return ((int)mode >> 2) - 1; | ||
} | ||
static inline int scr_needs_asr(enum SCRAccessMode mode) | ||
{ | ||
return (mode & ASR_Flag) == ASR_Flag; | ||
} | ||
|
||
static inline int scr_needs_asr_w(enum SCRAccessMode mode) | ||
{ | ||
return (mode & ASR_W_Flag) == ASR_W_Flag; | ||
} | ||
|
||
struct SCRInfo { | ||
bool r; | ||
bool w; | ||
|
@@ -89,6 +99,7 @@ struct SCRInfo { | |
.access = U_ASR, | ||
.name = "UScratchC"}, | ||
[CheriSCR_UEPCC] = {.r = true, .w = true, .access = U_ASR, .name = "UEPCC"}, | ||
[CheriSCR_UTIDC] = {.r = true, .w = true, .access = U_ASR_W, .name = "UTIDC"}, | ||
|
||
[CheriSCR_STCC] = {.r = true, .w = true, .access = S_ASR, .name = "STCC"}, | ||
[CheriSCR_STDC] = {.r = true, .w = true, .access = S_ASR, .name = "STDC"}, | ||
|
@@ -97,6 +108,7 @@ struct SCRInfo { | |
.access = S_ASR, | ||
.name = "SScratchC"}, | ||
[CheriSCR_SEPCC] = {.r = true, .w = true, .access = S_ASR, .name = "SEPCC"}, | ||
[CheriSCR_STIDC] = {.r = true, .w = true, .access = S_ASR_W, .name = "STIDC"}, | ||
|
||
[CheriSCR_MTCC] = {.r = true, .w = true, .access = M_ASR, .name = "MTCC"}, | ||
[CheriSCR_MTDC] = {.r = true, .w = true, .access = M_ASR, .name = "MTDC"}, | ||
|
@@ -105,6 +117,7 @@ struct SCRInfo { | |
.access = M_ASR, | ||
.name = "MScratchC"}, | ||
[CheriSCR_MEPCC] = {.r = true, .w = true, .access = M_ASR, .name = "MEPCC"}, | ||
[CheriSCR_MTIDC] = {.r = true, .w = true, .access = M_ASR_W, .name = "MTIDC"}, | ||
|
||
[CheriSCR_BSTCC] = {.r = true, .w = true, .access = H_ASR, .name= "BSTCC"}, | ||
[CheriSCR_BSTDC] = {.r = true, .w = true, .access = H_ASR, .name= "BSTCC"}, | ||
|
@@ -123,16 +136,19 @@ static inline cap_register_t *get_scr(CPUArchState *env, uint32_t index) | |
case CheriSCR_UTDC: return &env->UTDC; | ||
case CheriSCR_UScratchC: return &env->UScratchC; | ||
case CheriSCR_UEPCC: return &env->UEPCC; | ||
case CheriSCR_UTIDC: return &env->UTIDC; | ||
|
||
case CheriSCR_STCC: return &env->STCC; | ||
case CheriSCR_STDC: return &env->STDC; | ||
case CheriSCR_SScratchC: return &env->SScratchC; | ||
case CheriSCR_SEPCC: return &env->SEPCC; | ||
case CheriSCR_STIDC: return &env->STIDC; | ||
|
||
case CheriSCR_MTCC: return &env->MTCC; | ||
case CheriSCR_MTDC: return &env->MTDC; | ||
case CheriSCR_MScratchC: return &env->MScratchC; | ||
case CheriSCR_MEPCC: return &env->MEPCC; | ||
case CheriSCR_MTIDC: return &env->MTIDC; | ||
|
||
case CheriSCR_BSTCC: return &env->VSTCC; | ||
case CheriSCR_BSTDC: return &env->VSTDC; | ||
|
@@ -165,6 +181,10 @@ void HELPER(cspecialrw)(CPUArchState *env, uint32_t cd, uint32_t cs, | |
_host_return_address); | ||
} | ||
bool can_access_sysregs = cheri_have_access_sysregs(env); | ||
bool is_write = (cs != 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Introducing a variable for this when there are multiple existing, untouched uses of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jrtc27 The same would then apply to |
||
if (is_write && scr_needs_asr_w(mode) && !can_access_sysregs) { | ||
raise_cheri_exception(env, CapEx_AccessSystemRegsViolation, 32 + index); | ||
} | ||
if (scr_needs_asr(mode) && !can_access_sysregs) { | ||
raise_cheri_exception(env, CapEx_AccessSystemRegsViolation, 32 + index); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
U_ASR is ASR + ASR_W, which is a bit odd (i.e. you're inconsistent between the flag and the aliases what the unsuffixed version means)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also,
U_Always | ASR_Flag
andU_Always | ASR_Flag | ASR_W_Flag
behave the same, which is a bit confusing too IMOThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrtc27 Would
ASR_RW = ASR_R | ASR_W
be something you are happy with? Then all SCRs other than xTIDC need to haveASR_RW
.