public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges
@ 2013-01-11  8:57 Zhang Yanfei
  2013-01-11  8:58 ` [PATCH 2/2] kexec: add additional check when getting memory info Zhang Yanfei
  2013-01-15  4:56 ` [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges Zhang Yanfei
  0 siblings, 2 replies; 5+ messages in thread
From: Zhang Yanfei @ 2013-01-11  8:57 UTC (permalink / raw)
  To: horms; +Cc: kexec@lists.infradead.org

At first, we have already filled the kexec_info.memory_ranges by
calling my_load() -> get_memory_ranges(). So if we want to
get the memory information, we could just use the existing
one instead of calling get_memory_ranges again.

Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
---
 kexec/arch/i386/kexec-bzImage.c       |    2 +-
 kexec/arch/i386/kexec-elf-x86.c       |    2 +-
 kexec/arch/i386/kexec-multiboot-x86.c |    7 ++-----
 kexec/arch/i386/x86-linux-setup.c     |   10 ++++------
 kexec/arch/i386/x86-linux-setup.h     |    4 ++--
 kexec/arch/x86_64/kexec-elf-x86_64.c  |    2 +-
 6 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
index 0605909..83a023d 100644
--- a/kexec/arch/i386/kexec-bzImage.c
+++ b/kexec/arch/i386/kexec-bzImage.c
@@ -324,7 +324,7 @@ int do_bzImage_load(struct kexec_info *info,
 
 	/* Fill in the information BIOS calls would normally provide. */
 	if (!real_mode_entry) {
-		setup_linux_system_parameters(real_mode, info->kexec_flags);
+		setup_linux_system_parameters(info, real_mode);
 	}
 
 	return 0;
diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
index 8bd5ef6..e62ebcb 100644
--- a/kexec/arch/i386/kexec-elf-x86.c
+++ b/kexec/arch/i386/kexec-elf-x86.c
@@ -272,7 +272,7 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 			ramdisk_buf, ramdisk_length);
 
 		/* Fill in the information bios calls would usually provide */
-		setup_linux_system_parameters(&hdr->hdr, info->kexec_flags);
+		setup_linux_system_parameters(info, &hdr->hdr);
 
 		/* Initialize the registers */
 		elf_rel_get_symbol(&info->rhdr, "entry32_regs", &regs, sizeof(regs));
diff --git a/kexec/arch/i386/kexec-multiboot-x86.c b/kexec/arch/i386/kexec-multiboot-x86.c
index 23dab7b..de2a423 100644
--- a/kexec/arch/i386/kexec-multiboot-x86.c
+++ b/kexec/arch/i386/kexec-multiboot-x86.c
@@ -248,11 +248,8 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
 	mbi->boot_loader_name = sizeof(*mbi) + command_line_len; 
 
 	/* Memory map */
-	if ((get_memory_ranges(&range, &ranges, info->kexec_flags) < 0)
-			|| ranges == 0) {
-		fprintf(stderr, "Cannot get memory information\n");
-		return -1;
-	}
+	range = info->memory_range;
+	ranges = info->memory_ranges;
 	mmap = xmalloc(ranges * sizeof(*mmap));
 	for (i=0; i<ranges; i++) {
 		unsigned long long length;
diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
index b7ab8ea..ef62553 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -441,8 +441,8 @@ close:
 	close(data_file);
 }
 
-void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
-					unsigned long kexec_flags)
+void setup_linux_system_parameters(struct kexec_info *info,
+				   struct x86_linux_param_header *real_mode)
 {
 	/* Fill in information the BIOS would usually provide */
 	struct memory_range *range;
@@ -486,10 +486,8 @@ void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
 	/* another safe default */
 	real_mode->aux_device_info = 0;
 
-	/* Fill in the memory info */
-	if ((get_memory_ranges(&range, &ranges, kexec_flags) < 0) || ranges == 0) {
-		die("Cannot get memory information\n");
-	}
+	range = info->memory_range;
+	ranges = info->memory_ranges;
 	if (ranges > E820MAX) {
 		fprintf(stderr, "Too many memory ranges, truncating...\n");
 		ranges = E820MAX;
diff --git a/kexec/arch/i386/x86-linux-setup.h b/kexec/arch/i386/x86-linux-setup.h
index 8862513..96fbd33 100644
--- a/kexec/arch/i386/x86-linux-setup.h
+++ b/kexec/arch/i386/x86-linux-setup.h
@@ -7,8 +7,8 @@ void setup_linux_bootloader_parameters(
 	unsigned long real_mode_base, unsigned long cmdline_offset,
 	const char *cmdline, off_t cmdline_len,
 	const char *initrd_buf, off_t initrd_size);
-void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
-					unsigned long kexec_flags);
+void setup_linux_system_parameters(struct kexec_info *info,
+	struct x86_linux_param_header *real_mode);
 
 
 #define SETUP_BASE    0x90000
diff --git a/kexec/arch/x86_64/kexec-elf-x86_64.c b/kexec/arch/x86_64/kexec-elf-x86_64.c
index fe4b76b..a3fc728 100644
--- a/kexec/arch/x86_64/kexec-elf-x86_64.c
+++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
@@ -253,7 +253,7 @@ int elf_x86_64_load(int argc, char **argv, const char *buf, off_t len,
 			ramdisk_buf, ramdisk_length);
 
 		/* Fill in the information bios calls would usually provide */
-		setup_linux_system_parameters(&hdr->hdr, info->kexec_flags);
+		setup_linux_system_parameters(info, &hdr->hdr);
 
 		/* Initialize the registers */
 		elf_rel_get_symbol(&info->rhdr, "entry64_regs", &regs, sizeof(regs));
-- 
1.7.1

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

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

* [PATCH 2/2] kexec: add additional check when getting memory info
  2013-01-11  8:57 [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges Zhang Yanfei
@ 2013-01-11  8:58 ` Zhang Yanfei
  2013-01-30  4:16   ` Simon Horman
  2013-01-15  4:56 ` [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges Zhang Yanfei
  1 sibling, 1 reply; 5+ messages in thread
From: Zhang Yanfei @ 2013-01-11  8:58 UTC (permalink / raw)
  To: horms; +Cc: kexec@lists.infradead.org

This check makes sure that we indeed get the memory information.

Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
---
 kexec/kexec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index 89ec182..16c6308 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -675,7 +675,7 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 #endif
 
 	if (get_memory_ranges(&info.memory_range, &info.memory_ranges,
-		info.kexec_flags) < 0) {
+		info.kexec_flags) < 0 || info.memory_ranges == 0) {
 		fprintf(stderr, "Could not get memory layout\n");
 		return -1;
 	}
-- 
1.7.1

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

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

* Re: [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges
  2013-01-11  8:57 [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges Zhang Yanfei
  2013-01-11  8:58 ` [PATCH 2/2] kexec: add additional check when getting memory info Zhang Yanfei
@ 2013-01-15  4:56 ` Zhang Yanfei
  2013-01-30  4:16   ` Simon Horman
  1 sibling, 1 reply; 5+ messages in thread
From: Zhang Yanfei @ 2013-01-15  4:56 UTC (permalink / raw)
  To: horms; +Cc: kexec@lists.infradead.org

ping...

于 2013年01月11日 16:57, Zhang Yanfei 写道:
> At first, we have already filled the kexec_info.memory_ranges by
> calling my_load() -> get_memory_ranges(). So if we want to
> get the memory information, we could just use the existing
> one instead of calling get_memory_ranges again.
> 
> Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
> ---
>  kexec/arch/i386/kexec-bzImage.c       |    2 +-
>  kexec/arch/i386/kexec-elf-x86.c       |    2 +-
>  kexec/arch/i386/kexec-multiboot-x86.c |    7 ++-----
>  kexec/arch/i386/x86-linux-setup.c     |   10 ++++------
>  kexec/arch/i386/x86-linux-setup.h     |    4 ++--
>  kexec/arch/x86_64/kexec-elf-x86_64.c  |    2 +-
>  6 files changed, 11 insertions(+), 16 deletions(-)
> 
> diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
> index 0605909..83a023d 100644
> --- a/kexec/arch/i386/kexec-bzImage.c
> +++ b/kexec/arch/i386/kexec-bzImage.c
> @@ -324,7 +324,7 @@ int do_bzImage_load(struct kexec_info *info,
>  
>  	/* Fill in the information BIOS calls would normally provide. */
>  	if (!real_mode_entry) {
> -		setup_linux_system_parameters(real_mode, info->kexec_flags);
> +		setup_linux_system_parameters(info, real_mode);
>  	}
>  
>  	return 0;
> diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
> index 8bd5ef6..e62ebcb 100644
> --- a/kexec/arch/i386/kexec-elf-x86.c
> +++ b/kexec/arch/i386/kexec-elf-x86.c
> @@ -272,7 +272,7 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
>  			ramdisk_buf, ramdisk_length);
>  
>  		/* Fill in the information bios calls would usually provide */
> -		setup_linux_system_parameters(&hdr->hdr, info->kexec_flags);
> +		setup_linux_system_parameters(info, &hdr->hdr);
>  
>  		/* Initialize the registers */
>  		elf_rel_get_symbol(&info->rhdr, "entry32_regs", &regs, sizeof(regs));
> diff --git a/kexec/arch/i386/kexec-multiboot-x86.c b/kexec/arch/i386/kexec-multiboot-x86.c
> index 23dab7b..de2a423 100644
> --- a/kexec/arch/i386/kexec-multiboot-x86.c
> +++ b/kexec/arch/i386/kexec-multiboot-x86.c
> @@ -248,11 +248,8 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
>  	mbi->boot_loader_name = sizeof(*mbi) + command_line_len; 
>  
>  	/* Memory map */
> -	if ((get_memory_ranges(&range, &ranges, info->kexec_flags) < 0)
> -			|| ranges == 0) {
> -		fprintf(stderr, "Cannot get memory information\n");
> -		return -1;
> -	}
> +	range = info->memory_range;
> +	ranges = info->memory_ranges;
>  	mmap = xmalloc(ranges * sizeof(*mmap));
>  	for (i=0; i<ranges; i++) {
>  		unsigned long long length;
> diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
> index b7ab8ea..ef62553 100644
> --- a/kexec/arch/i386/x86-linux-setup.c
> +++ b/kexec/arch/i386/x86-linux-setup.c
> @@ -441,8 +441,8 @@ close:
>  	close(data_file);
>  }
>  
> -void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
> -					unsigned long kexec_flags)
> +void setup_linux_system_parameters(struct kexec_info *info,
> +				   struct x86_linux_param_header *real_mode)
>  {
>  	/* Fill in information the BIOS would usually provide */
>  	struct memory_range *range;
> @@ -486,10 +486,8 @@ void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
>  	/* another safe default */
>  	real_mode->aux_device_info = 0;
>  
> -	/* Fill in the memory info */
> -	if ((get_memory_ranges(&range, &ranges, kexec_flags) < 0) || ranges == 0) {
> -		die("Cannot get memory information\n");
> -	}
> +	range = info->memory_range;
> +	ranges = info->memory_ranges;
>  	if (ranges > E820MAX) {
>  		fprintf(stderr, "Too many memory ranges, truncating...\n");
>  		ranges = E820MAX;
> diff --git a/kexec/arch/i386/x86-linux-setup.h b/kexec/arch/i386/x86-linux-setup.h
> index 8862513..96fbd33 100644
> --- a/kexec/arch/i386/x86-linux-setup.h
> +++ b/kexec/arch/i386/x86-linux-setup.h
> @@ -7,8 +7,8 @@ void setup_linux_bootloader_parameters(
>  	unsigned long real_mode_base, unsigned long cmdline_offset,
>  	const char *cmdline, off_t cmdline_len,
>  	const char *initrd_buf, off_t initrd_size);
> -void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
> -					unsigned long kexec_flags);
> +void setup_linux_system_parameters(struct kexec_info *info,
> +	struct x86_linux_param_header *real_mode);
>  
>  
>  #define SETUP_BASE    0x90000
> diff --git a/kexec/arch/x86_64/kexec-elf-x86_64.c b/kexec/arch/x86_64/kexec-elf-x86_64.c
> index fe4b76b..a3fc728 100644
> --- a/kexec/arch/x86_64/kexec-elf-x86_64.c
> +++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
> @@ -253,7 +253,7 @@ int elf_x86_64_load(int argc, char **argv, const char *buf, off_t len,
>  			ramdisk_buf, ramdisk_length);
>  
>  		/* Fill in the information bios calls would usually provide */
> -		setup_linux_system_parameters(&hdr->hdr, info->kexec_flags);
> +		setup_linux_system_parameters(info, &hdr->hdr);
>  
>  		/* Initialize the registers */
>  		elf_rel_get_symbol(&info->rhdr, "entry64_regs", &regs, sizeof(regs));


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

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

* Re: [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges
  2013-01-15  4:56 ` [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges Zhang Yanfei
@ 2013-01-30  4:16   ` Simon Horman
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2013-01-30  4:16 UTC (permalink / raw)
  To: Zhang Yanfei; +Cc: kexec@lists.infradead.org

On Tue, Jan 15, 2013 at 12:56:02PM +0800, Zhang Yanfei wrote:
> 于 2013年01月11日 16:57, Zhang Yanfei 写道:
> > At first, we have already filled the kexec_info.memory_ranges by
> > calling my_load() -> get_memory_ranges(). So if we want to
> > get the memory information, we could just use the existing
> > one instead of calling get_memory_ranges again.
> > 
> > Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
>
> ping...

Sorry for the extended delay. Applied.


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

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

* Re: [PATCH 2/2] kexec: add additional check when getting memory info
  2013-01-11  8:58 ` [PATCH 2/2] kexec: add additional check when getting memory info Zhang Yanfei
@ 2013-01-30  4:16   ` Simon Horman
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2013-01-30  4:16 UTC (permalink / raw)
  To: Zhang Yanfei; +Cc: kexec@lists.infradead.org

On Fri, Jan 11, 2013 at 04:58:45PM +0800, Zhang Yanfei wrote:
> This check makes sure that we indeed get the memory information.
> 
> Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>

Thanks, applied.

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

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

end of thread, other threads:[~2013-01-30  4:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-11  8:57 [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges Zhang Yanfei
2013-01-11  8:58 ` [PATCH 2/2] kexec: add additional check when getting memory info Zhang Yanfei
2013-01-30  4:16   ` Simon Horman
2013-01-15  4:56 ` [PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges Zhang Yanfei
2013-01-30  4:16   ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox