From patchwork Fri Aug 25 08:07:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9921339 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 843E36022E for ; Fri, 25 Aug 2017 08:09:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 742C726E3A for ; Fri, 25 Aug 2017 08:09:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68F1F26CFC; Fri, 25 Aug 2017 08:09:59 +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 E28C726CFC for ; Fri, 25 Aug 2017 08:09:58 +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 1dl9ef-0003xH-3t; Fri, 25 Aug 2017 08:07:49 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dl9ee-0003xB-BX for xen-devel@lists.xenproject.org; Fri, 25 Aug 2017 08:07:48 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id D2/DC-01862-3DADF995; Fri, 25 Aug 2017 08:07:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRWlGSWpSXmKPExsXS6fjDS/fSrfm RBlPOWVp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnd1xpZCy6IV7x/8ZepgXGxQBcjJ4eQQJ5E z7/rLCA2r4CdxLJtDxhBbAkBQ4nTC2+CxVkEVCXm/bzCDGKzCahLtD3bztrFyMEhImAgce5oE ojJLKAvsW0dWLWwgLvEoW0LWCCm20lMWTOLCaSEV0BQ4u8OYZAws4CWxMNft1ggbG2JZQtfM0 NMkZZY/o9jAiPvLISGWUgaZiFpmIXQsICRZRWjenFqUVlqka6xXlJRZnpGSW5iZo6uoYGxXm5 qcXFiempOYlKxXnJ+7iZGYHgxAMEOxuYvTocYJTmYlER5l0fPjxTiS8pPqcxILM6ILyrNSS0+ xCjDwaEkwVt4EygnWJSanlqRlpkDDHSYtAQHj5IILw9Imre4IDG3ODMdInWKUVFKnDccJCEAk sgozYNrg0XXJUZZKWFeRqBDhHgKUotyM0tQ5V8xinMwKgnzJoNM4cnMK4Gb/gpoMRPQ4kkn5o AsLklESEk1MOpnBmzcs1pKP+XwTEedlFVvYrm7Jpc5KTD8Nma5FHf11qHvbd8f//mfIRgc93p t00SGH73NT8zy9OYF569zyCjyDpUKvTRLbunO1u/17o+SrgnJyaXb1v157HREb4WixQMJwy4d hauPRJc0Sdvu4G9a1FB0XWFVu7JaSpiX2T/f3rvvjuzfpMRSnJFoqMVcVJwIAL4bpbCpAgAA X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1503648465!111403964!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 5594 invoked from network); 25 Aug 2017 08:07:46 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-14.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Aug 2017 08:07:46 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Fri, 25 Aug 2017 02:07:44 -0600 Message-Id: <599FF6F102000078001738E4@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.2 Date: Fri, 25 Aug 2017 02:07:45 -0600 From: "Jan Beulich" To: "xen-devel" References: <599FF6F102000078001738E4@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Cc: Andrew Cooper Subject: [Xen-devel] [PATCH] 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). Signed-off-by: Jan Beulich --- 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,11 @@ SECTIONS __2M_init_start = .; /* Start of 2M superpages, mapped RWX (boot only). */ . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; +#ifndef EFI .init.text : { +#else + .init : { +#endif _sinittext = .; *(.init.text) /* @@ -165,8 +169,12 @@ SECTIONS */ *(.altinstr_replacement) _einittext = .; +#ifndef EFI } :text .init.data : { +#else + . = ALIGN(SMP_CACHE_BYTES); +#endif *(.init.rodata) *(.init.rodata.rel) *(.init.rodata.str*)