From: Brad Boyer <flar@allandria.com>
To: Thorsten Otto <admin@tho-otto.de>
Cc: linux-m68k@vger.kernel.org
Subject: Re: Software FPU emulation in linux kernel
Date: Mon, 3 Mar 2025 14:10:12 -0800 [thread overview]
Message-ID: <20250303221012.GA7422@allandria.com> (raw)
In-Reply-To: <3374772.VqM8IeB0Os@earendil>
On Mon, Mar 03, 2025 at 05:22:09PM +0100, Thorsten Otto wrote:
> i'm currently trying to port the software FPU emulation of linux-m68k to
> FreeMiNT, and got some questions about it.
>
> the FPSP for 040/060 are not installed when the software emulation is used.
> However, almost all trigonometric functions are not implemented: https://
> github.com/torvalds/linux/blob/7eb172143d5508b4da468ed59ee857c6e5e01da6/arch/
> m68k/math-emu/fp_trig.c#L21-L28
The FPSP code relies on having the basic FPU of the 040 or 060 and uses
the actual floating point registers and the FPU instructions which are
implemented in hardware. On the variants without the built-in FPU, it's
expected that the FPU emulator handles all of it since that's faster
than triggering the emulator for each FPU instruction used in FPSP.
> What sense does it then make to use an emulation, when only basic
> instructions like fadd/fmul etc. are implemented? Programs are not even
> aborted when using one of those functions, uprint just prints an error
> message, and the functions just return with their input arguments as
> result instead of calculating the expected value.
Well, most programs that use FPU instructions aren't going to use anything
beyond the basics. The 68881/68882 are kind of unusual in implementing
all of that in hardware. That's why Motorola cut down the instruction
set implemented in hardware when they created the 68040. The extra chip
space wasn't worth the limited usage. The fact that the emulator ignores
the instructions is not correct, obviously.
> So essentially: is that emulation actually used anywhere?
In practice, no. There's a lot of other issues as well. I seem to
recall that it only supports the 020/030 and not the versions of
the 040/060 without FPU. It also doesn't fully implement all the
stuff like rounding modes. It's just a basic outline of how to
emulate an FPU rather than something actually useful. The advice
has always been to use a full 68040/68060 or add a real 68881/68882
chip to the 020/030 systems. Most of them do have a socket for it
or a way to add one. I think there's only a couple 030 Mac models
that don't have that option available. For example, I made sure to
get the expansion card for my IIsi that adds the FPU socket. I'm
not sure what the status is for the other platforms, but I got the
impression that the Amiga systems pretty much all run in practice
with CPU upgrades beyond the factory-original configuration.
Most existing 68LC040 chips also have the bug that causes missed
page faults after software-emulated instructions as well, making
it even less useful to support FPU emulation for them. I think
the PB190 is the only Mac with a 68LC040 new enough to be using
the fixed mask revision. Most desktop systems back then used
sockets for the main CPU making it possible to swap a 68LC040 for
the full 68040.
Brad Boyer
flar@allandria.com
next prev parent reply other threads:[~2025-03-03 22:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 16:22 Software FPU emulation in linux kernel Thorsten Otto
2025-03-03 22:10 ` Brad Boyer [this message]
2025-03-04 5:24 ` Thorsten Otto
2025-03-04 5:48 ` Brad Boyer
2025-03-03 23:38 ` Michael Schmitz
2025-03-04 4:44 ` Finn Thain
2025-03-04 5:47 ` Thorsten Otto
2025-03-06 15:24 ` Thorsten Otto
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=20250303221012.GA7422@allandria.com \
--to=flar@allandria.com \
--cc=admin@tho-otto.de \
--cc=linux-m68k@vger.kernel.org \
/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.