gdbserver: Clear X86_XSTATE_MPX bits in xcr0 on x32

Message ID 20240319152558.45742-1-hjl.tools@gmail.com
State Dropped
Headers
Series gdbserver: Clear X86_XSTATE_MPX bits in xcr0 on x32 |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Testing passed

Commit Message

H.J. Lu March 19, 2024, 3:25 p.m. UTC
  Since MPX isn't available for x32, we should clear X86_XSTATE_MPX bits
on x32.

	PR server/31511
	* linux-x86-low.cc (x86_linux_read_description): Clear
	X86_XSTATE_MPX bits in xcr0 on x32.
---
 gdbserver/linux-x86-low.cc | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 3af0a009052..28b5d523b8e 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -938,6 +938,10 @@  x86_linux_read_description (void)
 	  xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
 			     / sizeof (uint64_t))];
 
+	  /* No MPX on x32.  */
+	  if (!is_elf64)
+	    xcr0 &= ~X86_XSTATE_MPX;
+
 	  xsave_len = x86_xsave_length ();
 
 	  /* Use PTRACE_GETREGSET if it is available.  */