From patchwork Sun Sep 17 18:12:51 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: 141217 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2347711vqi; Sun, 17 Sep 2023 16:44:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0FLxy/DPi6BpztDGVSHxP0rrfMQ1cKbpPZNUsa6GyTinqoG1SAnIn3I8hMvOczm3KB3et X-Received: by 2002:a05:6870:c1c9:b0:1d6:5e67:c140 with SMTP id i9-20020a056870c1c900b001d65e67c140mr9624743oad.58.1694994290778; Sun, 17 Sep 2023 16:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694994290; cv=none; d=google.com; s=arc-20160816; b=HDWJc70CB2vt1cD979JPtixBLBsejN49JpXpmtUT2bQtTkPlrzDxe2ZusfWXawMSIq 8kPsmkM62Mf2y8LY8aDaoXNO1lznWXVaxV1O18mREUL0grkEa5K7muw/7jCKxDmKp2LN +TU8QXfN7PM0T9/nfQUFTUhEvBekAkSo1AN0FobBE+XomcRsZJ/ge5f7PnPh+Y88nO2B DO06airR9xfLJzHCXPDhdKDvMceFT+q0c296bUnsQchLldVGrgCKe3tpwV2Xl80Iz4KB vIbrl9FwZerB4F8vU4c19Uo0HQlnadzTMuEl99kdAumcvbQiQaywohI21dr94bNvTPK6 Sfhg== 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=sDKxkhqIdeMe6T0j3y90XFzwL7zRPyAXKTJOyb7Djvo=; fh=mh/EFXDyWz6SYA4qEbcbMgOZ07AT4DlRJonTEXgTb50=; b=GEvOEeEAiCMMQdkDeUqU2dob3G0ojmSgCuqI2hfS7UGI8yfVsuPRzPXxBR0Thxc12q wN9EOt2b7IE2+Dp9YLbdHwDOuWwH4ggybK3OtNsNEOIdgZJ5n28YPUMGuu9KC2hRebqp Rr2YAIwfeUbZcqFUzNxcgsTjCjeoewuBwJQi2V9Eh8bpqtuyGBq5Lu7ZbTDJLbhsRsQb CvxCe7I9WgkByOIE0sOBL3n7dIg9btoG7fyWdv/FnX2aj7OEjbIu1BsmcjkX8Bmb+3BI 970hMGBQGuWSvx1AnMc9fgVborm0euUJ4IrDpGg40oBdT8ekAWGdYrmBnsdXZUQ3+VkQ f59g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xelt92Wd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id y15-20020a17090aa40f00b002680abc3699si9167350pjp.115.2023.09.17.16.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 16:44:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xelt92Wd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 0257581F3589; Sun, 17 Sep 2023 11:17:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238770AbjIQSNR (ORCPT + 28 others); Sun, 17 Sep 2023 14:13:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238324AbjIQSNC (ORCPT ); Sun, 17 Sep 2023 14:13:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85233129; Sun, 17 Sep 2023 11:12:55 -0700 (PDT) Date: Sun, 17 Sep 2023 18:12:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694974372; 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=sDKxkhqIdeMe6T0j3y90XFzwL7zRPyAXKTJOyb7Djvo=; b=xelt92WdWS/kab2oqQA9iIwnMzwEP0ieS9R0SME5FTxVR32WqrOnlRhETSJ4Ck4SKMsLc4 wq+WlQ3W5YPuFdEsHhSoeEGcoM+V1YxKA/x3htFXtdlXSPGhHovygvBN95NwKoYhXWvfc9 oV6uSSnQHN0yFpbMYpTGp+blBf7hfXcBVpA/8t0EruwEPubRvFN0R24AM0eDgy3/O9qcoF ooUz5PDtiRCC8+CWiCFzx9QWlulMduU8qhjP7St6LpbFi4ZLeZhEnBgTh3b1x7rPbqASjP h8eyibK9YSl2ovxGwZiBpx5OWr8GNfL3L2EuY5nKoFd+Axtl/nc+8tFjaTIrxg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694974372; 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=sDKxkhqIdeMe6T0j3y90XFzwL7zRPyAXKTJOyb7Djvo=; b=N1fISaY/MGNGtb8kyVxysVpdqaI/90mLH2wXkVnvM0i2MM03lzb7stlmJ6leFh2bNdAgrz djeajAuWCFAse2DA== 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: Set EFI handover offset directly in header asm Cc: Ard Biesheuvel , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230915171623.655440-12-ardb@google.com> References: <20230915171623.655440-12-ardb@google.com> MIME-Version: 1.0 Message-ID: <169497437194.27769.17857741013219317202.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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 11:17:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777141594841733720 X-GMAIL-MSGID: 1777330333731419328 The following commit has been merged into the x86/boot branch of tip: Commit-ID: eac956345f99dda3d68f4ae6cf7b494105e54780 Gitweb: https://git.kernel.org/tip/eac956345f99dda3d68f4ae6cf7b494105e54780 Author: Ard Biesheuvel AuthorDate: Fri, 15 Sep 2023 17:16:26 Committer: Ingo Molnar CommitterDate: Sun, 17 Sep 2023 19:48:42 +02:00 x86/boot: Set EFI handover offset directly in header asm The offsets of the EFI handover entrypoints are available to the assembler when constructing the header, so there is no need to set them from the build tool afterwards. This change has no impact on the resulting bzImage binary. Signed-off-by: Ard Biesheuvel Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20230915171623.655440-12-ardb@google.com --- arch/x86/boot/header.S | 18 +++++++++++++++++- arch/x86/boot/tools/build.c | 24 ------------------------ 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 5575d0f..72744ba 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S @@ -524,8 +524,24 @@ pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr # define INIT_SIZE VO_INIT_SIZE #endif + .macro __handover_offset +#ifndef CONFIG_EFI_HANDOVER_PROTOCOL + .long 0 +#elif !defined(CONFIG_X86_64) + .long ZO_efi32_stub_entry +#else + /* Yes, this is really how we defined it :( */ + .long ZO_efi64_stub_entry - 0x200 +#ifdef CONFIG_EFI_MIXED + .if ZO_efi32_stub_entry != ZO_efi64_stub_entry - 0x200 + .error "32-bit and 64-bit EFI entry points do not match" + .endif +#endif +#endif + .endm + init_size: .long INIT_SIZE # kernel initialization size -handover_offset: .long 0 # Filled in by build.c +handover_offset: __handover_offset kernel_info_offset: .long ZO_kernel_info # End of setup header ##################################################### diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index 14ef13f..0694975 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@ -55,8 +55,6 @@ u8 buf[SETUP_SECT_MAX*512]; #define PECOFF_COMPAT_RESERVE 0x0 #endif -static unsigned long efi32_stub_entry; -static unsigned long efi64_stub_entry; static unsigned long efi_pe_entry; static unsigned long efi32_pe_entry; static unsigned long _end; @@ -265,31 +263,12 @@ static void efi_stub_defaults(void) #endif } -static void efi_stub_entry_update(void) -{ - unsigned long addr = efi32_stub_entry; - -#ifdef CONFIG_EFI_HANDOVER_PROTOCOL -#ifdef CONFIG_X86_64 - /* Yes, this is really how we defined it :( */ - addr = efi64_stub_entry - 0x200; -#endif - -#ifdef CONFIG_EFI_MIXED - if (efi32_stub_entry != addr) - die("32-bit and 64-bit EFI entry points do not match\n"); -#endif -#endif - put_unaligned_le32(addr, &buf[0x264]); -} - #else static inline void update_pecoff_setup_and_reloc(unsigned int size) {} static inline void update_pecoff_text(unsigned int text_start, unsigned int file_sz) {} static inline void efi_stub_defaults(void) {} -static inline void efi_stub_entry_update(void) {} static inline int reserve_pecoff_reloc_section(int c) { @@ -332,8 +311,6 @@ static void parse_zoffset(char *fname) p = (char *)buf; while (p && *p) { - PARSE_ZOFS(p, efi32_stub_entry); - PARSE_ZOFS(p, efi64_stub_entry); PARSE_ZOFS(p, efi_pe_entry); PARSE_ZOFS(p, efi32_pe_entry); PARSE_ZOFS(p, _end); @@ -416,7 +393,6 @@ int main(int argc, char ** argv) update_pecoff_text(setup_sectors * 512, i + (sys_size * 16)); - efi_stub_entry_update(); crc = partial_crc32(buf, i, crc); if (fwrite(buf, 1, i, dest) != i)