accel: Introduce current_accel_name()
PATCH v2 1/2 accel: Introduce current_accel_name()
We need to fetch the name of the current accelerator in flexible error messages more going forward. Let's create a helper that gives it to us without casting in the target code.
--- accel/accel-common.c | 8 ++++++++ include/qemu/accel.h | 1 + softmmu/vl.c | 3 +-- 3 files changed, 10 insertions(+), 2 deletions(-)
accel/accel-common.c +8 -0
@@ -49,6 +49,14 @@ AccelClass *accel_find(const char *opt_name)return ac; } +/* Return the name of the current accelerator */ +const char *current_accel_name (void ) +{ +AccelClass *ac =ACCEL_GET_CLASS (current_accel ()); + +return ac->name; +} +static void accel_init_cpu_int_aux (ObjectClass *klass,void *opaque) {CPUClass *cc =CPU_CLASS (klass);
include/qemu/accel.h +1 -0
@@ -68,6 +68,7 @@ typedef struct AccelClass {AccelClass *accel_find (const char *opt_name);AccelState *current_accel (void ); +const char *current_accel_name (void );void accel_init_interfaces (AccelClass *ac);
softmmu/vl.c +1 -2
@@ -2271,8 +2271,7 @@ static void configure_accelerators(const char *progname) }if (init_failed && !qtest_chrdev) { -AccelClass *ac =ACCEL_GET_CLASS (current_accel ()); -error_report ("falling back to %s" , ac->name); +error_report ("falling back to %s" ,current_accel_name ()); }if (icount_enabled () && !tcg_enabled ()) {
Signature · 1 line
2.32.1 (Apple Git-133)
PATCH v2 2/2 target/arm: Catch invalid kvm state also for hvf
Some features such as running in EL3 or running M profile code are incompatible with virtualization as QEMU implements it today. To prevent users from picking invalid configurations on other virt solutions like Hvf, let's run the same checks there too.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1073
---
v1 -> v2:
- Use current_accel_name()
- Use !tcg_enabled()
--- target/arm/cpu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
target/arm/cpu.c +7 -4
@@ -1490,7 +1490,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } } -if (kvm_enabled ()) { +if (!tcg_enabled ()) {/* * Catch all the cases which might cause us to create more than one * address space for the CPU (otherwise we will assert() later in
@@ -1498,17 +1498,20 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)*/ if (arm_feature (env,ARM_FEATURE_M )) {error_setg (errp, -"Cannot enable KVM when using an M-profile guest CPU" ); +"Cannot enable %s when using an M-profile guest CPU" , +current_accel_name ());return ; }if (cpu->has_el3) {error_setg (errp, -"Cannot enable KVM when guest CPU has EL3 enabled" ); +"Cannot enable %s when guest CPU has EL3 enabled" , +current_accel_name ());return ; }if (cpu->tag_memory) {error_setg (errp, -"Cannot enable KVM when guest CPUs has MTE enabled" ); +"Cannot enable %s when guest CPUs has MTE enabled" , +current_accel_name ());return ; } }
Signature · 1 line
2.32.1 (Apple Git-133)
Re: [PATCH v2 2/2] target/arm: Catch invalid kvm state also for hvf
Quoted 10 lines · Alexander Graf
Some features such as running in EL3 or running M profile code are incompatible with virtualization as QEMU implements it today. To prevent users from picking invalid configurations on other virt solutions like Hvf, let's run the same checks there too.
Resolves:https://gitlab.com/qemu-project/qemu/-/issues/1073
Signed-off-by Alexander Graf<[email protected]>---
Quoted 7 lines
v1 -> v2:
- Use
current_accel_name()
- Use !tcg_enabled()--- target/arm/cpu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
r~
Re: [PATCH v2 2/2] target/arm: Catch invalid kvm state also for hvf
In reply to Alexander GrafQuoted 13 lines · Alexander Graf
Some features such as running in EL3 or running M profile code are incompatible with virtualization as QEMU implements it today. To prevent users from picking invalid configurations on other virt solutions like Hvf, let's run the same checks there too.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1073
Signed-off-by Alexander Graf <[email protected]>
target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1493
Quoted 5 lines
target/arm/cpu.c +1
-1@@ -1490,7 +1490,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } } -if (kvm_enabled ()) { +if (!tcg_enabled ()) {
I'm a bit surprised we don't need to also have "&& !qtest_enabled()", but I guess if "make check" works then we're fine :-)
-- PMM
Re: [PATCH v2 2/2] target/arm: Catch invalid kvm state also for hvf
Quoted 18 lines · Peter Maydell
Quoted 16 lines · Alexander Graf
Some features such as running in EL3 or running M profile code are incompatible with virtualization as QEMU implements it today. To prevent users from picking invalid configurations on other virt solutions like Hvf, let's run the same checks there too.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1073
Signed-off-by Alexander Graf <[email protected]>target/arm/cpu.c +0
-0@@ -1490,7 +1490,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } }
Quoted 5 lines
target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1493
Quoted 2 lines
target/arm/cpu.c +1
-1-if (kvm_enabled ()) { +if (!tcg_enabled ()) {I'm a bit surprised we don't need to also have "&& !qtest_enabled()", but I guess if "make check" works then we're fine :-)
In fact you do need to handle qtest here too, otherwise lots of tests in 'make check' barf on the unexpected error...
I'm going to squash the following fix in and take the patchset into target-arm.next. (PS: you forgot the cover letter, I think ?)
target/arm/cpu.c +1 -0
@@ -39,6 +39,7 @@#include "hw/boards.h" #endif #include "sysemu/tcg.h" +#include "sysemu/qtest.h" #include "sysemu/hw_accel.h" #include "kvm_arm.h" #include "disas/capstone.h"
@@ -1490,8 +1491,12 @@ static void arm_cpu_realizefn(DeviceState *dev,
Error **errp)
}
}- if (!tcg_enabled()) {
+ if (!tcg_enabled() && !qtest_enabled()) {
/*
+ * We assume that no accelerator except TCG (and the "not really an
+ * accelerator" qtest) can handle these features, because Arm hardware
+ * virtualization can't virtualize them.
+ * * Catch all the cases which might cause us to create more than one
* address space for the CPU (otherwise we will assert() later in
* cpu_address_space_init()).
thanks
-- PMM
Quoted 10 lines · Alexander Graf
We need to fetch the name of the current accelerator in flexible error messages more going forward. Let's create a helper that gives it to us without casting in the target code.
Signed-off-by Alexander Graf<[email protected]>--- accel/accel-common.c | 8 ++++++++ include/qemu/accel.h | 1 + softmmu/vl.c | 3 +-- 3 files changed, 10 insertions(+), 2 deletions(-)
r~