* [RFC] riscv: Can a valid LR/SC sequence have a backward branch on a failure path?
@ 2026-11-17 9:52 Vladimir Kondratiev
0 siblings, 0 replies; only message in thread
From: Vladimir Kondratiev @ 2026-11-17 9:52 UTC (permalink / raw)
To: linux-riscv, Palmer Dabbelt, Paul Walmsley
Cc: linux-trace-kernel, linux-kernel
Hi all,
I have run into a question regarding LR/SC sequence constraints: can a
valid constrained LR/SC sequence contain a backward branch on a failure
path?
Consider this CAS example, where I placed the failure path before the
LR/SC sequence:
cas:
j 1f
2:
li a0, -1
ret
1:
lr.w t0, (a0)
bne t0, a1, 2b
sc.w t0, a2, (a0)
bnez t0, 1b
li a0, 0
ret
The rules in [1] prohibit taken backward branches within the sequence.
In this example, the backward branch (`2b`) is not taken when LR/SC
successfully completes; it is only taken on the failure path.
My context is control flow graph (CFG) analysis when detecting whether a
particular address belongs to a valid constrained LR/SC loop (where
probes must be rejected).
When scanning `bne t0, a1, 2b` in this scenario, should the scanner
treat this as an invalid sequence and stop, or should it ignore this
branch target and continue scanning forward?
[1]
https://docs.riscv.org/reference/isa/v20260120/unpriv/a-st-ext.html#sec:lrscseq
Thanks,
Vladimir
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-17 9:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 9:52 [RFC] riscv: Can a valid LR/SC sequence have a backward branch on a failure path? Vladimir Kondratiev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox