NetBSD-Bugs archive

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

Re: kern/55889 (panic when boot GENERIC64 kernel on RaspberryPi4 (without RPi4_UEFI_Firmware))



The following reply was made to PR kern/55889; it has been noted by GNATS.

From: Kouichi Hashikawa <hashikaw%mail.ru@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: kern-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, skrll%netbsd.org@localhost,
 mlelstv%serpens.de@localhost
Subject: Re: kern/55889 (panic when boot GENERIC64 kernel on RaspberryPi4 (without  RPi4_UEFI_Firmware))
Date: Fri, 12 Mar 2021 02:50:28 +0900

 I found following comment in src/sys/net/route.c,
 * We can't have struct route as percpu data because it can be destroyed
 * over a memory enlargement processing of percpu.
 I change percpu_create(sizeof(struct cprng_fast) to percpu_create(sizeof(str=
 uc
 t cprng_fast *),
 kernel can boot.
 
 In src/sys/arch/arm/pic/pic.c, use percpu_create(sizeof(struct pic_percpu) a=
 lso.
 
 --- src/sys/crypto/cprng_fast/cprng_fast.c-1.16 2020-12-21 16:19:54.00000000=
 0=20
 +0900
 +++ src/sys/crypto/cprng_fast/cprng_fast.c      2021-03-11 16:44:11.89642563=
 8=20
 +0900
 @@ -70,11 +70,25 @@
 static percpu_t        *cprng_fast_percpu      __read_mostly;
 static void    *cprng_fast_softint     __read_mostly;
 
 +static inline struct cprng_fast *
 +cprng_percpu_getref(percpu_t *pc)
 +{
 +
 +       return *(struct cprng_fast **)percpu_getref(pc);
 +}
 +
 +static inline void
 +cprng_percpu_putref(percpu_t *pc)
 +{
 +
 +       percpu_putref(pc);
 +}
 +
 void
 cprng_fast_init(void)
 {
 
 -       cprng_fast_percpu =3D percpu_create(sizeof(struct cprng_fast),
 +       cprng_fast_percpu =3D percpu_create(sizeof(struct cprng_fast *),
           cprng_fast_init_cpu, NULL, NULL);
       cprng_fast_softint =3D softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE=
 ,
           &cprng_fast_intr, NULL);
 @@ -83,9 +97,12 @@
 static void
 cprng_fast_init_cpu(void *p, void *arg __unused, struct cpu_info *ci)
 {
 -       struct cprng_fast *const cprng =3D p;
 +       struct cprng_fast **const cprngp =3D p;
       uint8_t seed[CPRNG_FAST_SEED_BYTES];
 
 +       *cprngp =3D kmem_zalloc(sizeof(**cprngp), KM_SLEEP);
 +       struct cprng_fast *const cprng =3D *cprngp;
 +
       cprng->epoch =3D entropy_epoch();
       cprng_strong(kern_cprng, seed, sizeof seed, 0);
       cprng_fast_seed(cprng, seed);
 @@ -103,7 +120,7 @@
       struct cprng_fast *cprng;
       int s;
 
 -       *cprngp =3D cprng =3D percpu_getref(cprng_fast_percpu);
 +       *cprngp =3D cprng =3D cprng_percpu_getref(cprng_fast_percpu);
       s =3D splvm();
 
       if (__predict_false(cprng->epoch !=3D entropy_epoch()))
 @@ -116,7 +133,7 @@
 cprng_fast_put(struct cprng_fast *cprng, int s)
 {
 
 -       KASSERT((cprng =3D=3D percpu_getref(cprng_fast_percpu)) &&
 +       KASSERT((cprng =3D=3D cprng_percpu_getref(cprng_fast_percpu)) &&
           (percpu_putref(cprng_fast_percpu), true));
       splx(s);
       percpu_putref(cprng_fast_percpu);
 @@ -139,7 +156,7 @@
 
       cprng_strong(kern_cprng, seed, sizeof(seed), 0);
 
 -       cprng =3D percpu_getref(cprng_fast_percpu);
 +       cprng =3D cprng_percpu_getref(cprng_fast_percpu);
       s =3D splvm();
       cprng_fast_seed(cprng, seed);
       cprng->epoch =3D epoch;
 
 
 (missing correction?)
 --- src/sys/net/if_l2tp.c-dist  2020-12-21 16:20:48.000000000 +0900
 +++ src/sys/net/if_l2tp.c       2021-03-12 02:34:27.644208958 +0900
 @@ -411,7 +411,7 @@
       }
 
       IF_ENQUEUE(ifq, m);
 -       percpu_putref(sc->l2tp_ifq_percpu);
 +       l2tp_ifq_percpu_putref(sc->l2tp_ifq_percpu);
       softint_schedule(sc->l2tp_si);
       /* counter is incremented in l2tpintr() */
       splx(s);
 
 
 --=20
 Kouichi Hashikawa
 
 



Home | Main Index | Thread Index | Old Index