public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Simon Horman <horms@verge.net.au>,
	"H. Peter Anvin" <hpa@zytor.com>, Vivek Goyal <vgoyal@redhat.com>,
	Haren Myneni <hbabu@us.ibm.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Cc: Yinghai Lu <yinghai@kernel.org>, kexec@lists.infradead.org
Subject: [PATCH 8/8] x86: put 64bit bzImage high
Date: Fri, 16 Nov 2012 15:04:27 -0800	[thread overview]
Message-ID: <1353107067-14564-9-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1353107067-14564-1-git-send-email-yinghai@kernel.org>

also need to make sure pass right 64bit start address to go there directly later.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 kexec/arch/i386/kexec-bzImage.c |   53 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
index 6998587..3e705ca 100644
--- a/kexec/arch/i386/kexec-bzImage.c
+++ b/kexec/arch/i386/kexec-bzImage.c
@@ -18,8 +18,10 @@
  */
 
 #define _GNU_SOURCE
+#include <stddef.h>
 #include <stdio.h>
 #include <string.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -35,6 +37,7 @@
 #include "../../kexec-elf.h"
 #include "../../kexec-syscall.h"
 #include "kexec-x86.h"
+#include "../x86_64/kexec-x86_64.h"
 #include "x86-linux-setup.h"
 #include "crashdump-x86.h"
 #include <arch/options.h>
@@ -111,12 +114,15 @@ int do_bzImage_load(struct kexec_info *info,
 	size_t size;
 	int kern16_size;
 	unsigned long setup_base, setup_size;
+	struct entry64_regs regs64;
 	struct entry32_regs regs32;
 	struct entry16_regs regs16;
 	unsigned int relocatable_kernel = 0;
 	unsigned long kernel32_load_addr;
 	char *modified_cmdline;
 	unsigned long cmdline_end;
+	unsigned long code64_start_offset = 0;
+	unsigned long kernel64_load_addr = 0;
 
 	/*
 	 * Find out about the file I am about to load.
@@ -154,6 +160,13 @@ int do_bzImage_load(struct kexec_info *info,
 		dbgprintf("bzImage is relocatable\n");
 	}
 
+	if (setup_header.protocol_version >= 0x020C) {
+		code64_start_offset = setup_header.code64_start_offset;
+		if (code64_start_offset)
+			dbgprintf("code64_start_offset: 0x%lx\n",
+					 code64_start_offset);
+	}
+
 	/* Can't use bzImage for crash dump purposes with real mode entry */
 	if((info->kexec_flags & KEXEC_ON_CRASH) && real_mode_entry) {
 		fprintf(stderr, "Can't use bzImage for crash dump purposes"
@@ -250,7 +263,26 @@ int do_bzImage_load(struct kexec_info *info,
 				kernel32_max_addr = real_mode->initrd_addr_max;
 		}
 
-		kernel32_load_addr = add_buffer(info, kernel + kern16_size,
+		if (!real_mode_entry && code64_start_offset) {
+			/* align to 1G to avoid cross the PUD_SIZE boundary */
+			kernel64_load_addr = add_buffer(
+						info, kernel + kern16_size,
+						size, size, 1UL<<30,
+						1UL<<32, ULONG_MAX,
+						-1);
+			if (!kernel64_load_addr)
+				kernel64_load_addr = add_buffer(
+						info, kernel + kern16_size,
+						size, size, 1UL<<30,
+						1UL<<30, 1UL<<32,
+						-1);
+			if (kernel64_load_addr)
+				kernel64_load_addr += code64_start_offset;
+		}
+
+		if (!kernel64_load_addr)
+			kernel32_load_addr = add_buffer(
+						info, kernel + kern16_size,
 						size, size, kern_align,
 						0x100000, kernel32_max_addr,
 						1);
@@ -260,8 +292,11 @@ int do_bzImage_load(struct kexec_info *info,
 		add_segment(info, kernel + kern16_size, size,
 				kernel32_load_addr, size);
 	}
-		
-	dbgprintf("Loaded 32bit kernel at 0x%lx\n", kernel32_load_addr);
+
+	if (kernel64_load_addr)
+		dbgprintf("Loaded 64bit kernel at 0x%lx\n", kernel64_load_addr);
+	else
+		dbgprintf("Loaded 32bit kernel at 0x%lx\n", kernel32_load_addr);
 
 	/* Tell the kernel what is going on */
 	setup_linux_bootloader_parameters(info, real_mode, setup_base,
@@ -271,6 +306,16 @@ int do_bzImage_load(struct kexec_info *info,
 	/* Get the initial register values */
 	elf_rel_get_symbol(&info->rhdr, "entry16_regs", &regs16, sizeof(regs16));
 	elf_rel_get_symbol(&info->rhdr, "entry32_regs", &regs32, sizeof(regs32));
+	if (kernel64_load_addr) {
+		elf_rel_get_symbol(&info->rhdr, "entry64_regs", &regs64, sizeof(regs64));
+		regs64.rbx = 0;           /* Bootstrap processor */
+		regs64.rsi = setup_base;  /* Pointer to the parameters */
+		regs64.rip = kernel64_load_addr; /* the entry point */
+		regs64.rsp = elf_rel_get_addr(&info->rhdr, "stack_end"); /* Stack, unused */
+		elf_rel_set_symbol(&info->rhdr, "entry64_regs", &regs64, sizeof(regs64));
+
+		goto cmd_line;
+	}
 	/*
 
 	 * Initialize the 32bit start information.
@@ -320,6 +365,8 @@ int do_bzImage_load(struct kexec_info *info,
 	elf_rel_set_symbol(&info->rhdr, "entry16_regs", &regs16, sizeof(regs16));
 	elf_rel_set_symbol(&info->rhdr, "entry16_debug_regs", &regs16, sizeof(regs16));
 	elf_rel_set_symbol(&info->rhdr, "entry32_regs", &regs32, sizeof(regs32));
+
+cmd_line:
 	cmdline_end = setup_base + kern16_size + command_line_len - 1;
 	elf_rel_set_symbol(&info->rhdr, "cmdline_end", &cmdline_end,
 			   sizeof(unsigned long));
-- 
1.7.7


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

  parent reply	other threads:[~2012-11-16 23:04 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-16 23:04 [PATCH 0/8] kexec: put bzImage and ramdisk above 4G for x86 64bit Yinghai Lu
2012-11-16 23:04 ` [PATCH 1/8] Add min/max macro Yinghai Lu
2012-11-16 23:04 ` [PATCH 2/8] x86: add boot header member for version 2.12 Yinghai Lu
2012-11-16 23:04 ` [PATCH 3/8] add mem64_min/max control Yinghai Lu
2012-11-17  6:18   ` Eric W. Biederman
2012-11-17  7:06     ` Yinghai Lu
2012-11-17  8:25       ` Eric W. Biederman
2012-11-17 20:04         ` Yinghai Lu
2012-11-17 20:41           ` H. Peter Anvin
2012-11-17 20:51             ` Yinghai Lu
2012-11-17 20:54               ` H. Peter Anvin
2012-11-18  0:44           ` Yinghai Lu
2012-11-18  4:34             ` H. Peter Anvin
2012-11-18  4:47               ` Eric W. Biederman
2012-11-18  4:55                 ` H. Peter Anvin
2012-11-18  5:00                   ` Eric W. Biederman
2012-11-18  5:14                     ` H. Peter Anvin
2012-11-18  4:56                 ` Yinghai Lu
2012-11-18  5:20                   ` Eric W. Biederman
2012-11-18  5:35                     ` Yinghai Lu
2012-11-18  5:39                       ` Yinghai Lu
2012-11-18  5:58                         ` Yinghai Lu
2012-11-18  6:11                           ` Eric W. Biederman
2012-11-18  6:32                             ` Yinghai Lu
2012-11-18  6:38                             ` Yinghai Lu
2012-11-18  6:50                               ` Eric W. Biederman
2012-11-18  6:53                                 ` Yinghai Lu
2012-11-18  7:18                                   ` Yinghai Lu
2012-11-18 10:38                                     ` Eric W. Biederman
2012-11-19  3:02                                       ` [PATCH 0/6] kexec: put bzImage and ramdisk above 4G for x86 64bit Yinghai Lu
2012-11-19  3:02                                         ` [PATCH 1/6] kexec, x86: add boot header member for version 2.12 Yinghai Lu
2012-11-19  3:02                                         ` [PATCH 2/6] kexec: don't die during buffer finding Yinghai Lu
2012-11-19  3:02                                         ` [PATCH 3/6] kexec, x86: put ramdisk high for 64bit bzImage Yinghai Lu
2012-11-19  3:02                                         ` [PATCH 4/6] kexec, x86: set ext_cmd_line_ptr when boot_param is put high Yinghai Lu
2012-11-19  3:02                                         ` [PATCH 5/6] kexec, x86: Make x64_64 purgatory relocatable above 4G Yinghai Lu
2012-11-19  3:02                                         ` [PATCH 6/6] kexec, x86_64: put 64bit bzImage high Yinghai Lu
2012-11-19  3:04                                       ` [PATCH v2 0/6] kexec: put bzImage and ramdisk above 4G for x86 64bit Yinghai Lu
2012-11-19  3:04                                         ` [PATCH v2 1/6] kexec, x86: add boot header member for version 2.12 Yinghai Lu
2012-11-19  3:04                                         ` [PATCH v2 2/6] kexec: don't die during buffer finding Yinghai Lu
2012-11-19 17:05                                           ` Eric W. Biederman
2012-11-19  3:04                                         ` [PATCH v2 3/6] kexec, x86: put ramdisk high for 64bit bzImage Yinghai Lu
2012-11-19 17:20                                           ` Eric W. Biederman
2012-11-19  3:04                                         ` [PATCH v2 4/6] kexec, x86: set ext_cmd_line_ptr when boot_param is put high Yinghai Lu
2012-11-19 17:22                                           ` Eric W. Biederman
2012-11-19  3:04                                         ` [PATCH v2 5/6] kexec, x86: Make x64_64 purgatory relocatable above 4G Yinghai Lu
2012-11-19  3:04                                         ` [PATCH v2 6/6] kexec, x86_64: put 64bit bzImage high Yinghai Lu
2012-11-19 17:28                                           ` Eric W. Biederman
2012-11-19 17:04                                         ` [PATCH v2 0/6] kexec: put bzImage and ramdisk above 4G for x86 64bit Eric W. Biederman
2012-11-18  6:24                         ` [PATCH 3/8] add mem64_min/max control H. Peter Anvin
2012-11-18  6:23                     ` H. Peter Anvin
2012-11-18  6:44                       ` Eric W. Biederman
2012-11-16 23:04 ` [PATCH 4/8] Move out mem_min/max checking in locate_hole Yinghai Lu
2012-11-16 23:04 ` [PATCH 5/8] seperate checking 64bit mem range Yinghai Lu
2012-11-16 23:04 ` [PATCH 6/8] debug print out for add_buf Yinghai Lu
2012-11-16 23:04 ` [PATCH 7/8] x86: put ramdisk high for 64bit bzImage Yinghai Lu
2012-11-16 23:04 ` Yinghai Lu [this message]
2012-11-17  6:33   ` [PATCH 8/8] x86: put 64bit bzImage high Eric W. Biederman
     [not found]     ` <CAE9FiQWJaT9yfdV0rgV-5rM=BR4eX8sr+a99g8Ggf-+YkD8qgQ@mail.gmail.com>
2012-11-17  8:43       ` Eric W. Biederman
2012-11-19 21:00 ` [PATCH 0/8] kexec: put bzImage and ramdisk above 4G for x86 64bit Vivek Goyal
2012-11-19 22:34   ` Yinghai Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353107067-14564-9-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=hbabu@us.ibm.com \
    --cc=horms@verge.net.au \
    --cc=hpa@zytor.com \
    --cc=kexec@lists.infradead.org \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox