From: 54weasels <54weasels@gmail.com>
To: qemu-devel@nongnu.org
Cc: laurent@vivier.eu, balaton@eik.bme.hu, 54weasels <54weasels@gmail.com>
Subject: [PATCH v5 2/6] target/m68k: Fix fsave/frestore for 68881 FPU
Date: Wed, 2 Sep 2026 21:45:15 -0700 [thread overview]
Message-ID: <20260903044626.24453-3-54weasels@gmail.com> (raw)
In-Reply-To: <20260903044626.24453-1-54weasels@gmail.com>
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 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.
Signed-off-by: 54weasels <54weasels@gmail.com>
---
target/m68k/translate.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 138c89d3e5..c89ef213ed 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -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
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-09-03 4:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 4:45 [PATCH v5 0/6] Implement missing functionality and hooks in m68k to support upcoming Sun-3 implementation 54weasels
2026-09-03 4:45 ` [PATCH v5 1/6] target/m68k: Add dummy CAAR register 54weasels
2026-09-03 4:45 ` 54weasels [this message]
2026-09-03 4:45 ` [PATCH v5 3/6] target/m68k: Fix NMI pending for Level 7 interrupts 54weasels
2026-09-03 4:45 ` [PATCH v5 4/6] target/m68k: Extract Function Codes during TLB fills 54weasels
2026-09-03 4:45 ` [PATCH v5 5/6] target/m68k: Implement custom MMU intercept hook 54weasels
2026-09-03 4:45 ` [PATCH v5 6/6] target/m68k: Implement Physical Bus Error and Stack 54weasels
2026-09-09 18:54 ` [PATCH v5 0/6] Implement missing functionality and hooks in m68k to support upcoming Sun-3 implementation Purr Box
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=20260903044626.24453-3-54weasels@gmail.com \
--to=54weasels@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.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.