evansm7 / vftool

A simple macOS Virtualisation.framework wrapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

arch does not boot

m-bers opened this issue · comments

I can run ubuntu and debian via vftool just fine, vftool with "-a 'console=hvc0'" results in the kernel boot sequence outputting to the interactive terminal and eventually I get to a login prompt as expected.

Emulating aarch64 from an x86-64 host following this (https://xnand.netlify.app/2019/10/03/armv8-qemu-efi-aarch64.html) works like a charm with this command:

qemu-system-aarch64 -M virt -m 1024 -cpu cortex-a57 -kernel ./Image -initrd ./initramfs-linux.img -drive file=arm64disk.img,format=raw,index=0,media=disk -nographic -no-reboot -append "root=/dev/vda2 rw console=ttyAMA0"

I copied the kernel, initrd, and img to my M1 MacBook Air to boot with vftool with this command:
./vftool -k Image -i initramfs-linux.img -d arm64disk.img -m 8192 -a "root=/dev/vda2 rw console=hvc0" -p 4 -t 0

This results in the following output, with the kernel apparently never loading:
2021-01-04 22:18:54.370 vftool[5142:170426] vftool (v0.3 10/12/2020) starting
2021-01-04 22:18:54.370 vftool[5142:170426] +++ kernel at Image, initrd at initramfs-linux.img, cmdline 'root=/dev/vda2 rw console=hvc0', 4 cpus, 8192MB memory
2021-01-04 22:18:54.380 vftool[5142:170426] +++ Attaching disc arm64disk.img
2021-01-04 22:18:54.380 vftool[5142:170426] +++ Configuration validated.
2021-01-04 22:18:54.380 vftool[5142:170426] +++ canStart = 1, vm state 0
2021-01-04 22:18:54.424 vftool[5142:170427] +++ VM started

If I try to run arch's initrd and img with the ubuntu 5.4 kernel, here's the tail end of my output:

...
Starting version 246.1-1-arch
:: running hook [udev]
:: Triggering uevents...
Waiting 10 seconds for device /dev/vda2 ...
ERROR: device '/dev/vda2' not found. Skipping fsck.
:: mounting '/dev/vda2' on real root
mount: /new_root: special device /dev/vda2 does not exist.
You are now being dropped into an emergency shell.
sh: can't access tty; job control turned off

From the initramfs shell, I can confirm that /dev/vda does not exist, even though mkinitcpio should have been loaded with the "block" driver for virtio disks (again, this runs perfectly under emulation on the x86-64 host)

This doesn't not seem like a bug in vftool. A few things to diagnose this: look for virtio in /proc/devices, lsmod, and dmesg. This will tell you if the driver loaded.

ended up compiling a new kernel via the archlinuxarm PKGBUILD here: https://github.com/archlinuxarm/PKGBUILDs/blob/master/core/linux-aarch64/PKGBUILD

Kernel boots now but still won't recognize /dev/vda.

Here are the outputs of the original vftool command, /proc/devices, lsmod, and dmesg:

./vftool -k Image -i initramfs-linux.img  -d arm64disk.img -m 8192 -a "root=/dev/vda2 rw console=hvc0" -p 4 -t 0
2021-01-05 05:46:58.242 vftool[13702:314079] vftool (v0.3 10/12/2020) starting
2021-01-05 05:46:58.243 vftool[13702:314079] +++ kernel at Image, initrd at initramfs-linux.img, cmdline 'root=/dev/vda2 rw console=hvc0', 4 cpus, 8192MB memory
2021-01-05 05:46:58.258 vftool[13702:314079] +++ Attaching disc arm64disk.img
2021-01-05 05:46:58.258 vftool[13702:314079] +++ Configuration validated.
2021-01-05 05:46:58.258 vftool[13702:314079] +++ canStart = 1, vm state 0
2021-01-05 05:46:58.333 vftool[13702:314081] +++ VM started
[    0.425174] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.426191] libphy: Fixed MDIO Bus: probed
[    0.426777] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.427098] ehci-pci: EHCI PCI platform driver
[    0.428610] ehci-platform: EHCI generic platform driver
[    0.429264] ehci-orion: EHCI orion driver
[    0.438696] tegra-ehci: Tegra EHCI driver
[    0.440535] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.440612] ohci-pci: OHCI PCI platform driver
[    0.441065] ohci-platform: OHCI generic platform driver
[    0.447560] uhci_hcd: USB Universal Host Controller Interface driver
[    0.447969] usbcore: registered new interface driver uas
[    0.450310] usbcore: registered new interface driver usb-storage
[    0.452324] usbcore: registered new interface driver ums-cypress
[    0.453520] usbcore: registered new interface driver ums_eneub6250
[    0.454729] mousedev: PS/2 mouse device common for all mice
[    0.455372] sdhci: Secure Digital Host Controller Interface driver
[    0.455559] sdhci: Copyright(c) Pierre Ossman
[    0.455936] Synopsys Designware Multimedia Card Interface Driver
[    0.457931] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.458522] ledtrig-cpu: registered to indicate activity on CPUs
[    0.458749] hid: raw HID events driver (C) Jiri Kosina
[    0.458865] usbcore: registered new interface driver usbhid
[    0.459290] usbhid: USB HID core driver
[    0.459738] Initializing XFRM netlink socket
[    0.459885] NET: Registered protocol family 10
[    0.473141] Segment Routing with IPv6
[    0.473688] mip6: Mobile IPv6
[    0.473908] NET: Registered protocol family 17
[    0.474816] Key type dns_resolver registered
[    0.475706] registered taskstats version 1
[    0.476115] Loading compiled-in X.509 certificates
[    0.476418] zswap: loaded using pool lzo/zbud
[    0.476890] debug_vm_pgtable: debug_vm_pgtable: Validating architecture page table helpers
[    0.480556] Key type ._fscrypt registered
[    0.480873] Key type .fscrypt registered
[    0.481077] Key type fscrypt-provisioning registered
[    0.481214] ALSA device list:
[    0.481259]   No soundcards found.
[    0.481768] Freeing unused kernel memory: 5056K
[    0.530690] Run /init as init process
:: running early hook [udev]
Starting version 246.1-1-arch
:: running hook [udev]
:: Triggering uevents...
Waiting 10 seconds for device /dev/vda2 ...
ERROR: device '/dev/vda2' not found. Skipping fsck.
:: mounting '/dev/vda2' on real root
mount: /new_root: special device /dev/vda2 does not exist.
You are now being dropped into an emergency shell.
sh: can't access tty; job control turned off
[rootfs dev]# cat /proc/devices
Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  7 vcs
 10 misc
 13 input
 14 sound
 21 sg
 29 fb
 90 mtd
