From patchwork Fri Mar 18 19:59:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 8623621 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 43C729F44D for ; Fri, 18 Mar 2016 20:03:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D503201FE for ; Fri, 18 Mar 2016 20:03:03 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 242D92021B for ; Fri, 18 Mar 2016 20:03:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ah0Z9-0006SR-4x; Fri, 18 Mar 2016 20:00:11 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ah0Z8-0006SL-0S for xen-devel@lists.xenproject.org; Fri, 18 Mar 2016 20:00:10 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id C6/73-03497-94E5CE65; Fri, 18 Mar 2016 20:00:09 +0000 X-Env-Sender: konrad@char.us.oracle.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1458331207!32376452!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62625 invoked from network); 18 Mar 2016 20:00:08 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-10.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Mar 2016 20:00:08 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u2IJxrac011191 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Mar 2016 19:59:54 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u2IJxrNs029104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 18 Mar 2016 19:59:53 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u2IJxqhS012894; Fri, 18 Mar 2016 19:59:52 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 18 Mar 2016 12:59:52 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id 5BC8B6A00C4; Fri, 18 Mar 2016 15:59:51 -0400 (EDT) Date: Fri, 18 Mar 2016 15:59:51 -0400 From: Konrad Rzeszutek Wilk To: Jan Beulich Message-ID: <20160318195951.GB11924@char.us.oracle.com> References: <1458064616-23101-1-git-send-email-konrad.wilk@oracle.com> <1458064616-23101-7-git-send-email-konrad.wilk@oracle.com> <56EC054F02000078000DE552@prv-mh.provo.novell.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <56EC054F02000078000DE552@prv-mh.provo.novell.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: Keir Fraser , ross.lagerwall@citrix.com, andrew.cooper3@citrix.com, mpohlack@amazon.de, Julien Grall , Stefano Stabellini , sasha.levin@oracle.com, xen-devel@lists.xenproject.org Subject: Re: [Xen-devel] [PATCH v4 06/34] x86/arm: Add BUGFRAME_NR define and BUILD checks. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Mar 18, 2016 at 06:40:31AM -0600, Jan Beulich wrote: > >>> On 15.03.16 at 18:56, wrote: > > --- a/xen/include/asm-arm/bug.h > > +++ b/xen/include/asm-arm/bug.h > > @@ -31,6 +31,7 @@ struct bug_frame { > > #define BUGFRAME_warn 0 > > #define BUGFRAME_bug 1 > > #define BUGFRAME_assert 2 > > +#define BUGFRAME_NR 3 > > > > /* Many versions of GCC doesn't support the asm %c parameter which would > > * be preferable to this unpleasantness. We use mergeable string > > @@ -39,6 +40,7 @@ struct bug_frame { > > */ > > #define BUG_FRAME(type, line, file, has_msg, msg) do { \ > > BUILD_BUG_ON((line) >> 16); \ > > + BUILD_BUG_ON(type >= BUGFRAME_NR); \ > > The x86 variant has type properly parenthesized - why not here? > > > --- a/xen/include/asm-x86/bug.h > > +++ b/xen/include/asm-x86/bug.h > > @@ -9,7 +9,7 @@ > > #define BUGFRAME_warn 1 > > #define BUGFRAME_bug 2 > > #define BUGFRAME_assert 3 > > - > > +#define BUGFRAME_NR 4 > > #ifndef __ASSEMBLY__ > > Please retain the blank line. > > > @@ -51,6 +51,7 @@ struct bug_frame { > > > > #define BUG_FRAME(type, line, ptr, second_frame, msg) do { \ > > BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE_HI_WIDTH)); \ > > + BUILD_BUG_ON((type) >= (BUGFRAME_NR)); \ > > The ARM variant has BUGFRAME_NR properly un-parenthesized - > why here? I know I copied and pasted it and I must have done something uncanny. Anyhow this is what the change looks like now (I've retained the Reviewed and Ack as I think this change is mostly cosmetical in nature?) From 123ad665b283f8c59688bd86be0bbe79ce5723bb Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Thu, 10 Mar 2016 16:45:31 -0500 Subject: [PATCH] x86/arm: Add BUGFRAME_NR define and BUILD checks. So that we have a nice mechansim to figure out the upper bounds of bug.frames and also catch compiler errors in case one tries to use a higher frame number. Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Andrew Cooper Acked-by: Julien Grall --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Keir Fraser Cc: Jan Beulich Cc: Andrew Cooper v3: First time included. v4: Add BUG_FRAME check also in the assembler version of the macro. v5: Add Acks, make BUILD_BUG_ON checks look correct. Position the BUGFRAME_NR properly. --- --- xen/include/asm-arm/bug.h | 3 +++ xen/include/asm-x86/bug.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/xen/include/asm-arm/bug.h b/xen/include/asm-arm/bug.h index ab9e811..68353e1 100644 --- a/xen/include/asm-arm/bug.h +++ b/xen/include/asm-arm/bug.h @@ -32,6 +32,8 @@ struct bug_frame { #define BUGFRAME_bug 1 #define BUGFRAME_assert 2 +#define BUGFRAME_NR 3 + /* Many versions of GCC doesn't support the asm %c parameter which would * be preferable to this unpleasantness. We use mergeable string * sections to avoid multiple copies of the string appearing in the @@ -39,6 +41,7 @@ struct bug_frame { */ #define BUG_FRAME(type, line, file, has_msg, msg) do { \ BUILD_BUG_ON((line) >> 16); \ + BUILD_BUG_ON((type) >= BUGFRAME_NR); \ asm ("1:"BUG_INSTR"\n" \ ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \ "2:\t.asciz " __stringify(file) "\n" \ diff --git a/xen/include/asm-x86/bug.h b/xen/include/asm-x86/bug.h index e868e85..7825565 100644 --- a/xen/include/asm-x86/bug.h +++ b/xen/include/asm-x86/bug.h @@ -10,6 +10,7 @@ #define BUGFRAME_bug 2 #define BUGFRAME_assert 3 +#define BUGFRAME_NR 4 #ifndef __ASSEMBLY__ struct bug_frame { @@ -51,6 +52,7 @@ struct bug_frame { #define BUG_FRAME(type, line, ptr, second_frame, msg) do { \ BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE_HI_WIDTH)); \ + BUILD_BUG_ON((type) >= BUGFRAME_NR); \ asm volatile ( _ASM_BUGFRAME_TEXT(second_frame) \ :: _ASM_BUGFRAME_INFO(type, line, ptr, msg) ); \ } while (0) @@ -83,6 +85,11 @@ extern const struct bug_frame __start_bug_frames[], * in .rodata */ .macro BUG_FRAME type, line, file_str, second_frame, msg + + .if \type >= BUGFRAME_NR + .error "Invalid BUGFRAME index" + .endif + .L\@ud: ud2a .pushsection .rodata.str1, "aMS", @progbits, 1