xen/arm: pci: introduce PCI_PASSTHROUGH Kconfig option
PATCH v8 1/1 xen/arm: pci: introduce PCI_PASSTHROUGH Kconfig option
From: Rahul Singh <[email protected]>
Setting CONFIG_PCI_PASSTHROUGH=y will enable PCI passthrough on ARM, even though the feature is not yet complete in the current upstream codebase. The purpose of this is to make it easier to enable the necessary configs (HAS_PCI, HAS_VPCI) for testing and development of PCI passthrough on ARM, and to build it in CI.
Since PCI passthrough on ARM is still work in progress at this time, make it depend on EXPERT.
---
The alpine-3.18-gcc-arm64-randconfig CI job should pick up the new config option, but if we wanted it to be built more consistently in CI we could add CONFIG_PCI_PASSTHROUGH=y to one of the arm jobs in automation/gitlab-ci/build.yaml, e.g. alpine-3.18-gcc-debug-arm64.
v7->v8:
* remove select HAS_VPCI as HAS_VPCI_GUEST_SUPPORT already does so
* move select HAS_PCI to HAS_VPCI in common
* move remaining selects under config ARM_64
* add HAS_PASSTHROUGH
* remove "default n" since it is redundant
v6->v7:
* rebase
* send patch separately from series [3]
* add HAS_VPCI_GUEST_SUPPORT since it's upstream now
* drop Julien's A-b due to changes and was given several releases ago
v5->v6:
* no change
v4->v5:
* no change
v3->v4:
* no change
v2->v3:
* add Julien's A-b
v1->v2:
* drop "ARM" naming since it is already in an ARM category
* depend on EXPERT instead of UNSUPPORTED
Changes from downstream to v1:
* depends on ARM_64 (Stefano)
* Don't select HAS_VPCI_GUEST_SUPPORT since this config option is not currently used in the upstream codebase. This will want to be re-added here once the vpci series [2] is merged.
* Don't select ARM_SMMU_V3 since this option can already be selected independently. While PCI passthrough on ARM depends on an SMMU, it does not depend on a particular version or variant of an SMMU.
* Don't select HAS_ITS since this option can already be selected independently. HAS_ITS may want to be added here once the MSI series [1] is merged.
* Don't select LATE_HWDOM since this option is unrelated to PCI passthrough.
[1] https://gitlab.com/xen-project/people/bmarquis/xen-arm-poc/-/commits/poc/pci-passthrough
[2] https://lists.xenproject.org/archives/html/xen-devel/2023-10/msg00660.html
[3] https://lore.kernel.org/xen-devel/[email protected]/T/#t
(cherry picked from commit 9a08f1f7ce28ec619640ba9ce11018bf443e9a0e from the
downstream branch [1])
--- xen/arch/arm/Kconfig | 8 ++++++++ xen/drivers/Kconfig | 1 + 2 files changed, 9 insertions(+)
xen/arch/arm/Kconfig +8 -0
@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGH config ARM def_bool y
@@ -258,6 +260,12 @@ config PARTIAL_EMULATION source "arch/arm/firmware/Kconfig" +config PCI_PASSTHROUGH + bool "PCI passthrough" if EXPERT + depends on ARM_64 + help + This option enables PCI device passthrough + endmenu menu "ARM errata workaround via the alternative framework"
xen/drivers/Kconfig +1 -0
@@ -14,6 +14,7 @@ source "drivers/video/Kconfig" config HAS_VPCI bool + select HAS_PCI config HAS_VPCI_GUEST_SUPPORT bool
base-commit: 229a11aac7bf52f4532ab732ed10f173bd332cd0
Signature · 1 line
2.49.0
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGH
Seeing this, I like this as little as I liked ...
xen/arch/arm/Kconfig config PARTIAL_EMULATION · line 265
Quoted 7 lines
xen/arch/arm/Kconfig +3
-0@@ -258,6 +260,12 @@ config PARTIAL_EMULATION source "arch/arm/firmware/Kconfig" +config PCI_PASSTHROUGH + bool "PCI passthrough" if EXPERT + depends on ARM_64
... the form with the select-s put here. I'll (obviously) leave it to the Arm maintainers to judge, but my recommendation would be to simply drop this patch. As per the description it's merely "make it easier ...", which imo doesn't warrant such an abuse of HAS_*.
As a nit: The select-s also would better be sorted alphabetically.
Jan
Quoted 16 lines · Jan Beulich
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGHSeeing this, I like this as little as I liked ...
Quoted 4 lines
xen/arch/arm/Kconfig +0
-0@@ -258,6 +260,12 @@ config PARTIAL_EMULATION source "arch/arm/firmware/Kconfig"
Quoted 8 lines
xen/arch/arm/Kconfig config PARTIAL_EMULATION · line 265
Quoted 3 lines
xen/arch/arm/Kconfig +3
-0+config PCI_PASSTHROUGH + bool "PCI passthrough" if EXPERT + depends on ARM_64... the form with the select-s put here. I'll (obviously) leave it to the Arm maintainers to judge, but my recommendation would be to simply drop this patch. As per the description it's merely "make it easier ...", which imo doesn't warrant such an abuse of HAS_*.
"easier" was a poor choice of word. "possible" is more accurate. This patch addresses a real issue: currently the PCI and vPCI bits can't be built for Arm, allowing build issues to go unnoticed. E.g. see 4ce671963eb1 ("xen/arm: fix build with HAS_PCI").
Quoted 26 lines · Stewart Hildebrand
Quoted 16 lines · Jan Beulich
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGHSeeing this, I like this as little as I liked ...
Quoted 4 lines
xen/arch/arm/Kconfig +0
-0@@ -258,6 +260,12 @@ config PARTIAL_EMULATION source "arch/arm/firmware/Kconfig"Quoted 8 lines
xen/arch/arm/Kconfig config PARTIAL_EMULATION · line 265
Quoted 3 lines
xen/arch/arm/Kconfig +3
-0+config PCI_PASSTHROUGH + bool "PCI passthrough" if EXPERT + depends on ARM_64... the form with the select-s put here. I'll (obviously) leave it to the Arm maintainers to judge, but my recommendation would be to simply drop this patch. As per the description it's merely "make it easier ...", which imo doesn't warrant such an abuse of HAS_*.
Quoted 4 lines
"easier" was a poor choice of word. "possible" is more accurate. This patch addresses a real issue: currently the PCI and vPCI bits can't be built for Arm, allowing build issues to go unnoticed. E.g. see
4ce671963eb1("xen/arm: fix build withHAS_PCI").
Which gets us back to the question of whether to use "depends on HAS_PASSTHROUGH" (I think yes then) and where to put the remaining select (might then better move back to the new option).
Jan
Stefano Stabellini
Acked-byQuoted 27 lines · Jan Beulich
Quoted 26 lines · Stewart Hildebrand
Quoted 24 lines · Jan Beulich
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGHSeeing this, I like this as little as I liked ...
xen/arch/arm/Kconfig config PARTIAL_EMULATION · line 265
Quoted 7 lines
xen/arch/arm/Kconfig +3
-0@@ -258,6 +260,12 @@ config PARTIAL_EMULATION source "arch/arm/firmware/Kconfig" +config PCI_PASSTHROUGH + bool "PCI passthrough" if EXPERT + depends on ARM_64... the form with the select-s put here. I'll (obviously) leave it to the Arm maintainers to judge, but my recommendation would be to simply drop this patch. As per the description it's merely "make it easier ...", which imo doesn't warrant such an abuse of HAS_*.
Quoted 8 lines
Quoted 4 lines
"easier" was a poor choice of word. "possible" is more accurate. This patch addresses a real issue: currently the PCI and vPCI bits can't be built for Arm, allowing build issues to go unnoticed. E.g. see
4ce671963eb1("xen/arm: fix build withHAS_PCI").Which gets us back to the question of whether to use "depends on
HAS_PASSTHROUGH" (I think yes then) and where to put the remaining select (might then better move back to the new option).
In my opinion, HAS_ options should not be user-configurable but rather properties of the architecture. Therefore, I would add HAS_PASSTHROUGH to ARM_64 unconditionally. Then I would make PASSTHROUGH user-configurable, but dependent on HAS_PASSTHROUGH.
In the rest of the code, we would update the checks to be based on PASSTHROUGH instead of HAS_PASSTHROUGH.
That said, this patch is simpler while my suggestion is more invasive. Also this patch is at v8 and we shouldn't keep increasing the scope of the work for contributors. Finally, I am not certain all maintainers would agree with my view I just outlined.
So based on the above, and based on the fact that we certainly need this patch or something like it:
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGH
As I just learned, this change (or maybe it was the "select HAS_PCI" further down) has exposed the quarantining Kconfig option prompt, which (aiui) is entirely meaningless on Arm. IOW I think further adjustments are necessary.
Jan
Quoted 15 lines · Jan Beulich
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGHAs I just learned, this change (or maybe it was the "select
HAS_PCI" further down) has exposed the quarantiningKconfigoption prompt, which (aiui) is entirely meaningless on Arm. IOW I think further adjustments are necessary.
Quoted 1 line
Jan
Not entirely meaningless - the choice between "none" and "basic" still seems relevant. Just "scratch page" quarantining hasn't been implemented in any of the Arm iommu drivers.
Perhaps just the IOMMU_QUARANTINE_SCRATCH_PAGE option should be hidden on Arm (or only exposed on x86)? E.g.:
xen/drivers/passthrough/Kconfig +1 -0
@@ -90,4 +90,5 @@ choice bool "basic" config IOMMU_QUARANTINE_SCRATCH_PAGE bool "scratch page" + depends on X86 endchoice
Quoted 16 lines · Stewart Hildebrand
Quoted 14 lines · Jan Beulich
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGHAs I just learned, this change (or maybe it was the "select
HAS_PCI" further down) has exposed the quarantiningKconfigoption prompt, which (aiui) is entirely meaningless on Arm. IOW I think further adjustments are necessary.
Quoted 3 lines
Not entirely meaningless - the choice between "none" and "basic" still seems relevant. Just "scratch page" quarantining hasn't been implemented in any of the Arm iommu drivers.
Is there support for "basic"? For x86, most of the involved code lives in the vendor-specific drivers, and I can't find anything related in Arm's. Note in particular the hook iommu_quarantine_dev_init() calls, which isn't provided by any of the Arm drivers afaict.
Jan
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Stewart Hildebrand
Quoted 14 lines · Jan Beulich
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGHAs I just learned, this change (or maybe it was the "select
HAS_PCI" further down) has exposed the quarantiningKconfigoption prompt, which (aiui) is entirely meaningless on Arm. IOW I think further adjustments are necessary.
Quoted 8 lines
Quoted 3 lines
Not entirely meaningless - the choice between "none" and "basic" still seems relevant. Just "scratch page" quarantining hasn't been implemented in any of the Arm iommu drivers.
Is there support for "basic"? For x86, most of the involved code lives in the vendor-specific drivers, and I can't find anything related in Arm's. Note in particular the hook
iommu_quarantine_dev_init()calls, which isn't provided by any of the Arm drivers afaict.
Quoting xen/drivers/passthrough/Kconfig IOMMU_QUARANTINE_* help text:
"... basic form, all in-flight DMA will simply be forced to encounter IOMMU faults."
My understanding of "basic" is that after destruction of a domU with a PCI device assigned, the PCI device gets assigned to domIO. We have special casing for ( d == dom_io ) in some instances, but otherwise it has relatively little to do with the individual iommu drivers. I believe assigning to domIO should be enough for the Arm iommus to generate faults, since the iommu identifies the PCI device's DMA via sideband information (AXI stream ID).
Quoted 32 lines · Stewart Hildebrand
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Stewart Hildebrand
Quoted 14 lines · Jan Beulich
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGHAs I just learned, this change (or maybe it was the "select
HAS_PCI" further down) has exposed the quarantiningKconfigoption prompt, which (aiui) is entirely meaningless on Arm. IOW I think further adjustments are necessary.Quoted 8 lines
Quoted 3 lines
Not entirely meaningless - the choice between "none" and "basic" still seems relevant. Just "scratch page" quarantining hasn't been implemented in any of the Arm iommu drivers.
Is there support for "basic"? For x86, most of the involved code lives in the vendor-specific drivers, and I can't find anything related in Arm's. Note in particular the hook
iommu_quarantine_dev_init()calls, which isn't provided by any of the Arm drivers afaict.Quoting xen/drivers/passthrough/Kconfig IOMMU_QUARANTINE_* help text:
"... basic form, all in-flight DMA will simply be forced to encounter IOMMU faults."
Quoted 7 lines
My understanding of "basic" is that after destruction of a domU with a PCI device assigned, the PCI device gets assigned to domIO. We have special casing for ( d ==
dom_io) in some instances, but otherwise it has relatively little to do with the individual iommu drivers. I believe assigning to domIO should be enough for the Arm iommus to generate faults, since the iommu identifies the PCI device's DMA via sideband information (AXI stream ID).
Oh, and also note the commit messages in63919fc4d1ca ("xen/arm: smmuv3: Add PCI devices support for SMMUv3") andca8f6ffeb6e3 ("xen/arm: smmuv2: Add PCI devices support for SMMUv2") "Implement basic quarantining."
Quoted 41 lines · Stewart Hildebrand
Quoted 32 lines · Stewart Hildebrand
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Stewart Hildebrand
Quoted 14 lines · Jan Beulich
xen/arch/arm/Kconfig config ARM_64 · line 12
Quoted 8 lines · Stewart Hildebrand
xen/arch/arm/Kconfig +2
-0@@ -8,6 +8,8 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY + select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH + select HAS_PASSTHROUGH if PCI_PASSTHROUGHAs I just learned, this change (or maybe it was the "select
HAS_PCI" further down) has exposed the quarantiningKconfigoption prompt, which (aiui) is entirely meaningless on Arm. IOW I think further adjustments are necessary.Quoted 8 lines
Quoted 3 lines
Not entirely meaningless - the choice between "none" and "basic" still seems relevant. Just "scratch page" quarantining hasn't been implemented in any of the Arm iommu drivers.
Is there support for "basic"? For x86, most of the involved code lives in the vendor-specific drivers, and I can't find anything related in Arm's. Note in particular the hook
iommu_quarantine_dev_init()calls, which isn't provided by any of the Arm drivers afaict.Quoting xen/drivers/passthrough/Kconfig IOMMU_QUARANTINE_* help text:
"... basic form, all in-flight DMA will simply be forced to encounter IOMMU faults."
Quoted 7 lines
My understanding of "basic" is that after destruction of a domU with a PCI device assigned, the PCI device gets assigned to domIO. We have special casing for ( d ==
dom_io) in some instances, but otherwise it has relatively little to do with the individual iommu drivers. I believe assigning to domIO should be enough for the Arm iommus to generate faults, since the iommu identifies the PCI device's DMA via sideband information (AXI stream ID).
Quoted 5 lines
Oh, and also note the commit messages in
63919fc4d1ca("xen/arm: smmuv3: Add PCI devices support for SMMUv3") andca8f6ffeb6e3("xen/arm: smmuv2: Add PCI devices support for SMMUv2") "Implement basic quarantining."
I'm fine with the proposed adjustment if things work on Arm. I'll demand an Arm maintainer ack then though, I think.
Jan