From: Luca Miccio Subject: Re: [GSoC] Xen on ARM: create multiple guests from device tree Date: Thu, 23 Mar 2017 03:23:37 +0100 Message-ID: <075C6339-D4FD-4518-BE67-B63D2B4960EF@gmail.com> References: <58D17A85.5050709@gmail.com> <2A15827A-D2E8-4D7C-96F2-076A0C6AD8EC@gmail.com> <172A126F-34AD-48BC-A305-0C3F43623E76@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 10.0 \(3226\)) Content-Type: multipart/mixed; boundary="===============8411654084599192600==" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqsPe-0005N1-1d for xen-devel@lists.xenproject.org; Thu, 23 Mar 2017 02:23:42 +0000 Received: by mail-wm0-f67.google.com with SMTP id n11so13827836wma.0 for ; Wed, 22 Mar 2017 19:23:39 -0700 (PDT) In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Stefano Stabellini Cc: andre.przywara@arm.com, Dario.faggioli@citrix.com, Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org, nd@arm.com List-Id: xen-devel@lists.xenproject.org --===============8411654084599192600== Content-Type: multipart/alternative; boundary="Apple-Mail=_6E752355-11FE-40DF-B1F1-4B3360D07C6A" --Apple-Mail=_6E752355-11FE-40DF-B1F1-4B3360D07C6A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Il giorno 23 mar 2017, alle ore 01:55, Stefano Stabellini = ha scritto: >=20 > On Thu, 23 Mar 2017, Luca Miccio wrote: >>> Il giorno 23 mar 2017, alle ore 01:27, Stefano Stabellini = ha scritto: >>>=20 >>> On Thu, 23 Mar 2017, Luca Miccio wrote: >>>> Hi Stefano and Julien, >>>>=20 >>>>> Il giorno 22 mar 2017, alle ore 22:38, Stefano Stabellini = ha scritto: >>>>>=20 >>>>> Hi Luca, >>>>>=20 >>>>> please don't use HTML emails. >>>>>=20 >>>>>=20 >>>> Sorry for that. >>>>=20 >>>>> On Wed, 22 Mar 2017, Julien Grall wrote: >>>>>> On 22/03/2017 19:45, Luca Miccio wrote: >>>>>>> Hi Stefano, >>>>>>=20 >>>>>> Hello Luca, >>>>>>=20 >>>>>>> aarch64-linux-gnu-gcc -DCNTFRQ=3D0x01800000-DUART_BASE=3D0x1c0900= 00 >>>>>>> -DSYSREGS_BASE=3D0x1c010000 -DGIC_DIST_BASE=3D0x2c001000 >>>>>>> -DGIC_CPU_BASE=3D0x2c002000 -c -o boot.xen.o boot.S -DXEN >>>>>>> aarch64-linux-gnu-gcc -DPHYS_OFFSET=3D0x80000000 = -DMBOX_OFFSET=3D0xfff8 >>>>>>> -DBOOT=3Dboot.xen.o -DXEN_OFFSET=3D0xA00000 = -DKERNEL_OFFSET=3D0x80000 >>>>>>> -DFDT_OFFSET=3D0x08000000 -DFS_OFFSET=3D0x10000000 -DXEN=3DXen = -DKERNEL=3DImage >>>>>>> -DFILESYSTEM=3Dfilesystem.cpio.gz -E -P -C -o model.xen.lds = model.lds.S >>>>>>> aarch64-linux-gnu-gcc -DCNTFRQ=3D0x01800000-DUART_BASE=3D0x1c0900= 00 >>>>>>> -DSYSREGS_BASE=3D0x1c010000 -DGIC_DIST_BASE=3D0x2c001000 >>>>>>> -DGIC_CPU_BASE=3D0x2c002000 -c -o boot.o boot.S >>>>>>> aarch64-linux-gnu-gcc -DPHYS_OFFSET=3D0x80000000 = -DMBOX_OFFSET=3D0xfff8 >>>>>>> -DBOOT=3Dboot.o -DKERNEL_OFFSET=3D0x80000 = -DFDT_OFFSET=3D0x08000000 >>>>>>> -DFS_OFFSET=3D0x10000000 -DKERNEL=3DImage = -DFILESYSTEM=3Dfilesystem.cpio.gz -E >>>>>>> -P -C -o model.lds model.lds.S >>>>>>> aarch64-linux-gnu-ld -o xen-system.axf --script=3Dmodel.xen.lds >>>>>>> aarch64-linux-gnu-ld: section .xen LMA >>>>>>> [0000000080a00000,0000000080ac814f] overlaps section .kernel LMA >>>>>>> [0000000080080000,0000000080f009ff] >>>>>>> Makefile:78: set di istruzioni per l'obiettivo "xen-system.axf" = non riuscito >>>>>>> make: *** [xen-system.axf] Errore 1\ >>>>>>>=20 >>>>>>> Clearly there is a problem with the offset of xen section but i = can't >>>>>>> figure out how to solve it. >>>>>>=20 >>>>>> I would recommend to use the latest version of bootwrapper which = is now >>>>>> including support for Xen. I haven't yet updated the wiki with = the runes >>>>>> but here a quick summary of the step I am using: >>>>>>=20 >>>>>> * Building bootwrapper >>>>>>=20 >>>>>> 42sh> git clone = git://git.kernel.org/pub/scm/linux/kernel/git/mark/boot-wrapper-aarch64.gi= t >>>>>> 42sh> autoreconf -i >>>>>> 42sh> ./configure --host=3Daarch64-linux-gnu = --with-kernel-dir=3D --with-dtb=3D \ >>>>>> --with-cmdline=3D"console=3Dhvc0 earlycon=3Dpl011,0x1c090000 = root=3D/dev/vda rw" --enable-psci \ >>>>>> --with-xen-cmdline=3D"dtuart=3Dserial0 console=3Ddtuart = no-bootscrub dom0_mem=3D512M" \ >>>>>> --with-xen=3D --with-cpu-ids=3D0,1,2,3 >>>>>> 42sh> make >>>>>>=20 >>>>>> Where: >>>>>> * is the path to the kernel repository >>>>>> * is the path to the device-tree. I am using the one = shipped with Linux >>>>>> in arch/arm64/boot/dts/arm/foundation-armv8.dtbs >>>>>> It will be built if you did make all in Linux >>>>>> * is the path to Xen binary (xen/xen in the repo) >>>>>>=20 >>>>>> * Command line for the foundation model >>>>>> 42sh> Foundation_Platform --image=3D = --block-device=3D --cores=3D4 >>>>>>=20 >>>>>> Where: >>>>>> * is the path to xen-system.axf produced by bootwrapper >>>>>> * is the patch to your rootfs >>>>>>=20 >>>>>> Let me know if you need more details. >>>>>=20 >>>>> Thanks Julien, I successfully booted Xen and Linux following these >>>>> steps. I quickly updated the wiki. >>>>>=20 >>>>> Luca, I took me a while to figure out that for root=3D/dev/vda to = work >>>>> properly, Linux requires not just all the filesystem and virtio = options >>>>> enabled in the kernel config, but also CONFIG_VIRTIO_MMIO=3Dy. = With that, >>>>> you should be able to boot Xen, Linux and mount the root = filesystem. If >>>>> you download one of the Ubuntu arm64 cloud images, the root device = will >>>>> be /dev/vda1. >>>>=20 >>>> First of all, thank you for your help. >>>>=20 >>>> I think that i keep on doing somenthing wrong because now the = bootwrapper produces >>>> with no errors the xen-system.axf with the configuration that = Julien provided.=20 >>>> But when i launch the emulator it simply stops at: >>>> (XEN) Bringing up CPU1 >>>>=20 >>>> To help you understand, this is what i have done: >>>> - First i compiled the xen source with the following command: >>>> $ make dist-xen XEN_TARGET_ARCH=3Darm64 = CROSS_COMPILE=3Daarch64-linux-gnu- CONFIG_EARLY_PRINT=3Dfastmodel >>>> ( I am using the staging branch) >>>>=20 >>>> - Get the linux source with git:=20 >>>> $ git clone = git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git >>>>=20 >>>> -Checkout on the v4.4 branch=20 >>>>=20 >>>> - Follow the steps described in the blog and, as you said, i set in = my .config file: >>>> CONFIG_VIRTIO=3Dy >>>> CONFIG_VIRTIO_MMIO=3Dy >>>> CONFIG_VIRTIO_BLK=3Dy >>>> I also checked all the filesystem and virtio options.=20 >>>>=20 >>>> - Compile the linux kernel with the toolchain: >>>> $ make ARCH=3Darm64 CROSS_COMPILE=3Daarch64-linux-gnu- all (to get = also the .dtb file) >>>>=20 >>>> - Configured the bootwrapper with the command that Julian wrote and = then launched the=20 >>>> foundation model with the simple command: >>>> $ Foundation_Platform --image=3D/path/to/the/xen-system.axf = --block-device=3Dxenial-server-cloudimg-arm64.img --cores=3D4 >>>=20 >>> Try removing --cores=3D4, does it work? >>>=20 >> I have already tried this option with no results >=20 > The problem is that no matter the --cores=3D4 option, the device tree > (foundation-v8.dtb) has 4 cpu cores by default. It also says that the > "enable-method" is "spin-table". At the same time Julien wrote to pass > --enable-psci to the bootwrapper, which is a different way to start > secondary cpus. I am guessing that is the problem. I suggest to change > boot method to psci, to do that you need to modify the dts (device = tree > source), see the attached patch for Linux. Then you can rebuild the = dtb > (device tree binary) with: >=20 > make dtbs >=20 > Finally rebuild again the bootwrapper and run the model with --cores = 4. >=20 > For me, that works. Great way to get familiar with device tree ;-) I tried also this method but i had the same error. So i came up with the = idea of removing the psci method from the configure and also from the dtsi file that i have = changed.=20 With this configuration the model booted up correctly, even if the = process took about 10 minutes. Just for my personal knowledge: it is normal that the boot is very slow? = Is the rootfs that i=E2=80=99m using? Thank you for your response, Luca >=20 >>>> The image was downloaded at : = https://cloud-images.ubuntu.com/releases/16.04/release/ = >>>>=20 >>>> But, as I said, the emulator blocks at boot. I tried different = rootfs images and i have configured the root device >>>> properly to /dev/vda1. >>>>=20 >>>> Maybe my kernel configuration is wrong? > <1.txt> --Apple-Mail=_6E752355-11FE-40DF-B1F1-4B3360D07C6A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Il giorno 23 mar 2017, alle ore 01:55, Stefano Stabellini = <sstabellini@kernel.org> ha scritto:

