kexec/ppc64: Fix up ELF header and dt for PowerNV platform.
Subsystems (2)
PATCH 1/1 kexec/ppc64: Fix up ELF header and dt for PowerNV platform.
From: Mahesh Salgaonkar <[email protected]>
On PowerNV platform, OPAL region is overlapped with crashkernel, need to create ELF Program header for the overlapped memory. The changes are similar to the way RTAS region was handled.
--- kexec/arch/ppc/crashdump-powerpc.h | 2 ++ kexec/arch/ppc64/crashdump-ppc64.c | 28 +++++++++++++++++++++++ kexec/arch/ppc64/crashdump-ppc64.h | 2 ++ kexec/arch/ppc64/kexec-ppc64.c | 44 +++++++++++++++++++++++++++++++++++- kexec/fs2dt.c | 4 +++ 5 files changed, 79 insertions(+), 1 deletion(-)
kexec/arch/ppc/crashdump-powerpc.h +2 -0
@@ -40,6 +40,8 @@ extern unsigned long long crash_base;extern unsigned long long crash_size;extern unsigned int rtas_base;extern unsigned int rtas_size; +extern uint64_t opal_base; +extern uint64_t opal_size;extern uint64_t memory_limit;#endif /* CRASHDUMP_POWERPC_H */
kexec/arch/ppc64/crashdump-ppc64.c +28 -0
@@ -294,6 +294,34 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) crash_memory_range[memory_ranges++].end = cend; } +/* +* If OPAL region is overlapped with crashkernel, need to create ELF +* Program header for the overlapped memory. +*/ +if (crash_base < opal_base + opal_size && + opal_base < crash_base + crash_size) { + page_size =getpagesize (); + cstart = opal_base; + cend = opal_base + opal_size; +if (cstart < crash_base) + cstart = crash_base; +if (cend > crash_base + crash_size) + cend = crash_base + crash_size; +/* +* The opal section created here is formed by reading opal-base +* and opal-size from /proc/device-tree/ibm,opal. Unfortunately +* opal-size is not required to be a multiple of PAGE_SIZE +* The remainder of the page it ends on is just garbage, and is +* safe to read, its just not accounted in opal-size. Since +* we're creating an elf section here though, lets round it up +* to the next page size boundary though, so makedumpfile can +* read it safely without going south on us. +*/ + cend =_ALIGN (cend, page_size); + + crash_memory_range[memory_ranges].start = cstart; + crash_memory_range[memory_ranges++].end = cend; + } *range = crash_memory_range; *ranges = memory_ranges;
kexec/arch/ppc64/crashdump-ppc64.h +2 -0
@@ -31,6 +31,8 @@ extern uint64_t crash_size;extern uint64_t memory_limit;extern unsigned int rtas_base;extern unsigned int rtas_size; +extern uint64_t opal_base; +extern uint64_t opal_size;uint64_t lmb_size;unsigned int num_of_lmbs;
kexec/arch/ppc64/kexec-ppc64.c +43 -1
62 lines not on this page · raw message
kexec/fs2dt.c +4 -0
@@ -113,6 +113,10 @@ static void checkprop(char *name, unsigned *data, int len)die ("unrecoverable error: no property data" ); else if (!strcmp(name, "linux,rtas-base")) base =be32_to_cpu (*data); + else if (!strcmp(name, "opal-base-address")) + base =be64_to_cpu (*(unsigned long long *)data); + else if (!strcmp(name, "opal-runtime-size")) + size =be64_to_cpu (*(unsigned long long *)data); else if (!strcmp(name, "linux,tce-base")) base =be64_to_cpu (*(unsigned long long *) data); else if (!strcmp(name, "rtas-size") ||
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 7 lines · Mahesh J Salgaonkar
From: Mahesh Salgaonkar <[email protected]>
On PowerNV platform, OPAL region is overlapped with crashkernel, need to create ELF Program header for the overlapped memory. The changes are similar to the way RTAS region was handled.
Signed-off-by Mahesh Salgaonkar <[email protected]>
I apologise that this seems to have slipped through the cracks. Manesh, is this patch still needed? If so, is it possible for someone on the power side of things to review it?
Quoted 148 lines
--- kexec/arch/ppc/crashdump-powerpc.h | 2 ++ kexec/arch/ppc64/crashdump-ppc64.c | 28 +++++++++++++++++++++++ kexec/arch/ppc64/crashdump-ppc64.h | 2 ++ kexec/arch/ppc64/kexec-ppc64.c | 44 +++++++++++++++++++++++++++++++++++- kexec/fs2dt.c | 4 +++ 5 files changed, 79 insertions(+), 1 deletion(-)kexec/arch/ppc/crashdump-powerpc.h +2
-0@@ -40,6 +40,8 @@ extern unsigned long long crash_base;extern unsigned long long crash_size;extern unsigned int rtas_base;extern unsigned int rtas_size; +extern uint64_t opal_base; +extern uint64_t opal_size;extern uint64_t memory_limit;#endif /* CRASHDUMP_POWERPC_H */ kexec/arch/ppc64/crashdump-ppc64.c +28
-0@@ -294,6 +294,34 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) crash_memory_range[memory_ranges++].end = cend; } +/* +* If OPAL region is overlapped with crashkernel, need to create ELF +* Program header for the overlapped memory. +*/ +if (crash_base < opal_base + opal_size && + opal_base < crash_base + crash_size) { + page_size =getpagesize (); + cstart = opal_base; + cend = opal_base + opal_size; +if (cstart < crash_base) + cstart = crash_base; +if (cend > crash_base + crash_size) + cend = crash_base + crash_size; +/* +* The opal section created here is formed by reading opal-base +* and opal-size from /proc/device-tree/ibm,opal. Unfortunately +* opal-size is not required to be a multiple of PAGE_SIZE +* The remainder of the page it ends on is just garbage, and is +* safe to read, its just not accounted in opal-size. Since +* we're creating an elf section here though, lets round it up +* to the next page size boundary though, so makedumpfile can +* read it safely without going south on us. +*/ + cend =_ALIGN (cend, page_size); + + crash_memory_range[memory_ranges].start = cstart; + crash_memory_range[memory_ranges++].end = cend; + } *range = crash_memory_range; *ranges = memory_ranges;kexec/arch/ppc64/crashdump-ppc64.h +2
-0@@ -31,6 +31,8 @@ extern uint64_t crash_size;extern uint64_t memory_limit;extern unsigned int rtas_base;extern unsigned int rtas_size; +extern uint64_t opal_base; +extern uint64_t opal_size;uint64_t lmb_size;unsigned int num_of_lmbs;kexec/arch/ppc64/kexec-ppc64.c +43
-1@@ -43,6 +43,7 @@ uint64_t memory_limit;static int nr_memory_ranges, nr_exclude_ranges;uint64_t crash_base, crash_size;unsigned int rtas_base, rtas_size; +uint64_t opal_base, opal_size;int max_memory_ranges;static void cleanup_memory_ranges (void )@@ -343,7 +344,8 @@ static int get_devtree_details(unsigned long kexec_flags)strncmp (dentry->d_name,"memory@" ,7 ) &&strcmp (dentry->d_name,"memory" ) &&strncmp (dentry->d_name,"pci@" ,4 ) && - strncmp(dentry->d_name, "rtas", 4)) +strncmp (dentry->d_name,"rtas" ,4 ) && + strncmp(dentry->d_name, "ibm,opal", 8)) continue;strcpy (fname, device_tree);strcat (fname, dentry->d_name);@@ -575,6 +577,46 @@ static int get_devtree_details(unsigned long kexec_flags)add_usable_mem_rgns (rtas_base, rtas_size); }/* rtas */ +if (strncmp (dentry->d_name,"ibm,opal" ,8 ) ==0 ) { +strcat (fname,"/opal-base-address" ); + file =fopen (fname,"r" ); +if (file ==NULL ) { +perror (fname); + goto error_opencdir; + } +if (fread (&opal_base,sizeof (uint64_t ),1 , file) !=1 ) { +perror (fname); + goto error_openfile; + } + opal_base =be64_to_cpu (opal_base); +fclose (file); + +memset (fname,0 ,sizeof (fname)); +strcpy (fname, device_tree); +strcat (fname, dentry->d_name); +strcat (fname,"/opal-runtime-size" ); + file =fopen (fname,"r" ); +if (file ==NULL ) { +perror (fname); + goto error_opencdir; + } +if (fread (&opal_size,sizeof (uint64_t ),1 , file) !=1 ) { +perror (fname); + goto error_openfile; + } +fclose (file); +closedir (cdir); + opal_size =be64_to_cpu (opal_size); +/* Add OPAL to exclude_range */ + exclude_range[i].start = opal_base; + exclude_range[i].end = opal_base + opal_size; + i++; +if (i >= max_memory_ranges) +realloc_memory_ranges (); +if (kexec_flags &KEXEC_ON_CRASH ) +add_usable_mem_rgns (opal_base, opal_size); + }/* ibm,opal */ +if (!strncmp (dentry->d_name,"memory@" ,7 ) || !strcmp (dentry->d_name,"memory" )) {strcat (fname,"/reg" );kexec/fs2dt.c +0
-0
kexec/fs2dt.c static void checkprop(char *name, unsigned *data, int len) · line 122
Quoted 10 lines
kexec/fs2dt.c +4
-0@@ -113,6 +113,10 @@ static void checkprop(char *name, unsigned *data, int len)die ("unrecoverable error: no property data" ); else if (!strcmp(name, "linux,rtas-base")) base =be32_to_cpu (*data); + else if (!strcmp(name, "opal-base-address")) + base =be64_to_cpu (*(unsigned long long *)data); + else if (!strcmp(name, "opal-runtime-size")) + size =be64_to_cpu (*(unsigned long long *)data); else if (!strcmp(name, "linux,tce-base")) base =be64_to_cpu (*(unsigned long long *) data); else if (!strcmp(name, "rtas-size") ||
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 11 lines · Simon Horman
Quoted 7 lines · Mahesh J Salgaonkar
From: Mahesh Salgaonkar <[email protected]>
On PowerNV platform, OPAL region is overlapped with crashkernel, need to create ELF Program header for the overlapped memory. The changes are similar to the way RTAS region was handled.
Signed-off-by Mahesh Salgaonkar <[email protected]>I apologise that this seems to have slipped through the cracks. Manesh, is this patch still needed?
Yes. We still need this patch.
If so, is it possible for
Quoted 152 lines
someone on the power side of things to review it?
Quoted 150 lines
--- kexec/arch/ppc/crashdump-powerpc.h | 2 ++ kexec/arch/ppc64/crashdump-ppc64.c | 28 +++++++++++++++++++++++ kexec/arch/ppc64/crashdump-ppc64.h | 2 ++ kexec/arch/ppc64/kexec-ppc64.c | 44 +++++++++++++++++++++++++++++++++++- kexec/fs2dt.c | 4 +++ 5 files changed, 79 insertions(+), 1 deletion(-)kexec/arch/ppc/crashdump-powerpc.h +2
-0@@ -40,6 +40,8 @@ extern unsigned long long crash_base;extern unsigned long long crash_size;extern unsigned int rtas_base;extern unsigned int rtas_size; +extern uint64_t opal_base; +extern uint64_t opal_size;extern uint64_t memory_limit;#endif /* CRASHDUMP_POWERPC_H */ kexec/arch/ppc64/crashdump-ppc64.c +28
-0@@ -294,6 +294,34 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) crash_memory_range[memory_ranges++].end = cend; } +/* +* If OPAL region is overlapped with crashkernel, need to create ELF +* Program header for the overlapped memory. +*/ +if (crash_base < opal_base + opal_size && + opal_base < crash_base + crash_size) { + page_size =getpagesize (); + cstart = opal_base; + cend = opal_base + opal_size; +if (cstart < crash_base) + cstart = crash_base; +if (cend > crash_base + crash_size) + cend = crash_base + crash_size; +/* +* The opal section created here is formed by reading opal-base +* and opal-size from /proc/device-tree/ibm,opal. Unfortunately +* opal-size is not required to be a multiple of PAGE_SIZE +* The remainder of the page it ends on is just garbage, and is +* safe to read, its just not accounted in opal-size. Since +* we're creating an elf section here though, lets round it up +* to the next page size boundary though, so makedumpfile can +* read it safely without going south on us. +*/ + cend =_ALIGN (cend, page_size); + + crash_memory_range[memory_ranges].start = cstart; + crash_memory_range[memory_ranges++].end = cend; + } *range = crash_memory_range; *ranges = memory_ranges;kexec/arch/ppc64/crashdump-ppc64.h +2
-0@@ -31,6 +31,8 @@ extern uint64_t crash_size;extern uint64_t memory_limit;extern unsigned int rtas_base;extern unsigned int rtas_size; +extern uint64_t opal_base; +extern uint64_t opal_size;uint64_t lmb_size;unsigned int num_of_lmbs;kexec/arch/ppc64/kexec-ppc64.c +43
-1@@ -43,6 +43,7 @@ uint64_t memory_limit;static int nr_memory_ranges, nr_exclude_ranges;uint64_t crash_base, crash_size;unsigned int rtas_base, rtas_size; +uint64_t opal_base, opal_size;int max_memory_ranges;static void cleanup_memory_ranges (void )@@ -343,7 +344,8 @@ static int get_devtree_details(unsigned long kexec_flags)strncmp (dentry->d_name,"memory@" ,7 ) &&strcmp (dentry->d_name,"memory" ) &&strncmp (dentry->d_name,"pci@" ,4 ) && - strncmp(dentry->d_name, "rtas", 4)) +strncmp (dentry->d_name,"rtas" ,4 ) && + strncmp(dentry->d_name, "ibm,opal", 8)) continue;strcpy (fname, device_tree);strcat (fname, dentry->d_name);@@ -575,6 +577,46 @@ static int get_devtree_details(unsigned long kexec_flags)add_usable_mem_rgns (rtas_base, rtas_size); }/* rtas */ +if (strncmp (dentry->d_name,"ibm,opal" ,8 ) ==0 ) { +strcat (fname,"/opal-base-address" ); + file =fopen (fname,"r" ); +if (file ==NULL ) { +perror (fname); + goto error_opencdir; + } +if (fread (&opal_base,sizeof (uint64_t ),1 , file) !=1 ) { +perror (fname); + goto error_openfile; + } + opal_base =be64_to_cpu (opal_base); +fclose (file); + +memset (fname,0 ,sizeof (fname)); +strcpy (fname, device_tree); +strcat (fname, dentry->d_name); +strcat (fname,"/opal-runtime-size" ); + file =fopen (fname,"r" ); +if (file ==NULL ) { +perror (fname); + goto error_opencdir; + } +if (fread (&opal_size,sizeof (uint64_t ),1 , file) !=1 ) { +perror (fname); + goto error_openfile; + } +fclose (file); +closedir (cdir); + opal_size =be64_to_cpu (opal_size); +/* Add OPAL to exclude_range */ + exclude_range[i].start = opal_base; + exclude_range[i].end = opal_base + opal_size; + i++; +if (i >= max_memory_ranges) +realloc_memory_ranges (); +if (kexec_flags &KEXEC_ON_CRASH ) +add_usable_mem_rgns (opal_base, opal_size); + }/* ibm,opal */ +if (!strncmp (dentry->d_name,"memory@" ,7 ) || !strcmp (dentry->d_name,"memory" )) {strcat (fname,"/reg" );kexec/fs2dt.c +0
-0@@ -113,6 +113,10 @@ static void checkprop(char *name, unsigned *data, int len)die ("unrecoverable error: no property data" ); else if (!strcmp(name, "linux,rtas-base")) base =be32_to_cpu (*data);
Quoted 9 lines
kexec/fs2dt.c static void checkprop(char *name, unsigned *data, int len) · line 122
Quoted 8 lines
kexec/fs2dt.c +4
-0+else if (!strcmp (name,"opal-base-address" )) + base =be64_to_cpu (*(unsigned long long *)data); +else if (!strcmp (name,"opal-runtime-size" )) + size =be64_to_cpu (*(unsigned long long *)data);else if (!strcmp (name,"linux,tce-base" )) base =be64_to_cpu (*(unsigned long long *) data); else if (!strcmp(name, "rtas-size") ||
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedQuoted 8 lines · Mahesh Jagannath Salgaonkar
Quoted 7 lines · Simon Horman
Quoted 6 lines · Mahesh J Salgaonkar
From: Mahesh Salgaonkar <[email protected]>
On PowerNV platform, OPAL region is overlapped with crashkernel, need to create ELF Program header for the overlapped memory. The changes are similar to the way RTAS region was handled.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Mahesh Salgaonkar <[email protected]>I apologise that this seems to have slipped through the cracks. Manesh, is this patch still needed?
Yes. We still need this patch.
Thanks, applied.
Sorry once again for the delay.
Quoted 164 lines
If so, is it possible for
Quoted 161 lines
someone on the power side of things to review it?
Quoted 158 lines
--- kexec/arch/ppc/crashdump-powerpc.h | 2 ++ kexec/arch/ppc64/crashdump-ppc64.c | 28 +++++++++++++++++++++++ kexec/arch/ppc64/crashdump-ppc64.h | 2 ++ kexec/arch/ppc64/kexec-ppc64.c | 44 +++++++++++++++++++++++++++++++++++- kexec/fs2dt.c | 4 +++ 5 files changed, 79 insertions(+), 1 deletion(-)kexec/arch/ppc/crashdump-powerpc.h +2
-0@@ -40,6 +40,8 @@ extern unsigned long long crash_base;extern unsigned long long crash_size;extern unsigned int rtas_base;extern unsigned int rtas_size; +extern uint64_t opal_base; +extern uint64_t opal_size;extern uint64_t memory_limit;#endif /* CRASHDUMP_POWERPC_H */ kexec/arch/ppc64/crashdump-ppc64.c +28
-0@@ -294,6 +294,34 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) crash_memory_range[memory_ranges++].end = cend; } +/* +* If OPAL region is overlapped with crashkernel, need to create ELF +* Program header for the overlapped memory. +*/ +if (crash_base < opal_base + opal_size && + opal_base < crash_base + crash_size) { + page_size =getpagesize (); + cstart = opal_base; + cend = opal_base + opal_size; +if (cstart < crash_base) + cstart = crash_base; +if (cend > crash_base + crash_size) + cend = crash_base + crash_size; +/* +* The opal section created here is formed by reading opal-base +* and opal-size from /proc/device-tree/ibm,opal. Unfortunately +* opal-size is not required to be a multiple of PAGE_SIZE +* The remainder of the page it ends on is just garbage, and is +* safe to read, its just not accounted in opal-size. Since +* we're creating an elf section here though, lets round it up +* to the next page size boundary though, so makedumpfile can +* read it safely without going south on us. +*/ + cend =_ALIGN (cend, page_size); + + crash_memory_range[memory_ranges].start = cstart; + crash_memory_range[memory_ranges++].end = cend; + } *range = crash_memory_range; *ranges = memory_ranges;kexec/arch/ppc64/crashdump-ppc64.h +2
-0@@ -31,6 +31,8 @@ extern uint64_t crash_size;extern uint64_t memory_limit;extern unsigned int rtas_base;extern unsigned int rtas_size; +extern uint64_t opal_base; +extern uint64_t opal_size;uint64_t lmb_size;unsigned int num_of_lmbs;kexec/arch/ppc64/kexec-ppc64.c +43
-1@@ -43,6 +43,7 @@ uint64_t memory_limit;static int nr_memory_ranges, nr_exclude_ranges;uint64_t crash_base, crash_size;unsigned int rtas_base, rtas_size; +uint64_t opal_base, opal_size;int max_memory_ranges;static void cleanup_memory_ranges (void )@@ -343,7 +344,8 @@ static int get_devtree_details(unsigned long kexec_flags)strncmp (dentry->d_name,"memory@" ,7 ) &&strcmp (dentry->d_name,"memory" ) &&strncmp (dentry->d_name,"pci@" ,4 ) && - strncmp(dentry->d_name, "rtas", 4)) +strncmp (dentry->d_name,"rtas" ,4 ) && + strncmp(dentry->d_name, "ibm,opal", 8)) continue;strcpy (fname, device_tree);strcat (fname, dentry->d_name);@@ -575,6 +577,46 @@ static int get_devtree_details(unsigned long kexec_flags)add_usable_mem_rgns (rtas_base, rtas_size); }/* rtas */ +if (strncmp (dentry->d_name,"ibm,opal" ,8 ) ==0 ) { +strcat (fname,"/opal-base-address" ); + file =fopen (fname,"r" ); +if (file ==NULL ) { +perror (fname); + goto error_opencdir; + } +if (fread (&opal_base,sizeof (uint64_t ),1 , file) !=1 ) { +perror (fname); + goto error_openfile; + } + opal_base =be64_to_cpu (opal_base); +fclose (file); + +memset (fname,0 ,sizeof (fname)); +strcpy (fname, device_tree); +strcat (fname, dentry->d_name); +strcat (fname,"/opal-runtime-size" ); + file =fopen (fname,"r" ); +if (file ==NULL ) { +perror (fname); + goto error_opencdir; + } +if (fread (&opal_size,sizeof (uint64_t ),1 , file) !=1 ) { +perror (fname); + goto error_openfile; + } +fclose (file); +closedir (cdir); + opal_size =be64_to_cpu (opal_size); +/* Add OPAL to exclude_range */ + exclude_range[i].start = opal_base; + exclude_range[i].end = opal_base + opal_size; + i++; +if (i >= max_memory_ranges) +realloc_memory_ranges (); +if (kexec_flags &KEXEC_ON_CRASH ) +add_usable_mem_rgns (opal_base, opal_size); + }/* ibm,opal */ +if (!strncmp (dentry->d_name,"memory@" ,7 ) || !strcmp (dentry->d_name,"memory" )) {strcat (fname,"/reg" );kexec/fs2dt.c +4
-0@@ -113,6 +113,10 @@ static void checkprop(char *name, unsigned *data, int len)die ("unrecoverable error: no property data" ); else if (!strcmp(name, "linux,rtas-base")) base =be32_to_cpu (*data); + else if (!strcmp(name, "opal-base-address")) + base =be64_to_cpu (*(unsigned long long *)data); + else if (!strcmp(name, "opal-runtime-size")) + size =be64_to_cpu (*(unsigned long long *)data); else if (!strcmp(name, "linux,tce-base")) base =be64_to_cpu (*(unsigned long long *) data); else if (!strcmp(name, "rtas-size") ||
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec