diff mbox series

[v1,1/1] target/microblaze: mbar: Trap sleeps from user-space

Message ID 20200817173045.437534-2-edgar.iglesias@gmail.com (mailing list archive)
State New, archived
Headers show
Series target/microblaze: mbar: Trap sleeps from user-space | expand

Commit Message

Edgar E. Iglesias Aug. 17, 2020, 5:30 p.m. UTC
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Trap mbar-sleeps from user-space.

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(+)

Comments

Richard Henderson Aug. 18, 2020, 12:06 a.m. UTC | #1
On 8/17/20 10:30 AM, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
> 
> Trap mbar-sleeps from user-space.
> 
> 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(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
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)