From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.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 2EB2C36D51E for ; Thu, 23 Apr 2026 15:21:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776957669; cv=none; b=RvyVDWt06v6M1QEUVjRd12UyjmnIwGEOwgCw2uPTOnPAd07K/8DHur7NpPpnx36hy05kqLT9YXSom73rO+UKubnFJcgRT+YoN7LoB4AoSOJFHFMav5kxSnkks8dfcgrnBMwckxAPmxkrKCpbN4WA0DRTq8EIFhEYWnfhbT6we9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776957669; c=relaxed/simple; bh=yXlZQvg17gY3fAUY4jJcduAUEt6ZwFpw/pQ46EpXddg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OcIOkqw6e0DZVwxQ5p9cI4MLNdDc+Rqiwt0zSbR9JUks0j/ORTwVKYLOFunU1etrmkowTNJ6+YVpLiguZoMkTyM98ek3caKmzO3odS13k7ZAVZ3vsT3kqU5Mja2o2GzScQaL4FWkASK5CoTzhU61VRWxCtRMdYM0fKI+HsN8cNM= 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=vrV9AF+1; arc=none smtp.client-ip=209.85.221.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="vrV9AF+1" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-43ff19e54beso3632414f8f.2 for ; Thu, 23 Apr 2026 08:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776957667; x=1777562467; 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=LbAiKGuplKRxB5rqKcaYbo7jdF2aTV0smrny3EZRzJE=; b=vrV9AF+1EpsRxvHSq5PDdUKdVYYh3rCGQM1murUeAp0SNAi+4S7u04fNcG/C5jITMZ whHtdY+QSDfPurWaQ7j6BhMMhClmZUPnidoYUfr0s9MGca8M3PfbQAV59hhBQEfzZYw4 zYlS+kKGimCoKLHDnhko+gmuNmBjOQUemDFyR+uEq1dwpjJRKNALFkGaJ4+TfchjWjtt eo0i6d3tj1xmBhpOVQ/DsB+/DoRhwjT6vtR/EtmIOXidBk6YMVnCWAjhPPBsixELd01t Muvw04hcw2Y3q1I4LrOShyB5mfVo0DFedRZ+LkNq6jDdJHVIblRdVP/S9+22St1ZBNZM Y9Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776957667; x=1777562467; 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=LbAiKGuplKRxB5rqKcaYbo7jdF2aTV0smrny3EZRzJE=; b=oE7SEywRhsvzqj+N5ua86byOQen24GZeslYVQG5bznM5MRsYpaTKZIY3ZJrw2068Nw fHRQG/8xPZZz42xgYm+1mOSOKMaQ6oUz01yY61Z9uZNJ7C9tLV2E35OevRLZwYVbetA3 puPW88K9mmJrVTF5ffB+HvTfAgOz8gGFN7SnvhT/Qnp5SxePH4Jmbs3dMYDoJbZkVyTY DC6Il9mNfaGRWstbFKTeNTs9n6Y75Zvd8cOnmykarPg7Y9qsa5wx5L/rYUUnV5rrhwXW 5MxJLTNHVAgmtUSNv6jvxUt4rB5i4dwYMP9VDsyGz4se9zVAa6r1/Me4a9mqHzEe6zG8 9B3g== X-Gm-Message-State: AOJu0YxpeRth+U9h6uiQaE7RqW7Rj3wJR+uH8ET1M3yyqRlZQEklL+Xw yaRjDCfUspOZLO3vot5mfKEqm3NWgODkklB6TBJrPBlTyO3fJjQlvq3SjpTZ52aqTN4DEwjytpR LZ79SQy7YssxpqPRGM8OG0NOILjTh1cNMfyhSup75+tFNKY+XtkXfg2yduc1JDoVGlJIhSvN9XH 5btKzKSGKj+mN9QpvJg4ervXhzyXoRqw3SwA== X-Received: from wrqu15.prod.google.com ([2002:a5d:468f:0:b0:43d:70b2:d29a]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2c0c:b0:43e:b0f7:9ce9 with SMTP id ffacd0b85a97d-43fe3dc49c6mr44414203f8f.14.1776957666460; Thu, 23 Apr 2026 08:21:06 -0700 (PDT) Date: Thu, 23 Apr 2026 17:20:31 +0200 In-Reply-To: <20260423152024.1098465-19-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: <20260423152024.1098465-19-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1544; i=ardb@kernel.org; h=from:subject; bh=XoOv4APS7l/c88gRUS9wFyxalKNkl5Mjj1u3QN7wgaI=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIfOVxaEZ3lvnpK04VMAe7/nMeiLrMlV1tnBzzr01P+cK+ s7/43aio5SFQYyLQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAExk7SRGhp1HRe167uYzSW7W 5tD/Itw6LelaWUZh/cM5NSW1gsJdzAz/q+KSi8pq1586pDCryCI/2fK0pfj1rRIL/t26yJv05kk 5HwA= X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423152024.1098465-25-ardb+git@google.com> Subject: [PATCH v3 06/17] x86/efi: Unmap kernel-reserved boot regions from EFI page tables From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-efi@vger.kernel.org, x86@kernel.org, Ard Biesheuvel , "Mike Rapoport (Microsoft)" , Benjamin Herrenschmidt , Dave Young , Gregory Price 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 e79fb94c1bf6..1d10277796b7 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -433,12 +433,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. @@ -446,6 +440,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.54.0.rc2.544.gc7ae2d5bb8-goog