Skip to content

Commit 5e47c47

Browse files
author
H. Peter Anvin
committed
x86: remove zImage support
Impact: obsolete feature removal The zImage kernel format has been functionally unused for a very long time. It is just barely possible to build a modern kernel that still fits within the zImage size limit, but it is highly unlikely that anyone ever uses it. Furthermore, although it is still supported by most bootloaders, it has been at best poorly tested (or not tested at all); some bootloaders are even known to not support zImage at all and not having even noticed. Also remove some really obsolete constants that no longer have any meaning. LKML-Reference: <49B703D4.1000008@zytor.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1 parent 78b020d commit 5e47c47

5 files changed

Lines changed: 18 additions & 91 deletions

File tree

‎arch/x86/boot/Makefile‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,23 @@
66
# for more details.
77
#
88
# Copyright (C) 1994 by Linus Torvalds
9+
# Changed by many, many contributors over the years.
910
#
1011

1112
# ROOT_DEV specifies the default root-device when making the image.
1213
# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
1314
# the default of FLOPPY is used by 'build'.
1415

15-
ROOT_DEV := CURRENT
16+
ROOT_DEV := CURRENT
1617

1718
# If you want to preset the SVGA mode, uncomment the next line and
1819
# set SVGA_MODE to whatever number you want.
1920
# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
2021
# The number is the same as you would ordinarily press at bootup.
2122

22-
SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
23+
SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
2324

24-
# If you want the RAM disk device, define this to be the size in blocks.
25-
26-
#RAMDISK := -DRAMDISK=512
27-
28-
targets := vmlinux.bin setup.bin setup.elf zImage bzImage
25+
targets := vmlinux.bin setup.bin setup.elf bzImage
2926
subdir- := compressed
3027

3128
setup-y += a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o
@@ -71,17 +68,13 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
7168
KBUILD_CFLAGS += $(call cc-option,-m32)
7269
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
7370

74-
$(obj)/zImage: asflags-y := $(SVGA_MODE) $(RAMDISK)
75-
$(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__
76-
$(obj)/bzImage: asflags-y := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
77-
$(obj)/bzImage: BUILDFLAGS := -b
71+
$(obj)/bzImage: asflags-y := $(SVGA_MODE)
7872

7973
quiet_cmd_image = BUILD $@
80-
cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
81-
$(obj)/vmlinux.bin $(ROOT_DEV) > $@
74+
cmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \
75+
$(ROOT_DEV) > $@
8276

83-
$(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
84-
$(obj)/vmlinux.bin $(obj)/tools/build FORCE
77+
$(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
8578
$(call if_changed,image)
8679
@echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
8780

‎arch/x86/boot/header.S‎

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@
2424
#include "boot.h"
2525
#include "offsets.h"
2626

27-
SETUPSECTS = 4 /* default nr of setup-sectors */
2827
BOOTSEG = 0x07C0 /* original address of boot-sector */
29-
SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
30-
SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
31-
/* to be loaded */
32-
ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
28+
SYSSEG = 0x1000 /* historical load address >> 4 */
3329

3430
#ifndef SVGA_MODE
3531
#define SVGA_MODE ASK_VGA
@@ -97,12 +93,12 @@ bugger_off_msg:
9793
.section ".header", "a"
9894
.globl hdr
9995
hdr:
100-
setup_sects: .byte SETUPSECTS
96+
setup_sects: .byte 0 /* Filled in by build.c */
10197
root_flags: .word ROOT_RDONLY
102-
syssize: .long SYSSIZE
103-
ram_size: .word RAMDISK
98+
syssize: .long 0 /* Filled in by build.c */
99+
ram_size: .word 0 /* Obsolete */
104100
vid_mode: .word SVGA_MODE
105-
root_dev: .word ROOT_DEV
101+
root_dev: .word 0 /* Filled in by build.c */
106102
boot_flag: .word 0xAA55
107103

108104
# offset 512, entry point
@@ -123,14 +119,15 @@ _start:
123119
# or else old loadlin-1.5 will fail)
124120
.globl realmode_swtch
125121
realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
126-
start_sys_seg: .word SYSSEG
122+
start_sys_seg: .word SYSSEG # obsolete and meaningless, but just
123+
# in case something decided to "use" it
127124
.word kernel_version-512 # pointing to kernel version string
128125
# above section of header is compatible
129126
# with loadlin-1.5 (header v1.5). Don't
130127
# change it.
131128

132-
type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
133-
# Bootlin, SYSLX, bootsect...)
129+
type_of_loader: .byte 0 # 0 means ancient bootloader, newer
130+
# bootloaders know to change this.
134131
# See Documentation/i386/boot.txt for
135132
# assigned ids
136133

@@ -142,11 +139,7 @@ CAN_USE_HEAP = 0x80 # If set, the loader also has set
142139
# space behind setup.S can be used for
143140
# heap purposes.
144141
# Only the loader knows what is free
145-
#ifndef __BIG_KERNEL__
146-
.byte 0
147-
#else
148142
.byte LOADED_HIGH
149-
#endif
150143

151144
setup_move_size: .word 0x8000 # size to move, when setup is not
152145
# loaded at 0x90000. We will move setup
@@ -157,11 +150,7 @@ setup_move_size: .word 0x8000 # size to move, when setup is not
157150

158151
code32_start: # here loaders can put a different
159152
# start address for 32-bit code.
160-
#ifndef __BIG_KERNEL__
161-
.long 0x1000 # 0x1000 = default for zImage
162-
#else
163153
.long 0x100000 # 0x100000 = default for big kernel
164-
#endif
165154

166155
ramdisk_image: .long 0 # address of loaded ramdisk image
167156
# Here the loader puts the 32-bit

‎arch/x86/boot/pm.c‎

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -32,47 +32,6 @@ static void realmode_switch_hook(void)
3232
}
3333
}
3434

35-
/*
36-
* A zImage kernel is loaded at 0x10000 but wants to run at 0x1000.
37-
* A bzImage kernel is loaded and runs at 0x100000.
38-
*/
39-
static void move_kernel_around(void)
40-
{
41-
/* Note: rely on the compile-time option here rather than
42-
the LOADED_HIGH flag. The Qemu kernel loader unconditionally
43-
sets the loadflags to zero. */
44-
#ifndef __BIG_KERNEL__
45-
u16 dst_seg, src_seg;
46-
u32 syssize;
47-
48-
dst_seg = 0x1000 >> 4;
49-
src_seg = 0x10000 >> 4;
50-
syssize = boot_params.hdr.syssize; /* Size in 16-byte paragraphs */
51-
52-
while (syssize) {
53-
int paras = (syssize >= 0x1000) ? 0x1000 : syssize;
54-
int dwords = paras << 2;
55-
56-
asm volatile("pushw %%es ; "
57-
"pushw %%ds ; "
58-
"movw %1,%%es ; "
59-
"movw %2,%%ds ; "
60-
"xorw %%di,%%di ; "
61-
"xorw %%si,%%si ; "
62-
"rep;movsl ; "
63-
"popw %%ds ; "
64-
"popw %%es"
65-
: "+c" (dwords)
66-
: "r" (dst_seg), "r" (src_seg)
67-
: "esi", "edi");
68-
69-
syssize -= paras;
70-
dst_seg += paras;
71-
src_seg += paras;
72-
}
73-
#endif
74-
}
75-
7635
/*
7736
* Disable all interrupts at the legacy PIC.
7837
*/
@@ -147,9 +106,6 @@ void go_to_protected_mode(void)
147106
/* Hook before leaving real mode, also disables interrupts */
148107
realmode_switch_hook();
149108

150-
/* Move the kernel/setup to their final resting places */
151-
move_kernel_around();
152-
153109
/* Enable the A20 gate */
154110
if (enable_a20()) {
155111
puts("A20 gate not responding, unable to boot...\n");

‎arch/x86/boot/tools/build.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void die(const char * str, ...)
130130

131131
static void usage(void)
132132
{
133-
die("Usage: build [-b] setup system [rootdev] [> image]");
133+
die("Usage: build setup system [rootdev] [> image]");
134134
}
135135

136136
int main(int argc, char ** argv)
@@ -145,11 +145,6 @@ int main(int argc, char ** argv)
145145
void *kernel;
146146
u32 crc = 0xffffffffUL;
147147

148-
if (argc > 2 && !strcmp(argv[1], "-b"))
149-
{
150-
is_big_kernel = 1;
151-
argc--, argv++;
152-
}
153148
if ((argc < 3) || (argc > 4))
154149
usage();
155150
if (argc > 3) {
@@ -216,8 +211,6 @@ int main(int argc, char ** argv)
216211
die("Unable to mmap '%s': %m", argv[2]);
217212
/* Number of 16-byte paragraphs, including space for a 4-byte CRC */
218213
sys_size = (sz + 15 + 4) / 16;
219-
if (!is_big_kernel && sys_size > DEF_SYSSIZE)
220-
die("System is too big. Try using bzImage or modules.");
221214

222215
/* Patch the setup code with the appropriate size parameters */
223216
buf[0x1f1] = setup_sectors-1;

‎arch/x86/include/asm/boot.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#ifndef _ASM_X86_BOOT_H
22
#define _ASM_X86_BOOT_H
33

4-
/* Don't touch these, unless you really know what you're doing. */
5-
#define DEF_SYSSEG 0x1000
6-
#define DEF_SYSSIZE 0x7F00
7-
84
/* Internal svga startup constants */
95
#define NORMAL_VGA 0xffff /* 80x25 mode */
106
#define EXTENDED_VGA 0xfffe /* 80x50 mode */

0 commit comments

Comments
 (0)