From: Al Viro <viro@zeniv.linux.org.uk>
To: Richard Henderson <rth@twiddle.net>
Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] alpha: fix FEN fault handling
Date: Sat, 7 Jan 2023 02:46:25 +0000 [thread overview]
Message-ID: <Y7jdARsEQXPugR0t@ZenIV> (raw)
In-Reply-To: <84c0d4ea-09e2-4907-d03d-939d40fa3c96@twiddle.net>
On Fri, Jan 06, 2023 at 05:55:14PM -0800, Richard Henderson wrote:
> On 1/6/23 16:59, Al Viro wrote:
> > Type 3 instruction fault (FPU insn with FPU disabled) is handled
> > by quietly enabling FPU and returning. Which is fine, except that
> > we need to do that both for fault in userland and in the kernel;
> > the latter *can* legitimately happen - all it takes is this:
> >
> > .global _start
> > _start:
> > call_pal 0xae
> > lda $0, 0
> > ldq $0, 0($0)
> >
> > - call_pal CLRFEN to clear "FPU enabled" flag and arrange for
> > a signal delivery (SIGSEGV in this case).
> >
> > Fixed by moving the handling of type 3 into the common part of
> > do_entIF(), before we check for kernel vs. user mode.
> >
> > Incidentally, check for kernel mode is unidiomatic; the normal
> > way to do that is !user_mode(regs). The difference is that
> > the open-coded variant treats any of bits 63..3 of regs->ps being
> > set as "it's user mode" while the normal approach is to check just
> > the bit 3. PS is a 4-bit register and regs->ps always will have
> > bits 63..4 clear, so the open-code variant here is actually equivalent
> > to !user_mode(regs). Harder to follow, though...
> >
> > Reproducer above will crash any box where CLRFEN is not ignored by
> > PAL (== any actual hardware, AFAICS; PAL used in qemu doesn't
> > bother implementing that crap).
>
> I didn't realize I'd forgotten this in qemu. Anyway,
>
> Reviewed-by: Richard Henderson <rth@twiddle.net>
Not sure it's worth bothering with in palcode-clipper - for Linux it's
useless (run out of timeslice and FEN will end up set, no matter what),
nothing in NetBSD or OpenBSD trees generates that call_pal, current
FreeBSD doesn't support alpha and their last version to do so hadn't
generated that call_pal either... What else is out there? OSF?
next prev parent reply other threads:[~2023-01-07 2:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-07 0:59 [PATCH] alpha: fix FEN fault handling Al Viro
2023-01-07 1:55 ` Richard Henderson
2023-01-07 2:46 ` Al Viro [this message]
2023-01-07 21:28 ` Al Viro
2023-01-07 23:03 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y7jdARsEQXPugR0t@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.