Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp363205pxv; Wed, 14 Jul 2021 05:55:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5nK4fHH2YeTVx3NZjX69gL/cBpGq+Nj6V7JxfvX9MHYlFI/yVunmWK8CMao+CjDMzhJH7 X-Received: by 2002:a05:6402:64e:: with SMTP id u14mr13463458edx.122.1626267312450; Wed, 14 Jul 2021 05:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626267312; cv=none; d=google.com; s=arc-20160816; b=eR5xaHBXPWQ+p5Ucav1aU4tjYposyPAEWjUPJe38d3CjKA6nDf+v8BYSof7CF4UywE c2gzRnoecoB8bkG1lXxZaeo7aJXsdP9SzEB9yEN7hPyBLBTu/syeQJEDDS/Dd2F4GOJm WMlCUUhVxFy56A5qumLDnUGsPobR2PMEY4BBwOJWf+nTM9RYNI6Nk1Nzcfdwrx3tsUSj zCBMauQ+gatp29sbSNYzn8bksxR3wi12X1TSyGMpwoE1md1RvP4mHL97zoUFU5ItHyZu f3DNjxJys43YxAUR5QIXEMiKCPvaQ9SCQHFE2WHNontmx8QXT78e5iZLUeSOammbv7fH y2qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HZzub4bLqt+xciTADssazs5cYmHlEMtTJEt3uTS+UpE=; b=fzyX4gxYOLW23nHIbUUYBtRvuC5Te28r1XDJnuBMFHGnlLkAipKmK0nEezq0cAq1yB lPzyNAJtVZiJSStNMgWCGsdx2qwbNt4DfeX+6pMyKACFbLbXMev4oHZWoRezMRhxDYvO 3oOsPtIY8he6ZKrbtopWaECm3q31v2LFtuvA/GhEXGiyqmabuYto44i5JUSQ5RitSzuI t/Zm6uKZA3oXdG/yrmFRBTgC0LEbDCxsCqev5+00JeXdHBoCvyQ8UeVhqzJKFG+qn1kq ByG0iPSrrRfWP6SVJfw9C5ryZEbPPM6zSApXpv2BXdGg9TAbhl6AEhGxIoDFQNGqhaOz U3Pg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si2304174edv.384.2021.07.14.05.54.49; Wed, 14 Jul 2021 05:55:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239466AbhGNMxw (ORCPT + 99 others); Wed, 14 Jul 2021 08:53:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239396AbhGNMxl (ORCPT ); Wed, 14 Jul 2021 08:53:41 -0400 Received: from andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FC4BC0613DF for ; Wed, 14 Jul 2021 05:50:49 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed10:39cc:190a:2775:cfe7]) by andre.telenet-ops.be with bizsmtp id V0qW2500F1ccfby010qWp0; Wed, 14 Jul 2021 14:50:47 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1m3eLO-0018dN-8G; Wed, 14 Jul 2021 14:50:30 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1m3eLN-00AaDx-Nr; Wed, 14 Jul 2021 14:50:29 +0200 From: Geert Uytterhoeven To: Rob Herring , Russell King , Nicolas Pitre , Ard Biesheuvel , Linus Walleij , Catalin Marinas , Will Deacon , Nick Kossifidis , Paul Walmsley , Palmer Dabbelt , Albert Ou , Frank Rowand , Dave Young , Mike Rapoport Cc: Baoquan He , Vivek Goyal , Andrew Morton , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kexec@lists.infradead.org, linux-mm@kvack.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v4 02/10] memblock: Add variables for usable memory limitation Date: Wed, 14 Jul 2021 14:50:12 +0200 Message-Id: <04c4d231fb03a3810d72a45c8a5bc2272c5975f3.1626266516.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add two global variables (cap_mem_addr and cap_mem_size) for storing a base address and size, describing a limited region in which memory may be considered available for use by the kernel. If enabled, memory outside of this range is not available for use. These variables can by filled by firmware-specific code, and used in calls to memblock_cap_memory_range() by architecture-specific code. An example user is the parser of the "linux,usable-memory-range" property in the DT "/chosen" node. Signed-off-by: Geert Uytterhoeven --- This is similar to how the initial ramdisk (phys_initrd_{start,size}) and ELF core headers (elfcorehdr_{addr,size})) are handled. Does there exist a suitable place in the common memblock code to call "memblock_cap_memory_range(cap_mem_addr, cap_mem_size)", or does this have to be done in architecture-specific code? v4: - New. --- include/linux/memblock.h | 6 ++++++ mm/memblock.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index cbf46f56d1053b68..07e2474c4c3901e9 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -25,6 +25,12 @@ extern unsigned long max_pfn; */ extern unsigned long long max_possible_pfn; +/* + * limited region in which memory may be considered usable by the kernel + */ +extern phys_addr_t cap_mem_addr; +extern phys_addr_t cap_mem_size; + /** * enum memblock_flags - definition of memory region attributes * @MEMBLOCK_NONE: no special request diff --git a/mm/memblock.c b/mm/memblock.c index 0041ff62c584e7e1..66659f2b10ed40ff 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -101,6 +101,8 @@ unsigned long max_low_pfn; unsigned long min_low_pfn; unsigned long max_pfn; unsigned long long max_possible_pfn; +phys_addr_t cap_mem_addr; +phys_addr_t cap_mem_size; static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_RESERVED_REGIONS] __initdata_memblock; -- 2.25.1