From patchwork Fri Aug 25 14:34:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9922235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 29C13603FA for ; Fri, 25 Aug 2017 14:37:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A13051FF73 for ; Fri, 25 Aug 2017 14:37:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93AE32811E; Fri, 25 Aug 2017 14:37:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 538CC28384 for ; Fri, 25 Aug 2017 14:37:10 +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 1dlFh5-0007Be-Pz; Fri, 25 Aug 2017 14:34:43 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlFh5-0007BY-5Z for xen-devel@lists.xenproject.org; Fri, 25 Aug 2017 14:34:43 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 23/1C-03406-28530A95; Fri, 25 Aug 2017 14:34:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRWlGSWpSXmKPExsXS6fjDS7fRdEG kwen9hhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0brtYlMBVfEK15O52tgXCbQxcjJISSQJ/Gh bQIriM0rYCfx58YDNhBbQsBQ4vTCmywgNouAqsTVyZfBatgE1CXanm0Hsjk4RAQMJM4dTQIxm QX0JbatA6sWFvCWePl1AjvEdDuJmYefsoOU8AoISvzdIQwSZhbQknj46xYLhK0tsWzha2aIKd ISy/9xTGDknYXQMAtJwywkDbMQGhYwsqxi1ChOLSpLLdI1MtFLKspMzyjJTczM0TU0MNPLTS0 uTkxPzUlMKtZLzs/dxAgMLwYg2MG472PkIUZJDiYlUV7rl/MjhfiS8lMqMxKLM+KLSnNSiw8x ynBwKEnwfjdeECkkWJSanlqRlpkDDHSYtAQHj5IIr60JUJq3uCAxtzgzHSJ1ilFRSpy3FiQhA JLIKM2Da4NF1yVGWSlhXkagQ4R4ClKLcjNLUOVfMYpzMCoJ8yqBTOHJzCuBm/4KaDET0OJJJ+ aALC5JREhJNTAKKR7Xkt4bHXhYdeXE7TZlQZN+eC23tM68vMVLRXVqd4TUmpPhP9/FHLYIe5v 3y+Xc9BemayX6ElUbXotM+3yv19So8FauaEk6a9YkkScGZ7ZLfrXdJnTE9iXz8vvrYhfoMglZ 9Idb/eIq/TP/cum1k30V524Vni+tdSiVPdWQInNDS+dVibkSS3FGoqEWc1FxIgDCdk4gqQIAA A== X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1503671680!103959342!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33537 invoked from network); 25 Aug 2017 14:34:41 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-13.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Aug 2017 14:34:41 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Fri, 25 Aug 2017 08:34:39 -0600 Message-Id: <59A051A00200007800173D44@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.2 Date: Fri, 25 Aug 2017 08:34:40 -0600 From: "Jan Beulich" To: "xen-devel" References: <59A051A00200007800173D44@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Cc: Andrew Cooper Subject: [Xen-devel] [PATCH v2] x86/EFI: warn about r/o sections requiring relocations 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-Virus-Scanned: ClamAV using ClamSMTP EFI implementations may write-protect r/o sections, but we need to apply relocations. Eliminate the one present case of a r/o section with relocations (.init.text, which is now being combined with .init.data into just .init). Also correct a few other format strings (to account for the possibly missing NUL in section names) in mkreloc.c. Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- v2: Don't special case EFI in xen.lds.S. --- a/xen/arch/x86/efi/mkreloc.c +++ b/xen/arch/x86/efi/mkreloc.c @@ -66,8 +66,9 @@ struct coff_section { uint16_t relocation_count; uint16_t line_number_count; uint32_t flags; -#define COFF_SECTION_BSS 0x00000080 -#define COFF_SECTION_DISCARDABLE 0x02000000 +#define COFF_SECTION_BSS 0x00000080U +#define COFF_SECTION_DISCARDABLE 0x02000000U +#define COFF_SECTION_WRITEABLE 0x80000000U }; static void usage(const char *cmd, int rc) @@ -224,7 +225,7 @@ static void diff_sections(const unsigned if ( i < disp || i + width - disp > sec->file_size ) { fprintf(stderr, - "Bogus difference at %s:%08" PRIxFAST32 "\n", + "Bogus difference at %.8s:%08" PRIxFAST32 "\n", sec->name, i); exit(3); } @@ -235,7 +236,7 @@ static void diff_sections(const unsigned if ( delta != diff ) { fprintf(stderr, - "Difference at %s:%08" PRIxFAST32 " is %#" PRIxFAST64 + "Difference at %.8s:%08" PRIxFAST32 " is %#" PRIxFAST64 " (expected %#" PRIxFAST64 ")\n", sec->name, i, delta, diff); continue; @@ -261,11 +262,16 @@ static void diff_sections(const unsigned else if ( rva != cur_rva ) { fprintf(stderr, - "Cannot handle decreasing RVA (at %s:%08" PRIxFAST32 ")\n", + "Cannot handle decreasing RVA (at %.8s:%08" PRIxFAST32 ")\n", sec->name, i); exit(3); } + if ( !(sec->flags & COFF_SECTION_WRITEABLE) ) + fprintf(stderr, + "Warning: relocation to r/o section %.8s:%08" PRIxFAST32 "\n", + sec->name, i); + printf("\t.word (%u << 12) | 0x%03" PRIxFAST32 "\n", reloc, sec->rva + i - disp - rva); reloc_size += 2; --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -155,7 +155,7 @@ SECTIONS __2M_init_start = .; /* Start of 2M superpages, mapped RWX (boot only). */ . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; - .init.text : { + .init : { _sinittext = .; *(.init.text) /* @@ -165,8 +165,9 @@ SECTIONS */ *(.altinstr_replacement) _einittext = .; - } :text - .init.data : { + + . = ALIGN(SMP_CACHE_BYTES); + *(.init.rodata) *(.init.rodata.rel) *(.init.rodata.str*)