* [PATCH 0/2] Make sun3 work again.
@ 2026-09-24 11:18 Daniel Palmer
2026-09-24 11:18 ` [PATCH 1/2] m68k: sun3: register RAM with memblock and set the low pfn limits Daniel Palmer
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Palmer @ 2026-09-24 11:18 UTC (permalink / raw)
To: sammy, geert, linux-m68k; +Cc: linux-kernel, Daniel Palmer
Short version: Have a QEMU fork that can emulate all of the supported
m68k machines via the magic of LLM. LLM also fixed the ones that had
bit rotten. This series makes sun3 work again. Commits are cleaned
up but I have intentially left most of the comments intact as the LLM
debugged it not me.
Longer version:
I am reworking some stuff in my m68k tree and have added SMP etc.
I wanted something to test I haven't regressed all of the other
machines so I gave claude the qemu and kernel sources and told
it "emulate all of the supported m68k machines, try to boot
their native OS first, netbsd if there is a port and then linux."
It took a few weeks from what I remember (emulating 030 macs is
hard apparently...) but it was able to do it mostly. Some of the
natives OSes use the MMU in weird ways and it gave up trying to
model some of that in QEMU. It's pretty sure it can boot Linux
on anything with an m68k CPU now. It even created Palm Pilot
emulators and tested the 68000 Palm Pilot support.
While doing the QEMU work it also fixed up some of the machines
so they work again. I sent a patch for Apollo a few weeks ago.
This series fixes sun3 to the point you should be able to get
something to print out over serial.
With some further patches to add a real serial driver and
it gets to my nolibc based userspace:
https://gist.github.com/fifteenhex/e97322216d5e85e7a54a2adfcba08e32
The real serial driver is a lot of code so I have kept that
out of this series.
Daniel Palmer (2):
m68k: sun3: register RAM with memblock and set the low pfn limits
m68k: sun3: add an early boot console over the PROM
arch/m68k/sun3/config.c | 46 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] m68k: sun3: register RAM with memblock and set the low pfn limits
2026-09-24 11:18 [PATCH 0/2] Make sun3 work again Daniel Palmer
@ 2026-09-24 11:18 ` Daniel Palmer
2026-09-24 11:18 ` [PATCH 2/2] m68k: sun3: add an early boot console over the PROM Daniel Palmer
2026-09-24 11:32 ` [PATCH 0/2] Make sun3 work again John Paul Adrian Glaubitz
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Palmer @ 2026-09-24 11:18 UTC (permalink / raw)
To: sammy, geert, linux-m68k; +Cc: linux-kernel, Daniel Palmer
The sun3 memory init never talked to memblock, so paging_init() and the
first slab allocation found no memory at all:
* register physical RAM with memblock_add() and reserve the kernel
image (and embedded initramfs) below memory_start. The generic
m68k_setup_node() no longer does this, and sun3's paging_init()
allocates its page tables straight out of memblock, so without it
memblock is empty and paging_init() panics;
* memblock_set_bottom_up(true): paging_init() runs while only the low
RAM the PROM handed us is mapped, so its page-table allocations must
come from just above the kernel rather than the unmapped top of RAM;
* set min_low_pfn/max_low_pfn: memblock_free_all() clamps the pages it
releases into the buddy allocator to [min_low_pfn, max_low_pfn); with
them left 0 the whole of RAM stayed reserved and the first slab
allocation BUG'd.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
arch/m68k/sun3/config.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/arch/m68k/sun3/config.c b/arch/m68k/sun3/config.c
index cd8af809e0ca..cb4e19b95a1b 100644
--- a/arch/m68k/sun3/config.c
+++ b/arch/m68k/sun3/config.c
@@ -118,6 +118,30 @@ static void __init sun3_bootmem_alloc(unsigned long memory_start,
high_memory = (void *)memory_end;
availmem = memory_start;
+ /*
+ * memblock_free_all() clamps the pages it releases into the buddy
+ * allocator to [min_low_pfn, max_low_pfn); without these set the
+ * whole of RAM stays reserved and the first slab allocation fails.
+ */
+ min_low_pfn = __pa(memory_start) >> PAGE_SHIFT;
+ max_low_pfn = max_pfn;
+
+ /*
+ * Register physical RAM with memblock and reserve the kernel image
+ * (and the embedded initramfs) below memory_start. The generic
+ * m68k_setup_node() no longer does this, and sun3's paging_init()
+ * allocates its page tables straight out of memblock, so without
+ * this memblock is empty and paging_init() panics.
+ */
+ memblock_add(0, __pa(memory_end));
+ memblock_reserve(0, __pa(memory_start));
+ /*
+ * paging_init() runs while only the low RAM the PROM handed us is
+ * mapped, so its page-table allocations must come from just above
+ * the kernel (bottom-up) rather than the unmapped top of RAM.
+ */
+ memblock_set_bottom_up(true);
+
m68k_setup_node(0);
}
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] m68k: sun3: add an early boot console over the PROM
2026-09-24 11:18 [PATCH 0/2] Make sun3 work again Daniel Palmer
2026-09-24 11:18 ` [PATCH 1/2] m68k: sun3: register RAM with memblock and set the low pfn limits Daniel Palmer
@ 2026-09-24 11:18 ` Daniel Palmer
2026-09-24 11:32 ` [PATCH 0/2] Make sun3 work again John Paul Adrian Glaubitz
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Palmer @ 2026-09-24 11:18 UTC (permalink / raw)
To: sammy, geert, linux-m68k; +Cc: linux-kernel, Daniel Palmer
Register a CON_BOOT console that writes through the resident PROM's
polled character output (prom_putchar()).
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
arch/m68k/sun3/config.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/m68k/sun3/config.c b/arch/m68k/sun3/config.c
index cb4e19b95a1b..49821c28a641 100644
--- a/arch/m68k/sun3/config.c
+++ b/arch/m68k/sun3/config.c
@@ -145,11 +145,33 @@ static void __init sun3_bootmem_alloc(unsigned long memory_start,
m68k_setup_node(0);
}
+/* Early boot console over the resident PROM's polled character output. */
+static void sun3_early_console_write(struct console *con, const char *s,
+ unsigned int n)
+{
+ while (n-- > 0) {
+ if (*s == '\n')
+ prom_putchar('\r');
+ prom_putchar(*s++);
+ }
+}
+
+static struct console sun3_early_console = {
+ .name = "sun3prom",
+ .write = sun3_early_console_write,
+ .flags = CON_PRINTBUFFER | CON_BOOT,
+ .index = -1,
+};
void __init config_sun3(void)
{
unsigned long memory_start, memory_end;
+ if (!sun3_early_console.data) {
+ sun3_early_console.data = &sun3_early_console;
+ register_console(&sun3_early_console);
+ }
+
pr_info("ARCH: SUN3\n");
idprom_init();
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Make sun3 work again.
2026-09-24 11:18 [PATCH 0/2] Make sun3 work again Daniel Palmer
2026-09-24 11:18 ` [PATCH 1/2] m68k: sun3: register RAM with memblock and set the low pfn limits Daniel Palmer
2026-09-24 11:18 ` [PATCH 2/2] m68k: sun3: add an early boot console over the PROM Daniel Palmer
@ 2026-09-24 11:32 ` John Paul Adrian Glaubitz
2 siblings, 0 replies; 4+ messages in thread
From: John Paul Adrian Glaubitz @ 2026-09-24 11:32 UTC (permalink / raw)
To: Daniel Palmer, sammy, geert, linux-m68k; +Cc: linux-kernel
Hi Daniel,
On Thu, 2026-09-24 at 20:18 +0900, Daniel Palmer wrote:
> Short version: Have a QEMU fork that can emulate all of the supported
> m68k machines via the magic of LLM. LLM also fixed the ones that had
> bit rotten. This series makes sun3 work again. Commits are cleaned
> up but I have intentially left most of the comments intact as the LLM
> debugged it not me.
Very cool! Thanks a lot for working on this and resurrecting sun-3!
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-24 11:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 11:18 [PATCH 0/2] Make sun3 work again Daniel Palmer
2026-09-24 11:18 ` [PATCH 1/2] m68k: sun3: register RAM with memblock and set the low pfn limits Daniel Palmer
2026-09-24 11:18 ` [PATCH 2/2] m68k: sun3: add an early boot console over the PROM Daniel Palmer
2026-09-24 11:32 ` [PATCH 0/2] Make sun3 work again John Paul Adrian Glaubitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®