How to use Xen for linux(ubuntu) and Android

hi, @leo-yan
yes, it is 3GB.
[ 0.000000] Memory: 3019664K/3109084K available (10236K kernel code, 1180K rwdata, 4728K rodata, 1152K init, 405K bss, 73036K reserved, 16384K cma-reserved)
also according to HiKey960 - 96Boards
hikey960 DRAM is 3GB.

as for the booting image, I am using the latest version.

My board is also 3GB.

hi, @dradspd
seems this doesn’t matter 3G or 4G, I have another 4GB DRAM hikey960, the result is the same. I guess this is related to somewhere DRAM configuration or kernel size.

hi, @leo-yan
your 5.0-xen kernel, I tried, but failed, after boot, there is nothing coming out from console.
after deleted following section code in dts, now it works, also my xen can work now.

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
index 665c74d…33ea836 100644
— a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
+++ b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
@@ -45,16 +45,6 @@
#size-cells = <2>;
ranges;

– uefi-reboot-mode {
– reg = <0x0 0x32100000 0x0 0x00001000>;
– no-map;
– };

– bl31 {
– reg = <0x0 0x20200000 0x0 0x200000>;
– no-map;
– };

Thanks a lot for sharing this, @jackyard. At my side I don’t need to remove these two memory sections from dts.

Actually, UEFI will overwrite the memory regions with the code [1], thus ‘uefi-reboot-mode’ region will be reserved by UEFI by default; thus whether you remove it from dts or not, it will be reserved and cannot be used by Xen/kernels.

So I think BL31 region is the only cause for your booting failure; there has a conflict between the BL31 region [0x20200000-0x20400000) and Xen loading Image target address range [0000000020080000-00000000214bba00]; you could see my built Xen image can handle it by loading image to higher memory address so that avoid confliction.

I can confirm you are using a newer Xen code base than mine, so suppose there has some regression in Xen (my Xen code base last commit id is: commit a5b0eb363694e7e15405f0b3fc5fb6fab79df1db " x86/mm/p2m: stop checking for IOMMU shared page tables in mmio_order()"). I will rebuild Xen with latest code base and let you know the result.

Come back to your fixing, you could use it as temporary fixing but it’s not safe enough. Since you are using one conflicted memory region with ARM-TF BL31, which is runtime firmware.

[1] https://github.com/96boards-hikey/OpenPlatformPkg/blob/testing/hikey960_v1.3.4/Platforms/Hisilicon/HiKey960/Library/HiKey960Lib/HiKey960Mem.c#L49

Hello @leo-yan

Can you please share the booting images with which you got Xen to work ?

I know its been sometime since you were at this but still, if you have or could point to the current appropriate version for the same, it would be very helpful.

Thanks,
Rajagopal

Hi @Rajagopal,

Sorry for late. Hope now you are still interesting in Xen on Hikey960.

Since it’s a bit long while back when I tested Xen on Hikey960, the exactly steps I am not quite sure. Below are some my notes for enabling Xen on Hikey960:

Firstly, you could download prebuilt booting images from [1] and download Debian boot.img and rootFS image [2].

Then below are the notes for booting Xen with some extra steps.

- Linux kernel: mainline kernel with 5.0-rc2;

  make defconfig
  make -j16 Image dtbs

- Xen: latest code base

  git clone git://xenbits.xen.org/xen.git
  cd xen
  make dist-xen XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

- Prepare my boot image:

  $ mount -o loop,rw,sync boot-linux.uefi.img boot-fat  -> Here you need to use boot-linaro-stretch-developer-hikey-20191220-41.img which is downloaded from [2].
  $ cp Image hi6220-hikey.dtb boot-fat/

  # prepare xen.cfg and startup.nsh
  xen.cfg:
  options=dom0_mem=512M dom0_max_vcpus=8 conswitch=x console=dtuart
  dtuart=/smb/uart@f7113000
  kernel=Image console=hvc root=/dev/mmcblk0p9 rootwait rw 3 mem=256M
  dtb=hi6220-hikey.dtb


  # For startup.nsh, it have below content:
  FS0:
  Image console=ttyAMA3,115200 root=/dev/mmcblk0p9 rootwait rw efi=noruntime earlycon=pl011,0xf7113000

  $ umount boot-fat

- Flash the boot image into 'boot' partition and UEFI will find it by
  default:

  $ fastboot flash boot boot-linux.uefi.img

- After run into UEFI shell, execute 'xen' command

Another thing should note is the grub program: grubaa64.efi, you might need to build this image manually with specific configurations, this is because Hikey960’s prebuilt images might contain a grub which cannot support Xen properly. The detailed steps you could check the page [3], section “Building GRUB”.

[1] http://snapshots.linaro.org/reference-platform/components/uefi-staging/latest/hikey960/debug/
[2] http://snapshots.linaro.org/96boards/hikey/linaro/debian/latest/
[3] HiKey960 - Xen

Hello @leo-yan,

Thanks for the detailed steps and yes, I am still interested in Xen on HiKey960.

I managed to bring-up Ubuntu as Dom-U with GUI.
I modified @sumit.garg 's upstream-rebase kernel to support Dom-U & Hynix-UFS and used the same for both Dom-0 & Dom-U.

Now I am trying to bring-up Android as Dom-U, in the same setup.
Have you or anyone here achieved this before ?

I managed to build HiKey960 Android kernel from source, with Xen Dom-U enabled.
This kernel was also tested to be working fine natively, before trying it as Dom-U.
The rest - ramdisk, vendor, system & userdata, I am using as it is from factory-855.
For Dom-U I am NOT using the dt.img or any of its components, though.

I am able to get to 2nd stage of mounting but run into a loop of audiohal, cameraserver etc getting killed and started again.

Any inputs on this, please ?

Thanks in advance,
Rajagopal

No, I didn’t go so far :slight_smile:

Before I encountered the similar issue, and I can reflash userdata.img or use below command:

sudo fastboot format userdata

Not sure if this is the same problem or not.

Hello @leo-yan

Thanks for replying and y es I am still interested
in Xen on HiKey960.

I managed to bring-up Ubuntu as Dom-U with @Sumanth’s upstream-rebase as Dom-0.

Now I am trying to bring-up Android as Dom-U and keep running into “zygote” error.

Have you or anyone here achieved this before ?

Any inputs on this, please ?

Thanks & Regards,

Rajagopal

Disclaimer: “This message is intended only for the designated recipient(s). It may contain confidential or proprietary information and may be subject to other confidentiality protections. If you are not a designated recipient, you may not review, copy or distribute
this message. Please notify the sender by e-mail and delete this message. GlobalEdge does not accept any liability for virus infected mails.”