Re: panic: fpudna from userland

Brad Spencer <[email protected]> Wed, 15 May 2024 06:48:00 -0400
Newsgroups gmane.os.netbsd.ports.i386
Message-ID <[email protected]>
Emmanuel Dreyfus <[email protected]> writes:

> On Sun, Apr 21, 2024 at 02:22:41PM +0000, Emmanuel Dreyfus wrote:
>> On NetBSD-10.0 with XEN3PAE_DOMU kernel, I get this panic when building packages:
>> [ 35714.4540347] panic: fpudna from userland, ip 0xbbe74f, trapframe 0xdbe1dfa8
>
> It seems Xen produces spurious fpudna traps, as a comment in the netbsd-9 
> source says. What about the workaround below? I have been building stuff
> with it without a crash.
>
>
> --- sys/arch/x86/x86/fpu.c      25 Jul 2023 11:41:42 -0000      1.79.4.2
> +++ sys/arch/x86/x86/fpu.c      13 May 2024 14:54:59 -0000
> @@ -602,8 +602,17 @@
>  
>  void
>  fpudna(struct trapframe *frame)
>  {
> +#ifdef XENPV
> +       /*
> +        * Xen produes spurious fpudna traps, just do nothing.
> +        */
> +       if (USERMODE(frame->tf_cs)) {
> +               clts();
> +               return;
> +       } 
> +#endif
>         panic("fpudna from %s, ip %p, trapframe %p",
>             USERMODE(frame->tf_cs) ? "userland" : "kernel",
>             (void *)X86_TF_RIP(frame), frame);
>  }


The above patch appears to have helped.  I was somewhat able to prompt
the panic to happen by doing a build of a bunch of pkgsrc packages on a
NetBSD/i386 PAE Xen guest and without the patch, the panic would happen
at some random point during the pkgsrc build.  With the patch the build
proceeded to the end and there doesn't appear to be any obvious negative
side effects.


-- 
Brad Spencer - [email protected] - KC8VKS - http://anduin.eldar.org