diff mbox series

[PULL,v1,6/8] target/microblaze: mbar: Trap sleeps from user-space

Message ID 20200824100041.1864420-7-edgar.iglesias@gmail.com (mailing list archive)
State New, archived
Headers show
Series [PULL,v1,1/8] target/microblaze: mbar: Transfer dc->rd to mbar_imm | expand

Commit Message

Edgar E. Iglesias Aug. 24, 2020, 10 a.m. UTC
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Trap mbar-sleeps from user-space.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 target/microblaze/translate.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
index 530c15e5ad..a96cb21d96 100644
--- a/target/microblaze/translate.c
+++ b/target/microblaze/translate.c
@@ -1250,6 +1250,11 @@  static void dec_br(DisasContext *dc)
 
             LOG_DIS("sleep\n");
 
+            if (trap_userspace(dc, true)) {
+                /* Sleep is a privileged instruction.  */
+                return;
+            }
+
             t_sync_flags(dc);
             tcg_gen_st_i32(tmp_1, cpu_env,
                            -offsetof(MicroBlazeCPU, env)