public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: "Tedeschi, Walfred" <walfred.tedeschi@intel.com>,
	       "qiyaoltc@gmail.com" <qiyaoltc@gmail.com>,
	       "brobecker@adacore.com" <brobecker@adacore.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH V7] amd64-mpx: initialize bnd register before performing inferior calls.
Date: Thu, 16 Feb 2017 14:52:00 -0000	[thread overview]
Message-ID: <65ae9889-ab18-7228-c612-d47ec728174f@redhat.com> (raw)
In-Reply-To: <bb6c4c9c-5145-8585-b396-7e860e30eabd@intel.com>

On 02/16/2017 01:49 PM, Tedeschi, Walfred wrote:

>> Correct?
> Yes.
> But actual behavior at 7 has an issue!

7. is:

>>> 7. expected - control should be back to 1, i.e. on stop mode.
>>> 7. actual behavior - application finishes with the signal

But the rest of your email doesn't talk about this at all.
I'm confused....

> 
> When we set the BND registers from gdb itself (applying the patch) it
> looks like changing the values of BND again while in the prolog have no
> effect.
> Lets go to the reproducer:
> 
> The inferior call i want to do is "upper (x, a, b, c, d, 100)".
> it has the following relevant prolog:
> 
>   0x0000000000400a0b <+1>:    mov    %rsp,%rbp
>    0x0000000000400a0e <+4>:    sub    $0x18,%rsp
>    0x0000000000400a12 <+8>:    mov    %rdi,-0x18(%rbp)
>    0x0000000000400a16 <+12>:    mov    %rsi,-0x20(%rbp)
>    0x0000000000400a1a <+16>:    mov    %rdx,-0x28(%rbp)
>    0x0000000000400a1e <+20>:    mov    %rcx,-0x30(%rbp)
>    0x0000000000400a22 <+24>:    mov    %r8,-0x38(%rbp)
>    0x0000000000400a26 <+28>:    mov    %r9d,-0x3c(%rbp)
>    0x0000000000400a2a <+32>:    bndmov %bnd0,-0x50(%rbp)
>    0x0000000000400a2f <+37>:    bndmov %bnd1,-0x60(%rbp)
>    0x0000000000400a34 <+42>:    bndmov %bnd2,-0x70(%rbp)
>    0x0000000000400a39 <+47>:    bndmov %bnd3,-0x80(%rbp)
> 
> I can stop at the first instruction of "upper" by issuing b (void*)&upper.

FYI, the usual way to do that is with "b *upper".

> In order to verify the effective change in the BND i have printed
> bnd0..bnd3. Register values were same as entered with the GDB command.

printed how?  and printed when exactly?

> Other way is to do instruction stepping till " bndmov %bnd3,-0x80(%rbp)"
> and examine the memory at the indicated places.

Memory?  I thought you'd examine the registers?  What indicated
places, BTW?

> 
> Surprise! In the gdb i have applied the patch though changing the
> BND0..BND3 values at 0x0400a0b value present on memory was still set to
> the init state.

_memory_ set to the init state?

Can you please explain what you're seeing in a bit more detail?
You're leaving out details I'm finding myself needing to guess,
and I'd probably guess wrong.

But still, if I have to guess, I'd think that the problem with
stopping at function entry and poking the bnd registers
_before_ the prologue runs, would be that whatever bnd register value
you patch in, would be overridden by the bndmov instructions in the
prologue.  I.e., you need to single-step past those bndmov
instructions, and patch the bnd registers _then_, otherwise
the bndmovs undo your patching.

But this comment:

> In the version without applying the patch it i could see the value i
> entered while stopped at the first instruction.

... seems to contradict that.  So I'm double confused.

Still, I don't see what does this have to do with point 7.

Thanks,
Pedro Alves

  reply	other threads:[~2017-02-16 14:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 15:13 Walfred Tedeschi
2017-02-06 17:05 ` [ping] " Tedeschi, Walfred
2017-02-06 17:58 ` Pedro Alves
2017-02-07  8:56   ` Tedeschi, Walfred
2017-02-08 12:27     ` Pedro Alves
2017-02-08 16:21       ` Pedro Alves
2017-02-08 16:31         ` Tedeschi, Walfred
2017-02-13  8:33       ` Tedeschi, Walfred
2017-02-13 12:03         ` Pedro Alves
2017-02-13 12:55           ` Tedeschi, Walfred
2017-02-14 13:35         ` Tedeschi, Walfred
2017-02-14 13:59           ` Pedro Alves
2017-02-15 13:02             ` Tedeschi, Walfred
2017-02-15 13:15               ` Pedro Alves
2017-02-16 13:50                 ` Tedeschi, Walfred
2017-02-16 14:52                   ` Pedro Alves [this message]
2017-02-16 15:37                     ` Tedeschi, Walfred
2017-02-16 16:15                       ` Pedro Alves
2017-02-16 16:41                         ` Tedeschi, Walfred

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=65ae9889-ab18-7228-c612-d47ec728174f@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    --cc=walfred.tedeschi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).