本节使用上一实验章节在qemu vexpress-a15平台运行xen,guest OS Dom0 Linux编译生成的linux镜像和文件系统为基础进行测试运行。
首先需要修改设备树文件:
/ {
model = "V2P-CA15_CA7";
arm,hbi = <0x249>;
arm,vexpress,site = <0xf>;
compatible = "arm,vexpress,v2p-ca15_a7", "arm,vexpress";
interrupt-parent = <&gic>;
#address-cells = <2>;
#size-cells = <2>;
chosen {
bootargs = "dom0_mem=768M console=dtuart dtuart=serial0 dom0_vcpus_pin hmp-unsafe=true dom0_max_vcpus=1 bootscrub=0 loglvl=all";
/delete-property/stdout-path;
xen,dom0-bootargs = "rw root=/dev/ram rdinit=/sbin/init earlyprintk=serial,ttyAMA0 console=hvc0 earlycon=xenboot";
modules {
#address-cells = <1>;
#size-cells = <1>;
module@1 {
compatible = "xen,linux-zimage", "xen,multiboot-module";
reg = <0xa0008000 0xffffff>;
};
module@2 {
compatible = "multiboot,ramdisk", "multiboot,module";
reg = <0x82000000 0xffffff>;
};
};
domU1 {
compatible = "xen,domain";
#address-cells = <0x2>;
#size-cells = <0x1>;
memory = <0 131072>;
cpus = <1>;
vpl011;
module@1 {
compatible = "multiboot,kernel", "multiboot,module";
reg = <0x0 0xb0008000 0xffffff>;
bootargs = "rw root=/dev/ram rdinit=/sbin/init console=ttyAMA0";
};
module@2 {
compatible = "multiboot,ramdisk", "multiboot,module";
reg = <0x0 0x84000000 0xffffff>;
};
};
};
添加DomU1相关配置,memory字段指定DomU1内存空间大小,以kb为单位;cpus指定DomU1创建的vcpu数量;module@1和module@2的字段跟DomU0配置一样,只需修改起始地址,kernel的镜像位置指定为0xb0008000,ramdisk的起始地址指定为0x84000000,配置在qemu传参时要对应上。然后编译生成.dtb文件,作为设备树二进制文件传给xen启动使用。
运行 Qemu Xen DomU0 Linux和DomU1 Linux
qemu-system-aarch64 -machine vexpress-a15 -machine virtualization=true -cpu cortex-a15 -m 2048 -kernel u-boot -device loader,file=xen-uImage,force-raw=on,addr=0x80400000 -device loader,file=zImage,addr=0xa0008000 -device loader,file=vexpress-v2p-ca15_a7.dtb,addr=0x81f00000 -device loader,file=rootfs.img.gz,addr=0x82000000 -device loader,file=zImage,addr=0xb0008000 -device loader,file=rootfs.img.gz,addr=0x84000000 -nographic
U-Boot 2019.01 (Sep 14 2021 - 02:57:40 -0700)
DRAM: 1 GiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC: MMC: 0
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: smc911x-0
Hit any key to stop autoboot: 0
=> bootm 0x80400000 - 0x81f00000
输入bootm 0x80400000 - 0x81f00000,启动xen,如下是启动输出流程。
## Booting kernel from Legacy Image at 80400000 ...
Image Name:
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1048584 Bytes = 1 MiB
Load Address: 80200000
Entry Point: 80200000
Verifying Checksum ... OK
## Flattened Device Tree blob at 81f00000
Booting using the fdt blob at 0x81f00000
Loading Kernel Image ... OK
Loading Device Tree to 9fe61000, end 9fe68606 ... OK
Starting kernel ...
- UART enabled -
- Boot CPU booting -
- Setting up control registers -
- Turning on paging -
- Zero BSS -
- Ready -
(XEN) Checking for initrd in /chosen
(XEN) RAM: 0000000080000000 - 000000009fffffff
(XEN) RAM: 00000000a0000000 - 00000000bfffffff
(XEN)
(XEN) MODULE[0]: 0000000080200000 - 000000008033e290 Xen
(XEN) MODULE[1]: 000000009fe61000 - 000000009fe66000 Device Tree
(XEN) MODULE[2]: 00000000a0008000 - 00000000a0a08000 Kernel
(XEN) MODULE[3]: 0000000082000000 - 0000000082ffffff Ramdisk
(XEN) MODULE[4]: 00000000b0008000 - 00000000b1007fff Kernel
(XEN) MODULE[5]: 0000000084000000 - 0000000084ffffff Ramdisk
(XEN) RESVD[0]: 000000009ffbf000 - 000000009ffbf138
(XEN) RESVD[1]: 000000009fe61000 - 000000009fe66000
(XEN)
(XEN) CMDLINE[00000000b0008000]:domU1 rw root=/dev/ram rdinit=/sbin/init console=ttyAMA0
(XEN)
(XEN) Command line: dom0_mem=768M console=dtuart dtuart=serial0 dom0_vcpus_pin hmp-unsafe=true dom0_max_vcpus=1 bootscrub=0 loglvl=all
(XEN) PFN compression on bits 18...18
(XEN) Xen heap: 00000000be000000-00000000c0000000 (8192 pages)
(XEN) Dom heap: 253952 pages
(XEN) Domain heap initialised
(XEN) Booting using Device Tree
(XEN) Platform: VERSATILE EXPRESS
(XEN) Looking for dtuart at "serial0", options ""
Xen 4.16-unstable
(XEN) Xen version 4.16-unstable (hdwei@) (arm-linux-gnueabihf-gcc (Linaro GCC 6.5-2018.12) 6.5.0) debug=y Thu Apr 7 19:39:17 PDT 2022
(XEN) Latest ChangeSet: Thu Sep 9 17:34:39 2021 +0100 git:c76cfad-dirty
(XEN) build-id: 4830b94fe5739cf53a28a8c9222535f48d661f54
(XEN) Processor: 412fc0f1: "ARM Limited", variant: 0x2, part 0xc0f,rev 0x1
(XEN) 32-bit Execution:
(XEN) Processor Features: 00001131:00011011
(XEN) Instruction Sets: AArch32 A32 Thumb Thumb-2 ThumbEE Jazelle
(XEN) Extensions: GenericTimer Security
(XEN) Debug Features: 02010555
(XEN) Auxiliary Features: 00000000
(XEN) Memory Model Features: 10201105 20000000
(XEN) 01240000 02102211
(XEN) ISA Features: 02101110 13112111 21232041
(XEN) 111121

本文详细介绍了如何在qemuvexpress-a15平台上使用Xen启动两个Linux DomU,包括修改设备树文件、配置DomU1参数,并展示了启动过程中的关键输出。实验涉及Linux内核镜像加载、设备树和内存管理等技术。
最低0.47元/天 解锁文章
1094

被折叠的 条评论
为什么被折叠?



