From nobody Thu Apr 2 22:05:28 2026 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C05C2EDD70 for ; Thu, 26 Mar 2026 13:27:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774531640; cv=none; b=arHboL/PJrpN1ceprE1h6loIhVwbUdI8IQ8KulqRqpSUjcB41K8mF2GZchwFjHZZBjEdeFCWkjE9qGkRuBhttNIALeZ2LhQKDAqenx9Vk9gx+LOFFyIMkXoM8Bf0DGEDbdRyNg+fv9pCHuOJIMpAj4fauddK38X7sMJWP65pPCg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774531640; c=relaxed/simple; bh=WbNrFRXlNX50+SwMQqetIvGIhoch9/Q4vJfpPel7DPU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Aq031AI5bTC2bvuk9ab20NNlP/Hmm+1BFL0cEmIa0UMQBBmvF0l0QoYlhMd+vmLphRNjkyG0Lz4VrROmAkmWovolB66+TzmK822RXtmx1guaYD6IS8sRWALPnzz3+CDjsgRFitD6BUbqYEErbLqjJMkBu7hzGxNCsAouf1uj7tM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SaNs6d2Q; arc=none smtp.client-ip=209.85.218.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SaNs6d2Q" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-b938cb02038so112567166b.0 for ; Thu, 26 Mar 2026 06:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774531638; x=1775136438; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qqjJgWZvGe+GH9cTzgYDDSkDUy3ExwqWXbelQXjht+k=; b=SaNs6d2QY6Fj4A9RqHAxC0LcQchcDzTN9Mnm/lvrJgkeeJRV/CyV9ebbqu/JWfOPna XcukaWcJGvG8CbT+mAN4NqFF4M/oD2INDU2HoD7t55V+n7J9DOlr7G6zI7l2lq7BfxBH dPwYhDffdBcRe00y3cLmLsPR/ZWYEWTPY/Su5SLb7qLmRgh7Wb3ikyubR290OtRt5Vbp J9w32nxmqbPx8ly9e3WrxpodTw+RkrjZRz5sAHUxN7txcyE6sZLKX0hrTX+m2psIxkfL RanySP2fm4IA11JnfKJWOsxspbwKPApGl1zP9f+wmEZow2nC/XUYHgyEudW613Vbd8aZ KE1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774531638; x=1775136438; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qqjJgWZvGe+GH9cTzgYDDSkDUy3ExwqWXbelQXjht+k=; b=DiKrvzDBZe55MnsvZIlAXwFeEVFrPjvQTdFxsHxPlFFeMA4wQvrvRKYXE3C3r0N6iC JZ7ShlRSYEkbAwIE7tLNVA0mJ4y0V7S67YE4uBder4HcbLVq5SU+EUeH0cAgryliKNfn 2HJWzTFRnQAOTth9yDjC1TYiqFA6MU+6DoNIhYXFR8gQmi3VDxLJhWCcD+fNx2X5LFd8 yD8SEMFpAly7dLCI8V3knOOX+G4Vm6X4iBs/rrIic43IjHeFVhT0mnotD3rNe1Oal8WS 1m9nl0/yeYOjn9mvAo27DQzTF05ZKvHp80AmU+e7wmC09x//UmGoKtbHKw1vMJAd8eon mYiA== X-Gm-Message-State: AOJu0YyAwWtfsmLVTNnM9IbUtWYe4i323W61t7y2br2arEGHg/17GQiz EAZsld7URrq/1g8RZI7sdPlXNANsuuwYi7RzcSS1W+BJMXUYk5sc4kI+NVlj4qPBklp0IddF+A= = X-Received: from ejcji12.prod.google.com ([2002:a17:907:980c:b0:b93:58ba:e1d8]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:906:4fca:b0:b94:82e:55e7 with SMTP id a640c23a62f3a-b9b2eb254b3mr105037166b.25.1774531637697; Thu, 26 Mar 2026 06:27:17 -0700 (PDT) Date: Thu, 26 Mar 2026 14:26:58 +0100 In-Reply-To: <20260326132655.1733873-7-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260326132655.1733873-7-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=2488; i=ardb@kernel.org; h=from:subject; bh=A55998XzokyKWlEuNht3NSD6O3K91gXWoI+V5wOS36Y=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIfOoiVISI7fkc6Fnun0ie7Yt2nHP91K2Z4fVa8uWXXobu eWSF/N2lLIwiHExyIopsgjM/vtu5+mJUrXOs2Rh5rAygQxh4OIUgIkETWb4w8U957z2x6vX5Ze5 uJiFbqmIS3zbmsLfnHWiVePUrZIVuYwMa50e/GZuPv77716rf163QvlMN7DZSbzLunStLHZSgJM 1JwA= X-Mailer: git-send-email 2.53.0.1018.g2bb0e51243-goog Message-ID: <20260326132655.1733873-9-ardb+git@google.com> Subject: [PATCH 2/5] x86/efi: Gather initial memory reservation and table handling logic From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Ard Biesheuvel , Dave Young , Gregory Price , Usama Arif , Jiri Slaby , Breno Leitao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel Move the back-to-back calls to various EFI routines related to processing of firmware tables and reserving the associated memory into a helper function. This is tidier, and will avoid the need to add yet another function call there in a subsequent patch. Signed-off-by: Ard Biesheuvel Reviewed-by: Gregory Price --- arch/x86/include/asm/efi.h | 5 ++--- arch/x86/kernel/setup.c | 11 ++--------- arch/x86/platform/efi/efi.c | 13 +++++++++++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 51b4cdbea061..3dcb137a49ed 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -387,11 +387,10 @@ static inline bool efi_is_table_address(unsigned lon= g phys_addr) { return false; } -static inline void efi_reserve_boot_services(void) -{ -} #endif /* CONFIG_EFI */ =20 +void efi_init_reservations(void); + extern int __init efi_memmap_alloc(unsigned int num_entries, struct efi_memory_map_data *data); =20 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index eebcc9db1a1b..9f5f50bff16d 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1083,15 +1083,8 @@ void __init setup_arch(char **cmdline_p) mem_encrypt_setup_arch(); cc_random_init(); =20 - efi_find_mirror(); - efi_esrt_init(); - efi_mokvar_table_init(); - - /* - * The EFI specification says that boot service code won't be - * called after ExitBootServices(). This is, in fact, a lie. - */ - efi_reserve_boot_services(); + if (efi_enabled(EFI_BOOT)) + efi_init_reservations(); =20 /* preallocate 4k for mptable mpc */ e820__memblock_alloc_reserved_mpc_new(); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index d84c6020dda1..f32276bd8d4e 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -165,6 +165,19 @@ static void __init do_add_efi_memmap(void) e820__update_table(e820_table); } =20 +void __init efi_init_reservations(void) +{ + efi_find_mirror(); + efi_esrt_init(); + efi_mokvar_table_init(); + + /* + * The EFI specification says that boot service code won't be + * called after ExitBootServices(). This is, in fact, a lie. + */ + efi_reserve_boot_services(); +} + /* * Given add_efi_memmap defaults to 0 and there is no alternative * e820 mechanism for soft-reserved memory, import the full EFI memory --=20 2.53.0.1018.g2bb0e51243-goog