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, Oct 20, 5:46 PM
Unknown Object (File)
Oct 3 2024, 6:26 PM
Unknown Object (File)
Oct 3 2024, 2:40 PM
Unknown Object (File)
Oct 1 2024, 2:06 PM
Unknown Object (File)
Oct 1 2024, 12:54 PM
Unknown Object (File)
Sep 25 2024, 5:52 PM
Unknown Object (File)
Sep 24 2024, 5:20 PM
Unknown Object (File)
Sep 24 2024, 5:15 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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 38453
Build 35342: arc lint + arc unit

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.