From: Yinghai Lu <yinghai@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
"H. Peter Anvin" <hpa@zytor.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Yinghai Lu <yinghai@kernel.org>,
Rob Landley <rob@landley.net>,
Matt Fleming <matt.fleming@intel.com>
Subject: [PATCH v7 19/27] x86, boot: add fields to support load bzImage and ramdisk above 4G
Date: Mon, 17 Dec 2012 23:15:51 -0800 [thread overview]
Message-ID: <1355814959-10573-20-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1355814959-10573-1-git-send-email-yinghai@kernel.org>
ext_ramdisk_image/size will record high 32bits for ramdisk info.
xloadflags bit0 will be set if relocatable with 64bit.
Let get_ramdisk_image/size to use ext_ramdisk_image/size to get
right positon for ramdisk.
bootloader will fill value to ext_ramdisk_image/size when it load
ramdisk above 4G.
Also bootloader will check if xloadflags bit0 is set to decicde if
it could load ramdisk high above 4G.
sentinel is used to make sure kernel have ext_* valid values set
Update header version to 2.12.
-v2: add ext_cmd_line_ptr for above 4G support.
-v3: update to xloadflags from HPA.
-v4: use fields from bootparam instead setup_header according to HPA.
-v5: add checking for USE_EXT_BOOT_PARAMS
-v6: use sentinel to check if ext_* are valid suggested by HPA.
HPA said:
1. add a field in the uninitialized portion, call it "sentinel";
2. make sure the byte position corresponding to the "sentinel" field is
nonzero in the bzImage file;
3. if the kernel boots up and sentinel is nonzero, erase those fields
that you identified as uninitialized;
-v7: change to 0x1ef instead of 0x1f0, HPA said:
it is quite plausible that someone may (fairly sanely) start the
copy range at 0x1f0 instead of 0x1f1
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Rob Landley <rob@landley.net>
Cc: Matt Fleming <matt.fleming@intel.com>
---
Documentation/x86/boot.txt | 15 ++++++++++++++-
Documentation/x86/zero-page.txt | 4 ++++
arch/x86/boot/compressed/cmdline.c | 2 ++
arch/x86/boot/compressed/misc.c | 12 ++++++++++++
| 12 ++++++++++--
arch/x86/boot/setup.ld | 7 +++++++
arch/x86/include/uapi/asm/bootparam.h | 13 ++++++++++---
arch/x86/kernel/head64.c | 2 ++
arch/x86/kernel/setup.c | 4 ++++
9 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt
index 406d82d..18ca9fb 100644
--- a/Documentation/x86/boot.txt
+++ b/Documentation/x86/boot.txt
@@ -57,6 +57,9 @@ Protocol 2.10: (Kernel 2.6.31) Added a protocol for relaxed alignment
Protocol 2.11: (Kernel 3.6) Added a field for offset of EFI handover
protocol entry point.
+Protocol 2.12: (Kernel 3.9) Added three fields for loading bzImage and
+ ramdisk above 4G with 64bit in bootparam.
+
**** MEMORY LAYOUT
The traditional memory map for the kernel loader, used for Image or
@@ -182,7 +185,7 @@ Offset Proto Name Meaning
0230/4 2.05+ kernel_alignment Physical addr alignment required for kernel
0234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not
0235/1 2.10+ min_alignment Minimum alignment, as a power of two
-0236/2 N/A pad3 Unused
+0236/2 2.12+ xloadflags Boot protocol option flags
0238/4 2.06+ cmdline_size Maximum size of the kernel command line
023C/4 2.07+ hardware_subarch Hardware subarchitecture
0240/8 2.07+ hardware_subarch_data Subarchitecture-specific data
@@ -582,6 +585,16 @@ Protocol: 2.10+
misaligned kernel. Therefore, a loader should typically try each
power-of-two alignment from kernel_alignment down to this alignment.
+Field name: xloadflags
+Type: modify (obligatory)
+Offset/size: 0x236/2
+Protocol: 2.12+
+
+ This field is a bitmask.
+
+ Bit 0 (read): CAN_BE_LOADED_ABOVE_4G
+ - If 1, kernel/boot_params/cmdline/ramdisk can be above 4g,
+
Field name: cmdline_size
Type: read
Offset/size: 0x238/4
diff --git a/Documentation/x86/zero-page.txt b/Documentation/x86/zero-page.txt
index cf5437d..1140e59 100644
--- a/Documentation/x86/zero-page.txt
+++ b/Documentation/x86/zero-page.txt
@@ -19,6 +19,9 @@ Offset Proto Name Meaning
090/010 ALL hd1_info hd1 disk parameter, OBSOLETE!!
0A0/010 ALL sys_desc_table System description table (struct sys_desc_table)
0B0/010 ALL olpc_ofw_header OLPC's OpenFirmware CIF and friends
+0C0/004 ALL ext_ramdisk_image ramdisk_image high 32bits
+0C4/004 ALL ext_ramdisk_size ramdisk_size high 32bits
+0C8/004 ALL ext_cmd_line_ptr cmd_line_ptr high 32bits
140/080 ALL edid_info Video mode setup (struct edid_info)
1C0/020 ALL efi_info EFI 32 information (struct efi_info)
1E0/004 ALL alk_mem_k Alternative mem check, in KB
@@ -27,6 +30,7 @@ Offset Proto Name Meaning
1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below)
1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer
(below)
+1EF/001 ALL sentinel 0: states _ext_* fields are valid
290/040 ALL edd_mbr_sig_buffer EDD MBR signatures
2D0/A00 ALL e820_map E820 memory map table
(array of struct e820entry)
diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
index b4c913c..bffd73b 100644
--- a/arch/x86/boot/compressed/cmdline.c
+++ b/arch/x86/boot/compressed/cmdline.c
@@ -17,6 +17,8 @@ static unsigned long get_cmd_line_ptr(void)
{
unsigned long cmd_line_ptr = real_mode->hdr.cmd_line_ptr;
+ cmd_line_ptr |= (u64)real_mode->ext_cmd_line_ptr << 32;
+
return cmd_line_ptr;
}
int cmdline_find_option(const char *option, char *buffer, int bufsize)
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 88f7ff6..f714576 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -318,6 +318,16 @@ static void parse_elf(void *output)
free(phdrs);
}
+static void sanitize_real_mode(struct boot_params *real_mode)
+{
+ if (real_mode->sentinel) {
+ /* ext_* fields in boot_params are not valid, clear them */
+ real_mode->ext_ramdisk_image = 0;
+ real_mode->ext_ramdisk_size = 0;
+ real_mode->ext_cmd_line_ptr = 0;
+ }
+}
+
asmlinkage void decompress_kernel(void *rmode, memptr heap,
unsigned char *input_data,
unsigned long input_len,
@@ -325,6 +335,8 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
{
real_mode = rmode;
+ sanitize_real_mode(real_mode);
+
if (real_mode->screen_info.orig_video_mode == 7) {
vidmem = (char *) 0xb0000;
vidport = 0x3b4;
--git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 8c132a6..0d5790f 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -279,7 +279,7 @@ _start:
# Part 2 of the header, from the old setup.S
.ascii "HdrS" # header signature
- .word 0x020b # header version number (>= 0x0105)
+ .word 0x020c # header version number (>= 0x0105)
# or else old loadlin-1.5 will fail)
.globl realmode_swtch
realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
@@ -369,7 +369,15 @@ relocatable_kernel: .byte 1
relocatable_kernel: .byte 0
#endif
min_alignment: .byte MIN_KERNEL_ALIGN_LG2 # minimum alignment
-pad3: .word 0
+
+xloadflags:
+CAN_BE_LOADED_ABOVE_4G = 1 # If set, the kernel/boot_param/
+ # ramdisk could be loaded above 4g
+#if defined(CONFIG_X86_64) && defined(CONFIG_RELOCATABLE)
+ .word CAN_BE_LOADED_ABOVE_4G
+#else
+ .word 0
+#endif
cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
#added with boot protocol
diff --git a/arch/x86/boot/setup.ld b/arch/x86/boot/setup.ld
index 03c0683..9333d37 100644
--- a/arch/x86/boot/setup.ld
+++ b/arch/x86/boot/setup.ld
@@ -13,6 +13,13 @@ SECTIONS
.bstext : { *(.bstext) }
.bsdata : { *(.bsdata) }
+ /* sentinel: make sure if boot_params from bootloader is right */
+ . = 495;
+ .sentinel : {
+ sentinel = .;
+ BYTE(0xff);
+ }
+
. = 497;
.header : { *(.header) }
.entrytext : { *(.entrytext) }
diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/asm/bootparam.h
index 92862cd..3d8ed8f 100644
--- a/arch/x86/include/uapi/asm/bootparam.h
+++ b/arch/x86/include/uapi/asm/bootparam.h
@@ -58,7 +58,9 @@ struct setup_header {
__u32 initrd_addr_max;
__u32 kernel_alignment;
__u8 relocatable_kernel;
- __u8 _pad2[3];
+ __u8 min_alignment;
+ __u16 xloadflags;
+#define CAN_BE_LOADED_ABOVE_4G (1<<0)
__u32 cmdline_size;
__u32 hardware_subarch;
__u64 hardware_subarch_data;
@@ -106,7 +108,10 @@ struct boot_params {
__u8 hd1_info[16]; /* obsolete! */ /* 0x090 */
struct sys_desc_table sys_desc_table; /* 0x0a0 */
struct olpc_ofw_header olpc_ofw_header; /* 0x0b0 */
- __u8 _pad4[128]; /* 0x0c0 */
+ __u32 ext_ramdisk_image; /* 0x0c0 */
+ __u32 ext_ramdisk_size; /* 0x0c4 */
+ __u32 ext_cmd_line_ptr; /* 0x0c8 */
+ __u8 _pad4[116]; /* 0x0cc */
struct edid_info edid_info; /* 0x140 */
struct efi_info efi_info; /* 0x1c0 */
__u32 alt_mem_k; /* 0x1e0 */
@@ -115,7 +120,9 @@ struct boot_params {
__u8 eddbuf_entries; /* 0x1e9 */
__u8 edd_mbr_sig_buf_entries; /* 0x1ea */
__u8 kbd_status; /* 0x1eb */
- __u8 _pad6[5]; /* 0x1ec */
+ __u8 _pad5[3]; /* 0x1ec */
+ __u8 sentinel; /* 0x1ef */
+ __u8 _pad6[1]; /* 0x1f0 */
struct setup_header hdr; /* setup header */ /* 0x1f1 */
__u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
__u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index fe9037d..0824b02 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -106,6 +106,8 @@ static unsigned long get_cmd_line_ptr(void)
{
unsigned long cmd_line_ptr = boot_params.hdr.cmd_line_ptr;
+ cmd_line_ptr |= (u64)boot_params.ext_cmd_line_ptr << 32;
+
return cmd_line_ptr;
}
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 644a123..2509efa 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -298,12 +298,16 @@ static u64 __init get_ramdisk_image(void)
{
u64 ramdisk_image = boot_params.hdr.ramdisk_image;
+ ramdisk_image |= (u64)boot_params.ext_ramdisk_image << 32;
+
return ramdisk_image;
}
static u64 __init get_ramdisk_size(void)
{
u64 ramdisk_size = boot_params.hdr.ramdisk_size;
+ ramdisk_size |= (u64)boot_params.ext_ramdisk_size << 32;
+
return ramdisk_size;
}
--
1.7.10.4
next prev parent reply other threads:[~2012-12-18 7:17 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-18 7:15 [PATCH v7 00/27] x86, boot, 64bit: Add support for loading ramdisk and bzImage above 4G Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 01/27] x86, mm: Fix page table early allocation offset checking Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 02/27] x86, mm: make pgd next calculation consistent with pud/pmd Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 03/27] x86, realmode: set real_mode permissions early Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 04/27] x86, realmode: use init_level4_pgt to set trapmoline_pgt directly Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 05/27] x86, realmode: Separate real_mode reserve and setup Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 06/27] x86, 64bit: early #PF handler set page table Yinghai Lu
2012-12-18 20:43 ` Yinghai Lu
2012-12-18 20:49 ` H. Peter Anvin
2012-12-18 20:55 ` Yinghai Lu
2012-12-18 21:07 ` H. Peter Anvin
2012-12-20 16:56 ` Yinghai Lu
2012-12-25 0:16 ` H. Peter Anvin
2012-12-25 4:04 ` Yinghai Lu
2012-12-25 11:20 ` Borislav Petkov
2012-12-25 20:51 ` Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 07/27] x86, 64bit: Print init kernel lowmap correctly Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 08/27] x86: Merge early_reserve_initrd for 32bit and 64bit Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 09/27] x86: add get_ramdisk_image/size() Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 10/27] x86, boot: add get_cmd_line_ptr() Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 11/27] x86, boot: move checking of cmd_line_ptr out of common path Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 12/27] x86, boot: pass cmd_line_ptr with unsigned long Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 13/27] x86, boot: move verify_cpu.S and no_longmode after 0x200 Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 14/27] x86, boot: Move lldt/ltr out of 64bit code section Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 15/27] x86, kexec: remove 1024G limitation for kexec buffer on 64bit Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 16/27] x86, kexec: set ident mapping for kernel that is above max_pfn Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 17/27] x86, kexec: Merge ident_mapping_init and init_level4_page Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 18/27] x86, kexec: only set ident mapping for ram Yinghai Lu
2012-12-18 7:15 ` Yinghai Lu [this message]
2012-12-18 7:15 ` [PATCH v7 20/27] x86, boot: update comments about entries for 64bit image Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 21/27] x86, boot: Not need to check setup_header version Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 22/27] mm: Add alloc_bootmem_low_pages_nopanic() Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 23/27] x86: Don't panic if can not alloc buffer for swiotlb Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 24/27] x86: Add swiotlb force off support Yinghai Lu
2012-12-22 2:37 ` Konrad Rzeszutek Wilk
2012-12-22 2:42 ` Eric W. Biederman
2012-12-22 3:10 ` Konrad Rzeszutek Wilk
2012-12-22 3:23 ` Eric W. Biederman
2012-12-22 3:25 ` H. Peter Anvin
2012-12-22 5:11 ` Yinghai Lu
2012-12-24 23:34 ` H. Peter Anvin
2012-12-24 23:55 ` Yinghai Lu
2012-12-22 13:21 ` Konrad Rzeszutek Wilk
2012-12-22 5:10 ` Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 25/27] x86, kdump: remove crashkernel range find limit for 64bit Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 26/27] x86: add Crash kernel low reservation Yinghai Lu
2012-12-19 17:22 ` Borislav Petkov
2012-12-19 17:36 ` Yinghai Lu
2012-12-18 7:15 ` [PATCH v7 27/27] x86: Merge early kernel reserve for 32bit and 64bit Yinghai Lu
2012-12-18 22:43 ` [PATCH v7 00/27] x86, boot, 64bit: Add support for loading ramdisk and bzImage above 4G Borislav Petkov
2012-12-18 23:08 ` Yinghai Lu
2012-12-18 23:22 ` Borislav Petkov
2012-12-22 2:42 ` Konrad Rzeszutek Wilk
2012-12-22 3:01 ` H. Peter Anvin
2012-12-22 13:24 ` Konrad Rzeszutek Wilk
2012-12-23 7:29 ` Yinghai Lu
2012-12-23 14:33 ` H. Peter Anvin
2012-12-23 18:00 ` Yinghai Lu
2012-12-23 18:45 ` Borislav Petkov
2012-12-24 4:54 ` H. Peter Anvin
2012-12-24 10:04 ` Borislav Petkov
2012-12-24 18:44 ` Yinghai Lu
2012-12-24 4:55 ` H. Peter Anvin
2012-12-24 23:56 ` H. Peter Anvin
2012-12-25 20:57 ` Yinghai Lu
2012-12-25 1:06 ` H. Peter Anvin
2012-12-25 11:52 ` Borislav Petkov
2012-12-25 15:51 ` H. Peter Anvin
2013-01-08 21:08 ` Borislav Petkov
2013-01-08 21:15 ` H. Peter Anvin
2013-01-08 21:19 ` Borislav Petkov
2013-01-08 23:17 ` H. Peter Anvin
2013-01-08 23:25 ` Borislav Petkov
2012-12-22 5:20 ` Yinghai Lu
2012-12-22 13:32 ` Konrad Rzeszutek Wilk
2012-12-22 10:38 ` Yinghai Lu
2012-12-22 13:25 ` Konrad Rzeszutek Wilk
2012-12-22 13:47 ` Konrad Rzeszutek Wilk
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=1355814959-10573-20-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=mingo@elte.hu \
--cc=rob@landley.net \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).