aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasant Hegde <hegdevasant@linux.vnet.ibm.com>2020-02-10 21:46:35 +0530
committerVasant Hegde <hegdevasant@linux.vnet.ibm.com>2020-03-10 14:17:46 +0530
commitd0e472a76f1ad5f8ce0f1b7929db1eea55041609 (patch)
treec95d6f0459f3b59dfe2cf08d6ef73f6033fdf9ad
parent42d9d2ba5bddec06d5bb2e24909269610e62e661 (diff)
downloadskiboot-d0e472a76f1ad5f8ce0f1b7929db1eea55041609.zip
skiboot-d0e472a76f1ad5f8ce0f1b7929db1eea55041609.tar.gz
skiboot-d0e472a76f1ad5f8ce0f1b7929db1eea55041609.tar.bz2
mpipl: Rework memory reservation for OPAL dump
[ Upstream commit b0e024216a3b1d35aa2273b6f64742db7ae49861 ] During boot, OPAL reserves memory required to capture OPAL dump and architected register data. During MPIPL, hostboot will copy OPAL dump to this memory. Post MPIPL kernel will use this memory to create opalcore. We use mem_reserve_fw() for this reservation. At present this reservation happens late in the init path. It may clash with memory allocated by local_alloc(). We have two option to fix above issue: - Use local_alloc() for allocating memory for OPAL dump This works fine on first boot. We can use this method to reserve memory. But Post MPIPL we still want to reserve destination memory to make sure no one is stomping this area. Also this reservation might have happened in between other local_allocations. So in Post MPIPL boot allocator may not find enough memory in first region for other local_alloc() requests and may throw mem_alloc() error before trying to allocate from other regions. - Early memory reservation for OPAL dump Allocate and reserve memory just after memory region init. This patch uses second approach to fix reservation issue. Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
-rw-r--r--core/init.c7
-rw-r--r--core/opal-dump.c53
-rw-r--r--include/opal-dump.h3
3 files changed, 40 insertions, 23 deletions
diff --git a/core/init.c b/core/init.c
index e9509e7..4b86a94 100644
--- a/core/init.c
+++ b/core/init.c
@@ -1062,6 +1062,13 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt)
*/
mem_region_init();
+ /*
+ * Reserve memory required to capture OPAL dump. This should be done
+ * immediately after mem_region_init to avoid any clash with local
+ * memory allocation.
+ */
+ opal_mpipl_reserve_mem();
+
/* Reserve HOMER and OCC area */
homer_init();
diff --git a/core/opal-dump.c b/core/opal-dump.c
index dc3bd62..770dca7 100644
--- a/core/opal-dump.c
+++ b/core/opal-dump.c
@@ -65,6 +65,7 @@ static struct opal_mpipl_fadump *opal_mpipl_cpu_data;
static u64 opal_mpipl_tags[MAX_OPAL_MPIPL_TAGS];
static int opal_mpipl_max_tags = MAX_OPAL_MPIPL_TAGS;
+static u64 opal_dump_addr, opal_dump_size;
static int opal_mpipl_add_entry(u8 region, u64 src, u64 dest, u64 size)
{
@@ -222,28 +223,12 @@ static int opal_mpipl_remove_entry_mddt(bool remove_all, u8 region, u64 dest)
/* Register for OPAL dump. */
static void opal_mpipl_register(void)
{
- u64 opal_dest, opal_size;
u64 arch_regs_dest, arch_regs_size;
struct proc_dump_area *proc_dump = (void *)(PROC_DUMP_AREA_BASE);
- /* Get OPAL runtime size */
- if (!dt_find_property(opal_node, "opal-runtime-size")) {
- prlog(PR_DEBUG, "Could not get OPAL runtime size\n");
- return;
- }
- opal_size = dt_prop_get_u64(opal_node, "opal-runtime-size");
- if (!opal_size) {
- prlog(PR_DEBUG, "OPAL runtime size is zero\n");
- return;
- }
-
- /* Calculate and reserve OPAL dump destination memory */
- opal_dest = SKIBOOT_BASE + opal_size;
- mem_reserve_fw("ibm,firmware-dump", opal_dest, opal_size);
-
/* Add OPAL reservation detail to MDST/MDDT table */
opal_mpipl_add_entry(DUMP_REGION_OPAL_MEMORY,
- SKIBOOT_BASE, opal_dest, opal_size);
+ SKIBOOT_BASE, opal_dump_addr, opal_dump_size);
/* Thread size check */
if (proc_dump->thread_size != 0) {
@@ -251,13 +236,9 @@ static void opal_mpipl_register(void)
"but not supported.\n");
}
- /* Calculate memory to capture CPU register data */
- arch_regs_dest = opal_dest + opal_size;
- arch_regs_size = nr_chips() * ARCH_REGS_DATA_SIZE_PER_CHIP;
-
/* Reserve memory used to capture architected register state */
- mem_reserve_fw("ibm,firmware-arch-registers",
- arch_regs_dest, arch_regs_size);
+ arch_regs_dest = opal_dump_addr + opal_dump_size;
+ arch_regs_size = nr_chips() * ARCH_REGS_DATA_SIZE_PER_CHIP;
proc_dump->alloc_addr = arch_regs_dest | HRMOR_BIT;
proc_dump->alloc_size = arch_regs_size;
prlog(PR_NOTICE, "Architected register dest addr : 0x%llx, "
@@ -500,6 +481,32 @@ void opal_mpipl_save_crashing_pir(void)
prlog(PR_NOTICE, "Crashing PIR = 0x%x\n", this_cpu()->pir);
}
+void opal_mpipl_reserve_mem(void)
+{
+ struct dt_node *opal_node, *dump_node;
+ u64 arch_regs_dest, arch_regs_size;
+
+ opal_node = dt_find_by_path(dt_root, "ibm,opal");
+ if (!opal_node)
+ return;
+
+ dump_node = dt_find_by_path(opal_node, "dump");
+ if (!dump_node)
+ return;
+
+ /* Calculcate and Reserve OPAL dump destination memory */
+ opal_dump_size = SKIBOOT_SIZE + (cpu_max_pir + 1) * STACK_SIZE;
+ opal_dump_addr = SKIBOOT_BASE + opal_dump_size;
+ mem_reserve_fw("ibm,firmware-dump",
+ opal_dump_addr, opal_dump_size);
+
+ /* Reserve memory to capture CPU register data */
+ arch_regs_dest = opal_dump_addr + opal_dump_size;
+ arch_regs_size = nr_chips() * ARCH_REGS_DATA_SIZE_PER_CHIP;
+ mem_reserve_fw("ibm,firmware-arch-registers",
+ arch_regs_dest, arch_regs_size);
+}
+
void opal_mpipl_init(void)
{
void *mdst_base = (void *)MDST_TABLE_BASE;
diff --git a/include/opal-dump.h b/include/opal-dump.h
index 866d11a..30b60b3 100644
--- a/include/opal-dump.h
+++ b/include/opal-dump.h
@@ -124,4 +124,7 @@ extern void opal_mpipl_init(void);
/* Save metadata before triggering MPIPL */
void opal_mpipl_save_crashing_pir(void);
+/* Reserve memory to capture OPAL dump */
+extern void opal_mpipl_reserve_mem(void);
+
#endif /* __OPAL_DUMP_H */