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: christina.schimpe@intel.com
Subject: [PATCH 3/3] LAM: Support kernel space debugging
Date: Wed, 27 Mar 2024 07:47:39 +0000	[thread overview]
Message-ID: <20240327074739.2969623-4-christina.schimpe@intel.com> (raw)
In-Reply-To: <20240327074739.2969623-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 | 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;
 }
 
 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 <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


  parent reply	other threads:[~2024-03-27  7:49 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 ` Schimpe, Christina [this message]
2024-04-24 11:11   ` [PATCH 3/3] LAM: Support kernel space debugging Willgerodt, Felix
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=20240327074739.2969623-4-christina.schimpe@intel.com \
    --to=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