* [XEN PATCH] x86/iommu: Conditionally compile platform-specific union entries
@ 2024-05-23 9:19 Teddy Astie
2024-05-23 9:52 ` Roger Pau Monné
0 siblings, 1 reply; 3+ messages in thread
From: Teddy Astie @ 2024-05-23 9:19 UTC (permalink / raw)
To: xen-devel; +Cc: Teddy Astie, Jan Beulich, Andrew Cooper, Roger Pau Monné
If some platform driver isn't compiled in, remove its related union
entries as they are not used.
Signed-off-by Teddy Astie <teddy.astie@vates.tech>
---
xen/arch/x86/include/asm/iommu.h | 4 ++++
xen/arch/x86/include/asm/pci.h | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/xen/arch/x86/include/asm/iommu.h b/xen/arch/x86/include/asm/iommu.h
index 8dc464fbd3..99180940c4 100644
--- a/xen/arch/x86/include/asm/iommu.h
+++ b/xen/arch/x86/include/asm/iommu.h
@@ -42,17 +42,21 @@ struct arch_iommu
struct list_head identity_maps;
union {
+ #ifdef CONFIG_INTEL_IOMMU
/* Intel VT-d */
struct {
uint64_t pgd_maddr; /* io page directory machine address */
unsigned int agaw; /* adjusted guest address width, 0 is level 2 30-bit */
unsigned long *iommu_bitmap; /* bitmap of iommu(s) that the domain uses */
} vtd;
+ #endif
+ #ifdef CONFIG_AMD_IOMMU
/* AMD IOMMU */
struct {
unsigned int paging_mode;
struct page_info *root_table;
} amd;
+ #endif
};
};
diff --git a/xen/arch/x86/include/asm/pci.h b/xen/arch/x86/include/asm/pci.h
index fd5480d67d..842710f0dc 100644
--- a/xen/arch/x86/include/asm/pci.h
+++ b/xen/arch/x86/include/asm/pci.h
@@ -22,12 +22,16 @@ struct arch_pci_dev {
*/
union {
/* Subset of struct arch_iommu's fields, to be used in dom_io. */
+ #ifdef CONFIG_INTEL_IOMMU
struct {
uint64_t pgd_maddr;
} vtd;
+ #endif
+ #ifdef CONFIG_AMD_IOMMU
struct {
struct page_info *root_table;
} amd;
+ #endif
};
domid_t pseudo_domid;
mfn_t leaf_mfn;
--
2.45.1
Teddy Astie | Vates XCP-ng Intern
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [XEN PATCH] x86/iommu: Conditionally compile platform-specific union entries
2024-05-23 9:19 [XEN PATCH] x86/iommu: Conditionally compile platform-specific union entries Teddy Astie
@ 2024-05-23 9:52 ` Roger Pau Monné
2024-05-23 12:05 ` Teddy Astie
0 siblings, 1 reply; 3+ messages in thread
From: Roger Pau Monné @ 2024-05-23 9:52 UTC (permalink / raw)
To: Teddy Astie; +Cc: xen-devel, Jan Beulich, Andrew Cooper
On Thu, May 23, 2024 at 09:19:53AM +0000, Teddy Astie wrote:
> If some platform driver isn't compiled in, remove its related union
> entries as they are not used.
>
> Signed-off-by Teddy Astie <teddy.astie@vates.tech>
> ---
> xen/arch/x86/include/asm/iommu.h | 4 ++++
> xen/arch/x86/include/asm/pci.h | 4 ++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/xen/arch/x86/include/asm/iommu.h b/xen/arch/x86/include/asm/iommu.h
> index 8dc464fbd3..99180940c4 100644
> --- a/xen/arch/x86/include/asm/iommu.h
> +++ b/xen/arch/x86/include/asm/iommu.h
> @@ -42,17 +42,21 @@ struct arch_iommu
> struct list_head identity_maps;
>
> union {
> + #ifdef CONFIG_INTEL_IOMMU
> /* Intel VT-d */
> struct {
> uint64_t pgd_maddr; /* io page directory machine address */
> unsigned int agaw; /* adjusted guest address width, 0 is level 2 30-bit */
> unsigned long *iommu_bitmap; /* bitmap of iommu(s) that the domain uses */
> } vtd;
> + #endif
> + #ifdef CONFIG_AMD_IOMMU
> /* AMD IOMMU */
> struct {
> unsigned int paging_mode;
> struct page_info *root_table;
> } amd;
> + #endif
> };
> };
>
> diff --git a/xen/arch/x86/include/asm/pci.h b/xen/arch/x86/include/asm/pci.h
> index fd5480d67d..842710f0dc 100644
> --- a/xen/arch/x86/include/asm/pci.h
> +++ b/xen/arch/x86/include/asm/pci.h
> @@ -22,12 +22,16 @@ struct arch_pci_dev {
> */
> union {
> /* Subset of struct arch_iommu's fields, to be used in dom_io. */
> + #ifdef CONFIG_INTEL_IOMMU
> struct {
> uint64_t pgd_maddr;
> } vtd;
> + #endif
> + #ifdef CONFIG_AMD_IOMMU
> struct {
> struct page_info *root_table;
> } amd;
> + #endif
> };
The #ifdef and #endif processor directives shouldn't be indented.
Would you mind adding /* CONFIG_{AMD,INTEL}_IOMMU */ comments in the
#endif directives?
I wonder if we could move the definitions of those structures to the
vendor specific headers, but that's more convoluted, and would require
including the iommu headers in pci.h
Thanks, Roger.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [XEN PATCH] x86/iommu: Conditionally compile platform-specific union entries
2024-05-23 9:52 ` Roger Pau Monné
@ 2024-05-23 12:05 ` Teddy Astie
0 siblings, 0 replies; 3+ messages in thread
From: Teddy Astie @ 2024-05-23 12:05 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel, Jan Beulich, Andrew Cooper
Le 23/05/2024 à 11:52, Roger Pau Monné a écrit :
> The #ifdef and #endif processor directives shouldn't be indented.
>
> Would you mind adding /* CONFIG_{AMD,INTEL}_IOMMU */ comments in the
> #endif directives?
>
Sure, will change it for v2.
> I wonder if we could move the definitions of those structures to the
> vendor specific headers, but that's more convoluted, and would require
> including the iommu headers in pci.h
Do you mean moving the vtd/amd union entries to separate structures (e.g
vtd_arch_iommu) and put them into another file (I don't see any
vendor-specific headers for this, perhaps create ones ?).
>
> Thanks, Roger.
Teddy
Teddy Astie | Vates XCP-ng Intern
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-23 12:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23 9:19 [XEN PATCH] x86/iommu: Conditionally compile platform-specific union entries Teddy Astie
2024-05-23 9:52 ` Roger Pau Monné
2024-05-23 12:05 ` Teddy Astie
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.