Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1001971rdb; Fri, 2 Feb 2024 10:13:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsdWxsJE0adsUZlottR0RK+KGUVZUMUqT/Iidc5zCM5xUI9I9t1rlLwJu00ASDdB9WjlsL X-Received: by 2002:a05:6358:f08c:b0:178:6a93:ca84 with SMTP id ig12-20020a056358f08c00b001786a93ca84mr8250278rwb.24.1706897631197; Fri, 02 Feb 2024 10:13:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706897631; cv=pass; d=google.com; s=arc-20160816; b=PMGn1JxkSjAxvfO0Qo1ptd3293OkQxxI9HsUHDJ/JcGhpYmwISgBTcSkMJJJ4WroR+ IG7beK/nnMlOCd8QvsuxZRnFW4S4zfHJGXDuS0YoLwtwMQvvh4Hwh76qfywiAVMkiN+K UDMOOi1iUOLpaxE6cInhuQ2S8hk/RQIEpFhFeVGF0uMCGQSGVa8wwGbm6o+kdKFmHN5t BSO/lOpS3Q3JOKm6MhEWEHLUxkrHfnr4EE7troySVa7rMjjjIWgGe5cJSH+JywcfcNx4 FFdk9GgN/N2RoIr8Jk3qdiASH64pV0MZ66iJxfy4Dc792N65qh508dut43VjejCHXOex DhBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=cWtC7jO98lUeRBHL4RQhZAFvZjsqfE/uVt4nvdNHZP4=; fh=BJxKAAUnW+/kWU4jx4KnACcKLcPnlzo88PBvqoXl+u8=; b=arB6kcTek12GGY23accOv5eCBYR0csh1d6k1LvOgIgbimzd7bMUPaCaTaJPfHEtsOF ibVFLQaQ6l2ISySEpU5HpykKpvlifkPKk9LjZyrVW30P2ruUcpn00XsjaNI64Uac+IGO gTH46R7JfXe2VltIeFId7bZ1jH2Rzxtu5/mBF//GRt9D5uuKzbR/ccGSUOUpJEclIEWo 7zTKqRUaDn8od5gVB1UwyrXPZjZhLoktN+h4NFV6rIZyrvpytjbBCRlHrUZqvZoE096w 7sB90VdHNdNCSzju+T0HZgYsF9/yUcfvnVapATD7LV22y0gZLez7F5jBn/oDW9CBfHKN 5t8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=0BmDXPVC; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-50252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50252-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUVKXjfx/rKoaY/vQ0Yh6ds17AthBLmwMzQ+bKPwFKaUE+NRXIxIZgEBvaW/plbDPWhuvV5KrbV0hbmz/STOycEHo6YVtVyZUJUDfKY1g== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a70-20020a639049000000b005d8e320feb5si1917439pge.28.2024.02.02.10.13.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 10:13:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=0BmDXPVC; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-50252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50252-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 19B22B24562 for ; Fri, 2 Feb 2024 17:42:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2DA0814AD16; Fri, 2 Feb 2024 17:41:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="0BmDXPVC" Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 EAF8F14A4E9 for ; Fri, 2 Feb 2024 17:41:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706895681; cv=none; b=PfOq+0vWgdoHF8OqLC3aqKgdNAitkvgXofIp0jmg3taHroonqJW1vz2FtWu8xYRCCKgcOlReI7lhclmVQK19YKIC7Sg2I43s98/yyNgYpeVGCX1j7ybi+BNkxWnPOqiWgFjx8NdPgpHF9UxTsTwwzN3u5s2NTaNjA2RII7mLfJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706895681; c=relaxed/simple; bh=bZlfqok9qew6k9fz+Z27UK6LPlwWG6tsG4PeKP4rbXs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=B1UIchmFsDhMqe2tRQWLWab0cukO8zhCmNGVbBFlvEMvwi1F6zUYeG2Xp+6qgxCGNtX1tb7t+C3ABNq443SxGTMFdaLpvbzMEVgDp+QQxpFHHBq2n5peWx1QP0CmGBRk0YtyUPo2jz15V/2YBxW1w86dqq7pbZi7HJgT/c+k6pY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=0BmDXPVC; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a2d7e2e7fe0so206042866b.1 for ; Fri, 02 Feb 2024 09:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706895676; x=1707500476; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cWtC7jO98lUeRBHL4RQhZAFvZjsqfE/uVt4nvdNHZP4=; b=0BmDXPVCkF4bYZYVpY2IE1feYwif9ZVfDxf4Ai5kQ2+xDCQfVyIqRnNpIiqtzx7Wop 0/U+LW+t26DHFW/DdtukGLDFEuOQe3VEVp7AcJgo7w/vWqiok1OzprsQLDHBvXMl6P6j Y9xN2wj/q8cqsaotpugzLZ4NO9t77zu9lB9QXPQuUfw3fImZKPXzKO7jPOMyzPBr+imv F7Ymf956Ev3UfbjFNbCZWj1fvmwUiwDKPGlcwtNwJAo6q2XE2PAV+5koXBcTx+0fhdTZ NUzoW42EtSGesG9Kelhb0NZmuDibQODc/sqbaQOE6U7xtVmpsCcxvjsbI6NuW10Qm8/d Jopg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706895676; x=1707500476; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cWtC7jO98lUeRBHL4RQhZAFvZjsqfE/uVt4nvdNHZP4=; b=RmvYWWw+1QQTNcgjNUNPIperrWOeuK+nyIk6zgZCLBVd07JSwFVGYGG0QjfWOhLBpB zvo2UAXl9ovQ2a1b6DYSYvxiLF0QMMcAGKiB2DqPuxZHPrQyk635zykzvtctKVIpFtOd smL6vP72uvyeTaY7bAvjxFCz7czG91FVi9Aj6p5gyX9z+VLB7mqNWLo1zoTu5HZCUGzV rFW44E8SpRI9Njqk5g+QC8mA2B4W91j85wnOPbpqGWC7AoBJxTLJDaAlCIbE8X2MTuX0 PVItF2RfczqqgTpiMhm3s1xbgM2Ng/zy8yrEf7MxzOVq9Wmy3hoNnn3Vr4IeGnlWxQXJ hRjQ== X-Gm-Message-State: AOJu0YwhgB70R2nWHGYiXlJV/+xgzPfQdKVGCLCMXxbn6Hu5i9yxYRBs YOVvu7s8AVmHKfKQq3ueOoDc7TNmkYBgkfbMUmYcIuQnvuJuFWdVStYT/fzWhwfJr22KpbDQocO o3vpQcprwz76QGTH/ftYSDHnwomBatBRMnEKQgQ== X-Received: by 2002:a17:907:971a:b0:a37:1778:7d7f with SMTP id jg26-20020a170907971a00b00a3717787d7fmr1914343ejc.29.1706895675962; Fri, 02 Feb 2024 09:41:15 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240202163433.786581-1-abrestic@rivosinc.com> <20240202163433.786581-3-abrestic@rivosinc.com> In-Reply-To: From: Andrew Bresticker Date: Fri, 2 Feb 2024 12:41:04 -0500 Message-ID: Subject: Re: [PATCH 2/2] efi: Don't add memblocks for unusable memory To: Ard Biesheuvel Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 2, 2024 at 11:45=E2=80=AFAM Ard Biesheuvel wr= ote: > > On Fri, 2 Feb 2024 at 17:34, Andrew Bresticker wr= ote: > > > > Adding memblocks (even if nomap) for such regions unnecessarily consume= s > > resources by creating struct pages for memory that may never be used or= , > > in the case of soft-reserved regions, prevents the memory from later > > being hotplugged in by dax_kmem. This is also consistent with how x86 > > handles unusable memory found in the EFI memory map. > > > > x86 doesn't care as much about memory vs device semantics as ARM does. > > This affects the output of memblock_is_[region_]memory(), so we'd have > to double check that none of those uses get broken by this. > > If the soft reserved regions need to be omitted from memblock, we can > deal with that separately perhaps, but changing it at this level seems > inappropriate to me. Sure, I can constrain this to just the soft-reserved regions. -Andrew > > > > Signed-off-by: Andrew Bresticker > > --- > > drivers/firmware/efi/efi-init.c | 12 +----------- > > 1 file changed, 1 insertion(+), 11 deletions(-) > > > > diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi= -init.c > > index d4987d013080..f05bacac89b7 100644 > > --- a/drivers/firmware/efi/efi-init.c > > +++ b/drivers/firmware/efi/efi-init.c > > @@ -24,13 +24,6 @@ > > > > unsigned long __initdata screen_info_table =3D EFI_INVALID_TABLE_ADDR; > > > > -static int __init is_memory(efi_memory_desc_t *md) > > -{ > > - if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC)= ) > > - return 1; > > - return 0; > > -} > > - > > /* > > * Translate a EFI virtual address into a physical address: this is ne= cessary, > > * as some data members of the EFI system table are virtually remapped= after > > @@ -195,12 +188,9 @@ static __init void reserve_regions(void) > > memrange_efi_to_native(&paddr, &npages); > > size =3D npages << PAGE_SHIFT; > > > > - if (is_memory(md)) { > > + if (is_usable_memory(md)) { > > early_init_dt_add_memory_arch(paddr, size); > > > > - if (!is_usable_memory(md)) > > - memblock_mark_nomap(paddr, size); > > - > > /* keep ACPI reclaim memory intact for kexec et= c. */ > > if (md->type =3D=3D EFI_ACPI_RECLAIM_MEMORY) > > memblock_reserve(paddr, size); > > -- > > 2.34.1 > >