Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2145577rdb; Mon, 9 Oct 2023 14:22:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTLi1HBsp2XW+Hk1QU8kEzUAmkd3Q3JaDVWdkEuNXhustNo9zFMXasQLQfmGJGgMfDCjDv X-Received: by 2002:a05:6808:df3:b0:3a4:2204:e9e6 with SMTP id g51-20020a0568080df300b003a42204e9e6mr17874465oic.21.1696886542139; Mon, 09 Oct 2023 14:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696886542; cv=none; d=google.com; s=arc-20160816; b=Br1sPAev/be4adywu+7w29CySRHqwNHs0ZjONidnj0SpjElUxbWiRirBsIJW+qjwGw WNW5C1lJhZWzpbpqJfLmuRTt4GI8Ov36L+0VaXag5VHzJN5IvqixD0tvxnwOeBDgvGZL o6GnoEeiXZOJ7f/prjyyQ6qJo+l2DuCWEA4lUhtpQZMVOOBp3KhrXCcpNDcn5zvfa3GR HtmX3vzvAN5KtvDrgB+5HpDYjQ8UZg2ByX4vyaDYKOsKePUj41c9+1+0Crrs/ksBkpYR EEv7iukUKvmEjzUp7BYuG0bAzTY52urRH4sqL+1Zb7MC0yYaFImLOUWWfFryhDFJ/pAx qCAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8mLgZgZsKINwRDDkWZzPxyZScELihXUCqDAgiDKqpYg=; fh=5rjrd9z1AwCU6K4zctiyztRWfSlrVT4HOR1EMu5XpZI=; b=Hm4zNPJ3KjBmRqXbSSHzI3C7LtF0oJTAqob/sfLBczZUqvZAaXdVl89SS7y8LFr7O+ FK81UEgvrsXC7BarfncBRqdc7naEfS1Qs8PUE4PWSpY2r82B/JQwWI2ztg0FO4CDlsgF h3WWm1XELk8C0tjsCP2z7LqdzH5EzkCTvLDmV89BeTLHhZoGoQ0Q9SDq/vcHvlMYkwlI sxYLsIEDJmstL2kAmQbRTxIc+drXSI3G1Uz95PTlLnl7Ka9mCx/eicE1aCLFW/KQWAXv UI+zdlRiIpWSDdvIo8lE9I7RRLzCHU6kcfiC4N7iwMRR2W7no3hD2ht/4QP2BTryt+a7 4CsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fUNZTck4; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id z70-20020a633349000000b0058974d3c292si9542186pgz.191.2023.10.09.14.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 14:22:22 -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=@kernel.org header.s=k20201202 header.b=fUNZTck4; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4A80D80A998D; Mon, 9 Oct 2023 14:22:19 -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 S1378303AbjJIVWJ (ORCPT + 99 others); Mon, 9 Oct 2023 17:22:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234644AbjJIVVX (ORCPT ); Mon, 9 Oct 2023 17:21:23 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2A5110E5; Mon, 9 Oct 2023 14:20:45 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E5E9C433C8; Mon, 9 Oct 2023 21:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696886445; bh=Izus3StnMYpbpfGzcH3rYhOA83ytnmOL3p/SwGQe1R4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fUNZTck4iaJOeM8Je3T8WvINpFaFE1urkvmBB0giTm0St8bMQ0quQi+ggYYVRP50h MahNO4+KavBiymB0NVI9XueRQWswedp5X3ZXh0GX0NqHzy+STs6J+OjLX6tyCJnsAh I9eaIX1k9ArCepOmU9Puaps1+rQZghRG8u5NrYungLv8mpdOzHVfoogxkQM4Tab66C 7ObaYxQtU3/hMaWj5eWKTqZe/UYdyPous2VOaV+30c+HISS0AwVZDrJLVUNT9q//rP DH2uu6ixRAvD7KQBwB+gyUasD8wt2LwYUN0ZsF4E+z52yoV+zJ7NHxDD1ThrW8D3OU PjqwmudJAgOlA== From: Arnd Bergmann To: Thomas Zimmermann , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Arnd Bergmann , "David S. Miller" , "K. Y. Srinivasan" , Ard Biesheuvel , Borislav Petkov , Brian Cain , Catalin Marinas , Christophe Leroy , Daniel Vetter , Dave Hansen , David Airlie , Deepak Rawat , Dexuan Cui , Dinh Nguyen , Greg Kroah-Hartman , Guo Ren , Haiyang Zhang , Helge Deller , Huacai Chen , Ingo Molnar , Javier Martinez Canillas , John Paul Adrian Glaubitz , Khalid Aziz , Linus Walleij , Matt Turner , Max Filippov , Michael Ellerman , Nicholas Piggin , Palmer Dabbelt , Russell King , Thomas Bogendoerfer , Thomas Gleixner , WANG Xuerui , Wei Liu , Will Deacon , x86@kernel.org, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-hyperv@vger.kernel.org Subject: [PATCH v3 9/9] efi: move screen_info into efi init code Date: Mon, 9 Oct 2023 23:18:45 +0200 Message-Id: <20231009211845.3136536-10-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009211845.3136536-1-arnd@kernel.org> References: <20231009211845.3136536-1-arnd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Mon, 09 Oct 2023 14:22:19 -0700 (PDT) X-Spam-Level: ** From: Arnd Bergmann After the vga console no longer relies on global screen_info, there are only two remaining use cases: - on the x86 architecture, it is used for multiple boot methods (bzImage, EFI, Xen, kexec) to commucate the initial VGA or framebuffer settings to a number of device drivers. - on other architectures, it is only used as part of the EFI stub, and only for the three sysfb framebuffers (simpledrm, simplefb, efifb). Remove the duplicate data structure definitions by moving it into the efi-init.c file that sets it up initially for the EFI case, leaving x86 as an exception that retains its own definition for non-EFI boots. The added #ifdefs here are optional, I added them to further limit the reach of screen_info to configurations that have at least one of the users enabled. Reviewed-by: Ard Biesheuvel Reviewed-by: Javier Martinez Canillas Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- arch/arm/kernel/setup.c | 4 ---- arch/arm64/kernel/efi.c | 4 ---- arch/arm64/kernel/image-vars.h | 2 ++ arch/loongarch/kernel/efi.c | 3 ++- arch/loongarch/kernel/image-vars.h | 2 ++ arch/loongarch/kernel/setup.c | 5 ----- arch/riscv/kernel/image-vars.h | 2 ++ arch/riscv/kernel/setup.c | 5 ----- drivers/firmware/efi/efi-init.c | 14 +++++++++++++- drivers/firmware/efi/libstub/efi-stub-entry.c | 8 +++++++- 10 files changed, 28 insertions(+), 21 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index c15dfdbe3d5ae..b808712e85981 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -939,10 +939,6 @@ static struct screen_info vgacon_screen_info = { }; #endif -#if defined(CONFIG_EFI) -struct screen_info screen_info; -#endif - static int __init customize_machine(void) { /* diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 2b478ca356b00..52089f111c8db 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -71,10 +71,6 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md) return pgprot_val(PAGE_KERNEL_EXEC); } -/* we will fill this structure from the stub, so don't put it in .bss */ -struct screen_info screen_info __section(".data"); -EXPORT_SYMBOL(screen_info); - int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) { pteval_t prot_val = create_mapping_protection(md); diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h index 35f3c79595137..5e4dc72ab1bda 100644 --- a/arch/arm64/kernel/image-vars.h +++ b/arch/arm64/kernel/image-vars.h @@ -27,7 +27,9 @@ PROVIDE(__efistub__text = _text); PROVIDE(__efistub__end = _end); PROVIDE(__efistub___inittext_end = __inittext_end); PROVIDE(__efistub__edata = _edata); +#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) PROVIDE(__efistub_screen_info = screen_info); +#endif PROVIDE(__efistub__ctype = _ctype); PROVIDE(__pi___memcpy = __pi_memcpy); diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c index 9fc10cea21e10..df7db34024e61 100644 --- a/arch/loongarch/kernel/efi.c +++ b/arch/loongarch/kernel/efi.c @@ -115,7 +115,8 @@ void __init efi_init(void) set_bit(EFI_CONFIG_TABLES, &efi.flags); - init_screen_info(); + if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) + init_screen_info(); if (boot_memmap == EFI_INVALID_TABLE_ADDR) return; diff --git a/arch/loongarch/kernel/image-vars.h b/arch/loongarch/kernel/image-vars.h index e561989d02de9..5087416b9678d 100644 --- a/arch/loongarch/kernel/image-vars.h +++ b/arch/loongarch/kernel/image-vars.h @@ -12,7 +12,9 @@ __efistub_kernel_entry = kernel_entry; __efistub_kernel_asize = kernel_asize; __efistub_kernel_fsize = kernel_fsize; __efistub_kernel_offset = kernel_offset; +#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) __efistub_screen_info = screen_info; +#endif #endif diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 0d5edf1f7e4a1..407cd6b49bef6 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -57,10 +56,6 @@ #define SMBIOS_CORE_PACKAGE_OFFSET 0x23 #define LOONGSON_EFI_ENABLE (1 << 3) -#ifdef CONFIG_EFI -struct screen_info screen_info __section(".data"); -#endif - unsigned long fw_arg0, fw_arg1, fw_arg2; DEFINE_PER_CPU(unsigned long, kernelsp); struct cpuinfo_loongarch cpu_data[NR_CPUS] __read_mostly; diff --git a/arch/riscv/kernel/image-vars.h b/arch/riscv/kernel/image-vars.h index ea1a10355ce90..3df30dd1c458b 100644 --- a/arch/riscv/kernel/image-vars.h +++ b/arch/riscv/kernel/image-vars.h @@ -28,7 +28,9 @@ __efistub__start_kernel = _start_kernel; __efistub__end = _end; __efistub__edata = _edata; __efistub___init_text_end = __init_text_end; +#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) __efistub_screen_info = screen_info; +#endif #endif diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 0c466a50f1744..0624f44d43eca 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -40,10 +39,6 @@ #include "head.h" -#if defined(CONFIG_EFI) -struct screen_info screen_info __section(".data"); -#endif - /* * The lucky hart to first increment this variable will boot the other cores. * This is used before the kernel initializes the BSS so it can't be in the diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index ef0820f1a9246..d4987d0130801 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -55,6 +55,15 @@ static phys_addr_t __init efi_to_phys(unsigned long addr) extern __weak const efi_config_table_type_t efi_arch_tables[]; +/* + * x86 defines its own screen_info and uses it even without EFI, + * everything else can get it from here. + */ +#if !defined(CONFIG_X86) && (defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON)) +struct screen_info screen_info __section(".data"); +EXPORT_SYMBOL_GPL(screen_info); +#endif + static void __init init_screen_info(void) { struct screen_info *si; @@ -240,5 +249,8 @@ void __init efi_init(void) memblock_reserve(data.phys_map & PAGE_MASK, PAGE_ALIGN(data.size + (data.phys_map & ~PAGE_MASK))); - init_screen_info(); + if (IS_ENABLED(CONFIG_X86) || + IS_ENABLED(CONFIG_SYSFB) || + IS_ENABLED(CONFIG_EFI_EARLYCON)) + init_screen_info(); } diff --git a/drivers/firmware/efi/libstub/efi-stub-entry.c b/drivers/firmware/efi/libstub/efi-stub-entry.c index 2f1902e5d4075..a6c0498351905 100644 --- a/drivers/firmware/efi/libstub/efi-stub-entry.c +++ b/drivers/firmware/efi/libstub/efi-stub-entry.c @@ -13,7 +13,13 @@ struct screen_info *alloc_screen_info(void) { if (IS_ENABLED(CONFIG_ARM)) return __alloc_screen_info(); - return (void *)&screen_info + screen_info_offset; + + if (IS_ENABLED(CONFIG_X86) || + IS_ENABLED(CONFIG_EFI_EARLYCON) || + IS_ENABLED(CONFIG_SYSFB)) + return (void *)&screen_info + screen_info_offset; + + return NULL; } /* -- 2.39.2