From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.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 D6B523ACA51 for ; Fri, 10 Apr 2026 08:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775808039; cv=none; b=X9XK+3a34AsszwDaPhsbACezRM+dw19R0H9ZqG+V4e4E4qwPWuv03809z+5KFeJA5C1FK8aKAEF//k1KIgwe0suczVf+hNEx4WZUVjrmLMsnsqerKWuwFJXPA9Eo+qgAWRDycFLulFHppzdpVh0UJNwGsFfEJ5AsTg3C+0EQ0eM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775808039; c=relaxed/simple; bh=xiBwRUwdD7mwCb3k1s6xV78E/2MQKEFPT4F6+ExAwmQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=i+jdM9CUdhAU03hJzSEPJGgzu3IVhWHOtyTQhNB/eY16uLvTnoih9M9zY+3oZ0c6kqgWG0GkxI6uxKkarPNtc4/QbUzZHNjcs7FMJGVrKxFHcbXctH+ik6yte69AKI94KjbkmgHQQL9bOln/A3S5oLKScUTKvN7ZSvkV0daYW7Q= 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=Z2YEXOFK; arc=none smtp.client-ip=209.85.128.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="Z2YEXOFK" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-488c2cc0cbaso10044435e9.3 for ; Fri, 10 Apr 2026 01:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775808035; x=1776412835; 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=uwcAQPDDIrW1cFM9HvdigTfFfqAoQNgDOfizPxofehU=; b=Z2YEXOFKj8JUhSB7KyPkVZifrR4UQTSyfsc+9K2N8hwTc7mpqKBXneCZct3LQflKcZ Y8PDqu1wsvZAtPFm60V0p4PAdJ8qDQrOhGwrUpF8S1rXNA19z2fZDB8E/0lP6Wt7RMUs Ij1w6ktc8uh8EYJeIbErZlDJP6bpA2w0jSuJhTDyAh6e1ZfWEZKiimWidQzrp9A7g/xB aQnbcI8KKNNuL4Awlzrg2ZCiS5x7iT6Wvc+xNTTycxTa0FWO6PrEhVrFeg9mMU14BiMW yH+VflzcMu4v19mkXO+mGvgFmxRvTFW/YjKr1iVrz8GvmSWJvZlUjRjEwAdSDw458xjG Fq6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775808035; x=1776412835; 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=uwcAQPDDIrW1cFM9HvdigTfFfqAoQNgDOfizPxofehU=; b=bA4QGsdPlqqseOrUkfWhNNB12VtcjRKZXK9DZiKkCMrhGhDPDLUmC29Y4hvp8RB6yM mTCpK1FgJxLpkjT5KgtlBduH1GWlm2YhVw4Xr7sCrWChOebMGRKchAKwqOtjIj7vUTAf bmSIXpWLBHpXak8V6Ly6fz7aqc6UjpL8RpTwCDsL91T1jPM4W7mLzzYiCkhbon25ytKO z7Xa4AYM1E8XhSJQbuAi2+IgB9domgAgtiqO1qZcBXy9boE0mMjyJdq5iNtlavW4zkE2 Vy8Mw5xiFn2t6arSW87fnlOJFiMS8VLCpj/cyyiejod42+TAmpCHysgbZ/Gl9ZWnNQZZ 58ZQ== X-Gm-Message-State: AOJu0YwhhaC4rXK+/c5W1sRrMv5yy6dje2vMQY1yQ/unD/NiuSj8SGcC O7UWwB8SDo4hVbPZShmK/JnV8ho6a0XGBitA7OQM/XJErSlfjsy334rLPajisdja2VhLwgJZXg= = X-Received: from wrmg2.prod.google.com ([2002:adf:e402:0:b0:43c:fd30:98a9]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c10d:b0:488:ae4e:51a5 with SMTP id 5b1f17b1804b1-488d683d633mr16251785e9.15.1775808034928; Fri, 10 Apr 2026 01:00:34 -0700 (PDT) Date: Fri, 10 Apr 2026 09:59:56 +0200 In-Reply-To: <20260410075950.1687350-9-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: <20260410075950.1687350-9-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1541; i=ardb@kernel.org; h=from:subject; bh=G2RtUAKBQckrIeEWiuJzklUVykG05lXyXKv1jbxIYNI=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIfPGOoZHnG67pz06+TN2k0qQ5Ntq92SWB9P98iYWXV1cV fc649K7jlIWBjEuBlkxRRaB2X/f7Tw9UarWeZYszBxWJpAhDFycAjCR8hJGhkk68+dx1BasXttt Y73a6eIl0dYP/gUmnSe+KM7YI38ywpqR4Z3j3OoL8etuLTh8naFLz2i96R6juJuiP8LtWlrvztu bzg4A X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260410075950.1687350-15-ardb+git@google.com> Subject: [PATCH 6/7] x86/efi: Unmap kernel-reserved boot regions from EFI page tables From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Ard Biesheuvel Content-Type: text/plain; charset="UTF-8" From: Ard Biesheuvel Currently, the logic that unmaps boot services code and data regions that were mapped temporarily to work around firmware bugs disregards regions that have been marked as EFI_MEMORY_RUNTIME. However, such regions only have significance to the OS, and there is no reason to retain the mapping in the EFI page tables, given that the runtime firmware must never touch those regions. So pull the unmap forward. Signed-off-by: Ard Biesheuvel --- arch/x86/platform/efi/quirks.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index ee906c0c46c1..929ee71a140c 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -438,12 +438,6 @@ void __init efi_unmap_boot_services(void) continue; } - /* Do not free, someone else owns it: */ - if (md->attribute & EFI_MEMORY_RUNTIME) { - num_entries++; - continue; - } - /* * Before calling set_virtual_address_map(), EFI boot services * code/data regions were mapped as a quirk for buggy firmware. @@ -451,6 +445,12 @@ void __init efi_unmap_boot_services(void) */ efi_unmap_pages(md); + /* Do not free, someone else owns it: */ + if (md->attribute & EFI_MEMORY_RUNTIME) { + num_entries++; + continue; + } + /* * With CONFIG_DEFERRED_STRUCT_PAGE_INIT parts of the memory * map are still not initialized and we can't reliably free -- 2.53.0.1213.gd9a14994de-goog