Skip to content

Commit 82782ca

Browse files
committed
Merge branch 'x86-kbuild-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-kbuild-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (46 commits) x86, boot: add new generated files to the appropriate .gitignore files x86, boot: correct the calculation of ZO_INIT_SIZE x86-64: align __PHYSICAL_START, remove __KERNEL_ALIGN x86, boot: correct sanity checks in boot/compressed/misc.c x86: add extension fields for bootloader type and version x86, defconfig: update kernel position parameters x86, defconfig: update to current, no material changes x86: make CONFIG_RELOCATABLE the default x86: default CONFIG_PHYSICAL_START and CONFIG_PHYSICAL_ALIGN to 16 MB x86: document new bzImage fields x86, boot: make kernel_alignment adjustable; new bzImage fields x86, boot: remove dead code from boot/compressed/head_*.S x86, boot: use LOAD_PHYSICAL_ADDR on 64 bits x86, boot: make symbols from the main vmlinux available x86, boot: determine compressed code offset at compile time x86, boot: use appropriate rep string for move and clear x86, boot: zero EFLAGS on 32 bits x86, boot: set up the decompression stack as early as possible x86, boot: straighten out ranges to copy/zero in compressed/head*.S x86, boot: stylistic cleanups for boot/compressed/head_64.S ... Fixed trivial conflict in arch/x86/configs/x86_64_defconfig manually
2 parents f0d5e12 + 6799687 commit 82782ca

32 files changed

Lines changed: 1235 additions & 981 deletions

‎Documentation/x86/boot.txt‎

Lines changed: 114 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ Protocol 2.08: (Kernel 2.6.26) Added crc32 checksum and ELF format
5050
Protocol 2.09: (Kernel 2.6.26) Added a field of 64-bit physical
5151
pointer to single linked list of struct setup_data.
5252

53+
Protocol 2.10: (Kernel 2.6.31) Added a protocol for relaxed alignment
54+
beyond the kernel_alignment added, new init_size and
55+
pref_address fields. Added extended boot loader IDs.
56+
5357
**** MEMORY LAYOUT
5458

5559
The traditional memory map for the kernel loader, used for Image or
@@ -168,12 +172,13 @@ Offset Proto Name Meaning
168172
021C/4 2.00+ ramdisk_size initrd size (set by boot loader)
169173
0220/4 2.00+ bootsect_kludge DO NOT USE - for bootsect.S use only
170174
0224/2 2.01+ heap_end_ptr Free memory after setup end
171-
0226/2 N/A pad1 Unused
175+
0226/1 2.02+(3 ext_loader_ver Extended boot loader version
176+
0227/1 2.02+(3 ext_loader_type Extended boot loader ID
172177
0228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line
173178
022C/4 2.03+ ramdisk_max Highest legal initrd address
174179
0230/4 2.05+ kernel_alignment Physical addr alignment required for kernel
175180
0234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not
176-
0235/1 N/A pad2 Unused
181+
0235/1 2.10+ min_alignment Minimum alignment, as a power of two
177182
0236/2 N/A pad3 Unused
178183
0238/4 2.06+ cmdline_size Maximum size of the kernel command line
179184
023C/4 2.07+ hardware_subarch Hardware subarchitecture
@@ -182,6 +187,8 @@ Offset Proto Name Meaning
182187
024C/4 2.08+ payload_length Length of kernel payload
183188
0250/8 2.09+ setup_data 64-bit physical pointer to linked list
184189
of struct setup_data
190+
0258/8 2.10+ pref_address Preferred loading address
191+
0260/4 2.10+ init_size Linear memory required during initialization
185192

186193
(1) For backwards compatibility, if the setup_sects field contains 0, the
187194
real value is 4.
@@ -190,6 +197,8 @@ Offset Proto Name Meaning
190197
field are unusable, which means the size of a bzImage kernel
191198
cannot be determined.
192199

200+
(3) Ignored, but safe to set, for boot protocols 2.02-2.09.
201+
193202
If the "HdrS" (0x53726448) magic number is not found at offset 0x202,
194203
the boot protocol version is "old". Loading an old kernel, the
195204
following parameters should be assumed:
@@ -343,18 +352,32 @@ Protocol: 2.00+
343352
0xTV here, where T is an identifier for the boot loader and V is
344353
a version number. Otherwise, enter 0xFF here.
345354

355+
For boot loader IDs above T = 0xD, write T = 0xE to this field and
356+
write the extended ID minus 0x10 to the ext_loader_type field.
357+
Similarly, the ext_loader_ver field can be used to provide more than
358+
four bits for the bootloader version.
359+
360+
For example, for T = 0x15, V = 0x234, write:
361+
362+
type_of_loader <- 0xE4
363+
ext_loader_type <- 0x05
364+
ext_loader_ver <- 0x23
365+
346366
Assigned boot loader ids:
347367
0 LILO (0x00 reserved for pre-2.00 bootloader)
348368
1 Loadlin
349369
2 bootsect-loader (0x20, all other values reserved)
350-
3 SYSLINUX
351-
4 EtherBoot
370+
3 Syslinux
371+
4 Etherboot/gPXE
352372
5 ELILO
353373
7 GRUB
354-
8 U-BOOT
374+
8 U-Boot
355375
9 Xen
356376
A Gujin
357377
B Qemu
378+
C Arcturus Networks uCbootloader
379+
E Extended (see ext_loader_type)
380+
F Special (0xFF = undefined)
358381

359382
Please contact <hpa@zytor.com> if you need a bootloader ID
360383
value assigned.
@@ -453,6 +476,35 @@ Protocol: 2.01+
453476
Set this field to the offset (from the beginning of the real-mode
454477
code) of the end of the setup stack/heap, minus 0x0200.
455478

479+
Field name: ext_loader_ver
480+
Type: write (optional)
481+
Offset/size: 0x226/1
482+
Protocol: 2.02+
483+
484+
This field is used as an extension of the version number in the
485+
type_of_loader field. The total version number is considered to be
486+
(type_of_loader & 0x0f) + (ext_loader_ver << 4).
487+
488+
The use of this field is boot loader specific. If not written, it
489+
is zero.
490+
491+
Kernels prior to 2.6.31 did not recognize this field, but it is safe
492+
to write for protocol version 2.02 or higher.
493+
494+
Field name: ext_loader_type
495+
Type: write (obligatory if (type_of_loader & 0xf0) == 0xe0)
496+
Offset/size: 0x227/1
497+
Protocol: 2.02+
498+
499+
This field is used as an extension of the type number in
500+
type_of_loader field. If the type in type_of_loader is 0xE, then
501+
the actual type is (ext_loader_type + 0x10).
502+
503+
This field is ignored if the type in type_of_loader is not 0xE.
504+
505+
Kernels prior to 2.6.31 did not recognize this field, but it is safe
506+
to write for protocol version 2.02 or higher.
507+
456508
Field name: cmd_line_ptr
457509
Type: write (obligatory)
458510
Offset/size: 0x228/4
@@ -482,11 +534,19 @@ Protocol: 2.03+
482534
0x37FFFFFF, you can start your ramdisk at 0x37FE0000.)
483535

484536
Field name: kernel_alignment
485-
Type: read (reloc)
537+
Type: read/modify (reloc)
486538
Offset/size: 0x230/4
487-
Protocol: 2.05+
539+
Protocol: 2.05+ (read), 2.10+ (modify)
540+
541+
Alignment unit required by the kernel (if relocatable_kernel is
542+
true.) A relocatable kernel that is loaded at an alignment
543+
incompatible with the value in this field will be realigned during
544+
kernel initialization.
488545

489-
Alignment unit required by the kernel (if relocatable_kernel is true.)
546+
Starting with protocol version 2.10, this reflects the kernel
547+
alignment preferred for optimal performance; it is possible for the
548+
loader to modify this field to permit a lesser alignment. See the
549+
min_alignment and pref_address field below.
490550

491551
Field name: relocatable_kernel
492552
Type: read (reloc)
@@ -498,6 +558,22 @@ Protocol: 2.05+
498558
After loading, the boot loader must set the code32_start field to
499559
point to the loaded code, or to a boot loader hook.
500560

561+
Field name: min_alignment
562+
Type: read (reloc)
563+
Offset/size: 0x235/1
564+
Protocol: 2.10+
565+
566+
This field, if nonzero, indicates as a power of two the minimum
567+
alignment required, as opposed to preferred, by the kernel to boot.
568+
If a boot loader makes use of this field, it should update the
569+
kernel_alignment field with the alignment unit desired; typically:
570+
571+
kernel_alignment = 1 << min_alignment
572+
573+
There may be a considerable performance cost with an excessively
574+
misaligned kernel. Therefore, a loader should typically try each
575+
power-of-two alignment from kernel_alignment down to this alignment.
576+
501577
Field name: cmdline_size
502578
Type: read
503579
Offset/size: 0x238/4
@@ -582,6 +658,36 @@ Protocol: 2.09+
582658
sure to consider the case where the linked list already contains
583659
entries.
584660

661+
Field name: pref_address
662+
Type: read (reloc)
663+
Offset/size: 0x258/8
664+
Protocol: 2.10+
665+
666+
This field, if nonzero, represents a preferred load address for the
667+
kernel. A relocating bootloader should attempt to load at this
668+
address if possible.
669+
670+
A non-relocatable kernel will unconditionally move itself and to run
671+
at this address.
672+
673+
Field name: init_size
674+
Type: read
675+
Offset/size: 0x25c/4
676+
677+
This field indicates the amount of linear contiguous memory starting
678+
at the kernel runtime start address that the kernel needs before it
679+
is capable of examining its memory map. This is not the same thing
680+
as the total amount of memory the kernel needs to boot, but it can
681+
be used by a relocating boot loader to help select a safe load
682+
address for the kernel.
683+
684+
The kernel runtime start address is determined by the following algorithm:
685+
686+
if (relocatable_kernel)
687+
runtime_start = align_up(load_address, kernel_alignment)
688+
else
689+
runtime_start = pref_address
690+
585691

586692
**** THE IMAGE CHECKSUM
587693

‎arch/x86/Kbuild‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
obj-$(CONFIG_KVM) += kvm/
3+
4+
# Xen paravirtualization support
5+
obj-$(CONFIG_XEN) += xen/
6+
7+
# lguest paravirtualization support
8+
obj-$(CONFIG_LGUEST_GUEST) += lguest/
9+
10+
obj-y += kernel/
11+
obj-y += mm/
12+
13+
obj-y += crypto/
14+
obj-y += vdso/
15+
obj-$(CONFIG_IA32_EMULATION) += ia32/
16+

‎arch/x86/Kconfig‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ config X86
4747
select HAVE_KERNEL_BZIP2
4848
select HAVE_KERNEL_LZMA
4949

50+
config OUTPUT_FORMAT
51+
string
52+
default "elf32-i386" if X86_32
53+
default "elf64-x86-64" if X86_64
54+
5055
config ARCH_DEFCONFIG
5156
string
5257
default "arch/x86/configs/i386_defconfig" if X86_32
@@ -1460,9 +1465,7 @@ config KEXEC_JUMP
14601465

14611466
config PHYSICAL_START
14621467
hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
1463-
default "0x1000000" if X86_NUMAQ
1464-
default "0x200000" if X86_64
1465-
default "0x100000"
1468+
default "0x1000000"
14661469
---help---
14671470
This gives the physical address where the kernel is loaded.
14681471

@@ -1481,15 +1484,15 @@ config PHYSICAL_START
14811484
to be specifically compiled to run from a specific memory area
14821485
(normally a reserved region) and this option comes handy.
14831486

1484-
So if you are using bzImage for capturing the crash dump, leave
1485-
the value here unchanged to 0x100000 and set CONFIG_RELOCATABLE=y.
1486-
Otherwise if you plan to use vmlinux for capturing the crash dump
1487-
change this value to start of the reserved region (Typically 16MB
1488-
0x1000000). In other words, it can be set based on the "X" value as
1489-
specified in the "crashkernel=YM@XM" command line boot parameter
1490-
passed to the panic-ed kernel. Typically this parameter is set as
1491-
crashkernel=64M@16M. Please take a look at
1492-
Documentation/kdump/kdump.txt for more details about crash dumps.
1487+
So if you are using bzImage for capturing the crash dump,
1488+
leave the value here unchanged to 0x1000000 and set
1489+
CONFIG_RELOCATABLE=y. Otherwise if you plan to use vmlinux
1490+
for capturing the crash dump change this value to start of
1491+
the reserved region. In other words, it can be set based on
1492+
the "X" value as specified in the "crashkernel=YM@XM"
1493+
command line boot parameter passed to the panic-ed
1494+
kernel. Please take a look at Documentation/kdump/kdump.txt
1495+
for more details about crash dumps.
14931496

14941497
Usage of bzImage for capturing the crash dump is recommended as
14951498
one does not have to build two kernels. Same kernel can be used
@@ -1502,8 +1505,8 @@ config PHYSICAL_START
15021505
Don't change this unless you know what you are doing.
15031506

15041507
config RELOCATABLE
1505-
bool "Build a relocatable kernel (EXPERIMENTAL)"
1506-
depends on EXPERIMENTAL
1508+
bool "Build a relocatable kernel"
1509+
default y
15071510
---help---
15081511
This builds a kernel image that retains relocation information
15091512
so it can be loaded someplace besides the default 1MB.
@@ -1518,12 +1521,16 @@ config RELOCATABLE
15181521
it has been loaded at and the compile time physical address
15191522
(CONFIG_PHYSICAL_START) is ignored.
15201523

1524+
# Relocation on x86-32 needs some additional build support
1525+
config X86_NEED_RELOCS
1526+
def_bool y
1527+
depends on X86_32 && RELOCATABLE
1528+
15211529
config PHYSICAL_ALIGN
15221530
hex
15231531
prompt "Alignment value to which kernel should be aligned" if X86_32
1524-
default "0x100000" if X86_32
1525-
default "0x200000" if X86_64
1526-
range 0x2000 0x400000
1532+
default "0x1000000"
1533+
range 0x2000 0x1000000
15271534
---help---
15281535
This value puts the alignment restrictions on physical address
15291536
where kernel is loaded and run from. Kernel is compiled for an

‎arch/x86/Makefile‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ else
77
KBUILD_DEFCONFIG := $(ARCH)_defconfig
88
endif
99

10-
core-$(CONFIG_KVM) += arch/x86/kvm/
11-
1210
# BITS is used as extension for files which are available in a 32 bit
1311
# and a 64 bit version to simplify shared Makefiles.
1412
# e.g.: obj-y += foo_$(BITS).o
@@ -118,21 +116,8 @@ head-y += arch/x86/kernel/init_task.o
118116

119117
libs-y += arch/x86/lib/
120118

121-
# Sub architecture files that needs linking first
122-
core-y += $(fcore-y)
123-
124-
# Xen paravirtualization support
125-
core-$(CONFIG_XEN) += arch/x86/xen/
126-
127-
# lguest paravirtualization support
128-
core-$(CONFIG_LGUEST_GUEST) += arch/x86/lguest/
129-
130-
core-y += arch/x86/kernel/
131-
core-y += arch/x86/mm/
132-
133-
core-y += arch/x86/crypto/
134-
core-y += arch/x86/vdso/
135-
core-$(CONFIG_IA32_EMULATION) += arch/x86/ia32/
119+
# See arch/x86/Kbuild for content of core part of the kernel
120+
core-y += arch/x86/
136121

137122
# drivers-y are linked after core-y
138123
drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/

‎arch/x86/boot/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ bzImage
33
cpustr.h
44
mkcpustr
55
offsets.h
6+
voffset.h
7+
zoffset.h
68
setup
79
setup.bin
810
setup.elf

‎arch/x86/boot/Makefile‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,27 @@ $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
8686

8787
SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
8888

89-
sed-offsets := -e 's/^00*/0/' \
90-
-e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/\#define \2 0x\1/p'
89+
sed-voffset := -e 's/^\([0-9a-fA-F]*\) . \(_text\|_end\)$$/\#define VO_\2 0x\1/p'
9190

92-
quiet_cmd_offsets = OFFSETS $@
93-
cmd_offsets = $(NM) $< | sed -n $(sed-offsets) > $@
91+
quiet_cmd_voffset = VOFFSET $@
92+
cmd_voffset = $(NM) $< | sed -n $(sed-voffset) > $@
9493

95-
$(obj)/offsets.h: $(obj)/compressed/vmlinux FORCE
96-
$(call if_changed,offsets)
94+
targets += voffset.h
95+
$(obj)/voffset.h: vmlinux FORCE
96+
$(call if_changed,voffset)
97+
98+
sed-zoffset := -e 's/^\([0-9a-fA-F]*\) . \(startup_32\|input_data\|_end\|z_.*\)$$/\#define ZO_\2 0x\1/p'
99+
100+
quiet_cmd_zoffset = ZOFFSET $@
101+
cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
102+
103+
targets += zoffset.h
104+
$(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
105+
$(call if_changed,zoffset)
97106

98-
targets += offsets.h
99107

100108
AFLAGS_header.o += -I$(obj)
101-
$(obj)/header.o: $(obj)/offsets.h
109+
$(obj)/header.o: $(obj)/voffset.h $(obj)/zoffset.h
102110

103111
LDFLAGS_setup.elf := -T
104112
$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
relocs
22
vmlinux.bin.all
33
vmlinux.relocs
4+
vmlinux.lds
5+
mkpiggy
6+
piggy.S

0 commit comments

Comments
 (0)