2 * Jailhouse, a Linux-based partitioning hypervisor
4 * Copyright (c) ARM Limited, 2014
7 * Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
13 #include <asm/control.h>
14 #include <asm/traps.h>
15 #include <asm/sysregs.h>
16 #include <jailhouse/printk.h>
17 #include <jailhouse/control.h>
19 static int arch_handle_hvc(struct per_cpu *cpu_data, struct trap_context *ctx)
21 unsigned long *regs = ctx->regs;
23 regs[0] = hypercall(regs[0], regs[1], regs[2]);
28 static const trap_handler trap_handlers[38] =
30 [ESR_EC_HVC] = arch_handle_hvc,
33 void arch_handle_trap(struct per_cpu *cpu_data, struct registers *guest_regs)
35 struct trap_context ctx;
37 int ret = TRAP_UNHANDLED;
39 arm_read_banked_reg(SPSR_hyp, ctx.cpsr);
40 arm_read_sysreg(ESR_EL2, ctx.esr);
41 exception_class = ESR_EC(ctx.esr);
42 ctx.regs = guest_regs->usr;
44 if (trap_handlers[exception_class])
45 ret = trap_handlers[exception_class](cpu_data, &ctx);
47 if (ret != TRAP_HANDLED) {
48 panic_printk("CPU%d: Unhandled HYP trap, syndrome 0x%x\n",
49 cpu_data->cpu_id, ctx.esr);