NetBSD Problem Report #56471

From martin@aprisoft.de  Thu Oct 28 10:10:54 2021
Return-Path: <martin@aprisoft.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 607D91A9239
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 28 Oct 2021 10:10:54 +0000 (UTC)
Message-Id: <20211028101045.94AEE5CC84B@emmas.aprisoft.de>
Date: Thu, 28 Oct 2021 12:10:45 +0200 (CEST)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: ntpd dies at startup on macppc/current, sshd randomly dies
X-Send-Pr-Version: 3.95

>Number:         56471
>Category:       port-powerpc
>Synopsis:       ntpd dies at startup on macppc/current, sshd randomly dies
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    thorpej
>State:          feedback
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 28 10:15:00 +0000 2021
>Closed-Date:    
>Last-Modified:  Thu Nov 04 07:25:01 +0000 2021
>Originator:     Martin Husemann
>Release:        NetBSD 9.99.92
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD gethsemane.aprisoft.de 9.99.92 NetBSD 9.99.92 (GETHSEMANE) #136: Thu Oct 28 11:30:06 CEST 2021 martin@seven-days-to-the-wolves.aprisoft.de:/work/src/sys/arch/macppc/compile/GETHSEMANE macppc
Architecture: powerpc
Machine: macppc
>Description:

Something changed in the last week (my last update was on oct 21) and
now on macppc running -current

 - ntpd dies immediately at startup: ntpd[1324]: daemon child exited with code 22
 - sshd randomly dies often

>How-To-Repeat:

run macppc/current

>Fix:
n/a

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Fri, 29 Oct 2021 11:05:24 +0200

 Running ntpd with -D 255 shows:

 [..]
 setting SO_REUSEADDR on gem0@fe80::203:93ff:fe71:ffcc%2 to off
 setting SO_REUSEADDR on gem0@192.168.111.68 to off
 setting SO_REUSEADDR on lo0@127.0.0.1 to off
 setting SO_REUSEADDR on lo0@::1 to off
 setting SO_REUSEADDR on lo0@fe80::1%3 to off
 create_sockets: Total interfaces = 7
 29 Oct 10:57:56 ntpd[1447]: Listening on routing socket on fd #27 for interface updates
 io_open_sockets: maxactivefd 27
 forked worker child (pid 1214)
 parent closed request pipe, child 1214 terminating


 Running ktrace -i on it again (without the debug settings) shows this
 as last sequence of calls from the child:

   1213   1213 ntpd     CALL  compat_16___sigreturn14(0xffffe000)
   1213   1213 ntpd     RET   compat_16___sigreturn14 -1 errno 22 Invalid argument
   1213   1213 ntpd     CALL  exit(0x16)

 ... and this kernel does not have COMPAT_16 enabled.

 Just to make sure: this is from a clean build of today's -current. No old code
 involved.

 Martin

From: Jason Thorpe <thorpej@me.com>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 "martin@netbsd.org" <martin@NetBSD.org>
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Fri, 29 Oct 2021 07:48:35 -0700

 This was probably caused by Christos=E2=80=99s change that unified =
 __libc_sigaction14() with the added #define __LIBC12_SOURCE__.  Because =
 =E2=80=9Csigcontext=E2=80=9D signal handlers have been broken for so =
 long (since 2006), re-enabling them has turned up bugs (no one has been =
 using the old __sigreturn14 system call for a long time).

 > On Oct 29, 2021, at 2:10 AM, Martin Husemann <martin@duskware.de> =
 wrote:
 >=20
 > The following reply was made to PR bin/56471; it has been noted by =
 GNATS.
 >=20
 > From: Martin Husemann <martin@duskware.de>
 > To: gnats-bugs@netbsd.org
 > Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
 > Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd =
 randomly
 > dies
 > Date: Fri, 29 Oct 2021 11:05:24 +0200
 >=20
 > Running ntpd with -D 255 shows:
 >=20
 > [..]
 > setting SO_REUSEADDR on gem0@fe80::203:93ff:fe71:ffcc%2 to off
 > setting SO_REUSEADDR on gem0@192.168.111.68 to off
 > setting SO_REUSEADDR on lo0@127.0.0.1 to off
 > setting SO_REUSEADDR on lo0@::1 to off
 > setting SO_REUSEADDR on lo0@fe80::1%3 to off
 > create_sockets: Total interfaces =3D 7
 > 29 Oct 10:57:56 ntpd[1447]: Listening on routing socket on fd #27 for =
 interface updates
 > io_open_sockets: maxactivefd 27
 > forked worker child (pid 1214)
 > parent closed request pipe, child 1214 terminating
 >=20
 >=20
 > Running ktrace -i on it again (without the debug settings) shows this
 > as last sequence of calls from the child:
 >=20
 >   1213   1213 ntpd     CALL  compat_16___sigreturn14(0xffffe000)
 >   1213   1213 ntpd     RET   compat_16___sigreturn14 -1 errno 22 =
 Invalid argument
 >   1213   1213 ntpd     CALL  exit(0x16)
 >=20
 > ... and this kernel does not have COMPAT_16 enabled.
 >=20
 > Just to make sure: this is from a clean build of today's -current. No =
 old code
 > involved.
 >=20
 > Martin
 >=20

 -- thorpej

Responsible-Changed-From-To: bin-bug-people->thorpej
Responsible-Changed-By: thorpej@NetBSD.org
Responsible-Changed-When: Fri, 29 Oct 2021 14:53:13 +0000
Responsible-Changed-Why:
Take.


From: Jason Thorpe <thorpej@me.com>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 05:42:16 -0700

 > On Oct 29, 2021, at 2:05 AM, Martin Husemann <martin@duskware.de> =
 wrote:
 >=20
 >  1213   1213 ntpd     CALL  compat_16___sigreturn14(0xffffe000)
 >  1213   1213 ntpd     RET   compat_16___sigreturn14 -1 errno 22 =
 Invalid argument
 >  1213   1213 ntpd     CALL  exit(0x16)

 I have attempted to reproduce this on NetBSD/alpha, which, like powerpc, =
 also has compat_16___sigreturn14, to see if it was some common logic =
 problem in libc or the kernel.  I used lots of debug logging to verify =
 the code paths being taken.  Alpha works fine.  So it would seem this is =
 a powerpc-specific problem.

 The powerpc compat_16_sys___sigreturn14() has the following block:

         /*
          * Make sure SRR1 hasn't been maliciously tampered with. =20
          */    =20
         if (!PSL_USEROK_P(sc.sc_frame.srr1))
                 return (EINVAL);

 I=E2=80=99m pretty sure this is what is tripping in the failure case.

 In the powerpc sendsig_sigcontext(), that field is initialized like so:

         utf->srr1 =3D tf->tf_srr1 & PSL_USERSRR1;

 For reference, those PSL_USER* macros are defined as:

 #define PSL_USERSRR1            ((PSL_USERSET|PSL_USERMOD) & =
 PSL_USERMASK)
 #define PSL_USEROK_P(psl)       (((psl) & ~PSL_USERMOD) =3D=3D =
 PSL_USERSET)

 ...and on OEA machines (such as macppc), those expand to:

 #define PSL_USERSET             cpu_psluserset
 #define PSL_USERMOD             cpu_pslusermod
 #define PSL_USERMASK            cpu_pslusermask

         /*
          * Configure a PSL user mask matching this processor.
          * Don't allow to set PSL_FP/PSL_VEC, since that will affect =
 PCU. =20
          */
         cpu_psluserset =3D PSL_EE | PSL_PR | PSL_ME | PSL_IR | PSL_DR | =
 PSL_RI;
         cpu_pslusermod =3D PSL_FE0 | PSL_FE1 | PSL_LE | PSL_SE | PSL_BE;
 #ifdef PPC_OEA601
         if (cpuvers =3D=3D MPC601) {
                 cpu_psluserset &=3D PSL_601_MASK;=20
                 cpu_pslusermod &=3D PSL_601_MASK;=20
         }
 #endif
 #ifdef PPC_HIGH_VEC
         cpu_psluserset |=3D PSL_IP;       /* XXX ok? */
 #endif

 (register_t cpu_pslusermask =3D 0xffff;)

 It would be really interesting to know what the value of =
 sc.sc_frame.srr1 that sigreturn is objecting to.  Like, is it complete =
 garbage?

 -- thorpej

From: Jason Thorpe <thorpej@me.com>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 05:48:48 -0700

 > On Oct 30, 2021, at 5:42 AM, Jason Thorpe <thorpej@me.com> wrote:
 >=20
 >        /*
 >         * Make sure SRR1 hasn't been maliciously tampered with. =20
 >         */    =20
 >        if (!PSL_USEROK_P(sc.sc_frame.srr1))
 >                return (EINVAL);
 >=20
 > I=E2=80=99m pretty sure this is what is tripping in the failure case.

 It=E2=80=99s worth noting that the siginfo case, which was always being =
 used until very recently, simply does this:

                 /*
                  * Accept all user-settable bits without complaint;
                  * userland should not need to know the machine-specific
                  * MSR value.
                  */
                 tf->tf_srr1 =3D (gr[_REG_MSR] & PSL_USERMOD) | =
 PSL_USERSET;

 I.e. does no checking, and simply forces it to what it should be (modulo =
 accepting the user-settable bits, which in the OEA case are basically FP =
 modes and single-stepping).

 -- thorpej

From: Christos Zoulas <christos@zoulas.com>
To: Jason Thorpe <thorpej@me.com>
Cc: Martin Husemann <martin@duskware.de>,
 gnats-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 09:14:12 -0400

 Good debugging. Let's make it look like the siginfo case then.

 christos

 > On Oct 30, 2021, at 8:48 AM, Jason Thorpe <thorpej@me.com> wrote:
 >=20
 >=20
 >> On Oct 30, 2021, at 5:42 AM, Jason Thorpe <thorpej@me.com> wrote:
 >>=20
 >>       /*
 >>        * Make sure SRR1 hasn't been maliciously tampered with. =20
 >>        */    =20
 >>       if (!PSL_USEROK_P(sc.sc_frame.srr1))
 >>               return (EINVAL);
 >>=20
 >> I=E2=80=99m pretty sure this is what is tripping in the failure case.
 >=20
 > It=E2=80=99s worth noting that the siginfo case, which was always =
 being used until very recently, simply does this:
 >=20
 >                /*
 >                 * Accept all user-settable bits without complaint;
 >                 * userland should not need to know the =
 machine-specific
 >                 * MSR value.
 >                 */
 >                tf->tf_srr1 =3D (gr[_REG_MSR] & PSL_USERMOD) | =
 PSL_USERSET;
 >=20
 > I.e. does no checking, and simply forces it to what it should be =
 (modulo accepting the user-settable bits, which in the OEA case are =
 basically FP modes and single-stepping).
 >=20
 > -- thorpej

