lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 19 Oct 2023 11:48:25 -0700
From:   Oreoluwa Babatunde <quic_obabatun@...cinc.com>
To:     <catalin.marinas@....com>, <will@...nel.org>, <robh+dt@...nel.org>,
        <frowand.list@...il.com>
CC:     <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
        <linux-arm-msm@...r.kernel.org>, <kernel@...cinc.com>,
        Oreoluwa Babatunde <quic_obabatun@...cinc.com>
Subject: [RFC PATCH 3/3] of: reserved_mem: Make MAX_RESERVED_REGIONS a config option

Add code to make the size of reserved_mem_array a config option which
can be modified based on user requirements.
The reserved_mem_array is required during device bootup to store the
information of the reserved memory regions that need to be dynamically
allocated. After some time, this information is transferred to another
array which is used to store all reserved memory regions, after which
the reserved_mem_array will no longer be needed.

Since the size required for the reserved_mem_array can vary and there
is currently no way to free the memory afterwards, make the size of the
array configurable in an attempt to save some memory.

Signed-off-by: Oreoluwa Babatunde <quic_obabatun@...cinc.com>
---
 drivers/of/Kconfig           | 13 +++++++++++++
 drivers/of/of_reserved_mem.c |  9 ++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index da9826accb1b..3cb2ec4993b5 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -102,4 +102,17 @@ config OF_OVERLAY
 config OF_NUMA
 	bool
 
+config OF_MAX_RESERVED_REGIONS
+	int "OF resvered_mem array size"
+	default "64"
+	range 1 64
+	help
+	  The reserved_mem_array is used to store information about the dynamically
+	  placed reserved memory regions before we are able to allocate the memory
+	  needed to store all the reserved memory regions defined in the DT.
+	  Because the amount of memory needed initially for this array could vary,
+	  make the size of the reserved_mem_array configurable in an attempt to
+	  save some memory when possible.
+	  if unsure, leave as default value.
+
 endif # OF
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 203828ca118e..f408dce762e1 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -26,11 +26,10 @@
 
 #include "of_private.h"
 
-#define MAX_RESERVED_REGIONS	64
-static struct reserved_mem reserved_mem_array[MAX_RESERVED_REGIONS];
-static struct reserved_mem *reserved_mem __refdata = reserved_mem_array;
+static struct reserved_mem reserved_mem_array[CONFIG_OF_MAX_RESERVED_REGIONS];
+static struct reserved_mem *reserved_mem = reserved_mem_array;
 
-static int total_reserved_mem_cnt = MAX_RESERVED_REGIONS;
+static int total_reserved_mem_cnt = CONFIG_OF_MAX_RESERVED_REGIONS;
 static int reserved_mem_count;
 
 static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
@@ -93,7 +92,7 @@ static int alloc_reserved_mem_array(void)
 
 overlow_err:
 	memblock_free(new_array, alloc_size);
-	total_reserved_mem_cnt = MAX_RESERVED_REGIONS;
+	total_reserved_mem_cnt = CONFIG_OF_MAX_RESERVED_REGIONS;
 	return -1;
 }
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