All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kexec-tools v2 00/32] Keystone II updates for kexec tools
@ 2016-06-06 16:41 ` Russell King - ARM Linux
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King - ARM Linux @ 2016-06-06 16:41 UTC (permalink / raw)
  To: linux-arm-kernel

Here's the latest set of kexec-tools patches to support Keystone II
platforms, which work in conjunction with the kernel patches which
Andrew Morton has already taken.

Most of the patches have been reviewed, but there are a small number
which do not have Reviewed-by or Acked-by tags; these are due to
comments, which I've replied to, which have yet to have further
responses.

 kdump/kdump.c                     |  27 ++++-
 kexec/Makefile                    |   4 +
 kexec/arch/arm/Makefile           |   5 +
 kexec/arch/arm/crashdump-arm.c    | 247 +++++++++++++++++++-------------------
 kexec/arch/arm/crashdump-arm.h    |   2 +-
 kexec/arch/arm/iomem.h            |   9 ++
 kexec/arch/arm/kexec-arm.c        |   8 +-
 kexec/arch/arm/kexec-uImage-arm.c |   3 +-
 kexec/arch/arm/kexec-zImage-arm.c |   6 +-
 kexec/arch/arm/phys_to_virt.c     |   6 +-
 kexec/arch/arm/phys_to_virt.h     |   8 ++
 kexec/crashdump.h                 |   2 +-
 kexec/kexec-uImage.c              |   3 +-
 kexec/kexec.c                     |   4 +-
 kexec/kexec.h                     |   1 +
 kexec/mem_regions.c               | 128 ++++++++++++++++++++
 kexec/mem_regions.h               |  15 +++
 kexec/phys_to_virt.c              |   2 +-
 kexec/zlib.c                      |   4 +-
 19 files changed, 339 insertions(+), 145 deletions(-)


-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 00/32] Keystone II updates for kexec tools
@ 2016-06-06 16:41 ` Russell King - ARM Linux
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King - ARM Linux @ 2016-06-06 16:41 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Here's the latest set of kexec-tools patches to support Keystone II
platforms, which work in conjunction with the kernel patches which
Andrew Morton has already taken.

Most of the patches have been reviewed, but there are a small number
which do not have Reviewed-by or Acked-by tags; these are due to
comments, which I've replied to, which have yet to have further
responses.

 kdump/kdump.c                     |  27 ++++-
 kexec/Makefile                    |   4 +
 kexec/arch/arm/Makefile           |   5 +
 kexec/arch/arm/crashdump-arm.c    | 247 +++++++++++++++++++-------------------
 kexec/arch/arm/crashdump-arm.h    |   2 +-
 kexec/arch/arm/iomem.h            |   9 ++
 kexec/arch/arm/kexec-arm.c        |   8 +-
 kexec/arch/arm/kexec-uImage-arm.c |   3 +-
 kexec/arch/arm/kexec-zImage-arm.c |   6 +-
 kexec/arch/arm/phys_to_virt.c     |   6 +-
 kexec/arch/arm/phys_to_virt.h     |   8 ++
 kexec/crashdump.h                 |   2 +-
 kexec/kexec-uImage.c              |   3 +-
 kexec/kexec.c                     |   4 +-
 kexec/kexec.h                     |   1 +
 kexec/mem_regions.c               | 128 ++++++++++++++++++++
 kexec/mem_regions.h               |  15 +++
 kexec/phys_to_virt.c              |   2 +-
 kexec/zlib.c                      |   4 +-
 19 files changed, 339 insertions(+), 145 deletions(-)


-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 01/32] kdump: mmap() and munmap() only work on page-aligned quantites
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:58   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:58 UTC (permalink / raw)
  To: linux-arm-kernel

The man page for mmap() and munmap() says that mmap() and munmap()
only works for page-aligned addresses, sizes and offsets.  Arrange
to give these interfaces what they want.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 821ee7c..3247a54 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -25,22 +25,35 @@
 #define MAP_WINDOW_SIZE (64*1024*1024)
 #define DEV_MEM "/dev/mem"
 
+#define ALIGN_MASK(x,y) (((x) + (y)) & ~(y))
+#define ALIGN(x,y)	ALIGN_MASK(x, (y) - 1)
+
 static void *map_addr(int fd, unsigned long size, off_t offset)
 {
+	unsigned long page_size = getpagesize();
+	unsigned long map_offset = offset & (page_size - 1);
+	size_t len = ALIGN(size + map_offset, page_size);
 	void *result;
-	result = mmap(0, size, PROT_READ, MAP_SHARED, fd, offset);
+
+	result = mmap(0, len, PROT_READ, MAP_SHARED, fd, offset - map_offset);
 	if (result == MAP_FAILED) {
 		fprintf(stderr, "Cannot mmap " DEV_MEM " offset: %llu size: %lu: %s\n",
 			(unsigned long long)offset, size, strerror(errno));
 		exit(5);
 	}
-	return result;
+	return result + map_offset;
 }
 
 static void unmap_addr(void *addr, unsigned long size)
 {
+	unsigned long page_size = getpagesize();
+	unsigned long map_offset = (uintptr_t)addr & (page_size - 1);
+	size_t len = ALIGN(size + map_offset, page_size);
 	int ret;
-	ret = munmap(addr, size);
+
+	addr -= map_offset;
+
+	ret = munmap(addr, len);
 	if (ret < 0) {
 		fprintf(stderr, "munmap failed: %s\n",
 			strerror(errno));
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 01/32] kdump: mmap() and munmap() only work on page-aligned quantites
@ 2016-06-06 16:58   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:58 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

The man page for mmap() and munmap() says that mmap() and munmap()
only works for page-aligned addresses, sizes and offsets.  Arrange
to give these interfaces what they want.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 821ee7c..3247a54 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -25,22 +25,35 @@
 #define MAP_WINDOW_SIZE (64*1024*1024)
 #define DEV_MEM "/dev/mem"
 
+#define ALIGN_MASK(x,y) (((x) + (y)) & ~(y))
+#define ALIGN(x,y)	ALIGN_MASK(x, (y) - 1)
+
 static void *map_addr(int fd, unsigned long size, off_t offset)
 {
+	unsigned long page_size = getpagesize();
+	unsigned long map_offset = offset & (page_size - 1);
+	size_t len = ALIGN(size + map_offset, page_size);
 	void *result;
-	result = mmap(0, size, PROT_READ, MAP_SHARED, fd, offset);
+
+	result = mmap(0, len, PROT_READ, MAP_SHARED, fd, offset - map_offset);
 	if (result == MAP_FAILED) {
 		fprintf(stderr, "Cannot mmap " DEV_MEM " offset: %llu size: %lu: %s\n",
 			(unsigned long long)offset, size, strerror(errno));
 		exit(5);
 	}
-	return result;
+	return result + map_offset;
 }
 
 static void unmap_addr(void *addr, unsigned long size)
 {
+	unsigned long page_size = getpagesize();
+	unsigned long map_offset = (uintptr_t)addr & (page_size - 1);
+	size_t len = ALIGN(size + map_offset, page_size);
 	int ret;
-	ret = munmap(addr, size);
+
+	addr -= map_offset;
+
+	ret = munmap(addr, len);
 	if (ret < 0) {
 		fprintf(stderr, "munmap failed: %s\n",
 			strerror(errno));
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 02/32] kdump: fix multiple program header entries
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:58   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:58 UTC (permalink / raw)
  To: linux-arm-kernel

generate_new_headers() forgot to increment the program header pointer
after adding each program header from the kexec template. Fix it to
increment it correctly.

Without this, the program headers contain only the last entry, which
means we will be missing most of the kernel image in the dump.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 3247a54..99a1789 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -192,6 +192,7 @@ static void *generate_new_headers(
 		}
 		memcpy(nphdr, &phdr[i], sizeof(*nphdr));
 		nphdr->p_offset = offset;
+		nphdr++;
 		offset += phdr[i].p_filesz;
 	}
 	
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 02/32] kdump: fix multiple program header entries
@ 2016-06-06 16:58   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:58 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

generate_new_headers() forgot to increment the program header pointer
after adding each program header from the kexec template. Fix it to
increment it correctly.

Without this, the program headers contain only the last entry, which
means we will be missing most of the kernel image in the dump.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 3247a54..99a1789 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -192,6 +192,7 @@ static void *generate_new_headers(
 		}
 		memcpy(nphdr, &phdr[i], sizeof(*nphdr));
 		nphdr->p_offset = offset;
+		nphdr++;
 		offset += phdr[i].p_filesz;
 	}
 	
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 03/32] kdump: actually write out the memory
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:58   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:58 UTC (permalink / raw)
  To: linux-arm-kernel

Actually write out the memory rather than writing the notes a second
time.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 99a1789..1f5b984 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -300,7 +300,7 @@ int main(int argc, char **argv)
 	for(i = 0; i < ehdr->e_phnum; i++) {
 		unsigned long long offset, size;
 		size_t wsize;
-		if (phdr[i].p_type != PT_NOTE) {
+		if (phdr[i].p_type == PT_NOTE) {
 			continue;
 		}
 		offset = phdr[i].p_offset;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 03/32] kdump: actually write out the memory
@ 2016-06-06 16:58   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:58 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Actually write out the memory rather than writing the notes a second
time.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 99a1789..1f5b984 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -300,7 +300,7 @@ int main(int argc, char **argv)
 	for(i = 0; i < ehdr->e_phnum; i++) {
 		unsigned long long offset, size;
 		size_t wsize;
-		if (phdr[i].p_type != PT_NOTE) {
+		if (phdr[i].p_type == PT_NOTE) {
 			continue;
 		}
 		offset = phdr[i].p_offset;
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 04/32] kdump: fix kdump mapping
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

When kdump tries to map the program header, it fails to take account
of ehdr->e_phoff being an offset from the start of the ELF "file",
which causes:

Cannot mmap /dev/mem offset: 64 size: 392: Invalid argument

Ensure that we take account of the start address when mapping this.

This fix has been extracted from a larger patch by Vitaly Andrianov
adding support for Keystone 2.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 1f5b984..34d2149 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -284,7 +284,8 @@ int main(int argc, char **argv)
 	}
 	
 	/* Get the program header */
-	phdr = map_addr(fd, sizeof(*phdr)*(ehdr->e_phnum), ehdr->e_phoff);
+	phdr = map_addr(fd, sizeof(*phdr)*(ehdr->e_phnum), 
+			start_addr + ehdr->e_phoff);
 
 	/* Collect up the notes */
 	note_bytes = 0;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 04/32] kdump: fix kdump mapping
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

When kdump tries to map the program header, it fails to take account
of ehdr->e_phoff being an offset from the start of the ELF "file",
which causes:

Cannot mmap /dev/mem offset: 64 size: 392: Invalid argument

Ensure that we take account of the start address when mapping this.

This fix has been extracted from a larger patch by Vitaly Andrianov
adding support for Keystone 2.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 1f5b984..34d2149 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -284,7 +284,8 @@ int main(int argc, char **argv)
 	}
 	
 	/* Get the program header */
-	phdr = map_addr(fd, sizeof(*phdr)*(ehdr->e_phnum), ehdr->e_phoff);
+	phdr = map_addr(fd, sizeof(*phdr)*(ehdr->e_phnum), 
+			start_addr + ehdr->e_phoff);
 
 	/* Collect up the notes */
 	note_bytes = 0;
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 05/32] arm: fix kdump to work on LPAE systems
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

We need to use 64-bit file IO when mapping system memory and the core
dump file as we may be running on a LPAE system, otherwise we risk
mapping memory we shouldn't, and causing a kernel oops:

Unhandled fault: asynchronous external abort (0x211) at 0x00000000
pgd = edd2c740
[00000000] *pgd=82ec98003, *pmd=82dcd2003, *pte=00000000

Acked-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kexec/arch/arm/Makefile b/kexec/arch/arm/Makefile
index 38137d7..60e433a 100644
--- a/kexec/arch/arm/Makefile
+++ b/kexec/arch/arm/Makefile
@@ -18,6 +18,9 @@ libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
 
 arm_CPPFLAGS = -I$(srcdir)/kexec/libfdt
 
+# We want 64-bit file IO for kdump to work correctly on LPAE systems
+arm_CPPFLAGS += -D_FILE_OFFSET_BITS=64
+
 arm_KEXEC_SRCS += $(libfdt_SRCS)
 
 arm_UIMAGE = kexec/kexec-uImage.c
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 05/32] arm: fix kdump to work on LPAE systems
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

We need to use 64-bit file IO when mapping system memory and the core
dump file as we may be running on a LPAE system, otherwise we risk
mapping memory we shouldn't, and causing a kernel oops:

Unhandled fault: asynchronous external abort (0x211) at 0x00000000
pgd = edd2c740
[00000000] *pgd=82ec98003, *pmd=82dcd2003, *pte=00000000

Acked-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kexec/arch/arm/Makefile b/kexec/arch/arm/Makefile
index 38137d7..60e433a 100644
--- a/kexec/arch/arm/Makefile
+++ b/kexec/arch/arm/Makefile
@@ -18,6 +18,9 @@ libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
 
 arm_CPPFLAGS = -I$(srcdir)/kexec/libfdt
 
+# We want 64-bit file IO for kdump to work correctly on LPAE systems
+arm_CPPFLAGS += -D_FILE_OFFSET_BITS=64
+
 arm_KEXEC_SRCS += $(libfdt_SRCS)
 
 arm_UIMAGE = kexec/kexec-uImage.c
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 06/32] kdump: print mmap() offset in hex
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

When mmap() fails, printing a large decimal number is mostly
meaningless - it's not obvious what it means.  Printing a hex number
is more obvious, because we can see whether it's over 32-bit, or not
page aligned.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 34d2149..f34727f 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -37,7 +37,7 @@ static void *map_addr(int fd, unsigned long size, off_t offset)
 
 	result = mmap(0, len, PROT_READ, MAP_SHARED, fd, offset - map_offset);
 	if (result == MAP_FAILED) {
-		fprintf(stderr, "Cannot mmap " DEV_MEM " offset: %llu size: %lu: %s\n",
+		fprintf(stderr, "Cannot mmap " DEV_MEM " offset: %#llx size: %lu: %s\n",
 			(unsigned long long)offset, size, strerror(errno));
 		exit(5);
 	}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 06/32] kdump: print mmap() offset in hex
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

When mmap() fails, printing a large decimal number is mostly
meaningless - it's not obvious what it means.  Printing a hex number
is more obvious, because we can see whether it's over 32-bit, or not
page aligned.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kdump/kdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kdump/kdump.c b/kdump/kdump.c
index 34d2149..f34727f 100644
--- a/kdump/kdump.c
+++ b/kdump/kdump.c
@@ -37,7 +37,7 @@ static void *map_addr(int fd, unsigned long size, off_t offset)
 
 	result = mmap(0, len, PROT_READ, MAP_SHARED, fd, offset - map_offset);
 	if (result == MAP_FAILED) {
-		fprintf(stderr, "Cannot mmap " DEV_MEM " offset: %llu size: %lu: %s\n",
+		fprintf(stderr, "Cannot mmap " DEV_MEM " offset: %#llx size: %lu: %s\n",
 			(unsigned long long)offset, size, strerror(errno));
 		exit(5);
 	}
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 07/32] kexec: fix warnings caused by selecting 64-bit file IO on 32-bit platforms
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

Fix warnings caused by selecting 64-bit file IO on 32-bit platforms.

kexec/kexec.c:710:2: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'off_t' [-Wformat]
kexec/zlib.c:63:4: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'off_t' [-Wformat]
kexec/kexec-uImage.c:85:3: warning: format '%ld' expects argument of type 'long
int', but argument 2 has type 'off_t' [-Wformat]

Acked-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/kexec-uImage.c | 3 ++-
 kexec/kexec.c        | 4 ++--
 kexec/zlib.c         | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/kexec/kexec-uImage.c b/kexec/kexec-uImage.c
index 9df601b..5e24629 100644
--- a/kexec/kexec-uImage.c
+++ b/kexec/kexec-uImage.c
@@ -82,7 +82,8 @@ int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch)
 	if (be32_to_cpu(header.ih_size) > len - sizeof(header)) {
 		printf("uImage header claims that image has %d bytes\n",
 				be32_to_cpu(header.ih_size));
-		printf("we read only %ld bytes.\n", len - sizeof(header));
+		printf("we read only %lld bytes.\n",
+		       (long long)len - sizeof(header));
 		return -1;
 	}
 #ifdef HAVE_LIBZ
diff --git a/kexec/kexec.c b/kexec/kexec.c
index f0bd527..500e5a9 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -707,8 +707,8 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 	/* slurp in the input kernel */
 	kernel_buf = slurp_decompress_file(kernel, &kernel_size);
 
-	dbgprintf("kernel: %p kernel_size: 0x%lx\n",
-		  kernel_buf, kernel_size);
+	dbgprintf("kernel: %p kernel_size: %#llx\n",
+		  kernel_buf, (unsigned long long)kernel_size);
 
 	if (get_memory_ranges(&info.memory_range, &info.memory_ranges,
 		info.kexec_flags) < 0 || info.memory_ranges == 0) {
diff --git a/kexec/zlib.c b/kexec/zlib.c
index 7170ac3..95b6080 100644
--- a/kexec/zlib.c
+++ b/kexec/zlib.c
@@ -60,8 +60,8 @@ char *zlib_decompress_file(const char *filename, off_t *r_size)
 			if ((errno == EINTR) || (errno == EAGAIN))
 				continue;
 			_gzerror(fp, &errnum, &msg);
-			dbgprintf("Read on %s of %ld bytes failed: %s\n",
-					filename, (allocated - size) + 0UL, msg);
+			dbgprintf("Read on %s of %d bytes failed: %s\n",
+				  filename, (int)(allocated - size), msg);
 			size = 0;
 			goto fail;
 		}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 07/32] kexec: fix warnings caused by selecting 64-bit file IO on 32-bit platforms
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Fix warnings caused by selecting 64-bit file IO on 32-bit platforms.

kexec/kexec.c:710:2: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'off_t' [-Wformat]
kexec/zlib.c:63:4: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'off_t' [-Wformat]
kexec/kexec-uImage.c:85:3: warning: format '%ld' expects argument of type 'long
int', but argument 2 has type 'off_t' [-Wformat]

Acked-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/kexec-uImage.c | 3 ++-
 kexec/kexec.c        | 4 ++--
 kexec/zlib.c         | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/kexec/kexec-uImage.c b/kexec/kexec-uImage.c
index 9df601b..5e24629 100644
--- a/kexec/kexec-uImage.c
+++ b/kexec/kexec-uImage.c
@@ -82,7 +82,8 @@ int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch)
 	if (be32_to_cpu(header.ih_size) > len - sizeof(header)) {
 		printf("uImage header claims that image has %d bytes\n",
 				be32_to_cpu(header.ih_size));
-		printf("we read only %ld bytes.\n", len - sizeof(header));
+		printf("we read only %lld bytes.\n",
+		       (long long)len - sizeof(header));
 		return -1;
 	}
 #ifdef HAVE_LIBZ
diff --git a/kexec/kexec.c b/kexec/kexec.c
index f0bd527..500e5a9 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -707,8 +707,8 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 	/* slurp in the input kernel */
 	kernel_buf = slurp_decompress_file(kernel, &kernel_size);
 
-	dbgprintf("kernel: %p kernel_size: 0x%lx\n",
-		  kernel_buf, kernel_size);
+	dbgprintf("kernel: %p kernel_size: %#llx\n",
+		  kernel_buf, (unsigned long long)kernel_size);
 
 	if (get_memory_ranges(&info.memory_range, &info.memory_ranges,
 		info.kexec_flags) < 0 || info.memory_ranges == 0) {
diff --git a/kexec/zlib.c b/kexec/zlib.c
index 7170ac3..95b6080 100644
--- a/kexec/zlib.c
+++ b/kexec/zlib.c
@@ -60,8 +60,8 @@ char *zlib_decompress_file(const char *filename, off_t *r_size)
 			if ((errno == EINTR) || (errno == EAGAIN))
 				continue;
 			_gzerror(fp, &errnum, &msg);
-			dbgprintf("Read on %s of %ld bytes failed: %s\n",
-					filename, (allocated - size) + 0UL, msg);
+			dbgprintf("Read on %s of %d bytes failed: %s\n",
+				  filename, (int)(allocated - size), msg);
 			size = 0;
 			goto fail;
 		}
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 08/32] kexec: add max_size to memory_ranges
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

Many implementations statically allocate the memory range array, which
therefore will have a maximum allowable size.  Add this information to
the memory_ranges structure, so we don't have to carry it around.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/kexec.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kexec/kexec.h b/kexec/kexec.h
index c02ac8f..9194f1c 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -142,6 +142,7 @@ struct memory_range {
 
 struct memory_ranges {
         unsigned int size;
+	unsigned int max_size;
         struct memory_range *ranges;
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 08/32] kexec: add max_size to memory_ranges
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Many implementations statically allocate the memory range array, which
therefore will have a maximum allowable size.  Add this information to
the memory_ranges structure, so we don't have to carry it around.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/kexec.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kexec/kexec.h b/kexec/kexec.h
index c02ac8f..9194f1c 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -142,6 +142,7 @@ struct memory_range {
 
 struct memory_ranges {
         unsigned int size;
+	unsigned int max_size;
         struct memory_range *ranges;
 };
 
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 09/32] kexec: phys_to_virt() must take unsigned long long
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

crashdump-elf.c passes unsigned long long addresses into phys_to_virt()
so make phys_to_virt() accept such addresses without truncating them.
This is important for ARM LPAE systems.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/phys_to_virt.c | 2 +-
 kexec/crashdump.h             | 2 +-
 kexec/phys_to_virt.c          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kexec/arch/arm/phys_to_virt.c b/kexec/arch/arm/phys_to_virt.c
index bcced52..c2fe2ea 100644
--- a/kexec/arch/arm/phys_to_virt.c
+++ b/kexec/arch/arm/phys_to_virt.c
@@ -14,7 +14,7 @@
  * http://lists.arm.linux.org.uk/lurker/message/20010723.185051.94ce743c.en.html
  */
 unsigned long
-phys_to_virt(struct crash_elf_info *elf_info, unsigned long paddr)
+phys_to_virt(struct crash_elf_info *elf_info, unsigned long long paddr)
 {
 	return paddr + elf_info->page_offset - phys_offset;
 }
diff --git a/kexec/crashdump.h b/kexec/crashdump.h
index 95f1f0c..96219a8 100644
--- a/kexec/crashdump.h
+++ b/kexec/crashdump.h
@@ -55,7 +55,7 @@ int crash_create_elf64_headers(struct kexec_info *info,
 unsigned long crash_architecture(struct crash_elf_info *elf_info);
 
 unsigned long phys_to_virt(struct crash_elf_info *elf_info,
-			   unsigned long paddr);
+			   unsigned long long paddr);
 
 unsigned long xen_architecture(struct crash_elf_info *elf_info);
 int xen_get_nr_phys_cpus(void);
diff --git a/kexec/phys_to_virt.c b/kexec/phys_to_virt.c
index 91b6d01..5e8c4e3 100644
--- a/kexec/phys_to_virt.c
+++ b/kexec/phys_to_virt.c
@@ -10,7 +10,7 @@
  * their own implementation.
  */
 unsigned long
-phys_to_virt(struct crash_elf_info *elf_info, unsigned long paddr)
+phys_to_virt(struct crash_elf_info *elf_info, unsigned long long paddr)
 {
 	return paddr + elf_info->page_offset;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 09/32] kexec: phys_to_virt() must take unsigned long long
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

crashdump-elf.c passes unsigned long long addresses into phys_to_virt()
so make phys_to_virt() accept such addresses without truncating them.
This is important for ARM LPAE systems.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/phys_to_virt.c | 2 +-
 kexec/crashdump.h             | 2 +-
 kexec/phys_to_virt.c          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kexec/arch/arm/phys_to_virt.c b/kexec/arch/arm/phys_to_virt.c
index bcced52..c2fe2ea 100644
--- a/kexec/arch/arm/phys_to_virt.c
+++ b/kexec/arch/arm/phys_to_virt.c
@@ -14,7 +14,7 @@
  * http://lists.arm.linux.org.uk/lurker/message/20010723.185051.94ce743c.en.html
  */
 unsigned long
-phys_to_virt(struct crash_elf_info *elf_info, unsigned long paddr)
+phys_to_virt(struct crash_elf_info *elf_info, unsigned long long paddr)
 {
 	return paddr + elf_info->page_offset - phys_offset;
 }
diff --git a/kexec/crashdump.h b/kexec/crashdump.h
index 95f1f0c..96219a8 100644
--- a/kexec/crashdump.h
+++ b/kexec/crashdump.h
@@ -55,7 +55,7 @@ int crash_create_elf64_headers(struct kexec_info *info,
 unsigned long crash_architecture(struct crash_elf_info *elf_info);
 
 unsigned long phys_to_virt(struct crash_elf_info *elf_info,
-			   unsigned long paddr);
+			   unsigned long long paddr);
 
 unsigned long xen_architecture(struct crash_elf_info *elf_info);
 int xen_get_nr_phys_cpus(void);
diff --git a/kexec/phys_to_virt.c b/kexec/phys_to_virt.c
index 91b6d01..5e8c4e3 100644
--- a/kexec/phys_to_virt.c
+++ b/kexec/phys_to_virt.c
@@ -10,7 +10,7 @@
  * their own implementation.
  */
 unsigned long
-phys_to_virt(struct crash_elf_info *elf_info, unsigned long paddr)
+phys_to_virt(struct crash_elf_info *elf_info, unsigned long long paddr)
 {
 	return paddr + elf_info->page_offset;
 }
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 10/32] kexec: add generic helper to add to memory_regions
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

Add a helper to add a memory range to a memory_regions array.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/Makefile      |  4 ++++
 kexec/mem_regions.c | 30 ++++++++++++++++++++++++++++++
 kexec/mem_regions.h |  9 +++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 kexec/mem_regions.c
 create mode 100644 kexec/mem_regions.h

diff --git a/kexec/Makefile b/kexec/Makefile
index a758b4a..e2aee84 100644
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -69,6 +69,10 @@ dist				+= kexec/fs2dt.c kexec/fs2dt.h
 $(ARCH)_FS2DT			=
 KEXEC_SRCS			+= $($(ARCH)_FS2DT)
 
+dist				+= kexec/mem_regions.c kexec/mem_regions.h
+$(ARCH)_MEM_REGIONS		=
+KEXEC_SRCS			+= $($(ARCH)_MEM_REGIONS)
+
 include $(srcdir)/kexec/arch/alpha/Makefile
 include $(srcdir)/kexec/arch/arm/Makefile
 include $(srcdir)/kexec/arch/i386/Makefile
diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
new file mode 100644
index 0000000..a4952ff
--- /dev/null
+++ b/kexec/mem_regions.c
@@ -0,0 +1,30 @@
+#include "kexec.h"
+#include "mem_regions.h"
+
+/**
+ * mem_regions_add() - add a memory region to a set of ranges
+ * @ranges: ranges to add the memory region to
+ * @max: maximum number of entries in memory region
+ * @base: base address of memory region
+ * @length: length of memory region in bytes
+ * @type: type of memory region
+ *
+ * Add the memory region to the set of ranges, and return %0 if successful,
+ * or %-1 if we ran out of space.
+ */
+int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
+                    unsigned long long length, int type)
+{
+	struct memory_range *range;
+
+	if (ranges->size >= ranges->max_size)
+		return -1;
+
+	range = ranges->ranges + ranges->size++;
+	range->start = base;
+	range->end = base + length - 1;
+	range->type = type;
+
+	return 0;
+}
+
diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
new file mode 100644
index 0000000..b9cfba1
--- /dev/null
+++ b/kexec/mem_regions.h
@@ -0,0 +1,9 @@
+#ifndef MEM_REGIONS_H
+#define MEM_REGIONS_H
+
+struct memory_ranges;
+
+int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
+                    unsigned long long length, int type);
+
+#endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 10/32] kexec: add generic helper to add to memory_regions
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Add a helper to add a memory range to a memory_regions array.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/Makefile      |  4 ++++
 kexec/mem_regions.c | 30 ++++++++++++++++++++++++++++++
 kexec/mem_regions.h |  9 +++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 kexec/mem_regions.c
 create mode 100644 kexec/mem_regions.h

diff --git a/kexec/Makefile b/kexec/Makefile
index a758b4a..e2aee84 100644
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -69,6 +69,10 @@ dist				+= kexec/fs2dt.c kexec/fs2dt.h
 $(ARCH)_FS2DT			=
 KEXEC_SRCS			+= $($(ARCH)_FS2DT)
 
+dist				+= kexec/mem_regions.c kexec/mem_regions.h
+$(ARCH)_MEM_REGIONS		=
+KEXEC_SRCS			+= $($(ARCH)_MEM_REGIONS)
+
 include $(srcdir)/kexec/arch/alpha/Makefile
 include $(srcdir)/kexec/arch/arm/Makefile
 include $(srcdir)/kexec/arch/i386/Makefile
diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
new file mode 100644
index 0000000..a4952ff
--- /dev/null
+++ b/kexec/mem_regions.c
@@ -0,0 +1,30 @@
+#include "kexec.h"
+#include "mem_regions.h"
+
+/**
+ * mem_regions_add() - add a memory region to a set of ranges
+ * @ranges: ranges to add the memory region to
+ * @max: maximum number of entries in memory region
+ * @base: base address of memory region
+ * @length: length of memory region in bytes
+ * @type: type of memory region
+ *
+ * Add the memory region to the set of ranges, and return %0 if successful,
+ * or %-1 if we ran out of space.
+ */
+int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
+                    unsigned long long length, int type)
+{
+	struct memory_range *range;
+
+	if (ranges->size >= ranges->max_size)
+		return -1;
+
+	range = ranges->ranges + ranges->size++;
+	range->start = base;
+	range->end = base + length - 1;
+	range->type = type;
+
+	return 0;
+}
+
diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
new file mode 100644
index 0000000..b9cfba1
--- /dev/null
+++ b/kexec/mem_regions.h
@@ -0,0 +1,9 @@
+#ifndef MEM_REGIONS_H
+#define MEM_REGIONS_H
+
+struct memory_ranges;
+
+int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
+                    unsigned long long length, int type);
+
+#endif
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 11/32] kexec: add mem_regions sorting implementation
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

Add a mem_regions sorting implementation taken from the arm code.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/mem_regions.c | 27 +++++++++++++++++++++++++++
 kexec/mem_regions.h |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
index a4952ff..804984a 100644
--- a/kexec/mem_regions.c
+++ b/kexec/mem_regions.c
@@ -1,6 +1,33 @@
+#include <stdlib.h>
+
 #include "kexec.h"
 #include "mem_regions.h"
 
+static int mem_range_cmp(const void *a1, const void *a2)
+{
+	const struct memory_range *r1 = a1;
+	const struct memory_range *r2 = a2;
+
+	if (r1->start > r2->start)
+		return 1;
+	if (r1->start < r2->start)
+		return -1;
+
+	return 0;
+}
+
+/**
+ * mem_regions_sort() - sort ranges into ascending address order
+ * @ranges: ranges to sort
+ *
+ * Sort the memory regions into ascending address order.
+ */
+void mem_regions_sort(struct memory_ranges *ranges)
+{
+	qsort(ranges->ranges, ranges->size, sizeof(ranges->ranges),
+	      mem_range_cmp);
+}
+
 /**
  * mem_regions_add() - add a memory region to a set of ranges
  * @ranges: ranges to add the memory region to
diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
index b9cfba1..da7b5e8 100644
--- a/kexec/mem_regions.h
+++ b/kexec/mem_regions.h
@@ -3,6 +3,8 @@
 
 struct memory_ranges;
 
+void mem_regions_sort(struct memory_ranges *ranges);
+
 int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
                     unsigned long long length, int type);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 11/32] kexec: add mem_regions sorting implementation
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Add a mem_regions sorting implementation taken from the arm code.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/mem_regions.c | 27 +++++++++++++++++++++++++++
 kexec/mem_regions.h |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
index a4952ff..804984a 100644
--- a/kexec/mem_regions.c
+++ b/kexec/mem_regions.c
@@ -1,6 +1,33 @@
+#include <stdlib.h>
+
 #include "kexec.h"
 #include "mem_regions.h"
 
+static int mem_range_cmp(const void *a1, const void *a2)
+{
+	const struct memory_range *r1 = a1;
+	const struct memory_range *r2 = a2;
+
+	if (r1->start > r2->start)
+		return 1;
+	if (r1->start < r2->start)
+		return -1;
+
+	return 0;
+}
+
+/**
+ * mem_regions_sort() - sort ranges into ascending address order
+ * @ranges: ranges to sort
+ *
+ * Sort the memory regions into ascending address order.
+ */
+void mem_regions_sort(struct memory_ranges *ranges)
+{
+	qsort(ranges->ranges, ranges->size, sizeof(ranges->ranges),
+	      mem_range_cmp);
+}
+
 /**
  * mem_regions_add() - add a memory region to a set of ranges
  * @ranges: ranges to add the memory region to
diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
index b9cfba1..da7b5e8 100644
--- a/kexec/mem_regions.h
+++ b/kexec/mem_regions.h
@@ -3,6 +3,8 @@
 
 struct memory_ranges;
 
+void mem_regions_sort(struct memory_ranges *ranges);
+
 int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
                     unsigned long long length, int type);
 
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 12/32] kexec: add helper to exlude a region from a set of memory ranges
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

Add a helper to exclude a region from a set of memory ranges.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/mem_regions.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 kexec/mem_regions.h |  4 +++
 2 files changed, 75 insertions(+)

diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
index 804984a..b01a5c8 100644
--- a/kexec/mem_regions.c
+++ b/kexec/mem_regions.c
@@ -55,3 +55,74 @@ int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
 	return 0;
 }
 
+static void mem_regions_remove(struct memory_ranges *ranges, int index)
+{
+	int tail_entries;
+
+	/* we are assured to have at least one entry */
+	ranges->size -= 1;
+
+	/* if we have following entries, shuffle them down one place */
+	tail_entries = ranges->size - index;
+	if (tail_entries)
+		memmove(ranges->ranges + index, ranges->ranges + index + 1,
+			tail_entries * sizeof(*ranges->ranges));
+
+	/* zero the new tail entry */
+	memset(ranges->ranges + ranges->size, 0, sizeof(*ranges->ranges));
+}
+
+/**
+ * mem_regions_exclude() - excludes a memory region from a set of memory ranges
+ * @ranges: memory ranges to exclude the region from
+ * @range: memory range to exclude
+ *
+ * Exclude a memory region from a set of memory ranges.  We assume that
+ * the region to be excluded is either wholely located within one of the
+ * memory ranges, or not at all.
+ */
+int mem_regions_exclude(struct memory_ranges *ranges,
+			const struct memory_range *range)
+{
+	int i, ret;
+
+	for (i = 0; i < ranges->size; i++) {
+		struct memory_range *r = ranges->ranges + i;
+
+		/*
+		 * We assume that crash area is fully contained in
+		 * some larger memory area.
+		 */
+		if (r->start <= range->start && r->end >= range->end) {
+			if (r->start == range->start) {
+				if (r->end == range->end)
+					/* Remove this entry */
+					mem_regions_remove(ranges, i);
+				else
+					/* Shrink the start of this memory range */
+					r->start = range->end + 1;
+			} else if (r->end == range->end) {
+				/* Shrink the end of this memory range */
+				r->end = range->start - 1;
+			} else {
+				/*
+				 * Split this area into 2 smaller ones and
+				 * remove excluded range from between. First
+				 * create new entry for the remaining area.
+				 */
+				ret = mem_regions_add(ranges, range->end + 1,
+						      r->end - range->end, 0);
+				if (ret < 0)
+					return ret;
+
+				/*
+				 * Update this area to end before excluded
+				 * range.
+				 */
+				r->end = range->start - 1;
+				break;
+			}
+		}
+	}
+	return 0;
+}
diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
index da7b5e8..ae9e972 100644
--- a/kexec/mem_regions.h
+++ b/kexec/mem_regions.h
@@ -2,9 +2,13 @@
 #define MEM_REGIONS_H
 
 struct memory_ranges;
+struct memory_range;
 
 void mem_regions_sort(struct memory_ranges *ranges);
 
+int mem_regions_exclude(struct memory_ranges *ranges,
+			const struct memory_range *range);
+
 int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
                     unsigned long long length, int type);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 12/32] kexec: add helper to exlude a region from a set of memory ranges
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Add a helper to exclude a region from a set of memory ranges.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/mem_regions.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 kexec/mem_regions.h |  4 +++
 2 files changed, 75 insertions(+)

diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
index 804984a..b01a5c8 100644
--- a/kexec/mem_regions.c
+++ b/kexec/mem_regions.c
@@ -55,3 +55,74 @@ int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
 	return 0;
 }
 
