qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/m68k: Fix exception frame format for 68010
@ 2024-01-15 10:16 Daniel Palmer
  2024-02-22  9:57 ` Thomas Huth
  2024-02-23 12:03 ` Laurent Vivier
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Palmer @ 2024-01-15 10:16 UTC (permalink / raw)
  To: laurent; +Cc: qemu-devel, Daniel Palmer

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.

Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
 target/m68k/cpu.c       | 4 +++-
 target/m68k/cpu.h       | 2 ++
 target/m68k/op_helper.c | 4 ++--
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index 1421e77c2c07..20718944b4c8 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -137,7 +137,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)
 {
@@ -150,6 +151,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/cpu.h b/target/m68k/cpu.h
index d13427b0fe61..0fc591e618f6 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -549,6 +549,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/op_helper.c b/target/m68k/op_helper.c
index 1ce850bbc594..b09771672dec 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.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] target/m68k: Fix exception frame format for 68010
  2024-01-15 10:16 [PATCH] target/m68k: Fix exception frame format for 68010 Daniel Palmer
@ 2024-02-22  9:57 ` Thomas Huth
  2024-02-22 13:33   ` Mark Cave-Ayland
  2024-02-23 12:03 ` Laurent Vivier
  1 sibling, 1 reply; 7+ messages in thread
From: Thomas Huth @ 2024-02-22  9:57 UTC (permalink / raw)
  To: Daniel Palmer, laurent; +Cc: qemu-devel

On 15/01/2024 11.16, Daniel Palmer wrote:
>  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.
> 
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
> ---
>   target/m68k/cpu.c       | 4 +++-
>   target/m68k/cpu.h       | 2 ++
>   target/m68k/op_helper.c | 4 ++--
>   3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
> index 1421e77c2c07..20718944b4c8 100644
> --- a/target/m68k/cpu.c
> +++ b/target/m68k/cpu.c
> @@ -137,7 +137,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)
>   {
> @@ -150,6 +151,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/cpu.h b/target/m68k/cpu.h
> index d13427b0fe61..0fc591e618f6 100644
> --- a/target/m68k/cpu.h
> +++ b/target/m68k/cpu.h
> @@ -549,6 +549,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/op_helper.c b/target/m68k/op_helper.c
> index 1ce850bbc594..b09771672dec 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) {

LGTM,
Reviewed-by: Thomas Huth <thuth@redhat.com>

Laurent, if you're currently too busy with other stuff, I could also add 
this to my next pull request?

  Thomas



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] target/m68k: Fix exception frame format for 68010
  2024-02-22  9:57 ` Thomas Huth
@ 2024-02-22 13:33   ` Mark Cave-Ayland
  2024-02-22 13:37     ` Peter Maydell
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Cave-Ayland @ 2024-02-22 13:33 UTC (permalink / raw)
  To: Thomas Huth, Daniel Palmer, laurent; +Cc: qemu-devel

On 22/02/2024 09:57, Thomas Huth wrote:
> On 15/01/2024 11.16, Daniel Palmer wrote:
>>  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.
>>
>> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
>> ---
>>   target/m68k/cpu.c       | 4 +++-
>>   target/m68k/cpu.h       | 2 ++
>>   target/m68k/op_helper.c | 4 ++--
>>   3 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
>> index 1421e77c2c07..20718944b4c8 100644
>> --- a/target/m68k/cpu.c
>> +++ b/target/m68k/cpu.c
>> @@ -137,7 +137,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)
>>   {
>> @@ -150,6 +151,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/cpu.h b/target/m68k/cpu.h
>> index d13427b0fe61..0fc591e618f6 100644
>> --- a/target/m68k/cpu.h
>> +++ b/target/m68k/cpu.h
>> @@ -549,6 +549,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/op_helper.c b/target/m68k/op_helper.c
>> index 1ce850bbc594..b09771672dec 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) {
> 
> LGTM,
> Reviewed-by: Thomas Huth <thuth@redhat.com>

This is also:
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2164

> Laurent, if you're currently too busy with other stuff, I could also add this to my 
> next pull request?
> 
>   Thomas


ATB,

Mark.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] target/m68k: Fix exception frame format for 68010
  2024-02-22 13:33   ` Mark Cave-Ayland
@ 2024-02-22 13:37     ` Peter Maydell
  2024-02-22 13:50       ` Mark Cave-Ayland
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2024-02-22 13:37 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: Thomas Huth, Daniel Palmer, laurent, qemu-devel

On Thu, 22 Feb 2024 at 13:34, Mark Cave-Ayland
<mark.cave-ayland@ilande.co.uk> wrote:

> This is also:
> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2164

"Resolves:" for gitlab bug URLs; "Fixes:" is for git commits.

-- PMM


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] target/m68k: Fix exception frame format for 68010
  2024-02-22 13:37     ` Peter Maydell
@ 2024-02-22 13:50       ` Mark Cave-Ayland
  2024-02-22 14:48         ` Peter Maydell
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Cave-Ayland @ 2024-02-22 13:50 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Thomas Huth, Daniel Palmer, laurent, qemu-devel

On 22/02/2024 13:37, Peter Maydell wrote:

> On Thu, 22 Feb 2024 at 13:34, Mark Cave-Ayland
> <mark.cave-ayland@ilande.co.uk> wrote:
> 
>> This is also:
>> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2164
> 
> "Resolves:" for gitlab bug URLs; "Fixes:" is for git commits.

I think GitLab will happily accept either form (see 
https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) 
which appears to be supported by the git history? But I can certainly make a note of 
this convention for the future.


ATB,

Mark.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] target/m68k: Fix exception frame format for 68010
  2024-02-22 13:50       ` Mark Cave-Ayland
@ 2024-02-22 14:48         ` Peter Maydell
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2024-02-22 14:48 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: Thomas Huth, Daniel Palmer, laurent, qemu-devel

On Thu, 22 Feb 2024 at 13:50, Mark Cave-Ayland
<mark.cave-ayland@ilande.co.uk> wrote:
>
> On 22/02/2024 13:37, Peter Maydell wrote:
>
> > On Thu, 22 Feb 2024 at 13:34, Mark Cave-Ayland
> > <mark.cave-ayland@ilande.co.uk> wrote:
> >
> >> This is also:
> >> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2164
> >
> > "Resolves:" for gitlab bug URLs; "Fixes:" is for git commits.
>
> I think GitLab will happily accept either form (see
> https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
> which appears to be supported by the git history? But I can certainly make a note of
> this convention for the future.

Yes, gitlab's regex for detecting this is quite wide; the
intention is to try to keep the semantic uses "note which
git commit this change is correcting" and "note the bug
which this change is resolving" distinct.

-- PMM


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] target/m68k: Fix exception frame format for 68010
  2024-01-15 10:16 [PATCH] target/m68k: Fix exception frame format for 68010 Daniel Palmer
  2024-02-22  9:57 ` Thomas Huth
@ 2024-02-23 12:03 ` Laurent Vivier
  1 sibling, 0 replies; 7+ messages in thread
From: Laurent Vivier @ 2024-02-23 12:03 UTC (permalink / raw)
  To: Daniel Palmer; +Cc: qemu-devel

Le 15/01/2024 à 11:16, Daniel Palmer a écrit :
>  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.
> 
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
> ---
>   target/m68k/cpu.c       | 4 +++-
>   target/m68k/cpu.h       | 2 ++
>   target/m68k/op_helper.c | 4 ++--
>   3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
> index 1421e77c2c07..20718944b4c8 100644
> --- a/target/m68k/cpu.c
> +++ b/target/m68k/cpu.c
> @@ -137,7 +137,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)
>   {
> @@ -150,6 +151,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/cpu.h b/target/m68k/cpu.h
> index d13427b0fe61..0fc591e618f6 100644
> --- a/target/m68k/cpu.h
> +++ b/target/m68k/cpu.h
> @@ -549,6 +549,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/op_helper.c b/target/m68k/op_helper.c
> index 1ce850bbc594..b09771672dec 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) {

Reviewed-by: Laurent Vivier <laurent@vivier.eu>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-23 12:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-15 10:16 [PATCH] target/m68k: Fix exception frame format for 68010 Daniel Palmer
2024-02-22  9:57 ` Thomas Huth
2024-02-22 13:33   ` Mark Cave-Ayland
2024-02-22 13:37     ` Peter Maydell
2024-02-22 13:50       ` Mark Cave-Ayland
2024-02-22 14:48         ` Peter Maydell
2024-02-23 12:03 ` Laurent Vivier

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).