From 9a4a0448bed1d71f7cf153632bc0b450c1214e14 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 8 Jan 2015 13:28:42 +0100 Subject: [PATCH] hw vea9x4: remove trustzone support When building Genode for VEA9X4 as micro-hypervisor protected by the ARM TrustZone hardware we ran into limitations regarding our basic daily testing routines. The most significant is that, when speaking about RAM partitioning, the only available options are to configure the whole SRAM to be secure and the whole DDR-RAM to be non-secure or vice versa. The SRAM however provides only 32 MB which isn't enough for both a representative non-secure guest OS or a secure Genode that is still capable of passing our basic tests. This initiated our decision to remove the VEA9X4 TrustZone-support. Fixes #1351 --- .../platform/vea9x4/drivers/trustzone.h | 31 --- .../mk/platform_vea9x4/core-trustzone_off.mk | 19 -- .../mk/platform_vea9x4/core-trustzone_on.mk | 20 -- repos/base-hw/lib/mk/platform_vea9x4/core.mk | 7 +- repos/base-hw/mk/spec-hw_vea9x4_tz.mk | 14 -- .../core/include/spec/vea9x4/trustzone/pic.h | 77 ------- .../src/core/spec/vea9x4/trustzone/pic.cc | 48 ---- .../vea9x4/trustzone/platform_services.cc | 36 --- .../spec/vea9x4/trustzone/platform_support.cc | 94 -------- .../platform/vea9x4/drivers/board_base.h | 8 - repos/os/src/server/tz_vmm/README | 18 +- repos/os/src/server/tz_vmm/vea9x4/bp_147.h | 126 ----------- repos/os/src/server/tz_vmm/vea9x4/main.cc | 211 ------------------ repos/os/src/server/tz_vmm/vea9x4/sp810.h | 41 ---- repos/os/src/server/tz_vmm/vea9x4/sys_reg.h | 100 --------- repos/os/src/server/tz_vmm/vea9x4/target.mk | 5 - repos/os/src/server/tz_vmm/vea9x4/tsc_380.h | 208 ----------------- tool/builddir/etc/build.conf.hw_vea9x4_tz | 1 - tool/create_builddir | 4 - 19 files changed, 9 insertions(+), 1059 deletions(-) delete mode 100644 repos/base-hw/include/platform/vea9x4/drivers/trustzone.h delete mode 100644 repos/base-hw/lib/mk/platform_vea9x4/core-trustzone_off.mk delete mode 100644 repos/base-hw/lib/mk/platform_vea9x4/core-trustzone_on.mk delete mode 100644 repos/base-hw/mk/spec-hw_vea9x4_tz.mk delete mode 100644 repos/base-hw/src/core/include/spec/vea9x4/trustzone/pic.h delete mode 100644 repos/base-hw/src/core/spec/vea9x4/trustzone/pic.cc delete mode 100644 repos/base-hw/src/core/spec/vea9x4/trustzone/platform_services.cc delete mode 100644 repos/base-hw/src/core/spec/vea9x4/trustzone/platform_support.cc delete mode 100644 repos/os/src/server/tz_vmm/vea9x4/bp_147.h delete mode 100644 repos/os/src/server/tz_vmm/vea9x4/main.cc delete mode 100644 repos/os/src/server/tz_vmm/vea9x4/sp810.h delete mode 100644 repos/os/src/server/tz_vmm/vea9x4/sys_reg.h delete mode 100644 repos/os/src/server/tz_vmm/vea9x4/target.mk delete mode 100644 repos/os/src/server/tz_vmm/vea9x4/tsc_380.h delete mode 100644 tool/builddir/etc/build.conf.hw_vea9x4_tz diff --git a/repos/base-hw/include/platform/vea9x4/drivers/trustzone.h b/repos/base-hw/include/platform/vea9x4/drivers/trustzone.h deleted file mode 100644 index e1e824719..000000000 --- a/repos/base-hw/include/platform/vea9x4/drivers/trustzone.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * \brief TrustZone specific definitions for the Versatile Express board - * \author Stefan Kalkowski - * \date 2013-11-15 - */ - -/* - * Copyright (C) 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 _INCLUDE__PLATFORM__VEA9X4__DRIVERS__TRUSTZONE_H_ -#define _INCLUDE__PLATFORM__VEA9X4__DRIVERS__TRUSTZONE_H_ - -/* Genode includes */ -#include - -namespace Trustzone -{ - enum { - SECURE_RAM_BASE = Genode::Board_base::RAM_2_BASE, - SECURE_RAM_SIZE = Genode::Board_base::RAM_2_SIZE, - NONSECURE_RAM_BASE = 0x80000000, - NONSECURE_RAM_SIZE = 0x20000000, - }; -} - -#endif /* _INCLUDE__PLATFORM__VEA9X4__DRIVERS__TRUSTZONE_H_ */ - diff --git a/repos/base-hw/lib/mk/platform_vea9x4/core-trustzone_off.mk b/repos/base-hw/lib/mk/platform_vea9x4/core-trustzone_off.mk deleted file mode 100644 index db40fef34..000000000 --- a/repos/base-hw/lib/mk/platform_vea9x4/core-trustzone_off.mk +++ /dev/null @@ -1,19 +0,0 @@ -# -# \brief Build config for parts of core that depend on Trustzone status -# \author Stefan Kalkowski -# \author Martin Stein -# \date 2012-10-24 -# - -# add include paths -INC_DIR += $(REP_DIR)/src/core/include/spec/vea9x4 -INC_DIR += $(REP_DIR)/src/core/include/spec/cortex_a9 - -# add C++ sources -SRC_CC += platform_services.cc -SRC_CC += spec/vea9x4/platform_support.cc -SRC_CC += spec/cortex_a9/pic.cc -SRC_CC += spec/arm_gic/pic.cc - -# include less specific configuration -include $(REP_DIR)/lib/mk/core-trustzone.inc diff --git a/repos/base-hw/lib/mk/platform_vea9x4/core-trustzone_on.mk b/repos/base-hw/lib/mk/platform_vea9x4/core-trustzone_on.mk deleted file mode 100644 index cbc9722d6..000000000 --- a/repos/base-hw/lib/mk/platform_vea9x4/core-trustzone_on.mk +++ /dev/null @@ -1,20 +0,0 @@ -# -# \brief Build config for parts of core that depend on Trustzone status -# \author Stefan Kalkowski -# \author Martin Stein -# \date 2012-10-24 -# - -# add include paths -INC_DIR += $(REP_DIR)/src/core/vea9x4/trustzone -INC_DIR += $(REP_DIR)/src/core/include/spec/vea9x4 -INC_DIR += $(REP_DIR)/src/core/include/spec/cortex_a9 - -# add C++ sources -SRC_CC += vm_session_component.cc -SRC_CC += spec/vea9x4/trustzone/platform_support.cc -SRC_CC += spec/vea9x4/trustzone/pic.cc -SRC_CC += spec/vea9x4/trustzone/platform_services.cc - -# include less specific configuration -include $(REP_DIR)/lib/mk/core-trustzone.inc diff --git a/repos/base-hw/lib/mk/platform_vea9x4/core.mk b/repos/base-hw/lib/mk/platform_vea9x4/core.mk index 3ad2a5697..1f06b6040 100644 --- a/repos/base-hw/lib/mk/platform_vea9x4/core.mk +++ b/repos/base-hw/lib/mk/platform_vea9x4/core.mk @@ -5,9 +5,6 @@ # \date 2012-10-04 # -# add library dependencies -LIBS += core-trustzone - # add include paths INC_DIR += $(REP_DIR)/src/core/include/spec/vea9x4 INC_DIR += $(REP_DIR)/src/core/include/spec/cortex_a9 @@ -15,6 +12,10 @@ INC_DIR += $(REP_DIR)/src/core/include/spec/pl011 # add C++ sources SRC_CC += cpu.cc +SRC_CC += platform_services.cc +SRC_CC += spec/vea9x4/platform_support.cc +SRC_CC += spec/cortex_a9/pic.cc +SRC_CC += spec/arm_gic/pic.cc # include less specific configuration include $(REP_DIR)/lib/mk/arm_v7/core.inc diff --git a/repos/base-hw/mk/spec-hw_vea9x4_tz.mk b/repos/base-hw/mk/spec-hw_vea9x4_tz.mk deleted file mode 100644 index 7775d68cb..000000000 --- a/repos/base-hw/mk/spec-hw_vea9x4_tz.mk +++ /dev/null @@ -1,14 +0,0 @@ -# -# \brief Offer build configurations that are specific to base-hw and VEA9X4 -# \author Martin Stein -# \date 2011-12-20 -# - -# denote wich specs are also fullfilled by this spec -SPECS += hw_vea9x4 trustzone - -# adjust link address of a trustzone text segment -LD_TEXT_ADDR = 0x48000000 - -# include implied specs -include $(call select_from_repositories,mk/spec-hw_vea9x4.mk) diff --git a/repos/base-hw/src/core/include/spec/vea9x4/trustzone/pic.h b/repos/base-hw/src/core/include/spec/vea9x4/trustzone/pic.h deleted file mode 100644 index caea8d1ca..000000000 --- a/repos/base-hw/src/core/include/spec/vea9x4/trustzone/pic.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * \brief Programmable interrupt controller for core - * \author Martin Stein - * \author Stefan Kalkowski - * \date 2012-04-23 - */ - -/* - * 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 _PIC_H_ -#define _PIC_H_ - -/* core includes */ -#include -#include - -namespace Genode -{ - /** - * Programmable interrupt controller for core - */ - class Pic; -} - -class Genode::Pic : public Arm_gic -{ - public: - - /** - * Constructor - */ - Pic() : Arm_gic(Cpu::PL390_DISTRIBUTOR_MMIO_BASE, - Cpu::PL390_CPU_MMIO_BASE) - { - /* configure every shared peripheral interrupt */ - for (unsigned i = min_spi; i <= _max_interrupt; i++) { - _distr.write(0, i); - _distr.write(0, i); - _distr.write(0xff, i); - } - - /* disable the priority filter */ - _cpui.write(0xff); - - /* signal secure IRQ via FIQ interface */ - Cpui::Ctlr::access_t ctlr = 0; - Cpui::Ctlr::Enable_grp0::set(ctlr, 1); - Cpui::Ctlr::Enable_grp1::set(ctlr, 1); - Cpui::Ctlr::Fiq_en::set(ctlr, 1); - _cpui.write(ctlr); - - /* use whole band of prios */ - _cpui.write(~0); - - /* enable device */ - _distr.write(Distr::Ctlr::Enable::bits(1)); - } - - /** - * Mark interrupt 'i' unsecure - */ - void unsecure(unsigned const i) { - _distr.write(1, i); } -}; - - -bool Genode::Arm_gic::_use_security_ext() { return 1; } - - -namespace Kernel { class Pic : public Genode::Pic { }; } - -#endif /* _PIC_H_ */ diff --git a/repos/base-hw/src/core/spec/vea9x4/trustzone/pic.cc b/repos/base-hw/src/core/spec/vea9x4/trustzone/pic.cc deleted file mode 100644 index 721d9f32a..000000000 --- a/repos/base-hw/src/core/spec/vea9x4/trustzone/pic.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* - * \brief Programmable interrupt controller for core - * \author Stefan Kalkowski - * \author Martin Stein - * \date 2011-10-26 - */ - -/* - * Copyright (C) 2011-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. - */ - -/* core includes */ -#include - -using namespace Genode; - -void Arm_gic::_init() -{ - /* configure every shared peripheral interrupt */ - for (unsigned i = min_spi; i <= _max_irq; i++) { - _distr.write(0, i); - _distr.write(0, i); - _distr.write(~0, i); - } - - /* disable the priority filter */ - _cpui.write(~0); - - /* signal secure IRQ via FIQ interface */ - typedef Cpui::Ctlr Ctlr; - Ctlr::access_t v = 0; - Ctlr::Enable_grp0::set(v, 1); - Ctlr::Enable_grp1::set(v, 1); - Ctlr::Fiq_en::set(v, 1); - _cpui.write(v); - - /* use whole band of prios */ - _cpui.write(~0); - - /* enable device */ - _distr.write(Distr::Ctlr::Enable::bits(1)); -} - -void Pic::unsecure(unsigned const i) { - _distr.write(1, i); } diff --git a/repos/base-hw/src/core/spec/vea9x4/trustzone/platform_services.cc b/repos/base-hw/src/core/spec/vea9x4/trustzone/platform_services.cc deleted file mode 100644 index 3391b0ecc..000000000 --- a/repos/base-hw/src/core/spec/vea9x4/trustzone/platform_services.cc +++ /dev/null @@ -1,36 +0,0 @@ -/* - * \brief Platform specific services for base-hw and VEA9X4 (TrustZone) - * \author Stefan Kalkowski - * \date 2012-10-26 - */ - -/* - * 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. - */ - -/* Genode includes */ -#include -#include - -/* Core includes */ -#include -#include -#include - - -/* - * Add TrustZone specific vm service - */ -void Genode::platform_add_local_services(Genode::Rpc_entrypoint *ep, - Genode::Sliced_heap *sh, - Genode::Service_registry *ls) -{ - using namespace Genode; - - static Vm_root vm_root(ep, sh); - static Local_service vm_ls(Vm_session::service_name(), &vm_root); - ls->insert(&vm_ls); -} diff --git a/repos/base-hw/src/core/spec/vea9x4/trustzone/platform_support.cc b/repos/base-hw/src/core/spec/vea9x4/trustzone/platform_support.cc deleted file mode 100644 index 8a90987a7..000000000 --- a/repos/base-hw/src/core/spec/vea9x4/trustzone/platform_support.cc +++ /dev/null @@ -1,94 +0,0 @@ -/* - * \brief Platform implementations specific for base-hw and VEA9X4 - * \author Martin Stein - * \date 2012-04-27 - */ - -/* - * 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. - */ - -#include - -/* core includes */ -#include -#include -#include -#include -#include -#include - -using namespace Genode; - -/* monitor exception vector address */ -extern int _mon_kernel_entry; - - -void Kernel::init_trustzone(Pic * pic) -{ - /* check for compatibility */ - if (NR_OF_CPUS > 1) { - PERR("trustzone not supported with multiprocessing"); - return; - } - /* set exception vector entry */ - Cpu::mon_exception_entry_at((Genode::addr_t)&_mon_kernel_entry); - - /* enable coprocessor access for TZ VMs */ - Cpu::allow_coprocessor_nonsecure(); - - /* set unsecure IRQs */ - pic->unsecure(35); //Timer 2/3 - pic->unsecure(36); //RTC - pic->unsecure(37); //UART0 - pic->unsecure(41); //MCI0 - pic->unsecure(42); //MCI1 - pic->unsecure(43); //AACI - pic->unsecure(44); //KMI0 - pic->unsecure(45); //KMI1 - pic->unsecure(47); //ETHERNET - pic->unsecure(48); //USB -} - - -Native_region * Platform::_ram_regions(unsigned const i) -{ - static Native_region _regions[] = - { - { Trustzone::SECURE_RAM_BASE, Trustzone::SECURE_RAM_SIZE }, - }; - return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0; -} - - -Native_region * Platform::_mmio_regions(unsigned const i) -{ - static Native_region _regions[] = - { - { Board::MMIO_0_BASE, Board::MMIO_0_SIZE }, - { Board::MMIO_1_BASE, Board::MMIO_1_SIZE }, - { Trustzone::NONSECURE_RAM_BASE, Trustzone::NONSECURE_RAM_SIZE }, - }; - return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0; -} - - -Native_region * Platform::_core_only_mmio_regions(unsigned const i) -{ - static Native_region _regions[] = - { - /* Core timer and PIC */ - { Board::CORTEX_A9_PRIVATE_MEM_BASE, - Board::CORTEX_A9_PRIVATE_MEM_SIZE }, - - /* Core UART */ - { Board::PL011_0_MMIO_BASE, Board::PL011_0_MMIO_SIZE }, - }; - return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0; -} - - -Cpu::User_context::User_context() { cpsr = Psr::init_user_with_trustzone(); } diff --git a/repos/base/include/platform/vea9x4/drivers/board_base.h b/repos/base/include/platform/vea9x4/drivers/board_base.h index a82752cf8..f979319ca 100644 --- a/repos/base/include/platform/vea9x4/drivers/board_base.h +++ b/repos/base/include/platform/vea9x4/drivers/board_base.h @@ -65,14 +65,6 @@ namespace Genode PL180_0_IRQ = 9, PL180_1_IRQ = 10, - /* TrustZone Address Space Controller */ - TZASC_MMIO_BASE = 0x100ec000, - TZASC_MMIO_SIZE = 0x1000, - - /* TrustZone Protection Controller */ - TZPC_MMIO_BASE = 0x100e6000, - TZPC_MMIO_SIZE = 0x1000, - /* CPU */ CORTEX_A9_PRIVATE_MEM_BASE = 0x1e000000, CORTEX_A9_PRIVATE_MEM_SIZE = 0x2000, diff --git a/repos/os/src/server/tz_vmm/README b/repos/os/src/server/tz_vmm/README index 6afb8fc34..15e11a9fa 100644 --- a/repos/os/src/server/tz_vmm/README +++ b/repos/os/src/server/tz_vmm/README @@ -1,17 +1,9 @@ This is a small example virtual machine monitor, that uses the base-hw kernel -as TrustZone micro-hypervisor on the ARM Versatile Express CT A9x4 platform. -The VMM configures TrustZone Protection Controller and Address Space Controller -in a way, that allows a guest to access nearly all devices, and the DDR-RAM. -Only few resources needed by the kernel (timer, SRAM) aren't accessable by the -virtual-machine. +as secure-world micro-hypervisor on ARM TrustZone platforms. The VMM +configures TrustZone hardware in a way, that allows a guest to access nearly +all devices, and the DDR-RAM. Only few resources needed by the kernel (timer, +SRAM) aren't accessable by the virtual-machine. Moreover, the VMM prepares the guest memory with a Linux image, and ramdisk, and boots it. For the Linux guest to work properly a small patch, and tweaked -configuration is needed. Please checkout the following branch to test it: - - https://github.com/skalk/linux/tree/vexpress-tz - -To build linux do: - -! make ARCH=arm CROSS_COMPILE= vexpress_tz_defconfig -! make ARCH=arm CROSS_COMPILE= \ No newline at end of file +configuration is needed. diff --git a/repos/os/src/server/tz_vmm/vea9x4/bp_147.h b/repos/os/src/server/tz_vmm/vea9x4/bp_147.h deleted file mode 100644 index c10274b42..000000000 --- a/repos/os/src/server/tz_vmm/vea9x4/bp_147.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * \brief Driver for the Trustzone Protection Controller BP147 - * \author Stefan Kalkowski - * \date 2012-07-04 - */ - -/* - * Copyright (C) 2012 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 _BASE_HW__SRC__SERVER__VMM__BP_147_H_ -#define _BASE_HW__SRC__SERVER__VMM__BP_147_H_ - -/* Genode includes */ -#include - -class Bp_147 : Genode::Mmio -{ - private: - - /** - * Secure RAM Region Size Register - */ - struct Tzpcr0size : public Register<0x00, 32> - { - struct R0size : Bitfield<0,10> { }; - }; - - /** - * Decode Protection 0 Registers - */ - template - struct Tzpcdecprot0 : public Register - { - struct Pl341_apb : Register::template Bitfield<0,1> {}; - struct Pl354_apb : Register::template Bitfield<1,1> {}; - struct Scc : Register::template Bitfield<2,1> {}; - struct Dual_timer : Register::template Bitfield<4,1> {}; - struct Watchdog : Register::template Bitfield<5,1> {}; - struct Tzpc : Register::template Bitfield<6,1> {}; - struct Pl351_apb : Register::template Bitfield<7,1> {}; - struct Fast_pl301_apb : Register::template Bitfield<9,1> {}; - struct Slow_pl301_apb : Register::template Bitfield<10,1> {}; - struct Dmc_tzasc : Register::template Bitfield<12,1> {}; - struct Nmc_tzasc : Register::template Bitfield<12,1> {}; - struct Smc_tzasc : Register::template Bitfield<13,1> {}; - struct Debug_apb_phs : Register::template Bitfield<14,1> {}; - }; - - /** - * Decode Protection 1 Registers - */ - template - struct Tzpcdecprot1 : public Register - { - struct External_axi_slave_port - : Register::template Bitfield<0,1> {}; - /* SMC access */ - struct Pl354_axi - : Register::template Bitfield<1,1> {}; - struct Pl351_axi - : Register::template Bitfield<2,1> {}; - struct Entire_apb - : Register::template Bitfield<3,1> {}; - struct Pl111_configuration_port - : Register::template Bitfield<4,1> {}; - struct Axi_ram - : Register::template Bitfield<5,1> {}; - /* DDR RAM access */ - struct Pl341_axi - : Register::template Bitfield<6,1> {}; - /* ACP access */ - struct Cortexa9_coherency_port - : Register::template Bitfield<8,1> {}; - struct Entire_slow_axi_system - : Register::template Bitfield<9,1> {}; - }; - - /** - * Decode Protection 2 Registers - */ - template - struct Tzpcdecprot2 : public Register - { - struct External_master_tz : Register::template Bitfield<0,1> {}; - struct Dap_tz_override : Register::template Bitfield<1,1> {}; - struct Pl111_master_tz : Register::template Bitfield<2,1> {}; - struct Dmc_tzasc_lockdown : Register::template Bitfield<3,1> {}; - struct Nmc_tzasc_lockdown : Register::template Bitfield<4,1> {}; - struct Smc_tzasc_lockdown : Register::template Bitfield<5,1> {}; - }; - - struct Tzpcdecprot0stat : Tzpcdecprot0<0x800> {}; - struct Tzpcdecprot0set : Tzpcdecprot0<0x804> {}; - struct Tzpcdecprot0clr : Tzpcdecprot0<0x808> {}; - struct Tzpcdecprot1stat : Tzpcdecprot1<0x80c> {}; - struct Tzpcdecprot1set : Tzpcdecprot1<0x810> {}; - struct Tzpcdecprot1clr : Tzpcdecprot1<0x814> {}; - struct Tzpcdecprot2stat : Tzpcdecprot2<0x818> {}; - struct Tzpcdecprot2set : Tzpcdecprot2<0x81c> {}; - struct Tzpcdecprot2clr : Tzpcdecprot2<0x820> {}; - - public: - - Bp_147(Genode::addr_t const base) : Genode::Mmio(base) - { - /** - * Configure TZPC to allow non-secure AXI signals to - * Static Memory Controller (SMC), - * Dynamic Memory Controller (DMC), - * Accelerator Coherency Port (ACP), and - * PL111 configuration registers - */ - write( - Tzpcdecprot1set::Pl341_axi::bits(1) | - Tzpcdecprot1set::Pl354_axi::bits(1) | - Tzpcdecprot1set::Cortexa9_coherency_port::bits(1) | - Tzpcdecprot1set::Pl111_configuration_port::bits(1)); - } - -}; - -#endif /* _BASE_HW__SRC__SERVER__VMM__BP_147_H_ */ diff --git a/repos/os/src/server/tz_vmm/vea9x4/main.cc b/repos/os/src/server/tz_vmm/vea9x4/main.cc deleted file mode 100644 index 2aefddd81..000000000 --- a/repos/os/src/server/tz_vmm/vea9x4/main.cc +++ /dev/null @@ -1,211 +0,0 @@ -/* - * \brief Virtual Machine Monitor - * \author Stefan Kalkowski - * \date 2012-06-25 - */ - -/* - * Copyright (C) 2008-2012 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. - */ - -/* Genode includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* local includes */ -#include -#include -#include -#include -#include - -using namespace Genode; - -namespace Vmm { - class Vmm; -} - -class Vmm::Vmm : public Thread<8192> -{ - private: - - enum Hypervisor_calls { - SP810_ENABLE = 1, - CPU_ID, - SYS_COUNTER, - MISC_FLAGS, - SYS_CTRL, - MCI_STATUS - }; - - Io_mem_connection _tsc_io_mem; - Io_mem_connection _tpc_io_mem; - Io_mem_connection _sys_io_mem; - Io_mem_connection _sp810_io_mem; - - Tsc_380 _tsc; - Bp_147 _tpc; - Sys_reg _sys; - Sp810 _sp810; - - Vm *_vm; - - void _sys_ctrl() - { - enum { - OSC1 = 0xc0110001, - DVI_SRC = 0xc0710000, - DVI_MODE = 0xc0b00000 - }; - - uint32_t ctrl = _vm->state()->r2; - uint32_t data = _vm->state()->r0; - - switch(ctrl) { - case OSC1: - _sys.osc1(data); - break; - case DVI_SRC: - _sys.dvi_source(data); - break; - case DVI_MODE: - _sys.dvi_mode(data); - break; - default: - PWRN("Access violation to sys configuration ctrl=%ux", ctrl); - _vm->dump(); - } - } - - void _handle_hypervisor_call() - { - switch (_vm->state()->r1) { - case SP810_ENABLE: - _sp810.enable_timer0(); - _sp810.enable_timer1(); - break; - case CPU_ID: - _vm->state()->r0 = 0x0c000191; // Coretile A9 ID - break; - case SYS_COUNTER: - _vm->state()->r0 = _sys.counter(); - break; - case MISC_FLAGS: - _vm->state()->r0 = _sys.misc_flags(); - break; - case SYS_CTRL: - _sys_ctrl(); - break; - case MCI_STATUS: - _vm->state()->r0 = _sys.mci_status(); - break; - default: - PERR("Unknown hypervisor call!"); - _vm->dump(); - } - } - - bool _handle_data_abort() - { - PWRN("Vm tried to access %p which isn't allowed", - _tsc.last_failed_access()); - _vm->dump(); - return false; - } - - bool _handle_vm() - { - switch (_vm->state()->cpu_exception) { - case Cpu_state::DATA_ABORT: - if (!_handle_data_abort()) { - PERR("Could not handle data-abort will exit!"); - return false; - } - break; - case Cpu_state::SUPERVISOR_CALL: - _handle_hypervisor_call(); - break; - default: - PERR("Curious exception occured"); - _vm->dump(); - return false; - } - return true; - } - - protected: - - void entry() - { - Signal_receiver sig_rcv; - Signal_context sig_cxt; - Signal_context_capability sig_cap(sig_rcv.manage(&sig_cxt)); - _vm->sig_handler(sig_cap); - _vm->start(); - - while (true) { - _vm->run(); - Signal s = sig_rcv.wait_for_signal(); - if (s.context() != &sig_cxt) { - PWRN("Invalid context"); - continue; - } - if (!_handle_vm()) - return; - } - }; - - public: - - Vmm(addr_t tsc_base, addr_t tpc_base, - addr_t sys_base, addr_t sp810_base, - Vm *vm) - : Thread<8192>("vmm"), - _tsc_io_mem(tsc_base, 0x1000), - _tpc_io_mem(tpc_base, 0x1000), - _sys_io_mem(sys_base, 0x1000), - _sp810_io_mem(sp810_base, 0x1000), - _tsc((addr_t)env()->rm_session()->attach(_tsc_io_mem.dataspace())), - _tpc((addr_t)env()->rm_session()->attach(_tpc_io_mem.dataspace())), - _sys((addr_t)env()->rm_session()->attach(_sys_io_mem.dataspace())), - _sp810((addr_t)env()->rm_session()->attach(_sp810_io_mem.dataspace())), - _vm(vm) { } -}; - - -int main() -{ - enum { - SYS_VEA9X4_BASE = 0x10000000, - SP810_VEA9X4_BASE = 0x10001000, - TPC_VEA9X4_BASE = 0x100e6000, - TSC_VEA9X4_BASE = 0x100ec000, - MAIN_MEM_START = Trustzone::NONSECURE_RAM_BASE, - MAIN_MEM_SIZE = Trustzone::NONSECURE_RAM_SIZE, - KERNEL_OFFSET = 0x8000, - MACH_TYPE = 2272, - }; - - static const char* cmdline = "console=ttyAMA0,115200n8 root=/dev/ram0 lpj=1554432"; - static Vm vm("linux", "initrd.gz", cmdline, MAIN_MEM_START, MAIN_MEM_SIZE, - KERNEL_OFFSET, MACH_TYPE); - static Vmm::Vmm vmm(TSC_VEA9X4_BASE, TPC_VEA9X4_BASE, - SYS_VEA9X4_BASE, SP810_VEA9X4_BASE, &vm); - - PINF("Start virtual machine"); - vmm.start(); - - sleep_forever(); - return 0; -} diff --git a/repos/os/src/server/tz_vmm/vea9x4/sp810.h b/repos/os/src/server/tz_vmm/vea9x4/sp810.h deleted file mode 100644 index 6469332c1..000000000 --- a/repos/os/src/server/tz_vmm/vea9x4/sp810.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * \brief Driver for the SP810 system controller - * \author Stefan Kalkowski - * \date 2012-09-21 - */ - -/* - * Copyright (C) 2012 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 _BASE_HW__SRC__SERVER__VMM__810_H_ -#define _BASE_HW__SRC__SERVER__VMM__810_H_ - -/* Genode includes */ -#include - -class Sp810 : Genode::Mmio -{ - private: - - struct Ctrl : public Register<0, 32> - { - struct Timer0_enable : Bitfield<15,1> {}; - struct Timer1_enable : Bitfield<17,1> {}; - }; - - public: - - Sp810(Genode::addr_t const base) : Genode::Mmio(base) {} - - bool timer0() { return read(); } - bool timer1() { return read(); } - - void enable_timer0() { write(1); } - void enable_timer1() { write(1); } -}; - -#endif /* _BASE_HW__SRC__SERVER__VMM__SP810_H_ */ diff --git a/repos/os/src/server/tz_vmm/vea9x4/sys_reg.h b/repos/os/src/server/tz_vmm/vea9x4/sys_reg.h deleted file mode 100644 index c4102fae6..000000000 --- a/repos/os/src/server/tz_vmm/vea9x4/sys_reg.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * \brief Driver for the Motherboard Express system registers - * \author Stefan Kalkowski - * \date 2012-09-21 - */ - -/* - * Copyright (C) 2012 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 _BASE_HW__SRC__SERVER__VMM__SYS_REG_H_ -#define _BASE_HW__SRC__SERVER__VMM__SYS_REG_H_ - -/* Genode includes */ -#include - -class Sys_reg : Genode::Mmio -{ - private: - - struct Sys_mci : public Register<0x48, 32> {}; - - struct Sys_24mhz : public Register<0x5c, 32> {}; - - struct Sys_misc : public Register<0x60, 32> {}; - - struct Sys_cfg_data : public Register<0xa0, 32, true> {}; - - struct Sys_cfg_ctrl : public Register<0xa4, 32, true> - { - struct Device : Bitfield<0,12> { }; - struct Position : Bitfield<12,4> { }; - struct Site : Bitfield<16,2> { }; - struct Function : Bitfield<20,6> { }; - struct Write : Bitfield<30,1> { }; - struct Start : Bitfield<31,1> { }; - }; - - struct Sys_cfg_stat : public Register<0xa8, 32> - { - struct Complete : Bitfield<0,1> { }; - struct Error : Bitfield<1,1> { }; - }; - - public: - - Sys_reg(Genode::addr_t const base) : Genode::Mmio(base) {} - - Genode::uint32_t counter() { return read(); } - - Genode::uint32_t misc_flags() { return read(); } - - void osc1(Genode::uint32_t mhz) - { - write(0); - write(mhz); - write(Sys_cfg_ctrl::Device::bits(1) | - Sys_cfg_ctrl::Site::bits(1) | - Sys_cfg_ctrl::Function::bits(1) | - Sys_cfg_ctrl::Write::bits(1) | - Sys_cfg_ctrl::Start::bits(1)); - while (!read()) ; - } - - void dvi_source(Genode::uint32_t site) - { - if (site > 2) { - PERR("Invalid site value %u ignored", site); - return; - } - write(0); - write(site); - write(Sys_cfg_ctrl::Site::bits(1) | - Sys_cfg_ctrl::Function::bits(0x7) | - Sys_cfg_ctrl::Write::bits(1) | - Sys_cfg_ctrl::Start::bits(1)); - while (!read()) ; - } - - void dvi_mode(Genode::uint32_t mode) - { - if (mode > 4) { - PERR("Invalid dvi mode %u ignored", mode); - return; - } - write(0); - write(mode); - write(Sys_cfg_ctrl::Function::bits(0xb) | - Sys_cfg_ctrl::Write::bits(1) | - Sys_cfg_ctrl::Start::bits(1)); - while (!read()) ; - } - - Genode::uint32_t mci_status() { return read(); } -}; - -#endif /* _BASE_HW__SRC__SERVER__VMM__SYS_REG_H_ */ diff --git a/repos/os/src/server/tz_vmm/vea9x4/target.mk b/repos/os/src/server/tz_vmm/vea9x4/target.mk deleted file mode 100644 index 71ea3d341..000000000 --- a/repos/os/src/server/tz_vmm/vea9x4/target.mk +++ /dev/null @@ -1,5 +0,0 @@ -TARGET = tz_vmm -REQUIRES = trustzone platform_vea9x4 -LIBS = base -SRC_CC = main.cc -INC_DIR += $(PRG_DIR) $(PRG_DIR)/../include diff --git a/repos/os/src/server/tz_vmm/vea9x4/tsc_380.h b/repos/os/src/server/tz_vmm/vea9x4/tsc_380.h deleted file mode 100644 index 8b321b4c8..000000000 --- a/repos/os/src/server/tz_vmm/vea9x4/tsc_380.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - * \brief Driver for the CoreLink Trustzone Address Space Controller TSC-380 - * \author Stefan Kalkowski - * \date 2012-07-04 - */ - -/* - * Copyright (C) 2012 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 _BASE_HW__SRC__SERVER__VMM__TSC_380_H_ -#define _BASE_HW__SRC__SERVER__VMM__TSC_380_H_ - -/* Genode includes */ -#include - -class Tsc_380 : Genode::Mmio -{ - private: - - enum { - REGION0_REG_OFF = 0x100, - REGION1_REG_OFF = 0x110, - REGION2_REG_OFF = 0x120, - REGION3_REG_OFF = 0x130, - REGION4_REG_OFF = 0x140, - REGION5_REG_OFF = 0x150, - REGION6_REG_OFF = 0x160, - REGION7_REG_OFF = 0x170, - REGION8_REG_OFF = 0x180, - REGION9_REG_OFF = 0x190, - REGION10_REG_OFF = 0x1a0, - REGION11_REG_OFF = 0x1b0, - REGION12_REG_OFF = 0x1c0, - REGION13_REG_OFF = 0x1d0, - REGION14_REG_OFF = 0x1e0, - REGION15_REG_OFF = 0x1f0, - - REGION_LOW_OFF = 0x0, - REGION_HIGH_OFF = 0x4, - REGION_ATTR_OFF = 0x8, - }; - - /** - * Configuration register - */ - struct Config : public Register<0, 32> - { - struct Region_number : Bitfield<0,4> { }; - struct Address_width : Bitfield<8,6> { }; - }; - - struct Irq_status : public Register<0x10, 32> - { - struct Status : Bitfield<0,1> {}; - struct Overrun : Bitfield<1,1> {}; - }; - - struct Irq_clear : public Register<0x14, 32> - { - struct Status : Bitfield<0,1> {}; - struct Overrun : Bitfield<1,1> {}; - }; - - /** - * Fail address low register - */ - struct Fail_low : public Register<0x20, 32> { }; - - template - struct Region_low : public Register - { - enum { MASK = ~0UL << 15 }; - }; - - template - struct Region_high : public Register { }; - - template - struct Region_attr : public Register - { - struct Enable : - Register::template Bitfield<0, 1> { }; - struct Size : - Register::template Bitfield<1, 6> - { - enum { - SZ_32K = 14, - SZ_64K, - SZ_128K, - SZ_256K, - SZ_512K, - SZ_1M, - SZ_2M, - SZ_4M, - SZ_8M, - SZ_16M, - SZ_32M, - SZ_64M, - SZ_128M, - SZ_256M, - SZ_512M, - SZ_1G, - }; - }; - struct Subreg0 : - Register::template Bitfield<8, 1> { }; - struct Subreg1 : - Register::template Bitfield<9, 1> { }; - struct Subreg2 : - Register::template Bitfield<10, 1> { }; - struct Subreg3 : - Register::template Bitfield<11, 1> { }; - struct Subreg4 : - Register::template Bitfield<12, 1> { }; - struct Subreg5 : - Register::template Bitfield<13, 1> { }; - struct Subreg6 : - Register::template Bitfield<14, 1> { }; - struct Subreg7 : - Register::template Bitfield<15, 1> { }; - struct Normal_write : - Register::template Bitfield<28, 1> { }; - struct Normal_read : - Register::template Bitfield<29, 1> { }; - struct Secure_write : - Register::template Bitfield<30, 1> { }; - struct Secure_read : - Register::template Bitfield<31, 1> { }; - }; - - typedef Region_low<0x100> Region0_low; - - public: - - Tsc_380(Genode::addr_t const base) : Genode::Mmio(base) - { - /* Access to AACI, MMCI, KMI0/1 */ - write >(0x10000000); - write >(0x10008000); - write::Enable>(1); - write::Size>(Region_attr::Size::SZ_32K); - write::Normal_read>(1); - write::Normal_write>(1); - write::Secure_read>(1); - write::Secure_write>(1); - write::Subreg0>(1); - write::Subreg1>(1); - write::Subreg2>(1); - write::Subreg3>(1); - - /* Access to UART0, and WDT */ - write >(0x10008000); - write >(0x10010000); - write::Enable>(1); - write::Size>(Region_attr::Size::SZ_32K); - write::Normal_read>(1); - write::Normal_write>(1); - write::Secure_read>(1); - write::Secure_write>(1); - write::Subreg0>(1); - write::Subreg2>(1); - write::Subreg3>(1); - write::Subreg4>(1); - write::Subreg5>(1); - write::Subreg6>(1); - - /* Access to SP804 2/3, and RTC */ - write >(0x10010000); - write >(0x10018000); - write::Enable>(1); - write::Size>(Region_attr::Size::SZ_32K); - write::Normal_read>(1); - write::Normal_write>(1); - write::Secure_read>(1); - write::Secure_write>(1); - write::Subreg0>(1); - write::Subreg1>(1); - write::Subreg3>(1); - write::Subreg4>(1); - write::Subreg5>(1); - write::Subreg6>(1); - - /* Access to Ethernet and USB */ - write >(0x4e000000); - write >(0x50000000); - write::Enable>(1); - write::Size>(Region_attr::Size::SZ_32M); - write::Normal_read>(1); - write::Normal_write>(1); - write::Secure_read>(1); - write::Secure_write>(1); - - /* clear interrupts */ - write(0x3); - } - - void* last_failed_access() { - void *ret = (void*) read(); - write(0x3); - return ret; - } -}; - -#endif /* _BASE_HW__SRC__SERVER__VMM__TSC_380_H_ */ diff --git a/tool/builddir/etc/build.conf.hw_vea9x4_tz b/tool/builddir/etc/build.conf.hw_vea9x4_tz deleted file mode 100644 index bcc258b3d..000000000 --- a/tool/builddir/etc/build.conf.hw_vea9x4_tz +++ /dev/null @@ -1 +0,0 @@ -REPOSITORIES += $(GENODE_DIR)/repos/base-hw diff --git a/tool/create_builddir b/tool/create_builddir index 091a9b9b5..52a2c6f56 100755 --- a/tool/create_builddir +++ b/tool/create_builddir @@ -29,7 +29,6 @@ usage: @echo " 'codezero_vpb926'" @echo " 'hw_panda'" @echo " 'hw_vea9x4'" - @echo " 'hw_vea9x4_tz'" @echo " 'hw_pbxa9'" @echo " 'hw_imx31'" @echo " 'hw_imx53'" @@ -216,9 +215,6 @@ hw_pbxa9:: hw_vea9x4:: @echo "SPECS = genode hw_vea9x4" > $(BUILD_DIR)/etc/specs.conf -hw_vea9x4_tz:: - @echo "SPECS = genode hw_vea9x4_tz" > $(BUILD_DIR)/etc/specs.conf - hw_panda:: @echo "SPECS = genode hw_panda" > $(BUILD_DIR)/etc/specs.conf