All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "H. Peter Anvin" <hpa@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"vgoyal@redhat.com" <vgoyal@redhat.com>,
	"hbabu@us.ibm.com" <hbabu@us.ibm.com>,
	"kexec@lists.infradead.org" <kexec@lists.infradead.org>,
	"Huang, Ying" <ying.huang@intel.com>,
	"mingo@elte.hu" <mingo@elte.hu>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"sam@ravnborg.org" <sam@ravnborg.org>
Subject: RFC: x86: relocatable kernel changes (revised spec)
Date: Sun, 10 May 2009 22:18:44 -0700	[thread overview]
Message-ID: <4A07B534.8080606@zytor.com> (raw)
In-Reply-To: <4A047E53.8040003@intel.com>

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

Revised proposal to address Eric's comments.  This is intended to
provide full backwards compatibility while at the same time giving us
the future flexibility.

The intent will be to set by default:

	kernel_alignment	= 16 MB
	min_alignment		= log2(4K) or log2(2M)
	pref_address		= 16 MB

The reason to represent min_alignment as a logarithm is that I'm getting
very concerned about the diminishing space that is left without a
fundamental change to the initialized part of the header; specifically,
right now we rely on the signed byte at offset 0x201 to contain the
(additional) size of the header, which means end at 0x281 without a
major format change of some sort.

Comments appreciated.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 3886 bytes --]

diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt
index e020366..ccc1bd4 100644
--- a/Documentation/x86/boot.txt
+++ b/Documentation/x86/boot.txt
@@ -50,6 +50,11 @@ Protocol 2.08:	(Kernel 2.6.26) Added crc32 checksum and ELF format
 Protocol 2.09:	(Kernel 2.6.26) Added a field of 64-bit physical
 		pointer to single linked list of struct	setup_data.
 
+Protocol 2.10:	(Kernel 2.6.31?) A protocol for relaxed alignment
+	 	beyond the kernel_alignment added, new init_size and
+	 	pref_address fields.
+	 	
+
 **** MEMORY LAYOUT
 
 The traditional memory map for the kernel loader, used for Image or
@@ -173,7 +178,7 @@ Offset	Proto	Name		Meaning
 022C/4	2.03+	ramdisk_max	Highest legal initrd address
 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	N/A	pad2		Unused
+0235/1	2.10+	min_alignment	Minimum alignment, as a power of 2
 0236/2	N/A	pad3		Unused
 0238/4	2.06+	cmdline_size	Maximum size of the kernel command line
 023C/4	2.07+	hardware_subarch Hardware subarchitecture
@@ -182,6 +187,8 @@ Offset	Proto	Name		Meaning
 024C/4	2.08+	payload_length	Length of kernel payload
 0250/8	2.09+	setup_data	64-bit physical pointer to linked list
 				of struct setup_data
+0258/8	2.10+	pref_address	Preferred loading address
+0260/4	2.10+	init_size	Linear memory required during initialization
 
 (1) For backwards compatibility, if the setup_sects field contains 0, the
     real value is 4.
@@ -482,11 +489,15 @@ Protocol:	2.03+
   0x37FFFFFF, you can start your ramdisk at 0x37FE0000.)
 
 Field name:	kernel_alignment
-Type:		read (reloc)
+Type:		read/modify (reloc)
 Offset/size:	0x230/4
-Protocol:	2.05+
+Protocol:	2.05+ (read), 2.10+ (modify)
 
-  Alignment unit required by the kernel (if relocatable_kernel is true.)
+  Alignment unit required by the kernel (if relocatable_kernel is
+  true.)  Starting with protocol version 2.10, this reflects the
+  kernel alignment preferred for optimal performance and can be
+  modified by the loader; see the min_alignment and pref_address field
+  below.
 
 Field name:	relocatable_kernel
 Type:		read (reloc)
@@ -498,6 +509,22 @@ Protocol:	2.05+
   After loading, the boot loader must set the code32_start field to
   point to the loaded code, or to a boot loader hook.
 
+Field name:	min_alignment
+Type:		read (reloc)
+Offset/size:	0x235/1
+Protocol:	2.10+
+
+  This field, if nonzero, indicates as a power of 2 the minimum
+  alignment required, as opposed to preferred, by the kernel to boot.
+  If a boot loader makes use of this field, it should update the
+  kernel_alignment field with the alignment unit desired; typically:
+
+	kernel_alignment = 1 << min_alignment
+
+  There may be a considerable performance cost with an excessively
+  misaligned kernel.  Therefore, a loader should typically try each
+  power-of-two alignment from kernel_alignment down to this alignment.
+
 Field name:	cmdline_size
 Type:		read
 Offset/size:	0x238/4
@@ -582,6 +609,27 @@ Protocol:	2.09+
   sure to consider the case where the linked list already contains
   entries.
 
+Field name:	pref_address
+Type:		read (reloc)
+Offset/size:	0x258/8
+Protocol:	2.10+
+
+  This field, if nonzero, represents a preferred load address for the
+  kernel.  A relocating bootloader should attempt to load at this
+  address if possible.
+
+
+Field name:	init_size
+Type:		read
+Offset/size:	0x25c/4
+
+  This field indicates the amount of linear contiguous memory starting
+  at the kernel load address (rounded up to kernel_alignment) that the
+  kernel needs before it is capable of examining its memory map.  This
+  is not the same thing as the total amount of memory the kernel needs
+  to boot, but it can be used by a relocating boot loader to help
+  select a safe load address for the kernel.
+
 
 **** THE IMAGE CHECKSUM
 

WARNING: multiple messages have this Message-ID (diff)
From: "H. Peter Anvin" <hpa@zytor.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "kexec@lists.infradead.org" <kexec@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"hbabu@us.ibm.com" <hbabu@us.ibm.com>,
	"Huang, Ying" <ying.huang@intel.com>,
	"mingo@elte.hu" <mingo@elte.hu>,
	"H. Peter Anvin" <hpa@linux.intel.com>,
	"sam@ravnborg.org" <sam@ravnborg.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"vgoyal@redhat.com" <vgoyal@redhat.com>
Subject: RFC: x86: relocatable kernel changes (revised spec)
Date: Sun, 10 May 2009 22:18:44 -0700	[thread overview]
Message-ID: <4A07B534.8080606@zytor.com> (raw)
In-Reply-To: <4A047E53.8040003@intel.com>

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

Revised proposal to address Eric's comments.  This is intended to
provide full backwards compatibility while at the same time giving us
the future flexibility.

The intent will be to set by default:

	kernel_alignment	= 16 MB
	min_alignment		= log2(4K) or log2(2M)
	pref_address		= 16 MB

The reason to represent min_alignment as a logarithm is that I'm getting
very concerned about the diminishing space that is left without a
fundamental change to the initialized part of the header; specifically,
right now we rely on the signed byte at offset 0x201 to contain the
(additional) size of the header, which means end at 0x281 without a
major format change of some sort.

Comments appreciated.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 3886 bytes --]

diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt
index e020366..ccc1bd4 100644
--- a/Documentation/x86/boot.txt
+++ b/Documentation/x86/boot.txt
@@ -50,6 +50,11 @@ Protocol 2.08:	(Kernel 2.6.26) Added crc32 checksum and ELF format
 Protocol 2.09:	(Kernel 2.6.26) Added a field of 64-bit physical
 		pointer to single linked list of struct	setup_data.
 
+Protocol 2.10:	(Kernel 2.6.31?) A protocol for relaxed alignment
+	 	beyond the kernel_alignment added, new init_size and
+	 	pref_address fields.
+	 	
+
 **** MEMORY LAYOUT
 
 The traditional memory map for the kernel loader, used for Image or
@@ -173,7 +178,7 @@ Offset	Proto	Name		Meaning
 022C/4	2.03+	ramdisk_max	Highest legal initrd address
 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	N/A	pad2		Unused
+0235/1	2.10+	min_alignment	Minimum alignment, as a power of 2
 0236/2	N/A	pad3		Unused
 0238/4	2.06+	cmdline_size	Maximum size of the kernel command line
 023C/4	2.07+	hardware_subarch Hardware subarchitecture
@@ -182,6 +187,8 @@ Offset	Proto	Name		Meaning
 024C/4	2.08+	payload_length	Length of kernel payload
 0250/8	2.09+	setup_data	64-bit physical pointer to linked list
 				of struct setup_data
+0258/8	2.10+	pref_address	Preferred loading address
+0260/4	2.10+	init_size	Linear memory required during initialization
 
 (1) For backwards compatibility, if the setup_sects field contains 0, the
     real value is 4.
@@ -482,11 +489,15 @@ Protocol:	2.03+
   0x37FFFFFF, you can start your ramdisk at 0x37FE0000.)
 
 Field name:	kernel_alignment
-Type:		read (reloc)
+Type:		read/modify (reloc)
 Offset/size:	0x230/4
-Protocol:	2.05+
+Protocol:	2.05+ (read), 2.10+ (modify)
 
-  Alignment unit required by the kernel (if relocatable_kernel is true.)
+  Alignment unit required by the kernel (if relocatable_kernel is
+  true.)  Starting with protocol version 2.10, this reflects the
+  kernel alignment preferred for optimal performance and can be
+  modified by the loader; see the min_alignment and pref_address field
+  below.
 
 Field name:	relocatable_kernel
 Type:		read (reloc)
@@ -498,6 +509,22 @@ Protocol:	2.05+
   After loading, the boot loader must set the code32_start field to
   point to the loaded code, or to a boot loader hook.
 
+Field name:	min_alignment
+Type:		read (reloc)
+Offset/size:	0x235/1
+Protocol:	2.10+
+
+  This field, if nonzero, indicates as a power of 2 the minimum
+  alignment required, as opposed to preferred, by the kernel to boot.
+  If a boot loader makes use of this field, it should update the
+  kernel_alignment field with the alignment unit desired; typically:
+
+	kernel_alignment = 1 << min_alignment
+
+  There may be a considerable performance cost with an excessively
+  misaligned kernel.  Therefore, a loader should typically try each
+  power-of-two alignment from kernel_alignment down to this alignment.
+
 Field name:	cmdline_size
 Type:		read
 Offset/size:	0x238/4
@@ -582,6 +609,27 @@ Protocol:	2.09+
   sure to consider the case where the linked list already contains
   entries.
 
+Field name:	pref_address
+Type:		read (reloc)
+Offset/size:	0x258/8
+Protocol:	2.10+
+
+  This field, if nonzero, represents a preferred load address for the
+  kernel.  A relocating bootloader should attempt to load at this
+  address if possible.
+
+
+Field name:	init_size
+Type:		read
+Offset/size:	0x25c/4
+
+  This field indicates the amount of linear contiguous memory starting
+  at the kernel load address (rounded up to kernel_alignment) that the
+  kernel needs before it is capable of examining its memory map.  This
+  is not the same thing as the total amount of memory the kernel needs
+  to boot, but it can be used by a relocating boot loader to help
+  select a safe load address for the kernel.
+
 
 **** THE IMAGE CHECKSUM
 

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

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

  reply	other threads:[~2009-05-11  5:23 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-07 22:26 [PATCH 00/14] RFC: x86: relocatable kernel changes H. Peter Anvin
2009-05-07 22:26 ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 01/14] x86, boot: align the .bss section in the decompressor H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-08  7:17   ` Sam Ravnborg
2009-05-08  7:17     ` Sam Ravnborg
2009-05-08  8:18     ` Eric Dumazet
2009-05-08  8:18       ` Eric Dumazet
2009-05-08 16:54     ` H. Peter Anvin
2009-05-08 16:54       ` H. Peter Anvin
2009-05-08  7:53   ` Cyrill Gorcunov
2009-05-08  7:53     ` Cyrill Gorcunov
2009-05-08 17:03     ` H. Peter Anvin
2009-05-08 17:03       ` H. Peter Anvin
2009-05-08 17:15       ` Cyrill Gorcunov
2009-05-08 17:15         ` Cyrill Gorcunov
2009-05-08 17:21         ` H. Peter Anvin
2009-05-08 17:21           ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 02/14] x86, boot: honor CONFIG_PHYSICAL_START when relocatable H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-08  7:34   ` Sam Ravnborg
2009-05-08  7:34     ` Sam Ravnborg
2009-05-08 16:58     ` H. Peter Anvin
2009-05-08 16:58       ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 03/14] x86, config: change defaults PHYSICAL_START and PHYSICAL_ALIGN H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-08  7:36   ` Sam Ravnborg
2009-05-08  7:36     ` Sam Ravnborg
2009-05-08  9:47     ` Ingo Molnar
2009-05-08  9:47       ` Ingo Molnar
2009-05-08 17:01     ` H. Peter Anvin
2009-05-08 17:01       ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 04/14] x86, boot: unify use LOAD_PHYSICAL_ADDR and LOAD_PHYSICAL_ALIGN H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 05/14] kbuild: allow compressors (gzip, bzip2, lzma) to take multiple inputs H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-08  7:42   ` Sam Ravnborg
2009-05-08  7:42     ` Sam Ravnborg
2009-05-08 20:18     ` H. Peter Anvin
2009-05-08 20:18       ` H. Peter Anvin
2009-05-08 20:47       ` Sam Ravnborg
2009-05-08 20:47         ` Sam Ravnborg
2009-05-08 20:49         ` H. Peter Anvin
2009-05-08 20:49           ` H. Peter Anvin
2009-05-08 21:33           ` Sam Ravnborg
2009-05-08 21:33             ` Sam Ravnborg
2009-05-07 22:26 ` [PATCH 06/14] x86: add a Kconfig symbol for when relocations are needed H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 07/14] x86, boot: simplify arch/x86/boot/compressed/Makefile H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-08  7:45   ` Sam Ravnborg
2009-05-08  7:45     ` Sam Ravnborg
2009-05-07 22:26 ` [PATCH 08/14] x86, boot: use BP_scratch in arch/x86/boot/compressed/head_*.S H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 09/14] x86, boot: add new runtime_address and runtime_size bzImage fields H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-08  7:55   ` Sam Ravnborg
2009-05-08  7:55     ` Sam Ravnborg
2009-05-08 21:09     ` H. Peter Anvin
2009-05-08 21:09       ` H. Peter Anvin
2009-05-08 21:35       ` Sam Ravnborg
2009-05-08 21:35         ` Sam Ravnborg
2009-05-07 22:26 ` [PATCH 10/14] x86, doc: document the runtime_start " H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 11/14] x86, boot: use rep movsq to move kernel on 64 bits H. Peter Anvin
2009-05-07 22:26   ` H. Peter Anvin
2009-05-07 22:27 ` [PATCH 12/14] x86, boot: zero EFLAGS on 32 bits H. Peter Anvin
2009-05-07 22:27   ` H. Peter Anvin
2009-05-07 22:27 ` [PATCH 13/14] x86: make CONFIG_RELOCATABLE the default H. Peter Anvin
2009-05-07 22:27   ` H. Peter Anvin
2009-05-07 22:27 ` [PATCH 14/14] x86, defconfig: update defconfigs to relocatable H. Peter Anvin
2009-05-07 22:27   ` H. Peter Anvin
2009-05-08  1:23 ` [PATCH 00/14] RFC: x86: relocatable kernel changes Eric W. Biederman
2009-05-08  1:23   ` Eric W. Biederman
2009-05-08  5:31   ` H. Peter Anvin
2009-05-08  5:31     ` H. Peter Anvin
2009-05-08  6:54     ` Eric W. Biederman
2009-05-08  6:54       ` Eric W. Biederman
2009-05-08 18:04       ` H. Peter Anvin
2009-05-08 18:04         ` H. Peter Anvin
2009-05-08 18:47       ` H. Peter Anvin
2009-05-08 18:47         ` H. Peter Anvin
2009-05-11  5:18         ` H. Peter Anvin [this message]
2009-05-11  5:18           ` RFC: x86: relocatable kernel changes (revised spec) H. Peter Anvin
2009-05-11 11:54           ` Eric W. Biederman
2009-05-11 11:54             ` Eric W. Biederman
2009-05-11 16:03             ` H. Peter Anvin
2009-05-11 16:03               ` H. Peter Anvin
2009-05-11 17:56             ` RFC: x86: relocatable kernel changes (revised spec v2) H. Peter Anvin
2009-05-11 17:56               ` H. Peter Anvin

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=4A07B534.8080606@zytor.com \
    --to=hpa@zytor.com \
    --cc=ebiederm@xmission.com \
    --cc=hbabu@us.ibm.com \
    --cc=hpa@linux.intel.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sam@ravnborg.org \
    --cc=tglx@linutronix.de \
    --cc=vgoyal@redhat.com \
    --cc=ying.huang@intel.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 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.