Implement missing functionality and hooks in m68k to support upcoming Sun-3 implementation
v5 cover Implement missing functionality and hooks in m68k to support upcoming Sun-3 implementation
This series adds M68020/030-specific features to the m68k target that are required by the Sun-3 machine (series C) and its PROM/SunOS guests:
1/6: CAAR register stub for 68020/030 cache control 2/6: fsave/frestore fix for 68881 (non-68040) FPU frames 3/6: Edge-triggered NMI semantics for Level 7 interrupts 4/6: Function code extraction during TLB fills
5/6: Custom MMU intercept hook for Sun-3 transparent translation 6/6: Physical Bus Error and M68020 Format 0xB stack frames
Changes since v4:
- Added Signed-off-by to all patches.
- Patch 2/6 (fsave): Addressed Zoltan's review — replaced redundant M68040||FPU check with just M68K_FEATURE_FPU, removed unnecessary if/else in frestore, moved Context: below --- separator.
- Patch 3/6 (NMI): Addressed Zoltan's review — nmi_pending cannot be replaced by testing pending_level == 7. The flag captures the edge transition (level < 7 → 7) required by Motorola's NMI specification, while pending_level only reflects the current interrupt level. Testing pending_level alone would produce level-triggered behavior, firing on every interrupt check rather than once per edge.
- Rebased on current master.
54weasels (6):
target/m68k: Add dummy CAAR register target/m68k: Fix fsave/frestore for 68881 FPU target/m68k: Fix NMI pending for Level 7 interrupts target/m68k: Extract Function Codes during TLB fills target/m68k: Implement custom MMU intercept hook target/m68k: Implement Physical Bus Error and Stack
target/m68k/cpu.c | 4 +- target/m68k/cpu.h | 21 ++++- target/m68k/helper.c | 130 ++++++++++++++++++++++++++++- target/m68k/op_helper.c | 175 ++++++++++++++++++++++++++-------------- target/m68k/translate.c | 30 ++++--- 5 files changed, 280 insertions(+), 80 deletions(-)
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v5 3/6 target/m68k: Fix NMI pending for Level 7 interrupts
Why this change is made & How it will be used:
Level 7 interrupts are Non-Maskable Interrupts (NMI) on the M68k architecture. The hardware asserts an NMI only on the rising edge of the level 7 signal. The current QEMU implementation treats level 7 like a standard level interrupt. This patch ensures proper NMI edge-triggered semantics for level 7, which is strictly required by the Sun-3 keyboard/mouse NMI routing logic.
Impact on existing functionality:
Corrects NMI edge-triggering for all M68k boards, adhering closely to the Motorola specifications. Existing boards will now correctly require an edge transition to trigger consecutive NMIs.
--- target/m68k/cpu.h | 4 ++++ target/m68k/helper.c | 6 ++++++ target/m68k/op_helper.c | 14 ++++++-------- 3 files changed, 16 insertions(+), 8 deletions(-)
target/m68k/cpu.h +4 -0
@@ -25,6 +25,9 @@#include "exec/cpu-interrupt.h" #include "qemu/cpu-float.h" #include "cpu-qom.h" +#include "exec/cpu-defs.h" + +#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_1#define OS_BYTE 0#define OS_WORD 1
@@ -148,6 +151,7 @@ typedef struct CPUArchState {int pending_vector;int pending_level; +bool nmi_pending;/* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields;
target/m68k/helper.c +6 -0
@@ -949,6 +949,12 @@ void m68k_set_irq_level(M68kCPU *cpu, int level, uint8_t vector)CPUState *cs =CPU (cpu);CPUM68KState *env = &cpu->env; +if (level ==7 && env->pending_level !=7 ) { + env->nmi_pending = true; + }else if (level !=7 ) { + env->nmi_pending = false; + } + env->pending_level = level; env->pending_vector = vector;if (level) {
target/m68k/op_helper.c +6 -8
@@ -522,14 +522,12 @@ bool m68k_cpu_exec_interrupt(CPUState *cs, int interrupt_request) {CPUM68KState *env =cpu_env (cs); -if (interrupt_request &CPU_INTERRUPT_HARD - && ((env->sr &SR_I ) >>SR_I_SHIFT ) < env->pending_level) { -/* -* Real hardware gets the interrupt vector via an IACK cycle -* at this point. Current emulated hardware doesn't rely on -* this, so we provide/save the vector when the interrupt is -* first signalled. -*/ +if (env->nmi_pending) { + env->nmi_pending = false; + cs->exception_index = env->pending_vector; +do_interrupt_m68k_hardirq (env); +return true; + }else if (((env->sr &SR_I ) >>SR_I_SHIFT ) < env->pending_level) { cs->exception_index = env->pending_vector;do_interrupt_m68k_hardirq (env);return true;
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v5 4/6 target/m68k: Extract Function Codes during TLB fills
In reply to 54weaselsWhy this change is made & How it will be used:
The Motorola 68020 architecture utilizes 3-bit Function Codes (FC0-FC2) to distinguish between User/Supervisor Data and Program memory spaces during MMU translation. Previously, QEMU's TLB fills did not explicitly extract or pass these codes down to the translation hooks. This patch extracts the explicit Function Codes (either natively or via the moves instruction) and packs them into the access_type field. This is required for the upcoming Sun-3 emulation, whose external MMU hardware maps entirely different physical address spaces depending on the Function Code asserted on the bus.
Impact on existing functionality:
This change introduces no functional impact to existing ColdFire or Mac/Quadra m68k emulation targets. The extraction logic gracefully defaults to standard mapping modes for platforms that do not implement a custom MMU intercept hook, preserving existing TLB behavior.
--- target/m68k/cpu.c | 4 ++-- target/m68k/cpu.h | 10 ++++++---- target/m68k/helper.c | 26 ++++++++++++++++++++++++++ target/m68k/translate.c | 10 ++++++---- 4 files changed, 40 insertions(+), 10 deletions(-)
target/m68k/cpu.c +2 -2
@@ -52,8 +52,8 @@ static TCGTBCPUState m68k_get_tb_cpu_state(CPUState *cs) flags = (env->macsr >>4 ) &TB_FLAGS_MACSR ;if (env->sr &SR_S ) { flags |=TB_FLAGS_MSR_S ; - flags |= (env->sfc << (TB_FLAGS_SFC_S_BIT -2 )) &TB_FLAGS_SFC_S ; - flags |= (env->dfc << (TB_FLAGS_DFC_S_BIT -2 )) &TB_FLAGS_DFC_S ; + flags |= (env->sfc <<TB_FLAGS_SFC_S_BIT ) &TB_FLAGS_SFC_S ; + flags |= (env->dfc <<TB_FLAGS_DFC_S_BIT ) &TB_FLAGS_DFC_S ; }if (M68K_SR_TRACE (env->sr) ==M68K_SR_TRACE_ANY_INS ) { flags |=TB_FLAGS_TRACE ;
target/m68k/cpu.h +6 -4
@@ -604,12 +604,14 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,#define TB_FLAGS_MSR_S_BIT 13#define TB_FLAGS_MSR_S (1 << TB_FLAGS_MSR_S_BIT)#define TB_FLAGS_SFC_S_BIT 14 -#define TB_FLAGS_SFC_S (1 << TB_FLAGS_SFC_S_BIT) -#define TB_FLAGS_DFC_S_BIT 15 -#define TB_FLAGS_DFC_S (1 << TB_FLAGS_DFC_S_BIT) -#define TB_FLAGS_TRACE 16 +#define TB_FLAGS_SFC_S (7 << TB_FLAGS_SFC_S_BIT)/* 3 Bits reserved */ +#define TB_FLAGS_DFC_S_BIT 17 +#define TB_FLAGS_DFC_S (7 << TB_FLAGS_DFC_S_BIT)/* 3 Bits reserved */ +#define TB_FLAGS_TRACE 20#define TB_FLAGS_TRACE_BIT (1 << TB_FLAGS_TRACE) +#define MMU_MOVES_FC_BASE 2/* mmu_idx 2-9 correspond to FC 0-7 */ +void dump_mmu (CPUM68KState *env);#endif
target/m68k/helper.c +26 -0
@@ -975,6 +975,32 @@ bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size,int ret;target_ulong page_size; +if (qemu_access_type ==MMU_INST_FETCH ) { + access_type =ACCESS_CODE ; + }else { + access_type =ACCESS_DATA ; +if (qemu_access_type ==MMU_DATA_STORE ) { + access_type |=ACCESS_STORE ; + } + } + +/* Decode explicit Function Codes from moves instructions */ +if (mmu_idx >=MMU_MOVES_FC_BASE ) { +uint8_t fc = mmu_idx -MMU_MOVES_FC_BASE ; + access_type |= (fc <<8 );/* Pack explicit FC into access type */ +if (fc !=1 && fc !=2 ) { + access_type |=ACCESS_SUPER ; + } + }else { +/* Standard memory accesses map logically to normal M68K FCs */ +if (mmu_idx ==MMU_KERNEL_IDX ) { + access_type |=ACCESS_SUPER ; + access_type |= ((qemu_access_type ==MMU_INST_FETCH ?6 :5 ) <<8 ); + }else { + access_type |= ((qemu_access_type ==MMU_INST_FETCH ?2 :1 ) <<8 ); + } + } +if ((env->mmu.tcr &M68K_TCR_ENABLED ) ==0 ) {/* MMU disabled */ tlb_set_page(cs, address & TARGET_PAGE_MASK,
target/m68k/translate.c +6 -4
@@ -163,10 +163,12 @@ static void do_writebacks(DisasContext *s)#define IS_USER (s) 1#else #define IS_USER (s) (!(s->base.tb->flags & TB_FLAGS_MSR_S)) -#define SFC_INDEX (s) ((s->base.tb->flags & TB_FLAGS_SFC_S) ? \ - MMU_KERNEL_IDX : MMU_USER_IDX) -#define DFC_INDEX (s) ((s->base.tb->flags & TB_FLAGS_DFC_S) ? \ - MMU_KERNEL_IDX : MMU_USER_IDX) +#define SFC_INDEX (s) (MMU_MOVES_FC_BASE + \ + (((s)->base.tb->flags & TB_FLAGS_SFC_S) >> \ + TB_FLAGS_SFC_S_BIT)) +#define DFC_INDEX (s) (MMU_MOVES_FC_BASE + \ + (((s)->base.tb->flags & TB_FLAGS_DFC_S) >> \ + TB_FLAGS_DFC_S_BIT))#endif typedef void (*disas_proc )(CPUM68KState *env,DisasContext *s,uint16_t insn);
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v5 5/6 target/m68k: Implement custom MMU intercept hook
In reply to 54weaselsWhy this change is made & How it will be used:
Boards like the Sun-3 use an external custom MMU logic array rather than the standard 68851/68030 embedded MMU. This patch introduces a custom_mmu_get_physical_address opaque hook, allowing board initialization code to intercept TLB fills and delegate translation directly to the machine's external MMU implementation.
Impact on existing functionality:
Zero impact on existing boards. If the hook is not explicitly registered by the board initialization code, the standard 68k MMU translation pipeline executes normally.
--- target/m68k/cpu.h | 7 ++++ target/m68k/helper.c | 89 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+)
target/m68k/cpu.h +7 -0
@@ -156,6 +156,13 @@ typedef struct CPUArchState {/* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; +/* Custom MMU intercept logic, if any (e.g. for Sun-3) */ +void *custom_mmu_opaque; +int (*custom_mmu_get_physical_address)(void *env,hwaddr *physical, +int *prot,vaddr address, +int access_type, +hwaddr *page_size); +/* Fields from here on are preserved across CPU reset. */ uint64_t features; } CPUM68KState;
target/m68k/helper.c +89 -0
101 lines not on this page · raw message
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v5 2/6 target/m68k: Fix fsave/frestore for 68881 FPU
In reply to 54weaselsWhy this change is made & How it will be used:
The 68881/68882 FPUs require fsave/frestore instructions to read/write state frames. QEMU only fully implemented this for the 68040. The Sun-3 uses a 68881 FPU, and the boot ROM executes fsave to probe FPU presence. This patch adds basic 68881 FPU state frame handling (NULL frame) to accurately simulate an idle FPU state.
Impact on existing functionality:
Fixes FPU detection for 68881/68882 across all M68k boards without affecting 68040 specific state logic.
--- target/m68k/translate.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
target/m68k/translate.c +13 -7
@@ -5364,11 +5364,11 @@ DISAS_INSN(frestore)gen_exception (s, s->base.pc_next,EXCP_PRIVILEGE );return ; } -if (m68k_feature (s->env,M68K_FEATURE_M68040 )) { +if (m68k_feature (s->env,M68K_FEATURE_FPU )) {SRC_EA (env, addr,OS_LONG ,0 ,NULL );/* FIXME: check the state frame */ }else { -disas_undef (env, s, insn); +disas_undef_fpu (env, s, insn); } }
@@ -5379,12 +5379,18 @@ DISAS_INSN(fsave) return; } -if (m68k_feature (s->env,M68K_FEATURE_M68040 )) { -/* always write IDLE */ -TCGv idle =tcg_constant_i32 (0x41000000 ); -DEST_EA (env, insn,OS_LONG , idle,NULL ); +if (m68k_feature (s->env,M68K_FEATURE_FPU )) { +TCGv frame; +if (m68k_feature (s->env,M68K_FEATURE_M68040 )) { +/* 68040 FSAVE: always write IDLE */ + frame =tcg_constant_i32 (0x41000000 ); + }else { +/* 68881/68882 FSAVE: always write NULL frame */ + frame =tcg_constant_i32 (0x00000000 ); + } +DEST_EA (env, insn,OS_LONG , frame,NULL ); }else { -disas_undef (env, s, insn); +disas_undef_fpu (env, s, insn); } }#endif
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v5 6/6 target/m68k: Implement Physical Bus Error and Stack
In reply to 54weaselsWhy this change is made & How it will be used:
Physical memory timeouts (e.g., probing unpopulated memory locations) must generate a Bus Error exception, resulting in Format 0xA or 0xB stack frames on the 68020. The Sun-3 PROM probes memory sizes by intentionally causing bus errors and analyzing the Special Status Word (SSW) on the stack frame. This patch implements hardware-injected EXCP_ACCESS cycle generation and the corresponding 84-byte long stack frame teardown.
Impact on existing functionality:
Accurately populates the 68020 84-byte SSW stack frames. Older architectures (like 68000) safely ignore the hook and gracefully exit without generating the advanced frames.
--- target/m68k/helper.c | 1 + target/m68k/op_helper.c | 161 +++++++++++++++++++++++++++------------- 2 files changed, 109 insertions(+), 53 deletions(-)
target/m68k/helper.c +1 -0
@@ -29,6 +29,7 @@#include "system/memory.h" #include "gdbstub/helpers.h" #include "fpu/softfloat.h" +#include "qemu/log.h" #include "qemu/qemu-print.h" #define SIGNBIT (1u << 31)
target/m68k/op_helper.c +108 -53
195 lines not on this page · raw message
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v5 1/6 target/m68k: Add dummy CAAR register
In reply to 54weaselsWhy this change is made & How it will be used:
The Sun-3 ROM expects the Cache Control Register (CAAR) to exist on the 68020. Reading/writing this register currently aborts QEMU. This patch provides a dummy implementation that simply ignores writes and returns 0 on reads, allowing the ROM to continue booting.
Impact on existing functionality:
No impact on existing targets. ColdFire and Mac targets do not access CAAR in a way that currently aborts, and providing a safe dummy implementation ensures robustness across M68k boards.
--- target/m68k/helper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
target/m68k/helper.c +6 -2
@@ -281,8 +281,10 @@ void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)return ; }break ; -/* Unimplemented Registers */ +/* Dummy implementation for CAAR */ case M68K_CR_CAAR : +return ; +/* Unimplemented Registers */ case M68K_CR_PCR :case M68K_CR_BUSCR : cpu_abort(env_cpu(env),
@@ -385,8 +387,10 @@ uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg)return env->mmu.ttr[M68K_DTTR1 ]; }break ; -/* Unimplemented Registers */ +/* Dummy implementation for CAAR */ case M68K_CR_CAAR : +return 0 ; +/* Unimplemented Registers */ case M68K_CR_PCR :case M68K_CR_BUSCR : cpu_abort(env_cpu(env), "Unimplemented control register read 0x%x\n",
Signature · 1 line
2.50.1 (Apple Git-155)
Gentle ping on this series. v5 addresses Zoltan's review feedback from v4 (fsave simplification, NMI edge-trigger rationale, added Signed-off-by). Would appreciate any review when you have a chance.
Dan.
Quoted 42 lines · On Wed, Sep 2, 2026 at 9:46 PM 54weasels <[email protected]> wrote:
This series adds M68020/030-specific features to the m68k target that are required by the Sun-3 machine (series C) and its PROM/SunOS guests:
1/6: CAAR register stub for 68020/030 cache control 2/6: fsave/frestore fix for 68881 (non-68040) FPU frames 3/6: Edge-triggered NMI semantics for Level 7 interrupts 4/6: Function code extraction during TLB fills
5/6: Custom MMU intercept hook for Sun-3 transparent translation 6/6: Physical Bus Error and M68020 Format0xBstack framesChanges since v4:
- Added Signed-off-by to all patches.
- Patch 2/6 (fsave): Addressed Zoltan's review — replaced redundant M68040||FPU check with justM68K_FEATURE_FPU, removed unnecessary if/else in frestore, moved Context: below --- separator.
- Patch 3/6 (NMI): Addressed Zoltan's review —nmi_pendingcannot be replaced by testingpending_level== 7. The flag captures the edge transition (level < 7 → 7) required by Motorola's NMI specification, whilepending_levelonly reflects the current interrupt level. Testingpending_levelalone would produce level-triggered behavior, firing on every interrupt check rather than once per edge.
- Rebased on current master.54weasels (6):
target/m68k: Add dummy CAAR register target/m68k: Fix fsave/frestore for 68881 FPU target/m68k: Fix NMI pending for Level 7 interrupts target/m68k: Extract Function Codes during TLB fills target/m68k: Implement custom MMU intercept hook target/m68k: Implement Physical Bus Error and Stacktarget/m68k/cpu.c | 4 +- target/m68k/cpu.h | 21 ++++- target/m68k/helper.c | 130 ++++++++++++++++++++++++++++- target/m68k/op_helper.c | 175 ++++++++++++++++++++++++++-------------- target/m68k/translate.c | 30 ++++--- 5 files changed, 280 insertions(+), 80 deletions(-)--
2.50.1 (Apple Git-155)
Quoted 1 line · Purr Box
Gentle ping on this series. v5 addresses Zoltan's review feedback from v4 (fsave simplification, NMI edge-trigger rationale, added Signed-off-by). Would appreciate any review when you have a chance.
Apologies for the delay: I will have quick look through the series over the next few days, although I suspect I'd need to defer to Laurent's greater 68k knowledge here.
Quoted 42 lines
Dan.
On Wed, Sep 2, 2026 at 9:46 PM 54weasels <[email protected] <mailto:[email protected]>> wrote:
This series adds M68020/030-specific features to the m68k target that are required by the Sun-3 machine (series C) and its PROM/SunOS guests:
1/6: CAAR register stub for 68020/030 cache control 2/6: fsave/frestore fix for 68881 (non-68040) FPU frames 3/6: Edge-triggered NMI semantics for Level 7 interrupts 4/6: Function code extraction during TLB fills
5/6: Custom MMU intercept hook for Sun-3 transparent translation 6/6: Physical Bus Error and M68020 Format0xBstack framesChanges since v4:
- Added Signed-off-by to all patches.
- Patch 2/6 (fsave): Addressed Zoltan's review — replaced redundant M68040||FPU check with justM68K_FEATURE_FPU, removed unnecessary if/else in frestore, moved Context: below --- separator.
- Patch 3/6 (NMI): Addressed Zoltan's review —nmi_pendingcannot be replaced by testingpending_level== 7. The flag captures the edge transition (level < 7 → 7) required by Motorola's NMI specification, whilepending_levelonly reflects the current interrupt level. Testingpending_levelalone would produce level-triggered behavior, firing on every interrupt check rather than once per edge.
- Rebased on current master.54weasels (6):
target/m68k: Add dummy CAAR register target/m68k: Fix fsave/frestore for 68881 FPU target/m68k: Fix NMI pending for Level 7 interrupts target/m68k: Extract Function Codes during TLB fills target/m68k: Implement custom MMU intercept hook target/m68k: Implement Physical Bus Error and Stacktarget/m68k/cpu.c | 4 +-
target/m68k/cpu.h | 21 ++++-
target/m68k/helper.c | 130 ++++++++++++++++++++++++++++-target/m68k/op_helper.c| 175 ++++++++++++++++++++++++++--------------target/m68k/translate.c| 30 ++++---
5 files changed, 280 insertions(+), 80 deletions(-)
Quoted 2 lines
--
2.50.1 (Apple Git-155)
ATB,
Mark.
Thank you very much in advance! I'm looking forward to getting sun3 supported.
Dan.
Quoted 73 lines · Mark Cave-Ayland
Quoted 1 line · Purr Box
Gentle ping on this series. v5 addresses Zoltan's review feedback from
v4 (fsave
Quoted 1 line
simplification, NMI edge-trigger rationale, added Signed-off-by). Would
appreciate
Quoted 1 line
any review when you have a chance.
Apologies for the delay: I will have quick look through the series over the next few
days, although I suspect I'd need to defer to Laurent's greater 68k knowledge here.Quoted 7 lines
Dan.
On Wed, Sep 2, 2026 at 9:46 PM 54weasels <[email protected] <mailto:[email protected]>> wrote:
This series adds M68020/030-specific features to the m68k target that are required by the Sun-3 machine (series C) and its PROM/SunOS
guests:
Quoted 11 lines
1/6: CAAR register stub for 68020/030 cache control 2/6: fsave/frestore fix for 68881 (non-68040) FPU frames 3/6: Edge-triggered NMI semantics for Level 7 interrupts 4/6: Function code extraction during TLB fills
5/6: Custom MMU intercept hook for Sun-3 transparent translation 6/6: Physical Bus Error and M68020 Format0xBstack framesChanges since v4:
- Added Signed-off-by to all patches.
- Patch 2/6 (fsave): Addressed Zoltan's review — replacedredundant
Quoted 1 line
M68040||FPU check with just M68K_FEATURE_FPU, removedunnecessary
Quoted 2 lines
if/else in frestore, moved Context: below --- separator.
- Patch 3/6 (NMI): Addressed Zoltan's review —nmi_pendingcannotbe
Quoted 1 line
replaced by testing pending_level == 7. The flag captures theedge
Quoted 1 line
transition (level < 7 → 7) required by Motorola's NMI
specification,
Quoted 2 lines
while
pending_levelonly reflects the current interrupt level. Testingpending_levelalone would produce level-triggeredbehavior,
Quoted 11 lines
firing on every interrupt check rather than once per edge.
- Rebased on current master.54weasels (6):
target/m68k: Add dummy CAAR register target/m68k: Fix fsave/frestore for 68881 FPU target/m68k: Fix NMI pending for Level 7 interrupts target/m68k: Extract Function Codes during TLB fills target/m68k: Implement custom MMU intercept hook target/m68k: Implement Physical Bus Error and StackQuoted 4 lines
target/m68k/cpu.c| 4 +-
target/m68k/cpu.h| 21 ++++-
target/m68k/helper.c| 130 ++++++++++++++++++++++++++++-
target/m68k/op_helper.c| 175++++++++++++++++++++++++++--------------
Quoted 5 lines
target/m68k/translate.c | 30 ++++--- 5 files changed, 280 insertions(+), 80 deletions(-)-- 2.50.1 (Apple Git-155)ATB,
Mark.
Hi and quick ping if you could take a look at the series.
Thanks,
Dan.
Quoted 82 lines · Purr Box
Thank you very much in advance! I'm looking forward to getting sun3 supported.
Dan.
Quoted 74 lines · Mark Cave-Ayland
Quoted 1 line · Purr Box
Gentle ping on this series. v5 addresses Zoltan's review feedback from
v4 (fsave
Quoted 1 line
simplification, NMI edge-trigger rationale, added Signed-off-by). Would
appreciate
Quoted 1 line
any review when you have a chance.
Apologies for the delay: I will have quick look through the series over the next few
days, although I suspect I'd need to defer to Laurent's greater 68k knowledge here.Quoted 6 lines
Dan.
On Wed, Sep 2, 2026 at 9:46 PM 54weasels <[email protected] <mailto:[email protected]>> wrote:
This series adds M68020/030-specific features to the m68k target
that
Quoted 1 line
are required by the Sun-3 machine (series C) and its PROM/SunOS
guests:
Quoted 11 lines
1/6: CAAR register stub for 68020/030 cache control 2/6: fsave/frestore fix for 68881 (non-68040) FPU frames 3/6: Edge-triggered NMI semantics for Level 7 interrupts 4/6: Function code extraction during TLB fills
5/6: Custom MMU intercept hook for Sun-3 transparent translation 6/6: Physical Bus Error and M68020 Format0xBstack framesChanges since v4:
- Added Signed-off-by to all patches.
- Patch 2/6 (fsave): Addressed Zoltan's review — replacedredundant
Quoted 1 line
M68040||FPU check with just M68K_FEATURE_FPU, removedunnecessary
Quoted 2 lines
if/else in frestore, moved Context: below --- separator.
- Patch 3/6 (NMI): Addressed Zoltan's review —nmi_pendingcannot be
Quoted 1 line
replaced by testing pending_level == 7. The flag captures theedge
Quoted 1 line
transition (level < 7 → 7) required by Motorola's NMI
specification,
Quoted 2 lines
while
pending_levelonly reflects the current interrupt level. Testingpending_levelalone would produce level-triggeredbehavior,
Quoted 11 lines
firing on every interrupt check rather than once per edge.
- Rebased on current master.54weasels (6):
target/m68k: Add dummy CAAR register target/m68k: Fix fsave/frestore for 68881 FPU target/m68k: Fix NMI pending for Level 7 interrupts target/m68k: Extract Function Codes during TLB fills target/m68k: Implement custom MMU intercept hook target/m68k: Implement Physical Bus Error and StackQuoted 4 lines
target/m68k/cpu.c| 4 +-
target/m68k/cpu.h| 21 ++++-
target/m68k/helper.c| 130 ++++++++++++++++++++++++++++-
target/m68k/op_helper.c| 175++++++++++++++++++++++++++--------------
Quoted 5 lines
target/m68k/translate.c | 30 ++++--- 5 files changed, 280 insertions(+), 80 deletions(-)-- 2.50.1 (Apple Git-155)ATB,
Mark.
Hi folks - gentle ping. After the 68k patches it's all other devices so the patch train should move easier. I also have SCSI support and others pending.
Thank you very much in advance,
Dan.
Quoted 89 lines · On Sat, Sep 26, 2026, 09:30 Purr Box <[email protected]> wrote:
Hi and quick ping if you could take a look at the series.
Thanks,
Dan.Quoted 82 lines · Purr Box
Thank you very much in advance! I'm looking forward to getting sun3 supported.
Dan.
Quoted 74 lines · Mark Cave-Ayland
Quoted 1 line · Purr Box
Gentle ping on this series. v5 addresses Zoltan's review feedback from
v4 (fsave
Quoted 1 line
simplification, NMI edge-trigger rationale, added Signed-off-by).
Would appreciate
Quoted 1 line
any review when you have a chance.
Apologies for the delay: I will have quick look through the series over the next few
days, although I suspect I'd need to defer to Laurent's greater 68k knowledge here.Quoted 6 lines
Dan.
On Wed, Sep 2, 2026 at 9:46 PM 54weasels <[email protected] <mailto:[email protected]>> wrote:
This series adds M68020/030-specific features to the m68k target
that
Quoted 1 line
are required by the Sun-3 machine (series C) and its PROM/SunOS
guests:
Quoted 11 lines
1/6: CAAR register stub for 68020/030 cache control 2/6: fsave/frestore fix for 68881 (non-68040) FPU frames 3/6: Edge-triggered NMI semantics for Level 7 interrupts 4/6: Function code extraction during TLB fills
5/6: Custom MMU intercept hook for Sun-3 transparent translation 6/6: Physical Bus Error and M68020 Format0xBstack framesChanges since v4:
- Added Signed-off-by to all patches.
- Patch 2/6 (fsave): Addressed Zoltan's review — replacedredundant
Quoted 1 line
M68040||FPU check with just M68K_FEATURE_FPU, removedunnecessary
Quoted 2 lines
if/else in frestore, moved Context: below --- separator.
- Patch 3/6 (NMI): Addressed Zoltan's review —nmi_pendingcannot be
Quoted 1 line
replaced by testing pending_level == 7. The flag captures theedge
Quoted 1 line
transition (level < 7 → 7) required by Motorola's NMI
specification,
Quoted 2 lines
while
pending_levelonly reflects the current interrupt level. Testingpending_levelalone would produce level-triggeredbehavior,
Quoted 11 lines
firing on every interrupt check rather than once per edge.
- Rebased on current master.54weasels (6):
target/m68k: Add dummy CAAR register target/m68k: Fix fsave/frestore for 68881 FPU target/m68k: Fix NMI pending for Level 7 interrupts target/m68k: Extract Function Codes during TLB fills target/m68k: Implement custom MMU intercept hook target/m68k: Implement Physical Bus Error and StackQuoted 4 lines
target/m68k/cpu.c| 4 +-
target/m68k/cpu.h| 21 ++++-
target/m68k/helper.c| 130 ++++++++++++++++++++++++++++-
target/m68k/op_helper.c| 175++++++++++++++++++++++++++--------------
Quoted 5 lines
target/m68k/translate.c | 30 ++++--- 5 files changed, 280 insertions(+), 80 deletions(-)-- 2.50.1 (Apple Git-155)ATB,
Mark.
Hi again,
Is there anything I can do to help get this reviewed more easily? I know it's a hobby, not a potentially commercial project. I appreciate the maintainers' valuable time.and genuinely would like to hear from you. If these components are frozen or in maintenance mode please let me know.
Thanks again for your help,
Dan.
Quoted 100 lines · On Sat, Oct 10, 2026, 13:04 Purr Box <[email protected]> wrote:
Hi folks - gentle ping. After the 68k patches it's all other devices so the patch train should move easier. I also have SCSI support and others pending.
Thank you very much in advance,
Dan.Quoted 91 lines · On Sat, Sep 26, 2026, 09:30 Purr Box <[email protected]> wrote:
Hi and quick ping if you could take a look at the series.
Thanks,
Dan.Quoted 84 lines · Purr Box
Thank you very much in advance! I'm looking forward to getting sun3 supported.
Dan.
Quoted 76 lines · Mark Cave-Ayland
Quoted 1 line · Purr Box
Gentle ping on this series. v5 addresses Zoltan's review feedback
from v4 (fsave
Quoted 1 line
simplification, NMI edge-trigger rationale, added Signed-off-by).
Would appreciate
Quoted 1 line
any review when you have a chance.
Apologies for the delay: I will have quick look through the series over the next few
days, although I suspect I'd need to defer to Laurent's greater 68k knowledge here.Quoted 6 lines
Dan.
On Wed, Sep 2, 2026 at 9:46 PM 54weasels <[email protected] <mailto:[email protected]>> wrote:
This series adds M68020/030-specific features to the m68k target
that
Quoted 1 line
are required by the Sun-3 machine (series C) and its PROM/SunOS
guests:
Quoted 6 lines
1/6: CAAR register stub for 68020/030 cache control 2/6: fsave/frestore fix for 68881 (non-68040) FPU frames 3/6: Edge-triggered NMI semantics for Level 7 interrupts 4/6: Function code extraction during TLB fills 5/6: Custom MMU intercept hook for Sun-3 transparent
translation
Quoted 5 lines
6/6: Physical Bus Error and M68020 Format
0xBstack framesChanges since v4:
- Added Signed-off-by to all patches.
- Patch 2/6 (fsave): Addressed Zoltan's review — replacedredundant
Quoted 1 line
M68040||FPU check with just M68K_FEATURE_FPU, removedunnecessary
Quoted 2 lines
if/else in frestore, moved Context: below --- separator.
- Patch 3/6 (NMI): Addressed Zoltan's review —nmi_pendingcannot be
Quoted 1 line
replaced by testing pending_level == 7. The flag capturesthe edge
Quoted 1 line
transition (level < 7 → 7) required by Motorola's NMI
specification,
Quoted 1 line
while
pending_levelonly reflects the current interruptlevel.
Quoted 1 line
Testing
pending_levelalone would produce level-triggeredbehavior,
Quoted 11 lines
firing on every interrupt check rather than once per edge.
- Rebased on current master.54weasels (6):
target/m68k: Add dummy CAAR register target/m68k: Fix fsave/frestore for 68881 FPU target/m68k: Fix NMI pending for Level 7 interrupts target/m68k: Extract Function Codes during TLB fills target/m68k: Implement custom MMU intercept hook target/m68k: Implement Physical Bus Error and StackQuoted 4 lines
target/m68k/cpu.c| 4 +-
target/m68k/cpu.h| 21 ++++-
target/m68k/helper.c| 130 ++++++++++++++++++++++++++++-
target/m68k/op_helper.c| 175++++++++++++++++++++++++++--------------
Quoted 5 lines
target/m68k/translate.c | 30 ++++--- 5 files changed, 280 insertions(+), 80 deletions(-)-- 2.50.1 (Apple Git-155)ATB,
Mark.
Re: [PATCH v5 1/6] target/m68k: Add dummy CAAR register
In reply to 54weaselsLe 03/09/2026 à 06:45, 54weasels a écrit :
Quoted 16 lines
Why this change is made & How it will be used:
The Sun-3 ROM expects the Cache Control Register (CAAR) to exist on the 68020. Reading/writing this register currently aborts QEMU. This patch provides a dummy implementation that simply ignores writes and returns 0 on reads, allowing the ROM to continue booting.Impact on existing functionality:
No impact on existing targets. ColdFire and Mac targets do not access CAAR in a way that currently aborts, and providing a safe dummy implementation ensures robustness across M68k boards.Signed-off-by 54weasels <[email protected]>--- target/m68k/helper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)target/m68k/helper.c +0
-0
target/m68k/helper.c void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val) · line 285
Quoted 6 lines
target/m68k/helper.c +1
-1@@ -281,8 +281,10 @@ void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)return ; }break ; -/* Unimplemented Registers */ +/* Dummy implementation for CAAR */ case M68K_CR_CAAR :
CAAR is only supported on 020 and 030, use m68k_feature() here to check them and return. Otherwise use break to go to raise_exception_ra()
target/m68k/helper.c uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg) · line 392
Quoted 13 lines
target/m68k/helper.c +4
-1+return ; +/* Unimplemented Registers */ case M68K_CR_PCR :case M68K_CR_BUSCR : cpu_abort(env_cpu(env),@@ -385,8 +387,10 @@ uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg)return env->mmu.ttr[M68K_DTTR1 ]; }break ; -/* Unimplemented Registers */ +/* Dummy implementation for CAAR */ case M68K_CR_CAAR : +return 0 ;
Same comment as for m68k_movec_to()
target/m68k/helper.c uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg) · line 396
Quoted 4 lines
target/m68k/helper.c +1
-0+/* Unimplemented Registers */ case M68K_CR_PCR :case M68K_CR_BUSCR : cpu_abort(env_cpu(env), "Unimplemented control register read 0x%x\n",
Thanks,
Laurent
Re: [PATCH v5 2/6] target/m68k: Fix fsave/frestore for 68881 FPU
In reply to 54weaselsLe 03/09/2026 à 06:45, 54weasels a écrit :
Quoted 16 lines
Why this change is made & How it will be used:
The 68881/68882 FPUs require fsave/frestore instructions to read/write state frames. QEMU only fully implemented this for the 68040. The Sun-3 uses a 68881 FPU, and the boot ROM executesfsaveto probe FPU presence. This patch adds basic 68881 FPU state frame handling (NULL frame) to accurately simulate an idle FPU state.Impact on existing functionality:
Fixes FPU detection for 68881/68882 across all M68k boards without affecting 68040 specific state logic.Signed-off-by 54weasels <[email protected]>--- target/m68k/translate.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)target/m68k/translate.c +0
-0
target/m68k/translate.c DISAS_INSN(frestore) · line 5367
Quoted 5 lines
target/m68k/translate.c +1
-1@@ -5364,11 +5364,11 @@ DISAS_INSN(frestore)gen_exception (s, s->base.pc_next,EXCP_PRIVILEGE );return ; } -if (m68k_feature (s->env,M68K_FEATURE_M68040 )) { +if (m68k_feature (s->env,M68K_FEATURE_FPU )) {
This is not correct for 68060, it has FPU feature bit set but not 040 featuer bit, so it will be managed as 68881/68882. To keep existing behavior, it needs to call disas_undef()
target/m68k/translate.c DISAS_INSN(frestore) · line 5371
Quoted 5 lines
target/m68k/translate.c +1
-1SRC_EA (env, addr,OS_LONG ,0 ,NULL );/* FIXME: check the state frame */ }else { -disas_undef (env, s, insn); +disas_undef_fpu (env, s, insn);
unrelated, needs a separate patch or omitted.
Quoted 6 lines
target/m68k/translate.c +0
-0} }@@ -5379,12 +5379,18 @@ DISAS_INSN(fsave)return ; }
target/m68k/translate.c DISAS_INSN(fsave) · line 5386
Quoted 10 lines
target/m68k/translate.c +5
-4-if (m68k_feature (s->env,M68K_FEATURE_M68040 )) { -/* always write IDLE */ -TCGv idle =tcg_constant_i32 (0x41000000 ); -DEST_EA (env, insn,OS_LONG , idle,NULL ); +if (m68k_feature (s->env,M68K_FEATURE_FPU )) { +TCGv frame; +if (m68k_feature (s->env,M68K_FEATURE_M68040 )) { +/* 68040 FSAVE: always write IDLE */ + frame =tcg_constant_i32 (0x41000000 );
same as previously
target/m68k/translate.c DISAS_INSN(fsave) · line 5393
Quoted 8 lines
target/m68k/translate.c +6
-1+ }else { +/* 68881/68882 FSAVE: always write NULL frame */ + frame =tcg_constant_i32 (0x00000000 ); + } +DEST_EA (env, insn,OS_LONG , frame,NULL ); }else { -disas_undef (env, s, insn); +disas_undef_fpu (env, s, insn);
same as previously
target/m68k/translate.c DISAS_INSN(fsave) · line 5396
Quoted 3 lines
target/m68k/translate.c +0
-0} }#endif
Thanks,
Laurent
Re: [PATCH v5 1/6] target/m68k: Add dummy CAAR register
In reply to Laurent VivierQuoted 44 lines · Laurent Vivier
Quoted 16 lines · Le 03/09/2026 à 06:45, 54weasels a écrit :
Why this change is made & How it will be used:
The Sun-3 ROM expects the Cache Control Register (CAAR) to exist on the 68020. Reading/writing this register currently aborts QEMU. This patch provides a dummy implementation that simply ignores writes and returns 0 on reads, allowing the ROM to continue booting.Impact on existing functionality:
No impact on existing targets. ColdFire and Mac targets do not access CAAR in a way that currently aborts, and providing a safe dummy implementation ensures robustness across M68k boards.Signed-off-by 54weasels <[email protected]>--- target/m68k/helper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)target/m68k/helper.c +0
-0target/m68k/helper.c void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val) · line 285
Quoted 6 lines
target/m68k/helper.c +1
-1@@ -281,8 +281,10 @@ void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)return ; }break ; -/* Unimplemented Registers */ +/* Dummy implementation for CAAR */ case M68K_CR_CAAR :CAAR is only supported on 020 and 030, use
m68k_feature()here to check them and return. Otherwise use break to go toraise_exception_ra()target/m68k/helper.c uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg) · line 392
Quoted 13 lines
target/m68k/helper.c +4
-1+return ; +/* Unimplemented Registers */ case M68K_CR_PCR :case M68K_CR_BUSCR : cpu_abort(env_cpu(env),@@ -385,8 +387,10 @@ uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg)return env->mmu.ttr[M68K_DTTR1 ]; }break ; -/* Unimplemented Registers */ +/* Dummy implementation for CAAR */ case M68K_CR_CAAR : +return 0 ;Same comment as for
m68k_movec_to()
Quoted 8 lines
target/m68k/helper.c uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg) · line 396
Quoted 4 lines
target/m68k/helper.c +1
-0+/* Unimplemented Registers */ case M68K_CR_PCR :case M68K_CR_BUSCR : cpu_abort(env_cpu(env), "Unimplemented control register read 0x%x\n",Thanks,
Laurent
Thanks Laurent, will do in v6: CAAR is accepted only when M68020 or M68030 is set, and every other CPU falls through to raise_exception_ra(). Same change in m68k_movec_from().
Re: [PATCH v5 2/6] target/m68k: Fix fsave/frestore for 68881 FPU
In reply to Laurent VivierQuoted 13 lines · Laurent Vivier
Quoted 11 lines · Le 03/09/2026 à 06:45, 54weasels a écrit :
Why this change is made & How it will be used:
The 68881/68882 FPUs require fsave/frestore instructions to read/write state frames. QEMU only fully implemented this for the 68040. The Sun-3 uses a 68881 FPU, and the boot ROM executesfsaveto probe FPU presence. This patch adds basic 68881 FPU state frame handling (NULL frame) to accurately simulate an idle FPU state.Impact on existing functionality:
Fixes FPU detection for 68881/68882 across all M68k boards without affecting 68040 specific state logic.Signed-off-by 54weasels <[email protected]>--- target/m68k/translate.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
Quoted 14 lines
target/m68k/translate.c DISAS_INSN(frestore) · line 5367
Quoted 10 lines
target/m68k/translate.c +1
-1@@ -5364,11 +5364,11 @@ DISAS_INSN(frestore)gen_exception (s, s->base.pc_next,EXCP_PRIVILEGE );return ; } -if (m68k_feature (s->env,M68K_FEATURE_M68040 )) { +if (m68k_feature (s->env,M68K_FEATURE_FPU )) {This is not correct for 68060, it has FPU feature bit set but not 040 featuer bit, so it will be managed as 68881/68882. To keep existing behavior, it needs to call
disas_undef()
Good catch, thanks. In v6 I'll leave the 68040 path as it is and add an explicit branch for M68020/M68030 (NULL frame). Everything else, 68060 included, goes to disas_undef() as it does today.
Quoted 8 lines
target/m68k/translate.c DISAS_INSN(frestore) · line 5371
Quoted 5 lines
target/m68k/translate.c +1
-1SRC_EA (env, addr,OS_LONG ,0 ,NULL );/* FIXME: check the state frame */ }else { -disas_undef (env, s, insn); +disas_undef_fpu (env, s, insn);unrelated, needs a separate patch or omitted.
Agreed, I'll drop the disas_undef_fpu() change.
Quoted 37 lines
Quoted 6 lines
target/m68k/translate.c +0
-0} }@@ -5379,12 +5379,18 @@ DISAS_INSN(fsave)return ; }target/m68k/translate.c DISAS_INSN(fsave) · line 5386
Quoted 10 lines
target/m68k/translate.c +5
-4-if (m68k_feature (s->env,M68K_FEATURE_M68040 )) { -/* always write IDLE */ -TCGv idle =tcg_constant_i32 (0x41000000 ); -DEST_EA (env, insn,OS_LONG , idle,NULL ); +if (m68k_feature (s->env,M68K_FEATURE_FPU )) { +TCGv frame; +if (m68k_feature (s->env,M68K_FEATURE_M68040 )) { +/* 68040 FSAVE: always write IDLE */ + frame =tcg_constant_i32 (0x41000000 );same as previously
target/m68k/translate.c DISAS_INSN(fsave) · line 5393
Quoted 8 lines
target/m68k/translate.c +6
-1+ }else { +/* 68881/68882 FSAVE: always write NULL frame */ + frame =tcg_constant_i32 (0x00000000 ); + } +DEST_EA (env, insn,OS_LONG , frame,NULL ); }else { -disas_undef (env, s, insn); +disas_undef_fpu (env, s, insn);same as previously
target/m68k/translate.c DISAS_INSN(fsave) · line 5396
Quoted 3 lines
target/m68k/translate.c +0
-0} }#endif Thanks,
Laurent