[PATCH 5/7] lib: sbi: dbtr: keep type and chain of a trigger in UPDATE

liutong liutong at iscas.ac.cn
Tue Nov 24 07:55:59 PST 2026


On 11/21/26 00:11, Heinrich Schuchardt wrote:
> +		if (type != TDATA1_GET_TYPE(trig->tdata1) ||
> +		    dbtr_tdata1_chain(tdata1) !=
> +			    dbtr_tdata1_chain(trig->tdata1))

trig->tdata1 holds two different things. dbtr_trigger_setup() stores the
value the caller supplied; sbi_dbtr_read_trig() replaces it with the CSR
read-back:

	lib/sbi/sbi_dbtr.c:666
	trig->tdata1 = csr_read(CSR_TDATA1);

So the chain comparison depends on whether READ_TRIGGERS was called in
between. On QEMU that flips the result. type6_mcontrol6_validate() in
target/riscv/tcg/debug.c never writes the chain bit back, and
dbtr_trigger_valid() only rejects dmode and m, so chain=1 installs:

  install chain=1, update chain=0
	reference chain=1, rejected, although the CSR already has chain=0

  install chain=1, READ_TRIGGERS, update chain=0
	reference chain=0, accepted, although it differs from the install

The same update gets opposite answers and the discriminator is an
unrelated earlier call. The type comparison is not affected: a type that
passed type_mask survives the write back.

A field that read_trig does not touch would fix it. My update_trig v2
omits the chain check for the same reason and needs the same field.

liutong




More information about the opensbi mailing list