Skip to contentSkip to conversation

target/riscv: check 'I' and 'E' after checking 'G' in riscv_cpu_realize

PATCH Superseded Weiwei Li 2 participants 7 messages May 16, 2022 – May 17, 2022 RISC-V

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Weiwei Li

author
#0 lore raw

PATCH 1/2 target/riscv: check 'I' and 'E' after checking 'G' in riscv_cpu_realize

- setting ext_g will implicitly set ext_i

---
 slirp              |  2 +-
 target/riscv/cpu.c | 23 ++++++++++++-----------
 2 files changed, 13 insertions(+), 12 deletions(-)
slirp +1 -1
index 9d59bb775d..a88d9ace23 160000
@@ -1 +1 @@
-Subproject commit 9d59bb775d6294c8b447a88512f7bb43f12a25a8
+Subproject commit a88d9ace234a24ce1c17189642ef9104799425e0
target/riscv/cpu.c +12 -11
index ccacdee215..b12f69c584 100644
@@ -583,6 +583,18 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
     if (env->misa_ext == 0) {
         uint32_t ext = 0;
 
+        if (cpu->cfg.ext_g && !(cpu->cfg.ext_i & cpu->cfg.ext_m &
+                                cpu->cfg.ext_a & cpu->cfg.ext_f &
+                                cpu->cfg.ext_d)) {
+            warn_report("Setting G will also set IMAFD");
+            cpu->cfg.ext_i = true;
+            cpu->cfg.ext_m = true;
+            cpu->cfg.ext_a = true;
+            cpu->cfg.ext_f = true;
+            cpu->cfg.ext_d = true;
+        }
+
+
         /* Do some ISA extension error checking */
         if (cpu->cfg.ext_i && cpu->cfg.ext_e) {
             error_setg(errp,
@@ -596,17 +608,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
             return;
         }
 
-        if (cpu->cfg.ext_g && !(cpu->cfg.ext_i & cpu->cfg.ext_m &
-                                cpu->cfg.ext_a & cpu->cfg.ext_f &
-                                cpu->cfg.ext_d)) {
-            warn_report("Setting G will also set IMAFD");
-            cpu->cfg.ext_i = true;
-            cpu->cfg.ext_m = true;
-            cpu->cfg.ext_a = true;
-            cpu->cfg.ext_f = true;
-            cpu->cfg.ext_d = true;
-        }
-
         if (cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinx ||
             cpu->cfg.ext_zhinxmin) {
             cpu->cfg.ext_zfinx = true;
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/2 target/riscv: disable zb* extensions by default

- enable zb* extensions by default will make cpu types(such as sifive-u34) implicitly support zb* extensions

---
 target/riscv/cpu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
target/riscv/cpu.c +4 -4
index b12f69c584..a3a17323e7 100644
@@ -847,13 +847,13 @@ static Property riscv_cpu_properties[] = {
     DEFINE_PROP_BOOL("svnapot", RISCVCPU, cfg.ext_svnapot, false),
     DEFINE_PROP_BOOL("svpbmt", RISCVCPU, cfg.ext_svpbmt, false),
 
-    DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, true),
-    DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, true),
-    DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, true),
+    DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, false),
+    DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, false),
+    DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, false),
     DEFINE_PROP_BOOL("zbkb", RISCVCPU, cfg.ext_zbkb, false),
     DEFINE_PROP_BOOL("zbkc", RISCVCPU, cfg.ext_zbkc, false),
     DEFINE_PROP_BOOL("zbkx", RISCVCPU, cfg.ext_zbkx, false),
-    DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, true),
+    DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, false),
     DEFINE_PROP_BOOL("zk", RISCVCPU, cfg.ext_zk, false),
     DEFINE_PROP_BOOL("zkn", RISCVCPU, cfg.ext_zkn, false),
     DEFINE_PROP_BOOL("zknd", RISCVCPU, cfg.ext_zknd, false),
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 2/2] target/riscv: disable zb* extensions by default

Quoted 2 lines · Weiwei Li

- enable zb* extensions by default will make cpu types(such as sifive-u34) implicitly support zb* extensions

Agh, this is a pain.

Can you enable these by default for the base machines then? That way they will be enabled for the virt machine

Alistair

Quoted 33 lines
---
 target/riscv/cpu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
target/riscv/cpu.c +4 -5
index b12f69c584..a3a17323e7 100644
@@ -847,13 +847,13 @@ static Property riscv_cpu_properties[] = {
     DEFINE_PROP_BOOL("svnapot", RISCVCPU, cfg.ext_svnapot, false),
     DEFINE_PROP_BOOL("svpbmt", RISCVCPU, cfg.ext_svpbmt, false),
 
-    DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, true),
-    DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, true),
-    DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, true),
+    DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, false),
+    DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, false),
+    DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, false),
     DEFINE_PROP_BOOL("zbkb", RISCVCPU, cfg.ext_zbkb, false),
     DEFINE_PROP_BOOL("zbkc", RISCVCPU, cfg.ext_zbkc, false),
     DEFINE_PROP_BOOL("zbkx", RISCVCPU, cfg.ext_zbkx, false),
-    DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, true),
+    DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, false),
     DEFINE_PROP_BOOL("zk", RISCVCPU, cfg.ext_zk, false),
     DEFINE_PROP_BOOL("zkn", RISCVCPU, cfg.ext_zkn, false),
     DEFINE_PROP_BOOL("zknd", RISCVCPU, cfg.ext_zknd, false),
--

2.17.1

#3 lore raw

Re: [PATCH 2/2] target/riscv: disable zb* extensions by default

Quoted 9 lines · Alistair Francis
Quoted 2 lines · Weiwei Li

- enable zb* extensions by default will make cpu types(such as sifive-u34) implicitly support zb* extensions

Agh, this is a pain.

Can you enable these by default for the base machines then? That way they will be enabled for the virt machine

Actually, come to think of it, we can probably just register the riscv_cpu_properties for the base cpus. That way only those CPUs can be configured by the user. Can you do that instead?

Alistair

Quoted 36 lines

Alistair

Quoted 33 lines
---
 target/riscv/cpu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
target/riscv/cpu.c +4 -5
index b12f69c584..a3a17323e7 100644
@@ -847,13 +847,13 @@ static Property riscv_cpu_properties[] = {
     DEFINE_PROP_BOOL("svnapot", RISCVCPU, cfg.ext_svnapot, false),
     DEFINE_PROP_BOOL("svpbmt", RISCVCPU, cfg.ext_svpbmt, false),
 
-    DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, true),
-    DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, true),
-    DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, true),
+    DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, false),
+    DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, false),
+    DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, false),
     DEFINE_PROP_BOOL("zbkb", RISCVCPU, cfg.ext_zbkb, false),
     DEFINE_PROP_BOOL("zbkc", RISCVCPU, cfg.ext_zbkc, false),
     DEFINE_PROP_BOOL("zbkx", RISCVCPU, cfg.ext_zbkx, false),
-    DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, true),
+    DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, false),
     DEFINE_PROP_BOOL("zk", RISCVCPU, cfg.ext_zk, false),
     DEFINE_PROP_BOOL("zkn", RISCVCPU, cfg.ext_zkn, false),
     DEFINE_PROP_BOOL("zknd", RISCVCPU, cfg.ext_zknd, false),
--

2.17.1

author
#4 lore raw

Re: [PATCH 2/2] target/riscv: disable zb* extensions by default

Quoted 5 lines · Alistair Francis
Quoted 4 lines · Alistair Francis
Quoted 1 line · Weiwei Li

- enable zb* extensions by default will make cpu types(such as sifive-u34) implicitly support zb* extensions

Agh, this is a pain.

Quoted 8 lines
Quoted 2 lines

Can you enable these by default for the base machines then? That way they will be enabled for the virt machine

Actually, come to think of it, we can probably just register the riscv_cpu_properties for the base cpus. That way only those CPUs can be configured by the user. Can you do that instead?

Alistair

Yeah, This is OK. I'll do this later.

Regards,

Weiwei Li

Quoted 34 lines
Quoted 34 lines

Alistair

Quoted 32 lines
---
  target/riscv/cpu.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
target/riscv/cpu.c +4 -5
index b12f69c584..a3a17323e7 100644
@@ -847,13 +847,13 @@ static Property riscv_cpu_properties[] = {
      DEFINE_PROP_BOOL("svnapot", RISCVCPU, cfg.ext_svnapot, false),
      DEFINE_PROP_BOOL("svpbmt", RISCVCPU, cfg.ext_svpbmt, false),
 
-    DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, true),
-    DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, true),
-    DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, true),
+    DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, false),
+    DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, false),
+    DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, false),
      DEFINE_PROP_BOOL("zbkb", RISCVCPU, cfg.ext_zbkb, false),
      DEFINE_PROP_BOOL("zbkc", RISCVCPU, cfg.ext_zbkc, false),
      DEFINE_PROP_BOOL("zbkx", RISCVCPU, cfg.ext_zbkx, false),
-    DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, true),
+    DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, false),
      DEFINE_PROP_BOOL("zk", RISCVCPU, cfg.ext_zk, false),
      DEFINE_PROP_BOOL("zkn", RISCVCPU, cfg.ext_zkn, false),
      DEFINE_PROP_BOOL("zknd", RISCVCPU, cfg.ext_zknd, false),
--

2.17.1

#5 lore raw
In reply to Weiwei Li
Quoted 15 lines · Weiwei Li

- setting ext_g will implicitly set ext_i

---
 slirp              |  2 +-
 target/riscv/cpu.c | 23 ++++++++++++-----------
 2 files changed, 13 insertions(+), 12 deletions(-)
slirp +0 -0
index 9d59bb775d..a88d9ace23 160000

slirp line 1

Quoted 2 lines
slirp +1 -1
@@ -1 +1 @@
-Subproject commit 9d59bb775d6294c8b447a88512f7bb43f12a25a8
+Subproject commit a88d9ace234a24ce1c17189642ef9104799425e0

Looks like you accidentally included a submodule change

Alistair

Quoted 45 lines
target/riscv/cpu.c +12 -12
index ccacdee215..b12f69c584 100644
@@ -583,6 +583,18 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
     if (env->misa_ext == 0) {
         uint32_t ext = 0;
 
+        if (cpu->cfg.ext_g && !(cpu->cfg.ext_i & cpu->cfg.ext_m &
+                                cpu->cfg.ext_a & cpu->cfg.ext_f &
+                                cpu->cfg.ext_d)) {
+            warn_report("Setting G will also set IMAFD");
+            cpu->cfg.ext_i = true;
+            cpu->cfg.ext_m = true;
+            cpu->cfg.ext_a = true;
+            cpu->cfg.ext_f = true;
+            cpu->cfg.ext_d = true;
+        }
+
+
         /* Do some ISA extension error checking */
         if (cpu->cfg.ext_i && cpu->cfg.ext_e) {
             error_setg(errp,
@@ -596,17 +608,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
             return;
         }
 
-        if (cpu->cfg.ext_g && !(cpu->cfg.ext_i & cpu->cfg.ext_m &
-                                cpu->cfg.ext_a & cpu->cfg.ext_f &
-                                cpu->cfg.ext_d)) {
-            warn_report("Setting G will also set IMAFD");
-            cpu->cfg.ext_i = true;
-            cpu->cfg.ext_m = true;
-            cpu->cfg.ext_a = true;
-            cpu->cfg.ext_f = true;
-            cpu->cfg.ext_d = true;
-        }
-
         if (cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinx ||
             cpu->cfg.ext_zhinxmin) {
             cpu->cfg.ext_zfinx = true;
--

2.17.1

author
#6 lore raw
Quoted 19 lines · Alistair Francis
Quoted 14 lines · Weiwei Li

- setting ext_g will implicitly set ext_i

---
  slirp              |  2 +-
  target/riscv/cpu.c | 23 ++++++++++++-----------
  2 files changed, 13 insertions(+), 12 deletions(-)
slirp +0 -0
index 9d59bb775d..a88d9ace23 160000

slirp line 1

Quoted 2 lines
slirp +1 -1
@@ -1 +1 @@
-Subproject commit 9d59bb775d6294c8b447a88512f7bb43f12a25a8
+Subproject commit a88d9ace234a24ce1c17189642ef9104799425e0

Looks like you accidentally included a submodule change

Quoted 1 line

Alistair

Sorry. I'll fix this later.

Regards,

Weiwei Li

Quoted 45 lines
Quoted 45 lines
target/riscv/cpu.c +12 -12
index ccacdee215..b12f69c584 100644
@@ -583,6 +583,18 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
      if (env->misa_ext == 0) {
          uint32_t ext = 0;
 
+        if (cpu->cfg.ext_g && !(cpu->cfg.ext_i & cpu->cfg.ext_m &
+                                cpu->cfg.ext_a & cpu->cfg.ext_f &
+                                cpu->cfg.ext_d)) {
+            warn_report("Setting G will also set IMAFD");
+            cpu->cfg.ext_i = true;
+            cpu->cfg.ext_m = true;
+            cpu->cfg.ext_a = true;
+            cpu->cfg.ext_f = true;
+            cpu->cfg.ext_d = true;
+        }
+
+
          /* Do some ISA extension error checking */
          if (cpu->cfg.ext_i && cpu->cfg.ext_e) {
              error_setg(errp,
@@ -596,17 +608,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
              return;
          }
 
-        if (cpu->cfg.ext_g && !(cpu->cfg.ext_i & cpu->cfg.ext_m &
-                                cpu->cfg.ext_a & cpu->cfg.ext_f &
-                                cpu->cfg.ext_d)) {
-            warn_report("Setting G will also set IMAFD");
-            cpu->cfg.ext_i = true;
-            cpu->cfg.ext_m = true;
-            cpu->cfg.ext_a = true;
-            cpu->cfg.ext_f = true;
-            cpu->cfg.ext_d = true;
-        }
-
          if (cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinx ||
              cpu->cfg.ext_zhinxmin) {
              cpu->cfg.ext_zfinx = true;
--

2.17.1