[PATCH v1 0/3] vpci/msix: separate out common MSI-X code

Mykyta Poturai posted 3 patches 4 weeks ago
xen/arch/x86/include/asm/msi.h      |  21 ---
xen/arch/x86/msi.c                  |   2 +-
xen/drivers/passthrough/amd/iommu.h |   2 +-
xen/drivers/vpci/Makefile           |   6 +-
xen/drivers/vpci/header.c           |  30 +----
xen/drivers/vpci/msi.c              |   3 +-
xen/drivers/vpci/msix.c             | 197 ++++++---------------------
xen/drivers/vpci/msix_common.c      | 202 ++++++++++++++++++++++++++++
xen/drivers/vpci/private.h          |   2 +
xen/include/xen/msi.h               |  21 +++
xen/include/xen/vpci.h              |   5 +
11 files changed, 282 insertions(+), 209 deletions(-)
create mode 100644 xen/drivers/vpci/msix_common.c
[PATCH v1 0/3] vpci/msix: separate out common MSI-X code
Posted by Mykyta Poturai 4 weeks ago
This is preparatory work to make vPCI MSI-X functional on Arm. Split the
vPCI MSI-X code so that intercepting the MSI-X table and PBA stays x86
only, while the MSI-X capability handling becomes common. No functional
change intended.

This is a continuation of work done by Rahul from February 2022[1].

The approach is inverted, instead of moving out the x86 parts, move out
the common ones that will be needed on Arm. Subsequent arm patches for
reference can be found here[2].

[1] https://lore.kernel.org/xen-devel/cover.1644937405.git.rahul.singh@arm.com/T/#t
[2] https://github.com/stewdk/xen/tree/pcie-passthrough-arm-vpci-v26

Rahul Singh (1):
  vpci/msix: move helpers to common

Stewart Hildebrand (2):
  vpci/msix: move msix region removal to msix.c
  vpci/msix: move common msix code to common file

 xen/arch/x86/include/asm/msi.h      |  21 ---
 xen/arch/x86/msi.c                  |   2 +-
 xen/drivers/passthrough/amd/iommu.h |   2 +-
 xen/drivers/vpci/Makefile           |   6 +-
 xen/drivers/vpci/header.c           |  30 +----
 xen/drivers/vpci/msi.c              |   3 +-
 xen/drivers/vpci/msix.c             | 197 ++++++---------------------
 xen/drivers/vpci/msix_common.c      | 202 ++++++++++++++++++++++++++++
 xen/drivers/vpci/private.h          |   2 +
 xen/include/xen/msi.h               |  21 +++
 xen/include/xen/vpci.h              |   5 +
 11 files changed, 282 insertions(+), 209 deletions(-)
 create mode 100644 xen/drivers/vpci/msix_common.c

-- 
2.55.0
Re: [PATCH v1 0/3] vpci/msix: separate out common MSI-X code
Posted by Jan Beulich 4 weeks ago
On 26.10.2026 13:27, Mykyta Poturai wrote:
> This is preparatory work to make vPCI MSI-X functional on Arm. Split the
> vPCI MSI-X code so that intercepting the MSI-X table and PBA stays x86
> only,

This likely is related to peculiarities of Arm's interrupt handling, yet
on the surface I can't see why not intercepting MSI-X table accesses
would be safe. Would it be possible to extend background here a little?

> while the MSI-X capability handling becomes common. No functional
> change intended.
> 
> This is a continuation of work done by Rahul from February 2022[1].
> 
> The approach is inverted, instead of moving out the x86 parts, move out
> the common ones that will be needed on Arm. Subsequent arm patches for
> reference can be found here[2].
> 
> [1] https://lore.kernel.org/xen-devel/cover.1644937405.git.rahul.singh@arm.com/T/#t
> [2] https://github.com/stewdk/xen/tree/pcie-passthrough-arm-vpci-v26
> 
> Rahul Singh (1):
>   vpci/msix: move helpers to common
> 
> Stewart Hildebrand (2):
>   vpci/msix: move msix region removal to msix.c
>   vpci/msix: move common msix code to common file
> 
>  xen/arch/x86/include/asm/msi.h      |  21 ---
>  xen/arch/x86/msi.c                  |   2 +-
>  xen/drivers/passthrough/amd/iommu.h |   2 +-
>  xen/drivers/vpci/Makefile           |   6 +-
>  xen/drivers/vpci/header.c           |  30 +----
>  xen/drivers/vpci/msi.c              |   3 +-
>  xen/drivers/vpci/msix.c             | 197 ++++++---------------------
>  xen/drivers/vpci/msix_common.c      | 202 ++++++++++++++++++++++++++++