116 alsa
128 ptm
136 pts
162 raw
180 usb
189 usb_device
207 ttymxc
229 hvc
234 hidraw
235 rpmb
236 usbmon
237 virtio-portsdev
238 ttyLF
239 ttyLP
240 ttyTHS
241 ttyMSM
242 ttyAML
243 qcom_rmtfs_mem
244 bsg
245 watchdog
246 iio
247 rtc
248 dax
249 dimmctl
250 ndctl
251 tpm
252 ttyMV
253 rpmsg
254 gpiochip
511 vchiq

Block devices:
  8 sd
  9 md
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
179 mmc
254 mdp
259 blkext
[rootfs dev]# lsmod
lsmod
Module                  Size  Used by
[rootfs dev]# dmesg
dmesg
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x00000000]
[    0.000000] Linux version 5.8.0-2-ARCH (josh@1555d415abf4) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35) #1 SMP Tue Jan 5 07:25:11 UTC 2021
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 64 MiB at 0x00000000fc000000
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000070000000-0x000000007fffffff]
[    0.000000]   DMA32    [mem 0x0000000080000000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x000000026fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000070000000-0x000000026fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000070000000-0x000000026fffffff]
[    0.000000] On node 0 totalpages: 2097152[ 3297.061174] r
[    0.000000]   DMA zone: 1024 pages used for memmap
andom: fast init[    0.000000]   DMA zone: 0 pages reserved done

[    0.000000]   DMA zone: 65536 pages, LIFO batch:15
[    0.000000]   DMA32 zone: 8192 pages used for memmap
[    0.000000]   DMA32 zone: 524288 pages, LIFO batch:63
[    0.000000]   Normal zone: 23552 pages used for memmap
[    0.000000]   Normal zone: 1507328 pages, LIFO batch:63
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: Trusted OS migration not required
[    0.000000] psci: SMC Calling Convention v1.0
[    0.000000] percpu: Embedded 22 pages/cpu s53016 r8192 d28904 u90112
[    0.000000] pcpu-alloc: s53016 r8192 d28904 u90112 alloc=22*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 
[    0.000000] Detected PIPT I-cache on CPU0
[    0.000000] CPU features: detected: Speculative Store Bypassing Safe (SSBS)
[    0.000000] CPU features: detected: Address authentication (IMP DEF algorithm)
[    0.000000] alternatives: patching kernel code
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2064384
[    0.000000] Kernel command line: root=/dev/vda2 rw console=hvc0
[    0.000000] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes, linear)
[    0.000000] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] software IO TLB: mapped [mem 0x7bfff000-0x7ffff000] (64MB)
[    0.000000] Memory: 8041624K/8388608K available (15164K kernel code, 2108K rwdata, 7472K rodata, 5056K init, 819K bss, 281448K reserved, 65536K cma-reserved)
[    0.000000] random: get_random_u64 called from cache_random_seq_create+0x84/0x15c with crng_init=0
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[    0.000000]  Trampoline variant of Tasks RCU enabled.
[    0.000000]  Rude variant of Tasks RCU enabled.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] GICv3: 64 SPIs implemented
[    0.000000] GICv3: 0 Extended SPIs implemented
[    0.000000] GICv3: Distributor has no Range Selector support
[    0.000000] GICv3: 16 PPIs implemented
[    0.000000] GICv3: Enabling SGIs without active state
[    0.000000] GICv3: CPU0: found redistributor 0 region 0:0x0000000010010000
[    0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (virt).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000000] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000065] Console: colour dummy device 80x25
[    0.000083] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000084] pid_max: default: 32768 minimum: 301
[    0.000123] LSM: Security Framework initializing
[    0.000135] Yama: becoming mindful.
[    0.000184] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.000214] Mountpoint

Also, modinfo does show the virtio-blk driver as being loaded (unless I'm missing something):

[rootfs dev]# modinfo virtio-blk
modinfo virtio-blk
filename:       /lib/modules/5.8.0-2-ARCH/kernel/virtio_blk.ko
license:        GPL
description:    Virtio block driver
alias:          virtio:d00000002v*
depends:        
intree:         Y
name:           virtio_blk
vermagic:       5.8.0-2-ARCH SMP mod_unload aarch64
parm:           queue_depth:uint

@m-bers Tried to post this on Macrumors, but my post is under mod review. I was able to get the Arch Linux aarch64 image to boot (using ACVM, but expect it will work with vftool as well)- starting with the generic image, add the virtio, virtio_blk, virtio_pci, and virtio_net modules to mkinitcpio.conf. Rebuild the image with mkinitcpio -P and then install an EFI boot loader with systemd-boot (follow the Arch wiki). Works like a charm for me.