public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: Consolidate 32bit-pkeys.xml and 64bit-pkeys.xml
@ 2022-02-24 15:34 H.J. Lu
  2022-03-30 13:33 ` PING^1 " H.J. Lu
  2022-03-31 14:36 ` Pedro Alves
  0 siblings, 2 replies; 4+ messages in thread
From: H.J. Lu @ 2022-02-24 15:34 UTC (permalink / raw)
  To: GDB; +Cc: Walfred Tedeschi, Michael Sturm

1. Since 32bit-pkeys.xml and 64bit-pkeys.xml are identical, consolidate
them into a signal keys.xml.
2. Enable PKU for x32 to fix:

$ gdbserver :123456 x32-program
...
.../gdbserver/regcache.cc:255: A problem internal to GDBserver has been detected
.
Unknown register pkru requested

on Tiger Lake.
---
 gdb/amd64-linux-tdep.c                           |  6 ++++--
 gdb/arch/amd64.c                                 |  6 +++---
 gdb/arch/i386.c                                  |  4 ++--
 gdb/features/Makefile                            |  3 +--
 gdb/features/i386/64bit-pkeys.c                  | 14 --------------
 gdb/features/i386/64bit-pkeys.xml                | 13 -------------
 gdb/features/i386/{32bit-pkeys.c => pkeys.c}     |  4 ++--
 gdb/features/i386/{32bit-pkeys.xml => pkeys.xml} |  0
 8 files changed, 12 insertions(+), 38 deletions(-)
 delete mode 100644 gdb/features/i386/64bit-pkeys.c
 delete mode 100644 gdb/features/i386/64bit-pkeys.xml
 rename gdb/features/i386/{32bit-pkeys.c => pkeys.c} (74%)
 rename gdb/features/i386/{32bit-pkeys.xml => pkeys.xml} (100%)

diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 2416204310f..a3038622442 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1578,14 +1578,16 @@ amd64_linux_read_description (uint64_t xcr0_features_bit, bool is_x32)
 {
   static target_desc *amd64_linux_tdescs \
     [2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/] = {};
-  static target_desc *x32_linux_tdescs[2/*AVX*/][2/*AVX512*/] = {};
+  static target_desc *x32_linux_tdescs \
+    [2/*AVX*/][2/*AVX512*/][2/*PKRU*/] = {};
 
   target_desc **tdesc;
 
   if (is_x32)
     {
       tdesc = &x32_linux_tdescs[(xcr0_features_bit & X86_XSTATE_AVX) ? 1 : 0 ]
-	[(xcr0_features_bit & X86_XSTATE_AVX512) ? 1 : 0];
+	[(xcr0_features_bit & X86_XSTATE_AVX512) ? 1 : 0]
+	[(xcr0_features_bit & X86_XSTATE_PKRU) ? 1 : 0];
     }
   else
     {
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index 20716524e62..559f678d356 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -25,9 +25,9 @@
 #include "../features/i386/64bit-core.c"
 #include "../features/i386/64bit-linux.c"
 #include "../features/i386/64bit-mpx.c"
-#include "../features/i386/64bit-pkeys.c"
 #include "../features/i386/64bit-segments.c"
 #include "../features/i386/64bit-sse.c"
+#include "../features/i386/pkeys.c"
 
 #include "../features/i386/x32-core.c"
 
@@ -72,8 +72,8 @@ amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
   if (xcr0 & X86_XSTATE_AVX512)
     regnum = create_feature_i386_64bit_avx512 (tdesc.get (), regnum);
 
-  if ((xcr0 & X86_XSTATE_PKRU) && !is_x32)
-    regnum = create_feature_i386_64bit_pkeys (tdesc.get (), regnum);
+  if (xcr0 & X86_XSTATE_PKRU)
+    regnum = create_feature_i386_pkeys (tdesc.get (), regnum);
 
   return tdesc.release ();
 }
diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c
index 6241053783b..f5b33a800ad 100644
--- a/gdb/arch/i386.c
+++ b/gdb/arch/i386.c
@@ -27,8 +27,8 @@
 #include "../features/i386/32bit-avx.c"
 #include "../features/i386/32bit-avx512.c"
 #include "../features/i386/32bit-mpx.c"
-#include "../features/i386/32bit-pkeys.c"
 #include "../features/i386/32bit-segments.c"
+#include "../features/i386/pkeys.c"
 
 /* Create i386 target descriptions according to XCR0.  */
 
@@ -67,7 +67,7 @@ i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
     regnum = create_feature_i386_32bit_avx512 (tdesc.get (), regnum);
 
   if (xcr0 & X86_XSTATE_PKRU)
-    regnum = create_feature_i386_32bit_pkeys (tdesc.get (), regnum);
+    regnum = create_feature_i386_pkeys (tdesc.get (), regnum);
 
   return tdesc.release ();
 }
