All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: marc.zyngier@arm.com, xen-devel@lists.xenproject.org,
	Julien Grall <julien.grall@arm.com>
Subject: Re: [PATCH v3 18/39] ARM: new VGIC: Add CTLR, TYPER and IIDR handlers
Date: Wed, 28 Mar 2018 11:36:37 +0100	[thread overview]
Message-ID: <22aabd4d-df1b-0743-5453-c453e9754784@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1803271329370.12360@sstabellini-ThinkPad-X260>

Hi,

On 27/03/18 21:38, Stefano Stabellini wrote:
> On Wed, 21 Mar 2018, Andre Przywara wrote:
>> Those three registers are v2 emulation specific, so their implementation
>> lives entirely in vgic-mmio-v2.c. Also they are handled in one function,
>> as their implementation is pretty simple.
>> We choose to piggy-back on the existing KVM identification registers,
>> but use a different variant (major revision).
> 
> CC'ing Marc.
> 
> Reusing the KVM product ID could cause issues, for instance we could
> clash with KVM if Linux changes the Major number. If we were to actually
> reuse KVM's PRODUCT_ID we would need a better coordination in place.

Marc is aware of this, as this approach was decided after a brief
discussion with Julien and him last week.
If we need a quirk on the (guest) GIC driver side for the KVM VGIC, KVM
would bump the revision number, not the variant.
This is a good as coordination can realistically ever get.

> I suggest to either introduce a Xen specific PRODUCT_ID,

This is a bit of a stretch. Firstly, by the nature of this port the two
implementations are really close. Secondly: we can't really just occupy
any product ID. Technically the "K" isn't even reserved, but this ship
has sailed, so we could just piggy back on that for simplicity.

> or simply reuse
> the hardware value like the old vgic does for now. We can fix this
> later.

This implementation is totally different from anything existing. And we
don't want the guest to apply any errata fixes for the particular
hardware GIC. So using the hardware ID is not the best idea.

Cheers,
Andre

