From: "Willgerodt, Felix" <felix.willgerodt@intel.com>
To: "Schimpe, Christina" <christina.schimpe@intel.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "Schimpe, Christina" <christina.schimpe@intel.com>
Subject: RE: [PATCH 3/3] LAM: Support kernel space debugging
Date: Wed, 24 Apr 2024 11:11:58 +0000 [thread overview]
Message-ID: <MN2PR11MB4566B06C1E6EE701F265EC688E102@MN2PR11MB4566.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20240327074739.2969623-4-christina.schimpe@intel.com>
> -----Original Message-----
> From: Schimpe, Christina <christina.schimpe@intel.com>
> Sent: Mittwoch, 27. März 2024 08:48
> To: gdb-patches@sourceware.org
> Cc: Schimpe, Christina <christina.schimpe@intel.com>
> Subject: [PATCH 3/3] LAM: Support kernel space debugging
>
> From: Christina Schimpe <christina.schimpe@intel.com>
>
> Sign-extend watchpoint address for kernel space support.
> ---
> gdb/amd64-linux-tdep.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
> index 94c62277623..3498a6d4632 100644
> --- a/gdb/amd64-linux-tdep.c
> +++ b/gdb/amd64-linux-tdep.c
> @@ -51,6 +51,8 @@
>
> #include <sstream>
>
> +/* Bit 63 is used to select between a kernel-space and user-space address. */
> +#define VA_RANGE_SELECT_BIT_MASK 0x8000000000000000UL
> #define DEFAULT_TAG_MASK 0xffffffffffffffffULL
>
> /* Mapping between the general-purpose registers in `struct user'
> @@ -1852,10 +1854,21 @@ amd64_linux_lam_untag_mask ()
> static CORE_ADDR
> amd64_linux_remove_non_addr_bits_wpt (gdbarch *gdbarch, CORE_ADDR
> addr)
> {
> + /* The topmost bit tells us if we have a kernel-space address or a user-space
> + address. */
> + const bool kernel_address = (addr & VA_RANGE_SELECT_BIT_MASK) != 0;
> +
> + CORE_ADDR mask = amd64_linux_lam_untag_mask ();
> /* Clear insignificant bits of a target address using the untag mask.
> The untag mask preserves the topmost bit, which distinguishes user space
> from kernel space address. */
> - return (addr & amd64_linux_lam_untag_mask ());
> + addr &= mask;
> +
> + /* Sign-extend if we have a kernel-space address. */
> + if (kernel_address)
> + addr |= ~mask;
> +
> + return addr;
Ah, here is probably where we should add the comment I complained about in
patch 2.
I don't really know much about how kernel space debugging works.
(We can't get a kernel address when doing user-space debugging, can we?)
While this probably doesn't hurt much, I wonder if it isn't just dead code.
Is this file (amd64-linux-tdep.c) even used when doing kernel debugging?
And we still read the mask from /proc/pid/status. Is that available?
Maybe someone with more experience on this can chime in.
Thanks,
Felix
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2024-04-24 11:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-27 7:47 [PATCH 0/3] Add amd64 LAM watchpoint support Schimpe, Christina
2024-03-27 7:47 ` [PATCH 1/3] gdb: Make tagged pointer support configurable Schimpe, Christina
2024-03-28 11:58 ` Luis Machado
2024-04-04 8:18 ` Schimpe, Christina
2024-04-04 8:50 ` Luis Machado
2024-04-24 11:10 ` Willgerodt, Felix
2024-03-27 7:47 ` [PATCH 2/3] LAM: Enable tagged pointer support for watchpoints Schimpe, Christina
2024-03-27 12:37 ` Eli Zaretskii
2024-03-28 12:50 ` Luis Machado
2024-04-24 11:11 ` Willgerodt, Felix
2024-03-27 7:47 ` [PATCH 3/3] LAM: Support kernel space debugging Schimpe, Christina
2024-04-24 11:11 ` Willgerodt, Felix [this message]
2024-04-15 11:26 ` [PING][PATCH 0/3] Add amd64 LAM watchpoint support Schimpe, Christina
2024-04-22 7:17 ` [PING*2][PATCH " Schimpe, Christina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MN2PR11MB4566B06C1E6EE701F265EC688E102@MN2PR11MB4566.namprd11.prod.outlook.com \
--to=felix.willgerodt@intel.com \
--cc=christina.schimpe@intel.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox