Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Schimpe, Christina" <christina.schimpe@intel.com>
To: gdb-patches@sourceware.org
Cc: felix.willgerodt@intel.com, eliz@gnu.org, luis.machado@arm.com
Subject: [PATCH v2 3/3] LAM: Support kernel space debugging
Date: Mon, 27 May 2024 10:24:23 +0000	[thread overview]
Message-ID: <20240527102423.1361410-4-christina.schimpe@intel.com> (raw)
In-Reply-To: <20240527102423.1361410-1-christina.schimpe@intel.com>

From: Christina Schimpe <christina.schimpe@intel.com>

Sign-extend watchpoint address for kernel space support.
---
 gdb/amd64-linux-tdep.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index b19b12842fd..285d3dd0ae2 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -52,6 +52,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'
@@ -1848,9 +1850,21 @@ static CORE_ADDR
 amd64_linux_remove_non_address_bits_watchpoint (gdbarch *gdbarch,
 						CORE_ADDR addr)
 {
-  /* Clear insignificant bits of a target address using the untag
-     mask.  */
-  return (addr & amd64_linux_lam_untag_mask ());
+  /* 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.  */
+  addr &= mask;
+
+  /* Sign-extend if we have a kernel-space address.  */
+  if (kernel_address)
+    addr |= ~mask;
+
+  return addr;
 }
 
 static void
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


      parent reply	other threads:[~2024-05-27 10:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27 10:24 [PATCH v2 0/3] Add amd64 LAM watchpoint support Schimpe, Christina
2024-05-27 10:24 ` [PATCH v2 1/3] gdb: Make tagged pointer support configurable Schimpe, Christina
2024-06-03  7:58   ` Willgerodt, Felix
2024-06-03  8:40     ` Schimpe, Christina
2024-06-03 13:29       ` Luis Machado
2024-06-03 14:13         ` Schimpe, Christina
2024-06-10 14:00           ` Luis Machado
2024-06-10 15:05             ` Schimpe, Christina
2024-06-14  9:38               ` Schimpe, Christina
2024-06-14  9:54                 ` Schimpe, Christina
2024-06-14 10:09                 ` Luis Machado
2024-05-27 10:24 ` [PATCH v2 2/3] LAM: Enable tagged pointer support for watchpoints Schimpe, Christina
2024-06-03  7:58   ` Willgerodt, Felix
2024-06-03 12:04     ` Schimpe, Christina
2024-06-03 12:48       ` Willgerodt, Felix
2024-06-03 14:25         ` Schimpe, Christina
2024-05-27 10:24 ` Schimpe, Christina [this message]

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=20240527102423.1361410-4-christina.schimpe@intel.com \
    --to=christina.schimpe@intel.com \
    --cc=eliz@gnu.org \
    --cc=felix.willgerodt@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@arm.com \
    /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