aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristina Schimpe <christina.schimpe@intel.com>2022-08-10 08:50:37 +0200
committerSchimpe, Christina <christina.schimpe@intel.com>2024-11-18 13:36:16 +0000
commit27e82ad68b5eead610aabaf0e60335cc65cbd738 (patch)
treec3d2afa19d4a85358da5f185093ba15abff0b70d /gdb/testsuite/lib
parentgdb: Make tagged pointer support configurable. (diff)
downloadbinutils-gdb-27e82ad68b5eead610aabaf0e60335cc65cbd738.tar.gz
binutils-gdb-27e82ad68b5eead610aabaf0e60335cc65cbd738.tar.bz2
binutils-gdb-27e82ad68b5eead610aabaf0e60335cc65cbd738.zip
LAM: Enable tagged pointer support for watchpoints.
The Intel (R) linear address masking (LAM) feature modifies the checking applied to 64-bit linear addresses. With this so-called "modified canonicality check" the processor masks the metadata bits in a pointer before using it as a linear address. LAM supports two different modes that differ regarding which pointer bits are masked and can be used for metadata: LAM 48 resulting in a LAM width of 15 and LAM 57 resulting in a LAM width of 6. This patch adjusts watchpoint addresses based on the currently enabled LAM mode using the untag mask provided in the /proc/<pid>/status file. As LAM can be enabled at runtime or as the configuration may change when entering an enclave, GDB checks enablement state each time a watchpoint is updated. In contrast to the patch implemented for ARM's Top Byte Ignore "Clear non-significant bits of address on memory access", it is not necessary to adjust addresses before they are passed to the target layer cache, as for LAM tagged pointers are supported by the system call to read memory. Additionally, LAM applies only to addresses used for data accesses. Thus, it is sufficient to mask addresses used for watchpoints. The following examples are based on a LAM57 enabled program. Before this patch tagged pointers were not supported for watchpoints: ~~~ (gdb) print pi_tagged $2 = (int *) 0x10007ffffffffe004 (gdb) watch *pi_tagged Hardware watchpoint 2: *pi_tagged (gdb) c Continuing. Couldn't write debug register: Invalid argument. ~~~~ Once LAM 48 or LAM 57 is enabled for the current program, GDB can now specify watchpoints for tagged addresses with LAM width 15 or 6, respectively. Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp64
1 files changed, 64 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 410f99e3350..5d4d9db3ea4 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4323,6 +4323,70 @@ gdb_caching_proc allow_avx512fp16_tests {} {
return $allow_avx512fp16_tests
}
+# Run a test on the target to see if it supports LAM 57. Return 1 if so,
+# 0 if it does not. Based on the arch_prctl() handle ARCH_ENABLE_TAGGED_ADDR
+# to enable LAM which fails if the hardware or the OS does not support LAM.
+
+gdb_caching_proc allow_lam_tests {} {
+ global gdb_prompt inferior_exited_re
+
+ set me "allow_lam_tests"
+ if { ![istarget "x86_64-*-*"] } {
+ verbose "$me: target does not support LAM, returning 1" 2
+ return 0
+ }
+
+ # Compile a test program.
+ set src {
+ #define _GNU_SOURCE
+ #include <unistd.h>
+ #include <sys/syscall.h>
+ #include <assert.h>
+ #include <errno.h>
+ #include <asm/prctl.h>
+
+ int configure_lam ()
+ {
+ errno = 0;
+ syscall (SYS_arch_prctl, ARCH_ENABLE_TAGGED_ADDR, 6);
+ assert_perror (errno);
+ return errno;
+ }
+
+ int
+ main () { return configure_lam (); }
+ }
+
+ if {![gdb_simple_compile $me $src executable ""]} {
+ return 0
+ }
+ # No error message, compilation succeeded so now run it via gdb.
+
+ set allow_lam_tests 0
+ clean_restart $obj
+ gdb_run_cmd
+ gdb_expect {
+ -re ".*$inferior_exited_re with code.*${gdb_prompt} $" {
+ verbose -log "$me: LAM support not detected."
+ }
+ -re ".*Program received signal SIGABRT, Aborted.*${gdb_prompt} $" {
+ verbose -log "$me: LAM support not detected."
+ }
+ -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
+ verbose -log "$me: LAM support detected."
+ set allow_lam_tests 1
+ }
+ default {
+ warning "\n$me: default case taken."
+ }
+ }
+ gdb_exit
+ remote_file build delete $obj
+
+ verbose "$me: returning $allow_lam_tests" 2
+ return $allow_lam_tests
+}
+
# Run a test on the target to see if it supports btrace hardware. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.