+static void mem_regions_remove(struct memory_ranges *ranges, int index)
+{
+	int tail_entries;
+
+	/* we are assured to have at least one entry */
+	ranges->size -= 1;
+
+	/* if we have following entries, shuffle them down one place */
+	tail_entries = ranges->size - index;
+	if (tail_entries)
+		memmove(ranges->ranges + index, ranges->ranges + index + 1,
+			tail_entries * sizeof(*ranges->ranges));
+
+	/* zero the new tail entry */
+	memset(ranges->ranges + ranges->size, 0, sizeof(*ranges->ranges));
+}
+
+/**
+ * mem_regions_exclude() - excludes a memory region from a set of memory ranges
+ * @ranges: memory ranges to exclude the region from
+ * @range: memory range to exclude
+ *
+ * Exclude a memory region from a set of memory ranges.  We assume that
+ * the region to be excluded is either wholely located within one of the
+ * memory ranges, or not at all.
+ */
+int mem_regions_exclude(struct memory_ranges *ranges,
+			const struct memory_range *range)
+{
+	int i, ret;
+
+	for (i = 0; i < ranges->size; i++) {
+		struct memory_range *r = ranges->ranges + i;
+
+		/*
+		 * We assume that crash area is fully contained in
+		 * some larger memory area.
+		 */
+		if (r->start <= range->start && r->end >= range->end) {
+			if (r->start == range->start) {
+				if (r->end == range->end)
+					/* Remove this entry */
+					mem_regions_remove(ranges, i);
+				else
+					/* Shrink the start of this memory range */
+					r->start = range->end + 1;
+			} else if (r->end == range->end) {
+				/* Shrink the end of this memory range */
+				r->end = range->start - 1;
+			} else {
+				/*
+				 * Split this area into 2 smaller ones and
+				 * remove excluded range from between. First
+				 * create new entry for the remaining area.
+				 */
+				ret = mem_regions_add(ranges, range->end + 1,
+						      r->end - range->end, 0);
+				if (ret < 0)
+					return ret;
+
+				/*
+				 * Update this area to end before excluded
+				 * range.
+				 */
+				r->end = range->start - 1;
+				break;
+			}
+		}
+	}
+	return 0;
+}
diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
index da7b5e8..ae9e972 100644
--- a/kexec/mem_regions.h
+++ b/kexec/mem_regions.h
@@ -2,9 +2,13 @@
 #define MEM_REGIONS_H
 
 struct memory_ranges;
+struct memory_range;
 
 void mem_regions_sort(struct memory_ranges *ranges);
 
+int mem_regions_exclude(struct memory_ranges *ranges,
+			const struct memory_range *range);
+
 int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
                     unsigned long long length, int type);
 
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 13/32] arm: fix pointer signedness warning in kexec-uImage-arm.c
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

kexec/arch/arm/kexec-uImage-arm.c: In function 'uImage_arm_probe':
kexec/arch/arm/kexec-uImage-arm.c:14:2: warning: pointer targets in passing argument 1 of 'uImage_probe_kernel' differ in signedness [-Wpointer-sign]

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-uImage-arm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/arm/kexec-uImage-arm.c b/kexec/arch/arm/kexec-uImage-arm.c
index 03c2f4d..8e0a9ac 100644
--- a/kexec/arch/arm/kexec-uImage-arm.c
+++ b/kexec/arch/arm/kexec-uImage-arm.c
@@ -11,7 +11,8 @@
 
 int uImage_arm_probe(const char *buf, off_t len)
 {
-	return uImage_probe_kernel(buf, len, IH_ARCH_ARM);
+	return uImage_probe_kernel((const unsigned char *)buf, len,
+				   IH_ARCH_ARM);
 }
 
 int uImage_arm_load(int argc, char **argv, const char *buf, off_t len,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 13/32] arm: fix pointer signedness warning in kexec-uImage-arm.c
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

kexec/arch/arm/kexec-uImage-arm.c: In function 'uImage_arm_probe':
kexec/arch/arm/kexec-uImage-arm.c:14:2: warning: pointer targets in passing argument 1 of 'uImage_probe_kernel' differ in signedness [-Wpointer-sign]

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-uImage-arm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/arm/kexec-uImage-arm.c b/kexec/arch/arm/kexec-uImage-arm.c
index 03c2f4d..8e0a9ac 100644
--- a/kexec/arch/arm/kexec-uImage-arm.c
+++ b/kexec/arch/arm/kexec-uImage-arm.c
@@ -11,7 +11,8 @@
 
 int uImage_arm_probe(const char *buf, off_t len)
 {
-	return uImage_probe_kernel(buf, len, IH_ARCH_ARM);
+	return uImage_probe_kernel((const unsigned char *)buf, len,
+				   IH_ARCH_ARM);
 }
 
 int uImage_arm_load(int argc, char **argv, const char *buf, off_t len,
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 14/32] arm: fix off-by-one on memory end
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 16:59   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

The memory range end is inclusive, not exclusive (see x86).  We should
not be adding one to the value parsed from the /proc/iomem resources.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-arm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kexec/arch/arm/kexec-arm.c b/kexec/arch/arm/kexec-arm.c
index 4e90e69..e47fc00 100644
--- a/kexec/arch/arm/kexec-arm.c
+++ b/kexec/arch/arm/kexec-arm.c
@@ -51,7 +51,6 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 		if (count != 2)
 			continue;
 		str = line + consumed;
-		end = end + 1;
 
 		if (memcmp(str, "System RAM\n", 11) == 0) {
 			type = RANGE_RAM;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 14/32] arm: fix off-by-one on memory end
@ 2016-06-06 16:59   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 16:59 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

The memory range end is inclusive, not exclusive (see x86).  We should
not be adding one to the value parsed from the /proc/iomem resources.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-arm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kexec/arch/arm/kexec-arm.c b/kexec/arch/arm/kexec-arm.c
index 4e90e69..e47fc00 100644
--- a/kexec/arch/arm/kexec-arm.c
+++ b/kexec/arch/arm/kexec-arm.c
@@ -51,7 +51,6 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 		if (count != 2)
 			continue;
 		str = line + consumed;
-		end = end + 1;
 
 		if (memcmp(str, "System RAM\n", 11) == 0) {
 			type = RANGE_RAM;
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 15/32] arm: fix get_kernel_stext_sym() to close its file
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

Fix get_kernel_stext_sym() so that it closes its file once it's
finsihed with it - there's no need to leak file descriptors.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index b523e5f..a390187 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -71,25 +71,34 @@ static unsigned long long get_kernel_stext_sym(void)
 	char sym[128];
 	char line[128];
 	FILE *fp;
-	unsigned long long vaddr;
+	unsigned long long vaddr = 0;
 	char type;
 
-	fp = fopen(kallsyms, "r");	if (!fp) {
+	fp = fopen(kallsyms, "r");
+	if (!fp) {
 		fprintf(stderr, "Cannot open %s\n", kallsyms);
 		return 0;
 	}
 
 	while(fgets(line, sizeof(line), fp) != NULL) {
-		if (sscanf(line, "%Lx %c %s", &vaddr, &type, sym) != 3)
+		unsigned long long addr;
+
+		if (sscanf(line, "%Lx %c %s", &addr, &type, sym) != 3)
 			continue;
+
 		if (strcmp(sym, stext) == 0) {
-			dbgprintf("kernel symbol %s vaddr = %16llx\n", stext, vaddr);
-			return vaddr;
+			dbgprintf("kernel symbol %s vaddr = %#llx\n", stext, addr);
+			vaddr = addr;
+			break;
 		}
 	}
 
-	fprintf(stderr, "Cannot get kernel %s symbol address\n", stext);
-	return 0;
+	fclose(fp);
+
+	if (vaddr == 0)
+		fprintf(stderr, "Cannot get kernel %s symbol address\n", stext);
+
+	return vaddr;
 }
 
 static int get_kernel_page_offset(struct kexec_info *info,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 15/32] arm: fix get_kernel_stext_sym() to close its file
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Fix get_kernel_stext_sym() so that it closes its file once it's
finsihed with it - there's no need to leak file descriptors.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index b523e5f..a390187 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -71,25 +71,34 @@ static unsigned long long get_kernel_stext_sym(void)
 	char sym[128];
 	char line[128];
 	FILE *fp;
-	unsigned long long vaddr;
+	unsigned long long vaddr = 0;
 	char type;
 
-	fp = fopen(kallsyms, "r");	if (!fp) {
+	fp = fopen(kallsyms, "r");
+	if (!fp) {
 		fprintf(stderr, "Cannot open %s\n", kallsyms);
 		return 0;
 	}
 
 	while(fgets(line, sizeof(line), fp) != NULL) {
-		if (sscanf(line, "%Lx %c %s", &vaddr, &type, sym) != 3)
+		unsigned long long addr;
+
+		if (sscanf(line, "%Lx %c %s", &addr, &type, sym) != 3)
 			continue;
+
 		if (strcmp(sym, stext) == 0) {
-			dbgprintf("kernel symbol %s vaddr = %16llx\n", stext, vaddr);
-			return vaddr;
+			dbgprintf("kernel symbol %s vaddr = %#llx\n", stext, addr);
+			vaddr = addr;
+			break;
 		}
 	}
 
-	fprintf(stderr, "Cannot get kernel %s symbol address\n", stext);
-	return 0;
+	fclose(fp);
+
+	if (vaddr == 0)
+		fprintf(stderr, "Cannot get kernel %s symbol address\n", stext);
+
+	return vaddr;
 }
 
 static int get_kernel_page_offset(struct kexec_info *info,
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 16/32] arm: fix ELF32/ELF64 check
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

Rather than using ULONG_MAX to decide whether to use the ELF64 or ELF32
core dump format, use UINT32_MAX instead - we include stdint.h, so we
might as well use a constant which is meaningful for the limits of
the 32-bit ELF format.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index a390187..fcc4d42 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -369,8 +369,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	if (last_ranges < 0)
 		last_ranges = 0;
 
-	if (crash_memory_ranges[last_ranges].end > ULONG_MAX) {
-
+	if (crash_memory_ranges[last_ranges].end > UINT32_MAX) {
 		/* for support LPAE enabled kernel*/
 		elf_info.class = ELFCLASS64;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 16/32] arm: fix ELF32/ELF64 check
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Rather than using ULONG_MAX to decide whether to use the ELF64 or ELF32
core dump format, use UINT32_MAX instead - we include stdint.h, so we
might as well use a constant which is meaningful for the limits of
the 32-bit ELF format.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index a390187..fcc4d42 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -369,8 +369,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	if (last_ranges < 0)
 		last_ranges = 0;
 
-	if (crash_memory_ranges[last_ranges].end > ULONG_MAX) {
-
+	if (crash_memory_ranges[last_ranges].end > UINT32_MAX) {
 		/* for support LPAE enabled kernel*/
 		elf_info.class = ELFCLASS64;
 
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 17/32] arm: return proper error for missing crash kernel
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

Return the proper error code (ENOCRASHKERNEL) for a missing crash
kernel region in /proc/iomem, so the error handling in kexec.c can
print the appropriate message.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-zImage-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index d85ab9b..4755f06 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -451,7 +451,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 			 * No crash kernel memory reserved. We cannot do more
 			 * but just bail out.
 			 */
-			return -1;
+			return ENOCRASHKERNEL;
 		}
 		base = start;
 	} else {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 17/32] arm: return proper error for missing crash kernel
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Return the proper error code (ENOCRASHKERNEL) for a missing crash
kernel region in /proc/iomem, so the error handling in kexec.c can
print the appropriate message.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-zImage-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index d85ab9b..4755f06 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -451,7 +451,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 			 * No crash kernel memory reserved. We cannot do more
 			 * but just bail out.
 			 */
-			return -1;
+			return ENOCRASHKERNEL;
 		}
 		base = start;
 	} else {
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 18/32] arm: report if crash kernel is out of bounds
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

Report an error if the crash kernel memory region is outside of the
boot-view memory range - this can happen with systems such as
Keystone 2.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 11 +++++++++++
 kexec/arch/arm/crashdump-arm.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index fcc4d42..739c906 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -365,6 +365,17 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	if (get_kernel_page_offset(info, &elf_info))
 		return -1;
 
+	/*
+	 * Ensure that the crash kernel memory range is sane. The crash kernel
+	 * must be located within memory which is visible during booting.
+	 */
+	if (crash_reserved_mem.end > ARM_MAX_VIRTUAL) {
+		fprintf(stderr,
+			"Crash kernel memory [0x%llx-0x%llx] is inaccessible at boot - unable to load crash kernel\n",
+			crash_reserved_mem.start, crash_reserved_mem.end);
+		return -1;
+	}
+
 	last_ranges = usablemem_rgns.size - 1;
 	if (last_ranges < 0)
 		last_ranges = 0;
diff --git a/kexec/arch/arm/crashdump-arm.h b/kexec/arch/arm/crashdump-arm.h
index 2dbde04..7314960 100644
--- a/kexec/arch/arm/crashdump-arm.h
+++ b/kexec/arch/arm/crashdump-arm.h
@@ -9,6 +9,7 @@ extern "C" {
 #define DEFAULT_PAGE_OFFSET		(0xc0000000)
 #define KVBASE_MASK	(0x1ffffff)
 #define CRASH_MAX_MEMORY_RANGES	32
+#define ARM_MAX_VIRTUAL		UINT32_MAX
 
 
 extern struct memory_ranges usablemem_rgns;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 18/32] arm: report if crash kernel is out of bounds
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Report an error if the crash kernel memory region is outside of the
boot-view memory range - this can happen with systems such as
Keystone 2.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 11 +++++++++++
 kexec/arch/arm/crashdump-arm.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index fcc4d42..739c906 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -365,6 +365,17 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	if (get_kernel_page_offset(info, &elf_info))
 		return -1;
 
+	/*
+	 * Ensure that the crash kernel memory range is sane. The crash kernel
+	 * must be located within memory which is visible during booting.
+	 */
+	if (crash_reserved_mem.end > ARM_MAX_VIRTUAL) {
+		fprintf(stderr,
+			"Crash kernel memory [0x%llx-0x%llx] is inaccessible at boot - unable to load crash kernel\n",
+			crash_reserved_mem.start, crash_reserved_mem.end);
+		return -1;
+	}
+
 	last_ranges = usablemem_rgns.size - 1;
 	if (last_ranges < 0)
 		last_ranges = 0;
diff --git a/kexec/arch/arm/crashdump-arm.h b/kexec/arch/arm/crashdump-arm.h
index 2dbde04..7314960 100644
--- a/kexec/arch/arm/crashdump-arm.h
+++ b/kexec/arch/arm/crashdump-arm.h
@@ -9,6 +9,7 @@ extern "C" {
 #define DEFAULT_PAGE_OFFSET		(0xc0000000)
 #define KVBASE_MASK	(0x1ffffff)
 #define CRASH_MAX_MEMORY_RANGES	32
+#define ARM_MAX_VIRTUAL		UINT32_MAX
 
 
 extern struct memory_ranges usablemem_rgns;
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 19/32] arm: add memory ranges debug
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

Add the call to dbgprint_mem_range() into the ARM version of
get_memory_ranges().

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-arm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kexec/arch/arm/kexec-arm.c b/kexec/arch/arm/kexec-arm.c
index e47fc00..eeb27b4 100644
--- a/kexec/arch/arm/kexec-arm.c
+++ b/kexec/arch/arm/kexec-arm.c
@@ -70,6 +70,9 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 	fclose(fp);
 	*range = memory_range;
 	*ranges = memory_ranges;
+
+	dbgprint_mem_range("MEMORY RANGES", *range, *ranges);
+
 	return 0;
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 19/32] arm: add memory ranges debug
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Add the call to dbgprint_mem_range() into the ARM version of
get_memory_ranges().

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-arm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kexec/arch/arm/kexec-arm.c b/kexec/arch/arm/kexec-arm.c
index e47fc00..eeb27b4 100644
--- a/kexec/arch/arm/kexec-arm.c
+++ b/kexec/arch/arm/kexec-arm.c
@@ -70,6 +70,9 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 	fclose(fp);
 	*range = memory_range;
 	*ranges = memory_ranges;
+
+	dbgprint_mem_range("MEMORY RANGES", *range, *ranges);
+
 	return 0;
 }
 
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 20/32] arm: add maximum number of memory ranges
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

Add the maximum number of memory ranges to the list of usable memory
ranges, so that we don't have to carry this around.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 739c906..195b43f 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -46,8 +46,8 @@
  */
 static struct memory_range crash_memory_ranges[CRASH_MAX_MEMORY_RANGES];
 struct memory_ranges usablemem_rgns = {
-    .size = 0,
-    .ranges = crash_memory_ranges,
+	.max_size = CRASH_MAX_MEMORY_RANGES,
+	.ranges = crash_memory_ranges,
 };
 
 /* memory range reserved for crashkernel */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 20/32] arm: add maximum number of memory ranges
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Add the maximum number of memory ranges to the list of usable memory
ranges, so that we don't have to carry this around.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 739c906..195b43f 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -46,8 +46,8 @@
  */
 static struct memory_range crash_memory_ranges[CRASH_MAX_MEMORY_RANGES];
 struct memory_ranges usablemem_rgns = {
-    .size = 0,
-    .ranges = crash_memory_ranges,
+	.max_size = CRASH_MAX_MEMORY_RANGES,
+	.ranges = crash_memory_ranges,
 };
 
 /* memory range reserved for crashkernel */
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 21/32] arm: parse crash_reserved_mem early
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

We parse the crash kernel memory region in several locations in the
kexec tools - once to check that there's a region, another time for
real when we're locating the memory regions to dump, and another
while loading the image.

Move the real parsing step to is_crashkernel_mem_reserved(), which
matches what x86 is doing.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 47 +++++++++++++++++++++++++++++++-----------
 kexec/arch/arm/iomem.h         |  7 +++++++
 2 files changed, 42 insertions(+), 12 deletions(-)
 create mode 100644 kexec/arch/arm/iomem.h

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 195b43f..85afd9f 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -31,6 +31,7 @@
 #include "../../kexec-elf.h"
 #include "../../crashdump.h"
 #include "crashdump-arm.h"
