-
Notifications
You must be signed in to change notification settings - Fork 17
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
Exception priorities #11
Comments
Acknowledged - this is a known weakness in RTL and I semi-intentionally deferred it till we have a good way to verify. Since we now have the ability to check I will try to fix that in the next week and we can revisit. |
I have finally got the chance to clean things up on the exception priority side. Please see the latest commit (f3570e5). If we can start verifying RTL against sail it would be great, thanks. |
Started verifying the fixes for memory instructions. Looks largely OK, but I've run into a couple of issues:
|
Thanks - will check in the fix soon.
From: Louis-Emile Ploix ***@***.***>
Sent: Saturday, January 20, 2024 9:20 AM
To: microsoft/cheriot-ibex ***@***.***>
Cc: Comment ***@***.***>; Subscribed ***@***.***>
Subject: Re: [microsoft/cheriot-ibex] Exception priorities (Issue #11)
Started verifying the fixes for memory instructions. Looks largely OK, but I've run into a couple of issues:
1. In vio_cause_enc the bound_vio check should be last instead of first.
2. Misaligned capability loads should throw E_Fetch_Addr_Align exceptions, instead of EXC_CHERI, with priority lower even than bounds checks.
-
Reply to this email directly, view it on GitHub<#11 (comment)> or unsubscribe<https://github.com/notifications/unsubscribe-auth/A3V7IMBBSRTB6JLQNZYNVFTYPP4FBBFKMF2HI4TJMJ2XIZLTSOBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLLDTOVRGUZLDORPXI6LQMWWES43TOVSUG33NNVSW45FGORXXA2LDOOJIFJDUPFYGLKTSMVYG643JORXXE6NFOZQWY5LFVE2TSMBRGM3DKOBZQKSHI6LQMWSWS43TOVS2K5TBNR2WLKRRHEYTGMRYGU3TSMFHORZGSZ3HMVZKMY3SMVQXIZI>.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Checked in the fix (commit [5c37f9a]). Please verify, thanks. |
Fix looks good, there's just one more problem, then I can am happy to close this issue: In #12 I suggested that the From line 838 in if (cheri_operator_i[CIS_SUBSET])
top_chkaddr = rf_fullcap_b.top33;
else if (cheri_operator_i[CJAL] | cheri_operator_i[CJALR])
top_chkaddr = {base_chkaddr[31:1], 1'b0};
else if (is_cap) // CLC/CSC
top_chkaddr = base_chkaddr + 33'd8; // Don't assume alignment
else
top_chkaddr = base_chkaddr;
if (cheri_operator_i[CSEAL] | cheri_operator_i[CUNSEAL]) begin
top_bound = rf_fullcap_b.top33;
base_bound = rf_fullcap_b.base32;
end else if (cheri_operator_i[CJAL]) begin
top_bound = {pcc_cap_i.top33[32:1], 1'b0};
base_bound = pcc_cap_i.base32;
end else if (cheri_operator_i[CJALR]) begin
top_bound = {rf_fullcap_a.top33[32:1], 1'b0};
base_bound = rf_fullcap_a.base32;
end else begin // Includes CLC/CSC
top_bound = rf_fullcap_a.top33;
base_bound = rf_fullcap_a.base32;
end
top_vio = (top_chkaddr > top_bound);
base_vio = (base_chkaddr < base_bound);
top_equal = (top_chkaddr == top_bound);
if (debug_mode_i)
addr_bound_vio = 1'b0;
else if (is_cap | cheri_operator_i[CIS_SUBSET])
addr_bound_vio = top_vio | base_vio;
else if (cheri_operator_i[CJAL] | cheri_operator_i[CJALR])
addr_bound_vio = top_vio | base_vio | top_equal;
else if (cheri_operator_i[CSEAL] | cheri_operator_i[CUNSEAL])
addr_bound_vio = top_vio | base_vio | top_equal; |
@rmn30 , is there a particular reason the address bound violation has to take priority over alignment errors? This check is in the critical timing path for the load/store interface (since it has to gate the outgoing memory request), and I'd like to avoid additional adders.. |
I would expect alignment errors to be higher priority because you may wish to trap and emulate on alignment failures. |
This looks good to me. There are a few more issues with exceptions that I have since found:
Thanks, and apologies for the issue dump. |
Thanks, all good findings.
|
I also have one more issue with CSpecialRW: If an illegal scr address is accessed while the PCC also doesn't have if (cheri_operator_i[CCSR_RW] & cheri_wb_err_raw & illegal_scr_addr & cheri_exec_id_i)
// cspecialrw trap, illegal addr, treated as illegal_insn
cheri_wb_err_info_d = {3'h0, 1'b1, 12'h0};
else if (cheri_operator_i[CCSR_RW] & cheri_wb_err_raw & perm_vio & cheri_exec_id_i)
// cspecialrw traps, PERM_SR
cheri_wb_err_info_d = {5'h0, 1'b1, cheri_cs2_dec_i, cheri_err_cause}; |
Regarding #1, I think in our case we actually have I will to take a look at #4 and #5 later, it make take a little while since I'll be out of office for a few days. |
cheriot-ibex/rtl/ibex_controller.sv Lines 735 to 738 in 2911d85
Both that and the code at line 810 refer to the same Sail If the code at line 810 is to remain the same, the code at line 735 should look like the below: illegal_insn_prio: begin
exc_cause_o = EXC_CAUSE_ILLEGAL_INSN;
csr_mtval_o = 0;
end |
I see what you mean - yes we should make those 2 cases consistent. Likely will make line 737 to set mtval = 0 if pmode = 1. @rmn30, can you confirm we indeed what to go with mtval_has_illegal_inst_bits = 0? |
Yes, it should not be possible to create a tagged capability with base[8]=1 and exp=24 (i.e. base=2**32, which is greater than the 32-bit base used in csetbounds). If an untagged capability with such base is installed in MTCC when an exception / interrupt is taken this will result in an unrecoverable exception loop, so we don't really care about this case. |
This is all great, thanks. Easiest update I've made in a while. |
As pointed out to us before the exception priorities of CJAL, CJALR, memory instructions and instruction fetch errors are incorrect. I don't know if it is worth me going into too much detail here about each small issue here as there are many of them, most of which are best explained by simply comparing the SV and the Sail.
That said I am more happy to check any fixes as our verification setup does now check CSR writes (including for exceptions).
The text was updated successfully, but these errors were encountered: