[PATCH for-9.1] target/m68k: Always return a temporary from gen_lea_mode

Richard Henderson posted 1 patch 3 months, 1 week ago
target/m68k/translate.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH for-9.1] target/m68k: Always return a temporary from gen_lea_mode
Posted by Richard Henderson 3 months, 1 week ago
Returning a raw areg does not preserve the value if the areg
is subsequently modified.  Fixes, e.g. "jsr (sp)", where the
return address is pushed before the branch.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2483
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/m68k/translate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index fb5ecce0c3..5e2be846b7 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -723,7 +723,9 @@ static TCGv gen_lea_mode(CPUM68KState *env, DisasContext *s,
         }
         /* fallthru */
     case 2: /* Indirect register */
-        return get_areg(s, reg0);
+        tmp = tcg_temp_new();
+        tcg_gen_mov_i32(tmp, get_areg(s, reg0));
+        return tmp;
     case 4: /* Indirect predecrememnt.  */
         if (opsize == OS_UNSIZED) {
             return NULL_QREG;
-- 
2.43.0
Re: [PATCH for-9.1] target/m68k: Always return a temporary from gen_lea_mode
Posted by Philippe Mathieu-Daudé 3 months, 1 week ago
On 13/8/24 02:07, Richard Henderson wrote:
> Returning a raw areg does not preserve the value if the areg
> is subsequently modified.  Fixes, e.g. "jsr (sp)", where the
> return address is pushed before the branch.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2483
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/m68k/translate.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>