target/riscv: Validate the mode in write_vstvec
PATCH 1/1 target/riscv: Validate the mode in write_vstvec
Base on the riscv-privileged spec, vstvec substitutes for the usual stvec. Therefore, the encoding of the MODE should also be restricted to 0 and 1.
--- target/riscv/csr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
target/riscv/csr.c +6 -1
@@ -3791,7 +3791,12 @@ static RISCVException read_vstvec(CPURISCVState *env, int csrno,static RISCVException write_vstvec (CPURISCVState *env,int csrno,target_ulong val) { - env->vstvec = val; +/* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ +if ((val &3 ) <2 ) { + env->vstvec = val; + }else { +qemu_log_mask (LOG_UNIMP ,"CSR_VSTVEC: reserved mode not supported\n" ); + }return RISCV_EXCP_NONE ; }
Signature · 1 line
2.25.1
Quoted 5 lines · Jiayi Li
Base on the riscv-privileged spec, vstvec substitutes for the usual stvec. Therefore, the encoding of the MODE should also be restricted to 0 and 1.
Signed-off-by Jiayi Li <[email protected]>
Alistair
Quoted 26 lines
--- target/riscv/csr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)target/riscv/csr.c +6
-2@@ -3791,7 +3791,12 @@ static RISCVException read_vstvec(CPURISCVState *env, int csrno,static RISCVException write_vstvec (CPURISCVState *env,int csrno,target_ulong val) { - env->vstvec = val; +/* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ +if ((val &3 ) <2 ) { + env->vstvec = val; + }else { +qemu_log_mask (LOG_UNIMP ,"CSR_VSTVEC: reserved mode not supported\n" ); + }return RISCV_EXCP_NONE ; } --2.25.1
Quoted 13 lines · Jiayi Li
Base on the riscv-privileged spec, vstvec substitutes for the usual stvec. Therefore, the encoding of the MODE should also be restricted to 0 and 1.
Signed-off-by Jiayi Li <[email protected]>--- target/riscv/csr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)target/riscv/csr.c +0
-0
target/riscv/csr.c static RISCVException read_vstvec(CPURISCVState *env, int csrno, · line 3799
Quoted 10 lines
target/riscv/csr.c +6
-1@@ -3791,7 +3791,12 @@ static RISCVException read_vstvec(CPURISCVState *env, int csrno,static RISCVException write_vstvec (CPURISCVState *env,int csrno,target_ulong val) { - env->vstvec = val; +/* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ +if ((val &3 ) <2 ) { + env->vstvec = val; + }else { +qemu_log_mask (LOG_UNIMP ,"CSR_VSTVEC: reserved mode not supported\n" ); + }
By the way, you can get the all the reviewers mail by checking the patch with scripts/getmaintainer.pl.
Otherwise,
Zhiwei
Quoted 3 lines
target/riscv/csr.c +0
-0return RISCV_EXCP_NONE ; }
Alistair Francis
AppliedQuoted 5 lines · Jiayi Li
Base on the riscv-privileged spec, vstvec substitutes for the usual stvec. Therefore, the encoding of the MODE should also be restricted to 0 and 1.
Signed-off-by Jiayi Li <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 26 lines
--- target/riscv/csr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)target/riscv/csr.c +6
-2@@ -3791,7 +3791,12 @@ static RISCVException read_vstvec(CPURISCVState *env, int csrno,static RISCVException write_vstvec (CPURISCVState *env,int csrno,target_ulong val) { - env->vstvec = val; +/* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ +if ((val &3 ) <2 ) { + env->vstvec = val; + }else { +qemu_log_mask (LOG_UNIMP ,"CSR_VSTVEC: reserved mode not supported\n" ); + }return RISCV_EXCP_NONE ; } --2.25.1