From patchwork Thu Nov 24 08:12:11 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: 25357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3258575wrr; Thu, 24 Nov 2022 00:14:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ShD6iYqnf31fDjVTG2KzxDMX1Q11GhdxEJvzylb4j0BocqdrSo1fQXAiOuVllCfhT1JsS X-Received: by 2002:a05:6402:1950:b0:461:4c59:143c with SMTP id f16-20020a056402195000b004614c59143cmr27865066edz.85.1669277649932; Thu, 24 Nov 2022 00:14:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669277649; cv=none; d=google.com; s=arc-20160816; b=M+pkS7Pwbcsbf1RLmUBsy66gZHTWBvkrVJsB1CS/6lkaL0ZehYf8LLK7YbpZFGrN6D WUr72//b2zN+vup5xJmQqWKgVjEldjZ8xKSRJwVV42FYfLaxfWxWwJ9EVlcDIdKjfUHu 7r7s32+R2bN+JyXu81/gRJAEoI6KCT/iXyEiGz6V2mbarda2cIHQKRz/40G7+aKCrZ7P m75Dr1mDunzIvxyzsb+0xij7GRrEZYv8d5LazMO0uRMizSyDxiRgb2NnqKg8sPj1RS11 q8UPqwbVzNPervSNMDzO07X1vkrJPSa/Ojrv6nq+nndna0EPoxY6cfJ8nvcJgE+9APvm wYIQ== 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=+NgHwDXz9S4bWYO9YdP86Q7XXC3KD51F5/ITpGepsr4=; b=vws666uI0pTqRf0t/DW0vD78QqJfcSn7bX73eW3KrHK8yDyA/csoklBxILXQtys3Jp qP2jfBcckGBMlVfiqVgdRyEF/5m8s9qabgXN3QOfKvKjPNU6obD0eO2woO9dKq6h5dB8 GxyeJneKOh1ETTramTDkHcTusHniZ950mvK0cRL8wmtLNWL50tytoRefsssmloWMqZLM Bl9cCb7S0kZ3kfQhKhNZ4hy3bcu7E6PdL6N2qkl32lCLYbjekksNslP5zeCiNJ2jgMsj LcazVI+cShyL6qk3t76mmXtpYRhkuESamTqibGFJYRCyISuhPMzphyqATf1mM9E1VVOA 7Nhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ri8IAbup; dkim=neutral (no key) header.i=@linutronix.de header.b=mLvfNRT1; 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 n13-20020a05640205cd00b0046a0fe69325si456609edx.265.2022.11.24.00.13.46; Thu, 24 Nov 2022 00:14:09 -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=ri8IAbup; dkim=neutral (no key) header.i=@linutronix.de header.b=mLvfNRT1; 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 S229946AbiKXINb (ORCPT + 99 others); Thu, 24 Nov 2022 03:13:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbiKXIMl (ORCPT ); Thu, 24 Nov 2022 03:12:41 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0138E6EDE; Thu, 24 Nov 2022 00:12:13 -0800 (PST) Date: Thu, 24 Nov 2022 08:12:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669277532; 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=+NgHwDXz9S4bWYO9YdP86Q7XXC3KD51F5/ITpGepsr4=; b=ri8IAbupofTWHkoCYIBU3eIsLM7OTTYpbUhd3qEC6hbSdFmaC3F3p6ZIZdW5e6hnPigVsZ zPjamGN19Su5K/p0/EONek+6zMKlDHO5CjjjIqCQpqUGYwq8AOOxevVVrNWswExIllUE4z pu838AHvajE7JbdRIAPGk6dIFn6ai2+wTJc7wgzNr4jQQwW4hbtfST72XMhD71REPVscI2 q5T+rBnp4w/ExwVTGbykzJ9lxK+zQcVq4bglWZLZnATfKdiIGOHGe5nDu7q+mdvwzCN1zS TPp5QmUh1la7AeVYhQziaUEkgcLrPoS34uhLUBTZa2N4KN49HgJipLdtaxaSug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669277532; 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=+NgHwDXz9S4bWYO9YdP86Q7XXC3KD51F5/ITpGepsr4=; b=mLvfNRT1g+44y67D0lPpjWvWvx4eyZ/KMJZgx+rIbCEwGnx83/60cQI5lcW3gPiTXhv8Qf /nI0gTk7MYC+2pBA== 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 efi32_entry out of head_64.S Cc: Ard Biesheuvel , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221122161017.2426828-6-ardb@kernel.org> References: <20221122161017.2426828-6-ardb@kernel.org> MIME-Version: 1.0 Message-ID: <166927753136.4906.15970187480921733252.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?1750364480744985551?= X-GMAIL-MSGID: =?utf-8?q?1750364480744985551?= The following commit has been merged into the x86/boot branch of tip: Commit-ID: 73a6dec80e2acedaef3ca603d4b5799049f6e9f8 Gitweb: https://git.kernel.org/tip/73a6dec80e2acedaef3ca603d4b5799049f6e9f8 Author: Ard Biesheuvel AuthorDate: Tue, 22 Nov 2022 17:10:05 +01:00 Committer: Borislav Petkov CommitterDate: Tue, 22 Nov 2022 19:24:09 +01:00 x86/boot/compressed: Move efi32_entry out of head_64.S Move the efi32_entry() routine out of head_64.S and into efi-mixed.S, which reduces clutter in the complicated startup routines. It also permits linkage of some symbols used by code to be made local. Signed-off-by: Ard Biesheuvel Signed-off-by: Borislav Petkov Link: https://lore.kernel.org/r/20221122161017.2426828-6-ardb@kernel.org --- arch/x86/boot/compressed/efi_mixed.S | 57 ++++++++++++++++++++++----- arch/x86/boot/compressed/head_64.S | 45 +--------------------- 2 files changed, 47 insertions(+), 55 deletions(-) diff --git a/arch/x86/boot/compressed/efi_mixed.S b/arch/x86/boot/compressed/efi_mixed.S index 58ab2e1..3487484 100644 --- a/arch/x86/boot/compressed/efi_mixed.S +++ b/arch/x86/boot/compressed/efi_mixed.S @@ -105,7 +105,7 @@ SYM_FUNC_START(__efi64_thunk) /* * Switch to IDT and GDT with 32-bit segments. This is the firmware GDT * and IDT that was installed when the kernel started executing. The - * pointers were saved at the EFI stub entry point in head_64.S. + * pointers were saved by the efi32_entry() routine below. * * Pass the saved DS selector to the 32-bit code, and use far return to * restore the saved CS selector. @@ -217,22 +217,59 @@ SYM_FUNC_START_LOCAL(efi_enter32) lret SYM_FUNC_END(efi_enter32) +/* + * 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(efi32_entry) + call 1f +1: pop %ebx + + /* Save firmware GDTR and code/data selectors */ + 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 (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 + btrl $X86_CR0_PG_BIT, %eax + movl %eax, %cr0 + + jmp startup_32 +SYM_FUNC_END(efi32_entry) + .data .balign 8 -SYM_DATA_START(efi32_boot_gdt) +SYM_DATA_START_LOCAL(efi32_boot_gdt) .word 0 .quad 0 SYM_DATA_END(efi32_boot_gdt) -SYM_DATA_START(efi32_boot_idt) +SYM_DATA_START_LOCAL(efi32_boot_idt) .word 0 .quad 0 SYM_DATA_END(efi32_boot_idt) -SYM_DATA_START(efi32_boot_cs) - .word 0 -SYM_DATA_END(efi32_boot_cs) - -SYM_DATA_START(efi32_boot_ds) - .word 0 -SYM_DATA_END(efi32_boot_ds) +SYM_DATA_LOCAL(efi32_boot_cs, .word 0) +SYM_DATA_LOCAL(efi32_boot_ds, .word 0) +SYM_DATA_LOCAL(efi32_boot_args, .long 0, 0, 0) +SYM_DATA(efi_is64, .byte 1) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 9dd9010..9cd2a28 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -289,48 +289,6 @@ SYM_FUNC_START(efi32_stub_entry) 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 %ebx - - /* Save firmware GDTR and code/data selectors */ - 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 (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 - btrl $X86_CR0_PG_BIT, %eax - movl %eax, %cr0 - - jmp startup_32 -SYM_FUNC_END(efi32_entry) - __HEAD #endif .code64 @@ -763,9 +721,6 @@ SYM_DATA_END_LABEL(boot32_idt, SYM_L_GLOBAL, boot32_idt_end) SYM_DATA(image_offset, .long 0) #endif #ifdef CONFIG_EFI_MIXED -SYM_DATA(efi32_boot_args, .long 0, 0, 0) -SYM_DATA(efi_is64, .byte 1) - #define ST32_boottime 60 // offsetof(efi_system_table_32_t, boottime) #define BS32_handle_protocol 88 // offsetof(efi_boot_services_32_t, handle_protocol) #define LI32_image_base 32 // offsetof(efi_loaded_image_32_t, image_base)