diff mbox

[v8,11/27] ARM: VGIC: add vcpu_id to struct pending_irq

Message ID 1491957874-31600-12-git-send-email-andre.przywara@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andre Przywara April 12, 2017, 12:44 a.m. UTC
The target CPU for an LPI is encoded in the interrupt translation table
entry, so can't be easily derived from just an LPI number (short of
walking *all* tables and find the matching LPI).
To avoid this in case we need to know the VCPU (for the INVALL command,
for instance), put the VCPU ID in the struct pending_irq, so that it is
easily accessible.
We use the remaining 8 bits of padding space for that to avoid enlarging
the size of struct pending_irq. The number of VCPUs is limited to 127
at the moment anyway.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 xen/include/asm-arm/vgic.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Julien Grall April 12, 2017, 12:32 p.m. UTC | #1
Hi Andre,

On 12/04/17 01:44, Andre Przywara wrote:
> The target CPU for an LPI is encoded in the interrupt translation table
> entry, so can't be easily derived from just an LPI number (short of
> walking *all* tables and find the matching LPI).
> To avoid this in case we need to know the VCPU (for the INVALL command,
> for instance), put the VCPU ID in the struct pending_irq, so that it is
> easily accessible.
> We use the remaining 8 bits of padding space for that to avoid enlarging
> the size of struct pending_irq. The number of VCPUs is limited to 127
> at the moment anyway.
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
>  xen/include/asm-arm/vgic.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
> index e2111a5..02732db 100644
> --- a/xen/include/asm-arm/vgic.h
> +++ b/xen/include/asm-arm/vgic.h
> @@ -73,6 +73,7 @@ struct pending_irq
>      uint8_t lr;
>      uint8_t priority;
>      uint8_t lpi_priority;       /* Caches the priority if this is an LPI. */
> +    uint8_t lpi_vcpu_id;        /* The VCPU for an LPI. */

You likely want a BUILD_BUG_ON in the code to check a vCPU ID will fit 
in lpi_vcpu_id. See what we did in p2m_init.

>      /* inflight is used to append instances of pending_irq to
>       * vgic.inflight_irqs */
>      struct list_head inflight;
>

Cheers,
Andre Przywara April 12, 2017, 12:37 p.m. UTC | #2
Hi,

On 12/04/17 13:32, Julien Grall wrote:
> Hi Andre,
> 
> On 12/04/17 01:44, Andre Przywara wrote:
>> The target CPU for an LPI is encoded in the interrupt translation table
>> entry, so can't be easily derived from just an LPI number (short of
>> walking *all* tables and find the matching LPI).
>> To avoid this in case we need to know the VCPU (for the INVALL command,
>> for instance), put the VCPU ID in the struct pending_irq, so that it is
>> easily accessible.
>> We use the remaining 8 bits of padding space for that to avoid enlarging
>> the size of struct pending_irq. The number of VCPUs is limited to 127
>> at the moment anyway.
>>
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>> ---
>>  xen/include/asm-arm/vgic.h | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
>> index e2111a5..02732db 100644
>> --- a/xen/include/asm-arm/vgic.h
>> +++ b/xen/include/asm-arm/vgic.h
>> @@ -73,6 +73,7 @@ struct pending_irq
>>      uint8_t lr;
>>      uint8_t priority;
>>      uint8_t lpi_priority;       /* Caches the priority if this is an
>> LPI. */
>> +    uint8_t lpi_vcpu_id;        /* The VCPU for an LPI. */
> 
> You likely want a BUILD_BUG_ON in the code to check a vCPU ID will fit
> in lpi_vcpu_id. See what we did in p2m_init.

Ah, MAX_VIRT_CPUS was the name I was looking for (but couldn't find)
when I had the very same idea yesterday ;-)

Thanks for the pointer!

Cheers,
Andre.

> 
>>      /* inflight is used to append instances of pending_irq to
>>       * vgic.inflight_irqs */
>>      struct list_head inflight;
>>
diff mbox

Patch

diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index e2111a5..02732db 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -73,6 +73,7 @@  struct pending_irq
     uint8_t lr;
     uint8_t priority;
     uint8_t lpi_priority;       /* Caches the priority if this is an LPI. */
+    uint8_t lpi_vcpu_id;        /* The VCPU for an LPI. */
     /* inflight is used to append instances of pending_irq to
      * vgic.inflight_irqs */
     struct list_head inflight;