Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: a new app to demo Virtio and device passthrough #27

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Draft: a new app to demo Virtio and device passthrough
  • Loading branch information
abrandnewusername committed Jul 19, 2022
commit cf4a4e5a2797d2c692a80f7284d0517d6750f913
46 changes: 46 additions & 0 deletions apps/x86/supermicro/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@


#
# Copyright 2022, UNSW (ABN 57 195 873 179)
#
# SPDX-License-Identifier: BSD-2-Clause
#

cmake_minimum_required(VERSION 3.8.2)

project(supermicro)

# Include CAmkES VM helper functions
include(${CAMKES_VM_HELPERS_PATH})
find_package(camkes-vm-linux REQUIRED)
include(${CAMKES_VM_LINUX_HELPERS_PATH})

set(NumberVMs 4)
MATH(EXPR NumberVMsLess1 "${NumberVMs}-1")

# Declare VM component: Init
foreach(i RANGE ${NumberVMsLess1})
file(GLOB "init${i}_extra" "src/cross_vm_connections_vm${i}.c")
DeclareCAmkESVM("Init${i}" EXTRA_SOURCES "${init${i}_extra}")
endforeach()

DeclareCamkesComponent(virtqueueinit)

# Get 32-bit Linux VM files
GetArchDefaultLinuxKernelFile("32" kernel_file)
GetArchDefaultLinuxRootfsFile("32" rootfs_file)

# Decompress Linux Kernel image
DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file})

# Add Linux VM images into file server
AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel)
AddToFileServer("rootfs.cpio" ${rootfs_file})

# Initialise CAmkES Root Server with addition CPP includes
DeclareCAmkESVMRootServer(supermicro.camkes CPP_INCLUDES configurations)

if(SIMULATION)
include(simulation)
GenerateSimulateScript()
endif()
50 changes: 50 additions & 0 deletions apps/x86/supermicro/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
Copyright 2022, UNSW (ABN 57 195 873 179)

SPDX-License-Identifier: BSD-2-Clause
-->

# Multi VM Demo Application
abrandnewusername marked this conversation as resolved.
Show resolved Hide resolved

## Intro(TODO)

## Config

The passthrough device configuration options in `supermicro.camkes` may need to be changed. These include:
- Physical address of the base of the memory-mapped device and I/O ports
- Size of the memory region
- IRQ-related information (PCI, MSI, etc)
- PCI bus/dev/function information of the device

## Build and run the application

The following instructions build the application for x86_64:
```
mkdir build
cd build
../init-build.sh -DCAMKES_VM_APP=supermicro -DPLATFORM=supermicro
ninja
```

## Testing

Some tips for testing the Virtio Net and the passthrough ethernet.

1. Switching the serial port between different VMs: press `Return`, then `@`, then the index number of the VM we want to switch to.

2. Testing the Virtio Net
```
# on vm0
ifconfig eth0 192.168.1.1

# on vm1
ifconfig eth0 192.168.1.2
ping 192.168.1.1
```

3. Setting up the passthrough ethernet
```
# on vm0
ifconfig eth1 up
udhcpc -i eth1
```
21 changes: 21 additions & 0 deletions apps/x86/supermicro/app_settings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright 2022, UNSW (ABN 57 195 873 179)
#
# SPDX-License-Identifier: BSD-2-Clause
#

cmake_minimum_required(VERSION 3.8.2)

# Define kernel config options
set(KernelSel4Arch "x86_64" CACHE STRING "" FORCE)
set(KernelMaxNumNodes 2 CACHE STRING "" FORCE)
set(KernelHugePage OFF CACHE BOOL "" FORCE)
set(KernelMaxNumIOAPIC 5 CACHE STRING "" FORCE)
set(LibPlatSupportX86ConsoleDevice "com2" CACHE STRING "" FORCE)
abrandnewusername marked this conversation as resolved.
Show resolved Hide resolved

ApplyCommonSimulationSettings(${KernelArch})
set(KernelIOMMU ON CACHE BOOL "" FORCE)

# Use AHCI by default
set(SataserverUseAHCI ON CACHE STRING "")
set(CAmkESVMDestHardware "supermicro" CACHE STRING "" FORCE)
31 changes: 31 additions & 0 deletions apps/x86/supermicro/src/cross_vm_connections_0.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <camkes.h>
#include <camkes/dataport_caps.h>

#include <sel4vm/guest_vm.h>
#include <sel4vmmplatsupport/drivers/cross_vm_connection.h>
#include <sel4vmmplatsupport/drivers/pci_helper.h>
#include <crossvm.h>

