mconfigptr support
v2 cover mconfigptr support
Patches add the mconfigptr csr support.
mconfigptr is newly incorporated in risc-v privileged architecture specification 1.12 version.
priv spec 1.12.0 version check is also added.
qemu-system-riscv64 -nographic -machine virt -cpu rv64,priv_spec=v1.12.0
Changelog:
v1->v2
------
1. Added privileged architecture spec version 1.12 ("v1.12.0") check
2. Added predicate function for mconfigptr which verifies for priv spec version v1.12.0 or higher.
Thanks
Rahul
Rahul Pathak (2):
target/riscv: Add priv spec 1.12.0 version check target/riscv: csr: Implement mconfigptr CSR
target/riscv/cpu.c | 4 +++- target/riscv/cpu.h | 1 + target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 19 +++++++++++++++---- 4 files changed, 20 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/2 target/riscv: Add priv spec 1.12.0 version check
--- target/riscv/cpu.c | 4 +++- target/riscv/cpu.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
target/riscv/cpu.c +3 -1
@@ -405,7 +405,9 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) }if (cpu->cfg.priv_spec) { -if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.11.0" )) { +if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.12.0" )) { + priv_version =PRIV_VERSION_1_12_0 ; + }else if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.11.0" )) { priv_version =PRIV_VERSION_1_11_0 ; }else if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.10.0" )) { priv_version =PRIV_VERSION_1_10_0 ;
target/riscv/cpu.h +1 -0
@@ -79,6 +79,7 @@ enum {#define PRIV_VERSION_1_10_0 0x00011000#define PRIV_VERSION_1_11_0 0x00011100 +#define PRIV_VERSION_1_12_0 0x00011200#define VEXT_VERSION_0_07_1 0x00000701
Signature · 1 line
2.25.1
PATCH v2 2/2 target/riscv: csr: Implement mconfigptr CSR
In reply to Rahul Pathak--- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
target/riscv/cpu_bits.h +1 -0
@@ -140,6 +140,7 @@#define CSR_MARCHID 0xf12#define CSR_MIMPID 0xf13#define CSR_MHARTID 0xf14 +#define CSR_MCONFIGPTR 0xf15/* Machine Trap Setup */ #define CSR_MSTATUS 0x300
target/riscv/csr.c +15 -4
@@ -209,6 +209,16 @@ static RISCVException epmp(CPURISCVState *env, int csrno) return RISCV_EXCP_ILLEGAL_INST; } + +static RISCVException priv1p12 (CPURISCVState *env,int csrno) +{ +if (env->priv_ver >=PRIV_VERSION_1_12_0 ) { +return RISCV_EXCP_NONE ; + } + +return RISCV_EXCP_ILLEGAL_INST ; +} +#endif /* User Floating-Point CSRs */
@@ -1569,10 +1579,11 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_MINSTRETH] = { "minstreth", any32, read_instreth }, /* Machine Information Registers */ - [CSR_MVENDORID] = { "mvendorid", any, read_zero }, - [CSR_MARCHID] = { "marchid", any, read_zero }, - [CSR_MIMPID] = { "mimpid", any, read_zero }, - [CSR_MHARTID] = { "mhartid", any, read_mhartid }, + [CSR_MVENDORID] = { "mvendorid", any, read_zero }, + [CSR_MARCHID] = { "marchid", any, read_zero }, + [CSR_MIMPID] = { "mimpid", any, read_zero }, + [CSR_MHARTID] = { "mhartid", any, read_mhartid }, + [CSR_MCONFIGPTR] = {"mconfigptr", priv1p12, read_zero }, /* Machine Trap Setup */ [CSR_MSTATUS] = { "mstatus", any, read_mstatus, write_mstatus },
Signature · 1 line
2.25.1
Re: [PATCH v2 1/2] target/riscv: Add priv spec 1.12.0 version check
In reply to Rahul PathakQuoted 12 lines · Rahul Pathak
Signed-off-by Rahul Pathak <[email protected]>--- target/riscv/cpu.c | 4 +++- target/riscv/cpu.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)target/riscv/cpu.c +0
-0
target/riscv/cpu.c static void riscv_cpu_realize(DeviceState *dev, Error **errp) · line 410
Quoted 7 lines
target/riscv/cpu.c +3
-1@@ -405,7 +405,9 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) }if (cpu->cfg.priv_spec) { -if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.11.0" )) { +if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.12.0" )) { + priv_version =PRIV_VERSION_1_12_0 ; + }else if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.11.0" )) {
This change, actually allowing the user to enable the spec, should be in a separate patch at the end of the series.
The idea is to add the feature, then expose it.
Alistair
Quoted 19 lines
target/riscv/cpu.c +0
-0priv_version =PRIV_VERSION_1_11_0 ; }else if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.10.0" )) { priv_version =PRIV_VERSION_1_10_0 ;target/riscv/cpu.h +1
-1@@ -79,6 +79,7 @@ enum {#define PRIV_VERSION_1_10_0 0x00011000#define PRIV_VERSION_1_11_0 0x00011100 +#define PRIV_VERSION_1_12_0 0x00011200#define VEXT_VERSION_0_07_1 0x00000701 --2.25.1
Re: [PATCH v2 2/2] target/riscv: csr: Implement mconfigptr CSR
In reply to Rahul PathakQuoted 42 lines · Rahul Pathak
Signed-off-by Rahul Pathak <[email protected]>--- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)target/riscv/cpu_bits.h +1
-0@@ -140,6 +140,7 @@#define CSR_MARCHID 0xf12#define CSR_MIMPID 0xf13#define CSR_MHARTID 0xf14 +#define CSR_MCONFIGPTR 0xf15/* Machine Trap Setup */ #define CSR_MSTATUS 0x300target/riscv/csr.c +10
-0@@ -209,6 +209,16 @@ static RISCVException epmp(CPURISCVState *env, int csrno) return RISCV_EXCP_ILLEGAL_INST; } + +static RISCVException priv1p12 (CPURISCVState *env,int csrno) +{ +if (env->priv_ver >=PRIV_VERSION_1_12_0 ) { +return RISCV_EXCP_NONE ; + } + +return RISCV_EXCP_ILLEGAL_INST ; +} +#endif /* User Floating-Point CSRs */ @@ -1569,10 +1579,11 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_MINSTRETH] = { "minstreth", any32, read_instreth },
target/riscv/csr.c riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { · line 1585
Quoted 10 lines
target/riscv/csr.c +4
-4/* Machine Information Registers */ - [CSR_MVENDORID] = { "mvendorid", any, read_zero }, - [CSR_MARCHID] = { "marchid", any, read_zero }, - [CSR_MIMPID] = { "mimpid", any, read_zero }, - [CSR_MHARTID] = { "mhartid", any, read_mhartid }, + [CSR_MVENDORID] = { "mvendorid", any, read_zero }, + [CSR_MARCHID] = { "marchid", any, read_zero }, + [CSR_MIMPID] = { "mimpid", any, read_zero }, + [CSR_MHARTID] = { "mhartid", any, read_mhartid },
Why change these?
target/riscv/csr.c riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { · line 1586
Quoted 1 line
target/riscv/csr.c +1
-0+ [CSR_MCONFIGPTR] = {"mconfigptr", priv1p12, read_zero },
This looks fine, but there are more changes then this in v1.12. Looking at the preface we need mret/sret changes at least. It also looks like some other changes will need to be implemented or at least checked.
Alistair
Quoted 7 lines
target/riscv/csr.c +0
-1/* Machine Trap Setup */ [CSR_MSTATUS] = { "mstatus", any, read_mstatus, write_mstatus }, --2.25.1
Quoted 8 lines · Rahul Pathak
Patches add the mconfigptr csr support.
mconfigptr is newly incorporated in risc-v privileged architecture specification 1.12 version.
priv spec 1.12.0 version check is also added.qemu-system-riscv64 -nographic -machine virt -cpu rv64,priv_spec=v1.12.0
Thanks for the patches!
I gave some comments in line with the code changes. Overall this looks good, we just need to add the other v1.12.0 features.
Alistair
Quoted 26 lines
Changelog:
v1->v2
------
1. Added privileged architecture spec version 1.12 ("v1.12.0") check
2. Added predicate function for mconfigptr which verifies for priv spec version v1.12.0 or higher.Thanks
RahulRahul Pathak (2):
target/riscv: Add priv spec 1.12.0 version check target/riscv: csr: Implement mconfigptr CSRtarget/riscv/cpu.c | 4 +++- target/riscv/cpu.h | 1 + target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 19 +++++++++++++++---- 4 files changed, 20 insertions(+), 5 deletions(-)--
2.25.1
Re: [PATCH v2 2/2] target/riscv: csr: Implement mconfigptr CSR
In reply to Alistair FrancisQuoted 46 lines · Alistair Francis
target/riscv/csr.c static RISCVException epmp(CPURISCVState *env, int
Quoted 24 lines · Rahul Pathak
Signed-off-by Rahul Pathak <[email protected]>--- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)target/riscv/cpu_bits.h +1
-0@@ -140,6 +140,7 @@#define CSR_MARCHID 0xf12#define CSR_MIMPID 0xf13#define CSR_MHARTID 0xf14 +#define CSR_MCONFIGPTR 0xf15/* Machine Trap Setup */ #define CSR_MSTATUS 0x300target/riscv/csr.c +0
-0@@ -209,6 +209,16 @@ static RISCVException epmp(CPURISCVState *env, intcsrno)
Quoted 19 lines
target/riscv/csr.c +10
-0return RISCV_EXCP_ILLEGAL_INST; } + +static RISCVException priv1p12 (CPURISCVState *env,int csrno) +{ +if (env->priv_ver >=PRIV_VERSION_1_12_0 ) { +return RISCV_EXCP_NONE ; + } + +return RISCV_EXCP_ILLEGAL_INST ; +} +#endif /* User Floating-Point CSRs */ @@ -1569,10 +1579,11 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_MINSTRETH] = { "minstreth", any32, read_instreth },
Quoted 12 lines
target/riscv/csr.c riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { · line 1585
Quoted 9 lines
target/riscv/csr.c +4
-4/* Machine Information Registers */ - [CSR_MVENDORID] = { "mvendorid", any, read_zero }, - [CSR_MARCHID] = { "marchid", any, read_zero }, - [CSR_MIMPID] = { "mimpid", any, read_zero }, - [CSR_MHARTID] = { "mhartid", any, read_mhartid }, + [CSR_MVENDORID] = { "mvendorid", any, read_zero }, + [CSR_MARCHID] = { "marchid", any, read_zero }, + [CSR_MIMPID] = { "mimpid", any, read_zero }, + [CSR_MHARTID] = { "mhartid", any, read_mhartid },Why change these?
The alignment of all structure entries is consistent in their respective blocks, that's why I aligned these with the mconfigptr line. It's really not necessary and if my observation on the alignment is really not a requirement I will undo this.
Quoted 11 lines
target/riscv/csr.c riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { · line 1586
Quoted 4 lines
target/riscv/csr.c +1
-0+ [CSR_MCONFIGPTR] = {"mconfigptr", priv1p12, read_zero },This looks fine, but there are more changes then this in v1.12. Looking at the preface we need mret/sret changes at least. It also looks like some other changes will need to be implemented or at least checked.
Agree, I will look into that
Quoted 11 lines
Alistair
target/riscv/csr.c riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { · line 1588
Quoted 3 lines
target/riscv/csr.c +0
-0/* Machine Trap Setup */ [CSR_MSTATUS] = { "mstatus", any, read_mstatus,
write_mstatus},Quoted 4 lines
target/riscv/csr.c +0
-1--2.25.1
Re: [PATCH v2 1/2] target/riscv: Add priv spec 1.12.0 version check
In reply to Alistair FrancisQuoted 23 lines · Alistair Francis
target/riscv/cpu.c static void riscv_cpu_realize(DeviceState *dev,
Quoted 12 lines · Rahul Pathak
Signed-off-by Rahul Pathak <[email protected]>--- target/riscv/cpu.c | 4 +++- target/riscv/cpu.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)target/riscv/cpu.c +0
-0@@ -405,7 +405,9 @@ static void riscv_cpu_realize(DeviceState *dev,Error **errp)
target/riscv/cpu.c static void riscv_cpu_realize(DeviceState *dev, Error **errp) · line 410
Quoted 7 lines
target/riscv/cpu.c +3
-1}if (cpu->cfg.priv_spec) { -if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.11.0" )) { +if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.12.0" )) { + priv_version =PRIV_VERSION_1_12_0 ; + }else if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.11.0" )) {
Quoted 5 lines
This change, actually allowing the user to enable the spec, should be in a separate patch at the end of the series.
The idea is to add the feature, then expose it.
Sure, will change in the next version
Quoted 24 lines
Alistair
Quoted 19 lines
target/riscv/cpu.c +0
-0priv_version =PRIV_VERSION_1_11_0 ; }else if (!g_strcmp0 (cpu->cfg.priv_spec,"v1.10.0" )) { priv_version =PRIV_VERSION_1_10_0 ;target/riscv/cpu.h +1
-1@@ -79,6 +79,7 @@ enum {#define PRIV_VERSION_1_10_0 0x00011000#define PRIV_VERSION_1_11_0 0x00011100 +#define PRIV_VERSION_1_12_0 0x00011200#define VEXT_VERSION_0_07_1 0x00000701 --2.25.1
Quoted 9 lines · Alistair Francis
Quoted 7 lines · Rahul Pathak
Patches add the mconfigptr csr support.
mconfigptr is newly incorporated in risc-v privileged architecture specification 1.12 version.
priv spec 1.12.0 version check is also added.
Quoted 8 lines
Quoted 1 line
qemu-system-riscv64 -nographic -machine virt -cpu rv64,priv_spec=v1.12.0
Thanks for the patches!
I gave some comments in line with the code changes. Overall this looks good, we just need to add the other v1.12.0 features.
Alistair
Thanks Alistair, I will work on the comments and send the next version.
Quoted 29 lines
Quoted 28 lines
Changelog:
v1->v2
------
1. Added privileged architecture spec version 1.12 ("v1.12.0") check
2. Added predicate function for mconfigptr which verifies for priv spec version v1.12.0 or higher.Thanks
RahulRahul Pathak (2):
target/riscv: Add priv spec 1.12.0 version check target/riscv: csr: Implement mconfigptr CSRtarget/riscv/cpu.c | 4 +++- target/riscv/cpu.h | 1 + target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 19 +++++++++++++++---- 4 files changed, 20 insertions(+), 5 deletions(-)--
2.25.1