+#include "iomem.h"
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define ELFDATANATIVE ELFDATA2LSB
@@ -139,9 +140,8 @@ static int get_kernel_page_offset(struct kexec_info *info,
  * @length: size of the memory region
  *
  * This function is called once for each memory region found in /proc/iomem. It
- * locates system RAM and crashkernel reserved memory and places these to
- * variables: @crash_memory_ranges and @crash_reserved_mem. Number of memory
- * regions is placed in @crash_memory_nr_ranges.
+ * locates system RAM and places these into @crash_memory_ranges. Number of
+ * memory regions is placed in @crash_memory_nr_ranges.
  */
 static int crash_range_callback(void *UNUSED(data), int UNUSED(nr),
 				char *str, unsigned long long base,
@@ -159,10 +159,6 @@ static int crash_range_callback(void *UNUSED(data), int UNUSED(nr),
 		range->end = base + length - 1;
 		range->type = RANGE_RAM;
 		usablemem_rgns.size++;
-	} else if (strncmp(str, "Crash kernel\n", 13) == 0) {
-		crash_reserved_mem.start = base;
-		crash_reserved_mem.end = base + length - 1;
-		crash_reserved_mem.type = RANGE_RAM;
 	}
 
 	return 0;
@@ -424,12 +420,39 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	return 0;
 }
 
-int is_crashkernel_mem_reserved(void)
+/**
+ * iomem_range_callback() - callback called for each iomem region
+ * @data: not used
+ * @nr: not used
+ * @str: name of the memory region (not NULL terminated)
+ * @base: start address of the memory region
+ * @length: size of the memory region
+ *
+ * This function is called for each memory range in /proc/iomem, and stores
+ * the location of the crash kernel range into @crash_reserved_mem.
+ */
+static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
+				char *str, unsigned long long base,
+				unsigned long long length)
 {
-	uint64_t start, end;
+	if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) {
+		crash_reserved_mem.start = base;
+		crash_reserved_mem.end = base + length - 1;
+		crash_reserved_mem.type = RANGE_RAM;
+	}
+	return 0;
+}
 
-	if (parse_iomem_single("Crash kernel\n", &start, &end) == 0)
-		return start != end;
+/**
+ * is_crashkernel_mem_reserved() - check for the crashkernel reserved region
+ *
+ * Check for the crashkernel reserved region in /proc/iomem, and return
+ * true if it is present, or false otherwise. We use this to store the
+ * location of this region.
+ */
+int is_crashkernel_mem_reserved(void)
+{
+	kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL);
 
-	return 0;
+	return crash_reserved_mem.start != crash_reserved_mem.end;
 }
diff --git a/kexec/arch/arm/iomem.h b/kexec/arch/arm/iomem.h
new file mode 100644
index 0000000..81c593d
--- /dev/null
+++ b/kexec/arch/arm/iomem.h
@@ -0,0 +1,7 @@
+#ifndef IOMEM_H
+#define IOMEM_H
+
+#define SYSTEM_RAM		"System RAM\n"
+#define CRASH_KERNEL		"Crash kernel\n"
+
+#endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 21/32] arm: parse crash_reserved_mem early
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

We parse the crash kernel memory region in several locations in the
kexec tools - once to check that there's a region, another time for
real when we're locating the memory regions to dump, and another
while loading the image.

Move the real parsing step to is_crashkernel_mem_reserved(), which
matches what x86 is doing.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 47 +++++++++++++++++++++++++++++++-----------
 kexec/arch/arm/iomem.h         |  7 +++++++
 2 files changed, 42 insertions(+), 12 deletions(-)
 create mode 100644 kexec/arch/arm/iomem.h

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 195b43f..85afd9f 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -31,6 +31,7 @@
 #include "../../kexec-elf.h"
 #include "../../crashdump.h"
 #include "crashdump-arm.h"
+#include "iomem.h"
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define ELFDATANATIVE ELFDATA2LSB
@@ -139,9 +140,8 @@ static int get_kernel_page_offset(struct kexec_info *info,
  * @length: size of the memory region
  *
  * This function is called once for each memory region found in /proc/iomem. It
- * locates system RAM and crashkernel reserved memory and places these to
- * variables: @crash_memory_ranges and @crash_reserved_mem. Number of memory
- * regions is placed in @crash_memory_nr_ranges.
+ * locates system RAM and places these into @crash_memory_ranges. Number of
+ * memory regions is placed in @crash_memory_nr_ranges.
  */
 static int crash_range_callback(void *UNUSED(data), int UNUSED(nr),
 				char *str, unsigned long long base,
@@ -159,10 +159,6 @@ static int crash_range_callback(void *UNUSED(data), int UNUSED(nr),
 		range->end = base + length - 1;
 		range->type = RANGE_RAM;
 		usablemem_rgns.size++;
-	} else if (strncmp(str, "Crash kernel\n", 13) == 0) {
-		crash_reserved_mem.start = base;
-		crash_reserved_mem.end = base + length - 1;
-		crash_reserved_mem.type = RANGE_RAM;
 	}
 
 	return 0;
@@ -424,12 +420,39 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	return 0;
 }
 
-int is_crashkernel_mem_reserved(void)
+/**
+ * iomem_range_callback() - callback called for each iomem region
+ * @data: not used
+ * @nr: not used
+ * @str: name of the memory region (not NULL terminated)
+ * @base: start address of the memory region
+ * @length: size of the memory region
+ *
+ * This function is called for each memory range in /proc/iomem, and stores
+ * the location of the crash kernel range into @crash_reserved_mem.
+ */
+static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
+				char *str, unsigned long long base,
+				unsigned long long length)
 {
-	uint64_t start, end;
+	if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) {
+		crash_reserved_mem.start = base;
+		crash_reserved_mem.end = base + length - 1;
+		crash_reserved_mem.type = RANGE_RAM;
+	}
+	return 0;
+}
 
-	if (parse_iomem_single("Crash kernel\n", &start, &end) == 0)
-		return start != end;
+/**
+ * is_crashkernel_mem_reserved() - check for the crashkernel reserved region
+ *
+ * Check for the crashkernel reserved region in /proc/iomem, and return
+ * true if it is present, or false otherwise. We use this to store the
+ * location of this region.
+ */
+int is_crashkernel_mem_reserved(void)
+{
+	kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL);
 
-	return 0;
+	return crash_reserved_mem.start != crash_reserved_mem.end;
 }
diff --git a/kexec/arch/arm/iomem.h b/kexec/arch/arm/iomem.h
new file mode 100644
index 0000000..81c593d
--- /dev/null
+++ b/kexec/arch/arm/iomem.h
@@ -0,0 +1,7 @@
+#ifndef IOMEM_H
+#define IOMEM_H
+
+#define SYSTEM_RAM		"System RAM\n"
+#define CRASH_KERNEL		"Crash kernel\n"
+
+#endif
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 22/32] arm: use generic mem_region sorting implementation
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

Use the generic mem_region sorting implementation.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 85afd9f..d6db566 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -202,19 +202,6 @@ static void crash_exclude_range(void)
 	}
 }
 
-static int range_cmp(const void *a1, const void *a2)
-{
-	const struct memory_range *r1 = a1;
-	const struct memory_range *r2 = a2;
-
-	if (r1->start > r2->start)
-		return 1;
-	if (r1->start < r2->start)
-		return -1;
-
-	return 0;
-}
-
 /**
  * crash_get_memory_ranges() - read system physical memory
  *
@@ -246,8 +233,7 @@ static int crash_get_memory_ranges(void)
 	/*
 	 * Make sure that the memory regions are sorted.
 	 */
-	qsort(usablemem_rgns.ranges, usablemem_rgns.size,
-	      sizeof(*usablemem_rgns.ranges), range_cmp);
+	mem_regions_sort(&usablemem_rgns);
 
 	return 0;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 22/32] arm: use generic mem_region sorting implementation
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Use the generic mem_region sorting implementation.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 85afd9f..d6db566 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -202,19 +202,6 @@ static void crash_exclude_range(void)
 	}
 }
 
-static int range_cmp(const void *a1, const void *a2)
-{
-	const struct memory_range *r1 = a1;
-	const struct memory_range *r2 = a2;
-
-	if (r1->start > r2->start)
-		return 1;
-	if (r1->start < r2->start)
-		return -1;
-
-	return 0;
-}
-
 /**
  * crash_get_memory_ranges() - read system physical memory
  *
@@ -246,8 +233,7 @@ static int crash_get_memory_ranges(void)
 	/*
 	 * Make sure that the memory regions are sorted.
 	 */
-	qsort(usablemem_rgns.ranges, usablemem_rgns.size,
-	      sizeof(*usablemem_rgns.ranges), range_cmp);
+	mem_regions_sort(&usablemem_rgns);
 
 	return 0;
 }
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 23/32] arm: move crash system RAM parsing earlier
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/Makefile        |  2 ++
 kexec/arch/arm/crashdump-arm.c | 51 ++++++++----------------------------------
 2 files changed, 11 insertions(+), 42 deletions(-)

diff --git a/kexec/arch/arm/Makefile b/kexec/arch/arm/Makefile
index 60e433a..71db8c3 100644
--- a/kexec/arch/arm/Makefile
+++ b/kexec/arch/arm/Makefile
@@ -7,6 +7,8 @@ arm_FS2DT              = kexec/fs2dt.c
 arm_FS2DT_INCLUDE      = -include $(srcdir)/kexec/arch/arm/crashdump-arm.h \
                          -include $(srcdir)/kexec/arch/arm/kexec-arm.h
 
+arm_MEM_REGIONS        = kexec/mem_regions.c
+
 arm_KEXEC_SRCS=  kexec/arch/arm/kexec-elf-rel-arm.c
 arm_KEXEC_SRCS+= kexec/arch/arm/kexec-zImage-arm.c
 arm_KEXEC_SRCS+= kexec/arch/arm/kexec-uImage-arm.c
diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index d6db566..f2e6a0d 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -30,6 +30,7 @@
 #include "../../kexec.h"
 #include "../../kexec-elf.h"
 #include "../../crashdump.h"
+#include "../../mem_regions.h"
 #include "crashdump-arm.h"
 #include "iomem.h"
 
@@ -132,39 +133,6 @@ static int get_kernel_page_offset(struct kexec_info *info,
 }
 
 /**
- * crash_range_callback() - callback called for each iomem region
- * @data: not used
- * @nr: not used
- * @str: name of the memory region
- * @base: start address of the memory region
- * @length: size of the memory region
- *
- * This function is called once for each memory region found in /proc/iomem. It
- * locates system RAM and places these into @crash_memory_ranges. Number of
- * memory regions is placed in @crash_memory_nr_ranges.
- */
-static int crash_range_callback(void *UNUSED(data), int UNUSED(nr),
-				char *str, unsigned long long base,
-				unsigned long long length)
-{
-	struct memory_range *range;
-
-	if (usablemem_rgns.size >= CRASH_MAX_MEMORY_RANGES)
-		return 1;
-
-	range = usablemem_rgns.ranges + usablemem_rgns.size;
-
-	if (strncmp(str, "System RAM\n", 11) == 0) {
-		range->start = base;
-		range->end = base + length - 1;
-		range->type = RANGE_RAM;
-		usablemem_rgns.size++;
-	}
-
-	return 0;
-}
-
-/**
  * crash_exclude_range() - excludes memory region reserved for crashkernel
  *
  * Function locates where crashkernel reserved memory is and removes that region
@@ -213,12 +181,6 @@ static void crash_exclude_range(void)
  */
 static int crash_get_memory_ranges(void)
 {
-	/*
-	 * First read all memory regions that can be considered as
-	 * system memory including the crash area.
-	 */
-	kexec_iomem_for_each_line(NULL, crash_range_callback, NULL);
-
 	if (usablemem_rgns.size < 1) {
 		errno = EINVAL;
 		return -1;
@@ -414,8 +376,9 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
  * @base: start address of the memory region
  * @length: size of the memory region
  *
- * This function is called for each memory range in /proc/iomem, and stores
- * the location of the crash kernel range into @crash_reserved_mem.
+ * This function is called for each memory range in /proc/iomem, stores
+ * the location of the crash kernel range into @crash_reserved_mem, and
+ * stores the system RAM into @usablemem_rgns.
  */
 static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 				char *str, unsigned long long base,
@@ -426,6 +389,10 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 		crash_reserved_mem.end = base + length - 1;
 		crash_reserved_mem.type = RANGE_RAM;
 	}
+	else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
+		return mem_regions_add(&usablemem_rgns,
+				       base, length, RANGE_RAM);
+	}
 	return 0;
 }
 
@@ -434,7 +401,7 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
  *
  * Check for the crashkernel reserved region in /proc/iomem, and return
  * true if it is present, or false otherwise. We use this to store the
- * location of this region.
+ * location of this region, and system RAM regions.
  */
 int is_crashkernel_mem_reserved(void)
 {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 23/32] arm: move crash system RAM parsing earlier
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/Makefile        |  2 ++
 kexec/arch/arm/crashdump-arm.c | 51 ++++++++----------------------------------
 2 files changed, 11 insertions(+), 42 deletions(-)

diff --git a/kexec/arch/arm/Makefile b/kexec/arch/arm/Makefile
index 60e433a..71db8c3 100644
--- a/kexec/arch/arm/Makefile
+++ b/kexec/arch/arm/Makefile
@@ -7,6 +7,8 @@ arm_FS2DT              = kexec/fs2dt.c
 arm_FS2DT_INCLUDE      = -include $(srcdir)/kexec/arch/arm/crashdump-arm.h \
                          -include $(srcdir)/kexec/arch/arm/kexec-arm.h
 
+arm_MEM_REGIONS        = kexec/mem_regions.c
+
 arm_KEXEC_SRCS=  kexec/arch/arm/kexec-elf-rel-arm.c
 arm_KEXEC_SRCS+= kexec/arch/arm/kexec-zImage-arm.c
 arm_KEXEC_SRCS+= kexec/arch/arm/kexec-uImage-arm.c
diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index d6db566..f2e6a0d 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -30,6 +30,7 @@
 #include "../../kexec.h"
 #include "../../kexec-elf.h"
 #include "../../crashdump.h"
+#include "../../mem_regions.h"
 #include "crashdump-arm.h"
 #include "iomem.h"
 
@@ -132,39 +133,6 @@ static int get_kernel_page_offset(struct kexec_info *info,
 }
 
 /**
- * crash_range_callback() - callback called for each iomem region
- * @data: not used
- * @nr: not used
- * @str: name of the memory region
- * @base: start address of the memory region
- * @length: size of the memory region
- *
- * This function is called once for each memory region found in /proc/iomem. It
- * locates system RAM and places these into @crash_memory_ranges. Number of
- * memory regions is placed in @crash_memory_nr_ranges.
- */
-static int crash_range_callback(void *UNUSED(data), int UNUSED(nr),
-				char *str, unsigned long long base,
-				unsigned long long length)
-{
-	struct memory_range *range;
-
-	if (usablemem_rgns.size >= CRASH_MAX_MEMORY_RANGES)
-		return 1;
-
-	range = usablemem_rgns.ranges + usablemem_rgns.size;
-
-	if (strncmp(str, "System RAM\n", 11) == 0) {
-		range->start = base;
-		range->end = base + length - 1;
-		range->type = RANGE_RAM;
-		usablemem_rgns.size++;
-	}
-
-	return 0;
-}
-
-/**
  * crash_exclude_range() - excludes memory region reserved for crashkernel
  *
  * Function locates where crashkernel reserved memory is and removes that region
@@ -213,12 +181,6 @@ static void crash_exclude_range(void)
  */
 static int crash_get_memory_ranges(void)
 {
-	/*
-	 * First read all memory regions that can be considered as
-	 * system memory including the crash area.
-	 */
-	kexec_iomem_for_each_line(NULL, crash_range_callback, NULL);
-
 	if (usablemem_rgns.size < 1) {
 		errno = EINVAL;
 		return -1;
@@ -414,8 +376,9 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
  * @base: start address of the memory region
  * @length: size of the memory region
  *
- * This function is called for each memory range in /proc/iomem, and stores
- * the location of the crash kernel range into @crash_reserved_mem.
+ * This function is called for each memory range in /proc/iomem, stores
+ * the location of the crash kernel range into @crash_reserved_mem, and
+ * stores the system RAM into @usablemem_rgns.
  */
 static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 				char *str, unsigned long long base,
@@ -426,6 +389,10 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 		crash_reserved_mem.end = base + length - 1;
 		crash_reserved_mem.type = RANGE_RAM;
 	}
+	else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
+		return mem_regions_add(&usablemem_rgns,
+				       base, length, RANGE_RAM);
+	}
 	return 0;
 }
 
@@ -434,7 +401,7 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
  *
  * Check for the crashkernel reserved region in /proc/iomem, and return
  * true if it is present, or false otherwise. We use this to store the
- * location of this region.
+ * location of this region, and system RAM regions.
  */
 int is_crashkernel_mem_reserved(void)
 {
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 24/32] arm: add support for platforms with boot memory aliases
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

The kexec API deals with boot-view addresses, rather than normal system
view addresses.  This causes problems for platforms such as Keystone 2,
where the boot view is substantially different from the normal system
view.

This is because Keystone 2 boots from a memory alias in the lower 4GiB,
before switching to a high alias at 32GiB.

We handle this in a generic way by introducing boot alias resources in
/proc/iomem:

80000000-dfffffff : System RAM (boot alias)
  9f800000-9fffffff : Crash kernel (boot alias)
800000000-85fffffff : System RAM
  800008000-800790e37 : Kernel code
  8007ec000-8008b856f : Kernel data
  81f800000-81fffffff : Crash kernel

To allow kexec to load a kernel, we need to add the boot alias of RAM
to the memory ranges returned by get_memory_ranges().  Parse the
system RAM boot alias into the memory ranges.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/iomem.h     | 2 ++
 kexec/arch/arm/kexec-arm.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/arm/iomem.h b/kexec/arch/arm/iomem.h
index 81c593d..85f958e 100644
--- a/kexec/arch/arm/iomem.h
+++ b/kexec/arch/arm/iomem.h
@@ -2,6 +2,8 @@
 #define IOMEM_H
 
 #define SYSTEM_RAM		"System RAM\n"
+#define SYSTEM_RAM_BOOT		"System RAM (boot alias)\n"
 #define CRASH_KERNEL		"Crash kernel\n"
+#define CRASH_KERNEL_BOOT	"Crash kernel (boot alias)\n"
 
 #endif
diff --git a/kexec/arch/arm/kexec-arm.c b/kexec/arch/arm/kexec-arm.c
index eeb27b4..2194b7c 100644
--- a/kexec/arch/arm/kexec-arm.c
+++ b/kexec/arch/arm/kexec-arm.c
@@ -18,6 +18,7 @@
 #include "kexec-arm.h"
 #include <arch/options.h>
 #include "../../fs2dt.h"
