hw_arndale: enable ARM virtualization extensions

* enables world-switch using ARM virtualization extensions
* split TrustZone and virtualization extensions hardly from platforms,
  where it is not used
* extend 'Vm_session' interface to enable configuration of guest-physical memory
* introduce VM destruction syscall
* add virtual machine monitor for hw_arndale that emulates a simplified version
  of ARM's Versatile Express Cortex A15 board for a Linux guest OS

Fixes #1405
This commit is contained in:
Stefan Kalkowski
2015-02-19 14:50:27 +01:00
committed by Christian Helmuth
parent 07c8d1652e
commit 7582396e9c
73 changed files with 3460 additions and 738 deletions

View File

@ -17,6 +17,7 @@
#include <base/thread.h>
#include <drivers/board_base.h>
#include <drivers/trustzone.h>
#include <vm_state.h>
/* local includes */
#include <vm.h>

View File

@ -22,8 +22,8 @@ class Mmu
{
private:
Vm_state *_state;
Ram *_ram;
Genode::Vm_state *_state;
Ram *_ram;
unsigned _n_bits() { return _state->ttbrc & 0x7; }
@ -68,7 +68,7 @@ class Mmu
public:
Mmu(Vm_state *state, Ram *ram)
Mmu(Genode::Vm_state *state, Ram *ram)
: _state(state), _ram(ram) {}

View File

@ -40,7 +40,7 @@ class Vm {
Genode::Dataspace_client _kernel_cap;
Genode::Dataspace_client _initrd_cap;
const char* _cmdline;
Vm_state *_state;
Genode::Vm_state *_state;
Genode::Io_mem_connection _ram_iomem;
Ram _ram;
Genode::addr_t _kernel_offset;
@ -90,7 +90,7 @@ class Vm {
_kernel_cap(_kernel_rom.dataspace()),
_initrd_cap(_initrd_rom.dataspace()),
_cmdline(cmdline),
_state((Vm_state*)Genode::env()->rm_session()->attach(_vm_con.cpu_state())),
_state((Genode::Vm_state*)Genode::env()->rm_session()->attach(_vm_con.cpu_state())),
_ram_iomem(ram_base, ram_size),
_ram(ram_base, ram_size, (Genode::addr_t)Genode::env()->rm_session()->attach(_ram_iomem.dataspace())),
_kernel_offset(kernel_offset),
@ -99,7 +99,7 @@ class Vm {
void start()
{
Genode::memset((void*)_state, 0, sizeof(Vm_state));
Genode::memset((void*)_state, 0, sizeof(Genode::Vm_state));
_load_kernel();
_load_initrd();
_prepare_atag();
@ -161,7 +161,7 @@ class Vm {
_state->ip, va_to_pa(_state->ip));
printf(" cpsr = %08lx\n", _state->cpsr);
for (unsigned i = 0;
i < Vm_state::Mode_state::MAX; i++) {
i < Genode::Vm_state::Mode_state::MAX; i++) {
printf(" sp_%s = %08lx [%08lx]\n", modes[i],
_state->mode[i].sp, va_to_pa(_state->mode[i].sp));
printf(" lr_%s = %08lx [%08lx]\n", modes[i],
@ -186,8 +186,8 @@ class Vm {
return 0;
}
Vm_state *state() const { return _state; }
Ram *ram() { return &_ram; }
Genode::Vm_state *state() const { return _state; }
Ram *ram() { return &_ram; }
};
#endif /* _SRC__SERVER__VMM__INCLUDE__VM_H_ */

View File

@ -1,27 +0,0 @@
/*
* \brief Virtual Machine Monitor VM state definition
* \author Stefan Kalkowski
* \date 2012-06-25
*/
/*
* Copyright (C) 2012-2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _SRC__SERVER__VMM__INCLUDE__VM_STATE_H_
#define _SRC__SERVER__VMM__INCLUDE__VM_STATE_H_
/* Genode includes */
#include <cpu/cpu_state.h>
struct Vm_state : Genode::Cpu_state_modes
{
Genode::addr_t dfar; /* data fault address */
Genode::addr_t ttbr[2]; /* translation table base regs */
Genode::addr_t ttbrc; /* translation table base control */
};
#endif /* _SRC__SERVER__VMM__INCLUDE__VM_STATE_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
TARGET = vmm
REQUIRES = hw_arndale
LIBS = base
SRC_CC = main.cc

View File

@ -0,0 +1,30 @@
.section ".text.crt0"
.global _start
_start:
/* idle a little initially because U-Boot likes it this way */
mov r8, r8
mov r8, r8
mov r8, r8
mov r8, r8
mov r8, r8
mov r8, r8
mov r8, r8
mov r8, r8
/* zero-fill BSS segment */
ldr r0, =_bss_start
ldr r1, =_bss_end
mov r2, #0
1:
cmp r1, r0
ble 2f
str r2, [r0]
add r0, r0, #4
b 1b
2:
hvc #0
1: b 1b

View File

@ -0,0 +1,3 @@
TARGET = test-kernel
REQUIRES = hw_arndale
SRC_S = main.s