Nit: New file's names want to use dashes in favor of underscores.

Jan
Re: [PATCH v1 0/3] vpci/msix: separate out common MSI-X code
Posted by Mykyta Poturai 3 weeks, 6 days ago

On 10/26/26 2:34 PM, Jan Beulich wrote:
> On 26.10.2026 13:27, Mykyta Poturai wrote:
>> This is preparatory work to make vPCI MSI-X functional on Arm. Split the
>> vPCI MSI-X code so that intercepting the MSI-X table and PBA stays x86
>> only,
>
> This likely is related to peculiarities of Arm's interrupt handling, yet
> on the surface I can't see why not intercepting MSI-X table accesses
> would be safe. Would it be possible to extend background here a little?
>

Hi,

On Arm most of the work is done by the ITS, so the only thing the device
needs to write to the doorbell register is the EventID. Interrupt
translation is fully configured in the ITS; it will reject invalid
EventIDs and also has a sideband DeviceID, so misconfigured devices
cannot trigger each other's interrupts. Memory-wise everything is gated
by the IOMMU, so a wrong doorbell address would not pose any risk either.

So there is no need or benefit in translating anything here.

>> while the MSI-X capability handling becomes common. No functional
>> change intended.
>>
>> This is a continuation of work done by Rahul from February 2022[1].
>>
>> The approach is inverted, instead of moving out the x86 parts, move out
>> the common ones that will be needed on Arm. Subsequent arm patches for
>> reference can be found here[2].
>>
>> [1] https://lore.kernel.org/xen-devel/cover.1644937405.git.rahul.singh@arm.com/T/#t
>> [2] https://github.com/stewdk/xen/tree/pcie-passthrough-arm-vpci-v26
>>
>> Rahul Singh (1):
>>    vpci/msix: move helpers to common
>>
>> Stewart Hildebrand (2):
>>    vpci/msix: move msix region removal to msix.c
>>    vpci/msix: move common msix code to common file
>>
>>   xen/arch/x86/include/asm/msi.h      |  21 ---
>>   xen/arch/x86/msi.c                  |   2 +-
>>   xen/drivers/passthrough/amd/iommu.h |   2 +-
>>   xen/drivers/vpci/Makefile           |   6 +-
>>   xen/drivers/vpci/header.c           |  30 +----
>>   xen/drivers/vpci/msi.c              |   3 +-
>>   xen/drivers/vpci/msix.c             | 197 ++++++---------------------
>>   xen/drivers/vpci/msix_common.c      | 202 ++++++++++++++++++++++++++++
>
> Nit: New file's names want to use dashes in favor of underscores.
>
> Jan
Re: [PATCH v1 0/3] vpci/msix: separate out common MSI-X code
Posted by Jan Beulich 3 weeks, 6 days ago
On 27.10.2026 10:39, Mykyta Poturai wrote:
> On 10/26/26 2:34 PM, Jan Beulich wrote:
>> On 26.10.2026 13:27, Mykyta Poturai wrote:
>>> This is preparatory work to make vPCI MSI-X functional on Arm. Split the
>>> vPCI MSI-X code so that intercepting the MSI-X table and PBA stays x86
>>> only,
>>
>> This likely is related to peculiarities of Arm's interrupt handling, yet
>> on the surface I can't see why not intercepting MSI-X table accesses
>> would be safe. Would it be possible to extend background here a little?
> 
> On Arm most of the work is done by the ITS, so the only thing the device
> needs to write to the doorbell register is the EventID. Interrupt
> translation is fully configured in the ITS; it will reject invalid
> EventIDs and also has a sideband DeviceID, so misconfigured devices
> cannot trigger each other's interrupts. Memory-wise everything is gated
> by the IOMMU, so a wrong doorbell address would not pose any risk either.

And a guest fiddling with the mask bits behind Xen's back isn't a problem
either?

Jan
Re: [PATCH v1 0/3] vpci/msix: separate out common MSI-X code
Posted by Mykyta Poturai 3 weeks, 5 days ago
On 10/27/26 12:21 PM, Jan Beulich wrote:
> On 27.10.2026 10:39, Mykyta Poturai wrote:
>> On 10/26/26 2:34 PM, Jan Beulich wrote:
>>> On 26.10.2026 13:27, Mykyta Poturai wrote:
>>>> This is preparatory work to make vPCI MSI-X functional on Arm. Split the
>>>> vPCI MSI-X code so that intercepting the MSI-X table and PBA stays x86
>>>> only,
>>>
>>> This likely is related to peculiarities of Arm's interrupt handling, yet
>>> on the surface I can't see why not intercepting MSI-X table accesses
>>> would be safe. Would it be possible to extend background here a little?
>>
>> On Arm most of the work is done by the ITS, so the only thing the device
>> needs to write to the doorbell register is the EventID. Interrupt
>> translation is fully configured in the ITS; it will reject invalid
>> EventIDs and also has a sideband DeviceID, so misconfigured devices
>> cannot trigger each other's interrupts. Memory-wise everything is gated
>> by the IOMMU, so a wrong doorbell address would not pose any risk either.
> 
> And a guest fiddling with the mask bits behind Xen's back isn't a problem
> either?
> 
> Jan