+#include "iomem.h"
 
 #define MAX_MEMORY_RANGES 64
 #define MAX_LINE 160
@@ -52,7 +53,8 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 			continue;
 		str = line + consumed;
 
-		if (memcmp(str, "System RAM\n", 11) == 0) {
+		if (memcmp(str, SYSTEM_RAM_BOOT, strlen(SYSTEM_RAM_BOOT)) == 0 ||
+		    memcmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
 			type = RANGE_RAM;
 		}
 		else if (memcmp(str, "reserved\n", 9) == 0) {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 24/32] arm: add support for platforms with boot memory aliases
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

The kexec API deals with boot-view addresses, rather than normal system
view addresses.  This causes problems for platforms such as Keystone 2,
where the boot view is substantially different from the normal system
view.

This is because Keystone 2 boots from a memory alias in the lower 4GiB,
before switching to a high alias at 32GiB.

We handle this in a generic way by introducing boot alias resources in
/proc/iomem:

80000000-dfffffff : System RAM (boot alias)
  9f800000-9fffffff : Crash kernel (boot alias)
800000000-85fffffff : System RAM
  800008000-800790e37 : Kernel code
  8007ec000-8008b856f : Kernel data
  81f800000-81fffffff : Crash kernel

To allow kexec to load a kernel, we need to add the boot alias of RAM
to the memory ranges returned by get_memory_ranges().  Parse the
system RAM boot alias into the memory ranges.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/iomem.h     | 2 ++
 kexec/arch/arm/kexec-arm.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/arm/iomem.h b/kexec/arch/arm/iomem.h
index 81c593d..85f958e 100644
--- a/kexec/arch/arm/iomem.h
+++ b/kexec/arch/arm/iomem.h
@@ -2,6 +2,8 @@
 #define IOMEM_H
 
 #define SYSTEM_RAM		"System RAM\n"
+#define SYSTEM_RAM_BOOT		"System RAM (boot alias)\n"
 #define CRASH_KERNEL		"Crash kernel\n"
+#define CRASH_KERNEL_BOOT	"Crash kernel (boot alias)\n"
 
 #endif
diff --git a/kexec/arch/arm/kexec-arm.c b/kexec/arch/arm/kexec-arm.c
index eeb27b4..2194b7c 100644
--- a/kexec/arch/arm/kexec-arm.c
+++ b/kexec/arch/arm/kexec-arm.c
@@ -18,6 +18,7 @@
 #include "kexec-arm.h"
 #include <arch/options.h>
 #include "../../fs2dt.h"
+#include "iomem.h"
 
 #define MAX_MEMORY_RANGES 64
 #define MAX_LINE 160
@@ -52,7 +53,8 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 			continue;
 		str = line + consumed;
 
-		if (memcmp(str, "System RAM\n", 11) == 0) {
+		if (memcmp(str, SYSTEM_RAM_BOOT, strlen(SYSTEM_RAM_BOOT)) == 0 ||
+		    memcmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
 			type = RANGE_RAM;
 		}
 		else if (memcmp(str, "reserved\n", 9) == 0) {
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 25/32] arm: crashdump needs boot alias of crash kernel region
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

When crashdumping, we need the boot memory alias of the crash kernel
region rather than the system view.  Arrange to check for the boot
alias of the crash kernel region first, and if found, use it instead
of the main alias.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-zImage-arm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 4755f06..fdd2910 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -20,6 +20,7 @@
 #include "kexec-arm.h"
 #include "../../fs2dt.h"
 #include "crashdump-arm.h"
+#include "iomem.h"
 
 #define BOOT_PARAMS_SIZE 1536
 
@@ -446,7 +447,8 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 		 * We put the dump capture kernel at the start of crashkernel
 		 * reserved memory.
 		 */
-		if (parse_iomem_single("Crash kernel\n", &start, &end)) {
+		if (parse_iomem_single(CRASH_KERNEL_BOOT, &start, &end) &&
+		    parse_iomem_single(CRASH_KERNEL, &start, &end)) {
 			/*
 			 * No crash kernel memory reserved. We cannot do more
 			 * but just bail out.
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 25/32] arm: crashdump needs boot alias of crash kernel region
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

When crashdumping, we need the boot memory alias of the crash kernel
region rather than the system view.  Arrange to check for the boot
alias of the crash kernel region first, and if found, use it instead
of the main alias.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/kexec-zImage-arm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 4755f06..fdd2910 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -20,6 +20,7 @@
 #include "kexec-arm.h"
 #include "../../fs2dt.h"
 #include "crashdump-arm.h"
+#include "iomem.h"
 
 #define BOOT_PARAMS_SIZE 1536
 
@@ -446,7 +447,8 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 		 * We put the dump capture kernel at the start of crashkernel
 		 * reserved memory.
 		 */
-		if (parse_iomem_single("Crash kernel\n", &start, &end)) {
+		if (parse_iomem_single(CRASH_KERNEL_BOOT, &start, &end) &&
+		    parse_iomem_single(CRASH_KERNEL, &start, &end)) {
 			/*
 			 * No crash kernel memory reserved. We cannot do more
 			 * but just bail out.
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 26/32] arm: rename crash_reserved_mem to crash_kernel_mem
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:00   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

Rename crash_reserved_mem to crash_kernel_mem as we want to support
multiple reserved memory ranges.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index f2e6a0d..1a6ab88 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -53,7 +53,7 @@ struct memory_ranges usablemem_rgns = {
 };
 
 /* memory range reserved for crashkernel */
-static struct memory_range crash_reserved_mem;
+static struct memory_range crash_kernel_mem;
 
 static struct crash_elf_info elf_info = {
 	.class		= ELFCLASS32,
@@ -140,7 +140,7 @@ static int get_kernel_page_offset(struct kexec_info *info,
  */
 static void crash_exclude_range(void)
 {
-	const struct memory_range *range = &crash_reserved_mem;
+	const struct memory_range *range = &crash_kernel_mem;
 	int i;
 
 	for (i = 0; i < usablemem_rgns.size; i++) {
@@ -262,8 +262,8 @@ static void dump_memory_ranges(void)
 		return;
 
 	dbgprintf("crashkernel: [%#llx - %#llx] (%ldM)\n",
-		  crash_reserved_mem.start, crash_reserved_mem.end,
-		  (unsigned long)range_size(&crash_reserved_mem) >> 20);
+		  crash_kernel_mem.start, crash_kernel_mem.end,
+		  (unsigned long)range_size(&crash_kernel_mem) >> 20);
 
 	for (i = 0; i < usablemem_rgns.size; i++) {
 		struct memory_range *r = usablemem_rgns.ranges + i;
@@ -313,10 +313,10 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * Ensure that the crash kernel memory range is sane. The crash kernel
 	 * must be located within memory which is visible during booting.
 	 */
-	if (crash_reserved_mem.end > ARM_MAX_VIRTUAL) {
+	if (crash_kernel_mem.end > ARM_MAX_VIRTUAL) {
 		fprintf(stderr,
 			"Crash kernel memory [0x%llx-0x%llx] is inaccessible at boot - unable to load crash kernel\n",
-			crash_reserved_mem.start, crash_reserved_mem.end);
+			crash_kernel_mem.start, crash_kernel_mem.end);
 		return -1;
 	}
 
@@ -349,8 +349,8 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * regions to be aligned to SECTION_SIZE.
 	 */
 	elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << 20,
-					  crash_reserved_mem.start,
-					  crash_reserved_mem.end, -1, 0);
+					  crash_kernel_mem.start,
+					  crash_kernel_mem.end, -1, 0);
 
 	dbgprintf("elfcorehdr: %#lx\n", elfcorehdr);
 	cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr);
@@ -360,7 +360,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * prevents the dump capture kernel from using any other memory regions
 	 * which belong to the primary kernel.
 	 */
-	cmdline_add_mem(mod_cmdline, elfcorehdr - crash_reserved_mem.start);
+	cmdline_add_mem(mod_cmdline, elfcorehdr - crash_kernel_mem.start);
 
 	dump_memory_ranges();
 	dbgprintf("kernel command line: \"%s\"\n", mod_cmdline);
@@ -377,7 +377,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
  * @length: size of the memory region
  *
  * This function is called for each memory range in /proc/iomem, stores
- * the location of the crash kernel range into @crash_reserved_mem, and
+ * the location of the crash kernel range into @crash_kernel_mem, and
  * stores the system RAM into @usablemem_rgns.
  */
 static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
@@ -385,9 +385,9 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 				unsigned long long length)
 {
 	if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) {
-		crash_reserved_mem.start = base;
-		crash_reserved_mem.end = base + length - 1;
-		crash_reserved_mem.type = RANGE_RAM;
+		crash_kernel_mem.start = base;
+		crash_kernel_mem.end = base + length - 1;
+		crash_kernel_mem.type = RANGE_RAM;
 	}
 	else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
 		return mem_regions_add(&usablemem_rgns,
@@ -407,5 +407,5 @@ int is_crashkernel_mem_reserved(void)
 {
 	kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL);
 
-	return crash_reserved_mem.start != crash_reserved_mem.end;
+	return crash_kernel_mem.start != crash_kernel_mem.end;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 26/32] arm: rename crash_reserved_mem to crash_kernel_mem
@ 2016-06-06 17:00   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:00 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Rename crash_reserved_mem to crash_kernel_mem as we want to support
multiple reserved memory ranges.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index f2e6a0d..1a6ab88 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -53,7 +53,7 @@ struct memory_ranges usablemem_rgns = {
 };
 
 /* memory range reserved for crashkernel */
-static struct memory_range crash_reserved_mem;
+static struct memory_range crash_kernel_mem;
 
 static struct crash_elf_info elf_info = {
 	.class		= ELFCLASS32,
@@ -140,7 +140,7 @@ static int get_kernel_page_offset(struct kexec_info *info,
  */
 static void crash_exclude_range(void)
 {
-	const struct memory_range *range = &crash_reserved_mem;
+	const struct memory_range *range = &crash_kernel_mem;
 	int i;
 
 	for (i = 0; i < usablemem_rgns.size; i++) {
@@ -262,8 +262,8 @@ static void dump_memory_ranges(void)
 		return;
 
 	dbgprintf("crashkernel: [%#llx - %#llx] (%ldM)\n",
-		  crash_reserved_mem.start, crash_reserved_mem.end,
-		  (unsigned long)range_size(&crash_reserved_mem) >> 20);
+		  crash_kernel_mem.start, crash_kernel_mem.end,
+		  (unsigned long)range_size(&crash_kernel_mem) >> 20);
 
 	for (i = 0; i < usablemem_rgns.size; i++) {
 		struct memory_range *r = usablemem_rgns.ranges + i;
@@ -313,10 +313,10 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * Ensure that the crash kernel memory range is sane. The crash kernel
 	 * must be located within memory which is visible during booting.
 	 */
-	if (crash_reserved_mem.end > ARM_MAX_VIRTUAL) {
+	if (crash_kernel_mem.end > ARM_MAX_VIRTUAL) {
 		fprintf(stderr,
 			"Crash kernel memory [0x%llx-0x%llx] is inaccessible at boot - unable to load crash kernel\n",
-			crash_reserved_mem.start, crash_reserved_mem.end);
+			crash_kernel_mem.start, crash_kernel_mem.end);
 		return -1;
 	}
 
@@ -349,8 +349,8 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * regions to be aligned to SECTION_SIZE.
 	 */
 	elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << 20,
-					  crash_reserved_mem.start,
-					  crash_reserved_mem.end, -1, 0);
+					  crash_kernel_mem.start,
+					  crash_kernel_mem.end, -1, 0);
 
 	dbgprintf("elfcorehdr: %#lx\n", elfcorehdr);
 	cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr);
@@ -360,7 +360,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * prevents the dump capture kernel from using any other memory regions
 	 * which belong to the primary kernel.
 	 */
-	cmdline_add_mem(mod_cmdline, elfcorehdr - crash_reserved_mem.start);
+	cmdline_add_mem(mod_cmdline, elfcorehdr - crash_kernel_mem.start);
 
 	dump_memory_ranges();
 	dbgprintf("kernel command line: \"%s\"\n", mod_cmdline);
@@ -377,7 +377,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
  * @length: size of the memory region
  *
  * This function is called for each memory range in /proc/iomem, stores
- * the location of the crash kernel range into @crash_reserved_mem, and
+ * the location of the crash kernel range into @crash_kernel_mem, and
  * stores the system RAM into @usablemem_rgns.
  */
 static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
@@ -385,9 +385,9 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 				unsigned long long length)
 {
 	if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) {
-		crash_reserved_mem.start = base;
-		crash_reserved_mem.end = base + length - 1;
-		crash_reserved_mem.type = RANGE_RAM;
+		crash_kernel_mem.start = base;
+		crash_kernel_mem.end = base + length - 1;
+		crash_kernel_mem.type = RANGE_RAM;
 	}
 	else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
 		return mem_regions_add(&usablemem_rgns,
@@ -407,5 +407,5 @@ int is_crashkernel_mem_reserved(void)
 {
 	kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL);
 
-	return crash_reserved_mem.start != crash_reserved_mem.end;
+	return crash_kernel_mem.start != crash_kernel_mem.end;
 }
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 27/32] arm: add support for multiple reserved regions
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:01   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: linux-arm-kernel

Add support for reserving multiple memory regions rather than just a
single region.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 66 ++++++++++++++++--------------------------
 1 file changed, 25 insertions(+), 41 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 1a6ab88..9113f5e 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -55,6 +55,14 @@ struct memory_ranges usablemem_rgns = {
 /* memory range reserved for crashkernel */
 static struct memory_range crash_kernel_mem;
 
+/* reserved regions */
+#define CRASH_MAX_RESERVED_RANGES 2
+static struct memory_range crash_reserved_ranges[CRASH_MAX_RESERVED_RANGES];
+static struct memory_ranges crash_reserved_rgns = {
+	.max_size = CRASH_MAX_RESERVED_RANGES,
+	.ranges = crash_reserved_ranges,
+};
+
 static struct crash_elf_info elf_info = {
 	.class		= ELFCLASS32,
 	.data		= ELFDATANATIVE,
@@ -133,44 +141,6 @@ static int get_kernel_page_offset(struct kexec_info *info,
 }
 
 /**
- * crash_exclude_range() - excludes memory region reserved for crashkernel
- *
- * Function locates where crashkernel reserved memory is and removes that region
- * from the available memory regions.
- */
-static void crash_exclude_range(void)
-{
-	const struct memory_range *range = &crash_kernel_mem;
-	int i;
-
-	for (i = 0; i < usablemem_rgns.size; i++) {
-		struct memory_range *r = usablemem_rgns.ranges + i;
-
-		/*
-		 * We assume that crash area is fully contained in
-		 * some larger memory area.
-		 */
-		if (r->start <= range->start && r->end >= range->end) {
-			struct memory_range *new;
-			/*
-			 * Let's split this area into 2 smaller ones and
-			 * remove excluded range from between. First create
-			 * new entry for the remaining area.
-			 */
-			new = usablemem_rgns.ranges + usablemem_rgns.size;
-			new->start = range->end + 1;
-			new->end = r->end;
-			usablemem_rgns.size++;
-			/*
-			 * Next update this area to end before excluded range.
-			 */
-			r->end = range->start - 1;
-			break;
-		}
-	}
-}
-
-/**
  * crash_get_memory_ranges() - read system physical memory
  *
  * Function reads through system physical memory and stores found memory regions
@@ -181,16 +151,28 @@ static void crash_exclude_range(void)
  */
 static int crash_get_memory_ranges(void)
 {
+	int i;
+
 	if (usablemem_rgns.size < 1) {
 		errno = EINVAL;
 		return -1;
 	}
 
 	/*
-	 * Exclude memory reserved for crashkernel (this may result a split memory
-	 * region).
+	 * Exclude all reserved memory from the usable memory regions.
+	 * We want to avoid dumping the crashkernel region itself.  Note
+	 * that this may result memory regions in usablemem_rgns being
+	 * split.
 	 */
-	crash_exclude_range();
+	for (i = 0; i < crash_reserved_rgns.size; i++) {
+		if (mem_regions_exclude(&usablemem_rgns,
+					&crash_reserved_rgns.ranges[i])) {
+			fprintf(stderr,
+				"Error: Number of crash memory ranges excedeed the max limit\n");
+			errno = ENOMEM;
+			return -1;
+		}
+	}
 
 	/*
 	 * Make sure that the memory regions are sorted.
@@ -388,6 +370,8 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 		crash_kernel_mem.start = base;
 		crash_kernel_mem.end = base + length - 1;
 		crash_kernel_mem.type = RANGE_RAM;
+		return mem_regions_add(&crash_reserved_rgns,
+				       base, length, RANGE_RAM);
 	}
 	else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
 		return mem_regions_add(&usablemem_rgns,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 27/32] arm: add support for multiple reserved regions
@ 2016-06-06 17:01   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Add support for reserving multiple memory regions rather than just a
single region.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 66 ++++++++++++++++--------------------------
 1 file changed, 25 insertions(+), 41 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 1a6ab88..9113f5e 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -55,6 +55,14 @@ struct memory_ranges usablemem_rgns = {
 /* memory range reserved for crashkernel */
 static struct memory_range crash_kernel_mem;
 
+/* reserved regions */
+#define CRASH_MAX_RESERVED_RANGES 2
+static struct memory_range crash_reserved_ranges[CRASH_MAX_RESERVED_RANGES];
+static struct memory_ranges crash_reserved_rgns = {
+	.max_size = CRASH_MAX_RESERVED_RANGES,
+	.ranges = crash_reserved_ranges,
+};
+
 static struct crash_elf_info elf_info = {
 	.class		= ELFCLASS32,
 	.data		= ELFDATANATIVE,
@@ -133,44 +141,6 @@ static int get_kernel_page_offset(struct kexec_info *info,
 }
 
 /**
- * crash_exclude_range() - excludes memory region reserved for crashkernel
- *
- * Function locates where crashkernel reserved memory is and removes that region
- * from the available memory regions.
- */
-static void crash_exclude_range(void)
-{
-	const struct memory_range *range = &crash_kernel_mem;
-	int i;
-
-	for (i = 0; i < usablemem_rgns.size; i++) {
-		struct memory_range *r = usablemem_rgns.ranges + i;
-
-		/*
-		 * We assume that crash area is fully contained in
-		 * some larger memory area.
-		 */
-		if (r->start <= range->start && r->end >= range->end) {
-			struct memory_range *new;
-			/*
-			 * Let's split this area into 2 smaller ones and
-			 * remove excluded range from between. First create
-			 * new entry for the remaining area.
-			 */
-			new = usablemem_rgns.ranges + usablemem_rgns.size;
-			new->start = range->end + 1;
-			new->end = r->end;
-			usablemem_rgns.size++;
-			/*
-			 * Next update this area to end before excluded range.
-			 */
-			r->end = range->start - 1;
-			break;
-		}
-	}
-}
-
-/**
  * crash_get_memory_ranges() - read system physical memory
  *
  * Function reads through system physical memory and stores found memory regions
@@ -181,16 +151,28 @@ static void crash_exclude_range(void)
  */
 static int crash_get_memory_ranges(void)
 {
+	int i;
+
 	if (usablemem_rgns.size < 1) {
 		errno = EINVAL;
 		return -1;
 	}
 
 	/*
-	 * Exclude memory reserved for crashkernel (this may result a split memory
-	 * region).
+	 * Exclude all reserved memory from the usable memory regions.
+	 * We want to avoid dumping the crashkernel region itself.  Note
+	 * that this may result memory regions in usablemem_rgns being
+	 * split.
 	 */
-	crash_exclude_range();
+	for (i = 0; i < crash_reserved_rgns.size; i++) {
+		if (mem_regions_exclude(&usablemem_rgns,
+					&crash_reserved_rgns.ranges[i])) {
+			fprintf(stderr,
+				"Error: Number of crash memory ranges excedeed the max limit\n");
+			errno = ENOMEM;
+			return -1;
+		}
+	}
 
 	/*
 	 * Make sure that the memory regions are sorted.
@@ -388,6 +370,8 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 		crash_kernel_mem.start = base;
 		crash_kernel_mem.end = base + length - 1;
 		crash_kernel_mem.type = RANGE_RAM;
+		return mem_regions_add(&crash_reserved_rgns,
+				       base, length, RANGE_RAM);
 	}
 	else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
 		return mem_regions_add(&usablemem_rgns,
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 28/32] arm: add support for boot-time crash kernel resource
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:01   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: linux-arm-kernel

Add support for detecting and using the boot-time crash kernel
resource, which is needed for systems which have special boot-time
memory views, such as Keystone 2.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 9113f5e..25fdbe9 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -52,7 +52,7 @@ struct memory_ranges usablemem_rgns = {
 	.ranges = crash_memory_ranges,
 };
 
-/* memory range reserved for crashkernel */
+/* The boot-time physical memory range reserved for crashkernel region */
 static struct memory_range crash_kernel_mem;
 
 /* reserved regions */
@@ -366,13 +366,22 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 				char *str, unsigned long long base,
 				unsigned long long length)
 {
-	if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) {
+	if (strncmp(str, CRASH_KERNEL_BOOT, strlen(CRASH_KERNEL_BOOT)) == 0) {
 		crash_kernel_mem.start = base;
 		crash_kernel_mem.end = base + length - 1;
 		crash_kernel_mem.type = RANGE_RAM;
 		return mem_regions_add(&crash_reserved_rgns,
 				       base, length, RANGE_RAM);
 	}
+	else if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) {
+		if (crash_kernel_mem.start == crash_kernel_mem.end) {
+			crash_kernel_mem.start = base;
+			crash_kernel_mem.end = base + length - 1;
+			crash_kernel_mem.type = RANGE_RAM;
+		}
+		return mem_regions_add(&crash_reserved_rgns,
+				       base, length, RANGE_RAM);
+	}
 	else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
 		return mem_regions_add(&usablemem_rgns,
 				       base, length, RANGE_RAM);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 28/32] arm: add support for boot-time crash kernel resource
@ 2016-06-06 17:01   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Add support for detecting and using the boot-time crash kernel
resource, which is needed for systems which have special boot-time
memory views, such as Keystone 2.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 9113f5e..25fdbe9 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -52,7 +52,7 @@ struct memory_ranges usablemem_rgns = {
 	.ranges = crash_memory_ranges,
 };
 
-/* memory range reserved for crashkernel */
+/* The boot-time physical memory range reserved for crashkernel region */
 static struct memory_range crash_kernel_mem;
 
 /* reserved regions */
@@ -366,13 +366,22 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
 				char *str, unsigned long long base,
 				unsigned long long length)
 {
-	if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) {
+	if (strncmp(str, CRASH_KERNEL_BOOT, strlen(CRASH_KERNEL_BOOT)) == 0) {
 		crash_kernel_mem.start = base;
 		crash_kernel_mem.end = base + length - 1;
 		crash_kernel_mem.type = RANGE_RAM;
 		return mem_regions_add(&crash_reserved_rgns,
 				       base, length, RANGE_RAM);
 	}
+	else if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) {
+		if (crash_kernel_mem.start == crash_kernel_mem.end) {
+			crash_kernel_mem.start = base;
+			crash_kernel_mem.end = base + length - 1;
+			crash_kernel_mem.type = RANGE_RAM;
+		}
+		return mem_regions_add(&crash_reserved_rgns,
+				       base, length, RANGE_RAM);
+	}
 	else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) {
 		return mem_regions_add(&usablemem_rgns,
 				       base, length, RANGE_RAM);
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 29/32] arm: add debug of reserved and coredump memory ranges
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:01   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: linux-arm-kernel

Add debug of the reserved and coredump memory ranges for validation.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 25fdbe9..2dc8846 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -158,6 +158,10 @@ static int crash_get_memory_ranges(void)
 		return -1;
 	}
 
+	dbgprint_mem_range("Reserved memory ranges",
+			   crash_reserved_rgns.ranges,
+			   crash_reserved_rgns.size);
+
 	/*
 	 * Exclude all reserved memory from the usable memory regions.
 	 * We want to avoid dumping the crashkernel region itself.  Note
@@ -179,6 +183,9 @@ static int crash_get_memory_ranges(void)
 	 */
 	mem_regions_sort(&usablemem_rgns);
 
+	dbgprint_mem_range("Coredump memory ranges",
+			   usablemem_rgns.ranges, usablemem_rgns.size);
+
 	return 0;
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 29/32] arm: add debug of reserved and coredump memory ranges
@ 2016-06-06 17:01   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Add debug of the reserved and coredump memory ranges for validation.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 25fdbe9..2dc8846 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -158,6 +158,10 @@ static int crash_get_memory_ranges(void)
 		return -1;
 	}
 
+	dbgprint_mem_range("Reserved memory ranges",
+			   crash_reserved_rgns.ranges,
+			   crash_reserved_rgns.size);
+
 	/*
 	 * Exclude all reserved memory from the usable memory regions.
 	 * We want to avoid dumping the crashkernel region itself.  Note
@@ -179,6 +183,9 @@ static int crash_get_memory_ranges(void)
 	 */
 	mem_regions_sort(&usablemem_rgns);
 
+	dbgprint_mem_range("Coredump memory ranges",
+			   usablemem_rgns.ranges, usablemem_rgns.size);
+
 	return 0;
 }
 
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 30/32] arm: fix type of phys_offset
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:01   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: linux-arm-kernel

Some LPAE systems may have phys_offset above the 4GB mark.  Hence, we
need phys_offset to be a 64-bit integer.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 4 ++--
 kexec/arch/arm/crashdump-arm.h | 1 -
 kexec/arch/arm/phys_to_virt.c  | 4 +++-
 kexec/arch/arm/phys_to_virt.h  | 8 ++++++++
 4 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 kexec/arch/arm/phys_to_virt.h

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 2dc8846..2589582 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -33,6 +33,7 @@
 #include "../../mem_regions.h"
 #include "crashdump-arm.h"
 #include "iomem.h"
+#include "phys_to_virt.h"
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define ELFDATANATIVE ELFDATA2LSB
@@ -70,7 +71,6 @@ static struct crash_elf_info elf_info = {
 	.page_offset	= DEFAULT_PAGE_OFFSET,
 };
 
-unsigned long phys_offset;
 extern unsigned long long user_page_offset;
 
 /* Retrieve kernel _stext symbol virtual address from /proc/kallsyms */
@@ -293,7 +293,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * region as PHYS_OFFSET.
 	 */
 	phys_offset = usablemem_rgns.ranges->start;
-	dbgprintf("phys_offset: %#lx\n", phys_offset);
+	dbgprintf("phys_offset: %#llx\n", phys_offset);
 
 	if (get_kernel_page_offset(info, &elf_info))
 		return -1;
diff --git a/kexec/arch/arm/crashdump-arm.h b/kexec/arch/arm/crashdump-arm.h
index 7314960..6e87b13 100644
--- a/kexec/arch/arm/crashdump-arm.h
+++ b/kexec/arch/arm/crashdump-arm.h
@@ -16,7 +16,6 @@ extern struct memory_ranges usablemem_rgns;
 
 struct kexec_info;
 
-extern unsigned long phys_offset;
 extern int load_crashdump_segments(struct kexec_info *, char *);
 
 #ifdef __cplusplus
diff --git a/kexec/arch/arm/phys_to_virt.c b/kexec/arch/arm/phys_to_virt.c
index c2fe2ea..46a4f68 100644
--- a/kexec/arch/arm/phys_to_virt.c
+++ b/kexec/arch/arm/phys_to_virt.c
@@ -1,6 +1,8 @@
 #include "../../kexec.h"
 #include "../../crashdump.h"
-#include "crashdump-arm.h"
+#include "phys_to_virt.h"
+
+uint64_t phys_offset;
 
 /**
  * phys_to_virt() - translate physical address to virtual address
diff --git a/kexec/arch/arm/phys_to_virt.h b/kexec/arch/arm/phys_to_virt.h
new file mode 100644
index 0000000..b3147dd
--- /dev/null
+++ b/kexec/arch/arm/phys_to_virt.h
@@ -0,0 +1,8 @@
+#ifndef PHYS_TO_VIRT_H
+#define PHYS_TO_VIRT_H
+
+#include <stdint.h>
+
+extern uint64_t phys_offset;
+
+#endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 30/32] arm: fix type of phys_offset
@ 2016-06-06 17:01   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Some LPAE systems may have phys_offset above the 4GB mark.  Hence, we
need phys_offset to be a 64-bit integer.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 4 ++--
 kexec/arch/arm/crashdump-arm.h | 1 -
 kexec/arch/arm/phys_to_virt.c  | 4 +++-
 kexec/arch/arm/phys_to_virt.h  | 8 ++++++++
 4 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 kexec/arch/arm/phys_to_virt.h

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 2dc8846..2589582 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -33,6 +33,7 @@
 #include "../../mem_regions.h"
 #include "crashdump-arm.h"
 #include "iomem.h"
+#include "phys_to_virt.h"
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define ELFDATANATIVE ELFDATA2LSB
@@ -70,7 +71,6 @@ static struct crash_elf_info elf_info = {
 	.page_offset	= DEFAULT_PAGE_OFFSET,
 };
 
-unsigned long phys_offset;
 extern unsigned long long user_page_offset;
 
 /* Retrieve kernel _stext symbol virtual address from /proc/kallsyms */
@@ -293,7 +293,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * region as PHYS_OFFSET.
 	 */
 	phys_offset = usablemem_rgns.ranges->start;
-	dbgprintf("phys_offset: %#lx\n", phys_offset);
+	dbgprintf("phys_offset: %#llx\n", phys_offset);
 
 	if (get_kernel_page_offset(info, &elf_info))
 		return -1;
diff --git a/kexec/arch/arm/crashdump-arm.h b/kexec/arch/arm/crashdump-arm.h
index 7314960..6e87b13 100644
--- a/kexec/arch/arm/crashdump-arm.h
+++ b/kexec/arch/arm/crashdump-arm.h
@@ -16,7 +16,6 @@ extern struct memory_ranges usablemem_rgns;
 
 struct kexec_info;
 
-extern unsigned long phys_offset;
 extern int load_crashdump_segments(struct kexec_info *, char *);
 
 #ifdef __cplusplus
diff --git a/kexec/arch/arm/phys_to_virt.c b/kexec/arch/arm/phys_to_virt.c
index c2fe2ea..46a4f68 100644
--- a/kexec/arch/arm/phys_to_virt.c
+++ b/kexec/arch/arm/phys_to_virt.c
@@ -1,6 +1,8 @@
 #include "../../kexec.h"
 #include "../../crashdump.h"
-#include "crashdump-arm.h"
+#include "phys_to_virt.h"
+
+uint64_t phys_offset;
 
 /**
  * phys_to_virt() - translate physical address to virtual address
diff --git a/kexec/arch/arm/phys_to_virt.h b/kexec/arch/arm/phys_to_virt.h
new file mode 100644
index 0000000..b3147dd
--- /dev/null
+++ b/kexec/arch/arm/phys_to_virt.h
@@ -0,0 +1,8 @@
+#ifndef PHYS_TO_VIRT_H
+#define PHYS_TO_VIRT_H
+
+#include <stdint.h>
+
+extern uint64_t phys_offset;
+
+#endif
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 31/32] arm: clean up phys/page offset debug
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:01   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: linux-arm-kernel

Clean up the physical and page offset debug prints.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 2589582..3b71267 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -136,7 +136,6 @@ static int get_kernel_page_offset(struct kexec_info *info,
 				user_page_offset);
 	}
 	elf_info->page_offset = stext_sym_addr & (~KVBASE_MASK);
-	dbgprintf("page_offset is set to %llx\n", elf_info->page_offset);
 	return 0;
 }
 
@@ -293,11 +292,13 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * region as PHYS_OFFSET.
 	 */
 	phys_offset = usablemem_rgns.ranges->start;
-	dbgprintf("phys_offset: %#llx\n", phys_offset);
 
 	if (get_kernel_page_offset(info, &elf_info))
 		return -1;
 
+	dbgprintf("phys offset = %#llx, page offset = %llx\n",
+		  phys_offset, elf_info.page_offset);
+
 	/*
 	 * Ensure that the crash kernel memory range is sane. The crash kernel
 	 * must be located within memory which is visible during booting.
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 31/32] arm: clean up phys/page offset debug
@ 2016-06-06 17:01   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Clean up the physical and page offset debug prints.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 2589582..3b71267 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -136,7 +136,6 @@ static int get_kernel_page_offset(struct kexec_info *info,
 				user_page_offset);
 	}
 	elf_info->page_offset = stext_sym_addr & (~KVBASE_MASK);
-	dbgprintf("page_offset is set to %llx\n", elf_info->page_offset);
 	return 0;
 }
 
@@ -293,11 +292,13 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	 * region as PHYS_OFFSET.
 	 */
 	phys_offset = usablemem_rgns.ranges->start;
-	dbgprintf("phys_offset: %#llx\n", phys_offset);
 
 	if (get_kernel_page_offset(info, &elf_info))
 		return -1;
 
+	dbgprintf("phys offset = %#llx, page offset = %llx\n",
+		  phys_offset, elf_info.page_offset);
+
 	/*
 	 * Ensure that the crash kernel memory range is sane. The crash kernel
 	 * must be located within memory which is visible during booting.
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 32/32] arm: report which ELF core format we will use
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-06 17:01   ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: linux-arm-kernel

Report which ELF core format will be used to create the template ELF
core dump in the debug information.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 3b71267..4a89b5e 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -315,6 +315,8 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 		last_ranges = 0;
 
 	if (crash_memory_ranges[last_ranges].end > UINT32_MAX) {
+		dbgprintf("Using 64-bit ELF core format\n");
+
 		/* for support LPAE enabled kernel*/
 		elf_info.class = ELFCLASS64;
 
@@ -323,6 +325,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 					 usablemem_rgns.size, &buf, &bufsz,
 					 ELF_CORE_HEADER_ALIGN);
 	} else {
+		dbgprintf("Using 32-bit ELF core format\n");
 		err = crash_create_elf32_headers(info, &elf_info,
 					 usablemem_rgns.ranges,
 					 usablemem_rgns.size, &buf, &bufsz,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 32/32] arm: report which ELF core format we will use
@ 2016-06-06 17:01   ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-06 17:01 UTC (permalink / raw)
  To: kexec, linux-arm-kernel; +Cc: Pratyush Anand, Baoquan He

Report which ELF core format will be used to create the template ELF
core dump in the debug information.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 kexec/arch/arm/crashdump-arm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 3b71267..4a89b5e 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -315,6 +315,8 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 		last_ranges = 0;
 
 	if (crash_memory_ranges[last_ranges].end > UINT32_MAX) {
+		dbgprintf("Using 64-bit ELF core format\n");
+
 		/* for support LPAE enabled kernel*/
 		elf_info.class = ELFCLASS64;
 
@@ -323,6 +325,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 					 usablemem_rgns.size, &buf, &bufsz,
 					 ELF_CORE_HEADER_ALIGN);
 	} else {
+		dbgprintf("Using 32-bit ELF core format\n");
 		err = crash_create_elf32_headers(info, &elf_info,
 					 usablemem_rgns.ranges,
 					 usablemem_rgns.size, &buf, &bufsz,
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 04/32] kdump: fix kdump mapping
  2016-06-06 16:59   ` Russell King
@ 2016-06-07  2:05     ` Pratyush Anand
  -1 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-07  2:05 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/06/2016:05:59:03 PM, Russell King wrote:
> When kdump tries to map the program header, it fails to take account
> of ehdr->e_phoff being an offset from the start of the ELF "file",
> which causes:
> 
> Cannot mmap /dev/mem offset: 64 size: 392: Invalid argument
> 
> Ensure that we take account of the start address when mapping this.
> 
> This fix has been extracted from a larger patch by Vitaly Andrianov
> adding support for Keystone 2.
> 
> Signed-off-by: Russell King <rmk@arm.linux.org.uk>
Reviewed-by: Pratyush Anand <panand@redhat.com>
> ---
>  kdump/kdump.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kdump/kdump.c b/kdump/kdump.c
> index 1f5b984..34d2149 100644
> --- a/kdump/kdump.c
> +++ b/kdump/kdump.c
> @@ -284,7 +284,8 @@ int main(int argc, char **argv)
>  	}
>  	
>  	/* Get the program header */
> -	phdr = map_addr(fd, sizeof(*phdr)*(ehdr->e_phnum), ehdr->e_phoff);
> +	phdr = map_addr(fd, sizeof(*phdr)*(ehdr->e_phnum), 
> +			start_addr + ehdr->e_phoff);
>  
>  	/* Collect up the notes */
>  	note_bytes = 0;
> -- 
> 1.9.1

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH kexec-tools v2 04/32] kdump: fix kdump mapping
@ 2016-06-07  2:05     ` Pratyush Anand
  0 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-07  2:05 UTC (permalink / raw)
  To: Russell King; +Cc: kexec, Baoquan He, linux-arm-kernel

On 06/06/2016:05:59:03 PM, Russell King wrote:
> When kdump tries to map the program header, it fails to take account
> of ehdr->e_phoff being an offset from the start of the ELF "file",
> which causes:
> 
> Cannot mmap /dev/mem offset: 64 size: 392: Invalid argument
> 
> Ensure that we take account of the start address when mapping this.
> 
> This fix has been extracted from a larger patch by Vitaly Andrianov
> adding support for Keystone 2.
> 
> Signed-off-by: Russell King <rmk@arm.linux.org.uk>
Reviewed-by: Pratyush Anand <panand@redhat.com>
> ---
>  kdump/kdump.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kdump/kdump.c b/kdump/kdump.c
> index 1f5b984..34d2149 100644
> --- a/kdump/kdump.c
> +++ b/kdump/kdump.c
> @@ -284,7 +284,8 @@ int main(int argc, char **argv)
>  	}
>  	
>  	/* Get the program header */
> -	phdr = map_addr(fd, sizeof(*phdr)*(ehdr->e_phnum), ehdr->e_phoff);
> +	phdr = map_addr(fd, sizeof(*phdr)*(ehdr->e_phnum), 
> +			start_addr + ehdr->e_phoff);
>  
>  	/* Collect up the notes */
>  	note_bytes = 0;
> -- 
> 1.9.1

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 12/32] kexec: add helper to exlude a region from a set of memory ranges
  2016-06-06 16:59   ` Russell King
