From patchwork Sun Sep 17 18:12:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 141226 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2379248vqi; Sun, 17 Sep 2023 18:30:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoWLsrt5S8m5wgV2UBGqH67bj8RAk0ZjRhZwuw7N2omXt6Mv2WMvvJ4stiQiKcVjy65Eeh X-Received: by 2002:a17:902:e881:b0:1bc:3944:9391 with SMTP id w1-20020a170902e88100b001bc39449391mr6952526plg.25.1695000621647; Sun, 17 Sep 2023 18:30:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695000621; cv=none; d=google.com; s=arc-20160816; b=Mm8tmSRjuLLqR9+Md4wYJqrxOaWKVaDAvTSLr4ywGT5eKG+Km8aV0NEtfhy+TYHoTt SrRjfeizeDrxowQQ4M1uByVekBXuxOPKInV7JCz7Cm2xVCrMmNgNEbqk48k2bNMsJKDL hjRW8Zt0g9R8eOTazZeltEZHfKvh/ouPTnxZ7UvlVuZ7vRtfqoKTfRWSn5NKNbI5BNe4 jQFG8+xSzNVtAgn2DD21vCAtiYfJkpmIEx+t54isJaa0aRJyFqbfqeNOn+rQn1/tIHAs nim3OcBwgxZ+W7Cl1WAwYrhce0IN5DpbT9KCQP4wJu5cJZPP+pnJAh3o7hy5VjwNk0VJ 2Myw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=xZ2hoQt5yJsupnfBMW5gQJryRxD76bxHS17J1yJN7kw=; fh=mh/EFXDyWz6SYA4qEbcbMgOZ07AT4DlRJonTEXgTb50=; b=JJdvrrsd0WYvaWbeQPX8uv0eMyATu4oHug0Q2m4gepV4lfzRgbR1NH5Uysj53mnAEL IOVgkmaW5vitRqkwzgGQXIDuDdXBIsicF4GgQuPetHIuOIX5pQ8xe3WuS9RTGmKkU1X6 oVddgVj2PsZKYum6JQABUhgwWMTgpbk13gXYcWLDDCphQJfl4PyIFHg4PwFU2uJk9sWy ruAEuog9TlHPx7lKEWVTBDmHRRWaLxfCUWScq5S+6r4YQC4wdkJja3oXlotpHA2Q7hFv cbPOUyFD+4WHDFlrxuONVdanIaI805/c8ZI/zFzjyYcLfvGFlHLVjw2GP5jMEjXD2o6S M+yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iIZ6kuEz; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id o14-20020a17090323ce00b001bf1d1d99b0si7104899plh.568.2023.09.17.18.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 18:30:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iIZ6kuEz; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8F9F38116B0E; Sun, 17 Sep 2023 11:14:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238072AbjIQSNM (ORCPT + 28 others); Sun, 17 Sep 2023 14:13:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238153AbjIQSM7 (ORCPT ); Sun, 17 Sep 2023 14:12:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13841129; Sun, 17 Sep 2023 11:12:52 -0700 (PDT) Date: Sun, 17 Sep 2023 18:12:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694974370; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xZ2hoQt5yJsupnfBMW5gQJryRxD76bxHS17J1yJN7kw=; b=iIZ6kuEzmOjyves2twLZXy6jaeMs0NSxdZ3GVt+w4w3fpp7ung81f56q+kBV8ntzHU6+sA 6NAKeSvoNVBYka5+L7rucLQv1RRa4Z9LGZfMZR6Ujf8eV1C6d/xJMj0zX3efsyueEo8GVU hfatzvFkTVGrJDdgg66Zatk/5KiSlfffvR0aymL3JOCOtnaAEp8eXG/dZI0qmAGXXqAZeF Cdf7gUNfbEBjTSFy1pRqnY+YESGrTKeIVAj6QJTWK8fJX+jIeZYAgBtFQ7xk7upuELnYRo amcrzWB84pTe1cWFH2eoYGHGLssO+ELkSWLVy2p2xAIloUFUYOwt+IfF8a50GA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694974370; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xZ2hoQt5yJsupnfBMW5gQJryRxD76bxHS17J1yJN7kw=; b=aP59guHEHC3WYUVW6JyBUPPcsoPyIBEdLgqW7zyCQqFxvxkg7htbAXTUzXXMvXLMBvBUKM zAwlfBjbxalKR/DQ== From: "tip-bot2 for Ard Biesheuvel" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/boot] x86/boot: Drop PE/COFF .reloc section Cc: Ard Biesheuvel , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230915171623.655440-16-ardb@google.com> References: <20230915171623.655440-16-ardb@google.com> MIME-Version: 1.0 Message-ID: <169497437001.27769.5874942154023966990.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 17 Sep 2023 11:14:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777131730468382427 X-GMAIL-MSGID: 1777336972089805333 The following commit has been merged into the x86/boot branch of tip: Commit-ID: fa5750521e0a4efbc1af05223da9c4bbd6c21c83 Gitweb: https://git.kernel.org/tip/fa5750521e0a4efbc1af05223da9c4bbd6c21c83 Author: Ard Biesheuvel AuthorDate: Fri, 15 Sep 2023 17:16:30 Committer: Ingo Molnar CommitterDate: Sun, 17 Sep 2023 19:48:43 +02:00 x86/boot: Drop PE/COFF .reloc section Ancient buggy EFI loaders may have required a .reloc section to be present at some point in time, but this has not been true for a long time so the .reloc section can just be dropped. Signed-off-by: Ard Biesheuvel Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20230915171623.655440-16-ardb@google.com --- arch/x86/boot/header.S | 20 -------------------- arch/x86/boot/setup.ld | 4 ++-- arch/x86/boot/tools/build.c | 34 +++++----------------------------- 3 files changed, 7 insertions(+), 51 deletions(-) diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 2b07bc5..9e9641e 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S @@ -155,26 +155,6 @@ section_table: IMAGE_SCN_MEM_READ | \ IMAGE_SCN_MEM_EXECUTE # Characteristics - # - # The EFI application loader requires a relocation section - # because EFI applications must be relocatable. The .reloc - # offset & size fields are filled in by build.c. - # - .ascii ".reloc" - .byte 0 - .byte 0 - .long 0 - .long 0 - .long 0 # SizeOfRawData - .long 0 # PointerToRawData - .long 0 # PointerToRelocations - .long 0 # PointerToLineNumbers - .word 0 # NumberOfRelocations - .word 0 # NumberOfLineNumbers - .long IMAGE_SCN_CNT_INITIALIZED_DATA | \ - IMAGE_SCN_MEM_READ | \ - IMAGE_SCN_MEM_DISCARDABLE # Characteristics - #ifdef CONFIG_EFI_MIXED # # The offset & size fields are filled in by build.c. diff --git a/arch/x86/boot/setup.ld b/arch/x86/boot/setup.ld index 9bd5c1a..6d38949 100644 --- a/arch/x86/boot/setup.ld +++ b/arch/x86/boot/setup.ld @@ -40,8 +40,8 @@ SECTIONS setup_sig = .; LONG(0x5a5aaa55) - /* Reserve some extra space for the reloc and compat sections */ - setup_size = ALIGN(ABSOLUTE(.) + 64, 512); + /* Reserve some extra space for the compat section */ + setup_size = ALIGN(ABSOLUTE(.) + 32, 512); setup_sects = ABSOLUTE(setup_size / 512); } diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index 9712f27..faccff9 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@ -47,7 +47,6 @@ typedef unsigned int u32; /* This must be large enough to hold the entire setup */ u8 buf[SETUP_SECT_MAX*512]; -#define PECOFF_RELOC_RESERVE 0x20 #define PECOFF_COMPAT_RESERVE 0x20 static unsigned long efi32_pe_entry; @@ -180,24 +179,13 @@ static void update_pecoff_section_header(char *section_name, u32 offset, u32 siz update_pecoff_section_header_fields(section_name, offset, size, size, offset); } -static void update_pecoff_setup_and_reloc(unsigned int size) +static void update_pecoff_setup(unsigned int size) { u32 setup_offset = 0x200; - u32 reloc_offset = size - PECOFF_RELOC_RESERVE - PECOFF_COMPAT_RESERVE; -#ifdef CONFIG_EFI_MIXED - u32 compat_offset = reloc_offset + PECOFF_RELOC_RESERVE; -#endif - u32 setup_size = reloc_offset - setup_offset; + u32 compat_offset = size - PECOFF_COMPAT_RESERVE; + u32 setup_size = compat_offset - setup_offset; update_pecoff_section_header(".setup", setup_offset, setup_size); - update_pecoff_section_header(".reloc", reloc_offset, PECOFF_RELOC_RESERVE); - - /* - * Modify .reloc section contents with a single entry. The - * relocation is applied to offset 10 of the relocation section. - */ - put_unaligned_le32(reloc_offset + 10, &buf[reloc_offset]); - put_unaligned_le32(10, &buf[reloc_offset + 4]); #ifdef CONFIG_EFI_MIXED update_pecoff_section_header(".compat", compat_offset, PECOFF_COMPAT_RESERVE); @@ -214,21 +202,10 @@ static void update_pecoff_setup_and_reloc(unsigned int size) #endif } -static int reserve_pecoff_reloc_section(int c) -{ - /* Reserve 0x20 bytes for .reloc section */ - memset(buf+c, 0, PECOFF_RELOC_RESERVE); - return PECOFF_RELOC_RESERVE; -} - #else -static inline void update_pecoff_setup_and_reloc(unsigned int size) {} +static inline void update_pecoff_setup(unsigned int size) {} -static inline int reserve_pecoff_reloc_section(int c) -{ - return 0; -} #endif /* CONFIG_EFI_STUB */ static int reserve_pecoff_compat_section(int c) @@ -307,7 +284,6 @@ int main(int argc, char ** argv) fclose(file); c += reserve_pecoff_compat_section(c); - c += reserve_pecoff_reloc_section(c); /* Pad unused space with zeros */ setup_sectors = (c + 511) / 512; @@ -316,7 +292,7 @@ int main(int argc, char ** argv) i = setup_sectors*512; memset(buf+c, 0, i-c); - update_pecoff_setup_and_reloc(i); + update_pecoff_setup(i); /* Open and stat the kernel file */ fd = open(argv[2], O_RDONLY);