// these are defined in the dataport's glue code
extern dataport_caps_handle_t dp01_handle;
extern dataport_caps_handle_t dp02_handle;
extern dataport_caps_handle_t dp03_handle;

static struct camkes_crossvm_connection connections[] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment this to show how they work

{&dp01_handle, NULL, {.id = -1, .reg_callback = NULL}},
{&dp02_handle, NULL, {.id = -1, .reg_callback = NULL}},
{&dp03_handle, NULL, {.id = -1, .reg_callback = NULL}}
};

int camkes_cross_vm_connections_init(vm_t *vm, vmm_pci_space_t *pci, seL4_CPtr irq_notification,
uintptr_t connection_base_address)
{
return cross_vm_connections_init(vm, connection_base_address, connections, ARRAY_SIZE(connections), pci,
irq_notification);
}
31 changes: 31 additions & 0 deletions apps/x86/supermicro/src/cross_vm_connections_1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <camkes.h>
#include <camkes/dataport_caps.h>

#include <sel4vm/guest_vm.h>
#include <sel4vmmplatsupport/drivers/cross_vm_connection.h>
#include <sel4vmmplatsupport/drivers/pci_helper.h>
#include <crossvm.h>

// these are defined in the dataport's glue code
extern dataport_caps_handle_t dp10_handle;
extern dataport_caps_handle_t dp12_handle;
extern dataport_caps_handle_t dp13_handle;

static struct camkes_crossvm_connection connections[] = {
{&dp10_handle, NULL, {.id = -1, .reg_callback = NULL}},
{&dp12_handle, NULL, {.id = -1, .reg_callback = NULL}},
{&dp13_handle, NULL, {.id = -1, .reg_callback = NULL}}
};

int camkes_cross_vm_connections_init(vm_t *vm, vmm_pci_space_t *pci, seL4_CPtr irq_notification,
uintptr_t connection_base_address)
{
return cross_vm_connections_init(vm, connection_base_address, connections, ARRAY_SIZE(connections), pci,
irq_notification);
}
31 changes: 31 additions & 0 deletions apps/x86/supermicro/src/cross_vm_connections_2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <camkes.h>
#include <camkes/dataport_caps.h>

#include <sel4vm/guest_vm.h>
#include <sel4vmmplatsupport/drivers/cross_vm_connection.h>
#include <sel4vmmplatsupport/drivers/pci_helper.h>
#include <crossvm.h>

// these are defined in the dataport's glue code
extern dataport_caps_handle_t dp20_handle;
extern dataport_caps_handle_t dp21_handle;
extern dataport_caps_handle_t dp23_handle;

static struct camkes_crossvm_connection connections[] = {
{&dp20_handle, NULL, {.id = -1, .reg_callback = NULL}},
{&dp21_handle, NULL, {.id = -1, .reg_callback = NULL}},
{&dp23_handle, NULL, {.id = -1, .reg_callback = NULL}}
};

int camkes_cross_vm_connections_init(vm_t *vm, vmm_pci_space_t *pci, seL4_CPtr irq_notification,
uintptr_t connection_base_address)
{
return cross_vm_connections_init(vm, connection_base_address, connections, ARRAY_SIZE(connections), pci,
irq_notification);
}
31 changes: 31 additions & 0 deletions apps/x86/supermicro/src/cross_vm_connections_3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <camkes.h>
#include <camkes/dataport_caps.h>

#include <sel4vm/guest_vm.h>
#include <sel4vmmplatsupport/drivers/cross_vm_connection.h>
#include <sel4vmmplatsupport/drivers/pci_helper.h>
#include <crossvm.h>

// these are defined in the dataport's glue code
extern dataport_caps_handle_t dp30_handle;
extern dataport_caps_handle_t dp31_handle;
extern dataport_caps_handle_t dp32_handle;

static struct camkes_crossvm_connection connections[] = {
{&dp30_handle, NULL, {.id = -1, .reg_callback = NULL}},
{&dp31_handle, NULL, {.id = -1, .reg_callback = NULL}},
{&dp32_handle, NULL, {.id = -1, .reg_callback = NULL}}
};

int camkes_cross_vm_connections_init(vm_t *vm, vmm_pci_space_t *pci, seL4_CPtr irq_notification,
uintptr_t connection_base_address)
{
return cross_vm_connections_init(vm, connection_base_address, connections, ARRAY_SIZE(connections), pci,
irq_notification);
}
Loading