On Thu, 23 Mar 2017, Luca Miccio = wrote:
Il giorno 23 mar 2017, alle ore 01:27, Stefano Stabellini = <sstabellini@kernel.org> ha scritto:

On Thu, 23 Mar 2017, Luca Miccio wrote:
Hi Stefano and = Julien,

Il giorno 22 mar 2017, alle ore 22:38, Stefano Stabellini = <sstabellini@kernel.org> ha scritto:

Hi Luca,

please don't use HTML = emails.


Sorry = for that.

On Wed, 22 Mar 2017, Julien Grall wrote:
On 22/03/2017 19:45, = Luca Miccio wrote:
Hi = Stefano,

Hello Luca,

aarch64-linux-gnu-gcc =  -DCNTFRQ=3D0x01800000-DUART_BASE=3D0x1c090000
-DSYSREGS_BASE=3D0x1c010000 -DGIC_DIST_BASE=3D0x2c001000
-DGIC_CPU_BASE=3D0x2c002000 -c -o boot.xen.o boot.S -DXEN
aarch64-linux-gnu-gcc  -DPHYS_OFFSET=3D0x80000000 = -DMBOX_OFFSET=3D0xfff8
-DBOOT=3Dboot.xen.o = -DXEN_OFFSET=3D0xA00000 -DKERNEL_OFFSET=3D0x80000
-DFDT_OFFSET=3D0x08000000 -DFS_OFFSET=3D0x10000000 -DXEN=3DXen = -DKERNEL=3DImage
-DFILESYSTEM=3Dfilesystem.cpio.gz -E -P = -C -o model.xen.lds model.lds.S
aarch64-linux-gnu-gcc =  -DCNTFRQ=3D0x01800000-DUART_BASE=3D0x1c090000
-DSYSREGS_BASE=3D0x1c010000 -DGIC_DIST_BASE=3D0x2c001000
-DGIC_CPU_BASE=3D0x2c002000 -c -o boot.o boot.S
aarch64-linux-gnu-gcc  -DPHYS_OFFSET=3D0x80000000 = -DMBOX_OFFSET=3D0xfff8
-DBOOT=3Dboot.o = -DKERNEL_OFFSET=3D0x80000 -DFDT_OFFSET=3D0x08000000
-DFS_OFFSET=3D0x10000000 -DKERNEL=3DImage = -DFILESYSTEM=3Dfilesystem.cpio.gz -E
-P -C -o model.lds = model.lds.S
aarch64-linux-gnu-ld -o xen-system.axf = --script=3Dmodel.xen.lds
aarch64-linux-gnu-ld: section = .xen LMA
[0000000080a00000,0000000080ac814f] overlaps = section .kernel LMA
[0000000080080000,0000000080f009ff]
Makefile:78: set di istruzioni per l'obiettivo = "xen-system.axf" non riuscito
make: *** [xen-system.axf] = Errore 1\

