aboutsummaryrefslogtreecommitdiffhomepage
path: root/content/20191027-kernel-debugging-qemu
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-07-15 21:20:14 +0200
committerjohannst <johannes.stoelp@gmail.com>2021-07-15 21:20:14 +0200
commit82e9ac4163b46b59e121194f84ac370818482923 (patch)
treeb52adf8f5b2bafe7904f563c33ec23f46cb7c87c /content/20191027-kernel-debugging-qemu
parent617d73fc9eff5b08a80b873fd97f66caa7e80fc9 (diff)
downloadblog-82e9ac4163b46b59e121194f84ac370818482923.tar.gz
blog-82e9ac4163b46b59e121194f84ac370818482923.zip
use proper date fmt in content file names that zola can automatically can derive the date
Diffstat (limited to 'content/20191027-kernel-debugging-qemu')
-rw-r--r--content/20191027-kernel-debugging-qemu/Dockerfile32
-rw-r--r--content/20191027-kernel-debugging-qemu/Makefile12
-rwxr-xr-xcontent/20191027-kernel-debugging-qemu/build_initrd.sh54
-rwxr-xr-xcontent/20191027-kernel-debugging-qemu/build_kernel.sh38
-rwxr-xr-xcontent/20191027-kernel-debugging-qemu/run.sh24
5 files changed, 0 insertions, 160 deletions
diff --git a/content/20191027-kernel-debugging-qemu/Dockerfile b/content/20191027-kernel-debugging-qemu/Dockerfile
deleted file mode 100644
index 42e1f05..0000000
--- a/content/20191027-kernel-debugging-qemu/Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-FROM ubuntu:20.04
-MAINTAINER Johannes Stoelp <johannes.stoelp@gmail.edu>
-
-RUN apt update \
- && DEBIAN_FRONTEND=noninteractive \
- apt install \
- --yes \
- --no-install-recommends \
- # Download & unpack.
- wget \
- ca-certificates \
- xz-utils \
- # Build tools & deps (kernel).
- make \
- bc \
- gcc g++ \
- flex bison \
- libelf-dev \
- # Build tools & deps (initrd).
- cpio \
- # Run & debug.
- qemu-system-x86 \
- gdb \
- telnet \
- # Convenience.
- ripgrep \
- fd-find \
- neovim \
- && rm -rf /var/lib/apt/lists/* \
- && apt-get clean
-
-WORKDIR /develop
diff --git a/content/20191027-kernel-debugging-qemu/Makefile b/content/20191027-kernel-debugging-qemu/Makefile
deleted file mode 100644
index 11e7c7b..0000000
--- a/content/20191027-kernel-debugging-qemu/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-build:
- scripts/build_kernel.sh
- scripts/build_initrd.sh
-
-clean:
- $(RM) -r linux-*
- $(RM) -r busybox-*
- $(RM) initramfs.cpio.gz
-
-docker:
- DOCKER_BUILDKIT=1 docker build -t kernel-dev .
- docker run -it --rm -v $(PWD):/develop/scripts -v $(PWD)/Makefile:/develop/Makefile kernel-dev
diff --git a/content/20191027-kernel-debugging-qemu/build_initrd.sh b/content/20191027-kernel-debugging-qemu/build_initrd.sh
deleted file mode 100755
index fd82990..0000000
--- a/content/20191027-kernel-debugging-qemu/build_initrd.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/bash
-
-if test $(id -u) -ne 0; then
- SUDO=sudo
-fi
-
-set -e
-
-BUSYBOX=busybox-1.33.1
-INITRD=$PWD/initramfs.cpio.gz
-
-## Build busybox
-
-echo "[+] configure & build $BUSYBOX ..."
-[[ ! -d $BUSYBOX ]] && {
- wget https://busybox.net/downloads/$BUSYBOX.tar.bz2
- bunzip2 $BUSYBOX.tar.bz2 && tar xf $BUSYBOX.tar
-}
-
-cd $BUSYBOX
-make defconfig
-sed -i 's/# CONFIG_STATIC .*/CONFIG_STATIC=y/' .config
-make -j4 busybox
-make install
-
-## Create initrd
-
-echo "[+] create initrd $INITRD ..."
-
-cd _install
-
-# 1. create initrd folder structure
-mkdir -p bin sbin etc proc sys usr/bin usr/sbin dev
-
-# 2. create init process
-cat <<EOF > init
-#!/bin/sh
-
-mount -t proc none /proc
-mount -t sysfs none /sys
-
-exec setsid cttyhack sh
-EOF
-chmod +x init
-
-# 3. create device nodes
-$SUDO mknod dev/tty c 5 0
-$SUDO mknod dev/tty0 c 4 0
-$SUDO mknod dev/ttyS0 c 4 64
-
-# 4. created compressed initrd
-find . -print0 \
- | cpio --null -ov --format=newc \
- | gzip -9 > $INITRD
diff --git a/content/20191027-kernel-debugging-qemu/build_kernel.sh b/content/20191027-kernel-debugging-qemu/build_kernel.sh
deleted file mode 100755
index 7ae3014..0000000
--- a/content/20191027-kernel-debugging-qemu/build_kernel.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-
-set -e
-
-LINUX=linux-5.13.2
-wget https://cdn.kernel.org/pub/linux/kernel/v5.x/$LINUX.tar.xz
-unxz $LINUX.tar.xz && tar xf $LINUX.tar
-
-cd $LINUX
-
-cat <<EOF > kernel_fragment.config
-# 64bit kernel
-CONFIG_64BIT=y
-# enable support for compressed initrd (gzip)
-CONFIG_BLK_DEV_INITRD=y
-CONFIG_RD_GZIP=y
-# support for ELF and #! binary format
-CONFIG_BINFMT_ELF=y
-CONFIG_BINFMT_SCRIPT=y
-# /dev
-CONFIG_DEVTMPFS=y
-CONFIG_DEVTMPFS_MOUNT=y
-# tty & console
-CONFIG_TTY=y
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# pseudo fs
-CONFIG_PROC_FS=y
-CONFIG_SYSFS=y
-# debugging
-CONFIG_DEBUG_INFO=y
-CONFIG_PRINTK=y
-CONFIG_EARLY_PRINTK=y
-EOF
-
-make tinyconfig
-./scripts/kconfig/merge_config.sh -n ./kernel_fragment.config
-make -j4
diff --git a/content/20191027-kernel-debugging-qemu/run.sh b/content/20191027-kernel-debugging-qemu/run.sh
deleted file mode 100755
index b0a84ae..0000000
--- a/content/20191027-kernel-debugging-qemu/run.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-VER=5.13.2
-
-# Launch the emulator with our kernel.
-qemu-system-x86_64 \
- -kernel ./linux-$VER/arch/x86/boot/bzImage \
- -nographic \
- -append "earlyprintk=ttyS0 console=ttyS0 nokaslr init=/init debug" \
- -initrd ./initramfs.cpio.gz \
- -serial telnet:localhost:12345,server,nowait \
- -monitor none \
- -gdb tcp::1234 \
- -S &
-
-# Kill qemu when we exit.
-QEMU_PID=$!
-trap "kill $QEMU_PID" EXIT
-
-# Give qemu some time to come up.
-sleep 0.5
-
-# Attach debugger to qemu and load the kernel symbols.
-gdb -ex 'target remote :1234' ./linux-$VER/vmlinux