remotely XSA-59 related adjustments
cover remotely XSA-59 related adjustments
While investigating XSA-59, these were all found to be desirable adjustments.
1: x86: don't allow Dom0 access to the MSI address range
2: x86: don't allow Dom0 access to the HT address range
3: VT-d: warn about Compatibility Format Interrupts being enabled by firmware
PATCH 1/3 x86: don't allow Dom0 access to the MSI address range
In particular, MMIO assignments should not be done using this area.
xen/arch/x86/domain_build.c +4 -0
@@ -1122,6 +1122,10 @@ int __init construct_dom0(if ( !rangeset_contains_singleton (mmio_ro_ranges, mfn) ) rc |=iomem_deny_access (dom0, mfn, mfn); } +/* MSI range. */ + rc |=iomem_deny_access (dom0,paddr_to_pfn (MSI_ADDR_BASE_LO ), +paddr_to_pfn (MSI_ADDR_BASE_LO + +MSI_ADDR_DEST_ID_MASK ));/* Remove access to E820_UNUSABLE I/O regions above 1MB. */ for ( i =0 ; i < e820.nr_map; i++ )
x86: don't allow Dom0 access to the MSI address range
In particular, MMIO assignments should not be done using this area.
xen/arch/x86/domain_build.c +4 -0
@@ -1122,6 +1122,10 @@ int __init construct_dom0(if ( !rangeset_contains_singleton (mmio_ro_ranges, mfn) ) rc |=iomem_deny_access (dom0, mfn, mfn); } +/* MSI range. */ + rc |=iomem_deny_access (dom0,paddr_to_pfn (MSI_ADDR_BASE_LO ), +paddr_to_pfn (MSI_ADDR_BASE_LO + +MSI_ADDR_DEST_ID_MASK ));/* Remove access to E820_UNUSABLE I/O regions above 1MB. */ for ( i =0 ; i < e820.nr_map; i++ )
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/3] x86: don't allow Dom0 access to the MSI address range
Thanks!
Acked-by Xiantao Zhang <[email protected]>
Xiantao
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, August 21, 2013 2:37 PM
To: xen-devel
Cc: Zhang, Xiantao; Keir Fraser
Subject: [PATCH 1/3] x86: don't allow Dom0 access to the MSI address range
In particular, MMIO assignments should not be done using this area.
xen/arch/x86/domain_build.c +4 -0
@@ -1122,6 +1122,10 @@ int __init construct_dom0(if ( !rangeset_contains_singleton (mmio_ro_ranges, mfn) ) rc |=iomem_deny_access (dom0, mfn, mfn); } +/* MSI range. */ + rc |=iomem_deny_access (dom0,paddr_to_pfn (MSI_ADDR_BASE_LO ), +paddr_to_pfn (MSI_ADDR_BASE_LO + +MSI_ADDR_DEST_ID_MASK ));/* Remove access to E820_UNUSABLE I/O regions above 1MB. */ for ( i =0 ; i < e820.nr_map; i++ )
Re: [PATCH 1/3] x86: don't allow Dom0 access to the MSI address range
In reply to Jan BeulichQuoted 1 line · Jan Beulich
In particular, MMIO assignments should not be done using this area.
And just to make sure there are no regressions - have you tested this with an upstream dom0 kernel to make sure it does not blow things up?
Or at least if it does blow up - are there any WARN or BUG to help in coming up with a patch?
Quoted 44 lines
Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/domain_build.c +4
-0@@ -1122,6 +1122,10 @@ int __init construct_dom0(if ( !rangeset_contains_singleton (mmio_ro_ranges, mfn) ) rc |=iomem_deny_access (dom0, mfn, mfn); } +/* MSI range. */ + rc |=iomem_deny_access (dom0,paddr_to_pfn (MSI_ADDR_BASE_LO ), +paddr_to_pfn (MSI_ADDR_BASE_LO + +MSI_ADDR_DEST_ID_MASK ));/* Remove access to E820_UNUSABLE I/O regions above 1MB. */ for ( i =0 ; i < e820.nr_map; i++ )x86: don't allow Dom0 access to the MSI address range
In particular, MMIO assignments should not be done using this area.
Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/domain_build.c +4
-0@@ -1122,6 +1122,10 @@ int __init construct_dom0(if ( !rangeset_contains_singleton (mmio_ro_ranges, mfn) ) rc |=iomem_deny_access (dom0, mfn, mfn); } +/* MSI range. */ + rc |=iomem_deny_access (dom0,paddr_to_pfn (MSI_ADDR_BASE_LO ), +paddr_to_pfn (MSI_ADDR_BASE_LO + +MSI_ADDR_DEST_ID_MASK ));/* Remove access to E820_UNUSABLE I/O regions above 1MB. */ for ( i =0 ; i < e820.nr_map; i++ )_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/3] x86: don't allow Dom0 access to the MSI address range
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Jan Beulich
In particular, MMIO assignments should not be done using this area.
And just to make sure there are no regressions - have you tested this with an upstream dom0 kernel to make sure it does not blow things up?
No, I didn't. I'm only testing with our own kernels. But I can't see how this could cause any regression - Dom0 is not supposed to map that page (from CPU perspective it's the LAPIC) one, and if it ever assigned the range as MMIO to a device, things would have blown up.
Quoted 2 lines
Or at least if it does blow up - are there any WARN or BUG to help in coming up with a patch?
The E820 machine memory map that Dom0 gets to see would have that range marked as reserved (or unusable), and the MMIO rangeset printed in 'q' debug key output would also show the page as not accessible.
Jan
Re: [PATCH 1/3] x86: don't allow Dom0 access to the MSI address range
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Jan Beulich
In particular, MMIO assignments should not be done using this area.
Quoted 8 lines
Quoted 2 lines
And just to make sure there are no regressions - have you tested this with an upstream dom0 kernel to make sure it does not blow things up?
No, I didn't. I'm only testing with our own kernels. But I can't see how this could cause any regression - Dom0 is not supposed to map that page (from CPU perspective it's the LAPIC) one, and if it ever assigned the range as MMIO to a device, things would have blown up.
I see. What an odd name for an LAPIC region - MMIO.
Quoted 8 lines
Quoted 3 lines
Or at least if it does blow up - are there any WARN or BUG to help in coming up with a patch?
The E820 machine memory map that Dom0 gets to see would have that range marked as reserved (or unusable), and the MMIO rangeset printed in 'q' debug key output would also show the page as not accessible.
Thank you.
Quoted 3 lines
Jan
Re: [PATCH 1/3] x86: don't allow Dom0 access to the MSI address range
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 7 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Jan Beulich
In particular, MMIO assignments should not be done using this area.
And just to make sure there are no regressions - have you tested this with an upstream dom0 kernel to make sure it does not blow things up?
Quoted 7 lines
Quoted 5 lines
No, I didn't. I'm only testing with our own kernels. But I can't see how this could cause any regression - Dom0 is not supposed to map that page (from CPU perspective it's the LAPIC) one, and if it ever assigned the range as MMIO to a device, things would have blown up.
I see. What an odd name for an LAPIC region - MMIO.
The thing is that this address range has two meanings - to the CPU it's the LAPIC range, to PCI devices it's the MSI address one (which _is_ a special kind of MMIO).
Jan
PATCH 2/3 x86: don't allow Dom0 access to the HT address range
In reply to Jan BeulichIn particular, MMIO assignments should not be done using this area.
xen/arch/x86/domain_build.c +4 -0
@@ -1126,6 +1126,10 @@ int __init construct_dom0( rc |=iomem_deny_access (dom0,paddr_to_pfn (MSI_ADDR_BASE_LO ),paddr_to_pfn (MSI_ADDR_BASE_LO +MSI_ADDR_DEST_ID_MASK )); +/* HyperTransport range. */ +if ( boot_cpu_data.x86_vendor ==X86_VENDOR_AMD ) + rc |=iomem_deny_access (dom0,paddr_to_pfn (0xfdULL <<32 ), +paddr_to_pfn ((1ULL <<40 ) -1 ));/* Remove access to E820_UNUSABLE I/O regions above 1MB. */ for ( i =0 ; i < e820.nr_map; i++ )
x86: don't allow Dom0 access to the HT address range
In particular, MMIO assignments should not be done using this area.
xen/arch/x86/domain_build.c +4 -0
@@ -1126,6 +1126,10 @@ int __init construct_dom0( rc |=iomem_deny_access (dom0,paddr_to_pfn (MSI_ADDR_BASE_LO ),paddr_to_pfn (MSI_ADDR_BASE_LO +MSI_ADDR_DEST_ID_MASK )); +/* HyperTransport range. */ +if ( boot_cpu_data.x86_vendor ==X86_VENDOR_AMD ) + rc |=iomem_deny_access (dom0,paddr_to_pfn (0xfdULL <<32 ), +paddr_to_pfn ((1ULL <<40 ) -1 ));/* Remove access to E820_UNUSABLE I/O regions above 1MB. */ for ( i =0 ; i < e820.nr_map; i++ )
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 3/3 VT-d: warn about Compatibility Format Interrupts being enabled by firmware
In reply to Jan Beulich... as being insecure.
xen/drivers/passthrough/vtd/intremap.c +10 -6
@@ -712,8 +712,8 @@ int enable_intremap(struct iommu *iommu,if ( !platform_supports_intremap () ) { - dprintk(XENLOG_ERR VTDPREFIX, - "Platform firmware does not support interrupt remapping\n"); + printk(XENLOG_ERR VTDPREFIX + " Platform firmware does not support interrupt remapping\n");return -EINVAL ; }
@@ -724,15 +724,19 @@ int enable_intremap(struct iommu *iommu,if ( (sts &DMA_GSTS_IRES ) && ir_ctrl->iremap_maddr )return 0 ; - sts =dmar_readl (iommu->reg,DMAR_GSTS_REG );if ( !(sts &DMA_GSTS_QIES ) ) { - dprintk(XENLOG_ERR VTDPREFIX, -"Queued invalidation is not enabled, should not enable " - "interrupt remapping\n"); + printk(XENLOG_ERR VTDPREFIX +" Queued invalidation is not enabled on IOMMU #%u:" + " Should not enable interrupt remapping\n", iommu->index);return -EINVAL ; } +if ( !eim && (sts &DMA_GSTS_CFIS ) ) + printk(XENLOG_WARNING VTDPREFIX +" Compatibility Format Interrupts permitted on IOMMU #%u:" +" Device pass-through will be insecure\n" , iommu->index); +if ( ir_ctrl->iremap_maddr ==0 ) { drhd =iommu_to_drhd (iommu);
VT-d: warn about Compatibility Format Interrupts being enabled by firmware
... as being insecure.
xen/drivers/passthrough/vtd/intremap.c +10 -6
@@ -712,8 +712,8 @@ int enable_intremap(struct iommu *iommu,if ( !platform_supports_intremap () ) { - dprintk(XENLOG_ERR VTDPREFIX, - "Platform firmware does not support interrupt remapping\n"); + printk(XENLOG_ERR VTDPREFIX + " Platform firmware does not support interrupt remapping\n");return -EINVAL ; }
@@ -724,15 +724,19 @@ int enable_intremap(struct iommu *iommu,if ( (sts &DMA_GSTS_IRES ) && ir_ctrl->iremap_maddr )return 0 ; - sts =dmar_readl (iommu->reg,DMAR_GSTS_REG );if ( !(sts &DMA_GSTS_QIES ) ) { - dprintk(XENLOG_ERR VTDPREFIX, -"Queued invalidation is not enabled, should not enable " - "interrupt remapping\n"); + printk(XENLOG_ERR VTDPREFIX +" Queued invalidation is not enabled on IOMMU #%u:" + " Should not enable interrupt remapping\n", iommu->index);return -EINVAL ; } +if ( !eim && (sts &DMA_GSTS_CFIS ) ) + printk(XENLOG_WARNING VTDPREFIX +" Compatibility Format Interrupts permitted on IOMMU #%u:" +" Device pass-through will be insecure\n" , iommu->index); +if ( ir_ctrl->iremap_maddr ==0 ) { drhd =iommu_to_drhd (iommu);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/3] VT-d: warn about Compatibility Format Interrupts being enabled by firmware
Quoted 18 lines · Jan Beulich
... as being insecure.
Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/vtd/intremap.c +2
-2@@ -712,8 +712,8 @@ int enable_intremap(struct iommu *iommu,if ( !platform_supports_intremap () ) { - dprintk(XENLOG_ERR VTDPREFIX, - "Platform firmware does not support interrupt remapping\n"); + printk(XENLOG_ERR VTDPREFIX + " Platform firmware does not support interrupt remapping\n");return -EINVAL ; }
xen/drivers/passthrough/vtd/intremap.c int enable_intremap(struct iommu *iommu, · line 727
Quoted 4 lines
xen/drivers/passthrough/vtd/intremap.c +0
-1@@ -724,15 +724,19 @@ int enable_intremap(struct iommu *iommu,if ( (sts &DMA_GSTS_IRES ) && ir_ctrl->iremap_maddr )return 0 ; - sts =dmar_readl (iommu->reg,DMAR_GSTS_REG );
Nit: Might be nice to mention the removal of the redundant read in the changelog.
-George
Re: [PATCH 3/3] VT-d: warn about Compatibility Format Interrupts being enabled by firmware
Quoted 20 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 7 lines · Jan Beulich
... as being insecure.
Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/vtd/intremap.c int enable_intremap(struct iommu *iommu, · line 716
Quoted 7 lines
xen/drivers/passthrough/vtd/intremap.c +2
-2@@ -712,8 +712,8 @@ int enable_intremap(struct iommu *iommu,if ( !platform_supports_intremap () ) { - dprintk(XENLOG_ERR VTDPREFIX, - "Platform firmware does not support interrupt remapping\n"); + printk(XENLOG_ERR VTDPREFIX + " Platform firmware does not support interruptremapping\n");
Quoted 3 lines
xen/drivers/passthrough/vtd/intremap.c +0
-0return -EINVAL ; }
Quoted 8 lines
xen/drivers/passthrough/vtd/intremap.c int enable_intremap(struct iommu *iommu, · line 727
Quoted 5 lines
xen/drivers/passthrough/vtd/intremap.c +0
-1@@ -724,15 +724,19 @@ int enable_intremap(struct iommu *iommu,if ( (sts &DMA_GSTS_IRES ) && ir_ctrl->iremap_maddr )return 0 ; - sts =dmar_readl (iommu->reg,DMAR_GSTS_REG );Nit: Might be nice to mention the removal of the redundant read in the changelog.
Indeed, and in fact I meant to, but forgot when I created the patch metadata. Now added.
Jan
Re: [PATCH 3/3] VT-d: warn about Compatibility Format Interrupts being enabled by firmware
In reply to Jan BeulichThanks! Acked-by Xiantao Zhang <[email protected]>
Xiantao
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, August 21, 2013 2:38 PM
To: xen-devel
Cc: Zhang, Xiantao; Keir Fraser
Subject: [PATCH 3/3] VT-d: warn about Compatibility Format Interrupts being enabled by firmware
... as being insecure.
xen/drivers/passthrough/vtd/intremap.c +10 -6
@@ -712,8 +712,8 @@ int enable_intremap(struct iommu *iommu,if ( !platform_supports_intremap () ) { - dprintk(XENLOG_ERR VTDPREFIX, - "Platform firmware does not support interrupt remapping\n"); + printk(XENLOG_ERR VTDPREFIX + " Platform firmware does not support interrupt remapping\n");return -EINVAL ; }
@@ -724,15 +724,19 @@ int enable_intremap(struct iommu *iommu,if ( (sts &DMA_GSTS_IRES ) && ir_ctrl->iremap_maddr )return 0 ; - sts =dmar_readl (iommu->reg,DMAR_GSTS_REG );if ( !(sts &DMA_GSTS_QIES ) ) { - dprintk(XENLOG_ERR VTDPREFIX, -"Queued invalidation is not enabled, should not enable " - "interrupt remapping\n"); + printk(XENLOG_ERR VTDPREFIX +" Queued invalidation is not enabled on IOMMU #%u:" + " Should not enable interrupt remapping\n", iommu->index);return -EINVAL ; } +if ( !eim && (sts &DMA_GSTS_CFIS ) ) + printk(XENLOG_WARNING VTDPREFIX +" Compatibility Format Interrupts permitted on IOMMU #%u:" +" Device pass-through will be insecure\n" , iommu->index); +if ( ir_ctrl->iremap_maddr ==0 ) { drhd =iommu_to_drhd (iommu);