Clearly there is a problem with = the offset of xen section but i can't
figure out how to = solve it.

I would recommend to = use the latest version of bootwrapper which is now
including= support for Xen. I haven't yet updated the wiki with the runes
but here a quick summary of the step I am using:

* Building bootwrapper

42sh> git clone git://git.kernel.org/pub/scm/linux/kernel/git/mark/boot-wrapper= -aarch64.git
42sh> autoreconf -i
42sh> ./configure --host=3Daarch64-linux-gnu = --with-kernel-dir=3D<kernel-dir> --with-dtb=3D<dtb> \
--with-cmdline=3D"console=3Dhvc0 earlycon=3Dpl011,0x1c090000 = root=3D/dev/vda rw" --enable-psci \
--with-xen-cmdline=3D"dtuart=3Dserial0 console=3Ddtuart = no-bootscrub dom0_mem=3D512M" \
--with-xen=3D<xen-bin>= --with-cpu-ids=3D0,1,2,3
42sh> make

Where:
* <kernel-dir> is the path to the = kernel repository
* <dtb> is the path to the = device-tree. I am using the one shipped with Linux
 in = arch/arm64/boot/dts/arm/foundation-armv8.dtbs
 It = will be built if you did make all in Linux
* = <xen-bin> is the path to Xen binary (xen/xen in the repo)

