qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Daniel Palmer <daniel@0x0f.com>
Subject: [PULL 01/11] target/m68k: Fix exception frame format for 68010
Date: Fri, 23 Feb 2024 20:09:53 +0100	[thread overview]
Message-ID: <20240223191003.6268-2-thuth@redhat.com> (raw)
In-Reply-To: <20240223191003.6268-1-thuth@redhat.com>

From: Daniel Palmer <daniel@0x0f.com>

From the 68010 a word with the frame format and exception vector
are placed on the stack before the PC and SR.

M68K_FEATURE_QUAD_MULDIV is currently checked to workout if to do
this or not for the configured CPU but that flag isn't set for
68010 so currently the exception stack when 68010 is configured
is incorrect.

It seems like checking M68K_FEATURE_MOVEFROMSR_PRIV would do but
adding a new flag that shows exactly what is going on here is
maybe clearer.

Add a new flag for the behaviour, M68K_FEATURE_EXCEPTION_FORMAT_VEC,
and set it for 68010 and above, and then use it to control if the
format and vector word are pushed/pop during exception entry/exit.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2164
Signed-off-by: Daniel Palmer <daniel@0x0f.com>
Message-ID: <20240115101643.2165387-1-daniel@0x0f.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 target/m68k/cpu.h       | 2 ++
 target/m68k/cpu.c       | 4 +++-
 target/m68k/op_helper.c | 4 ++--
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 646cacbdf1..346427e144 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -550,6 +550,8 @@ enum m68k_features {
     M68K_FEATURE_TRAPCC,
     /* MOVE from SR privileged (from 68010) */
     M68K_FEATURE_MOVEFROMSR_PRIV,
+    /* Exception frame with format+vector (from 68010) */
+    M68K_FEATURE_EXCEPTION_FORMAT_VEC,
 };
 
 static inline bool m68k_feature(CPUM68KState *env, int feature)
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index 8a8392e694..d5a71c6315 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -142,7 +142,8 @@ static void m68000_cpu_initfn(Object *obj)
 }
 
 /*
- * Adds BKPT, MOVE-from-SR *now priv instr, and MOVEC, MOVES, RTD
+ * Adds BKPT, MOVE-from-SR *now priv instr, and MOVEC, MOVES, RTD,
+ *      format+vector in exception frame.
  */
 static void m68010_cpu_initfn(Object *obj)
 {
@@ -155,6 +156,7 @@ static void m68010_cpu_initfn(Object *obj)
     m68k_set_feature(env, M68K_FEATURE_BKPT);
     m68k_set_feature(env, M68K_FEATURE_MOVEC);
     m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV);
+    m68k_set_feature(env, M68K_FEATURE_EXCEPTION_FORMAT_VEC);
 }
 
 /*
diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c
index 47b4173bb9..956e76eb5f 100644
--- a/target/m68k/op_helper.c
+++ b/target/m68k/op_helper.c
@@ -52,7 +52,7 @@ throwaway:
     sp += 2;
     env->pc = cpu_ldl_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
     sp += 4;
-    if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
+    if (m68k_feature(env, M68K_FEATURE_EXCEPTION_FORMAT_VEC)) {
         /*  all except 68000 */
         fmt = cpu_lduw_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
         sp += 2;
@@ -256,7 +256,7 @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
                                   uint16_t format, uint16_t sr,
                                   uint32_t addr, uint32_t retaddr)
 {
-    if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
+    if (m68k_feature(env, M68K_FEATURE_EXCEPTION_FORMAT_VEC)) {
         /*  all except 68000 */
         CPUState *cs = env_cpu(env);
         switch (format) {
-- 
2.43.2



  reply	other threads:[~2024-02-23 19:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 19:09 [PULL 00/11] Test and misc patches Thomas Huth
2024-02-23 19:09 ` Thomas Huth [this message]
2024-02-23 19:09 ` [PULL 02/11] tests/cdrom-test: Add cdrom test for LoongArch virt machine Thomas Huth
2024-02-23 19:09 ` [PULL 03/11] tests/qtest: Fix boot-serial-test when using --without-default-devices Thomas Huth
2024-02-23 19:09 ` [PULL 04/11] tests: skip dbus-display tests that need a console Thomas Huth
2024-02-23 19:09 ` [PULL 05/11] target/ppc/kvm: Replace variable length array in kvmppc_save_htab() Thomas Huth
2024-02-23 19:09 ` [PULL 06/11] target/ppc/kvm: Replace variable length array in kvmppc_read_hptes() Thomas Huth
2024-02-23 19:09 ` [PULL 07/11] meson: Enable -Wvla Thomas Huth
2024-02-23 19:10 ` [PULL 08/11] docs: Document that 32-bit Windows is unsupported Thomas Huth
2024-02-23 19:10 ` [PULL 09/11] .gitlab-ci.d: Drop cross-win32-system job Thomas Huth
2024-02-23 19:10 ` [PULL 10/11] .gitlab-ci.d/windows.yml: Remove shared-msys2 abstraction Thomas Huth
2024-02-23 19:10 ` [PULL 11/11] target/i386: do not filter processor tracing features except on KVM Thomas Huth
2024-02-25 11:52 ` [PULL 00/11] Test and misc patches Peter Maydell

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=20240223191003.6268-2-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=daniel@0x0f.com \
    --cc=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).