x86/iommu: fix wrong usage of iommu_hwdom_inclusive
PATCH v2 1/2 x86/iommu: fix wrong usage of iommu_hwdom_inclusive
iommu_hwdom_inclusive was used where iommu_hwdom_reserved should be used.
---
Cc: Jan Beulich <[email protected]>
---
Changes since v1:
- New in this version.
--- xen/drivers/passthrough/iommu.c | 2 +- xen/drivers/passthrough/x86/iommu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
xen/drivers/passthrough/iommu.c +1 -1
@@ -157,7 +157,7 @@ static int __init parse_dom0_iommu_param(const char *s)else if ( (val =parse_boolean ("map-inclusive" , s, ss)) >=0 ) iommu_hwdom_inclusive = val;else if ( (val =parse_boolean ("map-reserved" , s, ss)) >=0 ) - iommu_hwdom_inclusive = val; + iommu_hwdom_reserved = val;else rc = -EINVAL ;
xen/drivers/passthrough/x86/iommu.c +1 -1
@@ -210,7 +210,7 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)BUG_ON (!is_hardware_domain (d)); -ASSERT (iommu_hwdom_inclusive !=-1 && iommu_hwdom_inclusive !=-1 ); +ASSERT (iommu_hwdom_inclusive !=-1 && iommu_hwdom_reserved !=-1 );if ( iommu_hwdom_inclusive && !is_pv_domain (d) ) { printk(XENLOG_WARNING
Signature · 7 lines
2.19.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/2 amd/iommu: remove hidden AMD inclusive mappings
And just rely on arch_iommu_hwdom_init to setup the correct inclusive mappings as it's done for Intel.
AMD has code in amd_iommu_hwdom_init to setup inclusive mappings up to max_pdx, remove this since it's now a duplication of arch_iommu_hwdom_init. Note that AMD mapped every page with a valid mfn up to max_pdx, arch_iommu_hwdom_init will only do so for memory below 4GB, so this is a functional change for AMD.
Move the default setting of iommu_hwdom_{inclusive/reserved} to arch_iommu_hwdom_init since the defaults are now the same for both Intel and AMD.
---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
Cc: Kevin Tian <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Paul Durrant <[email protected]>
--- xen/drivers/passthrough/amd/pci_amd_iommu.c | 39 --------------------- xen/drivers/passthrough/vtd/iommu.c | 7 ---- xen/drivers/passthrough/x86/iommu.c | 8 ++++- 3 files changed, 7 insertions(+), 47 deletions(-)
xen/drivers/passthrough/amd/pci_amd_iommu.c +0 -39
@@ -250,50 +250,11 @@ static int amd_iommu_add_device(u8 devfn, struct pci_dev *pdev); static void __hwdom_init amd_iommu_hwdom_init(struct domain *d) { -unsigned long i;const struct amd_iommu *iommu; -/* Inclusive IOMMU mappings are disabled by default on AMD hardware. */ -if ( iommu_hwdom_inclusive ==-1 ) - iommu_hwdom_inclusive =0 ; -/* Reserved IOMMU mappings are disabled by default on AMD hardware. */ -if ( iommu_hwdom_reserved ==-1 ) - iommu_hwdom_reserved =0 ; -if (allocate_domain_resources (dom_iommu (d)) )BUG (); -if ( !iommu_hwdom_passthrough && !need_iommu (d) ) - { -int rc =0 ; - -/* Set up 1:1 page table for dom0 */ -for ( i =0 ; i < max_pdx; i++ ) - { -unsigned long pfn =pdx_to_pfn (i); - -/* -* XXX Should we really map all non-RAM (above 4G)? Minimally -* a pfn_valid() check would seem desirable here. -*/ -if (mfn_valid (_mfn (pfn)) ) - { -int ret =amd_iommu_map_page (d, pfn, pfn, - IOMMUF_readable|IOMMUF_writable); - -if ( !rc ) - rc = ret; - } - -if ( !(i &0xfffff ) ) -process_pending_softirqs (); - } - -if ( rc ) -AMD_IOMMU_DEBUG ("d%d: IOMMU mapping failed: %d\n" , - d->domain_id, rc); - } - for_each_amd_iommu ( iommu ) if ( iomem_deny_access(d, PFN_DOWN(iommu->mmio_base_phys), PFN_DOWN(iommu->mmio_base_phys +
xen/drivers/passthrough/vtd/iommu.c +0 -7
@@ -1304,13 +1304,6 @@ static void __hwdom_init intel_iommu_hwdom_init(struct domain *d) {struct acpi_drhd_unit *drhd; -/* Inclusive mappings are enabled by default on Intel hardware for PV. */ -if ( iommu_hwdom_inclusive ==-1 ) - iommu_hwdom_inclusive =is_pv_domain (d); -/* Reserved IOMMU mappings are enabled by default on Intel hardware. */ -if ( iommu_hwdom_reserved ==-1 ) - iommu_hwdom_reserved =1 ; -setup_hwdom_pci_devices (d, setup_hwdom_device);setup_hwdom_rmrr (d);/* Make sure workarounds are applied before enabling the IOMMU(s). */
xen/drivers/passthrough/x86/iommu.c +7 -1
@@ -210,7 +210,13 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)BUG_ON (!is_hardware_domain (d)); -ASSERT (iommu_hwdom_inclusive !=-1 && iommu_hwdom_reserved !=-1 ); +/* Inclusive mappings are enabled by default for PV. */ +if ( iommu_hwdom_inclusive ==-1 ) + iommu_hwdom_inclusive =is_pv_domain (d); +/* Reserved IOMMU mappings are enabled by default. */ +if ( iommu_hwdom_reserved ==-1 ) + iommu_hwdom_reserved =1 ; +if ( iommu_hwdom_inclusive && !is_pv_domain (d) ) { printk(XENLOG_WARNING
Signature · 7 lines
2.19.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 2/2] amd/iommu: remove hidden AMD inclusive mappings
Roger,
Quoted 23 lines · Roger Pau Monne
And just rely on
arch_iommu_hwdom_initto setup the correct inclusive mappings as it's done for Intel.AMD has code in
amd_iommu_hwdom_initto setup inclusive mappings up tomax_pdx, remove this since it's now a duplication ofarch_iommu_hwdom_init. Note that AMD mapped every page with a valid mfn up tomax_pdx,arch_iommu_hwdom_initwill only do so for memory below 4GB, so this is a functional change for AMD.Move the default setting of iommu_hwdom_{inclusive/reserved} to
arch_iommu_hwdom_initsince the defaults are now the same for both Intel and AMD.Reported-by Paul Durrant <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>Reviewed-by Jan Beulich <[email protected]>Reviewed-by Kevin Tian <[email protected]>---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
Cc: Kevin Tian <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Paul Durrant <[email protected]>
Quoted 6 lines
--- xen/drivers/passthrough/amd/pci_amd_iommu.c | 39 --------------------- xen/drivers/passthrough/vtd/iommu.c | 7 ---- xen/drivers/passthrough/x86/iommu.c | 8 ++++- 3 files changed, 7 insertions(+), 47 deletions(-)
Thanks,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 02.10.18 at 10:08, <[email protected]> wrote:
iommu_hwdom_inclusivewas used whereiommu_hwdom_reservedshould be used.Reported-by Suravee Suthikulpanit <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel