Thread View: muc.lists.netbsd.port.mac68k
7 messages
7 total messages
Started by Romain Dolbeau
Fri, 30 Oct 2026 18:00
Some fixes for m68k users (incl/ for FPU emulation)
Author: Romain Dolbeau
Date: Fri, 30 Oct 2026 18:00
Date: Fri, 30 Oct 2026 18:00
36 lines
4135 bytes
4135 bytes
(relevant to all m68k, but mac68k is the most likely users of FPU emulation hence the cross-post; I didn't want to spam all the 68k lists) Hello, In the process of creating my litex68k port to my homegrown as-for-now-FPGA-based system (version with real CPUs still TBD :-) ), systematic testing has found some issues in m68k, in particular in the FPU emulation code. Those patches are not eligible for submission to "gnats" as they were identified and fixed mostly by using a LLM, but they might be of interest to end-users building their own kernel. Hopefully this notification message (which is written without LLM assistance!) will be acceptable to the lists. Also, the CPU they were actually tested on are my own soft-core recreation of the MC680x0 and if anyone ever tests them on actual silicon, feedback is very welcome! (all my '040 machines have full MC68040). The list of patches and brief description can be found here: <https://github.com/MelkhiorVintageComputing/netbsd-litex-m68k/blob/litex68k/UPSTREAM.md> (beware: LLM-generated). The most relevant are the FPU emulation patches, there's also a couple minor performance improvements that could be relevant. The SMP patches are probably of interest to no-one but me as other than my litex68k port, there's no SMP support for m68k. Cordially, -- Romain Dolbeau -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: Some fixes for m68k users (incl/ for FPU emulation)
Author: David Rogers
Date: Fri, 30 Oct 2026 18:11
Date: Fri, 30 Oct 2026 18:11
49 lines
6496 bytes
6496 bytes
I’ll give it a whirl here. I’ve got a Quadra 650 and IIci(in the middle of being recapped) that are up and running. I’ve been doing some llm assisted work with the Quadra to support Radius Rocket accelerator cards so it shouldn’t be too difficult. David Rogers > On Oct 30, 2026, at 1:00 PM, Romain Dolbeau <romain@dolbeau.org> wrote: > > (relevant to all m68k, but mac68k is the most likely users of FPU > emulation hence the cross-post; I didn't want to spam all the 68k > lists) > > Hello, > > In the process of creating my litex68k port to my homegrown > as-for-now-FPGA-based system (version with real CPUs still TBD :-) ), > systematic testing has found some issues in m68k, in particular in the > FPU emulation code. > > Those patches are not eligible for submission to "gnats" as they were > identified and fixed mostly by using a LLM, but they might be of > interest to end-users building their own kernel. Hopefully this > notification message (which is written without LLM assistance!) will > be acceptable to the lists. Also, the CPU they were actually tested on > are my own soft-core recreation of the MC680x0 and if anyone ever > tests them on actual silicon, feedback is very welcome! (all my '040 > machines have full MC68040). > > The list of patches and brief description can be found here: > <https://github.com/MelkhiorVintageComputing/netbsd-litex-m68k/blob/litex68k/UPSTREAM.md> > (beware: LLM-generated). The most relevant are the FPU emulation > patches, there's also a couple minor performance improvements that > could be relevant. The SMP patches are probably of interest to no-one > but me as other than my litex68k port, there's no SMP support for > m68k. > > Cordially, > > -- > Romain Dolbeau -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: Some fixes for m68k users (incl/ for FPU emulation)
Author: Jason Thorpe
Date: Sun, 01 Nov 2026 12:54
Date: Sun, 01 Nov 2026 12:54
38 lines
6226 bytes
6226 bytes
> On Oct 30, 2026, at 2:00 PM, Romain Dolbeau <romain@dolbeau.org> wrote: > > The list of patches and brief description can be found here: > <https://github.com/MelkhiorVintageComputing/netbsd-litex-m68k/blob/litex68k/UPSTREAM.md> > (beware: LLM-generated). The most relevant are the FPU emulation > patches, there's also a couple minor performance improvements that > could be relevant. Ok, I’ve read the 1.x problem descriptions on that list and committed changes that address 1.1, 1.2, and 1.3. 1.4 I consider irrelevant; pmap_motorola.c is deprecated and on its way out. I wrote a new pmap module (pmap_68k.c) from scratch about a year ago that addresses several problems with the old pmap module (most notably: terrible 68040/68060 support that was shoehorned in). Several ports have switched to using it, and only a couple of stragglers remain. It’s already demonstrated itself to be more stable on small memory configs, and enables large memory configs on 68040/68060 that would have just completely failed to boot with the old code. Any future improvements to the pmap code should focus on that implementation, rather than the old one. I’ll start looking at the 2.x list shortly. It seems to me that you’re starting from the NetBSD 11 code base, which predates a large re-factor I did of the m68k code this year. Some of the problems you describe in that 2.x list are now differently-applicable, so it’ll take me a little more time to process those. -- thorpej -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: Some fixes for m68k users (incl/ for FPU emulation)
Author: Romain Dolbeau
Date: Sun, 01 Nov 2026 14:12
Date: Sun, 01 Nov 2026 14:12
38 lines
4639 bytes
4639 bytes
Le dim. 1 nov. 2026 à 13:54, Jason Thorpe <thorpej@me.com> a écrit : > It seems to me that you’re starting from the NetBSD 11 code base Oups, sorry, should have said that; I used github's netbsd-11 tag as the baseline, so I'd have something reasonably stable. That was also used as the baseline for virt68k-smp, hence all the work done on "pmap_motorola.c" I haven't looked at pmap_68k so it might be OK already; please make sure U0/U1 aren't used for internal purposes - they are exposed on external pins so could have an impact on the hardware (even if in r practice almost nobody used them), and they are needed to "properly" support SMP on MC68040 (they are used to indicate the level of type of snooping to use for the data in that page). > It’ll take me a little more time to process those There was no request to do anything about any of it in a hurry, implied or otherwise! On my side, I was just mentioning (alleged) issues the LLM I used encountered and "fixed" along the way [with "fixed" meaning "the tests no longer fails", which isn't a very high standard...]. FPU_EMULATE is a useful tool, but in real life probably only used by people with soldered xC68LC040 that can't be upgraded to full xC68040 and that aren't XC68LC040. Most MC68030 systems had a socket for a MC68881/2. And as mentioned using soft-float userland is the right option IMHO. OTOH, FPU_EMULATE is quite useful to debug $4 frames on 'LC040 clones :-) Cordially, -- Romain Dolbeau -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: Some fixes for m68k users (incl/ for FPU emulation)
Author: Jason Thorpe
Date: Sun, 01 Nov 2026 16:40
Date: Sun, 01 Nov 2026 16:40
20 lines
5079 bytes
5079 bytes
> On Nov 1, 2026, at 9:12 AM, Romain Dolbeau <romain@dolbeau.org> wrote: > > Most MC68030 systems had a > socket for a MC68881/2. And as mentioned using soft-float userland is > the right option IMHO. While this is true, there’s another home-brew 68030 system port in the work for a system that does not have a 6888x socket. Yes, m68ksf is the ideal solution in that case, but having it work properly with FPU_EMULATE would be good. -- thorpej -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: Some fixes for m68k users (incl/ for FPU emulation)
Author: Jason Thorpe
Date: Mon, 02 Nov 2026 14:32
Date: Mon, 02 Nov 2026 14:32
56 lines
6877 bytes
6877 bytes
> On Oct 30, 2026, at 2:00 PM, Romain Dolbeau <romain@dolbeau.org> wrote:
>
> The list of patches and brief description can be found here:
> <https://github.com/MelkhiorVintageComputing/netbsd-litex-m68k/blob/litex68k/UPSTREAM.md>
> (beware: LLM-generated).
Ok, spent some time thinking about: 2.2 Kernel profiling (config -p) faults in __mcount (UP)
The shared m68k kernel Makefile machinery now automagically sets -fno-omit-frame-pointer if any of profiling, DDB, or KGDB are enabled. Previously, this was done piecemeal in individual kernel config files, and never for when profiling was enabled.
Now I’m ruminating about the kernel frame pointer sentinel. Contrary you what your issue says ("locore never sets %a6”), at least *some* of them so, and I am pretty sure I fixed all of them during The Great Refactor post-11. Example in virt68k:
Lmmuenabled:
lea _ASM_LABEL(tmpstk),%sp | re-load the temporary stack
jbsr _C_LABEL(vec_init) | initialize the vector table
/* phase 2 of pmap setup, returns lwp0 SP in %a0 */
jbsr _C_LABEL(pmap_bootstrap2)
movl %a0,%sp | now running on lwp0's stack
movl #0,%a6 | terminate the stack back trace
Granted, it’s not necessarily in the *right place* (pmap_bootstrap2() is not a no-instrument function and so profiling would blow up there), but based on what mcount (look one frame up to get the previous return address, which represents “frompc”), there actually needs to be *two* dummy frames, because the final frame in the chain must have a saved-%a6 of 0, because that’s the real sentinel for stack-unwinds. But obviously you can’t deref 0, so there has to be something else there to absorb mcount’s load.
Have I missed something?
Anyway, my solution will probably be to have a SET_KSTACK() macro in asm.h that alters its behavior on the presence of GPROF, and change all the places that fiddle with the early boot stack to use it.
Hm, I gonna have think a little more about cpu_lwp_fork() and this scenario.
-- thorpej
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: Some fixes for m68k users (incl/ for FPU emulation)
Author: Jason Thorpe
Date: Mon, 02 Nov 2026 18:48
Date: Mon, 02 Nov 2026 18:48
55 lines
5828 bytes
5828 bytes
> On Nov 2, 2026, at 9:32 AM, Jason Thorpe <thorpej@me.com> wrote:
>
> Have I missed something?
Ok, I’m waiting to catch a plane, so I sketched out by hand what I think happens:
SP -> TOP OF STACK A6=0
-- call function1 --
TOP OF STACK SP-> return address0 A6=0
-- function1 prof-prologue link %a6,#0 --
TOP OF STACK
return address0
SP-> saved A6 -> 0 A6=SP1
-- function1 prof-prologue jbsr __mcount --
TOP OF STACK
return address0
saved A6 -> 0 A6=SP1
SP-> return address1
-- __mcount prologue link %a6,#0 --
TOP OF STACK
return address0
saved A6 -> 0 SP1
return address1
SP-> saved A6 -> SP1 A6=SP2
__mcount then does (effectively - written as it is on the 68010 because it lacks the indirect addressing mode that 68020+ are using):
movl %a6@(4) -> selfpc -- that's SP2@4 -> return address1
movl %a6@(0),%a0 -- %a0 = SP1
movl %a0@(4) -> frompc -- that's SP1@4 -> return address0
So, I’m having trouble seeing where things are going off the rails… both of those frame-pointer relative loads should point to valid stack addresses.
Again, am I missing something?
-- thorpej
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads