public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* New siginfo type in kernel how to make gdb back compatible.
@ 2015-07-17 12:35 Tedeschi, Walfred
  2015-07-17 15:41 ` Yao Qi
  0 siblings, 1 reply; 3+ messages in thread
From: Tedeschi, Walfred @ 2015-07-17 12:35 UTC (permalink / raw)
  To: Joel Brobecker (brobecker@adacore.com),
	Yao Qi (qiyaoltc@gmail.com), Pedro Alves (palves@redhat.com)
  Cc: gdb

Hello All,

With Memory protection extensions the siginfo type has got new fields and new interpretation for a segmentation fault.
A segmentation fault can be now a signal for a bound violation. This is represented by segmentation fault with sigcode 3.

The new siginfo structure can be found here:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/include/uapi/asm-generic/siginfo.h?id=refs/tags/v4.1.2

to be more elucidative the sigfault part of the sifields is now:

		struct {
			void __user *_addr; /* faulting insn/memory ref. */
#ifdef __ARCH_SI_TRAPNO
			int _trapno;	/* TRAP # which caused the signal */
#endif
			short _addr_lsb; /* LSB of the reported address */
			struct {
				void __user *_lower;   /* <<<<<---- new field */
				void __user *_upper; /* <<<<<---- new field */
			} _addr_bnd;
		} _sigfault;


Glibc will have also to follow those changes.

GDB should be nevertheless back compatible, i.e. capable of displaying the siginfo for applications running on systems having  older glibc.

In case this is desirable and I do think it is.

How should we think about resolving that in terms of the siginfo type redefined inside of GDB?

I first thought about using the __libc_version, but not sure if this is a brilliant idea.


Thanks a lot and best regards,
-Fred

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Prof. Dr. Hermann Eul
Chairperson of the Supervisory Board: Tiffany Doon Silva
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

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

* Re: New siginfo type in kernel how to make gdb back compatible.
  2015-07-17 12:35 New siginfo type in kernel how to make gdb back compatible Tedeschi, Walfred
@ 2015-07-17 15:41 ` Yao Qi
  2015-07-20  7:54   ` Tedeschi, Walfred
  0 siblings, 1 reply; 3+ messages in thread
From: Yao Qi @ 2015-07-17 15:41 UTC (permalink / raw)
  To: Tedeschi, Walfred
  Cc: Joel Brobecker (brobecker@adacore.com),
	Yao Qi (qiyaoltc@gmail.com), Pedro Alves (palves@redhat.com),
	gdb

"Tedeschi, Walfred" <walfred.tedeschi@intel.com> writes:

> GDB should be nevertheless back compatible, i.e. capable of displaying the siginfo for applications running on systems having  older glibc.
>
> In case this is desirable and I do think it is.
>
> How should we think about resolving that in terms of the siginfo type redefined inside of GDB?

GDB creates a type for "struct siginfo" in
linux-tdep.c:linux_get_siginfo_type, and it should work well on both old
kernel and new kernel, because the new fields are added the end of
_sigfault.

If you want to show these new added fields $_siginfo, then, I am not
very sure.  How are these two fields used?  Are they only used when MPX
is enabled in linux kernel?  If so probably we can overwrite the default
linux one (linux_get_siginfo_type) with a new one
(linux_get_siginfo_type_1, for example) if i386_mpx_enabled is true.
linux_get_siginfo_type_1 returns the type with new fields, and we call
set_gdbarch_get_siginfo_type in i386_linux_init_abi like this,

  if (i386_mpx_enabled)
    set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type_1);

-- 
Yao (齐尧)

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

* RE: New siginfo type in kernel how to make gdb back compatible.
  2015-07-17 15:41 ` Yao Qi
@ 2015-07-20  7:54   ` Tedeschi, Walfred
  0 siblings, 0 replies; 3+ messages in thread
From: Tedeschi, Walfred @ 2015-07-20  7:54 UTC (permalink / raw)
  To: Yao Qi, gdb

Hello Yao,

I was creating the patch exactly in the way you described during early phases. But looks like the changes for boundaries have been added to the generic siginfo type on the kernel side. 
https://lkml.org/lkml/2014/9/11/977


Though in the general siginfo, the new fields are used only by MPX. 
I am considering that the right way is to adapt the general structure then. Is this ok?

Thanks and regards,
-Fred

-----Original Message-----
From: Yao Qi [mailto:qiyaoltc@gmail.com] 
Sent: Friday, July 17, 2015 5:41 PM
To: Tedeschi, Walfred
Cc: Joel Brobecker (brobecker@adacore.com); Yao Qi (qiyaoltc@gmail.com); Pedro Alves (palves@redhat.com); gdb@sourceware.org
Subject: Re: New siginfo type in kernel how to make gdb back compatible.

"Tedeschi, Walfred" <walfred.tedeschi@intel.com> writes:

> GDB should be nevertheless back compatible, i.e. capable of displaying the siginfo for applications running on systems having  older glibc.
>
> In case this is desirable and I do think it is.
>
> How should we think about resolving that in terms of the siginfo type redefined inside of GDB?

GDB creates a type for "struct siginfo" in linux-tdep.c:linux_get_siginfo_type, and it should work well on both old kernel and new kernel, because the new fields are added the end of _sigfault.

If you want to show these new added fields $_siginfo, then, I am not very sure.  How are these two fields used?  Are they only used when MPX is enabled in linux kernel?  If so probably we can overwrite the default linux one (linux_get_siginfo_type) with a new one (linux_get_siginfo_type_1, for example) if i386_mpx_enabled is true.
linux_get_siginfo_type_1 returns the type with new fields, and we call set_gdbarch_get_siginfo_type in i386_linux_init_abi like this,

  if (i386_mpx_enabled)
    set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type_1);

--
Yao (齐尧)
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Prof. Dr. Hermann Eul
Chairperson of the Supervisory Board: Tiffany Doon Silva
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

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

end of thread, other threads:[~2015-07-20  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-17 12:35 New siginfo type in kernel how to make gdb back compatible Tedeschi, Walfred
2015-07-17 15:41 ` Yao Qi
2015-07-20  7:54   ` Tedeschi, Walfred

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).