target/riscv: make mstatush.MPELP writable [GL4220]
Subsystems (2)
PATCH 1/1 target/riscv: make mstatush.MPELP writable [GL4220]
Add MSTATUS_MPELP in the write mask inside write_mstatush().
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4220
--- target/riscv/tcg/csr.c | 5 +++ tests/tcg/riscv32/system/meson.build | 7 +++++ tests/tcg/riscv32/test-mstatush-mpelp.S | 42 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/tcg/riscv32/test-mstatush-mpelp.S
target/riscv/tcg/csr.c +5 -0
@@ -2155,6 +2155,11 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno,uint64_t valh = (uint64_t )val <<32 ;uint64_t mask =riscv_has_ext (env,RVH ) ?MSTATUS_MPV |MSTATUS_GVA :0 ; +/* If cfi lp extension is available, then apply cfi lp mask */ +if (env_archcpu (env)->cfg.ext_zicfilp) { + mask |=MSTATUS_MPELP ; + } +if (riscv_cpu_cfg (env)->ext_smdbltrp) { mask |=MSTATUS_MDT ;if ((valh &MSTATUS_MDT ) !=0 ) {
tests/tcg/riscv32/system/meson.build +7 -0
@@ -22,6 +22,13 @@ tests += { }, } +tests += { + 'test-mstatush-mpelp.S': { + 'cflags': cflags, + 'qemu_args': ['-cpu', 'max', qemu_args], + }, +} + if 'qemu-system-riscv32' in emulators tcg_tests += { 'riscv32-softmmu': {
tests/tcg/riscv32/test-mstatush-mpelp.S new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.43.0
Ping review/Sashiko
Let's not miss the great "Gitlab fixes" train coming up in the next PR :)
Thanks,
Daniel
Quoted 94 lines · Daniel Henrique Barboza
Add
MSTATUS_MPELPin the write mask insidewrite_mstatush().Fixes 4923f672e3d7 ("target/riscv: Introduce elp state and enabling controls for zicfilp")Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4220
Signed-off-by Daniel Henrique Barboza <[email protected]>--- target/riscv/tcg/csr.c | 5 +++ tests/tcg/riscv32/system/meson.build | 7 +++++ tests/tcg/riscv32/test-mstatush-mpelp.S | 42 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+)create mode 100644
tests/tcg/riscv32/test-mstatush-mpelp.Starget/riscv/tcg/csr.c +5
-0@@ -2155,6 +2155,11 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno,uint64_t valh = (uint64_t )val <<32 ;uint64_t mask =riscv_has_ext (env,RVH ) ?MSTATUS_MPV |MSTATUS_GVA :0 ; +/* If cfi lp extension is available, then apply cfi lp mask */ +if (env_archcpu (env)->cfg.ext_zicfilp) { + mask |=MSTATUS_MPELP ; + } +if (riscv_cpu_cfg (env)->ext_smdbltrp) { mask |=MSTATUS_MDT ;if ((valh &MSTATUS_MDT ) !=0 ) {tests/tcg/riscv32/system/meson.build +7
-0@@ -22,6 +22,13 @@ tests += { }, } +tests += { + 'test-mstatush-mpelp.S': { + 'cflags': cflags, + 'qemu_args': ['-cpu', 'max', qemu_args], + }, +} + if 'qemu-system-riscv32' in emulators tcg_tests += { 'riscv32-softmmu': {tests/tcg/riscv32/test-mstatush-mpelp.S new file +42
-0@@ -0,0 +1,42 @@ +/* + * Test that mstatush.MPELP is writable (Gitlab 4220). + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#define MSTATUSH_MPELP 0x200 + +.option norvc + .text + .global _start + +_start: + lla t0, trap + csrw mtvec, t0 + + csrr s0, mstatush + li t0, MSTATUSH_MPELP + or t1, s0, t0 + csrw mstatush, t1 + + csrr s0, mstatush + and t1, s0, t0 + bne t0, t1, _fail + + j _pass + +trap: + j _fail + +_pass: + li t0, 0x100000 + li t1, 0x5555 /* FINISHER_PASS */ + sw t1, 0(t0) + j . + +_fail: + li t0, 0x100000 + li t1, 0x13333 /* status = FINISHER_FAIL, code = 1 */ + sw t1, 0(t0) + j .
Quoted 7 lines · Daniel Henrique Barboza
Add
MSTATUS_MPELPin the write mask insidewrite_mstatush().Fixes 4923f672e3d7 ("target/riscv: Introduce elp state and enablingcontrols for zicfilp")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4220
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Alistair
Quoted 96 lines
---
target/riscv/tcg/csr.c | 5 +++ tests/tcg/riscv32/system/meson.build | 7 +++++tests/tcg/riscv32/test-mstatush-mpelp.S| 42
+++++++++++++++++++++++++3 files changed, 54 insertions(+)create mode 100644
tests/tcg/riscv32/test-mstatush-mpelp.Starget/riscv/tcg/csr.c +0
-0@@ -2155,6 +2155,11 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, uint64_t valh = (uint64_t)val << 32;
uint64_tmask =riscv_has_ext(env, RVH)?MSTATUS_MPV|MSTATUS_GVA: 0;
+ /* If cfi lp extension is available, then apply cfi lp mask */ + if (env_archcpu(env)->cfg.ext_zicfilp) {
+ mask |=MSTATUS_MPELP;
+ }
+
if (riscv_cpu_cfg(env)->ext_smdbltrp) {
mask |=MSTATUS_MDT;
if ((valh &MSTATUS_MDT) != 0) {tests/tcg/riscv32/system/meson.build +0
-0@@ -22,6 +22,13 @@ tests += { }, }tests/tcg/riscv32/system/meson.build +7
-0+tests += { + 'test-mstatush-mpelp.S': { + 'cflags': cflags, + 'qemu_args': ['-cpu', 'max', qemu_args], + }, +} +if 'qemu-system-riscv32' in emulators
tcg_tests+= {
'riscv32-softmmu': {tests/tcg/riscv32/test-mstatush-mpelp.S new file +4
-0@@ -0,0 +1,42 @@ +/* + * Test that mstatush.MPELP is writable (Gitlab 4220). + * + * Copyright (c) Qualcomm Technologies, Inc. and/or itssubsidiaries.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */tests/tcg/riscv32/test-mstatush-mpelp.S new file +34
-0+ +#define MSTATUSH_MPELP 0x200 + +.option norvc + .text + .global _start + +_start: + lla t0, trap + csrw mtvec, t0 + + csrr s0, mstatush + li t0, MSTATUSH_MPELP + or t1, s0, t0 + csrw mstatush, t1 + + csrr s0, mstatush + and t1, s0, t0 + bne t0, t1, _fail + + j _pass + +trap: + j _fail + +_pass: + li t0, 0x100000 + li t1, 0x5555 /* FINISHER_PASS */ + sw t1, 0(t0) + j . + +_fail: + li t0, 0x100000 + li t1, 0x13333 /* status = FINISHER_FAIL, code = 1*/
tests/tcg/riscv32/test-mstatush-mpelp.S new file +2
-0+ sw t1, 0(t0) + j .
Alistair Francis
AppliedQuoted 7 lines · Daniel Henrique Barboza
Add
MSTATUS_MPELPin the write mask insidewrite_mstatush().Fixes 4923f672e3d7 ("target/riscv: Introduce elp state and enablingcontrols for zicfilp")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4220
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 96 lines
---
target/riscv/tcg/csr.c | 5 +++ tests/tcg/riscv32/system/meson.build | 7 +++++tests/tcg/riscv32/test-mstatush-mpelp.S| 42
+++++++++++++++++++++++++3 files changed, 54 insertions(+)create mode 100644
tests/tcg/riscv32/test-mstatush-mpelp.Starget/riscv/tcg/csr.c +0
-0@@ -2155,6 +2155,11 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, uint64_t valh = (uint64_t)val << 32;
uint64_tmask =riscv_has_ext(env, RVH)?MSTATUS_MPV|MSTATUS_GVA: 0;
+ /* If cfi lp extension is available, then apply cfi lp mask */ + if (env_archcpu(env)->cfg.ext_zicfilp) {
+ mask |=MSTATUS_MPELP;
+ }
+
if (riscv_cpu_cfg(env)->ext_smdbltrp) {
mask |=MSTATUS_MDT;
if ((valh &MSTATUS_MDT) != 0) {tests/tcg/riscv32/system/meson.build +0
-0@@ -22,6 +22,13 @@ tests += { }, }tests/tcg/riscv32/system/meson.build +7
-0+tests += { + 'test-mstatush-mpelp.S': { + 'cflags': cflags, + 'qemu_args': ['-cpu', 'max', qemu_args], + }, +} +if 'qemu-system-riscv32' in emulators
tcg_tests+= {
'riscv32-softmmu': {tests/tcg/riscv32/test-mstatush-mpelp.S new file +4
-0@@ -0,0 +1,42 @@ +/* + * Test that mstatush.MPELP is writable (Gitlab 4220). + * + * Copyright (c) Qualcomm Technologies, Inc. and/or itssubsidiaries.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */tests/tcg/riscv32/test-mstatush-mpelp.S new file +34
-0+ +#define MSTATUSH_MPELP 0x200 + +.option norvc + .text + .global _start + +_start: + lla t0, trap + csrw mtvec, t0 + + csrr s0, mstatush + li t0, MSTATUSH_MPELP + or t1, s0, t0 + csrw mstatush, t1 + + csrr s0, mstatush + and t1, s0, t0 + bne t0, t1, _fail + + j _pass + +trap: + j _fail + +_pass: + li t0, 0x100000 + li t1, 0x5555 /* FINISHER_PASS */ + sw t1, 0(t0) + j . + +_fail: + li t0, 0x100000 + li t1, 0x13333 /* status = FINISHER_FAIL, code = 1*/
tests/tcg/riscv32/test-mstatush-mpelp.S new file +2
-0+ sw t1, 0(t0) + j .