* Command line for the foundation model
42sh> Foundation_Platform --image=3D<image> = --block-device=3D<rootfs> --cores=3D4

Where:
* <image> is the path to = xen-system.axf produced by bootwrapper
* <rootfs> is = the patch to your rootfs

Let me know if you = need more details.

Thanks = Julien, I successfully booted Xen and Linux following these
steps. I quickly updated the wiki.

Luca, I took me a while to figure out that for root=3D/dev/vda = to work
properly, Linux requires not just all the = filesystem and virtio options
enabled in the kernel = config, but also CONFIG_VIRTIO_MMIO=3Dy. With that,
you = should be able to boot Xen, Linux and mount the root filesystem. If
you download one of the Ubuntu arm64 cloud images, the root = device will
be /dev/vda1.

First of all, thank you for your help.

I think that i keep on doing somenthing wrong because now the = bootwrapper produces
with no errors the xen-system.axf =  with the configuration that Julien provided. 
But when i = launch the emulator it simply stops at:
(XEN) Bringing up = CPU1

To help you understand, this is what i = have done:
- First i compiled the xen source with the = following command:
$ make dist-xen XEN_TARGET_ARCH=3Darm64 = CROSS_COMPILE=3Daarch64-linux-gnu- CONFIG_EARLY_PRINT=3Dfastmodel
( I am using the staging branch)

-= Get the linux source with git: 
$ git clone = git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.gi= t

-Checkout on the v4.4 branch 

- Follow the steps described in the blog and, as you said, i = set in my .config file:
CONFIG_VIRTIO=3Dy
CONFIG_VIRTIO_MMIO=3Dy
CONFIG_VIRTIO_BLK=3Dy
I also checked all the filesystem and virtio options. 

- Compile the linux kernel with the toolchain:
$ = make ARCH=3Darm64 CROSS_COMPILE=3Daarch64-linux-gnu- all (to get also = the .dtb file)

- Configured the bootwrapper = with the command that Julian wrote and then launched the 
foundation = model with the simple command:
$ Foundation_Platform = --image=3D/path/to/the/xen-system.axf = --block-device=3Dxenial-server-cloudimg-arm64.img --cores=3D4

Try removing --cores=3D4, does it = work?

I have already tried = this option with no results

The problem is that = no matter the --cores=3D4 option, the device tree
(foundation-v8.dtb) = has 4 cpu cores by default. It also says that the
"enable-method" is = "spin-table". At the same time Julien wrote to pass
--enable-psci to = the bootwrapper, which is a different way to start
secondary cpus. I = am guessing that is the problem. I suggest to change
boot method to = psci, to do that you need to modify the dts (device tree
source), see the = attached patch for Linux. Then you can rebuild the dtb
(device tree = binary) with:

make dtbs

Finally rebuild again the bootwrapper and = run the model with --cores 4.

For me, that works. Great way to get familiar = with device tree ;-)

I tried also = this method but i had the same error. So i came up with the idea of = removing the
psci method from the configure and also from the = dtsi file that i have changed. 

With this configuration the model booted up = correctly, even if the process took about 10 minutes.
Just for = my personal knowledge: it is normal that the boot is very slow? Is the = rootfs that i=E2=80=99m using?


Thank you for your = response,
Luca



The image was downloaded = at : https://cloud-images.ubuntu.com/releases/16.04/release/

But, as I said, the emulator blocks at boot. I = tried different rootfs images and i have configured the root device
properly to /dev/vda1.

Maybe my = kernel configuration is = wrong?
&l= t;1.txt>


= --Apple-Mail=_6E752355-11FE-40DF-B1F1-4B3360D07C6A-- --===============8411654084599192600== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============8411654084599192600==--