From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108463 invoked by alias); 16 Feb 2017 14:52:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 108438 invoked by uid 89); 16 Feb 2017 14:52:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=contradict, H*f:sk:bb6c4c9, H*i:sk:bb6c4c9, H*MI:sk:bb6c4c9 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Feb 2017 14:52:21 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 768DE61BA5; Thu, 16 Feb 2017 14:52:21 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1GEqIUT032238; Thu, 16 Feb 2017 09:52:19 -0500 Subject: Re: [PATCH V7] amd64-mpx: initialize bnd register before performing inferior calls. To: "Tedeschi, Walfred" , "qiyaoltc@gmail.com" , "brobecker@adacore.com" References: <1485875613-31975-1-git-send-email-walfred.tedeschi@intel.com> <53d42bb6-3b83-6213-4087-6d30e7d837de@redhat.com> <217a8c13-b7d0-7fe6-56b5-85ff53ce097a@intel.com> <88c7180f-8843-a148-425a-2adf56c6d0bf@redhat.com> <32693426-fbaf-8345-04c7-e2c329d6ec6e@intel.com> Cc: "gdb-patches@sourceware.org" From: Pedro Alves Message-ID: <65ae9889-ab18-7228-c612-d47ec728174f@redhat.com> Date: Thu, 16 Feb 2017 14:52:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-02/txt/msg00441.txt.bz2 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