No. Masking/unmasking an interrupt the guest has already mapped is just 
the guest doing its own configuration. Unmasking an unmapped interrupt 
will result in it being discarded by the ITS. So I don't see a problem 
here either.
Re: [PATCH v1 0/3] vpci/msix: separate out common MSI-X code
Posted by Jan Beulich 3 weeks, 5 days ago
On 28.10.2026 09:43, Mykyta Poturai wrote:
> On 10/27/26 12:21 PM, Jan Beulich wrote:
>> On 27.10.2026 10:39, Mykyta Poturai wrote:
>>> On 10/26/26 2:34 PM, Jan Beulich wrote:
>>>> On 26.10.2026 13:27, Mykyta Poturai wrote:
>>>>> This is preparatory work to make vPCI MSI-X functional on Arm. Split the
>>>>> vPCI MSI-X code so that intercepting the MSI-X table and PBA stays x86
>>>>> only,
>>>>
>>>> This likely is related to peculiarities of Arm's interrupt handling, yet
>>>> on the surface I can't see why not intercepting MSI-X table accesses
>>>> would be safe. Would it be possible to extend background here a little?
>>>
>>> On Arm most of the work is done by the ITS, so the only thing the device
>>> needs to write to the doorbell register is the EventID. Interrupt
>>> translation is fully configured in the ITS; it will reject invalid
>>> EventIDs and also has a sideband DeviceID, so misconfigured devices
>>> cannot trigger each other's interrupts. Memory-wise everything is gated
>>> by the IOMMU, so a wrong doorbell address would not pose any risk either.
>>
>> And a guest fiddling with the mask bits behind Xen's back isn't a problem
>> either?
> 
> No. Masking/unmasking an interrupt the guest has already mapped is just 
> the guest doing its own configuration. Unmasking an unmapped interrupt 
> will result in it being discarded by the ITS. So I don't see a problem 
> here either.

IOW unlike on x86, on Arm Xen never has a need to (transiently) mask an
interrupt that the guest wants / considers unmasked?

Jan
Re: [PATCH v1 0/3] vpci/msix: separate out common MSI-X code
Posted by Mykyta Poturai 3 weeks, 5 days ago
On 10/28/26 10:58 AM, Jan Beulich wrote:
> On 28.10.2026 09:43, Mykyta Poturai wrote:
>> On 10/27/26 12:21 PM, Jan Beulich wrote:
>>> On 27.10.2026 10:39, Mykyta Poturai wrote:
>>>> On 10/26/26 2:34 PM, Jan Beulich wrote:
>>>>> On 26.10.2026 13:27, Mykyta Poturai wrote:
>>>>>> This is preparatory work to make vPCI MSI-X functional on Arm. Split the
>>>>>> vPCI MSI-X code so that intercepting the MSI-X table and PBA stays x86
>>>>>> only,
>>>>>
>>>>> This likely is related to peculiarities of Arm's interrupt handling, yet
>>>>> on the surface I can't see why not intercepting MSI-X table accesses
>>>>> would be safe. Would it be possible to extend background here a little?
>>>>
>>>> On Arm most of the work is done by the ITS, so the only thing the device
>>>> needs to write to the doorbell register is the EventID. Interrupt
>>>> translation is fully configured in the ITS; it will reject invalid
>>>> EventIDs and also has a sideband DeviceID, so misconfigured devices
>>>> cannot trigger each other's interrupts. Memory-wise everything is gated
>>>> by the IOMMU, so a wrong doorbell address would not pose any risk either.
>>>
>>> And a guest fiddling with the mask bits behind Xen's back isn't a problem
>>> either?
>>
>> No. Masking/unmasking an interrupt the guest has already mapped is just
>> the guest doing its own configuration. Unmasking an unmapped interrupt
>> will result in it being discarded by the ITS. So I don't see a problem
>> here either.
> 
> IOW unlike on x86, on Arm Xen never has a need to (transiently) mask an
> interrupt that the guest wants / considers unmasked?

When such a need arises, the interrupt can and should be masked in the 
ITS. On Arm the MSI-X entry carries almost nothing - everything related 
to routing, mapping and masking is done in the ITS, which Xen will fully 
emulate.