		Linux on Xvisor Virt-v7 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-v7 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-v7 (paravirtualized ARMv7) Guest with Xvisor running on
ARM Fast Models Host:

  [1. Build environment for Xvisor]
  # export CROSS_COMPILE=arm-linux-gnueabi-

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

  [3. Initialize Xvisor submodules]
  # git submodule init
  # git submodule update
  (Note: This is required to be done only once in freshly cloned xvisor source)

  [4. Configure Xvisor with Generic v7-ve default settings]
  # make ARCH=arm generic-v7-ve-defconfig

  [5. Build Xvisor & DTBs]
  # make; make dtbs

  [6. Build Basic Firmware]
  # make -C tests/arm32/virt-v7/basic

  [7. Copy defconfig to Linux build directory]
  # cp tests/arm32/virt-v7/linux/linux-<linux_version>_defconfig <linux_build_directory>/.config

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

  [9. Configure Linux in build directory]
  # make O=<linux_build_directory> ARCH=arm oldconfig

  [10. Build Linux in build directory]
  # make O=<linux_build_directory> ARCH=arm Image dtbs

  [11. 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)

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

  [13. 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/arm32/virt-v7
  # ./build/tools/dtc/bin/dtc -I dts -O dtb -o ./build/disk/images/arm32/virt-v7x2.dtb ./tests/arm32/virt-v7/virt-v7x2.dts
  # cp -f ./build/tests/arm32/virt-v7/basic/firmware.bin ./build/disk/images/arm32/virt-v7/firmware.bin
  # cp -f ./tests/arm32/virt-v7/linux/nor_flash.list ./build/disk/images/arm32/virt-v7/nor_flash.list
  # cp -f ./tests/arm32/virt-v7/linux/cmdlist ./build/disk/images/arm32/virt-v7/cmdlist
  # cp -f <linux_build_directory>/arch/arm/boot/Image ./build/disk/images/arm32/virt-v7/Image
  # ./build/tools/dtc/bin/dtc -I dts -O dtb -o ./build/disk/images/arm32/virt-v7/virt-v7.dtb ./tests/arm32/virt-v7/linux/virt-v7.dts
  # cp -f <busybox_rootfs_directory>/rootfs.img ./build/disk/images/arm32/rootfs.img
  # genext2fs -B 1024 -b 16384 -d ./build/disk ./build/disk.img

  [14. Create fast_model_boot.axf for running it on ARM Fast Models]
  # ${CROSS_COMPILE}gcc -nostdlib -march=armv7ve -mtune=cortex-a15 -e start_boot -Wl,--build-id=none -Wl,-Ttext=0x80000000 -DSPIN_LOCATION=0x1c010030 -DSPIN_LOOP_ADDR=0x14000000 -DUART_PL011 -DUART_PL011_BASE=0x1c090000 -DGENTIMER_FREQ=100000000 -DGICv2 -DGIC_DIST_BASE=0x2c001000 -DGIC_CPU_BASE=0x2c002000 -DIMAGE=build/vmm.bin -DDTB=build/arch/arm/board/generic/dts/vexpress/a15/one_guest_virt-v7.dtb -DINITRD=build/disk.img ./docs/arm/fast_model_boot.S -o build/fast_model_boot.axf

  [15. Launch ARM fast models 8.0 or higher]
  # model_shell <your_fastmodel_dir>/FastModelsPortfolio_<xxxx>/examples/FVP_VE/Build_Cortex-A15x1/Linux-Debug-GCC-<yyyy>/cadi_system_Linux-Debug-GCC-<yyyy>.so build/fast_model_boot.axf
  OR
  # model_shell64 <your_fastmodel_dir>/FastModelsPortfolio_<xxxx>/examples/FVP_VE/Build_Cortex-A15x1/Linux64-Debug-GCC-<yyyy>/cadi_system_Linux64-Debug-GCC-<yyyy>.so build/fast_model_boot.axf

  [16. Kick Guest0 for starting Basic Firmware]
  XVisor# guest kick guest0

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

  [18. 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/arm32/virt-v7/linux/cmdlist file
   which we have added to guest NOR flash contains set of commands for booting
   linux from NOR flash)

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

  [20. 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)