diff --git a/gdb/features/Makefile b/gdb/features/Makefile
index 68e17d0085d..a2bb2a5922f 100644
--- a/gdb/features/Makefile
+++ b/gdb/features/Makefile
@@ -216,7 +216,6 @@ FEATURE_XMLFILES = aarch64-core.xml \
 	i386/32bit-avx.xml \
 	i386/32bit-mpx.xml \
 	i386/32bit-avx512.xml \
-	i386/32bit-pkeys.xml \
 	i386/32bit-segments.xml \
 	i386/64bit-avx512.xml \
 	i386/64bit-core.xml \
@@ -224,8 +223,8 @@ FEATURE_XMLFILES = aarch64-core.xml \
 	i386/64bit-segments.xml \
 	i386/64bit-avx.xml \
 	i386/64bit-linux.xml \
-	i386/64bit-pkeys.xml \
 	i386/64bit-sse.xml \
+	i386/pkeys.xml \
 	i386/x32-core.xml \
 	loongarch/base32.xml \
 	loongarch/base64.xml \
diff --git a/gdb/features/i386/64bit-pkeys.c b/gdb/features/i386/64bit-pkeys.c
deleted file mode 100644
index 83001d4a876..00000000000
--- a/gdb/features/i386/64bit-pkeys.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: 64bit-pkeys.xml */
-
-#include "gdbsupport/tdesc.h"
-
-static int
-create_feature_i386_64bit_pkeys (struct target_desc *result, long regnum)
-{
-  struct tdesc_feature *feature;
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pkeys");
-  tdesc_create_reg (feature, "pkru", regnum++, 1, NULL, 32, "uint32");
-  return regnum;
-}
diff --git a/gdb/features/i386/64bit-pkeys.xml b/gdb/features/i386/64bit-pkeys.xml
deleted file mode 100644
index db6c10af65f..00000000000
--- a/gdb/features/i386/64bit-pkeys.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2016-2022 Free Software Foundation, Inc.
-
-     Copying and distribution of this file, with or without modification,
-     are permitted in any medium without royalty provided the copyright
-     notice and this notice are preserved.  -->
-
-<!DOCTYPE feature SYSTEM "gdb-target.dtd">
-<feature name="org.gnu.gdb.i386.pkeys">
-
-  <reg name="pkru" bitsize="32" type="uint32"/>
-
-</feature>
diff --git a/gdb/features/i386/32bit-pkeys.c b/gdb/features/i386/pkeys.c
similarity index 74%
rename from gdb/features/i386/32bit-pkeys.c
rename to gdb/features/i386/pkeys.c
index 5e9087e4303..955d563176a 100644
--- a/gdb/features/i386/32bit-pkeys.c
+++ b/gdb/features/i386/pkeys.c
@@ -1,10 +1,10 @@
 /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: 32bit-pkeys.xml */
+  Original: pkeys.xml */
 
 #include "gdbsupport/tdesc.h"
 
 static int
