tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: make module loading by boot installboot patchable?
OK, here is an implementation which appears to work so far.
There are two new installboot(8) options, to toggle module
loading and boot.cfg evaluation. (I've added the latter because
an unsuspecting dhcpd setup will deliver a kernel binary if
a boot.cfg is tried to be read; there is a size check in the
boot code which prevents it from being parsed, but it is still
lost time in the boot process.)
Comments?
best regards
Matthias
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
#
# old_revision [bcf74b5990cc6edc20df3263bac900d50dc2ba94]
#
# patch "sys/arch/i386/stand/boot/boot2.c"
# from [58b7527140bba67edfc3d31e9544fa2855e016e1]
# to [81c9050e9af95c69a7ac6b3304c4e90181873cb2]
#
# patch "sys/arch/i386/stand/lib/boot_params.S"
# from [0e19a98b9611bae9e3e48251c60b8cde23863430]
# to [1fe70710ed9e4221bfa75d4a186452e892441801]
#
# patch "sys/arch/i386/stand/pxeboot/Makefile"
# from [c673736b7c1ab21c2780c8d5f6d0b80e7e266b13]
# to [fdbb894cde45ad54adf5d81353f24de3460f5caa]
#
# patch "sys/arch/i386/stand/pxeboot/main.c"
# from [eb22861c9bdcf54a557050e755913d00981531fb]
# to [d9734bc8fe39e081557368d44c0fbb4a3c4a113e]
#
# patch "sys/sys/bootblock.h"
# from [f62332a2865f37e80d78f66b16102ba46dba91fa]
# to [fce2103a8eb9b6f601dd8e193a94f6acfd905650]
#
# patch "usr.sbin/installboot/arch/i386.c"
# from [29e40c5c49c1c6f5397fae4e461595496d9860fd]
# to [96eb10e5176e4118bad8e6d09bcddc844d20ceec]
#
# patch "usr.sbin/installboot/installboot.8"
# from [75935addd933a8a57db34454a6ae2846cf644e0a]
# to [66f24084dbce7ad827e5646798a58ba782720c4e]
#
# patch "usr.sbin/installboot/installboot.c"
# from [0217e7022ba1b2305ae1e21225e462045e666c06]
# to [9b571dd9b228c7137fe32fba048c8ba6cc5ae2ca]
#
# patch "usr.sbin/installboot/installboot.h"
# from [1c8d7cc64741fcf00e45048d1a2438701230879a]
# to [efe5905f229f39581617a33ffb84d573ba83dca2]
#
============================================================
--- sys/arch/i386/stand/boot/boot2.c 58b7527140bba67edfc3d31e9544fa2855e016e1
+++ sys/arch/i386/stand/boot/boot2.c 81c9050e9af95c69a7ac6b3304c4e90181873cb2
@@ -291,6 +291,8 @@ boot2(int biosdev, u_int biossector)
#endif
gateA20();
+ boot_modules_enabled = !!(boot_params.bp_flags
+ & X86_BP_FLAGS_LOADMODULES);
if (boot_params.bp_flags & X86_BP_FLAGS_RESET_VIDEO)
biosvideomode();
@@ -308,7 +310,8 @@ boot2(int biosdev, u_int biossector)
default_filename = DEFFILENAME;
#ifndef SMALL
- parsebootconf(BOOTCONF);
+ if (boot_params.bp_flags & X86_BP_FLAGS_READBOOTCONF)
+ parsebootconf(BOOTCONF);
/*
* If console set in boot.cfg, switch to it.
============================================================
--- sys/arch/i386/stand/lib/boot_params.S
0e19a98b9611bae9e3e48251c60b8cde23863430
+++ sys/arch/i386/stand/lib/boot_params.S
1fe70710ed9e4221bfa75d4a186452e892441801
@@ -2,7 +2,11 @@
/* Default boot parameters - must match struct x86_boot_params in bootblock.h
*/
- .long 0 /* flags */
+#ifdef BOOTPARAM_DEFFLAGS
+ .long BOOTPARAM_DEFFLAGS
+#else
+ .long 0x0c /* flags: bootconf+modules */
+#endif
.long 5 /* timeout in seconds */
.long 0 /* console device 0 => CONSDEV_PC */
.long 9600 /* serial baud rate */
============================================================
--- sys/arch/i386/stand/pxeboot/Makefile
c673736b7c1ab21c2780c8d5f6d0b80e7e266b13
+++ sys/arch/i386/stand/pxeboot/Makefile
fdbb894cde45ad54adf5d81353f24de3460f5caa
@@ -63,6 +63,10 @@ CPPFLAGS+= -DEPIA_HACK
CPPFLAGS+= -DPASS_MEMMAP
CPPFLAGS+= -DEPIA_HACK
+# modules and boot.cfg need special DHCP server setup, disable
+# per default for compatibility with existing setups
+CPPFLAGS+= -DBOOTPARAM_DEFFLAGS=0
+
#CFLAGS= -O2 -fomit-frame-pointer -fno-defer-pop
CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-main
============================================================
--- sys/arch/i386/stand/pxeboot/main.c eb22861c9bdcf54a557050e755913d00981531fb
+++ sys/arch/i386/stand/pxeboot/main.c d9734bc8fe39e081557368d44c0fbb4a3c4a113e
@@ -130,9 +130,12 @@ main(void)
initio(CONSDEV_PC);
#endif
gateA20();
+ boot_modules_enabled = !!(boot_params.bp_flags
+ & X86_BP_FLAGS_LOADMODULES);
#ifndef SMALL
- parsebootconf(BOOTCONF);
+ if (boot_params.bp_flags & X86_BP_FLAGS_READBOOTCONF)
+ parsebootconf(BOOTCONF);
/*
* If console set in boot.cfg, switch to it.
============================================================
--- sys/sys/bootblock.h f62332a2865f37e80d78f66b16102ba46dba91fa
+++ sys/sys/bootblock.h fce2103a8eb9b6f601dd8e193a94f6acfd905650
@@ -1068,6 +1068,8 @@ struct x86_boot_params {
/* values for bp_flags */
#define X86_BP_FLAGS_RESET_VIDEO 1
#define X86_BP_FLAGS_PASSWORD 2
+#define X86_BP_FLAGS_LOADMODULES 4
+#define X86_BP_FLAGS_READBOOTCONF 8
/* values for bp_consdev */
#define X86_BP_CONSDEV_PC 0
============================================================
--- usr.sbin/installboot/arch/i386.c 29e40c5c49c1c6f5397fae4e461595496d9860fd
+++ usr.sbin/installboot/arch/i386.c 96eb10e5176e4118bad8e6d09bcddc844d20ceec
@@ -80,12 +80,14 @@ struct ib_mach ib_mach_i386 =
struct ib_mach ib_mach_i386 =
{ "i386", i386_setboot, no_clearboot, i386_editboot,
IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED | IB_CONSADDR |
- IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT };
+ IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT |
+ IB_MODULES | IB_BOOTCONF };
struct ib_mach ib_mach_amd64 =
{ "amd64", i386_setboot, no_clearboot, i386_editboot,
IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED | IB_CONSADDR |
- IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT };
+ IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT |
+ IB_MODULES | IB_BOOTCONF };
/*
* Attempting to write the 'labelsector' (or a sector near it - within 8k?)
@@ -272,6 +274,10 @@ update_i386_boot_params(ib_params *param
}
if (params->flags & IB_KEYMAP)
strlcpy(bp.bp_keymap, params->keymap, sizeof bp.bp_keymap);
+ if (params->flags & IB_MODULES)
+ bp.bp_flags ^= htole32(X86_BP_FLAGS_LOADMODULES);
+ if (params->flags & IB_BOOTCONF)
+ bp.bp_flags ^= htole32(X86_BP_FLAGS_READBOOTCONF);
if (params->flags & (IB_NOWRITE | IB_VERBOSE))
show_i386_boot_params(&bp);
============================================================
--- usr.sbin/installboot/installboot.8 75935addd933a8a57db34454a6ae2846cf644e0a
+++ usr.sbin/installboot/installboot.8 66f24084dbce7ad827e5646798a58ba782720c4e
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd October 12, 2008
+.Dd January 11, 2010
.Dt INSTALLBOOT 8
.Os
.Sh NAME
@@ -305,6 +305,18 @@ Set the timeout before the automatic boo
.Sy [ amd64 ,
.Sy i386 ]
Set the timeout before the automatic boot begins to the given number of
seconds.
+.
+.It Sy modules
+.Sy [ amd64 ,
+.Sy i386 ]
+(Don't) load kernel modules.
+.
+.It Sy bootconf
+.Sy [ amd64 ,
+.Sy i386 ]
+(Don't) read a
+.Dq boot.cfg
+file.
.El
.
.It Fl t Ar fstype
============================================================
--- usr.sbin/installboot/installboot.c 0217e7022ba1b2305ae1e21225e462045e666c06
+++ usr.sbin/installboot/installboot.c 9b571dd9b228c7137fe32fba048c8ba6cc5ae2ca
@@ -87,6 +87,8 @@ const struct option {
{ "speed", IB_CONSPEED, OPT_INT, OFFSET(conspeed) },
{ "sunsum", IB_SUNSUM, OPT_BOOL, 0 },
{ "timeout", IB_TIMEOUT, OPT_INT, OFFSET(timeout) },
+ { "modules", IB_MODULES, OPT_BOOL, 0 },
+ { "bootconf", IB_BOOTCONF, OPT_BOOL, 0 },
{ .name = NULL },
};
#undef OFFSET
============================================================
--- usr.sbin/installboot/installboot.h 1c8d7cc64741fcf00e45048d1a2438701230879a
+++ usr.sbin/installboot/installboot.h efe5905f229f39581617a33ffb84d573ba83dca2
@@ -65,6 +65,8 @@ typedef enum {
IB_PASSWORD = 1<<18, /* i386 boot password */
IB_KEYMAP = 1<<19, /* i386 console keymap */
IB_CONSADDR = 1<<20, /* i386 console io address */
+ IB_MODULES = 1<<21, /* i386: load modules */
+ IB_BOOTCONF = 1<<22, /* i386: read boot.conf */
} ib_flags;
typedef struct {
Home |
Main Index |
Thread Index |
Old Index