Skip to content

Commit

Permalink
Rename CJ* to J* and JALR.PCC/JALR.CAP to JALR.MODE
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqkurd-repo committed Feb 9, 2024
1 parent 2fa55c7 commit 72ab9c0
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 207 deletions.
2 changes: 1 addition & 1 deletion src/cap-description.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ capabilities that describe function entry points. A program may jump to a
sealed capability to begin executing the instructions it references. The jump
instruction automatically unseals the capability and installs it to the
program counter capability (see
xref:section_riscv_programmers_model[xrefstyle=short]). The <<CJALR>> instruction
xref:section_riscv_programmers_model[xrefstyle=short]). The <<JALR>> instruction
also seals the return address capability (if any) since it is the entry point
to the caller function.

Expand Down
15 changes: 7 additions & 8 deletions src/csv/CHERI_ISA.csv
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@
"C.CINCOFFSET4CSPN","✔","✔","","","","","✔","Capability","","","","✔","","","","","","","","","","","","C0","","C.ADDI4SPN","C.ADDI4SPN","ADD immediate to stack pointer, representability check","","","","","","","",""
"C.MV","✔","✔","","","","✔","","Legacy","","","","✔","","","","","","","","","","","","C2","","","","Register Move","","","","","","","",""
"C.CMOVE","✔","✔","","","","","✔","Capability","","","","✔","","","","","","","","","","","","C2","","C.MV","C.MV","Same as CMove","","","","","","","",""
"C.CJ","✔","✔","","","","","✔","Capability","","","","✔","","","","","","","","","","","","C2","","C.J","C.J","Jump to PC+offset, bounds check minimum size target instruction","mode==D (optional)","","","","","","",""
"C.CJAL","✔","","","","","","✔","Capability","","","","✔","","","","","","","","","","","","C2","","C.JAL","C.JAL","Jump to PC+offset, bounds check minimum size target instruction, link to cd","mode==D (optional)","","","","","","",""
"CJAL","✔","✔","","","","","✔","Capability","","","","✔","","","","","","","","","","","","JAL","","JAL","JAL","Jump to PC+offset, bounds check minimum size target instruction, link to cd","mode==D (optional)","","","","","","",""
"JALR.CAP","✔","✔","","","","✔","","Legacy","","","","","","","","","","","","","","","","JALR","","JALR.PCC","JALR.PCC","CJALR available in legacy mode (with zero offset)","mode==D (optional)","","","","","","",""
"JALR.PCC","✔","✔","","","","","✔","Capability","","","","","","","","","","","","","","","","JALR","1-src 1-dst","","","RISC-V JALR available in capability modes (with zero offset)","mode==D (optional)","","","","","","",""
"CJALR","✔","✔","","","","","✔","Capability","","","","","","","","","","","","","","","","JALR","","JALR","JALR","Indirect cap jump and link, bounds check minimum size target instruction, unseal target cap, seal link cap","mode==D (optional)","","","","","","",""
"C.CJALR","✔","✔","","","","","✔","Capability","","","","✔","","","","","","","","","","","","C2","","C.JALR","C.JALR","Indirect cap jump and link, bounds check minimum size target instruction, unseal target cap, seal link cap","mode==D (optional)","","","","","","",""
"C.CJR","✔","✔","","","","","✔","Capability","","","","✔","","","","","","","","","","","","C2","","C.JR","C.JR","Indirect cap jump, bounds check minimum size target instruction, unseal target cap","mode==D (optional)","","","","","","",""
"C.J","✔","✔","","","","✔","✔","Both","","","","✔","","","","","","","","","","","","C2","","C.J","C.J","Jump to PC+offset, bounds check minimum size target instruction","mode==D (optional)","","","","","","",""
"C.JAL","✔","","","","","✔","✔","Both","","","","✔","","","","","","","","","","","","C2","","C.JAL","C.JAL","Jump to PC+offset, bounds check minimum size target instruction, link to cd","mode==D (optional)","","","","","","",""
"JAL","✔","✔","","","","✔","✔","Both","","","","✔","","","","","","","","","","","","JAL","","JAL","JAL","Jump to PC+offset, bounds check minimum size target instruction, link to cd","mode==D (optional)","","","","","","",""
"JALR.MODE","✔","✔","","","","✔","✔","Both","","","","","","","","","","","","","","","","JALR","","JALR.PCC","JALR.PCC","JALR executes as in the other mode (with zero offset)","mode==D (optional)","","","","","","",""
"JALR","✔","✔","","","","✔","✔","Both","","","","","","","","","","","","","","","","JALR","","JALR","JALR","Indirect cap jump and link, bounds check minimum size target instruction, unseal target cap, seal link cap","mode==D (optional)","","","","","","",""
"C.JALR","✔","✔","","","","✔","✔","Both","","","","✔","","","","","","","","","","","","C2","","C.JALR","C.JALR","Indirect cap jump and link, bounds check minimum size target instruction, unseal target cap, seal link cap","mode==D (optional)","","","","","","",""
"C.JR","✔","✔","","","","✔","✔","Both","","","","✔","","","","","","","","","","","","C2","","C.JR","C.JR","Indirect cap jump, bounds check minimum size target instruction, unseal target cap","mode==D (optional)","","","","","","",""
"DRET","✔","✔","✔","","","","","Legacy","","","","","","","","","","","","","","","","SYSTEM","","","","Return from debug mode, sets DDC from DDDC and PCC from DPCC","MODE<D","","","","","","",""
"MRET","✔","✔","✔","","","","","Both","","","","","","","","","","","","","","","","SYSTEM","","","","Return from machine mode handler, sets PCC from MTVECC, needs ASR permission","MODE<M","PCC.ASR==0","","","","","",""
"SRET","✔","✔","✔","","","","","Both","","","","","","","","","","","","","","","","SYSTEM","","","","Return from supervisor mode handler, sets PCC from STVECC, needs ASR permission","MODE<S","PCC.ASR==0","mstatus.TSR==1 AND MODE==S","","","","",""
Expand Down
25 changes: 8 additions & 17 deletions src/insns/cj_j_16bit.adoc → src/insns/j_16bit.adoc
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
<<<
//[#insns-cj_j-16bit,reftext="Conditional branches (C.CJ,C.J), 16-bit encodings"]

