This is an automated email from Gerrit.

"Anatoly P <[email protected]>" just uploaded a new patch set to Gerrit, 
which you can find at https://review.openocd.org/c/openocd/+/9460

-- gerrit

commit 7620054f324496e7f22ff33a4ea1a78997a93293
Author: Anatoly Parshintsev <[email protected]>
Date:   Fri Feb 13 02:35:18 2026 +0300

    target/riscv: always validate dmstatus.version field
    
    The dmstatus.version field indicates which revision of the RISC-V debug
    specification the debug module implements. Since this field is always
    readable, validating it on every dmstatus access provides a simple
    and effective check that JTAG communication with the target is
    functioning correctly.
    
    Change-Id: I2bf40e92269e7ba3c747518e20f39069a1dee363
    Signed-off-by: Anatoly Parshintsev <[email protected]>

diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 50e0f83dd8..1096b191f1 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -580,6 +580,7 @@ static int dmstatus_read(struct target *target, uint32_t 
*dmstatus,
                                "%" PRId32 " (dmstatus=0x%" PRIx32 "). This 
error might be caused by a JTAG "
                                "signal issue. Try reducing the JTAG clock 
speed.",
                                get_field32(*dmstatus, DM_DMSTATUS_VERSION), 
*dmstatus);
+               return ERROR_FAIL;
        } else if (authenticated && !get_field(*dmstatus, 
DM_DMSTATUS_AUTHENTICATED)) {
                LOG_ERROR("Debugger is not authenticated to target Debug 
Module. "
                                "(dmstatus=0x%x). Use `riscv authdata_read` and 
"
@@ -2071,11 +2072,6 @@ static int examine(struct target *target)
        if (dmstatus_read(target, &dmstatus, false) != ERROR_OK)
                return ERROR_FAIL;
        LOG_TARGET_DEBUG(target, "dmstatus:  0x%08x", dmstatus);
-       int dmstatus_version = get_field(dmstatus, DM_DMSTATUS_VERSION);
-       if (dmstatus_version != 2 && dmstatus_version != 3) {
-               /* Error was already printed out in dmstatus_read(). */
-               return ERROR_FAIL;
-       }
 
        uint32_t hartinfo;
        if (dm_read(target, &hartinfo, DM_HARTINFO) != ERROR_OK)

-- 

Reply via email to