@ 2016-06-07  4:55     ` Pratyush Anand
  -1 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-07  4:55 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/06/2016:05:59:44 PM, Russell King wrote:
> Add a helper to exclude a region from a set of memory ranges.
> 
> Signed-off-by: Russell King <rmk@arm.linux.org.uk>

Reviewed-by: Pratyush Anand <panand@redhat.com>
> ---
>  kexec/mem_regions.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  kexec/mem_regions.h |  4 +++
>  2 files changed, 75 insertions(+)
> 
> diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
> index 804984a..b01a5c8 100644
> --- a/kexec/mem_regions.c
> +++ b/kexec/mem_regions.c
> @@ -55,3 +55,74 @@ int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
>  	return 0;
>  }
>  
> +static void mem_regions_remove(struct memory_ranges *ranges, int index)
> +{
> +	int tail_entries;
> +
> +	/* we are assured to have at least one entry */
> +	ranges->size -= 1;
> +
> +	/* if we have following entries, shuffle them down one place */
> +	tail_entries = ranges->size - index;
> +	if (tail_entries)
> +		memmove(ranges->ranges + index, ranges->ranges + index + 1,
> +			tail_entries * sizeof(*ranges->ranges));
> +
> +	/* zero the new tail entry */
> +	memset(ranges->ranges + ranges->size, 0, sizeof(*ranges->ranges));
> +}
> +
> +/**
> + * mem_regions_exclude() - excludes a memory region from a set of memory ranges
> + * @ranges: memory ranges to exclude the region from
> + * @range: memory range to exclude
> + *
> + * Exclude a memory region from a set of memory ranges.  We assume that
> + * the region to be excluded is either wholely located within one of the
> + * memory ranges, or not at all.
> + */
> +int mem_regions_exclude(struct memory_ranges *ranges,
> +			const struct memory_range *range)
> +{
> +	int i, ret;
> +
> +	for (i = 0; i < ranges->size; i++) {
> +		struct memory_range *r = ranges->ranges + i;
> +
> +		/*
> +		 * We assume that crash area is fully contained in
> +		 * some larger memory area.
> +		 */
> +		if (r->start <= range->start && r->end >= range->end) {
> +			if (r->start == range->start) {
> +				if (r->end == range->end)
> +					/* Remove this entry */
> +					mem_regions_remove(ranges, i);
> +				else
> +					/* Shrink the start of this memory range */
> +					r->start = range->end + 1;
> +			} else if (r->end == range->end) {
> +				/* Shrink the end of this memory range */
> +				r->end = range->start - 1;
> +			} else {
> +				/*
> +				 * Split this area into 2 smaller ones and
> +				 * remove excluded range from between. First
> +				 * create new entry for the remaining area.
> +				 */
> +				ret = mem_regions_add(ranges, range->end + 1,
> +						      r->end - range->end, 0);
> +				if (ret < 0)
> +					return ret;
> +
> +				/*
> +				 * Update this area to end before excluded
> +				 * range.
> +				 */
> +				r->end = range->start - 1;
> +				break;
> +			}
> +		}
> +	}
> +	return 0;
> +}
> diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
> index da7b5e8..ae9e972 100644
> --- a/kexec/mem_regions.h
> +++ b/kexec/mem_regions.h
> @@ -2,9 +2,13 @@
>  #define MEM_REGIONS_H
>  
>  struct memory_ranges;
> +struct memory_range;
>  
>  void mem_regions_sort(struct memory_ranges *ranges);
>  
> +int mem_regions_exclude(struct memory_ranges *ranges,
> +			const struct memory_range *range);
> +
>  int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
>                      unsigned long long length, int type);
>  
> -- 
> 1.9.1

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH kexec-tools v2 12/32] kexec: add helper to exlude a region from a set of memory ranges
@ 2016-06-07  4:55     ` Pratyush Anand
  0 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-07  4:55 UTC (permalink / raw)
  To: Russell King; +Cc: kexec, Baoquan He, linux-arm-kernel

On 06/06/2016:05:59:44 PM, Russell King wrote:
> Add a helper to exclude a region from a set of memory ranges.
> 
> Signed-off-by: Russell King <rmk@arm.linux.org.uk>

Reviewed-by: Pratyush Anand <panand@redhat.com>
> ---
>  kexec/mem_regions.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  kexec/mem_regions.h |  4 +++
>  2 files changed, 75 insertions(+)
> 
> diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
> index 804984a..b01a5c8 100644
> --- a/kexec/mem_regions.c
> +++ b/kexec/mem_regions.c
> @@ -55,3 +55,74 @@ int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
>  	return 0;
>  }
>  
> +static void mem_regions_remove(struct memory_ranges *ranges, int index)
> +{
> +	int tail_entries;
> +
> +	/* we are assured to have at least one entry */
> +	ranges->size -= 1;
> +
> +	/* if we have following entries, shuffle them down one place */
> +	tail_entries = ranges->size - index;
> +	if (tail_entries)
> +		memmove(ranges->ranges + index, ranges->ranges + index + 1,
> +			tail_entries * sizeof(*ranges->ranges));
> +
> +	/* zero the new tail entry */
> +	memset(ranges->ranges + ranges->size, 0, sizeof(*ranges->ranges));
> +}
> +
> +/**
> + * mem_regions_exclude() - excludes a memory region from a set of memory ranges
> + * @ranges: memory ranges to exclude the region from
> + * @range: memory range to exclude
> + *
> + * Exclude a memory region from a set of memory ranges.  We assume that
> + * the region to be excluded is either wholely located within one of the
> + * memory ranges, or not at all.
> + */
> +int mem_regions_exclude(struct memory_ranges *ranges,
> +			const struct memory_range *range)
> +{
> +	int i, ret;
> +
> +	for (i = 0; i < ranges->size; i++) {
> +		struct memory_range *r = ranges->ranges + i;
> +
> +		/*
> +		 * We assume that crash area is fully contained in
> +		 * some larger memory area.
> +		 */
> +		if (r->start <= range->start && r->end >= range->end) {
> +			if (r->start == range->start) {
> +				if (r->end == range->end)
> +					/* Remove this entry */
> +					mem_regions_remove(ranges, i);
> +				else
> +					/* Shrink the start of this memory range */
> +					r->start = range->end + 1;
> +			} else if (r->end == range->end) {
> +				/* Shrink the end of this memory range */
> +				r->end = range->start - 1;
> +			} else {
> +				/*
> +				 * Split this area into 2 smaller ones and
> +				 * remove excluded range from between. First
> +				 * create new entry for the remaining area.
> +				 */
> +				ret = mem_regions_add(ranges, range->end + 1,
> +						      r->end - range->end, 0);
> +				if (ret < 0)
> +					return ret;
> +
> +				/*
> +				 * Update this area to end before excluded
> +				 * range.
> +				 */
> +				r->end = range->start - 1;
> +				break;
> +			}
> +		}
> +	}
> +	return 0;
> +}
> diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
> index da7b5e8..ae9e972 100644
> --- a/kexec/mem_regions.h
> +++ b/kexec/mem_regions.h
> @@ -2,9 +2,13 @@
>  #define MEM_REGIONS_H
>  
>  struct memory_ranges;
> +struct memory_range;
>  
>  void mem_regions_sort(struct memory_ranges *ranges);
>  
> +int mem_regions_exclude(struct memory_ranges *ranges,
> +			const struct memory_range *range);
> +
>  int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
>                      unsigned long long length, int type);
>  
> -- 
> 1.9.1

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 16/32] arm: fix ELF32/ELF64 check
  2016-06-06 17:00   ` Russell King
@ 2016-06-07  5:41     ` Pratyush Anand
  -1 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-07  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/06/2016:06:00:05 PM, Russell King wrote:
> Rather than using ULONG_MAX to decide whether to use the ELF64 or ELF32
> core dump format, use UINT32_MAX instead - we include stdint.h, so we
> might as well use a constant which is meaningful for the limits of
> the 32-bit ELF format.
> 
> Signed-off-by: Russell King <rmk@arm.linux.org.uk>

Reviewed-by: Pratyush Anand <panand@redhat.com>
> ---
>  kexec/arch/arm/crashdump-arm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
> index a390187..fcc4d42 100644
> --- a/kexec/arch/arm/crashdump-arm.c
> +++ b/kexec/arch/arm/crashdump-arm.c
> @@ -369,8 +369,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
>  	if (last_ranges < 0)
>  		last_ranges = 0;
>  
> -	if (crash_memory_ranges[last_ranges].end > ULONG_MAX) {
> -
> +	if (crash_memory_ranges[last_ranges].end > UINT32_MAX) {
>  		/* for support LPAE enabled kernel*/
>  		elf_info.class = ELFCLASS64;
>  
> -- 
> 1.9.1

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH kexec-tools v2 16/32] arm: fix ELF32/ELF64 check
@ 2016-06-07  5:41     ` Pratyush Anand
  0 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-07  5:41 UTC (permalink / raw)
  To: Russell King; +Cc: kexec, Baoquan He, linux-arm-kernel

On 06/06/2016:06:00:05 PM, Russell King wrote:
> Rather than using ULONG_MAX to decide whether to use the ELF64 or ELF32
> core dump format, use UINT32_MAX instead - we include stdint.h, so we
> might as well use a constant which is meaningful for the limits of
> the 32-bit ELF format.
> 
> Signed-off-by: Russell King <rmk@arm.linux.org.uk>

Reviewed-by: Pratyush Anand <panand@redhat.com>
> ---
>  kexec/arch/arm/crashdump-arm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
> index a390187..fcc4d42 100644
> --- a/kexec/arch/arm/crashdump-arm.c
> +++ b/kexec/arch/arm/crashdump-arm.c
> @@ -369,8 +369,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
>  	if (last_ranges < 0)
>  		last_ranges = 0;
>  
> -	if (crash_memory_ranges[last_ranges].end > ULONG_MAX) {
> -
> +	if (crash_memory_ranges[last_ranges].end > UINT32_MAX) {
>  		/* for support LPAE enabled kernel*/
>  		elf_info.class = ELFCLASS64;
>  
> -- 
> 1.9.1

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 18/32] arm: report if crash kernel is out of bounds
  2016-06-06 17:00   ` Russell King
@ 2016-06-07  5:41     ` Pratyush Anand
  -1 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-07  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/06/2016:06:00:16 PM, Russell King wrote:
> Report an error if the crash kernel memory region is outside of the
> boot-view memory range - this can happen with systems such as
> Keystone 2.
> 
> Signed-off-by: Russell King <rmk@arm.linux.org.uk>
Reviewed-by: Pratyush Anand <panand@redhat.com> 
> ---
>  kexec/arch/arm/crashdump-arm.c | 11 +++++++++++
>  kexec/arch/arm/crashdump-arm.h |  1 +
>  2 files changed, 12 insertions(+)
> 
> diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
> index fcc4d42..739c906 100644
> --- a/kexec/arch/arm/crashdump-arm.c
> +++ b/kexec/arch/arm/crashdump-arm.c
> @@ -365,6 +365,17 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
>  	if (get_kernel_page_offset(info, &elf_info))
>  		return -1;
>  
> +	/*
> +	 * Ensure that the crash kernel memory range is sane. The crash kernel
> +	 * must be located within memory which is visible during booting.
> +	 */
> +	if (crash_reserved_mem.end > ARM_MAX_VIRTUAL) {
> +		fprintf(stderr,
> +			"Crash kernel memory [0x%llx-0x%llx] is inaccessible at boot - unable to load crash kernel\n",
> +			crash_reserved_mem.start, crash_reserved_mem.end);
> +		return -1;
> +	}
> +
>  	last_ranges = usablemem_rgns.size - 1;
>  	if (last_ranges < 0)
>  		last_ranges = 0;
> diff --git a/kexec/arch/arm/crashdump-arm.h b/kexec/arch/arm/crashdump-arm.h
> index 2dbde04..7314960 100644
> --- a/kexec/arch/arm/crashdump-arm.h
> +++ b/kexec/arch/arm/crashdump-arm.h
> @@ -9,6 +9,7 @@ extern "C" {
>  #define DEFAULT_PAGE_OFFSET		(0xc0000000)
>  #define KVBASE_MASK	(0x1ffffff)
>  #define CRASH_MAX_MEMORY_RANGES	32
> +#define ARM_MAX_VIRTUAL		UINT32_MAX
>  
>  
>  extern struct memory_ranges usablemem_rgns;
> -- 
> 1.9.1

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH kexec-tools v2 18/32] arm: report if crash kernel is out of bounds
@ 2016-06-07  5:41     ` Pratyush Anand
  0 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-07  5:41 UTC (permalink / raw)
  To: Russell King; +Cc: kexec, Baoquan He, linux-arm-kernel

On 06/06/2016:06:00:16 PM, Russell King wrote:
> Report an error if the crash kernel memory region is outside of the
> boot-view memory range - this can happen with systems such as
> Keystone 2.
> 
> Signed-off-by: Russell King <rmk@arm.linux.org.uk>
Reviewed-by: Pratyush Anand <panand@redhat.com> 
> ---
>  kexec/arch/arm/crashdump-arm.c | 11 +++++++++++
>  kexec/arch/arm/crashdump-arm.h |  1 +
>  2 files changed, 12 insertions(+)
> 
> diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
> index fcc4d42..739c906 100644
> --- a/kexec/arch/arm/crashdump-arm.c
> +++ b/kexec/arch/arm/crashdump-arm.c
> @@ -365,6 +365,17 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
>  	if (get_kernel_page_offset(info, &elf_info))
>  		return -1;
>  
> +	/*
> +	 * Ensure that the crash kernel memory range is sane. The crash kernel
> +	 * must be located within memory which is visible during booting.
> +	 */
> +	if (crash_reserved_mem.end > ARM_MAX_VIRTUAL) {
> +		fprintf(stderr,
> +			"Crash kernel memory [0x%llx-0x%llx] is inaccessible at boot - unable to load crash kernel\n",
> +			crash_reserved_mem.start, crash_reserved_mem.end);
> +		return -1;
> +	}
> +
>  	last_ranges = usablemem_rgns.size - 1;
>  	if (last_ranges < 0)
>  		last_ranges = 0;
> diff --git a/kexec/arch/arm/crashdump-arm.h b/kexec/arch/arm/crashdump-arm.h
> index 2dbde04..7314960 100644
> --- a/kexec/arch/arm/crashdump-arm.h
> +++ b/kexec/arch/arm/crashdump-arm.h
> @@ -9,6 +9,7 @@ extern "C" {
>  #define DEFAULT_PAGE_OFFSET		(0xc0000000)
>  #define KVBASE_MASK	(0x1ffffff)
>  #define CRASH_MAX_MEMORY_RANGES	32
> +#define ARM_MAX_VIRTUAL		UINT32_MAX
>  
>  
>  extern struct memory_ranges usablemem_rgns;
> -- 
> 1.9.1

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 00/32] Keystone II updates for kexec tools
  2016-06-06 16:41 ` Russell King - ARM Linux
@ 2016-06-08  0:27   ` Simon Horman
  -1 siblings, 0 replies; 86+ messages in thread
From: Simon Horman @ 2016-06-08  0:27 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Russell,

On Mon, Jun 06, 2016 at 05:41:29PM +0100, Russell King - ARM Linux wrote:
> Here's the latest set of kexec-tools patches to support Keystone II
> platforms, which work in conjunction with the kernel patches which
> Andrew Morton has already taken.
> 
> Most of the patches have been reviewed, but there are a small number
> which do not have Reviewed-by or Acked-by tags; these are due to
> comments, which I've replied to, which have yet to have further
> responses.

I see that Pratyush has now reviewed the patches which did not
have any Reviewed-by or Acked-by tags. I have applied the series.
Please let me know if I messed anything up.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH kexec-tools v2 00/32] Keystone II updates for kexec tools
@ 2016-06-08  0:27   ` Simon Horman
  0 siblings, 0 replies; 86+ messages in thread
From: Simon Horman @ 2016-06-08  0:27 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Pratyush Anand, kexec, Baoquan He, linux-arm-kernel

Hi Russell,

On Mon, Jun 06, 2016 at 05:41:29PM +0100, Russell King - ARM Linux wrote:
> Here's the latest set of kexec-tools patches to support Keystone II
> platforms, which work in conjunction with the kernel patches which
> Andrew Morton has already taken.
> 
> Most of the patches have been reviewed, but there are a small number
> which do not have Reviewed-by or Acked-by tags; these are due to
> comments, which I've replied to, which have yet to have further
> responses.

I see that Pratyush has now reviewed the patches which did not
have any Reviewed-by or Acked-by tags. I have applied the series.
Please let me know if I messed anything up.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 10/32] kexec: add generic helper to add to memory_regions
  2016-06-06 16:59   ` Russell King
