Skip to contentSkip to conversation

hw/riscv: virt: Warn the user if -bios is provided when using KVM

PATCH Superseded Ralf Ramsauer 3 participants 8 messages Mar 23, 2022 – Mar 31, 2022 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/riscv: virt: Warn the user if -bios is provided when using 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.

Warn the user that the bios won't be loaded.

---
 hw/riscv/virt.c | 3 +++
 1 file changed, 3 insertions(+)
hw/riscv/virt.c +3 -0
index 4496a15346..a4d13114ee 100644
@@ -1312,6 +1312,9 @@ static void virt_machine_init(MachineState *machine)
      * when KVM is enabled.
      */
     if (kvm_enabled()) {
+        if (machine->firmware && strcmp(machine->firmware, "none"))
+            warn_report("BIOS is not supported in combination with KVM. "
+                        "Ignoring BIOS.");
         g_free(machine->firmware);
         machine->firmware = g_strdup("none");
     }
Signature · 1 line
2.32.0
#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.

Warn the user that the bios won't be loaded.

Thanks for the patch.

hw/riscv/virt.c static void virt_machine_init(MachineState *machine) · line 1315

Quoted 13 lines
---
 hw/riscv/virt.c | 3 +++
 1 file changed, 3 insertions(+)
hw/riscv/virt.c +1 -0
index 4496a15346..a4d13114ee 100644
@@ -1312,6 +1312,9 @@ static void virt_machine_init(MachineState *machine)
      * when KVM is enabled.
      */
     if (kvm_enabled()) {
+        if (machine->firmware && strcmp(machine->firmware, "none"))

You need curly braces around the if statement. You can run checkpatch on the patch to catch issues like this with:

git show | ./scripts/checkpatch.pl -

hw/riscv/virt.c static void virt_machine_init(MachineState *machine) · line 1317

Quoted 2 lines
hw/riscv/virt.c +2 -0
+            warn_report("BIOS is not supported in combination with KVM. "
+                        "Ignoring BIOS.");

Maybe say

"Machine mode firmware is not supported in combination with KVM. Ignoring -bios"

Alistair

Quoted 6 lines
hw/riscv/virt.c +0 -1
         g_free(machine->firmware);
         machine->firmware = g_strdup("none");
     }
--

2.32.0

#2 lore raw
Quoted 30 lines · Alistair Francis
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.

Warn the user that the bios won't be loaded.

Thanks for the patch.

hw/riscv/virt.c static void virt_machine_init(MachineState *machine) · line 1315

Quoted 13 lines
---
  hw/riscv/virt.c | 3 +++
  1 file changed, 3 insertions(+)
hw/riscv/virt.c +1 -0
index 4496a15346..a4d13114ee 100644
@@ -1312,6 +1312,9 @@ static void virt_machine_init(MachineState *machine)
       * when KVM is enabled.
       */
      if (kvm_enabled()) {
+        if (machine->firmware && strcmp(machine->firmware, "none"))

You need curly braces around the if statement. You can run checkpatch on the patch to catch issues like this with:

Quoted 1 line

git show | ./scripts/checkpatch.pl -

total: 0 errors, 0 warnings, 9 lines checked

Your patch has no obvious style problems and is ready for submission.

Quoted 7 lines

hw/riscv/virt.c static void virt_machine_init(MachineState *machine) · line 1317

Quoted 3 lines
hw/riscv/virt.c +2 -0
+            warn_report("BIOS is not supported in combination with KVM. "
+                        "Ignoring BIOS.");

Maybe say

"Machine mode firmware is not supported in combination with KVM. Ignoring -bios"

Anyway, will provide a V2 with an improved warning message.

Thanks
Ralf

Quoted 9 lines

Alistair

Quoted 6 lines
hw/riscv/virt.c +0 -1
          g_free(machine->firmware);
          machine->firmware = g_strdup("none");
      }
--

2.32.0

#3 lore raw

PATCH v2 1/1 hw/riscv: virt: Warn the user if -bios is provided when using KVM

In reply to 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.

Warn the user that the bios won't be loaded.

---
 hw/riscv/virt.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/riscv/virt.c +4 -0
index da50cbed43..0c477addbc 100644
@@ -1312,6 +1312,10 @@ static void virt_machine_init(MachineState *machine)
      * when KVM is enabled.
      */
     if (kvm_enabled()) {
+        if (machine->firmware && strcmp(machine->firmware, "none")) {
+            warn_report("Machine mode firmware is not supported in combination "
+                        "with KVM. Ignoring -bios.");
+        }
         g_free(machine->firmware);
         machine->firmware = g_strdup("none");
     }
Signature · 1 line
2.35.1
Reviewed-by on v2 1/1
#4 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.

Warn the user that the bios won't be loaded.

Thanks!

Alistair

Quoted 22 lines
---
 hw/riscv/virt.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/riscv/virt.c +4 -1
index da50cbed43..0c477addbc 100644
@@ -1312,6 +1312,10 @@ static void virt_machine_init(MachineState *machine)
      * when KVM is enabled.
      */
     if (kvm_enabled()) {
+        if (machine->firmware && strcmp(machine->firmware, "none")) {
+            warn_report("Machine mode firmware is not supported in combination "
+                        "with KVM. Ignoring -bios.");
+        }
         g_free(machine->firmware);
         machine->firmware = g_strdup("none");
     }
--

2.35.1

#5 lore raw
In reply to Ralf Ramsauer
Quoted 16 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.

Warn the user that the bios won't be loaded.

---
 hw/riscv/virt.c | 3 +++
 1 file changed, 3 insertions(+)
hw/riscv/virt.c +0 -0
index 4496a15346..a4d13114ee 100644

hw/riscv/virt.c static void virt_machine_init(MachineState *machine) · line 1317

Quoted 6 lines
hw/riscv/virt.c +3 -0
@@ -1312,6 +1312,9 @@ static void virt_machine_init(MachineState *machine)
      * when KVM is enabled.
      */
     if (kvm_enabled()) {
+        if (machine->firmware && strcmp(machine->firmware, "none"))
+            warn_report("BIOS is not supported in combination with KVM. "
+                        "Ignoring BIOS.");

If the usage scenario isn't supportable, then ultimately we should be raising an error and immediately exiting.

If you know of common usage that is already mistakenly passing -bios, then we could start with a warning and list it as deprecated, then change to an error_report 2 releases later. If we don't thing people are often mistakenly passing -bios, then go straight for error_report and exit.

Quoted 7 lines
hw/riscv/virt.c +0 -0
         g_free(machine->firmware);
         machine->firmware = g_strdup("none");
     }
Signature · 1 line
2.32.0

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#6 lore raw
Quoted 28 lines · Daniel P. Berrangé
Quoted 16 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.

Warn the user that the bios won't be loaded.

---
 hw/riscv/virt.c | 3 +++
 1 file changed, 3 insertions(+)
hw/riscv/virt.c +0 -0
index 4496a15346..a4d13114ee 100644

hw/riscv/virt.c static void virt_machine_init(MachineState *machine) · line 1317

Quoted 6 lines
hw/riscv/virt.c +3 -0
@@ -1312,6 +1312,9 @@ static void virt_machine_init(MachineState *machine)
      * when KVM is enabled.
      */
     if (kvm_enabled()) {
+        if (machine->firmware && strcmp(machine->firmware, "none"))
+            warn_report("BIOS is not supported in combination with KVM. "
+                        "Ignoring BIOS.");

If the usage scenario isn't supportable, then ultimately we should be raising an error and immediately exiting.

Quoted 5 lines

If you know of common usage that is already mistakenly passing -bios, then we could start with a warning and list it as deprecated, then change to an error_report 2 releases later. If we don't thing people are often mistakenly passing -bios, then go straight for error_report and exit.

That's a good point. The original thinking was that we did support -bios and so we should warn the user that it's unlikely they want to use it. This would still allow S mode UEFI loaders to be used (they don't exist today).

Considering we are currently just ignoring the option I agree it's better to report an error.

Do you mind sending a v2 Ralf?

Alistair

Quoted 16 lines
Quoted 8 lines
hw/riscv/virt.c +0 -1
         g_free(machine->firmware);
         machine->firmware = g_strdup("none");
     }
--

2.32.0

With regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#7 lore raw
Quoted 40 lines · Alistair Francis
Quoted 28 lines · Daniel P. Berrangé
Quoted 16 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.

Warn the user that the bios won't be loaded.

---
  hw/riscv/virt.c | 3 +++
  1 file changed, 3 insertions(+)
hw/riscv/virt.c +0 -0
index 4496a15346..a4d13114ee 100644

hw/riscv/virt.c static void virt_machine_init(MachineState *machine) · line 1317

Quoted 6 lines
hw/riscv/virt.c +3 -0
@@ -1312,6 +1312,9 @@ static void virt_machine_init(MachineState *machine)
       * when KVM is enabled.
       */
      if (kvm_enabled()) {
+        if (machine->firmware && strcmp(machine->firmware, "none"))
+            warn_report("BIOS is not supported in combination with KVM. "
+                        "Ignoring BIOS.");

If the usage scenario isn't supportable, then ultimately we should be raising an error and immediately exiting.

Quoted 5 lines

If you know of common usage that is already mistakenly passing -bios, then we could start with a warning and list it as deprecated, then change to an error_report 2 releases later. If we don't thing people are often mistakenly passing -bios, then go straight for error_report and exit.

That's a good point. The original thinking was that we did support -bios and so we should warn the user that it's unlikely they want to use it. This would still allow S mode UEFI loaders to be used (they don't exist today).

Quoted 4 lines

Considering we are currently just ignoring the option I agree it's better to report an error.

Do you mind sending a v2 Ralf?

Yes, will return with another revision. Anyway, I'll choose to exit immediately, as I doubt that there are any non-development users of this particular feature (RISCV/Qemu + KVM) due to the lack of physical hardware.

Thanks
Ralf

Quoted 19 lines

Alistair

Quoted 16 lines
Quoted 8 lines
hw/riscv/virt.c +0 -1
          g_free(machine->firmware);
          machine->firmware = g_strdup("none");
      }
--

2.32.0

With regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|