Lines Matching refs:regs

235 static register_t *select_user_reg(struct cpu_user_regs *regs, int reg)  in select_user_reg()  argument
237 BUG_ON( !guest_mode(regs) ); in select_user_reg()
250 return &regs->r0 + reg; in select_user_reg()
253 if ( fiq_mode(regs) ) in select_user_reg()
254 return &regs->r8_fiq + reg - 8; in select_user_reg()
256 return &regs->r8 + reg - 8; in select_user_reg()
263 switch ( regs->cpsr & PSR_MODE_MASK ) in select_user_reg()
268 return &regs->sp_usr; in select_user_reg()
270 return &regs->lr; in select_user_reg()
272 return &regs->sp_fiq + reg - 13; in select_user_reg()
274 return &regs->sp_irq + reg - 13; in select_user_reg()
276 return &regs->sp_svc + reg - 13; in select_user_reg()
278 return &regs->sp_abt + reg - 13; in select_user_reg()
280 return &regs->sp_und + reg - 13; in select_user_reg()
287 return &regs->pc; in select_user_reg()
298 return &regs->x0 + reg; in select_user_reg()
302 register_t get_user_reg(struct cpu_user_regs *regs, int reg) in get_user_reg() argument
307 return *select_user_reg(regs, reg); in get_user_reg()
310 void set_user_reg(struct cpu_user_regs *regs, int reg, register_t value) in set_user_reg() argument
315 *select_user_reg(regs, reg) = value; in set_user_reg()
405 static void cpsr_switch_mode(struct cpu_user_regs *regs, int mode) in cpsr_switch_mode() argument
409 regs->cpsr &= ~(PSR_MODE_MASK|PSR_IT_MASK|PSR_JAZELLE|PSR_BIG_ENDIAN|PSR_THUMB); in cpsr_switch_mode()
411 regs->cpsr |= mode; in cpsr_switch_mode()
412 regs->cpsr |= PSR_IRQ_MASK; in cpsr_switch_mode()
414 regs->cpsr |= PSR_ABT_MASK; in cpsr_switch_mode()
416 regs->cpsr |= PSR_THUMB; in cpsr_switch_mode()
418 regs->cpsr |= PSR_BIG_ENDIAN; in cpsr_switch_mode()
436 static void inject_undef32_exception(struct cpu_user_regs *regs) in inject_undef32_exception() argument
438 uint32_t spsr = regs->cpsr; in inject_undef32_exception()
439 int is_thumb = (regs->cpsr & PSR_THUMB); in inject_undef32_exception()
446 cpsr_switch_mode(regs, PSR_MODE_UND); in inject_undef32_exception()
449 regs->spsr_und = spsr; in inject_undef32_exception()
450 regs->lr_und = regs->pc32 + return_offset; in inject_undef32_exception()
453 regs->pc32 = exception_handler32(VECTOR32_UND); in inject_undef32_exception()
461 static void inject_abt32_exception(struct cpu_user_regs *regs, in inject_abt32_exception() argument
465 uint32_t spsr = regs->cpsr; in inject_abt32_exception()
466 int is_thumb = (regs->cpsr & PSR_THUMB); in inject_abt32_exception()
473 cpsr_switch_mode(regs, PSR_MODE_ABT); in inject_abt32_exception()
476 regs->spsr_abt = spsr; in inject_abt32_exception()
477 regs->lr_abt = regs->pc32 + return_offset; in inject_abt32_exception()
479 regs->pc32 = exception_handler32(prefetch ? VECTOR32_PABT : VECTOR32_DABT); in inject_abt32_exception()
518 static void inject_dabt32_exception(struct cpu_user_regs *regs, in inject_dabt32_exception() argument
521 inject_abt32_exception(regs, 0, addr); in inject_dabt32_exception()
524 static void inject_pabt32_exception(struct cpu_user_regs *regs, in inject_pabt32_exception() argument
527 inject_abt32_exception(regs, 1, addr); in inject_pabt32_exception()
535 static vaddr_t exception_handler64(struct cpu_user_regs *regs, vaddr_t offset) in exception_handler64() argument
539 if ( usr_mode(regs) ) in exception_handler64()
541 else if ( psr_mode(regs->cpsr,PSR_MODE_EL0t) ) in exception_handler64()
550 void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len) in inject_undef64_exception() argument
561 handler = exception_handler64(regs, VECTOR64_SYNC_OFFSET); in inject_undef64_exception()
563 regs->spsr_el1 = regs->cpsr; in inject_undef64_exception()
564 regs->elr_el1 = regs->pc; in inject_undef64_exception()
566 regs->cpsr = PSR_MODE_EL1h | PSR_ABT_MASK | PSR_FIQ_MASK | \ in inject_undef64_exception()
568 regs->pc = handler; in inject_undef64_exception()
574 static void inject_abt64_exception(struct cpu_user_regs *regs, in inject_abt64_exception() argument
585 if ( psr_mode_is_user(regs) ) in inject_abt64_exception()
594 handler = exception_handler64(regs, VECTOR64_SYNC_OFFSET); in inject_abt64_exception()
596 regs->spsr_el1 = regs->cpsr; in inject_abt64_exception()
597 regs->elr_el1 = regs->pc; in inject_abt64_exception()
599 regs->cpsr = PSR_MODE_EL1h | PSR_ABT_MASK | PSR_FIQ_MASK | \ in inject_abt64_exception()
601 regs->pc = handler; in inject_abt64_exception()
607 static void inject_dabt64_exception(struct cpu_user_regs *regs, in inject_dabt64_exception() argument
611 inject_abt64_exception(regs, 0, addr, instr_len); in inject_dabt64_exception()
614 static void inject_iabt64_exception(struct cpu_user_regs *regs, in inject_iabt64_exception() argument
618 inject_abt64_exception(regs, 1, addr, instr_len); in inject_iabt64_exception()
623 void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr) in inject_undef_exception() argument
626 inject_undef32_exception(regs); in inject_undef_exception()
629 inject_undef64_exception(regs, hsr.len); in inject_undef_exception()
633 static void inject_iabt_exception(struct cpu_user_regs *regs, in inject_iabt_exception() argument
638 inject_pabt32_exception(regs, addr); in inject_iabt_exception()
641 inject_iabt64_exception(regs, addr, instr_len); in inject_iabt_exception()
645 static void inject_dabt_exception(struct cpu_user_regs *regs, in inject_dabt_exception() argument
650 inject_dabt32_exception(regs, addr); in inject_dabt_exception()
653 inject_dabt64_exception(regs, addr, instr_len); in inject_dabt_exception()
658 static void inject_vabt_exception(struct cpu_user_regs *regs) in inject_vabt_exception() argument
660 const union hsr hsr = { .bits = regs->hsr }; in inject_vabt_exception()
677 regs->pc -= hsr.len ? 4 : 2; in inject_vabt_exception()
699 static void __do_trap_serror(struct cpu_user_regs *regs, bool guest) in __do_trap_serror() argument
709 return inject_vabt_exception(regs); in __do_trap_serror()
729 return inject_vabt_exception(regs); in __do_trap_serror()
738 do_unexpected_trap("SError", regs); in __do_trap_serror()
789 static void show_registers_32(struct cpu_user_regs *regs, in show_registers_32() argument
796 BUG_ON( ! (regs->cpsr & PSR_MODE_BIT) ); in show_registers_32()
797 printk("PC: %08"PRIx32"\n", regs->pc32); in show_registers_32()
799 printk("PC: %08"PRIx32, regs->pc); in show_registers_32()
801 printk(" %pS", _p(regs->pc)); in show_registers_32()
804 printk("CPSR: %08"PRIx32" MODE:%s\n", regs->cpsr, in show_registers_32()
805 mode_string(regs->cpsr)); in show_registers_32()
807 regs->r0, regs->r1, regs->r2, regs->r3); in show_registers_32()
809 regs->r4, regs->r5, regs->r6, regs->r7); in show_registers_32()
811 regs->r8, regs->r9, regs->r10, in show_registers_32()
813 regs->r11, in show_registers_32()
815 regs->fp, in show_registers_32()
817 regs->r12); in show_registers_32()
822 regs->sp_usr, regs->lr); in show_registers_32()
824 regs->sp_svc, regs->lr_svc, regs->spsr_svc); in show_registers_32()
826 regs->sp_abt, regs->lr_abt, regs->spsr_abt); in show_registers_32()
828 regs->sp_und, regs->lr_und, regs->spsr_und); in show_registers_32()
830 regs->sp_irq, regs->lr_irq, regs->spsr_irq); in show_registers_32()
832 regs->sp_fiq, regs->lr_fiq, regs->spsr_fiq); in show_registers_32()
834 regs->r8_fiq, regs->r9_fiq, regs->r10_fiq, regs->r11_fiq, regs->r11_fiq); in show_registers_32()
839 printk("HYP: SP: %08"PRIx32" LR: %08"PRIregister"\n", regs->sp, regs->lr); in show_registers_32()
866 static void show_registers_64(struct cpu_user_regs *regs, in show_registers_64() argument
872 BUG_ON( (regs->cpsr & PSR_MODE_BIT) ); in show_registers_64()
874 printk("PC: %016"PRIx64, regs->pc); in show_registers_64()
876 printk(" %pS", _p(regs->pc)); in show_registers_64()
878 printk("LR: %016"PRIx64"\n", regs->lr); in show_registers_64()
881 printk("SP_EL0: %016"PRIx64"\n", regs->sp_el0); in show_registers_64()
882 printk("SP_EL1: %016"PRIx64"\n", regs->sp_el1); in show_registers_64()
886 printk("SP: %016"PRIx64"\n", regs->sp); in show_registers_64()
888 printk("CPSR: %08"PRIx32" MODE:%s\n", regs->cpsr, in show_registers_64()
889 mode_string(regs->cpsr)); in show_registers_64()
891 regs->x0, regs->x1, regs->x2); in show_registers_64()
893 regs->x3, regs->x4, regs->x5); in show_registers_64()
895 regs->x6, regs->x7, regs->x8); in show_registers_64()
897 regs->x9, regs->x10, regs->x11); in show_registers_64()
899 regs->x12, regs->x13, regs->x14); in show_registers_64()
901 regs->x15, regs->x16, regs->x17); in show_registers_64()
903 regs->x18, regs->x19, regs->x20); in show_registers_64()
905 regs->x21, regs->x22, regs->x23); in show_registers_64()
907 regs->x24, regs->x25, regs->x26); in show_registers_64()
909 regs->x27, regs->x28, regs->fp); in show_registers_64()
914 printk(" ELR_EL1: %016"PRIx64"\n", regs->elr_el1); in show_registers_64()
927 static void _show_registers(struct cpu_user_regs *regs, in _show_registers() argument
939 show_registers_32(regs, ctxt, guest_mode, v); in _show_registers()
943 if ( psr_mode_is_32bit(regs->cpsr) ) in _show_registers()
945 BUG_ON(!usr_mode(regs)); in _show_registers()
946 show_registers_32(regs, ctxt, guest_mode, v); in _show_registers()
950 show_registers_64(regs, ctxt, guest_mode, v); in _show_registers()
958 show_registers_64(regs, ctxt, guest_mode, v); in _show_registers()
960 show_registers_32(regs, ctxt, guest_mode, v); in _show_registers()
971 printk(" ESR_EL2: %08"PRIx32"\n", regs->hsr); in _show_registers()
983 void show_registers(struct cpu_user_regs *regs) in show_registers() argument
998 if ( guest_mode(regs) && is_32bit_domain(current->domain) ) in show_registers()
1003 _show_registers(regs, &ctxt, guest_mode(regs), current); in show_registers()
1029 static void show_guest_stack(struct vcpu *v, struct cpu_user_regs *regs) in show_guest_stack() argument
1043 switch ( regs->cpsr & PSR_MODE_MASK ) in show_guest_stack()
1054 sp = regs->sp_fiq; in show_guest_stack()
1057 sp = regs->sp_irq; in show_guest_stack()
1060 sp = regs->sp_svc; in show_guest_stack()
1063 sp = regs->sp_abt; in show_guest_stack()
1066 sp = regs->sp_und; in show_guest_stack()
1071 sp = regs->sp_el0; in show_guest_stack()
1074 sp = regs->sp_el1; in show_guest_stack()
1127 #define STACK_BEFORE_EXCEPTION(regs) ((register_t*)(regs)->sp) argument
1163 static void show_trace(struct cpu_user_regs *regs) in show_trace() argument
1169 printk(" [<%p>] %pS (PC)\n", _p(regs->pc), _p(regs->pc)); in show_trace()
1170 printk(" [<%p>] %pS (LR)\n", _p(regs->lr), _p(regs->lr)); in show_trace()
1173 low = (register_t)(STACK_BEFORE_EXCEPTION(regs)); in show_trace()
1178 next = regs->fp; in show_trace()
1198 void show_stack(struct cpu_user_regs *regs) in show_stack() argument
1200 register_t *stack = STACK_BEFORE_EXCEPTION(regs), addr; in show_stack()
1203 if ( guest_mode(regs) ) in show_stack()
1204 return show_guest_stack(current, regs); in show_stack()
1222 show_trace(regs); in show_stack()
1225 void show_execution_state(struct cpu_user_regs *regs) in show_execution_state() argument
1227 show_registers(regs); in show_execution_state()
1228 show_stack(regs); in show_execution_state()
1251 void do_unexpected_trap(const char *msg, struct cpu_user_regs *regs) in do_unexpected_trap() argument
1254 show_execution_state(regs); in do_unexpected_trap()
1258 int do_bug_frame(struct cpu_user_regs *regs, vaddr_t pc) in do_bug_frame() argument
1305 show_execution_state(regs); in do_bug_frame()
1311 if ( debugger_trap_fatal(TRAP_invalid_op, regs) ) in do_bug_frame()
1314 show_execution_state(regs); in do_bug_frame()
1325 if ( debugger_trap_fatal(TRAP_invalid_op, regs) ) in do_bug_frame()
1327 show_execution_state(regs); in do_bug_frame()
1336 static void do_trap_brk(struct cpu_user_regs *regs, const union hsr hsr) in do_trap_brk() argument
1341 BUG_ON(!hyp_mode(regs)); in do_trap_brk()
1346 if ( do_bug_frame(regs, regs->pc) ) in do_trap_brk()
1349 regs->pc += 4; in do_trap_brk()
1355 do_unexpected_trap("Undefined Breakpoint Value", regs); in do_trap_brk()
1362 struct cpu_user_regs *regs = guest_cpu_user_regs(); in do_deprecated_hypercall() local
1366 regs->x16 in do_deprecated_hypercall()
1369 regs->r12; in do_deprecated_hypercall()
1428 static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code) in do_debug_trap() argument
1436 domid, reg, get_user_reg(regs, reg), regs->pc); in do_debug_trap()
1439 printk("DOM%d: Reached %"PRIvaddr"\n", domid, regs->pc); in do_debug_trap()
1442 printk("%c", (char)(get_user_reg(regs, 0) & 0xff)); in do_debug_trap()
1446 show_execution_state(regs); in do_debug_trap()
1473 static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr, in do_trap_hypercall() argument
1486 HYPERCALL_RESULT_REG(regs) = -ENOSYS; in do_trap_hypercall()
1496 HYPERCALL_RESULT_REG(regs) = -ENOSYS; in do_trap_hypercall()
1500 HYPERCALL_RESULT_REG(regs) = call(HYPERCALL_ARGS(regs)); in do_trap_hypercall()
1507 case 5: HYPERCALL_ARG5(regs) = 0xDEADBEEF; in do_trap_hypercall()
1508 case 4: HYPERCALL_ARG4(regs) = 0xDEADBEEF; in do_trap_hypercall()
1509 case 3: HYPERCALL_ARG3(regs) = 0xDEADBEEF; in do_trap_hypercall()
1510 case 2: HYPERCALL_ARG2(regs) = 0xDEADBEEF; in do_trap_hypercall()
1521 regs->pc -= 4; /* re-execute 'hvc #XEN_HYPERCALL_TAG' */ in do_trap_hypercall()
1599 int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr) in check_conditional_instr() argument
1632 cpsr = regs->cpsr; in check_conditional_instr()
1639 BUG_ON( !psr_mode_is_32bit(regs->cpsr) || !(cpsr&PSR_THUMB) ); in check_conditional_instr()
1661 void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) in advance_pc() argument
1663 unsigned long itbits, cond, cpsr = regs->cpsr; in advance_pc()
1695 regs->cpsr = cpsr; in advance_pc()
1698 regs->pc += hsr.len ? 4 : 2; in advance_pc()
1702 void handle_raz_wi(struct cpu_user_regs *regs, in handle_raz_wi() argument
1710 if ( min_el > 0 && psr_mode_is_user(regs) ) in handle_raz_wi()
1711 return inject_undef_exception(regs, hsr); in handle_raz_wi()
1714 set_user_reg(regs, regidx, 0); in handle_raz_wi()
1717 advance_pc(regs, hsr); in handle_raz_wi()
1721 void handle_wo_wi(struct cpu_user_regs *regs, in handle_wo_wi() argument
1729 if ( min_el > 0 && psr_mode_is_user(regs) ) in handle_wo_wi()
1730 return inject_undef_exception(regs, hsr); in handle_wo_wi()
1733 return inject_undef_exception(regs, hsr); in handle_wo_wi()
1736 advance_pc(regs, hsr); in handle_wo_wi()
1740 void handle_ro_raz(struct cpu_user_regs *regs, in handle_ro_raz() argument
1748 if ( min_el > 0 && psr_mode_is_user(regs) ) in handle_ro_raz()
1749 return inject_undef_exception(regs, hsr); in handle_ro_raz()
1752 return inject_undef_exception(regs, hsr); in handle_ro_raz()
1755 set_user_reg(regs, regidx, 0); in handle_ro_raz()
1757 advance_pc(regs, hsr); in handle_ro_raz()
1865 static void do_trap_instr_abort_guest(struct cpu_user_regs *regs, in do_trap_instr_abort_guest() argument
1882 return __do_trap_serror(regs, true); in do_trap_instr_abort_guest()
1935 inject_iabt_exception(regs, gva, hsr.len); in do_trap_instr_abort_guest()
1938 static bool try_handle_mmio(struct cpu_user_regs *regs, in try_handle_mmio() argument
1956 if ( check_workaround_766422() && (regs->cpsr & PSR_THUMB) && in try_handle_mmio()
1959 rc = decode_instruction(regs, &info->dabt); in try_handle_mmio()
1999 static void do_trap_data_abort_guest(struct cpu_user_regs *regs, in do_trap_data_abort_guest() argument
2013 return __do_trap_serror(regs, true); in do_trap_data_abort_guest()
2056 if ( try_handle_mmio(regs, &info) ) in do_trap_data_abort_guest()
2058 advance_pc(regs, hsr); in do_trap_data_abort_guest()
2081 " gpa=%#"PRIpaddr"\n", hsr.bits, regs->pc, info.gva, info.gpa); in do_trap_data_abort_guest()
2082 inject_dabt_exception(regs, info.gva, hsr.len); in do_trap_data_abort_guest()
2085 static void enter_hypervisor_head(struct cpu_user_regs *regs) in enter_hypervisor_head() argument
2087 if ( guest_mode(regs) ) in enter_hypervisor_head()
2102 void do_trap_guest_sync(struct cpu_user_regs *regs) in do_trap_guest_sync() argument
2104 const union hsr hsr = { .bits = regs->hsr }; in do_trap_guest_sync()
2106 enter_hypervisor_head(regs); in do_trap_guest_sync()
2116 if ( !check_conditional_instr(regs, hsr) ) in do_trap_guest_sync()
2118 advance_pc(regs, hsr); in do_trap_guest_sync()
2130 advance_pc(regs, hsr); in do_trap_guest_sync()
2133 GUEST_BUG_ON(!psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2135 do_cp15_32(regs, hsr); in do_trap_guest_sync()
2138 GUEST_BUG_ON(!psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2140 do_cp15_64(regs, hsr); in do_trap_guest_sync()
2143 GUEST_BUG_ON(!psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2145 do_cp14_32(regs, hsr); in do_trap_guest_sync()
2148 GUEST_BUG_ON(!psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2150 do_cp14_64(regs, hsr); in do_trap_guest_sync()
2153 GUEST_BUG_ON(!psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2155 do_cp14_dbg(regs, hsr); in do_trap_guest_sync()
2158 GUEST_BUG_ON(!psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2160 do_cp(regs, hsr); in do_trap_guest_sync()
2169 GUEST_BUG_ON(!psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2171 do_trap_smc(regs, hsr); in do_trap_guest_sync()
2174 GUEST_BUG_ON(!psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2178 return do_debug_trap(regs, hsr.iss & 0x00ff); in do_trap_guest_sync()
2181 return do_trap_hvc_smccc(regs); in do_trap_guest_sync()
2182 do_trap_hypercall(regs, (register_t *)&regs->r12, hsr.iss); in do_trap_guest_sync()
2186 GUEST_BUG_ON(psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2190 return do_debug_trap(regs, hsr.iss & 0x00ff); in do_trap_guest_sync()
2193 return do_trap_hvc_smccc(regs); in do_trap_guest_sync()
2194 do_trap_hypercall(regs, &regs->x16, hsr.iss); in do_trap_guest_sync()
2202 GUEST_BUG_ON(psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2204 do_trap_smc(regs, hsr); in do_trap_guest_sync()
2207 GUEST_BUG_ON(psr_mode_is_32bit(regs->cpsr)); in do_trap_guest_sync()
2209 do_sysreg(regs, hsr); in do_trap_guest_sync()
2215 do_trap_instr_abort_guest(regs, hsr); in do_trap_guest_sync()
2219 do_trap_data_abort_guest(regs, hsr); in do_trap_guest_sync()
2226 inject_undef_exception(regs, hsr); in do_trap_guest_sync()
2230 void do_trap_hyp_sync(struct cpu_user_regs *regs) in do_trap_hyp_sync() argument
2232 const union hsr hsr = { .bits = regs->hsr }; in do_trap_hyp_sync()
2234 enter_hypervisor_head(regs); in do_trap_hyp_sync()
2240 do_trap_brk(regs, hsr); in do_trap_hyp_sync()
2259 do_unexpected_trap(fault, regs); in do_trap_hyp_sync()
2266 do_unexpected_trap("Hypervisor", regs); in do_trap_hyp_sync()
2270 void do_trap_hyp_serror(struct cpu_user_regs *regs) in do_trap_hyp_serror() argument
2272 enter_hypervisor_head(regs); in do_trap_hyp_serror()
2274 __do_trap_serror(regs, VABORT_GEN_BY_GUEST(regs)); in do_trap_hyp_serror()
2277 void do_trap_guest_serror(struct cpu_user_regs *regs) in do_trap_guest_serror() argument
2279 enter_hypervisor_head(regs); in do_trap_guest_serror()
2281 __do_trap_serror(regs, true); in do_trap_guest_serror()
2284 void do_trap_irq(struct cpu_user_regs *regs) in do_trap_irq() argument
2286 enter_hypervisor_head(regs); in do_trap_irq()
2287 gic_interrupt(regs, 0); in do_trap_irq()
2290 void do_trap_fiq(struct cpu_user_regs *regs) in do_trap_fiq() argument
2292 enter_hypervisor_head(regs); in do_trap_fiq()
2293 gic_interrupt(regs, 1); in do_trap_fiq()