From d438885deb9311d632cf811ebb0514c0349e9461 Mon Sep 17 00:00:00 2001 From: Jubilee Date: Tue, 12 Nov 2024 14:37:53 -0800 Subject: [PATCH] Explain `sscratch` is only swapped by software (#1722) * Explain `sscratch` is only swapped by software Someone familiar with the interrupt handlers of other ISAs may incorrectly imagine that the current description means that RISCV cores will automatically perform the swap of `sscratch` with a user register. This is not the case: it is a recommendation disguised as a description. Flesh it out a bit so it is less ambiguous. * Tweak sscratch description Signed-off-by: Andrew Waterman --------- Signed-off-by: Andrew Waterman Co-authored-by: Andrew Waterman --- src/supervisor.adoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/supervisor.adoc b/src/supervisor.adoc index 7187dda3d..85a41ab9f 100644 --- a/src/supervisor.adoc +++ b/src/supervisor.adoc @@ -490,8 +490,10 @@ access a counter if the corresponding bits in `scounteren` and The `sscratch` CSR is an SXLEN-bit read/write register, dedicated for use by the supervisor. Typically, `sscratch` is used to hold a pointer to the hart-local supervisor context while the hart is executing -user code. At the beginning of a trap handler, `sscratch` is swapped -with a user register to provide an initial working register. +user code. +At the beginning of a trap handler, software normally uses a CSRRW +instruction to swap `sscratch` with an integer register to obtain an +initial working register. .Supervisor Scratch Register include::images/bytefield/sscratch.edn[]