		Linux on Xvisor Virt-v8 SMP Guest

Linux is a computer operating system which is based on free and open source
software. the underlying source code can be used, freely modified, and
redistributed, both commercially and non-commercially, by anyone under
licenses such as the GNU General Public License. For more information on
Linux read the wiki page http://en.wikipedia.org/wiki/Linux

Linux already contains a support for device-tree based boards. We can use
linux kernel unmodified to run it as a Virt-v8 guest. We also provide a
defconfig for building kernel. To obtain Linux kernel sources visit the
following url: http://www.kernel.org

Please follow the steps below to build & run Linux kernel with Busybox
RootFS on Virt-v8 (paravirtualized ARMv8) Guest with Xvisor running on
Foundation v8 model (v11.xx or higher):

  [1. Build environment for Xvisor]
  # CROSS_COMPILE=aarch64-none-linux-gnu-

  [2. GoTo Xvisor source directory]
  # cd <xvisor_source_directory>

  [3. Configure Xvisor with Generic-V8 default settings]
  # make ARCH=arm generic-v8-defconfig

  [4. Build Xvisor & DTBs]
  # make

  [5. Build Basic Firmware]
  # make -C tests/arm64/virt-v8/basic

  [6. GoTo Linux source directory]
  # cd <linux_source_directory>

  [7. Configure Linux in build directory]
  # cp arch/arm64/configs/defconfig arch/arm64/configs/tmp-virt-v8_defconfig
  # <xvisor_source_directory>/tests/common/scripts/update-linux-defconfig.sh -p arch/arm64/configs/tmp-virt-v8_defconfig -f <xvisor_source_directory>/tests/arm64/virt-v8/linux/linux_extra.config
  # make O=<linux_build_directory> ARCH=arm64 tmp-virt-v8_defconfig

  [8. Build Linux in build directory to reflect changes in kernel image]
  # make O=<linux_build_directory> ARCH=arm64 Image dtbs

  [9. Create BusyBox RAMDISK to be used as RootFS for Linux kernel]
  (Note: For subsequent steps, we will assume that your RAMDISK is located at <busybox_rootfs_directory>/rootfs.img)
  (Note: Please refer tests/common/busybox/README.md for creating rootfs.img using BusyBox)

  [10. GoTo Xvisor source directory]
  # cd <xvisor_source_directory>

  [11. Create disk image for Xvisor]
  # mkdir -p ./build/disk/tmp
  # mkdir -p ./build/disk/system
  # cp -f ./docs/banner/roman.txt ./build/disk/system/banner.txt
  # cp -f ./docs/logo/xvisor_logo_name.ppm ./build/disk/system/logo.ppm
  # mkdir -p ./build/disk/images/arm64/virt-v8
  # dtc -q -I dts -O dtb -o ./build/disk/images/arm64/virt-v8-guest.dtb ./tests/arm64/virt-v8/virt-v8-guest.dts
  # cp -f ./build/tests/arm64/virt-v8/basic/firmware.bin ./build/disk/images/arm64/virt-v8/firmware.bin
  # cp -f ./tests/arm64/virt-v8/linux/nor_flash.list ./build/disk/images/arm64/virt-v8/nor_flash.list
  # cp -f ./tests/arm64/virt-v8/linux/cmdlist ./build/disk/images/arm64/virt-v8/cmdlist
  # cp -f ./tests/arm64/virt-v8/xscript/one_guest_virt-v8.xscript ./build/disk/boot.xscript
  # cp -f <linux_build_directory>/arch/arm64/boot/Image ./build/disk/images/arm64/virt-v8/Image
  # dtc -q -I dts -O dtb -o ./build/disk/images/arm64/virt-v8/virt-v8.dtb ./tests/arm64/virt-v8/linux/virt-v8.dts
  # cp -f <busybox_rootfs_directory>/rootfs.img ./build/disk/images/arm64/virt-v8/rootfs.img
  # genext2fs -B 1024 -b 32768 -d ./build/disk ./build/disk.img

  [12. Launch Foundation v8 Model]
  # ${CROSS_COMPILE}gcc -nostdlib -nostdinc -e _start -Wl,--build-id=none -Wl,-Ttext=0x80000000 -DGENTIMER_FREQ=100000000 -DUART_PL011 -DUART_PL011_BASE=0x1c090000 -DGICv2 -DGIC_DIST_BASE=0x2c001000 -DGIC_CPU_BASE=0x2c002000 -DSPIN_LOOP_ADDR=0x8000fff8 -DIMAGE=./build/vmm.bin -DDTB=./build/arch/arm/dts/arm/foundation-v8-gicv2.dtb -DINITRD=./build/disk.img ./docs/arm/foundation_v8_boot.S -o ./build/foundation_v8_boot.axf
  # <foundation_v8_install_directory>/models/Linux64_GCC-<xxxx>/Foundation_Platform --no-gicv3 --no-sve --image ./build/foundation_v8_boot.axf --network=nat

  [13. Kick Guest0 to start Basic Firmware]
  XVisor# guest kick guest0

  [14. Bind to virtual UART]
  XVisor# vserial bind guest0/uart0

  [15. Copy linux from NOR flash to RAM and start linux booting from RAM]
  [guest0/uart0] basic# autoexec
  (Note: "autoexec" is a short-cut command)
  (Note: The <xvisor_source_directory>/tests/arm64/virt-v8/linux/cmdlist file
   which we have added to guest NOR flash contains set of commands for booting
   linux from NOR flash)

  [16. Wait for Linux prompt to come-up and then try out some commands]
  [guest0/uart0] / # ls

  [17. Enter character seqence 'ESCAPE+x+q" return to Xvisor prompt]
  [guest0/uart0] / #

  (Note: replace all <> brackets based on your workspace)
  (Note: some of the above steps will need to be adapted for other
   types of ARM host)
  (Note: for more info on your desired ARM host refer docs/arm/)
  (Note: you are free to change the ordering of above steps based
   on your workspace)
