From patchwork Tue Aug 8 08:44:05 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: 132658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2297620vqr; Tue, 8 Aug 2023 11:01:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtKLgG+/iL/n9YEVwn8weKHTJ+rbrj1ELyfraSgb+HzUsh0BKLUkaPJfdx9nycK4XIRAHi X-Received: by 2002:a17:90b:4a91:b0:268:5558:de4c with SMTP id lp17-20020a17090b4a9100b002685558de4cmr285046pjb.38.1691517667391; Tue, 08 Aug 2023 11:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691517667; cv=none; d=google.com; s=arc-20160816; b=BMAiW1NPnI14pYpUzxJyL7h0koE326tshi3pNmbYrVBOW6fTrXQeG5EHKvqWCWW4Lp qDyC+LWjVvonsTQrdkila9JzLSjbdsULBnVMQ50BFQ6RIbg26klaVVyidDJLR237DQ1P SkhyYxcfZpWctPZWqMT3NY4cOBx9EV15uvKNmeLDxD2/mXmQY6+dhS6gh5Tny918dSDb irBYl9yGNOcHSWq2DO5bjKGCD0jUyjxvzyC4mBoPsTO5s+R6siQyHbZ5OQ2pC71YMaG8 VjzbVgJQjiPX98IRN8wsz1Dn/CMs/ZI34j1ex/JFtq4qp/rvojBfKfNWws7Ma31aLv6U WS9A== 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; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a170903018400b001b9c992945fsi7987272plg.555.2023.08.08.11.00.53; Tue, 08 Aug 2023 11:01:07 -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; 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 S232960AbjHHQd0 (ORCPT + 99 others); Tue, 8 Aug 2023 12:33:26 -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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773589111291319292 X-GMAIL-MSGID: 1773684830071534092 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)