> In fact, I would be happy to swith to KVM's product id after appropriate
> discussions with the KVM community. At the very least, it would need to
> be written down somewhere under docs/ and/or Documentation.
> 
> Marc, what do you think?
> 
> 
>> When the guest enables the distributor, we kick all VCPUs to get
>> potentially pending interrupts serviced.
>>
>> This is based on Linux commit 2b0cda878965, written by Marc Zyngier.
>>
>> Signed-off-by: Andre Przywara <andre.przywara@linaro.org>
>> ---
>> Changelog v2 ... v3:
>> - fix misleading comment about PRODUCT_ID letter
>> - clarify on meaning of VARIANT_ID_XEN
>>
>> Changelog v1 ... v2:
>> use new IIDR values (KVM product ID, Xen revision)
>> - add comment on handling GICD enablement
>> - use new vcpu_kick() function
>>
>>  xen/arch/arm/vgic/vgic-mmio-v2.c | 63 +++++++++++++++++++++++++++++++++++++++-
>>  xen/arch/arm/vgic/vgic.c         | 15 ++++++++++
>>  xen/arch/arm/vgic/vgic.h         |  9 ++++++
>>  3 files changed, 86 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c
>> index 6f10cf16ca..43c1ab5906 100644
>> --- a/xen/arch/arm/vgic/vgic-mmio-v2.c
>> +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c
>> @@ -20,9 +20,70 @@
>>  #include "vgic.h"
>>  #include "vgic-mmio.h"
>>  
>> +static unsigned long vgic_mmio_read_v2_misc(struct vcpu *vcpu,
>> +                                            paddr_t addr, unsigned int len)
>> +{
>> +    uint32_t value;
>> +
>> +    switch ( addr & 0x0c )      /* filter for the 4 registers handled here */
>> +    {
>> +    case GICD_CTLR:
>> +        value = vcpu->domain->arch.vgic.enabled ? GICD_CTL_ENABLE : 0;
>> +        break;
>> +    case GICD_TYPER:
>> +        value = vcpu->domain->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS;
>> +        value = (value >> 5) - 1;
>> +        value |= (vcpu->domain->max_vcpus - 1) << 5;
> 
> NIT: You can reuse GICD_TYPE_CPUS_SHIFT
> 
> 
>> +        break;
>> +    case GICD_IIDR:
>> +        value = (PRODUCT_ID_KVM << 24) |
>> +                (VARIANT_ID_XEN << 16) |
>> +                (IMPLEMENTER_ARM << 0);
>> +        break;
>> +    default:
>> +        return 0;
>> +    }
>> +
>> +    return value;
>> +}
>> +
>> +static void vgic_mmio_write_v2_misc(struct vcpu *vcpu,
>> +                                    paddr_t addr, unsigned int len,
>> +                                    unsigned long val)
>> +{
>> +    struct vgic_dist *dist = &vcpu->domain->arch.vgic;
>> +    bool enabled;
>> +
>> +    switch ( addr & 0x0c )      /* filter for the 4 registers handled here */
>> +    {
>> +    case GICD_CTLR:
>> +        domain_lock(vcpu->domain);
>> +
>> +        /*
>> +         * Store the new enabled state in our distributor structure.
>> +         * Work out whether it was disabled before and now got enabled,
>> +         * so that we signal all VCPUs to check for interrupts to be injected.
>> +         */
>> +        enabled = dist->enabled;
>> +        dist->enabled = val & GICD_CTL_ENABLE;
>> +        enabled = !enabled && dist->enabled;
>> +
>> +        domain_unlock(vcpu->domain);
>> +
>> +        if ( enabled )
>> +            vgic_kick_vcpus(vcpu->domain);
>> +
>> +        break;
>> +    case GICD_TYPER:
>> +    case GICD_IIDR:
>> +        /* read-only, writes ignored */
>> +        return;
>> +    }
>> +}
>> +
>>  static const struct vgic_register_region vgic_v2_dist_registers[] = {
>>      REGISTER_DESC_WITH_LENGTH(GICD_CTLR,
>> -        vgic_mmio_read_raz, vgic_mmio_write_wi, 12,
>> +        vgic_mmio_read_v2_misc, vgic_mmio_write_v2_misc, 12,
>>          VGIC_ACCESS_32bit),
>>      REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_IGROUPR,
>>          vgic_mmio_read_rao, vgic_mmio_write_wi, 1,
>> diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c
>> index 925cda4580..37b425a16c 100644
>> --- a/xen/arch/arm/vgic/vgic.c
>> +++ b/xen/arch/arm/vgic/vgic.c
>> @@ -684,6 +684,21 @@ int vgic_vcpu_pending_irq(struct vcpu *vcpu)
>>      return ret;
>>  }
>>  
>> +void vgic_kick_vcpus(struct domain *d)
>> +{
>> +    struct vcpu *vcpu;
>> +
>> +    /*
>> +     * We've injected an interrupt, time to find out who deserves
>> +     * a good kick...
>> +     */
>> +    for_each_vcpu( d, vcpu )
>> +    {
>> +        if ( vgic_vcpu_pending_irq(vcpu) )
>> +            vcpu_kick(vcpu);
>> +    }
>> +}
>> +
>>  /*
>>   * Local variables:
>>   * mode: C
>> diff --git a/xen/arch/arm/vgic/vgic.h b/xen/arch/arm/vgic/vgic.h
>> index 7f221fd195..aed7e4179a 100644
>> --- a/xen/arch/arm/vgic/vgic.h
>> +++ b/xen/arch/arm/vgic/vgic.h
>> @@ -17,6 +17,14 @@
>>  #ifndef __XEN_ARM_VGIC_VGIC_H__
>>  #define __XEN_ARM_VGIC_VGIC_H__
>>  
>> +/*
>> + * We piggy-back on the already used KVM product ID,  but use a different
>> + * variant (major revision) for Xen.
>> + */
>> +#define PRODUCT_ID_KVM          0x4b        /* ASCII code K */
>> +#define VARIANT_ID_XEN          0x01
>> +#define IMPLEMENTER_ARM         0x43b
>> +
>>  #define vgic_irq_is_sgi(intid) ((intid) < VGIC_NR_SGIS)
>>  
>>  static inline bool irq_is_pending(struct vgic_irq *irq)
>> @@ -37,6 +45,7 @@ struct vgic_irq *vgic_get_irq(struct domain *d, struct vcpu *vcpu,
>>  void vgic_put_irq(struct domain *d, struct vgic_irq *irq);
>>  void vgic_queue_irq_unlock(struct domain *d, struct vgic_irq *irq,
>>                             unsigned long flags);
>> +void vgic_kick_vcpus(struct domain *d);
>>  
>>  static inline void vgic_get_irq_kref(struct vgic_irq *irq)
>>  {

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-03-28 10:36 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21 16:31 [PATCH v3 00/39] New VGIC(-v2) implementation Andre Przywara
2018-03-21 16:31 ` [PATCH v3 01/39] xen/arm: gic: Read unconditionally the source from the LRs Andre Przywara
2018-03-21 16:31 ` [PATCH v3 02/39] ARM: GIC: add GIC_INVALID to enum gic_version Andre Przywara
2018-03-22  1:39   ` Julien Grall
2018-03-26 20:08   ` Stefano Stabellini
2018-03-21 16:31 ` [PATCH v3 03/39] ARM: GIC: Allow tweaking the active and pending state of an IRQ Andre Przywara
2018-03-22  1:51   ` Julien Grall
2018-03-22 11:11     ` Andre Przywara
2018-03-21 16:32 ` [PATCH v3 04/39] ARM: GIC: Allow reading pending state of a hardware IRQ Andre Przywara
2018-03-26 20:08   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 05/39] ARM: timer: Handle level triggered IRQs correctly Andre Przywara
2018-03-22  1:58   ` Julien Grall
2018-03-26 20:28   ` Stefano Stabellini
2018-03-27 13:06     ` Andre Przywara
2018-03-27 18:17       ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 06/39] ARM: evtchn: " Andre Przywara
2018-03-22  2:08   ` Julien Grall
2018-03-26 20:08   ` Stefano Stabellini
2018-03-28  0:01   ` Stefano Stabellini
2018-03-28 15:39     ` Andre Przywara
2018-03-28 17:46       ` Stefano Stabellini
2018-03-29  0:34         ` Julien Grall
2018-03-29 13:44         ` Andre Przywara
2018-04-03 13:34     ` Julien Grall
2018-03-21 16:32 ` [PATCH v3 07/39] ARM: vPL011: Use the VGIC's level triggered IRQs handling if available Andre Przywara
2018-03-26 20:20   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 08/39] ARM: new VGIC: Add data structure definitions Andre Przywara
2018-03-26 20:41   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 09/39] ARM: new VGIC: Add accessor to new struct vgic_irq instance Andre Przywara
2018-03-22  2:11   ` Julien Grall
2018-03-26 20:46     ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 10/39] ARM: new VGIC: Implement virtual IRQ injection Andre Przywara
2018-03-26 21:01   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 11/39] Add list_sort() routine from Linux Andre Przywara
2018-03-21 17:01   ` Jan Beulich
2018-03-22  2:14   ` Julien Grall
2018-03-21 16:32 ` [PATCH v3 12/39] ARM: new VGIC: Add IRQ sorting Andre Przywara
2018-03-26 21:16   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 13/39] ARM: new VGIC: Add IRQ sync/flush framework Andre Przywara
2018-03-22  2:16   ` Julien Grall
2018-03-26 21:30   ` Stefano Stabellini
2018-03-27 13:23     ` Andre Przywara
2018-03-27 18:55       ` Stefano Stabellini
2018-03-27 19:20         ` Stefano Stabellini
2018-03-27 22:13           ` André Przywara
2018-03-21 16:32 ` [PATCH v3 14/39] ARM: new VGIC: Add GICv2 world switch backend Andre Przywara
2018-03-22  3:48   ` Julien Grall
2018-03-22 11:04     ` Andre Przywara
2018-03-22 13:55       ` Julien Grall
2018-03-21 16:32 ` [PATCH v3 15/39] ARM: new VGIC: Implement vgic_vcpu_pending_irq Andre Przywara
2018-03-22  3:52   ` Julien Grall
2018-03-22 11:15     ` Andre Przywara
2018-03-26 23:34       ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 16/39] ARM: new VGIC: Add MMIO handling framework Andre Przywara
2018-03-27 20:07   ` Stefano Stabellini
2018-03-28  9:28     ` Andre Przywara
2018-03-21 16:32 ` [PATCH v3 17/39] ARM: new VGIC: Add GICv2 " Andre Przywara
2018-03-27 20:28   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 18/39] ARM: new VGIC: Add CTLR, TYPER and IIDR handlers Andre Przywara
2018-03-22  7:33   ` Julien Grall
2018-03-27 20:38   ` Stefano Stabellini
2018-03-28 10:36     ` Andre Przywara [this message]
2018-03-28 17:20       ` Stefano Stabellini
2018-03-28 17:22       ` [PATCH v3 26/39] ARM: new VGIC: Add SGIPENDR register handlers Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 19/39] ARM: new VGIC: Add ENABLE registers handlers Andre Przywara
2018-03-27 21:06   ` Stefano Stabellini
2018-03-28  9:09     ` Andre Przywara
2018-03-28 17:19       ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 20/39] ARM: new VGIC: Add PENDING " Andre Przywara
2018-03-27 21:14   ` Stefano Stabellini
2018-03-28 14:10     ` Andre Przywara
2018-03-21 16:32 ` [PATCH v3 21/39] ARM: new VGIC: Add ACTIVE " Andre Przywara
2018-03-27 21:21   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 22/39] ARM: new VGIC: Add PRIORITY " Andre Przywara
2018-03-27 21:24   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 23/39] ARM: new VGIC: Add CONFIG " Andre Przywara
2018-03-27 21:26   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 24/39] ARM: new VGIC: Add TARGET " Andre Przywara
2018-03-27  0:24   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 25/39] ARM: new VGIC: Add SGIR register handler Andre Przywara
2018-03-22  7:54   ` Julien Grall
2018-03-27 22:23   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 26/39] ARM: new VGIC: Add SGIPENDR register handlers Andre Przywara
2018-03-27 22:27   ` Stefano Stabellini
2018-03-28 10:37     ` Andre Przywara
2018-03-21 16:32 ` [PATCH v3 27/39] ARM: new VGIC: Handle hardware mapped IRQs Andre Przywara
2018-03-27 22:31   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 28/39] ARM: new VGIC: Add event channel IRQ handling Andre Przywara
2018-03-27 22:33   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 29/39] ARM: new VGIC: Handle virtual IRQ allocation/reservation Andre Przywara
2018-03-27 22:38   ` Stefano Stabellini
2018-03-28  9:17     ` Andre Przywara
2018-03-21 16:32 ` [PATCH v3 30/39] ARM: new VGIC: Dump virtual IRQ info Andre Przywara
2018-03-27 22:39   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 31/39] ARM: new VGIC: Provide system register emulation stub Andre Przywara
2018-03-27 22:40   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 32/39] ARM: new VGIC: Implement arch_move_irqs() Andre Przywara
2018-03-26 23:46   ` Stefano Stabellini
2018-03-28 18:47   ` Stefano Stabellini
2018-03-29 14:57     ` Andre Przywara
2018-03-21 16:32 ` [PATCH v3 33/39] ARM: new VGIC: Add preliminary stub implementation Andre Przywara
2018-03-27 22:48   ` Stefano Stabellini
2018-04-03 13:22     ` Julien Grall
2018-03-21 16:32 ` [PATCH v3 34/39] ARM: new VGIC: vgic-init: register VGIC Andre Przywara
2018-03-22  8:00   ` Julien Grall
2018-03-22 11:18     ` Andre Przywara
2018-03-27 22:50     ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 35/39] ARM: new VGIC: Add vgic_v2_enable Andre Przywara
2018-03-27 22:51   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 36/39] ARM: new VGIC: vgic-init: implement vgic_init Andre Przywara
2018-03-22  8:01   ` Julien Grall
2018-03-27 23:16   ` Stefano Stabellini
2018-03-28  0:06     ` Stefano Stabellini
2018-03-28 10:49     ` Andre Przywara
2018-03-21 16:32 ` [PATCH v3 37/39] ARM: new VGIC: vgic-init: implement map_resources Andre Przywara
2018-03-27 23:09   ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 38/39] ARM: new VGIC: Allocate two pages for struct vcpu Andre Przywara
2018-03-22  8:11   ` Julien Grall
2018-03-27 23:07     ` Stefano Stabellini
2018-03-21 16:32 ` [PATCH v3 39/39] ARM: VGIC: wire new VGIC(-v2) files into Xen build system Andre Przywara
2018-03-22  8:16   ` Julien Grall
2018-03-22 10:39     ` Andre Przywara

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=22aabd4d-df1b-0743-5453-c453e9754784@arm.com \
    --to=andre.przywara@arm.com \
    --cc=julien.grall@arm.com \
    --cc=marc.zyngier@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.