From: Jason Thorpe <thorpej@me.com>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 06:15:09 -0700

 --Apple-Mail=_CE036B8E-84DB-4C20-859B-EA82DAE652DB
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=utf-8


 > On Oct 30, 2021, at 5:48 AM, Jason Thorpe <thorpej@me.com> wrote:

 > I.e. does no checking, and simply forces it to what it should be =
 (modulo accepting the user-settable bits, which in the OEA case are =
 basically FP modes and single-stepping).

 Martin =E2=80=94 can you please try this patch?  I=E2=80=99d like to see =
 the debug output.


 --Apple-Mail=_CE036B8E-84DB-4C20-859B-EA82DAE652DB
 Content-Disposition: attachment;
 	filename=pr-56471-test-patch.txt
 Content-Type: text/plain;
 	x-unix-mode=0644;
 	name="pr-56471-test-patch.txt"
 Content-Transfer-Encoding: 7bit

 ? pr-56471-test-patch.txt
 Index: compat_16_machdep.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/compat_16_machdep.c,v
 retrieving revision 1.21
 diff -u -p -r1.21 compat_16_machdep.c
 --- compat_16_machdep.c	27 Oct 2021 04:15:00 -0000	1.21
 +++ compat_16_machdep.c	30 Oct 2021 13:13:30 -0000
 @@ -204,8 +204,11 @@ compat_16_sys___sigreturn14(struct lwp *
  	/*
  	 * Make sure SRR1 hasn't been maliciously tampered with.
  	 */
 -	if (!PSL_USEROK_P(sc.sc_frame.srr1))
 -		return (EINVAL);
 +	if (!PSL_USEROK_P(utf->srr1)) {
 +		printf("%s: XXX SRR1 = 0x%lx\n",
 +		    (u_long)sc.sc_frame.srr1);
 +		/* return (EINVAL); */
 +	}

  	/* Restore register context. */
  	memcpy(tf->tf_fixreg, utf->fixreg, sizeof(tf->tf_fixreg));
 @@ -214,7 +217,7 @@ compat_16_sys___sigreturn14(struct lwp *
  	tf->tf_xer  = utf->xer;
  	tf->tf_ctr  = utf->ctr;
  	tf->tf_srr0 = utf->srr0;
 -	tf->tf_srr1 = utf->srr1;
 +	tf->tf_srr1 = (utf->srr1 & PSL_USERMOD) | PSL_USERSET;

  #ifdef PPC_HAVE_FPU
  	struct pcb * const pcb = lwp_getpcb(l);

 --Apple-Mail=_CE036B8E-84DB-4C20-859B-EA82DAE652DB
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii



 -- thorpej


 --Apple-Mail=_CE036B8E-84DB-4C20-859B-EA82DAE652DB--

From: Jason Thorpe <thorpej@me.com>
To: Christos Zoulas <christos@zoulas.com>
Cc: Martin Husemann <martin@duskware.de>,
 gnats-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 06:15:35 -0700

 > On Oct 30, 2021, at 6:14 AM, Christos Zoulas <christos@zoulas.com> =
 wrote:
 >=20
 > Good debugging. Let's make it look like the siginfo case then.

 Yes, but I=E2=80=99d like to see the debug output from the patch I just =
 sent.


 -- thorpej

From: Rin Okuyama <rokuyama.rk@gmail.com>
To: Jason Thorpe <thorpej@me.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 23:22:51 +0900

 Probably not directly related to this problem, but there is
 hardcoded value for MSR in libpthread:

 https://nxr.netbsd.org/xref/src/lib/libpthread/arch/powerpc/pthread_md.h

       53 /*
       54  * Set initial, sane values for registers whose values aren't just
       55  * "don't care".
       56  * 0xd032 is PSL_USERSET from arch/powerpc/include/psl.h
       57  */
       58 #define _INITCONTEXT_U_MD(ucp)						\
       59 	(ucp)->uc_mcontext.__gregs[_REG_MSR] = 0xd032;
       60

 "Sane" value for MSR varies between oea/40x/booke. Userland should not
 be bothered, and kernel should not accept any values from userland.

 However, IIRC, once I tried to remove this macro, KASSERT fired for oea.

 I was going to investigate further, but no progress yet...

 Thanks,
 rin

From: Jason Thorpe <thorpej@me.com>
To: gnats-bugs@netbsd.org
Cc: Jason Thorpe <thorpej@netbsd.org>,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 "martin@netbsd.org" <martin@NetBSD.org>
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 07:41:17 -0700

 > On Oct 30, 2021, at 7:25 AM, Rin Okuyama <rokuyama.rk@gmail.com> =
 wrote:
 >=20
 > "Sane" value for MSR varies between oea/40x/booke. Userland should not
 > be bothered, and kernel should not accept any values from userland.

 Well, I think it needs to at least accept round-tripping the FP modes =
 and the tracing bits.  But yah, for initial value, just set to 0 and let =
 the kernel initialize is the Right Thing.

 > However, IIRC, once I tried to remove this macro, KASSERT fired for =
 oea.

 Which KASSERT fired?

 -- thorpej

From: Rin Okuyama <rokuyama.rk@gmail.com>
To: Jason Thorpe <thorpej@me.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sun, 31 Oct 2021 00:12:57 +0900

 On 2021/10/30 23:41, Jason Thorpe wrote:
 > 
 >> On Oct 30, 2021, at 7:25 AM, Rin Okuyama <rokuyama.rk@gmail.com> wrote:
 >>
 >> "Sane" value for MSR varies between oea/40x/booke. Userland should not
 >> be bothered, and kernel should not accept any values from userland.
 > 
 > Well, I think it needs to at least accept round-tripping the FP modes and the tracing bits.  But yah, for initial value, just set to 0 and let the kernel initialize is the Right Thing.

 For FP mode bits, we emulate m[ft]msr instructions for fenv(3). These
 insns raise privilege exceptions if executed from userland. We catch
 the exceptions and emulate m[ft]msr in powerpc_machdep.c:emulate_mxmsr(),
 by which only FP mode bits can be retrieved/modified.

 Tracing bit (PSL_DE) for oea cannot be set directly from userland. It
 can be set only via ptrace(2). Also, 40x/booke do not have PSL_DE bit,
 and we use software single stepping for these subarchs.

 >> However, IIRC, once I tried to remove this macro, KASSERT fired for oea.
 > 
 > Which KASSERT fired?

 Hmm, sorry, I cannot find it. Maybe I added by myself for debugging in
 my local tree.

 Thanks,
 rin

From: Jason Thorpe <thorpej@me.com>
To: Christos Zoulas <christos@zoulas.com>
Cc: Martin Husemann <martin@duskware.de>,
 gnats-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 11:32:37 -0700

 > On Oct 30, 2021, at 6:15 AM, Jason Thorpe <thorpej@me.com> wrote:
 >=20
 > Yes, but I=E2=80=99d like to see the debug output from the patch I =
 just sent.

 Ok, got my g4 mini up and running again, and my debug patch makes ntpd =
 and sshd work, and the debug output is:

 [  1501.566175] compat_16_sys___sigreturn14: XXX SRR1 =3D 0x200d032

 -- thorpej

From: Jason Thorpe <thorpej@me.com>
To: Christos Zoulas <christos@zoulas.com>
Cc: Martin Husemann <martin@duskware.de>,
 gnats-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 11:37:29 -0700

 > On Oct 30, 2021, at 11:32 AM, Jason Thorpe <thorpej@me.com> wrote:
 >=20
 >=20
 >> On Oct 30, 2021, at 6:15 AM, Jason Thorpe <thorpej@me.com> wrote:
 >>=20
 >> Yes, but I=E2=80=99d like to see the debug output from the patch I =
 just sent.
 >=20
 > Ok, got my g4 mini up and running again, and my debug patch makes ntpd =
 and sshd work, and the debug output is:
 >=20
 > [  1501.566175] compat_16_sys___sigreturn14: XXX SRR1 =3D 0x200d032

 Ok, and that=E2=80=99s VEC | EE | PR | ME | IR | DR | RI =E2=80=A6 which =
 is exactly what it=E2=80=99s supposed to be except for the VEC bit.  =
 That=E2=80=99s SUPPOSED to be masked out when it=E2=80=99s saved in the =
 sigcontext, so lemme keep digging.

 -- thorpej

From: Jason Thorpe <thorpej@me.com>
To: Christos Zoulas <christos@zoulas.com>
Cc: Martin Husemann <martin@duskware.de>,
 gnats-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/56471: ntpd dies at startup on macppc/current, sshd randomly
 dies
Date: Sat, 30 Oct 2021 11:58:00 -0700

 > On Oct 30, 2021, at 11:37 AM, Jason Thorpe <thorpej@me.com> wrote:
 >=20
 > Ok, and that=E2=80=99s VEC | EE | PR | ME | IR | DR | RI =E2=80=A6 =
 which is exactly what it=E2=80=99s supposed to be except for the VEC =
 bit.  That=E2=80=99s SUPPOSED to be masked out when it=E2=80=99s saved =
 in the sigcontext, so lemme keep digging.

 Ok, I totally see what=E2=80=99s happening now.  This is just a long =
 standing kernel bug that went unnoticed for years.  Working on a fix.

 -- thorpej

From: "Jason R Thorpe" <thorpej@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56471 CVS commit: src/sys/arch/powerpc
Date: Sat, 30 Oct 2021 19:44:56 +0000

 Module Name:	src
 Committed By:	thorpej
 Date:		Sat Oct 30 19:44:56 UTC 2021

 Modified Files:
 	src/sys/arch/powerpc/oea: altivec.c
 	src/sys/arch/powerpc/powerpc: compat_16_machdep.c

 Log Message:
 - In vec_restore_from_mcontext() and vec_save_to_mcontext(), allows the
   mcontext argument to be NULL.
 - In sendsig_sigcontext(), don't set PSL_VEC in the saved MSR; we can't
   actually round-trip the AltiVec registers.  At least get them saved
   into the PCB by calling vec_save_to_mcontext() (with a NULL mcontext
   argument).
 - In compat_16_sys___sigreturn14(), call vec_restore_from_mcontext()
   with a NULL mcontext argument, which will force any subsequent use
   of AltiVec to re-load the AltiVec registers from the PCB.

 This isn't ideal, but it's the best we can do with the limited capability
 of sigcontext.

 Fixes PR port-powerpc/56471.


 To generate a diff of this commit:
 cvs rdiff -u -r1.33 -r1.34 src/sys/arch/powerpc/oea/altivec.c
 cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/powerpc/compat_16_machdep.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: thorpej@NetBSD.org
State-Changed-When: Sat, 30 Oct 2021 19:45:53 +0000
State-Changed-Why:
Please verify this fixes the issue for you.


From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: thorpej@netbsd.org
Subject: Re: port-powerpc/56471 (ntpd dies at startup on macppc/current, sshd
 randomly dies)
Date: Sun, 31 Oct 2021 15:15:21 +0100

 The new kernel works fine (I'm still a bit irritated how
 compat_16_sys___sigreturn14 is involved in all this - but haven't followed
 closely).

 Martin

From: Jason Thorpe <thorpej@me.com>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@netbsd.org,
 Jason Thorpe <thorpej@netbsd.org>
Subject: Re: port-powerpc/56471 (ntpd dies at startup on macppc/current, sshd
 randomly dies)
Date: Sun, 31 Oct 2021 08:05:20 -0700

 > On Oct 31, 2021, at 7:15 AM, Martin Husemann <martin@duskware.de> =
 wrote:
 >=20
 > The new kernel works fine (I'm still a bit irritated how
 > compat_16_sys___sigreturn14 is involved in all this - but haven't =
 followed
 > closely).

 Yes, I=E2=80=99m a bit irritated, too, and intend to rid ourselves of =
 it.

 -- thorpej

From: Rin Okuyama <rokuyama.rk@gmail.com>
To: gnats-bugs@netbsd.org, thorpej@netbsd.org, gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org, martin@NetBSD.org
Cc: 
Subject: Re: port-powerpc/56471 (ntpd dies at startup on macppc/current, sshd
 randomly dies)
Date: Thu, 4 Nov 2021 16:23:20 +0900

 FYI, now, all of oea (sandpoint), 40[35] (evbppc), and booke (evbppc) work
 fine; no regressions for ATF and pkgsrc's including Perl and Python build.

 Thanks,
 rin

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.