Skip to content

Installing Linux default kernel drivers + cleaning up justfiles #49

@aghosn

Description

@aghosn

For issue 47 we will need to run kvm in the guest linux OS.
The problem is that we don't have an automated way to install the Linux default drivers, e.g., kvm, for the moment.
The procedure to do it is:

make -C C/ ubuntu_mount
make -C builds/linux-x86/ modules
sudo INSTALL_MOD_PATH=/tmp/mount/ make -C builds/linux-x86/ modules_install

Also, I think there might be some dead targets in the justfile, and for debugging purposes it would be good to have one to run linux directly without tyche.
A command to do so that seems compatible with our initramfs and its switch root are the following justfile rule:

only-linux SMP=default_smp:
  touch _empty.fake_disk
  qemu-system-x86_64 \
  -kernel builds/linux-x86/arch/x86_64/boot/bzImage \
  -smp {{SMP}} \
  --no-reboot -nographic \
  -device isa-debug-exit,iobase=0xf4,iosize=0x04 \
  -device intel-iommu,intremap=on,aw-bits=48 \
  -cpu host,+kvm -machine q35 -accel kvm,kernel-irqchip=split -m 6G \
  -drive file=_empty.fake_disk,format=raw,media=disk \
  -drive file=ubuntu.qcow2,format=qcow2,media=disk \
  -append "root=/dev/sda1 apic=debug earlyprintk=serial,ttyS0 console=ttyS0" \
  -chardev socket,path={{default_dbg}},server=on,wait=off,id=gdb0 -gdb chardev:gdb0
  rm _empty.fake_disk

dbg-only-linux:
  gdb -ex "target remote {{default_dbg}}" \
  -ex "source builds/linux-x86/vmlinux-gdb.py" \
  -ex "lx-symbols" \
  builds/linux-x86/vmlinux  

The first one starts our linux image with your ubuntu disk directly on top of qemu (it goes through the initramfs and then does the switchroot to the ubuntu disk), the second one allows to connect to qemu-gdb for the running instance.
For the first command, comment below if you get stuck within the ramfs.
Normally, if you've installed the modules correctly they should be loaded in your ubuntu linux (do an lsmod to check).
If not, they should be loadable by doing a:

sudo modprobe kvm

Metadata

Metadata

Assignees

No one assigned

    Labels

    LinuxRelated to the Linux host OSdocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions