From: Andrew Jones <drjones@redhat.com>
To: Haibo Xu <haibo.xu@linaro.org>
Cc: peter.maydell@linaro.org, richard.henderson@linaro.org,
qemu-devel@nongnu.org, abologna@redhat.com, qemu-arm@nongnu.org,
philmd@redhat.com
Subject: Re: [PATCH RESEND v2 4/6] hw/intc/arm_gicv3: Enable support for setting vGIC maintenance IRQ
Date: Tue, 27 Apr 2021 10:55:27 +0200 [thread overview]
Message-ID: <20210427085527.fvzbmxppceutdugn@gator.home> (raw)
In-Reply-To: <49a4944e2f148c56938380b981afe154b7a8b7ee.1617281290.git.haibo.xu@linaro.org>
On Thu, Apr 01, 2021 at 05:55:36AM -0700, Haibo Xu wrote:
> Using the new VGIC KVM device attribute to set the maintenance IRQ.
> This is fixed to use IRQ 25(PPI 9), as a platform decision matching
> the arm64 SBSA recommendation.
>
> Signed-off-by: Haibo Xu <haibo.xu@linaro.org>
> ---
> hw/arm/virt.c | 5 +++++
> hw/intc/arm_gicv3_common.c | 1 +
> hw/intc/arm_gicv3_kvm.c | 16 ++++++++++++++++
> include/hw/intc/arm_gicv3_common.h | 1 +
> 4 files changed, 23 insertions(+)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index aa2bbd14e0..92d46ebcfe 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -663,6 +663,11 @@ static void create_gic(VirtMachineState *vms)
> qdev_prop_set_uint32(vms->gic, "redist-region-count[1]",
> MIN(smp_cpus - redist0_count, redist1_capacity));
> }
> +
> + if (kvm_irqchip_in_kernel()) {
> + bool el2 = object_property_get_bool(OBJECT(first_cpu), "el2", NULL);
> + qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", el2);
> + }
> } else {
> if (!kvm_irqchip_in_kernel()) {
> qdev_prop_set_bit(vms->gic, "has-virtualization-extensions",
> diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
> index 58ef65f589..3ac10c8e61 100644
> --- a/hw/intc/arm_gicv3_common.c
> +++ b/hw/intc/arm_gicv3_common.c
> @@ -495,6 +495,7 @@ static Property arm_gicv3_common_properties[] = {
> DEFINE_PROP_UINT32("num-irq", GICv3State, num_irq, 32),
> DEFINE_PROP_UINT32("revision", GICv3State, revision, 3),
> DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0),
> + DEFINE_PROP_BOOL("has-virtualization-extensions", GICv3State, virt_extn, 0),
> DEFINE_PROP_ARRAY("redist-region-count", GICv3State, nb_redist_regions,
> redist_region_count, qdev_prop_uint32, uint32_t),
> DEFINE_PROP_END_OF_LIST(),
> diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
> index 65a4c880a3..1e1ca66e2c 100644
> --- a/hw/intc/arm_gicv3_kvm.c
> +++ b/hw/intc/arm_gicv3_kvm.c
> @@ -826,6 +826,22 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
> kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
> KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, &error_abort);
>
> + if (s->virt_extn) {
> + bool maint_irq_allowed;
> + uint32_t maint_irq = 25;
Please use KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ + 16, or better would be
something like PPI(KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ). We have a PPI() macro
in virt.h. I'm not sure if/where we could move that, though.
> +
> + maint_irq_allowed =
> + kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ, 0);
> + if (!maint_irq_allowed) {
I'll defer to the maintainers, but I'd rather see
if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ, 0)) {
which is slightly longer than 80 chars, then require the use of a local
variable and the broken assignment line.
> + error_setg(errp, "VGICv3 setting maintenance IRQ are not "
> + "supported by this host kernel");
"VGICv3 maintenance IRQ setting is not supported by this host kernel"
Also, I think we're trying not to brake error lines like this. It makes
grepping harder.
> + return;
> + }
> +
> + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ,
> + 0, &maint_irq, true, &error_abort);
> + }
> +
> kvm_arm_register_device(&s->iomem_dist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,
> KVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd, 0);
>
> diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
> index 91491a2f66..921ddc2c5f 100644
> --- a/include/hw/intc/arm_gicv3_common.h
> +++ b/include/hw/intc/arm_gicv3_common.h
> @@ -220,6 +220,7 @@ struct GICv3State {
> uint32_t num_irq;
> uint32_t revision;
> bool security_extn;
> + bool virt_extn;
> bool irq_reset_nonsecure;
> bool gicd_no_migration_shift_bug;
>
> --
> 2.17.1
>
>
Thanks,
drew
next prev parent reply other threads:[~2021-04-27 8:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 12:55 [PATCH RESEND v2 0/6] target/arm: Add nested virtualization support Haibo Xu
2021-04-01 12:55 ` [PATCH RESEND v2 1/6] Update linux header with new arm64 NV macro Haibo Xu
2021-04-01 12:55 ` [PATCH RESEND v2 2/6] target/arm/kvm: Add helper to detect el2 when using KVM Haibo Xu
2021-04-27 8:27 ` Andrew Jones
2021-04-01 12:55 ` [PATCH RESEND v2 3/6] target/arm/kvm: Add an option to turn on/off el2 support Haibo Xu
2021-04-27 8:38 ` Andrew Jones
2021-04-27 9:29 ` Peter Maydell
2021-04-01 12:55 ` [PATCH RESEND v2 4/6] hw/intc/arm_gicv3: Enable support for setting vGIC maintenance IRQ Haibo Xu
2021-04-27 8:55 ` Andrew Jones [this message]
2021-04-01 12:55 ` [PATCH RESEND v2 5/6] target/arm/cpu: Enable 'el2' to work with host/max cpu Haibo Xu
2021-04-27 9:24 ` Andrew Jones
2021-04-27 9:38 ` Peter Maydell
2021-04-27 9:49 ` Andrew Jones
2021-04-27 12:04 ` Peter Maydell
2021-04-01 12:55 ` [PATCH RESEND v2 6/6] target/arm: Add vCPU feature 'el2' test Haibo Xu
2021-04-27 9:37 ` Andrew Jones
2021-04-01 17:53 ` [PATCH RESEND v2 0/6] target/arm: Add nested virtualization support Andrea Bolognani
2021-04-27 9:40 ` Andrew Jones
2021-04-27 9:42 ` Peter Maydell
2021-04-27 9:54 ` Andrew Jones
2021-04-27 12:15 ` Peter Maydell
2021-04-27 14:48 ` Andrew Jones
2021-04-27 14:58 ` Peter Maydell
2021-04-27 15:01 ` Peter Maydell
2021-04-27 16:17 ` Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210427085527.fvzbmxppceutdugn@gator.home \
--to=drjones@redhat.com \
--cc=abologna@redhat.com \
--cc=haibo.xu@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).