Let take as example the debug monitors of free-bsd
, arm64
(aarch64). I chose free-bsd
because the code is readable, but the question is valid with any other kernel, such as Linux.
Reference to debug-monitors freebsd arm64: here
In arm64, hardware [break/watch]point are obtained through two important registers, a "control" register that drives an "address" register. You can find a nice schema here here (sections "Breakpoint exception" and "Watchpoint exception", not "Breakpoint Instruction exception").
Let's take as a reference breakpoints. According to arm64 manual:
Breakpoint matches when the PE executes from a virtual address with the same value as the DBGBVR register, and the current state of the PE matches the settings in DBGBCR.
Where PE
stands for Processing element
, DBGBVR
is the above mentioned "address" register and DBGBCR
is the above mentioned "control" register.
The official documentation clearly says virtual address. What happens in case several applications shares addresses (in TEXT segment for breakpoints and in DATA segments for watchpoints) with the same virtual address? Can the breakpoint (watchpoint), supposed for process A
, being triggered erroneously by the same virtual address reached by process B
?
Can the breakpoint (watchpoint), supposed for process A, being triggered erroneously by the same virtual address reached by process B?
Yes.
At whatever point you switch out TTBRx_EL1, you should also switch out the break-/watchpoint registers.