Module Name: src Committed By: ryo Date: Wed Apr 14 05:43:09 UTC 2021
Modified Files: src/sys/arch/aarch64/aarch64: bus_space.c trap.c Log Message: Fix the problem "pcictl pci0 list" causes "panic: trap_el1h_error" on rockpro64. The panic occures in bus_space_barrier() in rk3399_pcie.c:rkpcie_conf_read(). We expected bus_space_peek_4() to trap and recover in the path trap_el1h_sync() -> data_abort_handler(), but In fact, the read is delayed until bus_space_barrier(), and we get an SError interrupt (trap_el1h_error) instead of a Synchronous Exception (trap_el1h_sync). To catch this correctly, An implicit barrier in bus_space_peek have been added, and trap the SError interrupt to recover from. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/aarch64/bus_space.c cvs rdiff -u -r1.45 -r1.46 src/sys/arch/aarch64/aarch64/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/aarch64/aarch64/bus_space.c diff -u src/sys/arch/aarch64/aarch64/bus_space.c:1.15 src/sys/arch/aarch64/aarch64/bus_space.c:1.16 --- src/sys/arch/aarch64/aarch64/bus_space.c:1.15 Mon Dec 14 19:32:29 2020 +++ src/sys/arch/aarch64/aarch64/bus_space.c Wed Apr 14 05:43:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_space.c,v 1.15 2020/12/14 19:32:29 skrll Exp $ */ +/* $NetBSD: bus_space.c,v 1.16 2021/04/14 05:43:09 ryo Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.15 2020/12/14 19:32:29 skrll Exp $"); +__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.16 2021/04/14 05:43:09 ryo Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -702,6 +702,7 @@ generic_bs_pe_1(void *t, bus_space_handl if ((error = cpu_set_onfault(&fb)) == 0) { *datap = generic_dsb_bs_r_1(t, bsh, offset); + dsb(ld); cpu_unset_onfault(); } return error; @@ -716,6 +717,7 @@ generic_bs_pe_2(void *t, bus_space_handl if ((error = cpu_set_onfault(&fb)) == 0) { *datap = NSWAP(generic_dsb_bs_r_2)(t, bsh, offset); + dsb(ld); cpu_unset_onfault(); } return error; @@ -730,6 +732,7 @@ generic_bs_pe_4(void *t, bus_space_handl if ((error = cpu_set_onfault(&fb)) == 0) { *datap = NSWAP(generic_dsb_bs_r_4)(t, bsh, offset); + dsb(ld); cpu_unset_onfault(); } return error; @@ -744,6 +747,7 @@ generic_bs_pe_8(void *t, bus_space_handl if ((error = cpu_set_onfault(&fb)) == 0) { *datap = NSWAP(generic_dsb_bs_r_8)(t, bsh, offset); + dsb(ld); cpu_unset_onfault(); } return error; Index: src/sys/arch/aarch64/aarch64/trap.c diff -u src/sys/arch/aarch64/aarch64/trap.c:1.45 src/sys/arch/aarch64/aarch64/trap.c:1.46 --- src/sys/arch/aarch64/aarch64/trap.c:1.45 Tue Mar 9 16:44:27 2021 +++ src/sys/arch/aarch64/aarch64/trap.c Wed Apr 14 05:43:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.45 2021/03/09 16:44:27 ryo Exp $ */ +/* $NetBSD: trap.c,v 1.46 2021/04/14 05:43:09 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.45 2021/03/09 16:44:27 ryo Exp $"); +__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.46 2021/04/14 05:43:09 ryo Exp $"); #include "opt_arm_intr_impl.h" #include "opt_compat_netbsd32.h" @@ -861,6 +861,26 @@ unknown: } } +void +trap_el1h_error(struct trapframe *tf) +{ + /* + * Normally, we should panic unconditionally, + * but SError interrupt may occur when accessing to unmapped(?) I/O + * spaces. bus_space_{peek,poke}_{1,2,4,8}() should trap these case. + */ + struct faultbuf *fb; + + if (curcpu()->ci_intr_depth == 0) { + fb = cpu_disable_onfault(); + if (fb != NULL) { + cpu_jump_onfault(tf, fb, EFAULT); + return; + } + } + panic("%s", __func__); +} + #define bad_trap_panic(trapfunc) \ void \ trapfunc(struct trapframe *tf) \ @@ -872,7 +892,6 @@ bad_trap_panic(trap_el1t_irq) bad_trap_panic(trap_el1t_fiq) bad_trap_panic(trap_el1t_error) bad_trap_panic(trap_el1h_fiq) -bad_trap_panic(trap_el1h_error) bad_trap_panic(trap_el0_fiq) bad_trap_panic(trap_el0_error) bad_trap_panic(trap_el0_32fiq)