2015-02-19 13:50:27 +00:00
|
|
|
#
|
|
|
|
# \brief Virtual-machine monitor demo
|
|
|
|
# \author Stefan Kalkowski
|
|
|
|
# \date 2015-06-25
|
|
|
|
#
|
|
|
|
|
2017-01-03 12:17:41 +00:00
|
|
|
assert_spec hw
|
2019-04-10 10:43:17 +00:00
|
|
|
|
2021-01-13 09:15:10 +00:00
|
|
|
if { ![have_board imx7d_sabre] && ![have_board imx8q_evk] &&
|
2022-08-09 11:32:38 +00:00
|
|
|
![have_board virt_qemu_arm_v7a] &&
|
|
|
|
![have_board virt_qemu_arm_v8a]} {
|
2019-04-10 10:43:17 +00:00
|
|
|
puts "Run script is not supported on this platform"
|
|
|
|
exit 0
|
|
|
|
}
|
2015-02-19 13:50:27 +00:00
|
|
|
|
|
|
|
create_boot_directory
|
2021-02-19 10:02:58 +00:00
|
|
|
import_from_depot [depot_user]/src/[base_src] \
|
|
|
|
[depot_user]/src/init \
|
|
|
|
[depot_user]/src/libc \
|
|
|
|
[depot_user]/src/log_terminal \
|
|
|
|
[depot_user]/src/nic_router \
|
|
|
|
[depot_user]/src/terminal_crosslink \
|
|
|
|
[depot_user]/src/vfs \
|
|
|
|
[depot_user]/src/vfs_block \
|
|
|
|
[depot_user]/src/vmm
|
|
|
|
|
|
|
|
build { test/terminal_expect_send }
|
2015-02-19 13:50:27 +00:00
|
|
|
|
2022-11-15 12:34:37 +00:00
|
|
|
proc vmm_config { } {
|
|
|
|
|
|
|
|
# for early printk add bootarg: earlycon=pl011,0x9000000
|
|
|
|
|
|
|
|
if {[have_spec arm]} {
|
|
|
|
return {
|
|
|
|
<config kernel_rom="linux" initrd_rom="initrd" ram_size="128M"
|
|
|
|
cpu_count="1" cpu_type="arm,cortex-a15" gic_version="2"
|
|
|
|
bootargs="rdinit=/bin/sh ip=dhcp console=hvc0">
|
|
|
|
<virtio_device name="hvc0" type="console"/>
|
|
|
|
<virtio_device name="eth0" type="net"/>
|
|
|
|
<virtio_device name="blk0" type="block"/>
|
|
|
|
</config>}
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[have_spec arm_64]} {
|
|
|
|
return {
|
|
|
|
<config kernel_rom="linux" initrd_rom="initrd" ram_size="128M"
|
|
|
|
cpu_count="4" cpu_type="arm,cortex-a53" gic_version="3"
|
|
|
|
bootargs="rdinit=/bin/sh ip=dhcp console=hvc0">
|
|
|
|
<virtio_device name="hvc0" type="console"/>
|
|
|
|
<virtio_device name="eth0" type="net"/>
|
|
|
|
<virtio_device name="blk0" type="block"/>
|
|
|
|
</config>}
|
|
|
|
}
|
|
|
|
|
|
|
|
return unavailable
|
|
|
|
}
|
|
|
|
|
2015-02-19 13:50:27 +00:00
|
|
|
install_config {
|
2019-09-03 14:29:27 +00:00
|
|
|
<config verbose="yes" prio_levels="2">
|
2015-02-19 13:50:27 +00:00
|
|
|
<parent-provides>
|
|
|
|
<service name="ROM"/>
|
|
|
|
<service name="IRQ"/>
|
|
|
|
<service name="IO_MEM"/>
|
|
|
|
<service name="PD"/>
|
|
|
|
<service name="RM"/>
|
|
|
|
<service name="CPU"/>
|
|
|
|
<service name="LOG"/>
|
|
|
|
<service name="VM"/>
|
|
|
|
</parent-provides>
|
|
|
|
<default-route>
|
|
|
|
<any-service><parent/><any-child/></any-service>
|
|
|
|
</default-route>
|
2017-05-07 20:36:11 +00:00
|
|
|
<default caps="100"/>
|
2021-02-19 10:02:58 +00:00
|
|
|
|
2015-02-19 13:50:27 +00:00
|
|
|
<start name="timer">
|
|
|
|
<resource name="RAM" quantum="1M"/>
|
|
|
|
<provides><service name="Timer"/></provides>
|
|
|
|
</start>
|
2021-02-19 10:02:58 +00:00
|
|
|
|
2024-05-30 13:46:57 +00:00
|
|
|
<start name="nic">
|
2019-10-21 12:18:12 +00:00
|
|
|
<binary name="nic_router" />
|
|
|
|
<resource name="RAM" quantum="8M"/>
|
2021-01-08 16:27:24 +00:00
|
|
|
<provides>
|
|
|
|
<service name="Nic"/>
|
|
|
|
<service name="Uplink"/>
|
|
|
|
</provides>
|
2019-10-21 12:18:12 +00:00
|
|
|
<config>
|
|
|
|
<default-policy domain="default"/>
|
|
|
|
<domain name="default" interface="10.0.1.1/24">
|
|
|
|
<dhcp-server ip_first="10.0.1.2" ip_last="10.0.1.2" />
|
|
|
|
</domain>
|
|
|
|
</config>
|
|
|
|
</start>
|
2021-02-19 10:02:58 +00:00
|
|
|
|
|
|
|
<start name="vfs_block">
|
|
|
|
<resource name="RAM" quantum="2M"/>
|
|
|
|
<provides> <service name="Block"/> </provides>
|
|
|
|
<config>
|
|
|
|
<vfs> <rom name="block.img"/> </vfs>
|
|
|
|
<default-policy file="/block.img" block_size="512"/>
|
|
|
|
</config>
|
|
|
|
<route>
|
|
|
|
<any-service> <parent/> </any-service>
|
|
|
|
</route>
|
|
|
|
</start>
|
|
|
|
|
2019-10-21 12:18:12 +00:00
|
|
|
<start name="log_terminal">
|
|
|
|
<resource name="RAM" quantum="2M"/>
|
|
|
|
<provides> <service name="Terminal"/> </provides>
|
|
|
|
</start>
|
2021-02-19 10:02:58 +00:00
|
|
|
|
2019-04-04 14:41:41 +00:00
|
|
|
<start name="terminal_crosslink">
|
|
|
|
<resource name="RAM" quantum="1M"/>
|
|
|
|
<provides> <service name="Terminal"/> </provides>
|
2015-02-19 13:50:27 +00:00
|
|
|
</start>
|
2021-02-19 10:02:58 +00:00
|
|
|
|
2019-09-03 14:29:27 +00:00
|
|
|
<start name="vmm" caps="200" priority="-1">
|
2015-02-19 13:50:27 +00:00
|
|
|
<resource name="RAM" quantum="256M"/>
|
2019-10-21 12:18:12 +00:00
|
|
|
<route>
|
|
|
|
<service name="Terminal" label="earlycon"> <child name="log_terminal"/> </service>
|
|
|
|
<service name="Terminal"> <child name="terminal_crosslink"/> </service>
|
2024-05-30 13:46:57 +00:00
|
|
|
<service name="Nic"> <child name="nic"/> </service>
|
2019-10-21 12:18:12 +00:00
|
|
|
<any-service><parent/><any-child/></any-service>
|
2022-11-15 12:34:37 +00:00
|
|
|
</route>} [vmm_config] {
|
2015-02-19 13:50:27 +00:00
|
|
|
</start>
|
2021-02-19 10:02:58 +00:00
|
|
|
|
2019-04-04 14:41:41 +00:00
|
|
|
<start name="vm">
|
|
|
|
<binary name="test-terminal_expect_send"/>
|
|
|
|
<resource name="RAM" quantum="1M"/>
|
2021-02-19 10:02:58 +00:00
|
|
|
<config expect="/ #" send="mount /dev/vda /root; cp -r /etc /root; ls /root/etc; umount /root" verbose="yes"/>
|
2019-10-21 12:18:12 +00:00
|
|
|
<route>
|
|
|
|
<service name="Terminal"> <child name="terminal_crosslink"/> </service>
|
|
|
|
<any-service><parent/><any-child/></any-service>
|
|
|
|
</route>
|
2019-04-04 14:41:41 +00:00
|
|
|
</start>
|
2015-02-19 13:50:27 +00:00
|
|
|
</config>
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-03 14:29:27 +00:00
|
|
|
if { [have_spec arm] } {
|
|
|
|
|
|
|
|
if {![file exists bin/linux]} {
|
|
|
|
puts "Download linux kernel ..."
|
2022-11-15 12:34:37 +00:00
|
|
|
exec >& /dev/null wget -c -O bin/linux http://genode.org/files/release-22.11/linux-virtio-arm32
|
2019-09-03 14:29:27 +00:00
|
|
|
}
|
|
|
|
|
2019-11-14 09:52:20 +00:00
|
|
|
if {![file exists bin/initrd]} {
|
|
|
|
puts "Download initramfs ..."
|
|
|
|
exec >& /dev/null wget -c -O bin/initrd http://genode.org/files/release-20.05/initrd-arm32
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2022-11-15 12:34:37 +00:00
|
|
|
# To build the linux kernel from scratch, do the following steps:
|
2015-02-19 13:50:27 +00:00
|
|
|
#
|
2022-11-15 12:34:37 +00:00
|
|
|
# wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.21.tar.xz
|
|
|
|
# tar -xJf linux-5.14.21.tar.xz
|
|
|
|
# cd linux-5.14.21
|
|
|
|
# wget -O .config https://raw.githubusercontent.com/skalk/linux/66fb717e92b47512d8f686860a2c5e7329d01691/arch/arm/configs/virtio_only_defconfig
|
|
|
|
# make ARCH=arm CROSS_COMPILE=/usr/local/genode/tool/current/bin/genode-arm-
|
2015-02-19 13:50:27 +00:00
|
|
|
#
|
2022-11-15 12:34:37 +00:00
|
|
|
# copy arch/arm/boot/Image to your build directory in 'bin/linux'
|
2015-02-19 13:50:27 +00:00
|
|
|
#
|
|
|
|
#
|
2019-11-14 09:52:20 +00:00
|
|
|
# To construct the initrd do the following:
|
|
|
|
# * get and install gcc from bootlin:
|
|
|
|
# (https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/)
|
|
|
|
# * build busybox
|
|
|
|
# wget https://busybox.net/downloads/busybox-1.31.1.tar.bz2
|
|
|
|
# tar xjf busybox-1.31.1.tar.bz2
|
|
|
|
# mkdir build-busybox-aarch32
|
|
|
|
# cd busybox-1.31.1
|
|
|
|
# make O=../build-busybox-aarch32 defconfig
|
|
|
|
# make O=../build-busybox-aarch32 menuconfig
|
2015-02-19 13:50:27 +00:00
|
|
|
#
|
2019-11-14 09:52:20 +00:00
|
|
|
# [*] Setting -> Build static binary (no shared libs)
|
|
|
|
#
|
|
|
|
# cd ../build-busybox-aarch32
|
|
|
|
# make CROSS_COMPILE=/opt/armv7-eabihf--uclibc--stable-2020.02-1/bin/arm-buildroot-linux-uclibcgnueabihf- install -j6
|
|
|
|
# * create ramdisk
|
|
|
|
# cd _install
|
|
|
|
# find . | cpio -H newc -o | gzip > ../initrd
|
2015-02-19 13:50:27 +00:00
|
|
|
#
|
|
|
|
}
|
|
|
|
|
2019-09-03 14:29:27 +00:00
|
|
|
if { [have_spec arm_64] } {
|
|
|
|
|
|
|
|
if {![file exists bin/linux]} {
|
|
|
|
puts "Download linux kernel ..."
|
2022-11-15 12:34:37 +00:00
|
|
|
exec >& /dev/null wget -c -O bin/linux http://genode.org/files/release-22.11/linux-virtio-arm64
|
2019-09-03 14:29:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if {![file exists bin/initrd]} {
|
|
|
|
puts "Download initramfs ..."
|
2019-10-21 12:18:12 +00:00
|
|
|
exec >& /dev/null wget -c -O bin/initrd http://genode.org/files/release-20.02/initrd-arm64
|
2019-09-03 14:29:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2022-11-15 12:34:37 +00:00
|
|
|
# To build the linux kernel from scratch, do the following steps:
|
2019-09-03 14:29:27 +00:00
|
|
|
#
|
2022-11-15 12:34:37 +00:00
|
|
|
# wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.21.tar.xz
|
|
|
|
# tar -xJf linux-5.14.21.tar.xz
|
|
|
|
# cd linux-5.14.21
|
|
|
|
# wget -O .config https://raw.githubusercontent.com/skalk/linux/66fb717e92b47512d8f686860a2c5e7329d01691/arch/arm64/configs/virtio_only_defconfig
|
|
|
|
# make ARCH=arm64 CROSS_COMPILE=/usr/local/genode/tool/current/bin/genode-aarch64-
|
2019-09-03 14:29:27 +00:00
|
|
|
#
|
2022-11-15 12:34:37 +00:00
|
|
|
# copy arch/arm64/boot/Image to your build directory in 'bin/linux'
|
2019-09-03 14:29:27 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# To construct the initrd do the following:
|
|
|
|
# * get and install gcc from linaro
|
|
|
|
# (https://releases.linaro.org/components/toolchain/binaries/latest-7/)
|
|
|
|
# * build busybox
|
|
|
|
# wget https://busybox.net/downloads/busybox-1.29.3.tar.bz2
|
|
|
|
# tar xjf busybox-1.29.3.tar.bz2
|
|
|
|
# mkdir build-busybox-aarch64
|
|
|
|
# cd busybox-1.29.3
|
|
|
|
# make O=../build-busybox-aarch64 defconfig
|
|
|
|
# make O=../build-busybox-aarch64 menuconfig
|
|
|
|
#
|
|
|
|
# [*] Setting -> Build static binary (no shared libs)
|
|
|
|
#
|
|
|
|
# cd ../build-busybox-aarch64
|
|
|
|
# make CROSS_COMPILE=/usr/local/gcc-linaro/bin/aarch64-linux-gnu- install -j6
|
|
|
|
# * create ramdisk
|
|
|
|
# cd _install
|
|
|
|
# find . | cpio -H newc -o | gzip > ../initrd
|
2015-02-19 13:50:27 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 10:02:58 +00:00
|
|
|
catch { exec [installed_command dd] if=/dev/zero of=bin/block.img bs=1M count=0 seek=64 }
|
|
|
|
exec [installed_command mkfs.vfat] bin/block.img
|
|
|
|
|
2023-05-04 14:18:04 +00:00
|
|
|
build_boot_image [list {*}[build_artifacts] linux initrd block.img]
|
2015-02-19 13:50:27 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Execute test case
|
|
|
|
#
|
2020-03-25 18:09:36 +00:00
|
|
|
append qemu_args " -nographic "
|
2021-02-19 10:02:58 +00:00
|
|
|
|
|
|
|
run_genode_until "\[init -> vm\] .*resolv.conf.*" 220
|
2022-11-15 12:34:37 +00:00
|
|
|
exec rm bin/linux bin/initrd bin/block.img
|