1 /*
2 * xen/arch/arm/arm32/traps.c
3 *
4 * ARM AArch32 Specific Trap handlers
5 *
6 * Copyright (c) 2012 Citrix Systems.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19 #include <xen/lib.h>
20 #include <xen/kernel.h>
21
22 #include <public/xen.h>
23
24 #include <asm/processor.h>
25
do_trap_undefined_instruction(struct cpu_user_regs * regs)26 void do_trap_undefined_instruction(struct cpu_user_regs *regs)
27 {
28 uint32_t pc = regs->pc;
29 uint32_t instr;
30
31 if ( !is_kernel_text(pc) &&
32 (system_state >= SYS_STATE_active || !is_kernel_inittext(pc)) )
33 goto die;
34
35 /* PC should be always a multiple of 4, as Xen is using ARM instruction set */
36 if ( regs->pc & 0x3 )
37 goto die;
38
39 instr = *((uint32_t *)pc);
40 if ( instr != BUG_OPCODE )
41 goto die;
42
43 if ( do_bug_frame(regs, pc) )
44 goto die;
45
46 regs->pc += 4;
47 return;
48
49 die:
50 do_unexpected_trap("Undefined Instruction", regs);
51 }
52
do_trap_hypervisor_call(struct cpu_user_regs * regs)53 void do_trap_hypervisor_call(struct cpu_user_regs *regs)
54 {
55 do_unexpected_trap("Hypervisor Call", regs);
56 }
57
do_trap_prefetch_abort(struct cpu_user_regs * regs)58 void do_trap_prefetch_abort(struct cpu_user_regs *regs)
59 {
60 do_unexpected_trap("Prefetch Abort", regs);
61 }
62
do_trap_data_abort(struct cpu_user_regs * regs)63 void do_trap_data_abort(struct cpu_user_regs *regs)
64 {
65 /*
66 * We cannot distinguish Xen SErrors from synchronous data aborts. We
67 * want to avoid treating any Xen synchronous aborts as SErrors and
68 * forwarding them to the guest. Instead, crash the system in all
69 * cases when the abort comes from Xen. Even if they are Xen SErrors
70 * it would be a reasonable thing to do, and the default behavior with
71 * serror_op == DIVERSE.
72 */
73 if ( VABORT_GEN_BY_GUEST(regs) )
74 do_trap_guest_serror(regs);
75 else
76 do_unexpected_trap("Data Abort", regs);
77 }
78
79 /*
80 * Local variables:
81 * mode: C
82 * c-file-style: "BSD"
83 * c-basic-offset: 4
84 * indent-tabs-mode: nil
85 * End:
86 */
87