From 63dc5cf6048906eee2676c9dc88a1dd6e4edb923 Mon Sep 17 00:00:00 2001 From: Tariq Kurd Date: Tue, 17 Sep 2024 17:58:53 +0200 Subject: [PATCH 1/8] make the mode to enter unspecified --- src/debug-integration.adoc | 2 ++ src/riscv-hybrid-integration.adoc | 15 +++++++++++++-- src/trigger-integration.adoc | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/debug-integration.adoc b/src/debug-integration.adoc index 74e236b4..6ec6dcf5 100644 --- a/src/debug-integration.adoc +++ b/src/debug-integration.adoc @@ -182,6 +182,8 @@ The reset value is the <> capability with the <> set to {CA regardless of whether {cheri_default_ext_name} (see xref:section-cheri-execution-mode[xrefstyle=short]) is implemented: +The current CHERI execution mode can be determined in debug mode by reading <>. + <> is read/write but with no writeable fields, and so writes are ignored. diff --git a/src/riscv-hybrid-integration.adoc b/src/riscv-hybrid-integration.adoc index 0748f942..ff6766df 100644 --- a/src/riscv-hybrid-integration.adoc +++ b/src/riscv-hybrid-integration.adoc @@ -279,9 +279,20 @@ shown in xref:default-csrnames-added[xrefstyle=short]. {cheri_default_ext_name} optionally allows <> to execute in debug mode. -When entering debug mode, the core always enters {cheri_cap_mode_name}. +When entering debug mode, whether the core enters {cheri_int_mode_name} or +{cheri_cap_mode_name} is UNSPECIFIED. Implementations may optionally support switching CHERI execution mode by -executing the <> from the program buffer. +executing <> from the program buffer. + +The current mode can be read from <>. + +NOTE: Entering debug mode in {cheri_int_mode_name} allows non-CHERI aware debuggers +the ability to connect to, and debug, CHERI cores without any software +change. Entering in {cheri_cap_mode_name} allows CHERI aware debuggers to +connect directly and make use of the CHERI features without needing to +switch modes. It is anticipated that, over time, debuggers will move to +being updated to talk to CHERI cores, allowing {cheri_cap_mode_name} to +become to obvious mode to switch to when entering debug mode. ifdef::cheri_v9_annotations[] NOTE: *CHERI v9 Note:* The mode change instruction <> is new diff --git a/src/trigger-integration.adoc b/src/trigger-integration.adoc index 040cf227..db8b9a1f 100644 --- a/src/trigger-integration.adoc +++ b/src/trigger-integration.adoc @@ -9,7 +9,7 @@ shown in xref:trigger-exception-priority[xrefstyle=short]. .Synchronous exception priority (including triggers) in decreasing priority order. Entries added in {cheri_base_ext_name} are in *bold* [%autowidth,float="center",align="center",cols="<,>,<,<",options="header"] |=== -|Priority |Exc.Code |Description |Trigger +|Priority |Exc. Code |Description |Trigger |_Highest_ |3 + 3 + 3 + From e7c59d29d999e54653a38a10cfa4c09bb6981bd7 Mon Sep 17 00:00:00 2001 From: Tariq Kurd Date: Wed, 18 Sep 2024 13:02:42 +0200 Subject: [PATCH 2/8] clarify m-bit handling ni dinfc --- src/debug-integration.adoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/debug-integration.adoc b/src/debug-integration.adoc index 6ec6dcf5..78ad9484 100644 --- a/src/debug-integration.adoc +++ b/src/debug-integration.adoc @@ -182,7 +182,10 @@ The reset value is the <> capability with the <> set to {CA regardless of whether {cheri_default_ext_name} (see xref:section-cheri-execution-mode[xrefstyle=short]) is implemented: -The current CHERI execution mode can be determined in debug mode by reading <>. +The current CHERI execution mode can be determined in debug mode by reading <>, as the +<> is updated by the hardware. The value of the <> when the core is not in debug +mode is either the reset value or the value of the <> in debug mode when the core last +resumed execution. <> is read/write but with no writeable fields, and so writes are ignored. From 3b579d2fe95102a337135d50c1148a66895e0e0e Mon Sep 17 00:00:00 2001 From: Tariq Kurd Date: Thu, 19 Sep 2024 18:21:13 +0200 Subject: [PATCH 3/8] update after review --- src/debug-integration.adoc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/debug-integration.adoc b/src/debug-integration.adoc index 78ad9484..da84b69d 100644 --- a/src/debug-integration.adoc +++ b/src/debug-integration.adoc @@ -178,17 +178,17 @@ include::img/dscratch1creg.edn[] The <> register is a CLEN-bit plus tag bit CSR only accessible in debug mode. -The reset value is the <> capability with the <> set to {CAP_MODE_VALUE}, -regardless of whether {cheri_default_ext_name} (see xref:section-cheri-execution-mode[xrefstyle=short]) -is implemented: +The reset value is the <> capability. -The current CHERI execution mode can be determined in debug mode by reading <>, as the -<> is updated by the hardware. The value of the <> when the core is not in debug -mode is either the reset value or the value of the <> in debug mode when the core last -resumed execution. +If {cheri_default_ext_name} is implemented: -<> is read/write but with no writeable fields, and so writes are -ignored. +* The <> is reset to be {cheri_default_ext_name}. +* The debugger can set the <> to {cheri_base_mode_ext} by reading the CSR, using <> and then writing the CSR. +** This only needs doing once after resetting the core. +* The <> is used on debug mode entry to determine which CHERI execution mode to enter. + +The <> is the only writeable field in <>. +Therefore if {cheri_default_ext_name} is not implemented then it is read-write with no writeable fields. NOTE: A future version of this specification may add writeable fields to allow creation of other capabilities, if, for example, a future extension requires multiple formats for From 700e05d4152b5abf24f66a6801ca3cd068eac057 Mon Sep 17 00:00:00 2001 From: Tariq Kurd Date: Fri, 20 Sep 2024 09:53:13 +0100 Subject: [PATCH 4/8] Update src/debug-integration.adoc Co-authored-by: Alexander Richardson Signed-off-by: Tariq Kurd --- src/debug-integration.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug-integration.adoc b/src/debug-integration.adoc index da84b69d..d6e4da3b 100644 --- a/src/debug-integration.adoc +++ b/src/debug-integration.adoc @@ -182,7 +182,7 @@ The reset value is the <> capability. If {cheri_default_ext_name} is implemented: -* The <> is reset to be {cheri_default_ext_name}. +* The <> is reset to be {INT_MODE_VALUE}. * The debugger can set the <> to {cheri_base_mode_ext} by reading the CSR, using <> and then writing the CSR. ** This only needs doing once after resetting the core. * The <> is used on debug mode entry to determine which CHERI execution mode to enter. From 462ad3eb06d914c69a8a1082026dd034f441b1ae Mon Sep 17 00:00:00 2001 From: Tariq Kurd Date: Fri, 20 Sep 2024 11:23:20 +0200 Subject: [PATCH 5/8] point out that MODESW can be used to change mode --- src/debug-integration.adoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/debug-integration.adoc b/src/debug-integration.adoc index d6e4da3b..ac3a4c27 100644 --- a/src/debug-integration.adoc +++ b/src/debug-integration.adoc @@ -182,8 +182,9 @@ The reset value is the <> capability. If {cheri_default_ext_name} is implemented: -* The <> is reset to be {INT_MODE_VALUE}. -* The debugger can set the <> to {cheri_base_mode_ext} by reading the CSR, using <> and then writing the CSR. +* The <> is reset to be {cheri_default_ext_name} ({INT_MODE_VALUE}). +* The debugger can set the <> to {cheri_base_mode_ext} ({CAP_MODE_VALUE}) by executing <> from the program buffer +** if <> is not supported in debug mode then the same can be done by reading the CSR, using <> and then writing the CSR. ** This only needs doing once after resetting the core. * The <> is used on debug mode entry to determine which CHERI execution mode to enter. From 45098ded28c546506fd80e6f6e4675a736926b7e Mon Sep 17 00:00:00 2001 From: Tariq Kurd Date: Fri, 20 Sep 2024 11:47:53 +0200 Subject: [PATCH 6/8] clarify MODESW behaviour in debug mode --- src/debug-integration.adoc | 3 --- src/insns/modesw_16bit.adoc | 2 +- src/insns/modesw_32bit.adoc | 2 +- src/insns/modesw_common.adoc | 9 ++++++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/debug-integration.adoc b/src/debug-integration.adoc index ac3a4c27..ee19d3ff 100644 --- a/src/debug-integration.adoc +++ b/src/debug-integration.adoc @@ -5,9 +5,6 @@ This section describes changes to integrate the Sdext ISA and {cheri_base_ext_name}. It must be implemented to make external debug compatible with {cheri_base_ext_name}. Modifications to Sdext are kept to a minimum. -WARNING: This section is preliminary as no-one has yet built debug support - for CHERI-RISC-V so change is likely. - The following features, which are optional in Sdext, must be implemented for use with {cheri_base_ext_name}: diff --git a/src/insns/modesw_16bit.adoc b/src/insns/modesw_16bit.adoc index 645bf8fb..f99cb27c 100644 --- a/src/insns/modesw_16bit.adoc +++ b/src/insns/modesw_16bit.adoc @@ -9,7 +9,7 @@ NOTE: *CHERI v9 Note:* This instruction is *new*. endif::[] Synopsis:: -Capability/{cheri_int_mode_name} switching (C.MODESW), 16-bit encoding +{cheri_cap_mode_name}/{cheri_int_mode_name} switching (C.MODESW), 16-bit encoding Mnemonic:: `c.modesw` diff --git a/src/insns/modesw_32bit.adoc b/src/insns/modesw_32bit.adoc index 73b55d3b..416b25b8 100644 --- a/src/insns/modesw_32bit.adoc +++ b/src/insns/modesw_32bit.adoc @@ -6,7 +6,7 @@ include::new_encoding_note.adoc[] Synopsis:: -Switch CHERI execution mode +{cheri_cap_mode_name}/{cheri_int_mode_name} switching (MODESW), 32-bit encoding Mnemonic:: `modesw` diff --git a/src/insns/modesw_common.adoc b/src/insns/modesw_common.adoc index e03bc755..1844efcf 100644 --- a/src/insns/modesw_common.adoc +++ b/src/insns/modesw_common.adoc @@ -5,10 +5,13 @@ Toggle the hart's current CHERI execution mode in <>. * If the current mode in <> is {cheri_int_mode_name} ({INT_MODE_VALUE}), then the <> in <> is set to {cheri_cap_mode_name} ({CAP_MODE_VALUE}). * If the current mode is {cheri_cap_mode_name} ({CAP_MODE_VALUE}), then the <> in <> is set to {cheri_int_mode_name} ({INT_MODE_VALUE}). -NOTE: The effective CHERI exection mode is give by the value of some CSRs and +NOTE: The effective CHERI execution mode is give by the value of some CSRs and the <>'s <>, so executing <> does not necessarily change the machine's current mode. The current, effective CHERI execution mode can be observed as described in xref:m_bit_observe[xrefstyle=short]. -NOTE: Implementations may optionally support executing <> from the -program buffer while in debug mode. +NOTE: Implementations may optionally support executing <> from the +program buffer while in debug mode. If supported them the <> in +<> is toggled and used to control which mode to enter next time debug +mode is entered. The CHERI execution mode is only controlled by the <> +of <> in debug mode. From 46bc931e4f9f149cdcb7a3139410e1cf8cf1cb1e Mon Sep 17 00:00:00 2001 From: Tariq Kurd Date: Fri, 20 Sep 2024 13:27:01 +0200 Subject: [PATCH 7/8] remove redundant text --- src/riscv-hybrid-integration.adoc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/riscv-hybrid-integration.adoc b/src/riscv-hybrid-integration.adoc index ff6766df..974dbf4d 100644 --- a/src/riscv-hybrid-integration.adoc +++ b/src/riscv-hybrid-integration.adoc @@ -280,20 +280,12 @@ shown in xref:default-csrnames-added[xrefstyle=short]. {cheri_default_ext_name} optionally allows <> to execute in debug mode. When entering debug mode, whether the core enters {cheri_int_mode_name} or -{cheri_cap_mode_name} is UNSPECIFIED. +{cheri_cap_mode_name} is controlled by the <> in <>. Implementations may optionally support switching CHERI execution mode by executing <> from the program buffer. The current mode can be read from <>. -NOTE: Entering debug mode in {cheri_int_mode_name} allows non-CHERI aware debuggers -the ability to connect to, and debug, CHERI cores without any software -change. Entering in {cheri_cap_mode_name} allows CHERI aware debuggers to -connect directly and make use of the CHERI features without needing to -switch modes. It is anticipated that, over time, debuggers will move to -being updated to talk to CHERI cores, allowing {cheri_cap_mode_name} to -become to obvious mode to switch to when entering debug mode. - ifdef::cheri_v9_annotations[] NOTE: *CHERI v9 Note:* The mode change instruction <> is new and the requirement to optionally support it in debug mode is also new. From e9a587602d74df834261bd529e7f8a7419bfc25b Mon Sep 17 00:00:00 2001 From: Tariq Kurd Date: Fri, 20 Sep 2024 13:30:27 +0200 Subject: [PATCH 8/8] fix code seqeunce for observing cap mode in debug mdoe --- src/riscv-hybrid-integration.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/riscv-hybrid-integration.adoc b/src/riscv-hybrid-integration.adoc index 974dbf4d..7e4d8a54 100644 --- a/src/riscv-hybrid-integration.adoc +++ b/src/riscv-hybrid-integration.adoc @@ -99,8 +99,8 @@ write {CAP_MODE_VALUE} for {cheri_cap_mode_name} and {INT_MODE_VALUE} for {cheri_int_mode_name} to `x1`: ``` -csrr c1, dinfc -gctag x1, c1 +csrr c1, dinfc +gcmode x1, c1 ``` In any other privilege mode, the following sequence will write {CAP_MODE_VALUE}