amd64-mpx: initialize BND register before performing inferior calls.
authorWalfred Tedeschi <walfred.tedeschi@intel.com>
Tue, 7 Mar 2017 12:53:41 +0000 (13:53 +0100)
committerWalfred Tedeschi <walfred.tedeschi@intel.com>
Tue, 7 Mar 2017 12:53:41 +0000 (13:53 +0100)
commit4a612d6f67d605f480ce7eec7fd9ca1cd1087b35
tree326f4d3f1a5c7e1aebe2abeef5b7b3fc1d3e22ef
parentea86f5344298e24801c262d9b52afcc9cb692959
amd64-mpx: initialize BND register before performing inferior calls.

This patch initializes the BND registers before executing the inferior
call.  BND registers can be in arbitrary values at the moment of the
inferior call.  In case the function being called uses as part of the
parameters BND register, e.g. when passing a pointer as parameter, the
current value of the register will be used.  This can cause boundary
violations that are not due to a real bug or even desired by the user.
In this sense the best to be done is set the BND registers to allow
access to the whole memory, i.e. initialized state, before pushing the
inferior call.

2017-03-07  Walfred Tedeschi <walfred.tedeschi@intel.com>

gdb/ChangeLog:

* i387-tdep.h (i387_reset_bnd_regs): Add function definition.
* i387-tdep.c (i387_reset_bnd_regs): Add function implementation.
* i386-tdep.c (i386_push_dummy_call): Call i387_reset_bnd_regs.
* amd64-tdep (amd64_push_dummy_call): Call i387_reset_bnd_regs.

gdb/testsuite/ChangeLog:

* i386-mpx-call.c: New file.
* i386-mpx-call.exp: New file.

gdb/doc/ChangeLog:

* Memory Protection Extensions: Add information about inferior
calls.
gdb/ChangeLog
gdb/amd64-tdep.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/i386-tdep.c
gdb/i387-tdep.c
gdb/i387-tdep.h
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.arch/i386-mpx-call.c [new file with mode: 0644]
gdb/testsuite/gdb.arch/i386-mpx-call.exp [new file with mode: 0644]