From patchwork Mon Feb 22 16:57:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 8380341 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 A641E9F372 for ; Mon, 22 Feb 2016 16:59:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA6AC204AE for ; Mon, 22 Feb 2016 16:59:46 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE065204FC for ; Mon, 22 Feb 2016 16:59:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXtni-0002lw-Lz; Mon, 22 Feb 2016 16:57:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXtng-0002ky-NE for xen-devel@lists.xen.org; Mon, 22 Feb 2016 16:57:32 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 31/26-03519-BFD3BC65; Mon, 22 Feb 2016 16:57:31 +0000 X-Env-Sender: prvs=8531d772c=Andrew.Cooper3@citrix.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1456160249!23898040!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57727 invoked from network); 22 Feb 2016 16:57:31 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-8.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 22 Feb 2016 16:57:31 -0000 X-IronPort-AV: E=Sophos;i="5.22,485,1449532800"; d="scan'208";a="339985250" From: Andrew Cooper To: Xen-devel Date: Mon, 22 Feb 2016 16:57:27 +0000 Message-ID: <1456160247-15209-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH] xen: Work around Clang generating .data.rel.ro section for init-only files X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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 Clang-3.8 generates several .data.rel.ro sections when compiling Xen. As these contain no global symbols, they should be .data.rel.ro.local. This breaks the SPECIAL_DATA_SECTIONS check when converting the transition units to being init-only. For alternatives.c, explicitly move the nops arrays into __initconst. For efi boot.c, manually create the optimisation performed by Clang by collapsing the switch statement into a lookup table. The double use of const is required to avoid breaking the ARM build by creating a section type conflict with fdt_guid. Signed-off-by: Andrew Cooper --- CC: Jan Beulich v2: Fix ARM build --- xen/arch/x86/alternative.c | 4 ++-- xen/common/efi/boot.c | 58 +++++++++++++++------------------------------- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c index 46ac0fd..02b5e92 100644 --- a/xen/arch/x86/alternative.c +++ b/xen/arch/x86/alternative.c @@ -38,7 +38,7 @@ static const unsigned char k8nops[] __initconst = { K8_NOP7, K8_NOP8 }; -static const unsigned char * const k8_nops[ASM_NOP_MAX+1] = { +static const unsigned char * const k8_nops[ASM_NOP_MAX+1] __initconst = { NULL, k8nops, k8nops + 1, @@ -62,7 +62,7 @@ static const unsigned char p6nops[] __initconst = { P6_NOP7, P6_NOP8 }; -static const unsigned char * const p6_nops[ASM_NOP_MAX+1] = { +static const unsigned char * const p6_nops[ASM_NOP_MAX+1] __initconst = { NULL, p6nops, p6nops + 1, diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 53c7452..e0fdf40 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -241,53 +241,33 @@ static void __init noreturn blexit(const CHAR16 *str) /* generic routine for printing error messages */ static void __init PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode) { + static const CHAR16* const ErrCodeToStr[] __initconst = { + [~EFI_ERROR_MASK & EFI_NOT_FOUND] = L"Not found", + [~EFI_ERROR_MASK & EFI_NO_MEDIA] = L"The device has no media", + [~EFI_ERROR_MASK & EFI_MEDIA_CHANGED] = L"Media changed", + [~EFI_ERROR_MASK & EFI_DEVICE_ERROR] = L"Device error", + [~EFI_ERROR_MASK & EFI_VOLUME_CORRUPTED] = L"Volume corrupted", + [~EFI_ERROR_MASK & EFI_ACCESS_DENIED] = L"Access denied", + [~EFI_ERROR_MASK & EFI_OUT_OF_RESOURCES] = L"Out of resources", + [~EFI_ERROR_MASK & EFI_VOLUME_FULL] = L"Volume is full", + [~EFI_ERROR_MASK & EFI_SECURITY_VIOLATION] = L"Security violation", + [~EFI_ERROR_MASK & EFI_CRC_ERROR] = L"CRC error", + [~EFI_ERROR_MASK & EFI_COMPROMISED_DATA] = L"Compromised data", + [~EFI_ERROR_MASK & EFI_BUFFER_TOO_SMALL] = L"Buffer too small", + }; + EFI_STATUS ErrIdx = ErrCode & ~EFI_ERROR_MASK; + StdOut = StdErr; PrintErr((CHAR16 *)mesg); PrintErr(L": "); - switch (ErrCode) + if( (ErrIdx < ARRAY_SIZE(ErrCodeToStr)) && ErrCodeToStr[ErrIdx] ) + mesg = ErrCodeToStr[ErrIdx]; + else { - case EFI_NOT_FOUND: - mesg = L"Not found"; - break; - case EFI_NO_MEDIA: - mesg = L"The device has no media"; - break; - case EFI_MEDIA_CHANGED: - mesg = L"Media changed"; - break; - case EFI_DEVICE_ERROR: - mesg = L"Device error"; - break; - case EFI_VOLUME_CORRUPTED: - mesg = L"Volume corrupted"; - break; - case EFI_ACCESS_DENIED: - mesg = L"Access denied"; - break; - case EFI_OUT_OF_RESOURCES: - mesg = L"Out of resources"; - break; - case EFI_VOLUME_FULL: - mesg = L"Volume is full"; - break; - case EFI_SECURITY_VIOLATION: - mesg = L"Security violation"; - break; - case EFI_CRC_ERROR: - mesg = L"CRC error"; - break; - case EFI_COMPROMISED_DATA: - mesg = L"Compromised data"; - break; - case EFI_BUFFER_TOO_SMALL: - mesg = L"Buffer too small"; - break; - default: PrintErr(L"ErrCode: "); DisplayUint(ErrCode, 0); mesg = NULL; - break; } blexit(mesg); }