-create_feature_i386_32bit_pkeys (struct target_desc *result, long regnum)
+create_feature_i386_pkeys (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;
 
diff --git a/gdb/features/i386/32bit-pkeys.xml b/gdb/features/i386/pkeys.xml
similarity index 100%
rename from gdb/features/i386/32bit-pkeys.xml
rename to gdb/features/i386/pkeys.xml
-- 
2.35.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* PING^1 [PATCH] gdb: Consolidate 32bit-pkeys.xml and 64bit-pkeys.xml
  2022-02-24 15:34 [PATCH] gdb: Consolidate 32bit-pkeys.xml and 64bit-pkeys.xml H.J. Lu
@ 2022-03-30 13:33 ` H.J. Lu
  2022-03-31 14:36 ` Pedro Alves
  1 sibling, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2022-03-30 13:33 UTC (permalink / raw)
  To: GDB; +Cc: Walfred Tedeschi, Michael Sturm

On Thu, Feb 24, 2022 at 7:34 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> 1. Since 32bit-pkeys.xml and 64bit-pkeys.xml are identical, consolidate
> them into a signal keys.xml.
> 2. Enable PKU for x32 to fix:
>
> $ gdbserver :123456 x32-program
> ...
> .../gdbserver/regcache.cc:255: A problem internal to GDBserver has been detected
> .
> Unknown register pkru requested
>
> on Tiger Lake.
> ---
>  gdb/amd64-linux-tdep.c                           |  6 ++++--
>  gdb/arch/amd64.c                                 |  6 +++---
>  gdb/arch/i386.c                                  |  4 ++--
>  gdb/features/Makefile                            |  3 +--
>  gdb/features/i386/64bit-pkeys.c                  | 14 --------------
>  gdb/features/i386/64bit-pkeys.xml                | 13 -------------
>  gdb/features/i386/{32bit-pkeys.c => pkeys.c}     |  4 ++--
>  gdb/features/i386/{32bit-pkeys.xml => pkeys.xml} |  0
>  8 files changed, 12 insertions(+), 38 deletions(-)
>  delete mode 100644 gdb/features/i386/64bit-pkeys.c
>  delete mode 100644 gdb/features/i386/64bit-pkeys.xml
>  rename gdb/features/i386/{32bit-pkeys.c => pkeys.c} (74%)
>  rename gdb/features/i386/{32bit-pkeys.xml => pkeys.xml} (100%)
>
> diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
> index 2416204310f..a3038622442 100644
> --- a/gdb/amd64-linux-tdep.c
> +++ b/gdb/amd64-linux-tdep.c
> @@ -1578,14 +1578,16 @@ amd64_linux_read_description (uint64_t xcr0_features_bit, bool is_x32)
>  {
>    static target_desc *amd64_linux_tdescs \
>      [2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/] = {};
> -  static target_desc *x32_linux_tdescs[2/*AVX*/][2/*AVX512*/] = {};
> +  static target_desc *x32_linux_tdescs \
> +    [2/*AVX*/][2/*AVX512*/][2/*PKRU*/] = {};
>
>    target_desc **tdesc;
>
>    if (is_x32)
>      {
>        tdesc = &x32_linux_tdescs[(xcr0_features_bit & X86_XSTATE_AVX) ? 1 : 0 ]
> -       [(xcr0_features_bit & X86_XSTATE_AVX512) ? 1 : 0];
> +       [(xcr0_features_bit & X86_XSTATE_AVX512) ? 1 : 0]
> +       [(xcr0_features_bit & X86_XSTATE_PKRU) ? 1 : 0];
>      }
>    else
>      {
> diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
> index 20716524e62..559f678d356 100644
> --- a/gdb/arch/amd64.c
> +++ b/gdb/arch/amd64.c
> @@ -25,9 +25,9 @@
>  #include "../features/i386/64bit-core.c"
>  #include "../features/i386/64bit-linux.c"
>  #include "../features/i386/64bit-mpx.c"
> -#include "../features/i386/64bit-pkeys.c"
>  #include "../features/i386/64bit-segments.c"
>  #include "../features/i386/64bit-sse.c"
> +#include "../features/i386/pkeys.c"
>
>  #include "../features/i386/x32-core.c"
>
> @@ -72,8 +72,8 @@ amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
>    if (xcr0 & X86_XSTATE_AVX512)
>      regnum = create_feature_i386_64bit_avx512 (tdesc.get (), regnum);
>
> -  if ((xcr0 & X86_XSTATE_PKRU) && !is_x32)
> -    regnum = create_feature_i386_64bit_pkeys (tdesc.get (), regnum);
> +  if (xcr0 & X86_XSTATE_PKRU)
> +    regnum = create_feature_i386_pkeys (tdesc.get (), regnum);
>
>    return tdesc.release ();
>  }
> diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c
> index 6241053783b..f5b33a800ad 100644
> --- a/gdb/arch/i386.c
> +++ b/gdb/arch/i386.c
> @@ -27,8 +27,8 @@
>  #include "../features/i386/32bit-avx.c"
>  #include "../features/i386/32bit-avx512.c"
>  #include "../features/i386/32bit-mpx.c"
> -#include "../features/i386/32bit-pkeys.c"
>  #include "../features/i386/32bit-segments.c"
> +#include "../features/i386/pkeys.c"
>
>  /* Create i386 target descriptions according to XCR0.  */
>
> @@ -67,7 +67,7 @@ i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
>      regnum = create_feature_i386_32bit_avx512 (tdesc.get (), regnum);
>
>    if (xcr0 & X86_XSTATE_PKRU)
> -    regnum = create_feature_i386_32bit_pkeys (tdesc.get (), regnum);
> +    regnum = create_feature_i386_pkeys (tdesc.get (), regnum);
>
>    return tdesc.release ();
>  }
> diff --git a/gdb/features/Makefile b/gdb/features/Makefile
> index 68e17d0085d..a2bb2a5922f 100644
> --- a/gdb/features/Makefile
> +++ b/gdb/features/Makefile
> @@ -216,7 +216,6 @@ FEATURE_XMLFILES = aarch64-core.xml \
>         i386/32bit-avx.xml \
>         i386/32bit-mpx.xml \
>         i386/32bit-avx512.xml \
> -       i386/32bit-pkeys.xml \
>         i386/32bit-segments.xml \
>         i386/64bit-avx512.xml \
>         i386/64bit-core.xml \
> @@ -224,8 +223,8 @@ FEATURE_XMLFILES = aarch64-core.xml \
>         i386/64bit-segments.xml \
>         i386/64bit-avx.xml \
>         i386/64bit-linux.xml \
> -       i386/64bit-pkeys.xml \
>         i386/64bit-sse.xml \
> +       i386/pkeys.xml \
>         i386/x32-core.xml \
>         loongarch/base32.xml \
>         loongarch/base64.xml \
> diff --git a/gdb/features/i386/64bit-pkeys.c b/gdb/features/i386/64bit-pkeys.c
> deleted file mode 100644
> index 83001d4a876..00000000000
> --- a/gdb/features/i386/64bit-pkeys.c
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
> -  Original: 64bit-pkeys.xml */
> -
> -#include "gdbsupport/tdesc.h"
> -
> -static int
> -create_feature_i386_64bit_pkeys (struct target_desc *result, long regnum)
> -{
> -  struct tdesc_feature *feature;
> -
> -  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pkeys");
> -  tdesc_create_reg (feature, "pkru", regnum++, 1, NULL, 32, "uint32");
> -  return regnum;
> -}
> diff --git a/gdb/features/i386/64bit-pkeys.xml b/gdb/features/i386/64bit-pkeys.xml
> deleted file mode 100644
> index db6c10af65f..00000000000
> --- a/gdb/features/i386/64bit-pkeys.xml
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -<?xml version="1.0"?>
> -<!-- Copyright (C) 2016-2022 Free Software Foundation, Inc.
> -
> -     Copying and distribution of this file, with or without modification,
> -     are permitted in any medium without royalty provided the copyright
> -     notice and this notice are preserved.  -->
> -
> -<!DOCTYPE feature SYSTEM "gdb-target.dtd">
> -<feature name="org.gnu.gdb.i386.pkeys">
> -
> -  <reg name="pkru" bitsize="32" type="uint32"/>
> -
> -</feature>
> diff --git a/gdb/features/i386/32bit-pkeys.c b/gdb/features/i386/pkeys.c
> similarity index 74%
> rename from gdb/features/i386/32bit-pkeys.c
> rename to gdb/features/i386/pkeys.c
> index 5e9087e4303..955d563176a 100644
> --- a/gdb/features/i386/32bit-pkeys.c
> +++ b/gdb/features/i386/pkeys.c
> @@ -1,10 +1,10 @@
>  /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
> -  Original: 32bit-pkeys.xml */
> +  Original: pkeys.xml */
>
>  #include "gdbsupport/tdesc.h"
>
>  static int
> -create_feature_i386_32bit_pkeys (struct target_desc *result, long regnum)
> +create_feature_i386_pkeys (struct target_desc *result, long regnum)
>  {
>    struct tdesc_feature *feature;
>
> diff --git a/gdb/features/i386/32bit-pkeys.xml b/gdb/features/i386/pkeys.xml
> similarity index 100%
> rename from gdb/features/i386/32bit-pkeys.xml
> rename to gdb/features/i386/pkeys.xml
> --
> 2.35.1
>

PING.

-- 
H.J.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb: Consolidate 32bit-pkeys.xml and 64bit-pkeys.xml
  2022-02-24 15:34 [PATCH] gdb: Consolidate 32bit-pkeys.xml and 64bit-pkeys.xml H.J. Lu
  2022-03-30 13:33 ` PING^1 " H.J. Lu
@ 2022-03-31 14:36 ` Pedro Alves
  2022-03-31 17:13   ` H.J. Lu
  1 sibling, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2022-03-31 14:36 UTC (permalink / raw)
  To: H.J. Lu, GDB; +Cc: Walfred Tedeschi, Michael Sturm

On 2022-02-24 15:34, H.J. Lu via Gdb-patches wrote:
> 1. Since 32bit-pkeys.xml and 64bit-pkeys.xml are identical, consolidate
> them into a signal keys.xml.

I guess s/signal/single/.

> 2. Enable PKU for x32 to fix:
> 
> $ gdbserver :123456 x32-program
> ...
> .../gdbserver/regcache.cc:255: A problem internal to GDBserver has been detected
> .
> Unknown register pkru requested
> 
> on Tiger Lake.

Otherwise OK.  Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb: Consolidate 32bit-pkeys.xml and 64bit-pkeys.xml
  2022-03-31 14:36 ` Pedro Alves
@ 2022-03-31 17:13   ` H.J. Lu
  0 siblings, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2022-03-31 17:13 UTC (permalink / raw)
  To: Pedro Alves; +Cc: GDB, Walfred Tedeschi, Michael Sturm

[-- Attachment #1: Type: text/plain, Size: 589 bytes --]

On Thu, Mar 31, 2022 at 7:36 AM Pedro Alves <pedro@palves.net> wrote:
>
> On 2022-02-24 15:34, H.J. Lu via Gdb-patches wrote:
> > 1. Since 32bit-pkeys.xml and 64bit-pkeys.xml are identical, consolidate
> > them into a signal keys.xml.
>
> I guess s/signal/single/.

Fixed.

> > 2. Enable PKU for x32 to fix:
> >
> > $ gdbserver :123456 x32-program
> > ...
> > .../gdbserver/regcache.cc:255: A problem internal to GDBserver has been detected
> > .
> > Unknown register pkru requested
> >
> > on Tiger Lake.
>
> Otherwise OK.  Thanks.

This is the patch I am checking in.

Thanks.


--
H.J.

[-- Attachment #2: 0001-gdb-Consolidate-32bit-pkeys.xml-and-64bit-pkeys.xml.patch --]
[-- Type: application/x-patch, Size: 6661 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-31 17:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-24 15:34 [PATCH] gdb: Consolidate 32bit-pkeys.xml and 64bit-pkeys.xml H.J. Lu
2022-03-30 13:33 ` PING^1 " H.J. Lu
2022-03-31 14:36 ` Pedro Alves
2022-03-31 17:13   ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).