[RFC 6/7] TEST: Reserve system memory to be emulated as device memory

Anshuman Khandual khandual at linux.vnet.ibm.com
Tue May 3 16:29:25 AEST 2016


While booting, cap system memory at SYSRAM_END and start recording
the memory from DEVRAM_START as reserved memory.

Signed-off-by: Anshuman Khandual <khandual at linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/prom.h | 15 +++++++++++++++
 arch/powerpc/kernel/prom.c      | 11 +++++++++++
 2 files changed, 26 insertions(+)

diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 7f436ba..a4ec240e4 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -165,5 +165,20 @@ struct of_drconf_cell {
  */
 extern unsigned char ibm_architecture_vec[];
 
+#define SYSRAM_END	0x400000000
+#define DEVRAM_START	0xb00000000
+#define NR_RESERVE	500
+
+enum resmem_elements {
+	MEM_BASE = 0,
+	MEM_SIZE = 1,
+	MEM_NODE = 2,
+	MEM_MAX = 3
+};
+
+struct resmem {
+	u64     mem[NR_RESERVE][MEM_MAX];
+	u64     nr;
+};
 #endif /* __KERNEL__ */
 #endif /* _POWERPC_PROM_H */
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index a15fe1d..9b3bf2e 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -438,6 +438,8 @@ static int __init early_init_dt_scan_chosen_ppc(unsigned long node,
 }
 
 #ifdef CONFIG_PPC_PSERIES
+struct resmem rmem;
+EXPORT_SYMBOL(rmem);
 /*
  * Interpret the ibm,dynamic-memory property in the
  * /ibm,dynamic-reconfiguration-memory node.
@@ -471,6 +473,7 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 	if (usm != NULL)
 		is_kexec_kdump = 1;
 
+	memset(&rmem, 0, sizeof(struct resmem));
 	for (; n != 0; --n) {
 		base = dt_mem_next_cell(dt_root_addr_cells, &dm);
 		flags = of_read_number(&dm[3], 1);
@@ -508,6 +511,14 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 				if ((base + size) > 0x80000000ul)
 					size = 0x80000000ul - base;
 			}
+			if (base > DEVRAM_START) {
+				rmem.mem[rmem.nr][MEM_BASE] = base;
+				rmem.mem[rmem.nr][MEM_SIZE] = size;
+				rmem.nr++;
+				continue;
+			}
+			if (base > SYSRAM_END)
+				continue;
 			memblock_add(base, size);
 		} while (--rngs);
 	}
-- 
1.8.3.1



More information about the Linuxppc-dev mailing list