From patchwork Thu Nov 24 08:12:14 2022 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: 25360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3258725wrr; Thu, 24 Nov 2022 00:14:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf64GJAGWtpl4KRR4n2qxNv5VA2uNKIyy+pk78doP7FfzcN22R44qo0n0Ql3oIjcgL8swOLv X-Received: by 2002:a17:902:ca04:b0:184:e4ac:d135 with SMTP id w4-20020a170902ca0400b00184e4acd135mr19335619pld.47.1669277672617; Thu, 24 Nov 2022 00:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669277672; cv=none; d=google.com; s=arc-20160816; b=wt4mv73sywzeee/djn6L8S+0ky4A+Eemtab4btt4e0zkUu2YAHRW//92nxW4nVBb8L vL/kxXG+hY4P/UfK4LNZf9U6io/w2174wQA413TJk/krz6gg4VgDqYWnP27RY0cTKpog OGZ8DX9eyrrFOq7YoGImr5X2yavIGu4S62shQhZKstPjBAsHzlJYuGwMS50wCwyA0GW4 L1D1C4y5YUDrR2AUgirfsSPjnwI10qnyh+tQX8BrRSgMq83QGbgJXrZIUeQX0i6DSnif U4h0NwsmtMFXUY72tmP3/MyRKoSHKCDh+f/Mlayti/e3REa7duZPb3Z/6wLUfUnhSOwG ujvA== 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=cBmPkFd20Au8OG8UFls+h9LtmUUoiGqql7QhEiFSf8o=; b=xNUnRznLOfYXVsvtR/v7nFFCp1f7eyOIE241C/scrs82cgSFSuU5J3+URS7BmWnv3x yVH077S3qJpzWLIuyWxgKVlh8SNTnvUZdj6zCtQcDUd4rnkO55g3XeXPKBBf9AptD7C4 iVKlO/AYPpbQ7Qu03v7+s+MVLAtAKfOLmZ+ZoNkORIFXsiKNkiGcS6l6KnGgYhAyaG+f 51D3FFToPHv2y74fW/HCIuwYwRnXRfNguAXEpqgh4ighPYAHGBSV0MJwr1nqowTbC60L hDBFWJBevAXSYcBxtOipQMrfIYxSYSyroEgfSJqwPlrjbmZx6sOZ4tzAykB9n5Tml+ME YhxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=p95dAzSH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 bx23-20020a056a00429700b0056353f0bd40si479067pfb.29.2022.11.24.00.14.20; Thu, 24 Nov 2022 00:14:32 -0800 (PST) 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=p95dAzSH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S229996AbiKXINy (ORCPT + 99 others); Thu, 24 Nov 2022 03:13:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229852AbiKXIMm (ORCPT ); Thu, 24 Nov 2022 03:12:42 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34BA5E8728; Thu, 24 Nov 2022 00:12:17 -0800 (PST) Date: Thu, 24 Nov 2022 08:12:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669277535; 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=cBmPkFd20Au8OG8UFls+h9LtmUUoiGqql7QhEiFSf8o=; b=p95dAzSHghUmPbjB5DFozN8USFk/hvzyXKRaueNrx2fLmCJ4WxQ3dOeI6GOiiWDVpGwG9s fgglhG3MUwfeAJ/SXQnDuIKxyhJfydPUkbNhKmpZ9HT5xrjVKyyVaMHEfx4U6ZJs05jS7S okF5zN5sWLi1/rBKxlm0ifA9foFFR8LXxXaydfbAfOG3u5u/2mwPRu/QRzGu5tftGG2U07 ZUnZKG1db55MFt7a1lTKiIj2MXY7yD6zSz+6R8IeZKLHUdUo5wvNsz1u/Xz7Fg1lQlR4Eo qyvi9JH77EMFN4QZmY+a+mW6xAhIMVaOEhrQQknkkV8li8LnWovtV4rrE45dKw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669277535; 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=cBmPkFd20Au8OG8UFls+h9LtmUUoiGqql7QhEiFSf8o=; b=6NJvUdwCxf/V10Lea3aFKLxm+T2hZWX2VKeqnGe4JuLHMvW/k4j5OEA+sYFDwjZ+zG6b67 zKdxb0ncSlv1ZjDQ== 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/compressed: Move 32-bit entrypoint code into .text section Cc: Ard Biesheuvel , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221122161017.2426828-3-ardb@kernel.org> References: <20221122161017.2426828-3-ardb@kernel.org> MIME-Version: 1.0 Message-ID: <166927753466.4906.15998812490802967207.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750364504917299724?= X-GMAIL-MSGID: =?utf-8?q?1750364504917299724?= The following commit has been merged into the x86/boot branch of tip: Commit-ID: e2ab9eab324cdf240de89741e4a1aa79919f0196 Gitweb: https://git.kernel.org/tip/e2ab9eab324cdf240de89741e4a1aa79919f0196 Author: Ard Biesheuvel AuthorDate: Tue, 22 Nov 2022 17:10:02 +01:00 Committer: Borislav Petkov CommitterDate: Tue, 22 Nov 2022 19:03:56 +01:00 x86/boot/compressed: Move 32-bit entrypoint code into .text section Move the code that stores the arguments passed to the EFI entrypoint into the .text section, so that it can be moved into a separate compilation unit in a subsequent patch. Signed-off-by: Ard Biesheuvel Signed-off-by: Borislav Petkov Link: https://lore.kernel.org/r/20221122161017.2426828-3-ardb@kernel.org --- arch/x86/boot/compressed/head_64.S | 48 ++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index d33f060..5d07ef7 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -303,24 +303,41 @@ SYM_FUNC_START(efi32_stub_entry) popl %ecx popl %edx popl %esi + jmp efi32_entry +SYM_FUNC_END(efi32_stub_entry) + .text +/* + * This is the common EFI stub entry point for mixed mode. + * + * Arguments: %ecx image handle + * %edx EFI system table pointer + * %esi struct bootparams pointer (or NULL when not using + * the EFI handover protocol) + * + * Since this is the point of no return for ordinary execution, no registers + * are considered live except for the function parameters. [Note that the EFI + * stub may still exit and return to the firmware using the Exit() EFI boot + * service.] + */ +SYM_FUNC_START_LOCAL(efi32_entry) call 1f -1: pop %ebp - subl $ rva(1b), %ebp - - movl %esi, rva(efi32_boot_args+8)(%ebp) -SYM_INNER_LABEL(efi32_pe_stub_entry, SYM_L_LOCAL) - movl %ecx, rva(efi32_boot_args)(%ebp) - movl %edx, rva(efi32_boot_args+4)(%ebp) - movb $0, rva(efi_is64)(%ebp) +1: pop %ebx /* Save firmware GDTR and code/data selectors */ - sgdtl rva(efi32_boot_gdt)(%ebp) - movw %cs, rva(efi32_boot_cs)(%ebp) - movw %ds, rva(efi32_boot_ds)(%ebp) + sgdtl (efi32_boot_gdt - 1b)(%ebx) + movw %cs, (efi32_boot_cs - 1b)(%ebx) + movw %ds, (efi32_boot_ds - 1b)(%ebx) /* Store firmware IDT descriptor */ - sidtl rva(efi32_boot_idt)(%ebp) + sidtl (efi32_boot_idt - 1b)(%ebx) + + /* Store boot arguments */ + leal (efi32_boot_args - 1b)(%ebx), %ebx + movl %ecx, 0(%ebx) + movl %edx, 4(%ebx) + movl %esi, 8(%ebx) + movb $0x0, 12(%ebx) // efi_is64 /* Disable paging */ movl %cr0, %eax @@ -328,7 +345,8 @@ SYM_INNER_LABEL(efi32_pe_stub_entry, SYM_L_LOCAL) movl %eax, %cr0 jmp startup_32 -SYM_FUNC_END(efi32_stub_entry) +SYM_FUNC_END(efi32_entry) + __HEAD #endif .code64 @@ -831,7 +849,9 @@ SYM_FUNC_START(efi32_pe_entry) */ subl %esi, %ebx movl %ebx, rva(image_offset)(%ebp) // save image_offset - jmp efi32_pe_stub_entry + xorl %esi, %esi + jmp efi32_entry // pass %ecx, %edx, %esi + // no other registers remain live 2: popl %edi // restore callee-save registers popl %ebx