Page MenuHomeFreeBSD

arm64: clear debug registers in exec_setregs()
ClosedPublic

Authored by mhorne on Apr 9 2021, 2:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 24, 4:34 PM
Unknown Object (File)
Feb 18 2024, 8:06 PM
Unknown Object (File)
Jan 3 2024, 1:36 PM
Unknown Object (File)
Dec 23 2023, 12:50 AM
Unknown Object (File)
Dec 23 2023, 12:25 AM
Unknown Object (File)
Dec 14 2023, 10:39 PM
Unknown Object (File)
Dec 2 2023, 12:18 PM
Unknown Object (File)
Dec 1 2023, 10:06 PM
Subscribers

Details

Summary

This is both intuitive and required, as any previous breakpoint settings
may not be applicable to the new process.

Reported by: arichardson

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mhorne requested review of this revision.Apr 9 2021, 2:18 PM
This revision is now accepted and ready to land.Apr 9 2021, 9:39 PM

Also handle linux_exec_setregs().

This revision now requires review to proceed.Apr 12 2021, 3:04 PM

Should you do the same in freebsd32_setregs(), then?

In D29672#666686, @kib wrote:

Should you do the same in freebsd32_setregs(), then?

It is not required since we do not allow setting user dbregs for 32-bit processes. Still, doing so would guard against any future changes so yes, I think it's worth adding there too.

Also clear in freebsd32_setregs(). Add a local pcb pointer instead of using td->pcb repeatedly.

In D29672#666686, @kib wrote:

Should you do the same in freebsd32_setregs(), then?

It is not required since we do not allow setting user dbregs for 32-bit processes.

I am curious how this is arranged. Could you please point me?

Still, doing so would guard against any future changes so yes, I think it's worth adding there too.

This revision is now accepted and ready to land.Apr 13 2021, 10:02 AM
In D29672#666998, @kib wrote:
In D29672#666686, @kib wrote:

Should you do the same in freebsd32_setregs(), then?

It is not required since we do not allow setting user dbregs for 32-bit processes.

I am curious how this is arranged. Could you please point me?

The debug registers are not directly accessible at EL0, and set_dbregs32() is a stub. Perhaps it is more precise to say that setting them is not supported, than disallowed.

emaste's recent change 5be27cbf16c85 is somewhat relevant here.

The debug registers are not directly accessible at EL0, and set_dbregs32() is a stub. Perhaps it is more precise to say that setting them is not supported, than disallowed.

But can 64bit debugger modify dbregs for 32bit target?

In D29672#667075, @kib wrote:

The debug registers are not directly accessible at EL0, and set_dbregs32() is a stub. Perhaps it is more precise to say that setting them is not supported, than disallowed.

But can 64bit debugger modify dbregs for 32bit target?

That might be possible, it seems like this case is not handled.

The code in kern_ptrace() is slightly tricky, but it seems like PROC_WRITE(dbreg, td2, addr) would expand to set_dbregs(td2, addr) for a 64-bit client but 32-bit td2. Is this correct, and why? I would sort of expect set_dbregs32(td2, addr), but there must be some reason otherwise.

The code in kern_ptrace() is slightly tricky, but it seems like PROC_WRITE(dbreg, td2, addr) would expand to set_dbregs(td2, addr) for a 64-bit client but 32-bit td2. Is this correct, and why? I would sort of expect set_dbregs32(td2, addr), but there must be some reason otherwise.

Idea is that full execution environment for the host is 64bit, and the register set does not depend on the mode of the target process. On the other hand, 32bit process itself represents some specific ABI that needs a translation to the full native one. So e.g. set_dbregs32() is there to translate from 32bit ABI to native (wide), not to handle 32bit target.

This revision was automatically updated to reflect the committed changes.