Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/aarch64/aarch64 Fix the problem "pcictl pci0 list" ...



details:   https://anonhg.NetBSD.org/src/rev/c23f4cc407fc
branches:  trunk
changeset: 961267:c23f4cc407fc
user:      ryo <ryo%NetBSD.org@localhost>
date:      Wed Apr 14 05:43:09 2021 +0000

description:
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.

diffstat:

 sys/arch/aarch64/aarch64/bus_space.c |   8 ++++++--
 sys/arch/aarch64/aarch64/trap.c      |  25 ++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 5 deletions(-)

diffs (103 lines):

diff -r 2f8cdc29ad4a -r c23f4cc407fc sys/arch/aarch64/aarch64/bus_space.c
--- a/sys/arch/aarch64/aarch64/bus_space.c      Wed Apr 14 02:45:58 2021 +0000
+++ b/sys/arch/aarch64/aarch64/bus_space.c      Wed Apr 14 05:43:09 2021 +0000
@@ -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 <ryo%nerv.org@localhost>
@@ -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 @@
 
        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 @@
 
        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 @@
 
        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 @@
 
        if ((error = cpu_set_onfault(&fb)) == 0) {
                *datap = NSWAP(generic_dsb_bs_r_8)(t, bsh, offset);
+               dsb(ld);
                cpu_unset_onfault();
        }
        return error;
diff -r 2f8cdc29ad4a -r c23f4cc407fc sys/arch/aarch64/aarch64/trap.c
--- a/sys/arch/aarch64/aarch64/trap.c   Wed Apr 14 02:45:58 2021 +0000
+++ b/sys/arch/aarch64/aarch64/trap.c   Wed Apr 14 05:43:09 2021 +0000
@@ -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 @@
        }
 }
 
+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_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)



Home | Main Index | Thread Index | Old Index