.. _partition_mode: Using partition mode on UP2 ########################### ACRN hypervisor supports partition mode, in which the User OS running in a privileged VM can bypass the ACRN hypervisor and directly access isolated PCI devices. This tutorial provides step by step instructions on how to set up the ACRN hypervisor partition mode on `UP2 `_ boards running two privileged VMs as shown in :numref:`two-priv-vms`: .. figure:: images/partition_mode_up2.png :align: center :name: two-priv-vms Two privileged VMs running in partition mode Prerequisites ************* In this tutorial two Linux privileged VMs are started by the ACRN hypervisor. To set up the Linux root filesystems for each VM, follow the Clear Linux OS `bare metal installation guide `_ to install Clear Linux OS on a **SATA disk** and a **USB flash disk** prior the setup, as the two privileged VMs will mount the root filesystems via the SATA controller and the USB controller respectively. Build kernel and modules for partition mode UOS *********************************************** #. On your development workstation, clone the ACRN kernel source tree, and build the Linux kernel image that will be used to boot the privileged VMs: .. code-block:: none $ git clone https://github.com/projectacrn/acrn-kernel.git Cloning into 'acrn-kernel'... ... $ cd acrn-kernel $ cp kernel_config_uos .config $ make olddefconfig scripts/kconfig/conf --olddefconfig Kconfig # # configuration written to .config # $ make $ make modules_install INSTALL_MOD_PATH=out/ The last two commands built the bootable kernel image ``arch/x86/boot/bzImage``, and the loadable kernel modules under the ``./out/`` folder. Copy these files to a removable disk for installing on the UP2 board later. #. Current ACRN partition mode implementation requires a multi-boot capable bootloader to boot both ACRN hypervisor and the bootable kernel image built from the previous step. You could install Ubuntu OS to the UP2 board by following `this Ubuntu tutorial `_. The Ubuntu installer creates 3 disk partitions on the on-board eMMC memory. By default, the GRUB bootloader is installed on the ESP (EFI System Partition) partition, which will be used to bootstrap the partition mode ACRN hypervisor. #. After installing the Ubuntu OS, power off the UP2 board, attach the SATA disk and the USB flash disk to the board. Power on the board and make sure it boots the Ubuntu OS from the eMMC, then copy the loadable kernel modules built in Step 1 to the ``/lib/modules/`` folder on both the mounted SATA disk and USB disk. For example, assuming the SATA disk and USB flash disk are assigned to ``/dev/sda`` and ``/dev/sdb`` respectively, the following commands set up the partition mode loadable kernel modules onto the root filesystems to be loaded by the privileged VMs: .. code-block:: none # Mount the Clear Linux OS root filesystem on the SATA disk $ sudo mount /dev/sda3 /mnt $ sudo cp -r /lib/modules/* /mnt/lib/modules $ sudo umount /mnt # Mount the Clear Linux OS root filesystem on the USB flash disk $ sudo mount /dev/sdb3 /mnt $ sudo cp -r /lib/modules/* /mnt/lib/modules $ sudo umount /mnt #. Copy the bootable kernel image to the ``/boot`` directory: .. code-block:: none $ sudo cp /bzImage /boot/ Enable partition mode in ACRN hypervisor **************************************** #. Before building the ACRN hypervisor, you need to figure out the I/O address of the serial port, and the PCI BAR addresses of the SATA controller and the USB controller on your UP2 board. Enter the following command to get the I/O addresses of the serial ports. UP2 boards support two serial ports. The addresses from the command output represent the I/O addresses of the serial port of the 10-pin side connector and the 40-pin expansion header respectively. You will need to connect the serial port to the development host, in order to access the ACRN serial console to switch between privileged VMs. .. code-block:: none :emphasize-lines: 1 $ sudo lspci | grep UART 00:18.0 . Series HSUART Controller #1 (rev 0b) 00:18.1 . Series HSUART Controller #2 (rev 0b) The second with ``00:18.1`` is the one on the 40-pin expansion connector. The following command prints detailed information about all PCI buses and devices in the system. Look up the PCI BAR addresses of the SATA controller and the USB controller, record these addresses (highlighted below) for editing the source code later. .. code-block:: none :emphasize-lines: 1,9,10,14,22 $ sudo lspci -vv ... 00:12.0 SATA controller: Intel Corporation Device 5ae3 (rev 0b) (prog-if 01 [AHCI 1.0]) Subsystem: Intel Corporation Device 7270 Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+ Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- SERR- TAbort- SERR- ACRN:\>sos_console 1 ----- Entering Guest 1 Shell ----- [ 1.997439] systemd[1]: Listening on Network Service Netlink Socket. [ OK ] Listening on Network Service Netlink Socket. [ 1.999347] systemd[1]: Created slice system-serial\x2dgetty.slice. [ OK ] Created slice system-serial\x2dgetty.slice. [ OK ] Listening on Journal Socket (/dev/log). ... clr-932c8a3012ec4dc6af53790b7afbf6ba login: root Password: root@clr-932c8a3012ec4dc6af53790b7afbf6ba ~ # lspci 00:00.0 Host bridge: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series Host Bridge (rev 0b) 00:01.0 SATA controller: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series SATA AHCI Controller (rev 0b) root@clr-932c8a3012ec4dc6af53790b7afbf6ba ~ # ---Entering ACRN SHELL--- ACRN:\>sos_console 2 ----- Entering Guest 2 Shell ----- [ 1.490122] usb 1-4: new full-speed USB device number 2 using xhci_hcd [ 1.621311] usb 1-4: not running at top speed; connect to a high speed hub [ 1.627824] usb 1-4: New USB device found, idVendor=058f, idProduct=6387, bcdDevice= 1.01 [ 1.628438] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 ... clr-2e8082cd4fc24d57a3c2d3db43368d36 login: root Password: root@clr-2e8082cd4fc24d57a3c2d3db43368d36 ~ # lspci 00:00.0 Host bridge: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series Host Bridge (rev 0b) 00:01.0 USB controller: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series USB xHCI (rev 0b) 00:02.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c) root@clr-2e8082cd4fc24d57a3c2d3db43368d36 ~ #