[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC 2/2] hw/arm/virt: kvm: allow gicv3 by default if host does not
From: |
Andrew Jones |
Subject: |
Re: [RFC 2/2] hw/arm/virt: kvm: allow gicv3 by default if host does not support v2 |
Date: |
Thu, 27 Feb 2020 09:48:07 +0100 |
On Wed, Feb 26, 2020 at 06:05:00PM +0100, Eric Auger wrote:
> At the moment if the end-user does not specify the gic-version along
> with KVM acceleration, v2 is set by default. However most of the
> systems now have GICv3 and sometimes they do not support GICv2
> compatibility. In that case we end up with this error:
>
> qemu-system-aarch64: PMU: KVM_SET_DEVICE_ATTR: Invalid argument
> qemu-system-aarch64: failed to set irq for PMU
> and qemu aborts.
>
> This patch keeps the default v2 selection in all cases except
> in the KVM accelerated mode when the host does not support v2.
> This case did not work anyway so we do not break any compatibility.
> Now we get v3 selected in such a case. Also if the end-user explicitly
> sets v2 whereas this latter is not supported, we also are
> informed that v2 is not selected by thos host instead of getting the
> above PMU related message.
>
> Signed-off-by: Eric Auger <address@hidden>
> Reported-by: Dr. David Alan Gilbert <address@hidden>
> ---
> hw/arm/virt.c | 30 ++++++++++++++++++++++++++++++
> include/hw/arm/virt.h | 1 +
> 2 files changed, 31 insertions(+)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index a196bbf0d5..b37b0c40c1 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1554,6 +1554,33 @@ static void machvirt_init(MachineState *machine)
> }
> }
> }
> + } else if (kvm_enabled()) {
> + int probe_bitmap = kvm_arm_vgic_probe();
> +
> + if (!probe_bitmap) {
> + error_report(
> + "Unable to determine GIC version supported by host");
> + exit(1);
> + }
> + if (!vms->gic_version_user_selected) {
> + /*
> + * by default v2 is supposed to be chosen: check it is
> + * supported by the host. Otherwise take v3.
> + */
> + if (probe_bitmap & KVM_ARM_VGIC_V2) {
How about 'if ((probe_bitmap & KVM_ARM_VGIC_V2) && max_cpus <= GIC_NCPU)',
because even on gicv3 hosts that support gicv2 guests command lines that
didn't specify a gic version and did specify more than 8 vcpus were also
broken. We can now automagically allow those to work too.
Thanks,
drew