Skip to contentSkip to conversation

Check access permission to ADDVL/ADDPL/RDVL

PATCH Applied Amir Charif 4 participants 6 messages Mar 14, 2019 – Mar 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check access permission to ADDVL/ADDPL/RDVL

These instructions do not trap when SVE is disabled in EL0, causing them to be executed with wrong size information.

---
 target/arm/translate-sve.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
target/arm/translate-sve.c +14 -8
index 3a2eb51..245cd82 100644
@@ -943,24 +943,30 @@ static bool trans_INDEX_rr(DisasContext *s, arg_INDEX_rr *a)
 
 static bool trans_ADDVL(DisasContext *s, arg_ADDVL *a)
 {
-    TCGv_i64 rd = cpu_reg_sp(s, a->rd);
-    TCGv_i64 rn = cpu_reg_sp(s, a->rn);
-    tcg_gen_addi_i64(rd, rn, a->imm * vec_full_reg_size(s));
+    if (sve_access_check(s)) {
+        TCGv_i64 rd = cpu_reg_sp(s, a->rd);
+        TCGv_i64 rn = cpu_reg_sp(s, a->rn);
+        tcg_gen_addi_i64(rd, rn, a->imm * vec_full_reg_size(s));
+    }
     return true;
 }
 
 static bool trans_ADDPL(DisasContext *s, arg_ADDPL *a)
 {
-    TCGv_i64 rd = cpu_reg_sp(s, a->rd);
-    TCGv_i64 rn = cpu_reg_sp(s, a->rn);
-    tcg_gen_addi_i64(rd, rn, a->imm * pred_full_reg_size(s));
+    if (sve_access_check(s)) {
+        TCGv_i64 rd = cpu_reg_sp(s, a->rd);
+        TCGv_i64 rn = cpu_reg_sp(s, a->rn);
+        tcg_gen_addi_i64(rd, rn, a->imm * pred_full_reg_size(s));
+    }
     return true;
 }
 
 static bool trans_RDVL(DisasContext *s, arg_RDVL *a)
 {
-    TCGv_i64 reg = cpu_reg(s, a->rd);
-    tcg_gen_movi_i64(reg, a->imm * vec_full_reg_size(s));
+    if (sve_access_check(s)) {
+        TCGv_i64 reg = cpu_reg(s, a->rd);
+        tcg_gen_movi_i64(reg, a->imm * vec_full_reg_size(s));
+    }
     return true;
 }
 
Signature · 1 line
2.7.4
#1 lore raw

Richard, Amir -- it looks like you both sent exactly the same patch at pretty much exactly the same time. Any preferences for whose version I apply ? :-)

thanks
-- PMM

Quoted 54 lines · Amir Charif

These instructions do not trap when SVE is disabled in EL0, causing them to be executed with wrong size information.

---
 target/arm/translate-sve.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
target/arm/translate-sve.c +14 -9
index 3a2eb51..245cd82 100644
@@ -943,24 +943,30 @@ static bool trans_INDEX_rr(DisasContext *s, arg_INDEX_rr *a)
 
 static bool trans_ADDVL(DisasContext *s, arg_ADDVL *a)
 {
-    TCGv_i64 rd = cpu_reg_sp(s, a->rd);
-    TCGv_i64 rn = cpu_reg_sp(s, a->rn);
-    tcg_gen_addi_i64(rd, rn, a->imm * vec_full_reg_size(s));
+    if (sve_access_check(s)) {
+        TCGv_i64 rd = cpu_reg_sp(s, a->rd);
+        TCGv_i64 rn = cpu_reg_sp(s, a->rn);
+        tcg_gen_addi_i64(rd, rn, a->imm * vec_full_reg_size(s));
+    }
     return true;
 }
 
 static bool trans_ADDPL(DisasContext *s, arg_ADDPL *a)
 {
-    TCGv_i64 rd = cpu_reg_sp(s, a->rd);
-    TCGv_i64 rn = cpu_reg_sp(s, a->rn);
-    tcg_gen_addi_i64(rd, rn, a->imm * pred_full_reg_size(s));
+    if (sve_access_check(s)) {
+        TCGv_i64 rd = cpu_reg_sp(s, a->rd);
+        TCGv_i64 rn = cpu_reg_sp(s, a->rn);
+        tcg_gen_addi_i64(rd, rn, a->imm * pred_full_reg_size(s));
+    }
     return true;
 }
 
 static bool trans_RDVL(DisasContext *s, arg_RDVL *a)
 {
-    TCGv_i64 reg = cpu_reg(s, a->rd);
-    tcg_gen_movi_i64(reg, a->imm * vec_full_reg_size(s));
+    if (sve_access_check(s)) {
+        TCGv_i64 reg = cpu_reg(s, a->rd);
+        tcg_gen_movi_i64(reg, a->imm * vec_full_reg_size(s));
+    }
     return true;
 }
 
--

2.7.4

Reviewed-by
#2 lore raw
Quoted 6 lines · Peter Maydell

Richard, Amir -- it looks like you both sent exactly the same patch at pretty much exactly the same time. Any preferences for whose version I apply ? :-)

thanks
-- PMM

Hah. Bit of miscommunication there. Might as well apply Amir's and have my

r~

#3 lore raw
Quoted 10 lines · Richard Henderson
Quoted 6 lines · Peter Maydell

Richard, Amir -- it looks like you both sent exactly the same patch at pretty much exactly the same time. Any preferences for whose version I apply ? :-)

thanks
-- PMM

Hah. Bit of miscommunication there. Might as well apply Amir's and have my

Great minds think alike!

My personal preference, if it counts for anything, is to apply Amir's patch, because it's always nice to have first-time contributors added in a release. Welcome to the community, Amir!

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 10 lines · Eric Blake
Quoted 8 lines · Richard Henderson
Quoted 6 lines · Peter Maydell

Richard, Amir -- it looks like you both sent exactly the same patch at pretty much exactly the same time. Any preferences for whose version I apply ? :-)

thanks
-- PMM

Quoted 8 lines
Quoted 2 lines

Hah. Bit of miscommunication there. Might as well apply Amir's and have my

Great minds think alike!

My personal preference, if it counts for anything, is to apply Amir's patch, because it's always nice to have first-time contributors added in a release. Welcome to the community, Amir!

I usually tie-break by whoever sent the patch first, which in this case is also Amir.

Applied to target-arm.next, thanks.

-- PMM

#5 lore raw
In reply to Eric Blake

Thanks Eric, happy to join ^^

-----Message d'origine-----
De : Eric Blake <[email protected]>
Envoyé : jeudi 14 mars 2019 18:44
À : Richard Henderson <[email protected]>; Peter Maydell <[email protected]>; Amir CHARIF <[email protected]> Cc : qemu-arm <[email protected]>; QEMU Developers <[email protected]>
Objet : Re: [Qemu-devel] [Qemu-arm] [PATCH] Check access permission to ADDVL/ADDPL/RDVL

Quoted 11 lines · Richard Henderson
Quoted 6 lines · Peter Maydell

Richard, Amir -- it looks like you both sent exactly the same patch at pretty much exactly the same time. Any preferences for whose version I apply ? :-)

thanks
-- PMM

Hah. Bit of miscommunication there. Might as well apply Amir's and have my

Great minds think alike!

My personal preference, if it counts for anything, is to apply Amir's patch, because it's always nice to have first-time contributors added in a release. Welcome to the community, Amir!

--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org