Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4669407rwb; Tue, 8 Aug 2023 11:50:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrMWwVfbYdl5ZyFY4c2FmIJn1p2tzpkSPEbX8R50Hjw0llF7+XiamX2Khb8B8EiIjo6YKF X-Received: by 2002:a17:903:41c7:b0:1b7:f443:c7f8 with SMTP id u7-20020a17090341c700b001b7f443c7f8mr681354ple.15.1691520616210; Tue, 08 Aug 2023 11:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520616; cv=none; d=google.com; s=arc-20160816; b=Lhgu47jfEK+agGeBEpBFLULvNtpjre54BCmA82o10Ymwu32gzKGO/8xhGJXPH13kPV vkYQupz44vpi0LnMPwjVHcHAomoM/wJWxn0U6PPzWH9rjfq98TCGYjY8uVOESQEvWiBs +C3AIvlcJDCWX1Ax92X0cXT5yxpJXsyrko4Fqn6zezor/TmUCE8FRlgX8xhu/5OSeEHO ho0FAp8OfbyqeyKIKujoRpJSkNwCgKF4ICmZLBrnRZYbTteNfQEEjrsdDKKM/iE9ocUU dMudetCyyXoWrRUDF+Oy4szRGQv0tuVztONO9HWrIoye5nCI8elzFy+VM1xcKd2aU8bS McMw== 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=1Or2b4Na7nTw1tFARkW7WHc5iPHSvRQThhKn5LYONTM=; fh=upm4t26Ojn/J6N+Q9k8Qqzx52VymNDAlYlARzLeNh5s=; b=nzYfWCNk65TXsLDvkXVMgTKDWhGB/hNinr+a/AALdbs36bHBKjePeJ0U76HL5fjuuw mnWr639iuGu/lINQ+kFdnqHWg8h18HsUOTaPvVvJmY8SflfEoq8sv7097AtK0Yahc18D /DHCiaWn28beJLilbMwMFG19nrNnsSZtAjdxdcqllnmZdsq80WBsnChy5xyTNya23xbq 4hIPHp3JfpSJxdwbY+sdvZUcPualdrxN9H6sBMM0P6U5hl3bqYr3Yp16ABYaE7dejBcj Qjj2EyXOyjkk7cE2zrOfCKZM/anE9O+BbaMA4AMvezndI+Xf0f1w9LHpczu908tCTfLS GwTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4NL+DV5v; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CQdYCbv3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kq7-20020a170903284700b001a51368b098si7322657plb.209.2023.08.08.11.50.04; Tue, 08 Aug 2023 11:50:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4NL+DV5v; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CQdYCbv3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbjHHQdZ (ORCPT + 99 others); Tue, 8 Aug 2023 12:33:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232915AbjHHQcc (ORCPT ); Tue, 8 Aug 2023 12:32:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6459831024; Tue, 8 Aug 2023 08:52:00 -0700 (PDT) Date: Tue, 08 Aug 2023 08:44:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691484245; 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=1Or2b4Na7nTw1tFARkW7WHc5iPHSvRQThhKn5LYONTM=; b=4NL+DV5vu25vxrX4bhBaUbqNa71x3FmcliKVnGMT97x4jXpiBkwE9RgChbeLJq7UXX1SwT MmMyAzPtXh0BWeRJVoROfxUe+G5IFOvYbl0Q/f/ly0EJYyQ57KpuBgR8/8gwOa68lUQ8e9 NH1vbh3WyQ76BV56nN23QhSEdrOS1tVbP5oJy9aMyDmyL2zBfYuvYPRFvm2DI/eDh4akj2 faiAuII503BMMZd1UOy2ubLT100+JmlfUs8N2WIhfQCzK22ZjVjbTJxHItSRbTGvuKVpD7 VcGBH74bGmUiU7dEWUX+q2V8vcF3VXuACuvYUrYwxw1D3DLs00tLWgr6kVTeWQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691484245; 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=1Or2b4Na7nTw1tFARkW7WHc5iPHSvRQThhKn5LYONTM=; b=CQdYCbv3nTcsptwwHFCOTaadktKENjEER7AMBALs4c+aFCNgUH081TDUFwK4EiNzPdoDOM TxBZM6HkxdWG+HDQ== 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/decompressor: Avoid magic offsets for EFI handover entrypoint Cc: Ard Biesheuvel , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230807162720.545787-6-ardb@kernel.org> References: <20230807162720.545787-6-ardb@kernel.org> MIME-Version: 1.0 Message-ID: <169148424523.27769.14326172898952623288.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/boot branch of tip: Commit-ID: 12792064587623065250069d1df980e2c9ac3e67 Gitweb: https://git.kernel.org/tip/12792064587623065250069d1df980e2c9ac3e67 Author: Ard Biesheuvel AuthorDate: Mon, 07 Aug 2023 18:27:02 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 07 Aug 2023 20:39:00 +02:00 x86/decompressor: Avoid magic offsets for EFI handover entrypoint The native 32-bit or 64-bit EFI handover protocol entrypoint offset relative to the respective startup_32/64 address is described in boot_params as handover_offset, so that the special Linux/x86 aware EFI loader can find it there. When mixed mode is enabled, this single field has to describe this offset for both the 32-bit and 64-bit entrypoints, so their respective relative offsets have to be identical. Given that startup_32 and startup_64 are 0x200 bytes apart, and the EFI handover entrypoint resides at a fixed offset, the 32-bit and 64-bit versions of those entrypoints must be exactly 0x200 bytes apart as well. Currently, hard-coded fixed offsets are used to ensure this, but it is sufficient to emit the 64-bit entrypoint 0x200 bytes after the 32-bit one, wherever it happens to reside. This allows this code (which is now EFI mixed mode specific) to be moved into efi_mixed.S and out of the startup code in head_64.S. Signed-off-by: Ard Biesheuvel Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20230807162720.545787-6-ardb@kernel.org --- arch/x86/boot/compressed/efi_mixed.S | 20 +++++++++++++++++++- arch/x86/boot/compressed/head_64.S | 18 ------------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/arch/x86/boot/compressed/efi_mixed.S b/arch/x86/boot/compressed/efi_mixed.S index dcc562c..9308b59 100644 --- a/arch/x86/boot/compressed/efi_mixed.S +++ b/arch/x86/boot/compressed/efi_mixed.S @@ -140,6 +140,16 @@ SYM_FUNC_START(__efi64_thunk) SYM_FUNC_END(__efi64_thunk) .code32 +#ifdef CONFIG_EFI_HANDOVER_PROTOCOL +SYM_FUNC_START(efi32_stub_entry) + add $0x4, %esp /* Discard return address */ + popl %ecx + popl %edx + popl %esi + jmp efi32_entry +SYM_FUNC_END(efi32_stub_entry) +#endif + /* * EFI service pointer must be in %edi. * @@ -220,7 +230,7 @@ SYM_FUNC_END(efi_enter32) * stub may still exit and return to the firmware using the Exit() EFI boot * service.] */ -SYM_FUNC_START(efi32_entry) +SYM_FUNC_START_LOCAL(efi32_entry) call 1f 1: pop %ebx @@ -320,6 +330,14 @@ SYM_FUNC_START(efi32_pe_entry) RET SYM_FUNC_END(efi32_pe_entry) +#ifdef CONFIG_EFI_HANDOVER_PROTOCOL + .org efi32_stub_entry + 0x200 + .code64 +SYM_FUNC_START_NOALIGN(efi64_stub_entry) + jmp efi_stub_entry +SYM_FUNC_END(efi64_stub_entry) +#endif + .section ".rodata" /* EFI loaded image protocol GUID */ .balign 4 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index e688020..a3f764d 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -294,17 +294,6 @@ SYM_FUNC_START(startup_32) lret SYM_FUNC_END(startup_32) -#if IS_ENABLED(CONFIG_EFI_MIXED) && IS_ENABLED(CONFIG_EFI_HANDOVER_PROTOCOL) - .org 0x190 -SYM_FUNC_START(efi32_stub_entry) - add $0x4, %esp /* Discard return address */ - popl %ecx - popl %edx - popl %esi - jmp efi32_entry -SYM_FUNC_END(efi32_stub_entry) -#endif - .code64 .org 0x200 SYM_CODE_START(startup_64) @@ -542,13 +531,6 @@ trampoline_return: jmp *%rax SYM_CODE_END(startup_64) -#if IS_ENABLED(CONFIG_EFI_MIXED) && IS_ENABLED(CONFIG_EFI_HANDOVER_PROTOCOL) - .org 0x390 -SYM_FUNC_START(efi64_stub_entry) - jmp efi_stub_entry -SYM_FUNC_END(efi64_stub_entry) -#endif - .text SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)