Skip to content

Commit 2471e15

Browse files
committed
cleanup initrd, improve population of lib directories, remove some extra drivers, add notes on /dev
1 parent 6dcbaeb commit 2471e15

9 files changed

Lines changed: 149 additions & 47 deletions

File tree

Makefile

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
all: coreboot
22

3+
force:
4+
-rm $(linux_dir)/arch/x86/boot/bzImage
35

46
kexec_version := 2.0.12
57
kexec_dir := kexec-tools-$(kexec_version)
@@ -27,7 +29,7 @@ busybox_url := https://busybox.net/downloads/$(busybox_tar)
2729
busybox_hash := 5a0fe06885ee1b805fb459ab6aaa023fe4f2eccee4fb8c0fd9a6c17c0daca2fc
2830
busybox_config := config/busybox.config
2931

30-
busybox: $(busybox_dir) $(busybox_dir)/.config
32+
$(busybox_dir)/busybox: $(busybox_dir) $(busybox_dir)/.config
3133
make -C "$(busybox_dir)" -j 8
3234

3335
$(busybox_dir): $(busybox_tar)
@@ -57,7 +59,14 @@ $(linux_dir)/.config: $(linux_config)
5759
cp "$<" "$@"
5860
make -C "$(linux_dir)" oldconfig
5961

60-
$(linux_dir)/arch/x86/boot/bzImage: $(linux_dir) $(linux_dir)/.config
62+
bzImage: $(linux_dir)/arch/x86/boot/bzImage
63+
64+
$(linux_dir)/arch/x86/boot/bzImage: \
65+
$(linux_dir) \
66+
$(linux_dir)/.config \
67+
initrd/bin/busybox \
68+
initrd/libs \
69+
6170
make -C "$(linux_dir)" bzImage
6271
ls -Fla "$@"
6372

@@ -81,6 +90,13 @@ $(coreboot_dir)/util/crossgcc/xgcc/bin/iasl:
8190
$(coreboot_dir)/bzImage: $(linux_dir)/arch/x86/boot/bzImage
8291
cp "$<" "$@"
8392

93+
initrd.img:
94+
( \
95+
cd initrd && \
96+
find . \
97+
| cpio --quiet -H newc -o \
98+
) | xz -9 > "$@"
99+
84100
# initrd image is now included by the Linux kernel build process
85101
initrd: \
86102
initrd/bin/busybox \
@@ -101,12 +117,7 @@ INITRD_LIBS += \
101117
libdl.so.2 \
102118

103119
initrd/libs:
104-
-mkdir -p initrd/lib/x86_64-linux-gnu
105-
-mkdir -p initrd/lib64
106-
cp /lib64/ld-linux-x86-64.so.2 initrd/lib64/
107-
for lib in $(INITRD_LIBS); do \
108-
cp "/lib/x86_64-linux-gnu/$$lib" initrd/lib/x86_64-linux-gnu/; \
109-
done
120+
./populate-lib ./initrd/lib/x86_64-linux-gnu/ initrd/bin/* initrd/sbin/*
110121

111122

112123
$(coreboot_tar):
@@ -134,7 +145,6 @@ $(coreboot_dir)/build/coreboot.rom: \
134145
$(coreboot_dir)/.config \
135146
$(coreboot_dir)/util/crossgcc/xgcc/bin/iasl \
136147
$(coreboot_dir)/bzImage \
137-
$(coreboot_dir)/initrd.img \
138148
$(coreboot-blobs_canary) \
139149

140150
make -C "$(coreboot_dir)"

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ Components:
2121
* kexec
2222
* tpmtotp
2323
* QubesOS (Xen)
24+
25+
---
26+
27+
Notes:
28+
29+
`initrd/dev/` must be populated with a few entries for things to work.
30+
At the least I've found that you need `console`, `mem`, `null`,
31+
`tty`, `tty0`, and `ttyS0`.
32+

config/busybox.config

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Automatically generated make config: don't edit
3-
# Busybox version: 1.26.0.git
4-
# Sun Jul 24 22:29:47 2016
3+
# Busybox version: 1.25.0
4+
# Wed Jul 27 23:30:27 2016
55
#
66
CONFIG_HAVE_DOT_CONFIG=y
77

@@ -25,7 +25,7 @@ CONFIG_FEATURE_VERBOSE_USAGE=y
2525
CONFIG_FEATURE_COMPRESS_USAGE=y
2626
CONFIG_BUSYBOX=y
2727
# CONFIG_FEATURE_INSTALLER is not set
28-
# CONFIG_INSTALL_NO_USR is not set
28+
CONFIG_INSTALL_NO_USR=y
2929
# CONFIG_LOCALE_SUPPORT is not set
3030
CONFIG_UNICODE_SUPPORT=y
3131
# CONFIG_UNICODE_USING_LOCALE is not set
@@ -354,14 +354,18 @@ CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y
354354
# CONFIG_FEATURE_RESIZE_PRINT is not set
355355
# CONFIG_SETCONSOLE is not set
356356
# CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS is not set
357-
# CONFIG_SETFONT is not set
358-
# CONFIG_FEATURE_SETFONT_TEXTUAL_MAP is not set
357+
CONFIG_SETFONT=y
358+
CONFIG_FEATURE_SETFONT_TEXTUAL_MAP=y
359359
CONFIG_DEFAULT_SETFONT_DIR=""
360360
# CONFIG_SETKEYCODES is not set
361361
# CONFIG_SETLOGCONS is not set
362362
# CONFIG_SHOWKEY is not set
363-
# CONFIG_FEATURE_LOADFONT_PSF2 is not set
364-
# CONFIG_FEATURE_LOADFONT_RAW is not set
363+
364+
#
365+
# Common options for loadfont and setfont
366+
#
367+
CONFIG_FEATURE_LOADFONT_PSF2=y
368+
CONFIG_FEATURE_LOADFONT_RAW=y
365369

366370
#
367371
# Debian Utilities

config/coreboot.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ CONFIG_MAX_PIRQ_LINKS=4
290290
# CONFIG_SOUTHBRIDGE_AMD_CIMX_SB900 is not set
291291
CONFIG_SOUTHBRIDGE_INTEL_C216=y
292292
CONFIG_SOUTH_BRIDGE_OPTIONS=y
293-
CONFIG_LOCK_SPI_ON_RESUME_NONE=y
294-
# CONFIG_LOCK_SPI_ON_RESUME_RO is not set
293+
# CONFIG_LOCK_SPI_ON_RESUME_NONE is not set
294+
CONFIG_LOCK_SPI_ON_RESUME_RO=y
295295
# CONFIG_LOCK_SPI_ON_RESUME_NO_ACCESS is not set
296296
CONFIG_SOUTHBRIDGE_INTEL_COMMON=y
297297
CONFIG_SOUTHBRIDGE_INTEL_COMMON_GPIO=y

config/linux.config

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ CONFIG_ARCH_SUPPORTS_INT128=y
138138
# CONFIG_SYSFS_DEPRECATED is not set
139139
# CONFIG_RELAY is not set
140140
CONFIG_BLK_DEV_INITRD=y
141-
CONFIG_INITRAMFS_SOURCE="../initrd/"
141+
CONFIG_INITRAMFS_SOURCE="../initrd"
142142
CONFIG_INITRAMFS_ROOT_UID=0
143143
CONFIG_INITRAMFS_ROOT_GID=0
144144
# CONFIG_RD_GZIP is not set
@@ -833,10 +833,10 @@ CONFIG_DM_VERITY_FEC=y
833833
# Input device support
834834
#
835835
CONFIG_INPUT=y
836-
CONFIG_INPUT_FF_MEMLESS=m
837-
CONFIG_INPUT_POLLDEV=m
836+
# CONFIG_INPUT_FF_MEMLESS is not set
837+
# CONFIG_INPUT_POLLDEV is not set
838838
# CONFIG_INPUT_SPARSEKMAP is not set
839-
CONFIG_INPUT_MATRIXKMAP=m
839+
# CONFIG_INPUT_MATRIXKMAP is not set
840840

841841
#
842842
# Userland interfaces
@@ -850,23 +850,23 @@ CONFIG_INPUT_MATRIXKMAP=m
850850
# Input Device Drivers
851851
#
852852
CONFIG_INPUT_KEYBOARD=y
853-
CONFIG_KEYBOARD_ADP5588=m
854-
CONFIG_KEYBOARD_ADP5589=m
853+
# CONFIG_KEYBOARD_ADP5588 is not set
854+
# CONFIG_KEYBOARD_ADP5589 is not set
855855
CONFIG_KEYBOARD_ATKBD=y
856-
CONFIG_KEYBOARD_QT1070=m
857-
CONFIG_KEYBOARD_QT2160=m
858-
CONFIG_KEYBOARD_LKKBD=m
859-
CONFIG_KEYBOARD_TCA6416=m
860-
CONFIG_KEYBOARD_TCA8418=m
861-
CONFIG_KEYBOARD_LM8333=m
862-
CONFIG_KEYBOARD_MAX7359=m
863-
CONFIG_KEYBOARD_MCS=m
864-
CONFIG_KEYBOARD_MPR121=m
865-
CONFIG_KEYBOARD_NEWTON=m
866-
CONFIG_KEYBOARD_OPENCORES=m
867-
CONFIG_KEYBOARD_STOWAWAY=m
868-
CONFIG_KEYBOARD_SUNKBD=m
869-
CONFIG_KEYBOARD_XTKBD=m
856+
# CONFIG_KEYBOARD_QT1070 is not set
857+
# CONFIG_KEYBOARD_QT2160 is not set
858+
# CONFIG_KEYBOARD_LKKBD is not set
859+
# CONFIG_KEYBOARD_TCA6416 is not set
860+
# CONFIG_KEYBOARD_TCA8418 is not set
861+
# CONFIG_KEYBOARD_LM8333 is not set
862+
# CONFIG_KEYBOARD_MAX7359 is not set
863+
# CONFIG_KEYBOARD_MCS is not set
864+
# CONFIG_KEYBOARD_MPR121 is not set
865+
# CONFIG_KEYBOARD_NEWTON is not set
866+
# CONFIG_KEYBOARD_OPENCORES is not set
867+
# CONFIG_KEYBOARD_STOWAWAY is not set
868+
# CONFIG_KEYBOARD_SUNKBD is not set
869+
# CONFIG_KEYBOARD_XTKBD is not set
870870
# CONFIG_INPUT_MOUSE is not set
871871
# CONFIG_INPUT_JOYSTICK is not set
872872
# CONFIG_INPUT_TABLET is not set
@@ -880,7 +880,7 @@ CONFIG_KEYBOARD_XTKBD=m
880880
CONFIG_SERIO=y
881881
CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y
882882
CONFIG_SERIO_I8042=y
883-
CONFIG_SERIO_SERPORT=m
883+
# CONFIG_SERIO_SERPORT is not set
884884
# CONFIG_SERIO_CT82C710 is not set
885885
# CONFIG_SERIO_PCIPS2 is not set
886886
CONFIG_SERIO_LIBPS2=y
@@ -956,11 +956,11 @@ CONFIG_HW_RANDOM_TPM=m
956956
# CONFIG_HANGCHECK_TIMER is not set
957957
CONFIG_TCG_TPM=y
958958
CONFIG_TCG_TIS=y
959-
CONFIG_TCG_TIS_I2C_ATMEL=m
960-
CONFIG_TCG_TIS_I2C_INFINEON=m
961-
CONFIG_TCG_TIS_I2C_NUVOTON=m
962-
CONFIG_TCG_NSC=m
963-
CONFIG_TCG_ATMEL=m
959+
# CONFIG_TCG_TIS_I2C_ATMEL is not set
960+
# CONFIG_TCG_TIS_I2C_INFINEON is not set
961+
# CONFIG_TCG_TIS_I2C_NUVOTON is not set
962+
# CONFIG_TCG_NSC is not set
963+
# CONFIG_TCG_ATMEL is not set
964964
# CONFIG_TCG_INFINEON is not set
965965
# CONFIG_TCG_CRB is not set
966966
# CONFIG_TELCLOCK is not set

initrd/init

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
#!/bin/ash
2-
echo "Hello coreboot initrd"
2+
echo '====================================================='
3+
echo ' _ _ _ ____ ___ __ __ '
4+
echo '| | | | ___ __ _ __| |___ _ | _ \ / _ \| \/ |'
5+
echo '| |_| |/ _ \/ _` |/ _` / __| (_) | |_) | | | | |\/| |'
6+
echo '| _ | __/ (_| | (_| \__ \ _ | _ <| |_| | | | |'
7+
echo '|_| |_|\___|\__,_|\__,_|___/ (_) |_| \_\\___/|_| |_|'
8+
echo ''
9+
echo '====================================================='
310

411
# Mount the system directories
5-
mkdir /proc /sys /dev /tmp /boot
12+
mkdir /proc /sys /dev /tmp /boot 2>/dev/null
13+
614
mount -t proc none /proc
715
mount -t sysfs none /sys
816
mount -t devtmpfs none /dev
917

18+
## Ensure that we load libraries from our directory
19+
#export LD_LIBRARY_PATH=/lib64
20+
1021
# Start an interactive shell
22+
echo "Run './start-xen' to load the hypervisor"
23+
echo "Run 'kexec -e' to boot it"
24+
echo
25+
1126
exec /bin/ash

initrd/lib64/ld-linux-x86-64.so.2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../lib/x86_64-linux-gnu/ld-linux-x86-64.so.2

initrd/start-xen

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ exec kexec \
66
--module "/boot/vmlinuz-4.1.13-9.pvops.qubes.x86_64 placeholder root=/dev/mapper/qubes_dom0-root ro i915.preliminary_hw_support=1 rd.lvm.lv=qubes_dom0/root rd.luks.uuid=luks-0f662ac6-2939-48fe-bc95-f5a7e3d6fefb vconsole.font=latarcyrheb-sun16 rd.lvm.lv=qubes_dom0/swap rhgb" \
77
--module "/boot/initramfs-4.1.13-9.pvops.qubes.x86_64.img" \
88
--command-line "console=vga dom0_mem=min:1024M dom0_mem=max:4096M" \
9-
/xen-4.6.3.gz
9+
/boot/xen-4.6.3.gz

populate-lib

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/perl
2+
# Find all libraries for the executables
3+
#
4+
use warnings;
5+
use strict;
6+
use Data::Dumper;
7+
use File::Copy;
8+
use File::Basename;
9+
10+
my $dest = shift
11+
or die "Usage: $0 dest-dir [programs...]\n";
12+
13+
my %libraries;
14+
15+
for my $file (@ARGV)
16+
{
17+
my @libs = `ldd "$file"`;
18+
for (@libs)
19+
{
20+
if (/ => ([^ ]+)/)
21+
{
22+
# Normal library
23+
$libraries{$1}++;
24+
}
25+
elsif (/^\s+([^ ]+) \(/)
26+
{
27+
# Dynamic linker
28+
$libraries{$1}++;
29+
}
30+
}
31+
}
32+
33+
print Dumper(\%libraries);
34+
35+
unless( -d $dest )
36+
{
37+
system("mkdir", "-p", $dest)
38+
and die "$dest: Unable to make directory: $!\n";
39+
}
40+
41+
my $size = 0;
42+
43+
for my $lib (keys %libraries)
44+
{
45+
$size += -s $lib;
46+
my $libname = basename $lib;
47+
# my $dirname = dirname "$dest/$lib";
48+
#
49+
# unless( -d $dirname )
50+
# {
51+
# system("mkdir", "-p", $dirname)
52+
# and die "$dirname: Unable to make directory: $!\n";
53+
# }
54+
55+
copy $lib, "$dest/$libname"
56+
or die "$lib: Unable to copy: $!\n";
57+
58+
# make them executable because otherwise chroot barfs
59+
system("chmod", "+x", "$dest/$libname");
60+
}
61+
62+
print "Total size $size\n";
63+
__END__

0 commit comments

Comments
 (0)