@ 2016-06-08  1:13     ` Baoquan He
  -1 siblings, 0 replies; 86+ messages in thread
From: Baoquan He @ 2016-06-08  1:13 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/06/16 at 05:59pm, Russell King wrote:
> diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
> new file mode 100644
> index 0000000..a4952ff
> --- /dev/null
> +++ b/kexec/mem_regions.c
> @@ -0,0 +1,30 @@
> +#include "kexec.h"
> +#include "mem_regions.h"
> +
> +/**
> + * mem_regions_add() - add a memory region to a set of ranges
> + * @ranges: ranges to add the memory region to
> + * @max: maximum number of entries in memory region

This need be removed. It should be a remnant of intermediate attempt.

> + * @base: base address of memory region
> + * @length: length of memory region in bytes
> + * @type: type of memory region
> + *
> + * Add the memory region to the set of ranges, and return %0 if successful,
> + * or %-1 if we ran out of space.
> + */
> +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
> +                    unsigned long long length, int type)
> +{
> +	struct memory_range *range;
> +
> +	if (ranges->size >= ranges->max_size)
> +		return -1;
> +
> +	range = ranges->ranges + ranges->size++;
> +	range->start = base;
> +	range->end = base + length - 1;
> +	range->type = type;
> +
> +	return 0;
> +}
> +
> diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
> new file mode 100644
> index 0000000..b9cfba1
> --- /dev/null
> +++ b/kexec/mem_regions.h
> @@ -0,0 +1,9 @@
> +#ifndef MEM_REGIONS_H
> +#define MEM_REGIONS_H
> +
> +struct memory_ranges;
> +
> +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
> +                    unsigned long long length, int type);
> +
> +#endif
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH kexec-tools v2 10/32] kexec: add generic helper to add to memory_regions
@ 2016-06-08  1:13     ` Baoquan He
  0 siblings, 0 replies; 86+ messages in thread
From: Baoquan He @ 2016-06-08  1:13 UTC (permalink / raw)
  To: Russell King; +Cc: Pratyush Anand, kexec, linux-arm-kernel

On 06/06/16 at 05:59pm, Russell King wrote:
> diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
> new file mode 100644
> index 0000000..a4952ff
> --- /dev/null
> +++ b/kexec/mem_regions.c
> @@ -0,0 +1,30 @@
> +#include "kexec.h"
> +#include "mem_regions.h"
> +
> +/**
> + * mem_regions_add() - add a memory region to a set of ranges
> + * @ranges: ranges to add the memory region to
> + * @max: maximum number of entries in memory region

This need be removed. It should be a remnant of intermediate attempt.

> + * @base: base address of memory region
> + * @length: length of memory region in bytes
> + * @type: type of memory region
> + *
> + * Add the memory region to the set of ranges, and return %0 if successful,
> + * or %-1 if we ran out of space.
> + */
> +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
> +                    unsigned long long length, int type)
> +{
> +	struct memory_range *range;
> +
> +	if (ranges->size >= ranges->max_size)
> +		return -1;
> +
> +	range = ranges->ranges + ranges->size++;
> +	range->start = base;
> +	range->end = base + length - 1;
> +	range->type = type;
> +
> +	return 0;
> +}
> +
> diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
> new file mode 100644
> index 0000000..b9cfba1
> --- /dev/null
> +++ b/kexec/mem_regions.h
> @@ -0,0 +1,9 @@
> +#ifndef MEM_REGIONS_H
> +#define MEM_REGIONS_H
> +
> +struct memory_ranges;
> +
> +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
> +                    unsigned long long length, int type);
> +
> +#endif
> -- 
> 1.9.1
> 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH kexec-tools v2 10/32] kexec: add generic helper to add to memory_regions
  2016-06-08  1:13     ` Baoquan He
@ 2016-06-08  1:22       ` Simon Horman
  -1 siblings, 0 replies; 86+ messages in thread
From: Simon Horman @ 2016-06-08  1:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 08, 2016 at 09:13:44AM +0800, Baoquan He wrote:
> On 06/06/16 at 05:59pm, Russell King wrote:
> > diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
> > new file mode 100644
> > index 0000000..a4952ff
> > --- /dev/null
> > +++ b/kexec/mem_regions.c
> > @@ -0,0 +1,30 @@
> > +#include "kexec.h"
> > +#include "mem_regions.h"
> > +
> > +/**
> > + * mem_regions_add() - add a memory region to a set of ranges
> > + * @ranges: ranges to add the memory region to
> > + * @max: maximum number of entries in memory region
> 
> This need be removed. It should be a remnant of intermediate attempt.

Russell,

Please fix this as a follow-up patch as I applied the series earlier
this morning.

> > + * @base: base address of memory region
> > + * @length: length of memory region in bytes
> > + * @type: type of memory region
> > + *
> > + * Add the memory region to the set of ranges, and return %0 if successful,
> > + * or %-1 if we ran out of space.
> > + */
> > +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
> > +                    unsigned long long length, int type)
> > +{
> > +	struct memory_range *range;
> > +
> > +	if (ranges->size >= ranges->max_size)
> > +		return -1;
> > +
> > +	range = ranges->ranges + ranges->size++;
> > +	range->start = base;
> > +	range->end = base + length - 1;
> > +	range->type = type;
> > +
> > +	return 0;
> > +}
> > +
> > diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
> > new file mode 100644
> > index 0000000..b9cfba1
> > --- /dev/null
> > +++ b/kexec/mem_regions.h
> > @@ -0,0 +1,9 @@
> > +#ifndef MEM_REGIONS_H
> > +#define MEM_REGIONS_H
> > +
> > +struct memory_ranges;
> > +
> > +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
> > +                    unsigned long long length, int type);
> > +
> > +#endif
> > -- 
> > 1.9.1
> > 
> 
> _______________________________________________
> kexec mailing list
> kexec at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH kexec-tools v2 10/32] kexec: add generic helper to add to memory_regions
@ 2016-06-08  1:22       ` Simon Horman
  0 siblings, 0 replies; 86+ messages in thread
From: Simon Horman @ 2016-06-08  1:22 UTC (permalink / raw)
  To: Baoquan He; +Cc: Pratyush Anand, kexec, linux-arm-kernel, Russell King

On Wed, Jun 08, 2016 at 09:13:44AM +0800, Baoquan He wrote:
> On 06/06/16 at 05:59pm, Russell King wrote:
> > diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
> > new file mode 100644
> > index 0000000..a4952ff
> > --- /dev/null
> > +++ b/kexec/mem_regions.c
> > @@ -0,0 +1,30 @@
> > +#include "kexec.h"
> > +#include "mem_regions.h"
> > +
> > +/**
> > + * mem_regions_add() - add a memory region to a set of ranges
> > + * @ranges: ranges to add the memory region to
> > + * @max: maximum number of entries in memory region
> 
> This need be removed. It should be a remnant of intermediate attempt.

Russell,

Please fix this as a follow-up patch as I applied the series earlier
this morning.

> > + * @base: base address of memory region
> > + * @length: length of memory region in bytes
> > + * @type: type of memory region
> > + *
> > + * Add the memory region to the set of ranges, and return %0 if successful,
> > + * or %-1 if we ran out of space.
> > + */
> > +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
> > +                    unsigned long long length, int type)
> > +{
> > +	struct memory_range *range;
> > +
> > +	if (ranges->size >= ranges->max_size)
> > +		return -1;
> > +
> > +	range = ranges->ranges + ranges->size++;
> > +	range->start = base;
> > +	range->end = base + length - 1;
> > +	range->type = type;
> > +
> > +	return 0;
> > +}
> > +
> > diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
> > new file mode 100644
> > index 0000000..b9cfba1
> > --- /dev/null
> > +++ b/kexec/mem_regions.h
> > @@ -0,0 +1,9 @@
> > +#ifndef MEM_REGIONS_H
> > +#define MEM_REGIONS_H
> > +
> > +struct memory_ranges;
> > +
> > +int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
> > +                    unsigned long long length, int type);
> > +
> > +#endif
> > -- 
> > 1.9.1
> > 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH] Remove "max" parameter comment
  2016-06-08  1:22       ` Simon Horman
@ 2016-06-09 16:18         ` Russell King
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-09 16:18 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the "max" parameter in the documentation for mem_regions_add()

Signed-off-by: Russell King <rmk@armlinux.org.uk>
---
 kexec/mem_regions.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
index b01a5c89..e61c0747 100644
--- a/kexec/mem_regions.c
+++ b/kexec/mem_regions.c
@@ -31,7 +31,6 @@ void mem_regions_sort(struct memory_ranges *ranges)
 /**
  * mem_regions_add() - add a memory region to a set of ranges
  * @ranges: ranges to add the memory region to
- * @max: maximum number of entries in memory region
  * @base: base address of memory region
  * @length: length of memory region in bytes
  * @type: type of memory region
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH] Remove "max" parameter comment
@ 2016-06-09 16:18         ` Russell King
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King @ 2016-06-09 16:18 UTC (permalink / raw)
  To: Simon Horman; +Cc: Pratyush Anand, kexec, linux-arm-kernel, Baoquan He

Remove the "max" parameter in the documentation for mem_regions_add()

Signed-off-by: Russell King <rmk@armlinux.org.uk>
---
 kexec/mem_regions.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
index b01a5c89..e61c0747 100644
--- a/kexec/mem_regions.c
+++ b/kexec/mem_regions.c
@@ -31,7 +31,6 @@ void mem_regions_sort(struct memory_ranges *ranges)
 /**
  * mem_regions_add() - add a memory region to a set of ranges
  * @ranges: ranges to add the memory region to
- * @max: maximum number of entries in memory region
  * @base: base address of memory region
  * @length: length of memory region in bytes
  * @type: type of memory region
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH] Remove "max" parameter comment
  2016-06-09 16:18         ` Russell King
@ 2016-06-09 17:06           ` Pratyush Anand
  -1 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-09 17:06 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/06/2016:05:18:08 PM, Russell King wrote:
> Remove the "max" parameter in the documentation for mem_regions_add()
> 
> Signed-off-by: Russell King <rmk@armlinux.org.uk>
Reviewed-by: Pratyush Anand <panand@redhat.com> 
> ---
>  kexec/mem_regions.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
> index b01a5c89..e61c0747 100644
> --- a/kexec/mem_regions.c
> +++ b/kexec/mem_regions.c
> @@ -31,7 +31,6 @@ void mem_regions_sort(struct memory_ranges *ranges)
>  /**
>   * mem_regions_add() - add a memory region to a set of ranges
>   * @ranges: ranges to add the memory region to
> - * @max: maximum number of entries in memory region
>   * @base: base address of memory region
>   * @length: length of memory region in bytes
>   * @type: type of memory region
> -- 
> 1.9.1

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH] Remove "max" parameter comment
@ 2016-06-09 17:06           ` Pratyush Anand
  0 siblings, 0 replies; 86+ messages in thread
From: Pratyush Anand @ 2016-06-09 17:06 UTC (permalink / raw)
  To: Russell King; +Cc: Simon Horman, kexec, linux-arm-kernel, Baoquan He

On 09/06/2016:05:18:08 PM, Russell King wrote:
> Remove the "max" parameter in the documentation for mem_regions_add()
> 
> Signed-off-by: Russell King <rmk@armlinux.org.uk>
Reviewed-by: Pratyush Anand <panand@redhat.com> 
> ---
>  kexec/mem_regions.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
> index b01a5c89..e61c0747 100644
> --- a/kexec/mem_regions.c
> +++ b/kexec/mem_regions.c
> @@ -31,7 +31,6 @@ void mem_regions_sort(struct memory_ranges *ranges)
>  /**
>   * mem_regions_add() - add a memory region to a set of ranges
>   * @ranges: ranges to add the memory region to
> - * @max: maximum number of entries in memory region
>   * @base: base address of memory region
>   * @length: length of memory region in bytes
>   * @type: type of memory region
> -- 
> 1.9.1

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH] Remove "max" parameter comment
  2016-06-09 16:18         ` Russell King
@ 2016-06-23  0:40           ` Simon Horman
  -1 siblings, 0 replies; 86+ messages in thread
From: Simon Horman @ 2016-06-23  0:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jun 09, 2016 at 05:18:08PM +0100, Russell King wrote:
> Remove the "max" parameter in the documentation for mem_regions_add()
> 
> Signed-off-by: Russell King <rmk@armlinux.org.uk>

Thanks, applied.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH] Remove "max" parameter comment
@ 2016-06-23  0:40           ` Simon Horman
  0 siblings, 0 replies; 86+ messages in thread
From: Simon Horman @ 2016-06-23  0:40 UTC (permalink / raw)
  To: Russell King; +Cc: Pratyush Anand, kexec, linux-arm-kernel, Baoquan He

On Thu, Jun 09, 2016 at 05:18:08PM +0100, Russell King wrote:
> Remove the "max" parameter in the documentation for mem_regions_add()
> 
> Signed-off-by: Russell King <rmk@armlinux.org.uk>

Thanks, applied.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 86+ messages in thread

end of thread, other threads:[~2016-06-23  0:40 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-06 16:41 [PATCH kexec-tools v2 00/32] Keystone II updates for kexec tools Russell King - ARM Linux
2016-06-06 16:41 ` Russell King - ARM Linux
2016-06-06 16:58 ` [PATCH kexec-tools v2 01/32] kdump: mmap() and munmap() only work on page-aligned quantites Russell King
2016-06-06 16:58   ` Russell King
2016-06-06 16:58 ` [PATCH kexec-tools v2 02/32] kdump: fix multiple program header entries Russell King
2016-06-06 16:58   ` Russell King
2016-06-06 16:58 ` [PATCH kexec-tools v2 03/32] kdump: actually write out the memory Russell King
2016-06-06 16:58   ` Russell King
2016-06-06 16:59 ` [PATCH kexec-tools v2 04/32] kdump: fix kdump mapping Russell King
2016-06-06 16:59   ` Russell King
2016-06-07  2:05   ` Pratyush Anand
2016-06-07  2:05     ` Pratyush Anand
2016-06-06 16:59 ` [PATCH kexec-tools v2 05/32] arm: fix kdump to work on LPAE systems Russell King
2016-06-06 16:59   ` Russell King
2016-06-06 16:59 ` [PATCH kexec-tools v2 06/32] kdump: print mmap() offset in hex Russell King
2016-06-06 16:59   ` Russell King
2016-06-06 16:59 ` [PATCH kexec-tools v2 07/32] kexec: fix warnings caused by selecting 64-bit file IO on 32-bit platforms Russell King
2016-06-06 16:59   ` Russell King
2016-06-06 16:59 ` [PATCH kexec-tools v2 08/32] kexec: add max_size to memory_ranges Russell King
2016-06-06 16:59   ` Russell King
2016-06-06 16:59 ` [PATCH kexec-tools v2 09/32] kexec: phys_to_virt() must take unsigned long long Russell King
2016-06-06 16:59   ` Russell King
2016-06-06 16:59 ` [PATCH kexec-tools v2 10/32] kexec: add generic helper to add to memory_regions Russell King
2016-06-06 16:59   ` Russell King
2016-06-08  1:13   ` Baoquan He
2016-06-08  1:13     ` Baoquan He
2016-06-08  1:22     ` Simon Horman
2016-06-08  1:22       ` Simon Horman
2016-06-09 16:18       ` [PATCH] Remove "max" parameter comment Russell King
2016-06-09 16:18         ` Russell King
2016-06-09 17:06         ` Pratyush Anand
2016-06-09 17:06           ` Pratyush Anand
2016-06-23  0:40         ` Simon Horman
2016-06-23  0:40           ` Simon Horman
2016-06-06 16:59 ` [PATCH kexec-tools v2 11/32] kexec: add mem_regions sorting implementation Russell King
2016-06-06 16:59   ` Russell King
2016-06-06 16:59 ` [PATCH kexec-tools v2 12/32] kexec: add helper to exlude a region from a set of memory ranges Russell King
2016-06-06 16:59   ` Russell King
2016-06-07  4:55   ` Pratyush Anand
2016-06-07  4:55     ` Pratyush Anand
2016-06-06 16:59 ` [PATCH kexec-tools v2 13/32] arm: fix pointer signedness warning in kexec-uImage-arm.c Russell King
2016-06-06 16:59   ` Russell King
2016-06-06 16:59 ` [PATCH kexec-tools v2 14/32] arm: fix off-by-one on memory end Russell King
2016-06-06 16:59   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 15/32] arm: fix get_kernel_stext_sym() to close its file Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 16/32] arm: fix ELF32/ELF64 check Russell King
2016-06-06 17:00   ` Russell King
2016-06-07  5:41   ` Pratyush Anand
2016-06-07  5:41     ` Pratyush Anand
2016-06-06 17:00 ` [PATCH kexec-tools v2 17/32] arm: return proper error for missing crash kernel Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 18/32] arm: report if crash kernel is out of bounds Russell King
2016-06-06 17:00   ` Russell King
2016-06-07  5:41   ` Pratyush Anand
2016-06-07  5:41     ` Pratyush Anand
2016-06-06 17:00 ` [PATCH kexec-tools v2 19/32] arm: add memory ranges debug Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 20/32] arm: add maximum number of memory ranges Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 21/32] arm: parse crash_reserved_mem early Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 22/32] arm: use generic mem_region sorting implementation Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 23/32] arm: move crash system RAM parsing earlier Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 24/32] arm: add support for platforms with boot memory aliases Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 25/32] arm: crashdump needs boot alias of crash kernel region Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:00 ` [PATCH kexec-tools v2 26/32] arm: rename crash_reserved_mem to crash_kernel_mem Russell King
2016-06-06 17:00   ` Russell King
2016-06-06 17:01 ` [PATCH kexec-tools v2 27/32] arm: add support for multiple reserved regions Russell King
2016-06-06 17:01   ` Russell King
2016-06-06 17:01 ` [PATCH kexec-tools v2 28/32] arm: add support for boot-time crash kernel resource Russell King
2016-06-06 17:01   ` Russell King
2016-06-06 17:01 ` [PATCH kexec-tools v2 29/32] arm: add debug of reserved and coredump memory ranges Russell King
2016-06-06 17:01   ` Russell King
2016-06-06 17:01 ` [PATCH kexec-tools v2 30/32] arm: fix type of phys_offset Russell King
2016-06-06 17:01   ` Russell King
2016-06-06 17:01 ` [PATCH kexec-tools v2 31/32] arm: clean up phys/page offset debug Russell King
2016-06-06 17:01   ` Russell King
2016-06-06 17:01 ` [PATCH kexec-tools v2 32/32] arm: report which ELF core format we will use Russell King
2016-06-06 17:01   ` Russell King
2016-06-08  0:27 ` [PATCH kexec-tools v2 00/32] Keystone II updates for kexec tools Simon Horman
2016-06-08  0:27   ` Simon Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.