add complete build system
parent
700a1b10b3
commit
e5a5b64c61
@ -1,2 +1,15 @@
|
|||||||
|
.*
|
||||||
|
buildroot-2022.02.1.tar.xz
|
||||||
|
buildroot-2022.02.1/
|
||||||
|
busybox-1.20.0.tar.bz2
|
||||||
|
busybox-1.20.0/
|
||||||
|
linux-5.17.2.tar.xz
|
||||||
|
linux-5.17.2/
|
||||||
|
|
||||||
floppy.img
|
floppy.img
|
||||||
|
floppy/boot/busyboz
|
||||||
|
floppy/boot/bzImage
|
||||||
|
floppy/lib/
|
||||||
|
modules.img
|
||||||
|
modules/
|
||||||
preinit/init
|
preinit/init
|
||||||
|
@ -1,14 +1,38 @@
|
|||||||
# linux-486
|
# linux-486
|
||||||
|
|
||||||
This repo provides the files necessary to build a Linux-based "operating system" for old i486 systems with at least 8MB of RAM.
|
This repo provides the files necessary to build a Linux-based "operating system" for old i486 systems with at least 8MB of RAM. Build scripts for all components of the sysem are provided. An i486-linux toolchain is also built, enabling you to compile other programs for the system.
|
||||||
|
|
||||||
The generated single floppy disk image allows you to boot into a Busybox system that is kept entirely in memory, freeing up the floppy disk drive for other disks/data.
|
The generated boot floppy disk provides you with a Busybox system that is kept entirely in memory. uClibc's shared library files are also loaded into memory, allowing other programs to save on memory (as opposed to using static binaries).
|
||||||
|
|
||||||
The boot process goes:
|
A second floppy containing additional kernel modules can also be generated. Both floppies are ext2 formatted.
|
||||||
* GRUB 0.96 boots Linux.
|
|
||||||
* Linux loads an embedded initramfs with a "preinit" init binary.
|
|
||||||
* "preinit" mounts the floppy disk, decompresses busybox into the root ramdisk filesystem, then unmounts the floppy.
|
|
||||||
* busybox runs its own init process, bringing you to a shell.
|
|
||||||
|
|
||||||
To test the floppy image with QEMU, provide at least 8320K of RAM.
|
## Build requirements
|
||||||
|
|
||||||
|
* building tools (make, gcc, linux's requirements, etc.)
|
||||||
|
* bash
|
||||||
|
* wget
|
||||||
|
* tar, xz, bzip2
|
||||||
|
|
||||||
|
## Build steps
|
||||||
|
|
||||||
|
Run the build scripts in this order:
|
||||||
|
|
||||||
|
1. `build-toolchain.sh` (after this script, add ~/i486-linux/bin to your PATH)
|
||||||
|
2. `build-linux.sh`
|
||||||
|
3. `build-busybox.sh`
|
||||||
|
4. `build-floppy.sh`
|
||||||
|
5. `build-modules.sh`
|
||||||
|
|
||||||
|
After successful execution of all scripts, you should have `floppy.img` (boot image) and `modules.img` (modules). These can be `dd`'d to a 1.44M 3.5" floppy disk.
|
||||||
|
|
||||||
|
## Booting the system
|
||||||
|
|
||||||
|
The system requires an i486 or better processor, a 3.5" floppy drive, and at least 8MB of RAM (8320K for QEMU).
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
* Once the system is booted, the floppy disk can be removed.
|
||||||
|
* root's password is `toor`.
|
||||||
|
* Mount the modules floppy to `/lib/modules`; then, use `modprobe` for loading and unloading.
|
||||||
|
* The `msdos` module may need to be loaded to read MS-DOS/FAT floppies.
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -e ./busybox-1.20.0.tar.bz2 ] ; then
|
||||||
|
echo "Fetching busybox..."
|
||||||
|
wget https://www.busybox.net/downloads/busybox-1.20.0.tar.bz2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e ./busybox-1.20.0 ] ; then
|
||||||
|
echo "Extracting busybox..."
|
||||||
|
tar xf busybox-1.20.0.tar.bz2
|
||||||
|
cp config-busybox-1.20.0 busybox-1.20.0/.config
|
||||||
|
cd busybox-1.20.0
|
||||||
|
patch include/libbb.h < ../busybox/libbb.h.patch
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
make -C busybox-1.20.0 -j8
|
||||||
|
|
||||||
|
lzma -zc9 busybox-1.20.0/busybox > floppy/boot/busyboz
|
||||||
|
echo "Busybox is now installed to the floppy folder."
|
||||||
|
|
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
dd if=/dev/zero of=floppy.img bs=1k count=1440
|
||||||
|
mkfs.ext2 -b 1024 -i 65536 -I 128 -m 0 -r 0 -T floppy -d floppy floppy.img
|
||||||
|
|
||||||
|
sudo mount floppy.img /mnt -oloop
|
||||||
|
sudo mkdir /mnt/dev
|
||||||
|
sudo mount devtmpfs /mnt/dev -t devtmpfs
|
||||||
|
|
||||||
|
sudo chown -R root:root /mnt/*
|
||||||
|
sudo lilo -v -g -b /dev/loop0 -r /mnt -C /boot/lilo.conf
|
||||||
|
|
||||||
|
sudo umount /mnt/dev
|
||||||
|
sudo rmdir /mnt/dev
|
||||||
|
df -h /mnt
|
||||||
|
sudo umount /mnt
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -e ./linux-5.17.2.tar.xz ] ; then
|
||||||
|
echo "Fetching Linux..."
|
||||||
|
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.17.2.tar.xz
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e ./linux-5.17.2 ] ; then
|
||||||
|
echo "Extracting Linux..."
|
||||||
|
tar xf ./linux-5.17.2.tar.xz
|
||||||
|
cp config-5.17.2tiny ./linux-5.17.2/.config
|
||||||
|
|
||||||
|
cd ./linux-5.17.2
|
||||||
|
|
||||||
|
echo "Patching Linux..."
|
||||||
|
patch usr/gen_initramfs.sh < ../linux/patches/gen_initramfs.sh.patch
|
||||||
|
# TODO: Other patches necessary? They do save some space...
|
||||||
|
else
|
||||||
|
cd ./linux-5.17.2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating initramfs file structure..."
|
||||||
|
sudo rm -rf initrd
|
||||||
|
mkdir -p initrd/{bin,dev/pts,etc/init.d,lib/modules,mnt,proc,root,run,sys}
|
||||||
|
cp ../linux/{fstab,group,inittab,passwd} initrd/etc
|
||||||
|
|
||||||
|
make -C ../preinit
|
||||||
|
cp ../preinit/init initrd/init
|
||||||
|
|
||||||
|
echo "Calling sudo to create initramfs's /dev/console..."
|
||||||
|
sudo mknod initrd/dev/console c 5 1
|
||||||
|
|
||||||
|
echo "Building Linux..."
|
||||||
|
make -j8
|
||||||
|
|
||||||
|
echo "Calling sudo to copy bzImage to the floppy folder..."
|
||||||
|
sudo cp arch/x86/boot/bzImage ../floppy/boot/bzImage
|
||||||
|
|
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Building ./modules/ floppy folder..."
|
||||||
|
|
||||||
|
rm -rf ./modules
|
||||||
|
INSTALL_MOD_PATH=$(pwd)/modules make -C linux-5.17.2 modules_install
|
||||||
|
mv modules/lib/modules/* modules/
|
||||||
|
rmdir modules/lib/modules modules/lib
|
||||||
|
rm modules/5.17.2clyne/{source,build}
|
||||||
|
find modules/ -type f -name "*.ko" -exec strip --strip-debug {} \;
|
||||||
|
du -sh ./modules
|
||||||
|
|
||||||
|
echo "Creating modules.img..."
|
||||||
|
|
||||||
|
dd if=/dev/zero of=modules.img bs=1k count=1440
|
||||||
|
mkfs.vfat -F 12 modules.img
|
||||||
|
sudo mount -oloop modules.img /mnt
|
||||||
|
sudo cp -R modules/* /mnt/
|
||||||
|
sudo chown root:root /mnt/*
|
||||||
|
df -h /mnt
|
||||||
|
sudo umount /mnt
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -e ./buildroot-2022.02.1.tar.xz ] ; then
|
||||||
|
echo "Fetching buildroot..."
|
||||||
|
wget https://buildroot.org/downloads/buildroot-2022.02.1.tar.xz
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e ./buildroot-2022.02.1 ] ; then
|
||||||
|
echo "Extracting buildroot..."
|
||||||
|
tar xf buildroot-2022.02.1.tar.xz
|
||||||
|
|
||||||
|
cp config-buildroot-2022.02.1 buildroot-2022.02.1/.config
|
||||||
|
cp config-uclibc buildroot-2022.02.1/config-uclibc
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building with sudo..."
|
||||||
|
sudo make -C buildroot-2022.02.1 toolchain -j8
|
||||||
|
|
||||||
|
echo "Installing i486-linux toolchain to ~ (and adding to PATH)..."
|
||||||
|
cp -R buildroot-2022.02.1/output/host ~/i486-linux
|
||||||
|
export PATH=$PATH:~/i486-linux/bin
|
||||||
|
|
||||||
|
echo "Copying libc files to the floppy folder..."
|
||||||
|
mkdir floppy/lib
|
||||||
|
sudo strip buildroot-2022.02.1/output/target/lib/ld-uClibc-1.0.40.so
|
||||||
|
sudo strip buildroot-2022.02.1/output/target/lib/libuClibc-1.0.40.so
|
||||||
|
sudo bash -c "lzma -zc9 buildroot-2022.02.1/output/target/lib/ld-uClibc-1.0.40.so > floppy/lib/lduClibc.lzm"
|
||||||
|
sudo bash -c "lzma -zc9 buildroot-2022.02.1/output/target/lib/libuClibc-1.0.40.so > floppy/lib/libc.lzm"
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cp base.img floppy.img
|
|
||||||
sudo mount -oloop floppy.img /mnt
|
|
||||||
sudo chown -R root:root floppy/
|
|
||||||
sudo rsync -av floppy/ /mnt/
|
|
||||||
df -h /mnt
|
|
||||||
sudo umount /mnt
|
|
@ -0,0 +1,10 @@
|
|||||||
|
--- include/libbb.h 2012-04-21 21:33:23.000000000 -0400
|
||||||
|
+++ include/libbb.h.new 2022-04-29 20:49:40.674509941 -0400
|
||||||
|
@@ -40,6 +40,7 @@
|
||||||
|
#include <sys/poll.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
+#include <sys/resource.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,241 @@
|
|||||||
|
#
|
||||||
|
# Automatically generated file; DO NOT EDIT.
|
||||||
|
# uClibc-ng 1.0.40 C Library Configuration
|
||||||
|
#
|
||||||
|
# TARGET_aarch64 is not set
|
||||||
|
# TARGET_alpha is not set
|
||||||
|
# TARGET_arc is not set
|
||||||
|
# TARGET_arm is not set
|
||||||
|
# TARGET_avr32 is not set
|
||||||
|
# TARGET_bfin is not set
|
||||||
|
# TARGET_c6x is not set
|
||||||
|
# TARGET_cris is not set
|
||||||
|
# TARGET_csky is not set
|
||||||
|
# TARGET_frv is not set
|
||||||
|
# TARGET_h8300 is not set
|
||||||
|
# TARGET_hppa is not set
|
||||||
|
TARGET_i386=y
|
||||||
|
# TARGET_ia64 is not set
|
||||||
|
# TARGET_kvx is not set
|
||||||
|
# TARGET_lm32 is not set
|
||||||
|
# TARGET_m68k is not set
|
||||||
|
# TARGET_metag is not set
|
||||||
|
# TARGET_microblaze is not set
|
||||||
|
# TARGET_mips is not set
|
||||||
|
# TARGET_nds32 is not set
|
||||||
|
# TARGET_nios2 is not set
|
||||||
|
# TARGET_or1k is not set
|
||||||
|
# TARGET_powerpc is not set
|
||||||
|
# TARGET_riscv64 is not set
|
||||||
|
# TARGET_sh is not set
|
||||||
|
# TARGET_sparc is not set
|
||||||
|
# TARGET_sparc64 is not set
|
||||||
|
# TARGET_tile is not set
|
||||||
|
# TARGET_x86_64 is not set
|
||||||
|
# TARGET_xtensa is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Target Architecture Features and Options
|
||||||
|
#
|
||||||
|
TARGET_ARCH="i386"
|
||||||
|
FORCE_OPTIONS_FOR_ARCH=y
|
||||||
|
# CONFIG_386 is not set
|
||||||
|
CONFIG_486=y
|
||||||
|
# CONFIG_586 is not set
|
||||||
|
# CONFIG_686 is not set
|
||||||
|
TARGET_SUBARCH="i486"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Using ELF file format
|
||||||
|
#
|
||||||
|
ARCH_HAS_DEPRECATED_SYSCALLS=y
|
||||||
|
ARCH_LITTLE_ENDIAN=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Using Little Endian
|
||||||
|
#
|
||||||
|
ARCH_HAS_MMU=y
|
||||||
|
ARCH_USE_MMU=y
|
||||||
|
UCLIBC_HAS_FLOATS=y
|
||||||
|
UCLIBC_HAS_FPU=y
|
||||||
|
# DO_C99_MATH is not set
|
||||||
|
# DO_XSI_MATH is not set
|
||||||
|
# UCLIBC_HAS_FENV is not set
|
||||||
|
KERNEL_HEADERS="/home/clyne/Programming/486/buildroot-2022.02.1/output/build/linux-headers-5.17.2/usr/include"
|
||||||
|
HAVE_DOT_CONFIG=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# General Library Settings
|
||||||
|
#
|
||||||
|
DOPIC=y
|
||||||
|
ARCH_HAS_UCONTEXT=y
|
||||||
|
HAVE_SHARED=y
|
||||||
|
# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
|
||||||
|
LDSO_LDD_SUPPORT=y
|
||||||
|
# LDSO_CACHE_SUPPORT is not set
|
||||||
|
LDSO_PRELOAD_ENV_SUPPORT=y
|
||||||
|
# LDSO_PRELOAD_FILE_SUPPORT is not set
|
||||||
|
LDSO_STANDALONE_SUPPORT=y
|
||||||
|
LDSO_PRELINK_SUPPORT=y
|
||||||
|
# UCLIBC_STATIC_LDCONFIG is not set
|
||||||
|
# LDSO_RUNPATH is not set
|
||||||
|
LDSO_SEARCH_INTERP_PATH=y
|
||||||
|
LDSO_LD_LIBRARY_PATH=y
|
||||||
|
UCLIBC_CTOR_DTOR=y
|
||||||
|
# LDSO_GNU_HASH_SUPPORT is not set
|
||||||
|
# HAS_NO_THREADS is not set
|
||||||
|
# UCLIBC_HAS_LINUXTHREADS is not set
|
||||||
|
UCLIBC_HAS_THREADS_NATIVE=y
|
||||||
|
UCLIBC_HAS_THREADS=y
|
||||||
|
UCLIBC_HAS_TLS=y
|
||||||
|
# PTHREADS_DEBUG_SUPPORT is not set
|
||||||
|
UCLIBC_HAS_SYSLOG=y
|
||||||
|
UCLIBC_HAS_LFS=y
|
||||||
|
# MALLOC is not set
|
||||||
|
# MALLOC_SIMPLE is not set
|
||||||
|
MALLOC_STANDARD=y
|
||||||
|
UCLIBC_DYNAMIC_ATEXIT=y
|
||||||
|
# UCLIBC_HAS_UTMPX is not set
|
||||||
|
# UCLIBC_SUSV2_LEGACY is not set
|
||||||
|
UCLIBC_SUSV3_LEGACY=y
|
||||||
|
UCLIBC_HAS_CONTEXT_FUNCS=y
|
||||||
|
UCLIBC_SUSV3_LEGACY_MACROS=y
|
||||||
|
UCLIBC_SUSV4_LEGACY=y
|
||||||
|
UCLIBC_STRICT_HEADERS=y
|
||||||
|
# UCLIBC_HAS_STUBS is not set
|
||||||
|
# UCLIBC_HAS_SHADOW is not set
|
||||||
|
# UCLIBC_HAS_PROGRAM_INVOCATION_NAME is not set
|
||||||
|
# UCLIBC_HAS___PROGNAME is not set
|
||||||
|
UCLIBC_HAS_PTY=y
|
||||||
|
ASSUME_DEVPTS=y
|
||||||
|
UNIX98PTY_ONLY=y
|
||||||
|
UCLIBC_HAS_GETPT=y
|
||||||
|
# UCLIBC_HAS_LIBUTIL is not set
|
||||||
|
UCLIBC_HAS_TM_EXTENSIONS=y
|
||||||
|
UCLIBC_HAS_TZ_CACHING=y
|
||||||
|
# UCLIBC_HAS_TZ_FILE is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Advanced Library Settings
|
||||||
|
#
|
||||||
|
UCLIBC_PWD_BUFFER_SIZE=256
|
||||||
|
UCLIBC_GRP_BUFFER_SIZE=256
|
||||||
|
|
||||||
|
#
|
||||||
|
# Support various families of functions
|
||||||
|
#
|
||||||
|
UCLIBC_LINUX_SPECIFIC=y
|
||||||
|
UCLIBC_HAS_GNU_ERROR=y
|
||||||
|
UCLIBC_BSD_SPECIFIC=y
|
||||||
|
# UCLIBC_HAS_BSD_ERR is not set
|
||||||
|
# UCLIBC_HAS_OBSOLETE_BSD_SIGNAL is not set
|
||||||
|
# UCLIBC_HAS_BSD_B64_NTOP_B64_PTON is not set
|
||||||
|
# UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL is not set
|
||||||
|
# UCLIBC_NTP_LEGACY is not set
|
||||||
|
# UCLIBC_SV4_DEPRECATED is not set
|
||||||
|
UCLIBC_HAS_REALTIME=y
|
||||||
|
UCLIBC_HAS_ADVANCED_REALTIME=y
|
||||||
|
UCLIBC_HAS_EPOLL=y
|
||||||
|
# UCLIBC_HAS_XATTR is not set
|
||||||
|
# UCLIBC_HAS_PROFILING is not set
|
||||||
|
# UCLIBC_HAS_CRYPT_IMPL is not set
|
||||||
|
UCLIBC_HAS_CRYPT_STUB=y
|
||||||
|
UCLIBC_HAS_CRYPT=y
|
||||||
|
UCLIBC_HAS_NETWORK_SUPPORT=y
|
||||||
|
UCLIBC_HAS_SOCKET=y
|
||||||
|
UCLIBC_HAS_IPV4=y
|
||||||
|
UCLIBC_HAS_IPV6=y
|
||||||
|
# UCLIBC_USE_NETLINK is not set
|
||||||
|
# UCLIBC_HAS_BSD_RES_CLOSE is not set
|
||||||
|
UCLIBC_HAS_COMPAT_RES_STATE=y
|
||||||
|
# UCLIBC_HAS_EXTRA_COMPAT_RES_STATE is not set
|
||||||
|
UCLIBC_HAS_RESOLVER_SUPPORT=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# String and Stdio Support
|
||||||
|
#
|
||||||
|
# UCLIBC_HAS_STRING_GENERIC_OPT is not set
|
||||||
|
UCLIBC_HAS_STRING_ARCH_OPT=y
|
||||||
|
UCLIBC_HAS_STDIO_FUTEXES=y
|
||||||
|
UCLIBC_HAS_CTYPE_TABLES=y
|
||||||
|
UCLIBC_HAS_CTYPE_SIGNED=y
|
||||||
|
UCLIBC_HAS_CTYPE_UNSAFE=y
|
||||||
|
# UCLIBC_HAS_CTYPE_CHECKED is not set
|
||||||
|
# UCLIBC_HAS_CTYPE_ENFORCED is not set
|
||||||
|
UCLIBC_HAS_WCHAR=y
|
||||||
|
UCLIBC_HAS_LIBICONV=y
|
||||||
|
UCLIBC_HAS_LIBINTL=y
|
||||||
|
# UCLIBC_HAS_LOCALE is not set
|
||||||
|
# UCLIBC_HAS_HEXADECIMAL_FLOATS is not set
|
||||||
|
UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
|
||||||
|
UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
|
||||||
|
UCLIBC_HAS_STDIO_BUFSIZ_4096=y
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
|
||||||
|
UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
|
||||||
|
# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
|
||||||
|
UCLIBC_HAS_STDIO_GETC_MACRO=y
|
||||||
|
UCLIBC_HAS_STDIO_PUTC_MACRO=y
|
||||||
|
UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
|
||||||
|
# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
|
||||||
|
UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
|
||||||
|
# UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE is not set
|
||||||
|
# UCLIBC_HAS_GLIBC_CUSTOM_STREAMS is not set
|
||||||
|
UCLIBC_HAS_PRINTF_M_SPEC=y
|
||||||
|
UCLIBC_HAS_ERRNO_MESSAGES=y
|
||||||
|
# UCLIBC_HAS_SYS_ERRLIST is not set
|
||||||
|
UCLIBC_HAS_SIGNUM_MESSAGES=y
|
||||||
|
# UCLIBC_HAS_SYS_SIGLIST is not set
|
||||||
|
UCLIBC_HAS_GNU_GETOPT=y
|
||||||
|
UCLIBC_HAS_GETOPT_LONG=y
|
||||||
|
UCLIBC_HAS_GNU_GETSUBOPT=y
|
||||||
|
# UCLIBC_HAS_ARGP is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Big and Tall
|
||||||
|
#
|
||||||
|
UCLIBC_HAS_REGEX=y
|
||||||
|
UCLIBC_HAS_FNMATCH=y
|
||||||
|
UCLIBC_HAS_WORDEXP=y
|
||||||
|
# UCLIBC_HAS_NFTW is not set
|
||||||
|
# UCLIBC_HAS_FTW is not set
|
||||||
|
# UCLIBC_HAS_FTS is not set
|
||||||
|
UCLIBC_HAS_GLOB=y
|
||||||
|
UCLIBC_HAS_GNU_GLOB=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Library Installation Options
|
||||||
|
#
|
||||||
|
RUNTIME_PREFIX="/"
|
||||||
|
DEVEL_PREFIX="/usr"
|
||||||
|
MULTILIB_DIR="lib"
|
||||||
|
HARDWIRED_ABSPATH=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Security options
|
||||||
|
#
|
||||||
|
# UCLIBC_BUILD_PIE is not set
|
||||||
|
# UCLIBC_HAS_SSP is not set
|
||||||
|
UCLIBC_BUILD_RELRO=y
|
||||||
|
UCLIBC_BUILD_NOW=y
|
||||||
|
UCLIBC_BUILD_NOEXECSTACK=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Development/debugging options
|
||||||
|
#
|
||||||
|
CROSS_COMPILER_PREFIX="/home/clyne/Programming/486/buildroot-2022.02.1/output/host/bin/i486-buildroot-linux-uclibc-"
|
||||||
|
UCLIBC_EXTRA_CFLAGS=""
|
||||||
|
# DODEBUG is not set
|
||||||
|
DOSTRIP=y
|
||||||
|
# DOASSERTS is not set
|
||||||
|
# SUPPORT_LD_DEBUG is not set
|
||||||
|
# SUPPORT_LD_DEBUG_EARLY is not set
|
||||||
|
# UCLIBC_MALLOC_DEBUGGING is not set
|
||||||
|
# UCLIBC_HAS_BACKTRACE is not set
|
||||||
|
WARNINGS=""
|
||||||
|
# EXTRA_WARNINGS is not set
|
@ -1,9 +0,0 @@
|
|||||||
default 0
|
|
||||||
root (fd0)
|
|
||||||
|
|
||||||
title Clyne/Linux
|
|
||||||
kernel /boot/bzImage root=/dev/ram0 rw vga=788
|
|
||||||
|
|
||||||
title Reboot
|
|
||||||
reboot
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,11 @@
|
|||||||
|
disk=/dev/loop0
|
||||||
|
bios=0
|
||||||
|
sectors=18
|
||||||
|
heads=2
|
||||||
|
cylinders=80
|
||||||
|
backup=/dev/null
|
||||||
|
install=text
|
||||||
|
compact
|
||||||
|
image=/boot/bzImage
|
||||||
|
label=linux
|
||||||
|
append="root=/dev/ram0 rw"
|
@ -0,0 +1,5 @@
|
|||||||
|
none /proc proc defaults 0 0
|
||||||
|
#devpts /dev/pts devpts gid=5,mode=620 0 0
|
||||||
|
#devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
|
||||||
|
sysfs /sys sysfs defaults 0 0
|
||||||
|
tmpfs /run tmpfs defaults 0 0
|
@ -0,0 +1 @@
|
|||||||
|
root::0:root
|
@ -0,0 +1,51 @@
|
|||||||
|
# Note: BusyBox init works just fine without an inittab. If no inittab is
|
||||||
|
# found, it has the following default behavior:
|
||||||
|
# ::sysinit:/etc/init.d/rcS
|
||||||
|
# ::askfirst:/bin/sh
|
||||||
|
# ::ctrlaltdel:/sbin/reboot
|
||||||
|
# ::shutdown:/sbin/swapoff -a
|
||||||
|
# ::shutdown:/bin/umount -a -r
|
||||||
|
# ::restart:/sbin/init
|
||||||
|
# tty2::askfirst:/bin/sh
|
||||||
|
# tty3::askfirst:/bin/sh
|
||||||
|
# tty4::askfirst:/bin/sh
|
||||||
|
#
|
||||||
|
# Boot-time system configuration/initialization script.
|
||||||
|
# This is run first except when booting in single-user mode.
|
||||||
|
#
|
||||||
|
#::sysinit:/etc/init.d/rcS
|
||||||
|
::sysinit:/bin/mount -a
|
||||||
|
|
||||||
|
# /bin/sh invocations on selected ttys
|
||||||
|
#
|
||||||
|
# Note below that we prefix the shell commands with a "-" to indicate to the
|
||||||
|
# shell that it is supposed to be a login shell. Normally this is handled by
|
||||||
|
# login, but since we are bypassing login in this case, BusyBox lets you do
|
||||||
|
# this yourself...
|
||||||
|
#
|
||||||
|
# Start an "askfirst" shell on the console (whatever that may be)
|
||||||
|
::askfirst:-/bin/sh
|
||||||
|
# Start an "askfirst" shell on /dev/tty2-4
|
||||||
|
#tty2::askfirst:-/bin/sh
|
||||||
|
#tty3::askfirst:-/bin/sh
|
||||||
|
#tty4::askfirst:-/bin/sh
|
||||||
|
|
||||||
|
# /bin/getty invocations for selected ttys
|
||||||
|
#tty4::respawn:/bin/getty 38400 tty5
|
||||||
|
#tty5::respawn:/bin/getty 38400 tty6
|
||||||
|
|
||||||
|
# Example of how to put a getty on a serial line (for a terminal)
|
||||||
|
::respawn:/bin/getty -L ttyS0 9600 vt100
|
||||||
|
#::respawn:/bin/getty -L ttyS1 9600 vt100
|
||||||
|
#
|
||||||
|
# Example how to put a getty on a modem line.
|
||||||
|
#::respawn:/bin/getty 57600 ttyS2
|
||||||
|
|
||||||
|
# Stuff to do when restarting the init process
|
||||||
|
::restart:/bin/init
|
||||||
|
|
||||||
|
# Stuff to do before rebooting
|
||||||
|
#::ctrlaltdel:/bin/reboot
|
||||||
|
::shutdown:/bin/umount -a -r
|
||||||
|
#::shutdown:/bin/swapoff -a
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
root:Dtd09GUh1f5sY:0:0:root:/root:/bin/sh
|
@ -0,0 +1,156 @@
|
|||||||
|
--- arch/x86/kernel/cpu/bugs.c.new 2022-04-21 10:22:57.337425325 -0400
|
||||||
|
+++ arch/x86/kernel/cpu/bugs.c 2022-04-21 10:34:47.550249356 -0400
|
||||||
|
@@ -36,6 +36,7 @@
|
||||||
|
|
||||||
|
#include "cpu.h"
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
static void __init spectre_v1_select_mitigation(void);
|
||||||
|
static void __init spectre_v2_select_mitigation(void);
|
||||||
|
static void __init ssb_select_mitigation(void);
|
||||||
|
@@ -45,6 +46,7 @@
|
||||||
|
static void __init taa_select_mitigation(void);
|
||||||
|
static void __init srbds_select_mitigation(void);
|
||||||
|
static void __init l1d_flush_select_mitigation(void);
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
|
||||||
|
/* The base value of the SPEC_CTRL MSR that always has to be preserved. */
|
||||||
|
u64 x86_spec_ctrl_base;
|
||||||
|
@@ -112,6 +114,7 @@
|
||||||
|
if (boot_cpu_has(X86_FEATURE_STIBP))
|
||||||
|
x86_spec_ctrl_mask |= SPEC_CTRL_STIBP;
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
/* Select the proper CPU mitigations before patching alternatives: */
|
||||||
|
spectre_v1_select_mitigation();
|
||||||
|
spectre_v2_select_mitigation();
|
||||||
|
@@ -127,6 +130,7 @@
|
||||||
|
* mitigation until after TAA mitigation selection is done.
|
||||||
|
*/
|
||||||
|
mds_print_mitigation();
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
|
||||||
|
arch_smt_update();
|
||||||
|
|
||||||
|
@@ -248,6 +252,7 @@
|
||||||
|
[MDS_MITIGATION_VMWERV] = "Vulnerable: Clear CPU buffers attempted, no microcode",
|
||||||
|
};
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
static void __init mds_select_mitigation(void)
|
||||||
|
{
|
||||||
|
if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) {
|
||||||
|
@@ -274,6 +279,7 @@
|
||||||
|
|
||||||
|
pr_info("%s\n", mds_strings[mds_mitigation]);
|
||||||
|
}
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
|
||||||
|
static int __init mds_cmdline(char *str)
|
||||||
|
{
|
||||||
|
@@ -317,6 +323,7 @@
|
||||||
|
[TAA_MITIGATION_TSX_DISABLED] = "Mitigation: TSX disabled",
|
||||||
|
};
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
static void __init taa_select_mitigation(void)
|
||||||
|
{
|
||||||
|
u64 ia32_cap;
|
||||||
|
@@ -388,6 +395,7 @@
|
||||||
|
out:
|
||||||
|
pr_info("%s\n", taa_strings[taa_mitigation]);
|
||||||
|
}
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
|
||||||
|
static int __init tsx_async_abort_parse_cmdline(char *str)
|
||||||
|
{
|
||||||
|
@@ -463,6 +471,7 @@
|
||||||
|
wrmsrl(MSR_IA32_MCU_OPT_CTRL, mcu_ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
static void __init srbds_select_mitigation(void)
|
||||||
|
{
|
||||||
|
u64 ia32_cap;
|
||||||
|
@@ -487,6 +496,7 @@
|
||||||
|
update_srbds_msr();
|
||||||
|
pr_info("%s\n", srbds_strings[srbds_mitigation]);
|
||||||
|
}
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
|
||||||
|
static int __init srbds_parse_cmdline(char *str)
|
||||||
|
{
|
||||||
|
@@ -504,6 +514,7 @@
|
||||||
|
#undef pr_fmt
|
||||||
|
#define pr_fmt(fmt) "L1D Flush : " fmt
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
enum l1d_flush_mitigations {
|
||||||
|
L1D_FLUSH_OFF = 0,
|
||||||
|
L1D_FLUSH_ON,
|
||||||
|
@@ -528,10 +539,12 @@
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
early_param("l1d_flush", l1d_flush_parse_cmdline);
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
|
||||||
|
#undef pr_fmt
|
||||||
|
#define pr_fmt(fmt) "Spectre V1 : " fmt
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
enum spectre_v1_mitigation {
|
||||||
|
SPECTRE_V1_MITIGATION_NONE,
|
||||||
|
SPECTRE_V1_MITIGATION_AUTO,
|
||||||
|
@@ -618,6 +631,7 @@
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
early_param("nospectre_v1", nospectre_v1_cmdline);
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
|
||||||
|
#undef pr_fmt
|
||||||
|
#define pr_fmt(fmt) "Spectre V2 : " fmt
|
||||||
|
@@ -729,6 +743,7 @@
|
||||||
|
{ "seccomp,ibpb", SPECTRE_V2_USER_CMD_SECCOMP_IBPB, false },
|
||||||
|
};
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
static void __init spec_v2_user_print_cond(const char *reason, bool secure)
|
||||||
|
{
|
||||||
|
if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2) != secure)
|
||||||
|
@@ -1071,6 +1086,7 @@
|
||||||
|
/* Set up IBPB and STIBP depending on the general spectre V2 command */
|
||||||
|
spectre_v2_user_select_mitigation(cmd);
|
||||||
|
}
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
|
||||||
|
static void update_stibp_msr(void * __unused)
|
||||||
|
{
|
||||||
|
@@ -1207,6 +1223,7 @@
|
||||||
|
{ "seccomp", SPEC_STORE_BYPASS_CMD_SECCOMP }, /* Disable Speculative Store Bypass via prctl and seccomp */
|
||||||
|
};
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
static enum ssb_mitigation_cmd __init ssb_parse_cmdline(void)
|
||||||
|
{
|
||||||
|
enum ssb_mitigation_cmd cmd = SPEC_STORE_BYPASS_CMD_AUTO;
|
||||||
|
@@ -1316,6 +1333,7 @@
|
||||||
|
if (boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS))
|
||||||
|
pr_info("%s\n", ssb_strings[ssb_mode]);
|
||||||
|
}
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
|
||||||
|
#undef pr_fmt
|
||||||
|
#define pr_fmt(fmt) "Speculation prctl: " fmt
|
||||||
|
@@ -1573,6 +1591,7 @@
|
||||||
|
enum vmx_l1d_flush_state l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_AUTO;
|
||||||
|
EXPORT_SYMBOL_GPL(l1tf_vmx_mitigation);
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
/*
|
||||||
|
* These CPUs all support 44bits physical address space internally in the
|
||||||
|
* cache but CPUID can report a smaller number of physical address bits.
|
||||||
|
@@ -1926,3 +1945,4 @@
|
||||||
|
return cpu_show_common(dev, attr, buf, X86_BUG_SRBDS);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
+#endif // CONFIG_M486
|
@ -0,0 +1,31 @@
|
|||||||
|
--- usr/gen_initramfs.sh 2022-04-08 07:59:05.000000000 -0400
|
||||||
|
+++ usr/gen_initramfs.sh.new 2022-04-21 08:51:04.635080820 -0400
|
||||||
|
@@ -187,8 +187,8 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
prog=$0
|
||||||
|
-root_uid=0
|
||||||
|
-root_gid=0
|
||||||
|
+root_uid="squash"
|
||||||
|
+root_gid="squash"
|
||||||
|
dep_list=
|
||||||
|
cpio_list=$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)
|
||||||
|
output="/dev/stdout"
|
||||||
|
@@ -209,13 +209,13 @@
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
"-u") # map $1 to uid=0 (root)
|
||||||
|
- root_uid="$1"
|
||||||
|
- [ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0)
|
||||||
|
+# root_uid="$1"
|
||||||
|
+# [ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
"-g") # map $1 to gid=0 (root)
|
||||||
|
- root_gid="$1"
|
||||||
|
- [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
|
||||||
|
+# root_gid="$1"
|
||||||
|
+# [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
"-h")
|
@ -0,0 +1,386 @@
|
|||||||
|
--- arch/x86/realmode/init.c.new 2022-04-21 08:59:29.875419413 -0400
|
||||||
|
+++ arch/x86/realmode/init.c 2022-04-21 09:00:11.359752804 -0400
|
||||||
|
@@ -19,195 +19,195 @@
|
||||||
|
|
||||||
|
void load_trampoline_pgtable(void)
|
||||||
|
{
|
||||||
|
-#ifdef CONFIG_X86_32
|
||||||
|
- load_cr3(initial_page_table);
|
||||||
|
-#else
|
||||||
|
- /*
|
||||||
|
- * This function is called before exiting to real-mode and that will
|
||||||
|
- * fail with CR4.PCIDE still set.
|
||||||
|
- */
|
||||||
|
- if (boot_cpu_has(X86_FEATURE_PCID))
|
||||||
|
- cr4_clear_bits(X86_CR4_PCIDE);
|
||||||
|
-
|
||||||
|
- write_cr3(real_mode_header->trampoline_pgd);
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * The CR3 write above will not flush global TLB entries.
|
||||||
|
- * Stale, global entries from previous page tables may still be
|
||||||
|
- * present. Flush those stale entries.
|
||||||
|
- *
|
||||||
|
- * This ensures that memory accessed while running with
|
||||||
|
- * trampoline_pgd is *actually* mapped into trampoline_pgd.
|
||||||
|
- */
|
||||||
|
- __flush_tlb_all();
|
||||||
|
+//#ifdef CONFIG_X86_32
|
||||||
|
+// load_cr3(initial_page_table);
|
||||||
|
+//#else
|
||||||
|
+// /*
|
||||||
|
+// * This function is called before exiting to real-mode and that will
|
||||||
|
+// * fail with CR4.PCIDE still set.
|
||||||
|
+// */
|
||||||
|
+// if (boot_cpu_has(X86_FEATURE_PCID))
|
||||||
|
+// cr4_clear_bits(X86_CR4_PCIDE);
|
||||||
|
+//
|
||||||
|
+// write_cr3(real_mode_header->trampoline_pgd);
|
||||||
|
+//#endif
|
||||||
|
+//
|
||||||
|
+// /*
|
||||||
|
+// * The CR3 write above will not flush global TLB entries.
|
||||||
|
+// * Stale, global entries from previous page tables may still be
|
||||||
|
+// * present. Flush those stale entries.
|
||||||
|
+// *
|
||||||
|
+// * This ensures that memory accessed while running with
|
||||||
|
+// * trampoline_pgd is *actually* mapped into trampoline_pgd.
|
||||||
|
+// */
|
||||||
|
+// __flush_tlb_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
void __init reserve_real_mode(void)
|
||||||
|
{
|
||||||
|
- phys_addr_t mem;
|
||||||
|
- size_t size = real_mode_size_needed();
|
||||||
|
-
|
||||||
|
- if (!size)
|
||||||
|
- return;
|
||||||
|
-
|
||||||
|
- WARN_ON(slab_is_available());
|
||||||
|
-
|
||||||
|
- /* Has to be under 1M so we can execute real-mode AP code. */
|
||||||
|
- mem = memblock_phys_alloc_range(size, PAGE_SIZE, 0, 1<<20);
|
||||||
|
- if (!mem)
|
||||||
|
- pr_info("No sub-1M memory is available for the trampoline\n");
|
||||||
|
- else
|
||||||
|
- set_real_mode_mem(mem);
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * Unconditionally reserve the entire fisrt 1M, see comment in
|
||||||
|
- * setup_arch().
|
||||||
|
- */
|
||||||
|
- memblock_reserve(0, SZ_1M);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static void sme_sev_setup_real_mode(struct trampoline_header *th)
|
||||||
|
-{
|
||||||
|
-#ifdef CONFIG_AMD_MEM_ENCRYPT
|
||||||
|
- if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT))
|
||||||
|
- th->flags |= TH_FLAGS_SME_ACTIVE;
|
||||||
|
-
|
||||||
|
- if (cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT)) {
|
||||||
|
- /*
|
||||||
|
- * Skip the call to verify_cpu() in secondary_startup_64 as it
|
||||||
|
- * will cause #VC exceptions when the AP can't handle them yet.
|
||||||
|
- */
|
||||||
|
- th->start = (u64) secondary_startup_64_no_verify;
|
||||||
|
-
|
||||||
|
- if (sev_es_setup_ap_jump_table(real_mode_header))
|
||||||
|
- panic("Failed to get/update SEV-ES AP Jump Table");
|
||||||
|
- }
|
||||||
|
-#endif
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static void __init setup_real_mode(void)
|
||||||
|
-{
|
||||||
|
- u16 real_mode_seg;
|
||||||
|
- const u32 *rel;
|
||||||
|
- u32 count;
|
||||||
|
- unsigned char *base;
|
||||||
|
- unsigned long phys_base;
|
||||||
|
- struct trampoline_header *trampoline_header;
|
||||||
|
- size_t size = PAGE_ALIGN(real_mode_blob_end - real_mode_blob);
|
||||||
|
-#ifdef CONFIG_X86_64
|
||||||
|
- u64 *trampoline_pgd;
|
||||||
|
- u64 efer;
|
||||||
|
- int i;
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
- base = (unsigned char *)real_mode_header;
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * If SME is active, the trampoline area will need to be in
|
||||||
|
- * decrypted memory in order to bring up other processors
|
||||||
|
- * successfully. This is not needed for SEV.
|
||||||
|
- */
|
||||||
|
- if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT))
|
||||||
|
- set_memory_decrypted((unsigned long)base, size >> PAGE_SHIFT);
|
||||||
|
-
|
||||||
|
- memcpy(base, real_mode_blob, size);
|
||||||
|
-
|
||||||
|
- phys_base = __pa(base);
|
||||||
|
- real_mode_seg = phys_base >> 4;
|
||||||
|
-
|
||||||
|
- rel = (u32 *) real_mode_relocs;
|
||||||
|
-
|
||||||
|
- /* 16-bit segment relocations. */
|
||||||
|
- count = *rel++;
|
||||||
|
- while (count--) {
|
||||||
|
- u16 *seg = (u16 *) (base + *rel++);
|
||||||
|
- *seg = real_mode_seg;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* 32-bit linear relocations. */
|
||||||
|
- count = *rel++;
|
||||||
|
- while (count--) {
|
||||||
|
- u32 *ptr = (u32 *) (base + *rel++);
|
||||||
|
- *ptr += phys_base;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Must be performed *after* relocation. */
|
||||||
|
- trampoline_header = (struct trampoline_header *)
|
||||||
|
- __va(real_mode_header->trampoline_header);
|
||||||
|
-
|
||||||
|
-#ifdef CONFIG_X86_32
|
||||||
|
- trampoline_header->start = __pa_symbol(startup_32_smp);
|
||||||
|
- trampoline_header->gdt_limit = __BOOT_DS + 7;
|
||||||
|
- trampoline_header->gdt_base = __pa_symbol(boot_gdt);
|
||||||
|
-#else
|
||||||
|
- /*
|
||||||
|
- * Some AMD processors will #GP(0) if EFER.LMA is set in WRMSR
|
||||||
|
- * so we need to mask it out.
|
||||||
|
- */
|
||||||
|
- rdmsrl(MSR_EFER, efer);
|
||||||
|
- trampoline_header->efer = efer & ~EFER_LMA;
|
||||||
|
-
|
||||||
|
- trampoline_header->start = (u64) secondary_startup_64;
|
||||||
|
- trampoline_cr4_features = &trampoline_header->cr4;
|
||||||
|
- *trampoline_cr4_features = mmu_cr4_features;
|
||||||
|
-
|
||||||
|
- trampoline_header->flags = 0;
|
||||||
|
-
|
||||||
|
- trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
|
||||||
|
-
|
||||||
|
- /* Map the real mode stub as virtual == physical */
|
||||||
|
- trampoline_pgd[0] = trampoline_pgd_entry.pgd;
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * Include the entirety of the kernel mapping into the trampoline
|
||||||
|
- * PGD. This way, all mappings present in the normal kernel page
|
||||||
|
- * tables are usable while running on trampoline_pgd.
|
||||||
|
- */
|
||||||
|
- for (i = pgd_index(__PAGE_OFFSET); i < PTRS_PER_PGD; i++)
|
||||||
|
- trampoline_pgd[i] = init_top_pgt[i].pgd;
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
- sme_sev_setup_real_mode(trampoline_header);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-/*
|
||||||
|
- * reserve_real_mode() gets called very early, to guarantee the
|
||||||
|
- * availability of low memory. This is before the proper kernel page
|
||||||
|
- * tables are set up, so we cannot set page permissions in that
|
||||||
|
- * function. Also trampoline code will be executed by APs so we
|
||||||
|
- * need to mark it executable at do_pre_smp_initcalls() at least,
|
||||||
|
- * thus run it as a early_initcall().
|
||||||
|
- */
|
||||||
|
-static void __init set_real_mode_permissions(void)
|
||||||
|
-{
|
||||||
|
- unsigned char *base = (unsigned char *) real_mode_header;
|
||||||
|
- size_t size = PAGE_ALIGN(real_mode_blob_end - real_mode_blob);
|
||||||
|
-
|
||||||
|
- size_t ro_size =
|
||||||
|
- PAGE_ALIGN(real_mode_header->ro_end) -
|
||||||
|
- __pa(base);
|
||||||
|
-
|
||||||
|
- size_t text_size =
|
||||||
|
- PAGE_ALIGN(real_mode_header->ro_end) -
|
||||||
|
- real_mode_header->text_start;
|
||||||
|
-
|
||||||
|
- unsigned long text_start =
|
||||||
|
- (unsigned long) __va(real_mode_header->text_start);
|
||||||
|
-
|
||||||
|
- set_memory_nx((unsigned long) base, size >> PAGE_SHIFT);
|
||||||
|
- set_memory_ro((unsigned long) base, ro_size >> PAGE_SHIFT);
|
||||||
|
- set_memory_x((unsigned long) text_start, text_size >> PAGE_SHIFT);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static int __init init_real_mode(void)
|
||||||
|
-{
|
||||||
|
- if (!real_mode_header)
|
||||||
|
- panic("Real mode trampoline was not allocated");
|
||||||
|
-
|
||||||
|
- setup_real_mode();
|
||||||
|
- set_real_mode_permissions();
|
||||||
|
-
|
||||||
|
- return 0;
|
||||||
|
-}
|
||||||
|
-early_initcall(init_real_mode);
|
||||||
|
+// phys_addr_t mem;
|
||||||
|
+// size_t size = real_mode_size_needed();
|
||||||
|
+//
|
||||||
|
+// if (!size)
|
||||||
|
+// return;
|
||||||
|
+//
|
||||||
|
+// WARN_ON(slab_is_available());
|
||||||
|
+//
|
||||||
|
+// /* Has to be under 1M so we can execute real-mode AP code. */
|
||||||
|
+// mem = memblock_phys_alloc_range(size, PAGE_SIZE, 0, 1<<20);
|
||||||
|
+// if (!mem)
|
||||||
|
+// pr_info("No sub-1M memory is available for the trampoline\n");
|
||||||
|
+// else
|
||||||
|
+// set_real_mode_mem(mem);
|
||||||
|
+//
|
||||||
|
+// /*
|
||||||
|
+// * Unconditionally reserve the entire fisrt 1M, see comment in
|
||||||
|
+// * setup_arch().
|
||||||
|
+// */
|
||||||
|
+// memblock_reserve(0, SZ_1M);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+//static void sme_sev_setup_real_mode(struct trampoline_header *th)
|
||||||
|
+//{
|
||||||
|
+//#ifdef CONFIG_AMD_MEM_ENCRYPT
|
||||||
|
+// if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT))
|
||||||
|
+// th->flags |= TH_FLAGS_SME_ACTIVE;
|
||||||
|
+//
|
||||||
|
+// if (cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT)) {
|
||||||
|
+// /*
|
||||||
|
+// * Skip the call to verify_cpu() in secondary_startup_64 as it
|
||||||
|
+// * will cause #VC exceptions when the AP can't handle them yet.
|
||||||
|
+// */
|
||||||
|
+// th->start = (u64) secondary_startup_64_no_verify;
|
||||||
|
+//
|
||||||
|
+// if (sev_es_setup_ap_jump_table(real_mode_header))
|
||||||
|
+// panic("Failed to get/update SEV-ES AP Jump Table");
|
||||||
|
+// }
|
||||||
|
+//#endif
|
||||||
|
+//}
|
||||||
|
+//
|
||||||
|
+//static void __init setup_real_mode(void)
|
||||||
|
+//{
|
||||||
|
+// u16 real_mode_seg;
|
||||||
|
+// const u32 *rel;
|
||||||
|
+// u32 count;
|
||||||
|
+// unsigned char *base;
|
||||||
|
+// unsigned long phys_base;
|
||||||
|
+// struct trampoline_header *trampoline_header;
|
||||||
|
+// size_t size = PAGE_ALIGN(real_mode_blob_end - real_mode_blob);
|
||||||
|
+//#ifdef CONFIG_X86_64
|
||||||
|
+// u64 *trampoline_pgd;
|
||||||
|
+// u64 efer;
|
||||||
|
+// int i;
|
||||||
|
+//#endif
|
||||||
|
+//
|
||||||
|
+// base = (unsigned char *)real_mode_header;
|
||||||
|
+//
|
||||||
|
+// /*
|
||||||
|
+// * If SME is active, the trampoline area will need to be in
|
||||||
|
+// * decrypted memory in order to bring up other processors
|
||||||
|
+// * successfully. This is not needed for SEV.
|
||||||
|
+// */
|
||||||
|
+// if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT))
|
||||||
|
+// set_memory_decrypted((unsigned long)base, size >> PAGE_SHIFT);
|
||||||
|
+//
|
||||||
|
+// memcpy(base, real_mode_blob, size);
|
||||||
|
+//
|
||||||
|
+// phys_base = __pa(base);
|
||||||
|
+// real_mode_seg = phys_base >> 4;
|
||||||
|
+//
|
||||||
|
+// rel = (u32 *) real_mode_relocs;
|
||||||
|
+//
|
||||||
|
+// /* 16-bit segment relocations. */
|
||||||
|
+// count = *rel++;
|
||||||
|
+// while (count--) {
|
||||||
|
+// u16 *seg = (u16 *) (base + *rel++);
|
||||||
|
+// *seg = real_mode_seg;
|
||||||
|
+// }
|
||||||
|
+//
|
||||||
|
+// /* 32-bit linear relocations. */
|
||||||
|
+// count = *rel++;
|
||||||
|
+// while (count--) {
|
||||||
|
+// u32 *ptr = (u32 *) (base + *rel++);
|
||||||
|
+// *ptr += phys_base;
|
||||||
|
+// }
|
||||||
|
+//
|
||||||
|
+// /* Must be performed *after* relocation. */
|
||||||
|
+// trampoline_header = (struct trampoline_header *)
|
||||||
|
+// __va(real_mode_header->trampoline_header);
|
||||||
|
+//
|
||||||
|
+//#ifdef CONFIG_X86_32
|
||||||
|
+// trampoline_header->start = __pa_symbol(startup_32_smp);
|
||||||
|
+// trampoline_header->gdt_limit = __BOOT_DS + 7;
|
||||||
|
+// trampoline_header->gdt_base = __pa_symbol(boot_gdt);
|
||||||
|
+//#else
|
||||||
|
+// /*
|
||||||
|
+// * Some AMD processors will #GP(0) if EFER.LMA is set in WRMSR
|
||||||
|
+// * so we need to mask it out.
|
||||||
|
+// */
|
||||||
|
+// rdmsrl(MSR_EFER, efer);
|
||||||
|
+// trampoline_header->efer = efer & ~EFER_LMA;
|
||||||
|
+//
|
||||||
|
+// trampoline_header->start = (u64) secondary_startup_64;
|
||||||
|
+// trampoline_cr4_features = &trampoline_header->cr4;
|
||||||
|
+// *trampoline_cr4_features = mmu_cr4_features;
|
||||||
|
+//
|
||||||
|
+// trampoline_header->flags = 0;
|
||||||
|
+//
|
||||||
|
+// trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
|
||||||
|
+//
|
||||||
|
+// /* Map the real mode stub as virtual == physical */
|
||||||
|
+// trampoline_pgd[0] = trampoline_pgd_entry.pgd;
|
||||||
|
+//
|
||||||
|
+// /*
|
||||||
|
+// * Include the entirety of the kernel mapping into the trampoline
|
||||||
|
+// * PGD. This way, all mappings present in the normal kernel page
|
||||||
|
+// * tables are usable while running on trampoline_pgd.
|
||||||
|
+// */
|
||||||
|
+// for (i = pgd_index(__PAGE_OFFSET); i < PTRS_PER_PGD; i++)
|
||||||
|
+// trampoline_pgd[i] = init_top_pgt[i].pgd;
|
||||||
|
+//#endif
|
||||||
|
+//
|
||||||
|
+// sme_sev_setup_real_mode(trampoline_header);
|
||||||
|
+//}
|
||||||
|
+//
|
||||||
|
+///*
|
||||||
|
+// * reserve_real_mode() gets called very early, to guarantee the
|
||||||
|
+// * availability of low memory. This is before the proper kernel page
|
||||||
|
+// * tables are set up, so we cannot set page permissions in that
|
||||||
|
+// * function. Also trampoline code will be executed by APs so we
|
||||||
|
+// * need to mark it executable at do_pre_smp_initcalls() at least,
|
||||||
|
+// * thus run it as a early_initcall().
|
||||||
|
+// */
|
||||||
|
+//static void __init set_real_mode_permissions(void)
|
||||||
|
+//{
|
||||||
|
+// unsigned char *base = (unsigned char *) real_mode_header;
|
||||||
|
+// size_t size = PAGE_ALIGN(real_mode_blob_end - real_mode_blob);
|
||||||
|
+//
|
||||||
|
+// size_t ro_size =
|
||||||
|
+// PAGE_ALIGN(real_mode_header->ro_end) -
|
||||||
|
+// __pa(base);
|
||||||
|
+//
|
||||||
|
+// size_t text_size =
|
||||||
|
+// PAGE_ALIGN(real_mode_header->ro_end) -
|
||||||
|
+// real_mode_header->text_start;
|
||||||
|
+//
|
||||||
|
+// unsigned long text_start =
|
||||||
|
+// (unsigned long) __va(real_mode_header->text_start);
|
||||||
|
+//
|
||||||
|
+// set_memory_nx((unsigned long) base, size >> PAGE_SHIFT);
|
||||||
|
+// set_memory_ro((unsigned long) base, ro_size >> PAGE_SHIFT);
|
||||||
|
+// set_memory_x((unsigned long) text_start, text_size >> PAGE_SHIFT);
|
||||||
|
+//}
|
||||||
|
+//
|
||||||
|
+//static int __init init_real_mode(void)
|
||||||
|
+//{
|
||||||
|
+// if (!real_mode_header)
|
||||||
|
+// panic("Real mode trampoline was not allocated");
|
||||||
|
+//
|
||||||
|
+// setup_real_mode();
|
||||||
|
+// set_real_mode_permissions();
|
||||||
|
+//
|
||||||
|
+// return 0;
|
||||||
|
+//}
|
||||||
|
+//early_initcall(init_real_mode);
|
@ -0,0 +1,45 @@
|
|||||||
|
--- init/initramfs.c.new 2022-04-21 10:43:58.644900319 -0400
|
||||||
|
+++ init/initramfs.c 2022-04-21 10:46:57.309758246 -0400
|
||||||
|
@@ -461,7 +461,7 @@
|
||||||
|
|
||||||
|
#include <linux/decompress/generic.h>
|
||||||
|
|
||||||
|
-static char * __init unpack_to_rootfs(char *buf, unsigned long len)
|
||||||
|
+static char * __init do_unpack_to_rootfs(char *buf, unsigned long len, char *output)
|
||||||
|
{
|
||||||
|
long written;
|
||||||
|
decompress_fn decompress;
|
||||||
|
@@ -497,7 +497,7 @@
|
||||||
|
decompress = decompress_method(buf, len, &compress_name);
|
||||||
|
pr_debug("Detected %s compressed data\n", compress_name);
|
||||||
|
if (decompress) {
|
||||||
|
- int res = decompress(buf, len, NULL, flush_buffer, NULL,
|
||||||
|
+ int res = decompress(buf, len, NULL, flush_buffer, output,
|
||||||
|
&my_inptr, error);
|
||||||
|
if (res)
|
||||||
|
error("decompressor failed");
|
||||||
|
@@ -523,6 +523,11 @@
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static char * __init unpack_to_rootfs(char *buf, unsigned long len)
|
||||||
|
+{
|
||||||
|
+ return do_unpack_to_rootfs(buf, len, NULL);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int __initdata do_retain_initrd;
|
||||||
|
|
||||||
|
static int __init retain_initrd_param(char *str)
|
||||||
|
@@ -683,7 +688,11 @@
|
||||||
|
else
|
||||||
|
printk(KERN_INFO "Unpacking initramfs...\n");
|
||||||
|
|
||||||
|
- err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start);
|
||||||
|
+ //err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start);
|
||||||
|
+ void *output = vmalloc(0x80000);
|
||||||
|
+ err = do_unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start, output);
|
||||||
|
+ vfree(output);
|
||||||
|
+
|
||||||
|
if (err) {
|
||||||
|
#ifdef CONFIG_BLK_DEV_RAM
|
||||||
|
populate_initrd_image(err);
|
@ -0,0 +1,26 @@
|
|||||||
|
--- arch/x86/kernel/cpu/intel.c.new 2022-04-21 10:30:16.303395343 -0400
|
||||||
|
+++ arch/x86/kernel/cpu/intel.c 2022-04-21 10:31:18.648938081 -0400
|
||||||
|
@@ -752,6 +752,8 @@
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#ifndef CONFIG_M486
|
||||||
|
+
|
||||||
|
#define TLB_INST_4K 0x01
|
||||||
|
#define TLB_INST_4M 0x02
|
||||||
|
#define TLB_INST_2M_4M 0x03
|
||||||
|
@@ -926,6 +928,14 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+#else
|
||||||
|
+
|
||||||
|
+static void intel_detect_tlb(struct cpuinfo_x86 *c)
|
||||||
|
+{
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#endif // CONFIG_M486
|
||||||
|
+
|
||||||
|
static const struct cpu_dev intel_cpu_dev = {
|
||||||
|
.c_vendor = "Intel",
|
||||||
|
.c_ident = { "GenuineIntel" },
|
@ -0,0 +1,34 @@
|
|||||||
|
--- arch/x86/realmode/rmpiggy.S.new 2022-04-21 09:00:39.636016815 -0400
|
||||||
|
+++ arch/x86/realmode/rmpiggy.S 2022-04-21 09:00:51.392134904 -0400
|
||||||
|
@@ -3,17 +3,17 @@
|
||||||
|
* Wrapper script for the realmode binary as a transport object
|
||||||
|
* before copying to low memory.
|
||||||
|
*/
|
||||||
|
-#include <linux/linkage.h>
|
||||||
|
-#include <asm/page_types.h>
|
||||||
|
-
|
||||||
|
- .section ".init.data","aw"
|
||||||
|
-
|
||||||
|
- .balign PAGE_SIZE
|
||||||
|
-
|
||||||
|
-SYM_DATA_START(real_mode_blob)
|
||||||
|
- .incbin "arch/x86/realmode/rm/realmode.bin"
|
||||||
|
-SYM_DATA_END_LABEL(real_mode_blob, SYM_L_GLOBAL, real_mode_blob_end)
|
||||||
|
-
|
||||||
|
-SYM_DATA_START(real_mode_relocs)
|
||||||
|
- .incbin "arch/x86/realmode/rm/realmode.relocs"
|
||||||
|
-SYM_DATA_END(real_mode_relocs)
|
||||||
|
+//#include <linux/linkage.h>
|
||||||
|
+//#include <asm/page_types.h>
|
||||||
|
+//
|
||||||
|
+// .section ".init.data","aw"
|
||||||
|
+//
|
||||||
|
+// .balign PAGE_SIZE
|
||||||
|
+//
|
||||||
|
+//SYM_DATA_START(real_mode_blob)
|
||||||
|
+// .incbin "arch/x86/realmode/rm/realmode.bin"
|
||||||
|
+//SYM_DATA_END_LABEL(real_mode_blob, SYM_L_GLOBAL, real_mode_blob_end)
|
||||||
|
+//
|
||||||
|
+//SYM_DATA_START(real_mode_relocs)
|
||||||
|
+// .incbin "arch/x86/realmode/rm/realmode.relocs"
|
||||||
|
+//SYM_DATA_END(real_mode_relocs)
|
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "Mounting filesystems..."
|
||||||
|
mount -a
|
||||||
|
mkdir /dev/pts
|
||||||
|
mount devpts /dev/pts -t devpts -o gid=5,mode=620
|
||||||
|
|
||||||
|
echo "Ready."
|
||||||
|
|
Loading…
Reference in New Issue