kexec/ppc64: Handle reserved memory ranges exported by OPAL firmware.
Subsystems (2)
PATCH 1/1 kexec/ppc64: Handle reserved memory ranges exported by OPAL firmware.
From: Mahesh Salgaonkar <[email protected]>
OPAL based system exports reserved memory ranges through /proc/device-tree for the regions that are reserved by OPAL firmware. Traverse /proc/device-tree/reserved-ranges and add them to exclude_ranges[] and reserve them.
--- kexec/arch/ppc64/kexec-ppc64.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
kexec/arch/ppc64/kexec-ppc64.c +44 -0
@@ -31,6 +31,7 @@#include "../../kexec.h" #include "../../kexec-syscall.h" #include "kexec-ppc64.h" +#include "../../fs2dt.h" #include "crashdump-ppc64.h" #include <arch/options.h>
@@ -314,6 +315,47 @@ static int sort_ranges(void)return 0 ; } +void scan_reserved_ranges (unsigned long kexec_flags,int *range_index) +{ +char fname[256 ], buf[16 ]; +FILE *file; +int i = *range_index; + +strcpy (fname,"/proc/device-tree/reserved-ranges" ); + + file =fopen (fname,"r" ); +if (file ==NULL ) { +if (errno !=ENOENT ) { +perror (fname); +return ; + } + errno =0 ; +/* File not present. Non PowerKVM system. */ +return ; + } + +/* +* Each reserved range is an (address,size) pair, 2 cells each, +* totalling 4 cells per range. +*/ +while (fread (buf,sizeof (uint64_t ) *2 ,1 , file) ==1 ) { +uint64_t base, size; + + base =be64_to_cpu (((uint64_t *)buf)[0 ]); + size =be64_to_cpu (((uint64_t *)buf)[1 ]); + + exclude_range[i].start = base; + exclude_range[i].end = base + size; + i++; +if (i >= max_memory_ranges) +realloc_memory_ranges (); + +reserve (base, size); + } +fclose (file); + *range_index = i; +} +/* Get devtree details and create exclude_range array * Also create usablemem_ranges for KEXEC_ON_CRASH */
@@ -339,6 +381,8 @@ static int get_devtree_details(unsigned long kexec_flags)return -1 ; } +scan_reserved_ranges (kexec_flags, &i); +while ((dentry =readdir (dir)) !=NULL ) { if (strncmp(dentry->d_name, "chosen", 6) && strncmp(dentry->d_name, "memory@", 7) &&
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 8 lines · Mahesh J Salgaonkar
From: Mahesh Salgaonkar <[email protected]>
OPAL based system exports reserved memory ranges through
/proc/device-treefor the regions that are reserved by OPAL firmware. Traverse/proc/device-tree/reserved-rangesand add them to exclude_ranges[] and reserve them.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 66 lines
--- kexec/arch/ppc64/kexec-ppc64.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)kexec/arch/ppc64/kexec-ppc64.c +42
-0@@ -31,6 +31,7 @@#include "../../kexec.h" #include "../../kexec-syscall.h" #include "kexec-ppc64.h" +#include "../../fs2dt.h" #include "crashdump-ppc64.h" #include <arch/options.h> @@ -314,6 +315,47 @@ static int sort_ranges(void)return 0 ; } +void scan_reserved_ranges (unsigned long kexec_flags,int *range_index) +{ +char fname[256 ], buf[16 ]; +FILE *file; +int i = *range_index; + +strcpy (fname,"/proc/device-tree/reserved-ranges" ); + + file =fopen (fname,"r" ); +if (file ==NULL ) { +if (errno !=ENOENT ) { +perror (fname); +return ; + } + errno =0 ; +/* File not present. Non PowerKVM system. */ +return ; + } + +/* +* Each reserved range is an (address,size) pair, 2 cells each, +* totalling 4 cells per range. +*/ +while (fread (buf,sizeof (uint64_t ) *2 ,1 , file) ==1 ) { +uint64_t base, size; + + base =be64_to_cpu (((uint64_t *)buf)[0 ]); + size =be64_to_cpu (((uint64_t *)buf)[1 ]); + + exclude_range[i].start = base; + exclude_range[i].end = base + size; + i++; +if (i >= max_memory_ranges) +realloc_memory_ranges (); + +reserve (base, size); + } +fclose (file); + *range_index = i; +} +/* Get devtree details and create exclude_range array * Also create usablemem_ranges for KEXEC_ON_CRASH */
kexec/arch/ppc64/kexec-ppc64.c static int get_devtree_details(unsigned long kexec_flags) · line 388
Quoted 8 lines
kexec/arch/ppc64/kexec-ppc64.c +2
-0@@ -339,6 +381,8 @@ static int get_devtree_details(unsigned long kexec_flags)return -1 ; } +scan_reserved_ranges (kexec_flags, &i); +while ((dentry =readdir (dir)) !=NULL ) { if (strncmp(dentry->d_name, "chosen", 6) && strncmp(dentry->d_name, "memory@", 7) &&
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 8 lines · Simon Horman
Quoted 7 lines · Mahesh J Salgaonkar
From: Mahesh Salgaonkar <[email protected]>
OPAL based system exports reserved memory ranges through
/proc/device-treefor the regions that are reserved by OPAL firmware. Traverse/proc/device-tree/reserved-rangesand add them to exclude_ranges[] and reserve them.
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?
Yup. We need this also.
If so, is it possible for
Quoted 70 lines
someone on the power side of things to review it?
Quoted 68 lines
--- kexec/arch/ppc64/kexec-ppc64.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)kexec/arch/ppc64/kexec-ppc64.c +42
-0@@ -31,6 +31,7 @@#include "../../kexec.h" #include "../../kexec-syscall.h" #include "kexec-ppc64.h" +#include "../../fs2dt.h" #include "crashdump-ppc64.h" #include <arch/options.h> @@ -314,6 +315,47 @@ static int sort_ranges(void)return 0 ; } +void scan_reserved_ranges (unsigned long kexec_flags,int *range_index) +{ +char fname[256 ], buf[16 ]; +FILE *file; +int i = *range_index; + +strcpy (fname,"/proc/device-tree/reserved-ranges" ); + + file =fopen (fname,"r" ); +if (file ==NULL ) { +if (errno !=ENOENT ) { +perror (fname); +return ; + } + errno =0 ; +/* File not present. Non PowerKVM system. */ +return ; + } + +/* +* Each reserved range is an (address,size) pair, 2 cells each, +* totalling 4 cells per range. +*/ +while (fread (buf,sizeof (uint64_t ) *2 ,1 , file) ==1 ) { +uint64_t base, size; + + base =be64_to_cpu (((uint64_t *)buf)[0 ]); + size =be64_to_cpu (((uint64_t *)buf)[1 ]); + + exclude_range[i].start = base; + exclude_range[i].end = base + size; + i++; +if (i >= max_memory_ranges) +realloc_memory_ranges (); + +reserve (base, size); + } +fclose (file); + *range_index = i; +} +/* Get devtree details and create exclude_range array * Also create usablemem_ranges for KEXEC_ON_CRASH */ @@ -339,6 +381,8 @@ static int get_devtree_details(unsigned long kexec_flags)return -1 ; }
Quoted 7 lines
kexec/arch/ppc64/kexec-ppc64.c static int get_devtree_details(unsigned long kexec_flags) · line 388
Quoted 6 lines
kexec/arch/ppc64/kexec-ppc64.c +2
-0+scan_reserved_ranges (kexec_flags, &i); +while ((dentry =readdir (dir)) !=NULL ) { if (strncmp(dentry->d_name, "chosen", 6) && strncmp(dentry->d_name, "memory@", 7) &&
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 9 lines · Mahesh Jagannath Salgaonkar
Quoted 8 lines · Simon Horman
Quoted 7 lines · Mahesh J Salgaonkar
From: Mahesh Salgaonkar <[email protected]>
OPAL based system exports reserved memory ranges through
/proc/device-treefor the regions that are reserved by OPAL firmware. Traverse/proc/device-tree/reserved-rangesand add them to exclude_ranges[] and reserve them.
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?
Yup. We need this also.
Thanks, I have applied this too.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec