		Linux-3.0.4 on VExpress Cortex-A9 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

The Linux-3.0.4 version of Linux already contains a support for Realivew
PB-A8 Board. We can use this kernel unmodified to run it as a xvisor guest.
We have provided a patch for linux-3.0.4 kernel but that is for disabling
devices (which we don't emulate in xvisor) and for supportting early printk.
We have also provided a VExpress Cortex-A9 defconfig for linux-3.0.4 kernel
for ease in building kernel. To obtain Linux-3.0.4 sources visit the 
following site: http://www.kernel.org

Please follow the steps below to build & run Linux-3.0.4 kernel with
Busybox-1.19.2 RootFS on VExpress Cortex-A9 Guest with Xvisor running on QEMU 
VExpress Cortex-A9 Host:

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

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

  [3. Configure Xvisor with VExpress Cortex-A9 default settings]
  # make ARCH=arm vexpress-a9-defconfig 

  [4. Enable VExpress-A9 Guest from menuconfig]
  # make menuconfig
  SELECT '1x vexpress-a9 guest' DTS from 'Versatile Express Cortex-A9 Options'

  [5. Build Xvisor]
  # make

  [6. Build Basic Test Code]
  # make -C tests/arm32/vexpress-a9/basic

  [7. Copy patch to Linux-3.0.4 source directory]
  # cp tests/arm32/vexpress-a9/linux-3.0.4/linux-3.0.4_vexpress_a9.patch <linux-3.0.4_source_directory>

  [8. Copy defconfig to Linux-3.0.4 build directory]
  # cp tests/arm32/vexpress-a9/linux-3.0.4/linux-3.0.4_vexpress_a9_defconfig <linux-3.0.4_build_directory>/.config

  [9. Copy defconfig to Busybox-1.19.2 source directory]
  # cp tests/arm32/vexpress-a9/linux-3.0.4/busybox-1.19.2_defconfig <busybox-1.19.2_source_directory>/.config

  [10. GoTo Linux-3.0.4 source directory]
  # cd <linux-3.0.4_source_directory>

  [11. Patch Linux-3.0.4 source]
  # patch -p1 < ./linux-3.0.4_vexpress_a9.patch

  [12. Configure Linux-3.0.4 in build directory]
  # make O=<linux-3.0.4_build_directory> ARCH=arm oldconfig

  [13. Build Linux-3.0.4 in build directory]
  # make O=<linux-3.0.4_build_directory> ARCH=arm zImage

  [14. Patch Linux-3.0.4 kernel to replace sensitive non-priviledged instructions]
  # <xvisor_source_directory>/arch/arm/cpu/arm32/elf2cpatch.py -f <linux-3.0.4_build_directory>/vmlinux .text.head .init .text | <xvisor_source_directory>/build/tools/cpatch/cpatch32 <linux-3.0.4_build_directory>/vmlinux 0

  [15. Build Linux-3.0.4 in build directory to reflect changes in kernel image]
  # make O=<linux-3.0.4_build_directory> ARCH=arm zImage

  [16. Patch Linux-3.0.4 compressed kernel to replace sensitive non-priviledged instructions]
  # <xvisor_source_directory>/arch/arm/cpu/arm32/elf2cpatch.py -f <linux-3.0.4_build_directory>/arch/arm/boot/compressed/vmlinux .text.head .init .text | <xvisor_source_directory>/build/tools/cpatch/cpatch32 <linux-3.0.4_build_directory>/arch/arm/boot/compressed/vmlinux 0

  [17. Create final compressed kernel image]
  # ${CROSS_COMPILE}objcopy -O binary <linux-3.0.4_build_directory>/arch/arm/boot/compressed/vmlinux <linux-3.0.4_build_directory>/arch/arm/boot/zImage

  [18. GoTo Busybox-1.19.2 source directory]
  # cd <busybox-1.19.2_source_directory>

  [19. Configure Busybox-1.19.2 source]
  # make oldconfig

  [20. Build Busybox-1.19.2 RootFS]
  # make install

  [21. Change ownership of installed RootFS]
  # sudo chown -R root:root ./_install

  [22. Create RootFS image]
  # fakeroot /bin/bash -c "genext2fs -b 3096 -N 1024 -D <xvisor_source_directory>/tests/arm32/vexpress-a9/linux-3.0.4/busybox-1.19.2_dev.txt -d ./_install <linux-3.0.4_build_directory>/rootfs.img"

  [23. GoTo Linux-3.0.4 build directory]
  # cd <linux-3.0.4_build_directory>

  [24. Create xvisor_linux-3.0.4_qemu.img for running it on QEMU]
  # <xvisor_source_directory>/tools/scripts/memimg.py -a 0x60010000 -o xvisor_linux-3.0.4_qemu.img <xvisor_source_directory>/build/vmm.bin@0x60010000 <xvisor_source_directory>/build/tests/arm32/vexpress-a9/basic/arm_test.bin.patched@0x60800000 ./arch/arm/boot/zImage@0x60900000 ./rootfs.img@0x60C00000

  [25. Launch QEMU 0.14.xx or higher]
  # qemu-system-arm -M vexpress-a9 -display none -serial stdio -kernel ./xvisor_linux-3.0.4_qemu.img

  [26. Kick Guest0 for starting Basic Test]
  XVisor# guest kick 0

  [27. Bind to virtual UART0 of Linux Guest]
  XVisor# vserial bind guest0/uart0

  [28. Copy linux from NOR flash to RAM and start linux booting from RAM]
  [guest0/uart0] arm-test# copy 0x60400000 0x40100000 0x300000
  (Note: This command will copy zImage to RAM)
  [guest0/uart0] arm-test# copy 0x61000000 0x40400000 0x400000
  (Note: This command will copy rootfs.img to RAM)
  [guest0/uart0] arm-test# start_linux 0x60400000 0x61000000 0x400000
  (Note: This command will start linux booting)
  OR
  [guest0/uart0] arm-test# nor_boot
  (Note: "nor_boot" is a short-cut command)

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

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

  (Note: replace all <> brackets based on your workspace)
  (Note: the above steps assumes Xvisor running on VExpress Cortex-A9 host 
   emulated by QEMU 0.14.xx or higher. For other types of ARM host some of the 
   above steps will need to be adapted for that specfic ARM host. For more info
   on your desired ARM host refer docs/arm/)
  (Note: you are free to change ordering of above step based on your workspace)


