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 BF9BF326930 for ; Thu, 23 Apr 2026 15:21:01 +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=1776957663; cv=none; b=SKUEAmqnLNGu8P7b2PhULkFiVC3mjtDmOzIyE+q/Cegq+DdTAaXV0qRmuaaKTZ2+bzXYDlH0KetnkRd0TdQPYd5Cn9ot5up0yyDQ0+3gRNzSMnTmw1QU8QMrziLlpntWOPc7cdlxl0k0qaVsASvQVeFXe/kB0SOlKaeCOXKg9sY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776957663; c=relaxed/simple; bh=rDCZLCXVdfhYaKY8LVOXFIF/6b3Fy0ov0xYCP0dCALs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=o0mgExQQ1adXFo0Ih1P2BnQ23t+yztMMLipaoPaOeSlW4munVSrc5i/iaDqzIZd9LWCiKudVKEMayRhjtYTD9ANM9ewvBOypO8QnNI1RVSod+Yz33YcyT/iZsFcNl0tAA55ce0ZyZcLuZlAQ1TKpyZD1I1kHnpnk9N5kOhF8sdE= 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=ZSQQFBdl; 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="ZSQQFBdl" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-488c2aa6becso63671085e9.2 for ; Thu, 23 Apr 2026 08:21:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776957660; x=1777562460; 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=4mSa+7vyhBL8YFiiwNvF07aeMvbJQOJ+ZSj43s2ayiM=; b=ZSQQFBdlG2mmBfYm1RV8vyz5JyOZ2ATNHEhJkqiAcQKfcGyYYIzcQCv8j4eY/hnh4C L2NbR5ngJ0uGRe6JbjJCe8pv35mGkWWaSCKgMCT3DVLNLogrTqKVSjx5089XoqLEYrkl RKtABHbp49SNPgtrlLTaMzLP9J2trhRVj7hxjoI+qjk8tcz4Sj1x+ZhZpPJidr8+LHof pPCZMKS9s7Vs96guZ2LHsixDidMT+kyQNWmrWIvyvFhb35ffiqAEiBQDASH7Cgl0g4TO idta5nMtCWLCT9FQMjVXPKzABqQx11uTXSMFJUVWkt0yh8Xo6TO59DuBDof1vaTQ74Yo Dilw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776957660; x=1777562460; 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=4mSa+7vyhBL8YFiiwNvF07aeMvbJQOJ+ZSj43s2ayiM=; b=l4Z15975Ph0LTV2YW7noYBqmniqk77pUH2lNKSUOIMA+x7Jy9aVNAKOFayRe11J53q Bn+vXyPeohEg0c342OJQ79BwIzONi0K+goA3MdS9AcVleImcT7Y3625zlrWSpQoiGW9I eX3hBIE91iLuQuGorereOPsqh/x2Si6Xw1HUlhDqSrfK4QZxqVXrt+AOIL2LtkwLKNn6 CsDz4lg/jhx40hamZ6o6aviXuI4jSr92diZr9GqMYpz/4PORCDDV+wdQztdXNC96jYI1 435OcYZ3AcgeO/zxEahrNNoYebuEp4/KO5vGPBhsQ4fHG9EhqFlZYeyJJ3/zebDcF7jE DoIg== X-Gm-Message-State: AOJu0Ywamcn2BVci+5cQtlEIZAMFpYns7vps4CncKbjq3oONTzY8FEtg OxxCN8NA008vqgxkUy7Cd03CIpFPt6V5eXYUtQGA1zlwjZcbmhWoC8OqHyrKjuTdqE5MpNhgd5Z 8NihIVVu2DLmW7xiwtvBpgUvgDqp2ulMIY5zMuh4COBgX5IMc/JNEkOInHW+LA/aDeQMo88lQHz C3bZYc6B0BkIPBbgmFCvM6J69atiAYaMKYeQ== X-Received: from wmbz21.prod.google.com ([2002:a05:600c:c095:b0:488:7ca9:439c]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4e4f:b0:488:d6eb:e63c with SMTP id 5b1f17b1804b1-488fb778703mr395298005e9.15.1776957660235; Thu, 23 Apr 2026 08:21:00 -0700 (PDT) Date: Thu, 23 Apr 2026 17:20:26 +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=2088; i=ardb@kernel.org; h=from:subject; bh=F9s4TuifOtslvPyT1K7byiUAjZGW0HaWaUoXOgAp+vY=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIfOVxa66dP0X1VxWvcv/LdjrtKPXNtzmx9yivcdiMha6v r5oeeN+RykLgxgXg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZiIxUmG/+FsKz61C5z6yzNz a4n302Va4hGaO1zc4l97crffv7WCsY+Roc3wV1dBuHr3ZPtO03e1B04ya70zyjOtkZA4e3KG+Sk jfgA= X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423152024.1098465-20-ardb+git@google.com> Subject: [PATCH v3 01/17] x86/efi: Omit redundant kernel image overlap check 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 The physical region covering the kernel's executable image is memblock_reserve()'d in early_mem_reserve(), and so it is guaranteed not to intersect with the regions passed to can_free_region(). So remove the pointless overlap check. Signed-off-by: Ard Biesheuvel --- arch/x86/platform/efi/quirks.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index df24ffc6105d..4d8de7c6ce59 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -305,16 +305,11 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size) * can free regions in efi_free_boot_services(). * * Use this function to ensure we do not free regions owned by somebody - * else. We must only reserve (and then free) regions: - * - * - Not within any part of the kernel - * - Not the BIOS reserved area (E820_TYPE_RESERVED, E820_TYPE_NVS, etc) + * else. We must only reserve (and then free) regions that do not intersect + * with the BIOS reserved area (E820_TYPE_RESERVED, E820_TYPE_NVS, etc) */ static __init bool can_free_region(u64 start, u64 size) { - if (start + size > __pa_symbol(_text) && start <= __pa_symbol(_end)) - return false; - if (!e820__mapped_all(start, start+size, E820_TYPE_RAM)) return false; @@ -343,10 +338,8 @@ void __init efi_reserve_boot_services(void) * Because the following memblock_reserve() is paired * with free_reserved_area() for this region in * efi_free_boot_services(), we must be extremely - * careful not to reserve, and subsequently free, - * critical regions of memory (like the kernel image) or - * those regions that somebody else has already - * reserved. + * careful not to reserve, and subsequently free, critical + * regions of memory that somebody else has already reserved. * * A good example of a critical region that must not be * freed is page zero (first 4Kb of memory), which may -- 2.54.0.rc2.544.gc7ae2d5bb8-goog