[#C_J,reftext="C.J"]
==== C.J

See <<C.CJ>>.

[#C_CJ,reftext="C.CJ"]
==== C.CJ

Synopsis::
Register based jumps without link, 16-bit encodings

Capability Mode Mnemonic::
`c.cj offset`
Mnemonic::
`c.j offset`

Capability Mode Expansion::
`cjal c0, offset`

Legacy Mode Mnemonic::
`c.j offset`
`jal c0, offset`

Legacy Mode Expansion::
`jal x0, offset`

Encoding::
include::wavedrom/c-cj-format-ls.adoc[]
include::wavedrom/c-j-format-ls.adoc[]

Description::
Set the next PC following the standard `jal` definition.
Check a minimum length instruction is in <<pcc>> bounds at the target PC, take a CHERI Length Violation exception on error.
*There is no difference in Capability Mode or Legacy Mode execution for this instruction.*

Exceptions::
See <<CJAL>>, <<JAL>>
See <<JAL>>

include::pcrel_debug_warning.adoc[]

Prerequisites for C.CJ::
Prerequisites for Capability Mode::
{c_cheri_base_ext_names}

Prerequisites for C.J::
Prerequisites for Legacy Mode::
{c_cheri_legacy_ext_names}

Operation (after expansion to 32-bit encodings)::
See <<CJAL>>, <<JAL>>
See <<JAL>>
22 changes: 8 additions & 14 deletions src/insns/cjal_jal_16bit.adoc → src/insns/jal_16bit.adoc
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<<<
//[#insns-cjal_jal-16bit,reftext="Conditional branches (C.CJAL,C.JAL), 16-bit encodings"]

[#C_JAL,reftext="C.JAL"]
==== C.JAL

See <<C.CJAL>>.

[#C_CJAL,reftext="C.CJAL"]
==== C.CJAL

Synopsis::
Register based jumps with link, 16-bit encodings

Capability Mode Mnemonic (RV32)::
`c.cjal c1, offset`
`c.jal c1, offset`

Capability Mode Expansion (RV32)::
`cjal c1, offset`
`jal c1, offset`

Legacy Mode Mnemonic (RV32)::
`c.jal x1, offset`
Expand All @@ -25,20 +19,20 @@ Legacy Mode Expansion (RV32)::
`jal x1, offset`

Encoding (RV32)::
include::wavedrom/c-cjal-format-ls.adoc[]
include::wavedrom/c-jal-format-ls.adoc[]

include::cjal_jal_common.adoc[]
include::jal_common.adoc[]

Exceptions::
See <<CJAL>>, <<JAL>>
See <<JAL>>

include::pcrel_debug_warning.adoc[]

Prerequisites for C.CJAL::
Prerequisites for Capability Mode::
{c_cheri_base_ext_names}

Prerequisites for C.JAL::
Prerequisites for Legacy Mode::
{c_cheri_legacy_ext_names}

Operation (after expansion to 32-bit encodings)::
See <<CJAL>>, <<JAL>>
See <<JAL>>
29 changes: 6 additions & 23 deletions src/insns/cjal_jal_32bit.adoc → src/insns/jal_32bit.adoc
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
<<<
//[#insns-cjal_jal-32bit,reftext="Jumps (CJAL, JAL), 32-bit encodings"]

[#CJ,reftext="CJ"]
==== CJ

Expands to <<CJAL>> following the expansion rule for <<J>> expanding to <<JAL>> from cite:[riscv-unpriv-spec].

[#J,reftext="J"]
==== J

Expands to <<JAL>> following the expansion rule from cite:[riscv-unpriv-spec].

[#CJAL,reftext="CJAL"]
==== CJAL

See <<JAL>>

[#JAL,reftext="JAL"]
==== CJAL, JAL
==== JAL

Synopsis::
Jump and link

Capability Mode Mnemonic::
`cjal cd, offset`
`jal cd, offset`

Legacy Mode Mnemonic::
`jal rd, offset`
Expand All @@ -32,7 +21,7 @@ Encoding::
include::wavedrom/ct-unconditional.adoc[]

Capability Mode Description::
CJAL's immediate encodes a signed offset in multiple of 2 bytes. The <<pcc>> is
JAL's immediate encodes a signed offset in multiple of 2 bytes. The <<pcc>> is
incremented by the sign-extended offset to form the jump target capability. The
target capability is written to <<pcc>>. The <<pcc>> of the next instruction
following the jump (<<pcc>> + 4) is sealed and written to `cd`.
Expand All @@ -49,19 +38,13 @@ address is not within the bounds of the <<pcc>>. In this case, _CHERI jump or
branch fault_ is reported in the TYPE field and Length Violation is reported in
the CAUSE field of <<mtval>> or <<stval>>.
Prerequisites for CJAL::
Prerequisites for Capability Mode::
{cheri_base_ext_name}
Prerequisites for JAL::
Prerequisites for Legacy Mode::
{cheri_legacy_ext_name}
CJAL Operation::
+
--
TODO
--
JAL Operation TODO #where's the target check?# ::
Operation::
+
--
TODO
Expand Down
File renamed without changes.
22 changes: 8 additions & 14 deletions src/insns/cjalr_jalr_16bit.adoc → src/insns/jalr_16bit.adoc
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<<<
//[#insns-cjalr_jalr-16bit,reftext="Conditional branches (C.CJALR, C.JALR), 16-bit encodings"]

[#C_JALR,reftext="C.JALR"]
==== C.JALR

See <<C.CJALR>>.

[#C_CJALR,reftext="C.CJALR"]
==== C.CJALR

Synopsis::
Register based jumps with link, 16-bit encodings

Capability Mode Mnemonic::
`c.cjalr c1, cs1`
`c.jalr c1, cs1`

Capability Mode Expansion::
`cjalr c1, 0(cs1)`
`jalr c1, 0(cs1)`

Legacy Mode Mnemonic::
`c.jalr x1, rs1`
Expand All @@ -25,20 +19,20 @@ Legacy Mode Expansion::
`jalr x1, 0(rs1)`

Encoding::
include::wavedrom/c-cjalr-format-ls.adoc[]
include::wavedrom/c-jalr-format-ls.adoc[]

include::cjalr_jalr_common.adoc[]
include::jalr_common.adoc[]

Exceptions::
See <<CJALR>>, <<JALR>>
See <<JALR>>

include::pcrel_debug_warning.adoc[]

Prerequisites C.CJALR::
Prerequisites for Capability Mode::
{c_cheri_base_ext_names}

Prerequisites C.JALR::
Prerequisites for Legacy Mode::
{c_cheri_legacy_ext_names}

Operation (after expansion to 32-bit encodings)::
See <<CJALR>>, <<JALR>>
See <<JALR>>
30 changes: 7 additions & 23 deletions src/insns/cjalr_jalr_32bit.adoc → src/insns/jalr_32bit.adoc
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
<<<

[#CJR,reftext="CJR"]
==== CJR

Expands to <<CJALR>> following the expansion rule for <<JR>> expanding to <<JARL>> from cite:[riscv-unpriv-spec].

[#JR,reftext="JR"]
==== JR

Expands to <<JALR>> following the expansion rule from cite:[riscv-unpriv-spec].

[#CJALR,reftext="CJALR"]
==== CJALR

See <<JALR>>

[#JALR,reftext="JALR"]
==== CJALR, JALR
==== JALR

Synopsis::
Jump and link register

Capability Mode Mnemonic::
`cjalr cd, cs1, offset`
`jalr cd, cs1, offset`

Legacy Mode Mnemonic::
`jalr rd, rs1, offset`
Expand All @@ -31,7 +21,7 @@ Encoding::
include::wavedrom/ct-unconditional-2.adoc[]

Capability Mode Description::
CJALR allows unconditional, indirect jumps to a target capability. The
JALR allows unconditional, indirect jumps to a target capability. The
target capability is obtained by unsealing `cs1` if the immediate is zero and
incrementing its address by the sign-extended 12-bit immediate otherwise,
and then setting the least-significant bit of the
Expand All @@ -57,7 +47,7 @@ reported in the CAUSE field of <<mtval>> or <<stval>>:

[%autowidth,options=header,align=center]
|==============================================================================
| CAUSE | JALR | CJALR | Reason
| CAUSE | Legacy Mode | Capability Mode | Reason
| Tag violation | | ✔ | `cs1` has tag set to 0
| Seal violation | | ✔ | `cs1` is sealed and the immediate is not 0
| Permission violation | | ✔ | `cs1` does not grant <<x_perm>>
Expand All @@ -66,19 +56,13 @@ reported in the CAUSE field of <<mtval>> or <<stval>>:

include::pcrel_debug_warning.adoc[]

Prerequisites CJALR::
Prerequisites Capability Mode::
{cheri_base_ext_name}

Prerequisites JALR::
Prerequisites Legacy Mode::
{cheri_legacy_ext_name}

CJALR Operation::
+
--
TBD
--

JALR Operation::
Operation::
+
--
TBD
Expand Down
Loading

0 comments on commit 72ab9c0

Please sign in to comment.