Skip to contentSkip to conversation

hw/riscv: virt: Exit if the user provided -bios in combination with KVM

PATCH Applied Ralf Ramsauer 4 participants 5 messages Apr 1, 2022 – Apr 12, 2022 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 hw/riscv: virt: Exit if the user provided -bios in combination with KVM

The -bios option is silently ignored if used in combination with -enable-kvm. The reason is that the machine starts in S-Mode, and the bios typically runs in M-Mode.

Better exit in that case to not confuse the user.

---
 hw/riscv/virt.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
hw/riscv/virt.c +10 -4
index da50cbed43..09609c96e8 100644
@@ -1308,12 +1308,18 @@ static void virt_machine_init(MachineState *machine)
 
     /*
      * Only direct boot kernel is currently supported for KVM VM,
-     * so the "-bios" parameter is ignored and treated like "-bios none"
-     * when KVM is enabled.
+     * so the "-bios" parameter is not supported when KVM is enabled.
      */
     if (kvm_enabled()) {
-        g_free(machine->firmware);
-        machine->firmware = g_strdup("none");
+        if (machine->firmware) {
+            if (strcmp(machine->firmware, "none")) {
+                error_report("Machine mode firmware is not supported in "
+                             "combination with KVM.");
+                exit(1);
+            }
+        } else {
+            machine->firmware = g_strdup("none");
+        }
     }
 
     if (riscv_is_32bit(&s->soc[0])) {
Signature · 1 line
2.32.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 8 lines · Ralf Ramsauer

The -bios option is silently ignored if used in combination with -enable-kvm. The reason is that the machine starts in S-Mode, and the bios typically runs in M-Mode.

Better exit in that case to not confuse the user.

Alistair

Quoted 34 lines
---
 hw/riscv/virt.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
hw/riscv/virt.c +10 -5
index da50cbed43..09609c96e8 100644
@@ -1308,12 +1308,18 @@ static void virt_machine_init(MachineState *machine)
 
     /*
      * Only direct boot kernel is currently supported for KVM VM,
-     * so the "-bios" parameter is ignored and treated like "-bios none"
-     * when KVM is enabled.
+     * so the "-bios" parameter is not supported when KVM is enabled.
      */
     if (kvm_enabled()) {
-        g_free(machine->firmware);
-        machine->firmware = g_strdup("none");
+        if (machine->firmware) {
+            if (strcmp(machine->firmware, "none")) {
+                error_report("Machine mode firmware is not supported in "
+                             "combination with KVM.");
+                exit(1);
+            }
+        } else {
+            machine->firmware = g_strdup("none");
+        }
     }
 
     if (riscv_is_32bit(&s->soc[0])) {
--

2.32.0

Reviewed-by on v3 1/1
#2 lore raw
In reply to Ralf Ramsauer
Quoted 5 lines · Ralf Ramsauer

The -bios option is silently ignored if used in combination with -enable-kvm. The reason is that the machine starts in S-Mode, and the bios typically runs in M-Mode.

Quoted 7 lines

Better exit in that case to not confuse the user.

---
 hw/riscv/virt.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
Reviewed-by on v3 1/1
#3 lore raw
In reply to Ralf Ramsauer
Quoted 8 lines · Ralf Ramsauer

The -bios option is silently ignored if used in combination with -enable-kvm. The reason is that the machine starts in S-Mode, and the bios typically runs in M-Mode.

Better exit in that case to not confuse the user.

Looks good to me.

Regards,
Anup

Quoted 34 lines
---
 hw/riscv/virt.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
hw/riscv/virt.c +10 -5
index da50cbed43..09609c96e8 100644
@@ -1308,12 +1308,18 @@ static void virt_machine_init(MachineState *machine)
 
     /*
      * Only direct boot kernel is currently supported for KVM VM,
-     * so the "-bios" parameter is ignored and treated like "-bios none"
-     * when KVM is enabled.
+     * so the "-bios" parameter is not supported when KVM is enabled.
      */
     if (kvm_enabled()) {
-        g_free(machine->firmware);
-        machine->firmware = g_strdup("none");
+        if (machine->firmware) {
+            if (strcmp(machine->firmware, "none")) {
+                error_report("Machine mode firmware is not supported in "
+                             "combination with KVM.");
+                exit(1);
+            }
+        } else {
+            machine->firmware = g_strdup("none");
+        }
     }
 
     if (riscv_is_32bit(&s->soc[0])) {
--

2.32.0

#4 lore raw
In reply to Ralf Ramsauer
Quoted 8 lines · Ralf Ramsauer

The -bios option is silently ignored if used in combination with -enable-kvm. The reason is that the machine starts in S-Mode, and the bios typically runs in M-Mode.

Better exit in that case to not confuse the user.

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 34 lines
---
 hw/riscv/virt.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
hw/riscv/virt.c +10 -5
index da50cbed43..09609c96e8 100644
@@ -1308,12 +1308,18 @@ static void virt_machine_init(MachineState *machine)
 
     /*
      * Only direct boot kernel is currently supported for KVM VM,
-     * so the "-bios" parameter is ignored and treated like "-bios none"
-     * when KVM is enabled.
+     * so the "-bios" parameter is not supported when KVM is enabled.
      */
     if (kvm_enabled()) {
-        g_free(machine->firmware);
-        machine->firmware = g_strdup("none");
+        if (machine->firmware) {
+            if (strcmp(machine->firmware, "none")) {
+                error_report("Machine mode firmware is not supported in "
+                             "combination with KVM.");
+                exit(1);
+            }
+        } else {
+            machine->firmware = g_strdup("none");
+        }
     }
 
     if (riscv_is_32bit(&s->soc[0])) {
--

2.32.0