From patchwork Wed Oct 8 11:40:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Agarwal X-Patchwork-Id: 3136 Received: (qmail 10664 invoked by alias); 8 Oct 2014 11:40:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 10654 invoked by uid 89); 8 Oct 2014 11:40:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: na01-bn1-obe.outbound.protection.outlook.com Received: from mail-bn1on0082.outbound.protection.outlook.com (HELO na01-bn1-obe.outbound.protection.outlook.com) (157.56.110.82) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 08 Oct 2014 11:40:34 +0000 Received: from BN1BFFO11FD027.protection.gbl (10.58.144.34) by BN1BFFO11HUB054.protection.gbl (10.58.144.201) with Microsoft SMTP Server (TLS) id 15.0.1039.16; Wed, 8 Oct 2014 11:40:30 +0000 Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BN1BFFO11FD027.mail.protection.outlook.com (10.58.144.90) with Microsoft SMTP Server (TLS) id 15.0.1039.16 via Frontend Transport; Wed, 8 Oct 2014 11:40:29 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-smtp1) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1XbpZs-00046D-R9; Wed, 08 Oct 2014 04:38:44 -0700 From: Ajit Kumar Agarwal To: Pedro Alves , "gdb-patches@sourceware.org" CC: Vinod Kathail , Vidhumouli Hunsigida , Nagaraju Mekala Subject: RE: [PATCH] Microblaze: Reject invalid target descriptions. Date: Wed, 8 Oct 2014 11:40:27 +0000 MIME-Version: 1.0 X-RCIS-Action: ALLOW Message-ID: <8a209dc112fe40ab9652220413f6fffa@BN1BFFO11FD027.protection.gbl> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(438002)(51704005)(13464003)(189002)(199003)(164054003)(377424004)(377454003)(479174003)(24454002)(120916001)(74316001)(33646002)(85306004)(104016003)(54356999)(95666004)(50986999)(46406003)(53416004)(21056001)(77096002)(108616004)(80022003)(46102003)(2656002)(50466002)(92566001)(99396003)(19580395003)(97756001)(87936001)(86362001)(575784001)(85852003)(23726002)(20776003)(6806004)(106466001)(64706001)(107046002)(44976005)(4396001)(19580405001)(31966008)(76482002)(47776003)(107986001)(24736002)(23106004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1BFFO11HUB054; H:xsj-pvapsmtpgw01; FPR:; MLV:sfv; PTR:unknown-60-83.xilinx.com; MX:1; A:1; LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BN1BFFO11HUB054; X-Forefront-PRVS: 0358535363 Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=ajit.kumar.agarwal@xilinx.com; X-OriginatorOrg: xilinx.com I have copied the patch file. Please find the git log message for this patch. Microblaze: Reject invalid target descriptions. We currently validate the target description, but then forget to reject it if found invalid. Tested the Microblaze Design with and without stack-protect registers. The gdb command "info registers" displayed the register correctly. If stack protect designs is not selected only core registers are displayed. When the stack-protect register is selected in the design, the core registers along with stack-protect registers are displayed. gdb/ 2014-10-08 Ajit Agarwal * microblaze-tdep.c (microblaze_gdbarch_init): If the description isn't valid, release the tdesc arch data and return NULL. Signed-off-by:Ajit Agarwal ajitkum@xilinx.com Thanks & Regards Ajit -----Original Message----- From: Ajit Kumar Agarwal Sent: Wednesday, October 08, 2014 5:06 PM To: 'Pedro Alves'; gdb-patches@sourceware.org Cc: Vinod Kathail; Vidhumouli Hunsigida; Nagaraju Mekala Subject: [PATCH] Microblaze: Reject invalid target descriptions. Hello Pedro: Please find the updated patch with the feedback incorporated. [Pedro]: Sure you do. Just hack your target or gdbserver to send a bogus description. Tested . From f69e29dbda0669ee0f5b263c0aab094db6960693 Mon Sep 17 00:00:00 2001 From: Ajit Kumar Agarwal Date: Tue, 7 Oct 2014 15:06:08 +0530 Subject: [PATCH] Microblaze: Reject invalid target descriptions. We currently validate the target description, but then forget to reject it if found invalid. Tested the Microblaze Design with and without stack-protect registers. The gdb command "info registers" displayed the register correctly. If stack protect designs is not selected only core registers are displayed. When the stack-protect register is selected in the design, the core registers along with stack-protect registers are displayed. gdb/ 2014-10-08 Ajit Agarwal * microblaze-tdep.c (microblaze_gdbarch_init): If the description isn't valid, release the tdesc arch data and return NULL. Signed-off-by:Ajit Agarwal ajitkum@xilinx.com --- gdb/microblaze-tdep.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) -- 1.7.1 Thanks & Regards Ajit -----Original Message----- From: Pedro Alves [mailto:palves@redhat.com] Sent: Tuesday, October 07, 2014 10:39 PM To: Ajit Kumar Agarwal; gdb-patches@sourceware.org Cc: Vinod Kathail; Vidhumouli Hunsigida; Nagaraju Mekala Subject: Re: [Patch, microblaze]: Added cleanup data for invalid target description On 10/07/2014 05:36 PM, Ajit Kumar Agarwal wrote: > > > -----Original Message----- > From: Pedro Alves [mailto:palves@redhat.com] > Sent: Tuesday, October 07, 2014 9:37 PM > To: Ajit Kumar Agarwal; gdb-patches@sourceware.org > Cc: Vinod Kathail; Vidhumouli Hunsigida; Nagaraju Mekala > Subject: Re: [Patch, microblaze]: Added cleanup data for invalid > target description > > On 10/07/2014 11:16 AM, Ajit Kumar Agarwal wrote: >> >> From 00f2692d10e0254366471095516d657693aeff42 Mon Sep 17 00:00:00 >> 2001 >> From: Ajit Kumar Agarwal >> Date: Tue, 7 Oct 2014 15:06:08 +0530 >> Subject: [PATCH] [Patch, microblaze]: Added cleanup data for invalid target description. > >>> s/Added/Add/. But even better would be saying what this actually intends to do, which is "reject". Note the [PATCH] tag usually end ups stripped when >>the commit is imported into git, but the redundant [Patch, ...] seems like something you added manually, and is unnecessary. > > Thanks for the suggestion. >> >> Cleanup the tdesc data if the target description check is invalid. >> >> 2014-10-07 Ajit Agarwal >> >> * microblaze-tdep.c (microblaze_gdbarch_init): Use of >> tdesc_data_cleanup. > > So, I'd write: > > ~~~ >>> [PATCH] Microblaze: Reject invalid target descriptions > >>> We currently validate the target description, but then forget to reject it if found invalid. > >>> gdb/ >>> 2014-10-07 Ajit Agarwal > >>> * microblaze-tdep.c (microblaze_gdbarch_init): If the description >>> isn't valid, release the tdesc arch data and return NULL. > ~~~ > > I will make this Change. Thanks for suggestion. > >>> But, you didn't state how you tested this, which should be part of the commit log too. > > I have tested the Microblaze Design with and without stack -protect registers. The gdb command "info registers" displayed the register correctly. If stack protect designs is not selected only core registers are displayed. When the stack-protect register is selected in the design, the core registers along with stack-protect registers are displayed. Please remember to always state this in the commit/submit log. I've now added an explicit bullet item for that to the contribution checklist. > >>> Did you make sure incorrect descriptions are rejected and GDB warns about them? > > We don't have the invalid Microblaze design with which I can test gdb warning and cleaning up the tdesc data. Sure you do. Just hack your target or gdbserver to send a bogus description. Thanks, Pedro Alves diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c index 6a9f11f..f257b96 100644 --- a/gdb/microblaze-tdep.c +++ b/gdb/microblaze-tdep.c @@ -722,7 +722,13 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) MICROBLAZE_SHR_REGNUM, "rshr"); } - } + + if (!valid_p) + { + tdesc_data_cleanup (tdesc_data); + return NULL; + } + } /* Allocate space for the new architecture. */ tdep = XNEW (struct gdbarch_tdep);