VT-d: make dom0-strict work with buggy firmware
v2 cover VT-d: make dom0-strict work with buggy firmware
When dom0-strict mode is enabled the iommu_inclusive_mapping workaround for firmware with undeclared RMRRs is rendered useless. This series fixes the problem.
Paul Durrant (2):
VT-d: re-phrase logic in vtd_set_hwdom_mapping() for clarity
VT-d: reconcile iommu_inclusive_mapping and iommu=dom0-strict
docs/misc/xen-command-line.markdown | 6 ++++-- xen/drivers/passthrough/vtd/iommu.c | 2 +- xen/drivers/passthrough/vtd/x86/vtd.c | 39 ++++++++++++++++++++++------------- xen/include/xen/iommu.h | 2 +- 4 files changed, 31 insertions(+), 18 deletions(-)
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Kevin Tian <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Roger Pau Monne <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/2 VT-d: re-phrase logic in vtd_set_hwdom_mapping() for clarity
It is hard to reconcile the comment at the top of the loop in vtd_set_hwdom_mapping() with the if statement following it. This patch re-phrases the logic, preserving the semantics, but making it easier to read.
The patch also modifies the Xen command line documentation to make it clear that iommu_inclusive_mapping only applies to pages up to the 4GB boundary.
NOTE: This patch also corrects the indentation of the printk() towards
the end of vtd_set_hwdom_mapping().
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Kevin Tian <[email protected]>
Cc: Roger Pau Monne <[email protected]>
v2:
- Compare against GB(4) rather than 0xffffffff.
--- docs/misc/xen-command-line.markdown | 4 ++-- xen/drivers/passthrough/vtd/x86/vtd.c | 31 +++++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-)
docs/misc/xen-command-line.markdown +2 -2
@@ -1212,8 +1212,8 @@ wait descriptor timed out', try increasing this value. Use this to work around firmware issues providing incorrect RMRR entries. Rather than only mapping RAM pages for IOMMU accesses for Dom0, with this -option all pages not marked as unusable in the E820 table will get a mapping -established. +option all pages up to 4GB, not marked as unusable in the E820 table, will +get a mapping established. ### irq\_ratelimit (x86) > `= <integer>`
xen/drivers/passthrough/vtd/x86/vtd.c +17 -14
@@ -114,26 +114,29 @@ void __hwdom_init vtd_set_hwdom_mapping(struct domain *d)BUG_ON (!is_hardware_domain (d)); - top =max (max_pdx,pfn_to_pdx (0xffffffffUL >>PAGE_SHIFT ) +1 ); + top =max (max_pdx,pfn_to_pdx (GB (4 ) >>PAGE_SHIFT ));for ( i =0 ; i < top; i++ ) { +unsigned long pfn =pdx_to_pfn (i); +bool map;int rc =0 ; +if ( pfn >= (GB (4 ) >>PAGE_SHIFT ) && !mfn_valid (_mfn (pfn)) ) +continue ; +/* -* Set up 1:1 mapping for dom0. Default to use only conventional RAM -* areas and let RMRRs include needed reserved regions. When set, the -* inclusive mapping maps in everything below 4GB except unusable -* ranges. +* Set up 1:1 mapping for dom0. Default to include only +* conventional RAM areas and let RMRRs include needed reserved +* regions. When set, the inclusive mapping maps in every pfn up +* to 4GB except those that fall in unusable ranges. */ -unsigned long pfn =pdx_to_pfn (i); +if ( iommu_inclusive_mapping && pfn < (GB (4 ) >>PAGE_SHIFT ) ) + map = !page_is_ram_type (pfn,RAM_TYPE_UNUSABLE ); +else + map =page_is_ram_type (pfn,RAM_TYPE_CONVENTIONAL ); -if ( pfn > (0xffffffffUL >>PAGE_SHIFT ) ? - (!mfn_valid (_mfn (pfn)) || - !page_is_ram_type (pfn,RAM_TYPE_CONVENTIONAL )) : - iommu_inclusive_mapping ? -page_is_ram_type (pfn,RAM_TYPE_UNUSABLE ) : - !page_is_ram_type (pfn,RAM_TYPE_CONVENTIONAL ) ) +if ( !map )continue ;/* Exclude Xen bits */
@@ -151,8 +154,8 @@ void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) }if ( rc ) - printk(XENLOG_WARNING VTDPREFIX " d%d: IOMMU mapping failed: %d\n", - d->domain_id, rc); + printk(XENLOG_WARNING VTDPREFIX " d%d: IOMMU mapping failed: %d\n", + d->domain_id, rc);if (!(i & (0xfffff >> (PAGE_SHIFT -PAGE_SHIFT_4K ))))process_pending_softirqs ();
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] VT-d: re-phrase logic in vtd_set_hwdom_mapping() for clarity
Quoted 5 lines · Paul Durrant
It is hard to reconcile the comment at the top of the loop in
vtd_set_hwdom_mapping()with the if statement following it. This patch re-phrases the logic, preserving the semantics, but making it easier to read.
Quoted 8 lines
The patch also modifies the Xen command line documentation to make it clear that
iommu_inclusive_mappingonly applies to pages up to the 4GB boundary.NOTE: This patch also corrects the indentation of the
printk()towards
the end ofvtd_set_hwdom_mapping().Signed-off-by Paul Durrant <[email protected]>
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] VT-d: re-phrase logic in vtd_set_hwdom_mapping() for clarity
In reply to Paul Durrantxen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 117
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 12.06.18 at 15:47, <[email protected]> wrote:
xen/drivers/passthrough/vtd/x86/vtd.c +1
-1@@ -114,26 +114,29 @@ void __hwdom_init vtd_set_hwdom_mapping(struct domain *d)BUG_ON (!is_hardware_domain (d)); - top =max (max_pdx,pfn_to_pdx (0xffffffffUL >>PAGE_SHIFT ) +1 ); + top =max (max_pdx,pfn_to_pdx (GB (4 ) >>PAGE_SHIFT ));
At certain boundaries
pfn_to_pdx(x + 1) != pfn_to_pdx(x) + 1
i.e. there was a reason for the way this was phrased before.
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 126
Quoted 8 lines
xen/drivers/passthrough/vtd/x86/vtd.c +4
-0for ( i =0 ; i < top; i++ ) { +unsigned long pfn =pdx_to_pfn (i); +bool map;int rc =0 ; +if ( pfn >= (GB (4 ) >>PAGE_SHIFT ) && !mfn_valid (_mfn (pfn)) ) +continue ;
Why ahead of the comment ...
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 133
Quoted 10 lines
xen/drivers/passthrough/vtd/x86/vtd.c +4
-4/* -* Set up 1:1 mapping for dom0. Default to use only conventional RAM -* areas and let RMRRs include needed reserved regions. When set, the -* inclusive mapping maps in everything below 4GB except unusable -* ranges. +* Set up 1:1 mapping for dom0. Default to include only +* conventional RAM areas and let RMRRs include needed reserved +* regions. When set, the inclusive mapping maps in every pfn up +* to 4GB except those that fall in unusable ranges. */
... explaining it, when the other parts that get explained follow after it?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] VT-d: re-phrase logic in vtd_set_hwdom_mapping() for clarity
Quoted 22 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 14 June 2018 16:44
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Kevin Tian <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: Re: [PATCH v2 1/2] VT-d: re-phrase logic invtd_set_hwdom_mapping()for clarityxen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 12.06.18 at 15:47, <[email protected]> wrote:
xen/drivers/passthrough/vtd/x86/vtd.c +0
-0@@ -114,26 +114,29 @@ void __hwdom_init
vtd_set_hwdom_mapping(struct domain *d)Quoted 3 lines
xen/drivers/passthrough/vtd/x86/vtd.c +0
-0BUG_ON (!is_hardware_domain (d));
Quoted 8 lines
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 117
Quoted 2 lines
xen/drivers/passthrough/vtd/x86/vtd.c +1
-1- top =max (max_pdx,pfn_to_pdx (0xffffffffUL >>PAGE_SHIFT ) +1 ); + top =max (max_pdx,pfn_to_pdx (GB (4 ) >>PAGE_SHIFT ));At certain boundaries
pfn_to_pdx(x + 1)!=pfn_to_pdx(x)+ 1i.e. there was a reason for the way this was phrased before.
Oh, I'd misread the bracketing (and I actually didn't know that either). How about:
max_pfn = (GB(4) >> PAGE_SHIFT) - 1;
top = max(max_pdx, pfn_to_pdx(max_pfn) + 1);
Quoted 24 lines
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 126
Quoted 9 lines
xen/drivers/passthrough/vtd/x86/vtd.c +4
-0for ( i =0 ; i < top; i++ ) { +unsigned long pfn =pdx_to_pfn (i); +bool map;int rc =0 ; +if ( pfn >= (GB (4 ) >>PAGE_SHIFT ) && !mfn_valid (_mfn (pfn)) ) +continue ;Why ahead of the comment ...
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d)
Quoted 3 lines
xen/drivers/passthrough/vtd/x86/vtd.c +0
-2/* -* Set up 1:1 mapping for dom0. Default to use only conventional RAM -* areas and let RMRRs include needed reserved regions. When set, the
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 133
Quoted 7 lines
xen/drivers/passthrough/vtd/x86/vtd.c +4
-2-* inclusive mapping maps in everything below 4GB except unusable -* ranges. +* Set up 1:1 mapping for dom0. Default to include only +* conventional RAM areas and let RMRRs include needed reserved +* regions. When set, the inclusive mapping maps in every pfn up +* to 4GB except those that fall in unusable ranges. */
Quoted 1 line
... explaining it, when the other parts that get explained follow after it?
Because the comment only refers to what happens below 4G, so the prior if statement is not covered (and was not covered by the old version of the comment either).
Paul
Quoted 3 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] VT-d: re-phrase logic in vtd_set_hwdom_mapping() for clarity
Quoted 30 lines
Quoted 30 lines
Quoted 1 line · On 14.06.18 at 17:55, <[email protected]> wrote:
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 14 June 2018 16:44
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Kevin Tian <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: Re: [PATCH v2 1/2] VT-d: re-phrase logic invtd_set_hwdom_mapping()for clarityxen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 12.06.18 at 15:47, <[email protected]> wrote:
xen/drivers/passthrough/vtd/x86/vtd.c +0
-0@@ -114,26 +114,29 @@ void __hwdom_init
vtd_set_hwdom_mapping(struct domain *d)xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 117
Quoted 5 lines
xen/drivers/passthrough/vtd/x86/vtd.c +1
-1BUG_ON (!is_hardware_domain (d)); - top =max (max_pdx,pfn_to_pdx (0xffffffffUL >>PAGE_SHIFT ) +1 ); + top =max (max_pdx,pfn_to_pdx (GB (4 ) >>PAGE_SHIFT ));At certain boundaries
pfn_to_pdx(x + 1)!=pfn_to_pdx(x)+ 1
Quoted 7 lines
Quoted 1 line
i.e. there was a reason for the way this was phrased before.
Oh, I'd misread the bracketing (and I actually didn't know that either). How about:
max_pfn= (GB(4) >>PAGE_SHIFT) - 1;
top =max(max_pdx, pfn_to_pdx(max_pfn) + 1);
Yes, that's fine (but I'd be fine also without the extra local variable).
Quoted 23 lines
Quoted 23 lines
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 126
Quoted 8 lines
xen/drivers/passthrough/vtd/x86/vtd.c +4
-0for ( i =0 ; i < top; i++ ) { +unsigned long pfn =pdx_to_pfn (i); +bool map;int rc =0 ; +if ( pfn >= (GB (4 ) >>PAGE_SHIFT ) && !mfn_valid (_mfn (pfn)) ) +continue ;Why ahead of the comment ...
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d)
Quoted 3 lines
xen/drivers/passthrough/vtd/x86/vtd.c +0
-2/* -* Set up 1:1 mapping for dom0. Default to use only conventional RAM -* areas and let RMRRs include needed reserved regions. When set, the
Quoted 7 lines
xen/drivers/passthrough/vtd/x86/vtd.c +4
-2-* inclusive mapping maps in everything below 4GB except unusable -* ranges. +* Set up 1:1 mapping for dom0. Default to include only +* conventional RAM areas and let RMRRs include needed reserved +* regions. When set, the inclusive mapping maps in every pfn up +* to 4GB except those that fall in unusable ranges. */
Quoted 5 lines
Quoted 1 line
... explaining it, when the other parts that get explained follow after it?
Because the comment only refers to what happens below 4G, so the prior if statement is not covered (and was not covered by the old version of the comment either).
"Default to include only conventional RAM areas" very much covers the if() above, according to my reading.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] VT-d: re-phrase logic in vtd_set_hwdom_mapping() for clarity
Quoted 49 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 14 June 2018 17:03
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: RE: [PATCH v2 1/2] VT-d: re-phrase logic invtd_set_hwdom_mapping()for clarityQuoted 7 lines
Quoted 7 lines
Quoted 1 line · On 14.06.18 at 17:55, <[email protected]> wrote:
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 14 June 2018 16:44
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau MonneQuoted 1 line
Quoted 1 line
Wei Liu <[email protected]>; George Dunlap
Quoted 1 line
Quoted 1 line
Ian Jackson <[email protected]>; Kevin Tian
Quoted 23 lines
Quoted 22 lines
Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: Re: [PATCH v2 1/2] VT-d: re-phrase logic invtd_set_hwdom_mapping()for clarityxen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 12.06.18 at 15:47, <[email protected]> wrote:
xen/drivers/passthrough/vtd/x86/vtd.c +0
-0@@ -114,26 +114,29 @@ void __hwdom_init
vtd_set_hwdom_mapping(struct domain *d)xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 117
Quoted 5 lines
xen/drivers/passthrough/vtd/x86/vtd.c +1
-1BUG_ON (!is_hardware_domain (d)); - top =max (max_pdx,pfn_to_pdx (0xffffffffUL >>PAGE_SHIFT ) +1 ); + top =max (max_pdx,pfn_to_pdx (GB (4 ) >>PAGE_SHIFT ));At certain boundaries
pfn_to_pdx(x + 1)!=pfn_to_pdx(x)+ 1i.e. there was a reason for the way this was phrased before.
Quoted 8 lines
Quoted 5 lines
Oh, I'd misread the bracketing (and I actually didn't know that either). How about:
max_pfn= (GB(4) >>PAGE_SHIFT) - 1;
top =max(max_pdx, pfn_to_pdx(max_pfn) + 1);Yes, that's fine (but I'd be fine also without the extra local variable).
Ok.
Quoted 29 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen/drivers/passthrough/vtd/x86/vtd.c +2
-0for ( i =0 ; i < top; i++ ) { +unsigned long pfn =pdx_to_pfn (i); +bool map;int rc =0 ;Quoted 7 lines
Quoted 7 lines
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 126
Quoted 2 lines
xen/drivers/passthrough/vtd/x86/vtd.c +2
-0+if ( pfn >= (GB (4 ) >>PAGE_SHIFT ) && !mfn_valid (_mfn (pfn)) ) +continue ;Why ahead of the comment ...
Quoted 2 lines
xen/drivers/passthrough/vtd/x86/vtd.c +0
-1/* -* Set up 1:1 mapping for dom0. Default to use only conventional RAM
Quoted 1 line
Quoted 1 line
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init · line 123
Quoted 1 line
xen/drivers/passthrough/vtd/x86/vtd.c +0
-1-* areas and let RMRRs include needed reserved regions. When set,
Quoted 2 lines
Quoted 2 lines
the
Quoted 1 line
xen/drivers/passthrough/vtd/x86/vtd.c +0
-1-* inclusive mapping maps in everything below 4GB except unusable
Quoted 3 lines
Quoted 3 lines
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d)
Quoted 3 lines
xen/drivers/passthrough/vtd/x86/vtd.c +2
-1-* ranges. +* Set up 1:1 mapping for dom0. Default to include only +* conventional RAM areas and let RMRRs include needed reserved
Quoted 6 lines
Quoted 5 lines
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 133
Quoted 3 lines
xen/drivers/passthrough/vtd/x86/vtd.c +2
-0+* regions. When set, the inclusive mapping maps in every pfn up +* to 4GB except those that fall in unusable ranges. */ ... explaining it, when the other parts that get explained follow after it?
Quoted 8 lines
Quoted 1 line
Because the comment only refers to what happens below 4G, so the prior
if
Quoted 2 lines
statement is not covered (and was not covered by the old version of the comment either).
"Default to include only conventional RAM areas" very much covers the
if()above, according to my reading.
Ok, I suppose it does. I'll move it below the comment.
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/2 VT-d: reconcile iommu_inclusive_mapping and iommu=dom0-strict
In reply to Paul DurrantThe documentation for the iommu_inclusive_mapping Xen command line option states:
"Use this to work around firmware issues providing incorrect RMRR entries"
Unfortunately this workaround does not function correctly if the dom0-strict iommu option is also specified.
The documentation goes on to say:
"Rather than only mapping RAM pages for IOMMU accesses for Dom0, with this
option all pages up to 4GB, not marked as unusable in the E820 table, will get a mapping established."
This patch modifies the VT-d hardware domain initialization code such that the workaround will continue to function in dom0-strict mode, by mapping all pages not marked as unusable *unless* they are RAM pages not assigned to dom0.
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Kevin Tian <[email protected]>
v2:
- Make sure that the initial mapping only applies to PV dom0.
--- docs/misc/xen-command-line.markdown | 4 +++- xen/drivers/passthrough/vtd/iommu.c | 2 +- xen/drivers/passthrough/vtd/x86/vtd.c | 8 ++++++++ xen/include/xen/iommu.h | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-)
docs/misc/xen-command-line.markdown +3 -1
@@ -1213,7 +1213,9 @@ wait descriptor timed out', try increasing this value. Use this to work around firmware issues providing incorrect RMRR entries. Rather than only mapping RAM pages for IOMMU accesses for Dom0, with this option all pages up to 4GB, not marked as unusable in the E820 table, will -get a mapping established. +get a mapping established. Note that this option is only applicable to a +PV dom0 and if `dom0-strict` mode is enabled then conventional RAM pages +not assigned to dom0 will not be mapped. ### irq\_ratelimit (x86) > `= <integer>`
xen/drivers/passthrough/vtd/iommu.c +1 -1
@@ -1304,7 +1304,7 @@ static void __hwdom_init intel_iommu_hwdom_init(struct domain *d) {struct acpi_drhd_unit *drhd; -if ( !iommu_passthrough && !need_iommu (d) ) +if ( !iommu_passthrough &&is_pv_domain (d) ) {/* Set up 1:1 page table for hardware domain. */ vtd_set_hwdom_mapping (d);
xen/drivers/passthrough/vtd/x86/vtd.c +8 -0
@@ -143,6 +143,14 @@ void __hwdom_init vtd_set_hwdom_mapping(struct domain *d)if (xen_in_range (pfn) )continue ; +/* +* If dom0-strict mode is enabled then exclude conventional RAM +* and let the common code map dom0's pages. +*/ +if ( iommu_dom0_strict && +page_is_ram_type (pfn,RAM_TYPE_CONVENTIONAL ) ) +continue ; + tmp =1 << (PAGE_SHIFT -PAGE_SHIFT_4K );for ( j =0 ; j < tmp; j++ ) {
xen/include/xen/iommu.h +1 -1
@@ -29,7 +29,7 @@#include <asm/iommu.h> extern bool_t iommu_enable, iommu_enabled; -extern bool_t force_iommu, iommu_verbose; +extern bool_t force_iommu, iommu_dom0_strict, iommu_verbose;extern bool_t iommu_workaround_bios_bug, iommu_igfx, iommu_passthrough;extern bool_t iommu_snoop, iommu_qinval, iommu_intremap, iommu_intpost;extern bool_t iommu_hap_pt_share;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 2/2] VT-d: reconcile iommu_inclusive_mapping and iommu=dom0-strict
Quoted 14 lines · Paul Durrant
The documentation for the
iommu_inclusive_mappingXen command line option states:"Use this to work around firmware issues providing incorrect RMRR entries"
Unfortunately this workaround does not function correctly if the dom0-strict iommu option is also specified.
The documentation goes on to say:
"Rather than only mapping RAM pages for IOMMU accesses for Dom0, with this
option all pages up to 4GB, not marked as unusable in the E820 table, will get a mapping established."
Quoted 6 lines
This patch modifies the VT-d hardware domain initialization code such that the workaround will continue to function in dom0-strict mode, by mapping all pages not marked as unusable *unless* they are RAM pages not assigned to dom0.
Signed-off-by Paul Durrant <[email protected]>
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 2/2] VT-d: reconcile iommu_inclusive_mapping and iommu=dom0-strict
In reply to Paul DurrantQuoted 11 lines
Quoted 1 line
Quoted 1 line · On 12.06.18 at 15:47, <[email protected]> wrote:
The documentation for the
iommu_inclusive_mappingXen command line option states:"Use this to work around firmware issues providing incorrect RMRR entries"
Unfortunately this workaround does not function correctly if the dom0-strict iommu option is also specified.
The documentation goes on to say:
Quoted 8 lines
"Rather than only mapping RAM pages for IOMMU accesses for Dom0, with this
option all pages up to 4GB, not marked as unusable in the E820 table, will get a mapping established."This patch modifies the VT-d hardware domain initialization code such that the workaround will continue to function in dom0-strict mode, by mapping all pages not marked as unusable *unless* they are RAM pages not assigned to dom0.
Hmm, so far I was under the impression that the two options aren't meant to work together anyway.
docs/misc/xen-command-line.markdown wait descriptor timed out', try increasing this value. · line 1218
Quoted 10 lines
docs/misc/xen-command-line.markdown +3
-1@@ -1213,7 +1213,9 @@ wait descriptor timed out', try increasing this value. Use this to work around firmware issues providing incorrect RMRR entries. Rather than only mapping RAM pages for IOMMU accesses for Dom0, with this option all pages up to 4GB, not marked as unusable in the E820 table, will -get a mapping established. +get a mapping established. Note that this option is only applicable to a +PV dom0 and if `dom0-strict` mode is enabled then conventional RAM pages +not assigned to dom0 will not be mapped.
I think for readability you want to either split the sentence into two (dropping the "and") or at least insert a comma ahead of the "and".
xen/drivers/passthrough/vtd/iommu.c static void __hwdom_init intel_iommu_hwdom_init(struct domain *d) · line 1307
Quoted 8 lines
xen/drivers/passthrough/vtd/iommu.c +1
-1@@ -1304,7 +1304,7 @@ static void __hwdom_init intel_iommu_hwdom_init(struct domain *d) {struct acpi_drhd_unit *drhd; -if ( !iommu_passthrough && !need_iommu (d) ) +if ( !iommu_passthrough &&is_pv_domain (d) )
I don't understand this change: Where is the !need_iommu() condition getting enforced now? Oh, wait ...
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 150
Quoted 11 lines
xen/drivers/passthrough/vtd/x86/vtd.c +5
-0@@ -143,6 +143,14 @@ void __hwdom_init vtd_set_hwdom_mapping(struct domain *d)if (xen_in_range (pfn) )continue ; +/* +* If dom0-strict mode is enabled then exclude conventional RAM +* and let the common code map dom0's pages. +*/ + if ( iommu_dom0_strict &&
This is equivalent to need_iommu(d), and if you wrote it that way the patch would be easier to review and ...
xen/include/xen/iommu.h line 32
Quoted 8 lines
xen/include/xen/iommu.h +1
-1@@ -29,7 +29,7 @@#include <asm/iommu.h> extern bool_t iommu_enable, iommu_enabled; -extern bool_t force_iommu, iommu_verbose; +extern bool_t force_iommu, iommu_dom0_strict, iommu_verbose;
... this wouldn't be needed.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 2/2] VT-d: reconcile iommu_inclusive_mapping and iommu=dom0-strict
Quoted 54 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 14 June 2018 16:59
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Kevin Tian <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: Re: [PATCH v2 2/2] VT-d: reconcileiommu_inclusive_mappingand iommu=dom0-strictQuoted 2 lines
Quoted 1 line
Quoted 1 line · On 12.06.18 at 15:47, <[email protected]> wrote:
The documentation for the
iommu_inclusive_mappingXen command lineoption
Quoted 3 lines
states:
"Use this to work around firmware issues providing incorrect RMRR
entries"
Quoted 2 lines
Unfortunately this workaround does not function correctly if the dom0-
strict
Quoted 5 lines
iommu option is also specified.
The documentation goes on to say:
"Rather than only mapping RAM pages for IOMMU accesses for Dom0, with
this
Quoted 6 lines
option all pages up to 4GB, not marked as unusable in the E820 table, will get a mapping established."
This patch modifies the VT-d hardware domain initialization code such that the workaround will continue to function in dom0-strict mode, by mapping all pages not marked as unusable *unless* they are RAM pages not
assigned
Quoted 1 line
to dom0.
Hmm, so far I was under the impression that the two options aren't meant to work together anyway.
docs/misc/xen-command-line.markdown wait descriptor timed out', try increasing this
Quoted 3 lines
docs/misc/xen-command-line.markdown +0
-0@@ -1213,7 +1213,9 @@ wait descriptor timed out', try increasing thisvalue.
docs/misc/xen-command-line.markdown wait descriptor timed out', try increasing this · line 1214
Quoted 2 lines
docs/misc/xen-command-line.markdown +0
-0Use this to work around firmware issues providing incorrect RMRR entries. Rather than only mapping RAM pages for IOMMU accesses for Dom0, withthis
docs/misc/xen-command-line.markdown wait descriptor timed out', try increasing this value.
Quoted 4 lines
docs/misc/xen-command-line.markdown +2
-1option all pages up to 4GB, not marked as unusable in the E820 table, will -get a mapping established. +get a mapping established. Note that this option is only applicable to a +PV dom0 and if `dom0-strict` mode is enabled then conventional RAMpages
Quoted 5 lines
docs/misc/xen-command-line.markdown wait descriptor timed out', try increasing this value. · line 1218
Quoted 1 line
docs/misc/xen-command-line.markdown +1
-0+not assigned to dom0 will not be mapped.I think for readability you want to either split the sentence into two (dropping
the "and") or at least insert a comma ahead of the "and".
Ok.
Quoted 35 lines
xen/drivers/passthrough/vtd/iommu.c static void __hwdom_init
Quoted 4 lines
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -1304,7 +1304,7 @@ static void __hwdom_init
intel_iommu_hwdom_init(struct domain *d)xen/drivers/passthrough/vtd/iommu.c static void __hwdom_init intel_iommu_hwdom_init(struct domain *d) · line 1307
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +1
-1{struct acpi_drhd_unit *drhd; -if ( !iommu_passthrough && !need_iommu (d) ) +if ( !iommu_passthrough &&is_pv_domain (d) )I don't understand this change: Where is the !need_iommu() condition getting enforced now? Oh, wait ...
xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init
Quoted 3 lines
xen/drivers/passthrough/vtd/x86/vtd.c +0
-0@@ -143,6 +143,14 @@ void __hwdom_init
vtd_set_hwdom_mapping(struct domain *d)xen/drivers/passthrough/vtd/x86/vtd.c void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) · line 150
Quoted 8 lines
xen/drivers/passthrough/vtd/x86/vtd.c +5
-0if (xen_in_range (pfn) )continue ; +/* +* If dom0-strict mode is enabled then exclude conventional RAM +* and let the common code map dom0's pages. +*/ + if ( iommu_dom0_strict &&This is equivalent to
need_iommu(d), and if you wrote it that way the patch would be easier to review and ...Quoted 5 lines
xen/include/xen/iommu.h +0
-0@@ -29,7 +29,7 @@#include <asm/iommu.h>
Quoted 6 lines
xen/include/xen/iommu.h line 32
Quoted 3 lines
xen/include/xen/iommu.h +1
-1extern bool_t iommu_enable, iommu_enabled; -extern bool_t force_iommu, iommu_verbose; +extern bool_t force_iommu, iommu_dom0_strict, iommu_verbose;... this wouldn't be needed.
I could do that, but I think that checking the actual option rather than a side-effect of the option is preferable so I'd rather leave it this way. I'll add some text to the commit comment.
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel