50 lines
1.9 KiB
Diff
50 lines
1.9 KiB
Diff
|
|
From 364efd620bb9b6003a2b65fe7ea56b640a209be4 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Liu Jing <liujing_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Mon, 21 Oct 2024 19:22:03 +0800
|
||
|
|
Subject: [PATCH] target/m68k: Perform writback before modifying SR
|
||
|
|
|
||
|
|
Writes to SR may change security state, which may involve
|
||
|
|
a swap of %ssp with %usp as reflected in %a7. Finish the
|
||
|
|
writeback of %sp@+ before swapping stack pointers.
|
||
|
|
|
||
|
|
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1206
|
||
|
|
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||
|
|
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
|
||
|
|
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
|
||
|
|
Message-Id: <20220913142818.7802-3-richard.henderson@linaro.org>
|
||
|
|
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
|
||
|
|
Signed-off-by: Liu Jing <liujing_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
target/m68k/translate.c | 8 +++++---
|
||
|
|
1 file changed, 5 insertions(+), 3 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
|
||
|
|
index af43c8eab8..6cc4321921 100644
|
||
|
|
--- a/target/m68k/translate.c
|
||
|
|
+++ b/target/m68k/translate.c
|
||
|
|
@@ -2269,9 +2269,9 @@ static void gen_set_sr_im(DisasContext *s, uint16_t val, int ccr_only)
|
||
|
|
tcg_gen_movi_i32(QREG_CC_N, val & CCF_N ? -1 : 0);
|
||
|
|
tcg_gen_movi_i32(QREG_CC_X, val & CCF_X ? 1 : 0);
|
||
|
|
} else {
|
||
|
|
- TCGv sr = tcg_const_i32(val);
|
||
|
|
- gen_helper_set_sr(cpu_env, sr);
|
||
|
|
- tcg_temp_free(sr);
|
||
|
|
+ /* Must writeback before changing security state. */
|
||
|
|
+ do_writebacks(s);
|
||
|
|
+ gen_helper_set_sr(cpu_env, tcg_constant_i32(val));
|
||
|
|
}
|
||
|
|
set_cc_op(s, CC_OP_FLAGS);
|
||
|
|
}
|
||
|
|
@@ -2281,6 +2281,8 @@ static void gen_set_sr(DisasContext *s, TCGv val, int ccr_only)
|
||
|
|
if (ccr_only) {
|
||
|
|
gen_helper_set_ccr(cpu_env, val);
|
||
|
|
} else {
|
||
|
|
+ /* Must writeback before changing security state. */
|
||
|
|
+ do_writebacks(s);
|
||
|
|
gen_helper_set_sr(cpu_env, val);
|
||
|
|
}
|
||
|
|
set_cc_op(s, CC_OP_FLAGS);
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|