iommu: fix PVH dom0 settings
PATCH 1/1 iommu: fix PVH dom0 settings
PVH dom0 must operate with the iommu settings in 'strict' mode i.e. only the domain's own pages will be mapped in the IOMMU. The check_hwdom_reqs() is supposed to ensure this. Unfortunately the test for a PVH dom0 is made using paging_mode_translate() and, when commit f89f5558 "remove late (on-demand) construction of IOMMU page tables" moved the call of check_hwdom_reqs() from iommu_hwdom_init() to iommu_domain_init(), that test became ineffective (because iommu_domain_init() is called before paging_enable()).
This patch replaces the test of paging_mode_translate() with a test of hap_enabled(), and also verifies 'strict' mode is turned on in arch_iommu_check_autotranslated_hwdom().
---
Cc: Jan Beulich <[email protected]>
--- xen/drivers/passthrough/iommu.c | 6 +++--- xen/drivers/passthrough/x86/iommu.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-)
xen/drivers/passthrough/iommu.c +3 -3
@@ -154,13 +154,13 @@ custom_param("dom0-iommu", parse_dom0_iommu_param); static void __hwdom_init check_hwdom_reqs(struct domain *d) { -if ( iommu_hwdom_none || !paging_mode_translate (d) ) +if ( iommu_hwdom_none || !hap_enabled (d) )return ; -arch_iommu_check_autotranslated_hwdom (d); - iommu_hwdom_passthrough = false; iommu_hwdom_strict = true; + +arch_iommu_check_autotranslated_hwdom (d); }int iommu_domain_init (struct domain *d,unsigned int opts)
xen/drivers/passthrough/x86/iommu.c +3 -0
@@ -85,6 +85,9 @@ void __hwdom_init arch_iommu_check_autotranslated_hwdom(struct domain *d) {if ( !is_iommu_enabled (d) )panic ("Presently, iommu must be enabled for PVH hardware domain\n" ); + +if ( !iommu_hwdom_strict ) +panic ("PVH hardware domain iommu must be set in 'strict' mode\n" ); }int arch_iommu_domain_init (struct domain *d)
Signature · 7 lines
2.20.1.2.gb21ebb671 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Paul Durrant
PVH dom0 must operate with the iommu settings in 'strict' mode i.e. only the domain's own pages will be mapped in the IOMMU. The
check_hwdom_reqs()is supposed to ensure this. Unfortunately the test for a PVH dom0 is made usingpaging_mode_translate()and, when commitf89f5558"remove late (on-demand) construction of IOMMU page tables" moved the call ofcheck_hwdom_reqs()fromiommu_hwdom_init()toiommu_domain_init(), that test became ineffective (becauseiommu_domain_init()is called beforepaging_enable()).
Quoted 6 lines
This patch replaces the test of
paging_mode_translate()with a test ofhap_enabled(), and also verifies 'strict' mode is turned on inarch_iommu_check_autotranslated_hwdom().Signed-off-by Paul Durrant <[email protected]>Reported-by Roger Pau Monne <[email protected]>
Nit: Conventionally your two tags should be the other way around, to represent events chronologically.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Paul Durrant
PVH dom0 must operate with the iommu settings in 'strict' mode i.e. only the domain's own pages will be mapped in the IOMMU. The
check_hwdom_reqs()is supposed to ensure this. Unfortunately the test for a PVH dom0 is made usingpaging_mode_translate()and, when commitf89f5558"remove late (on-demand) construction of IOMMU page tables" moved the call ofcheck_hwdom_reqs()fromiommu_hwdom_init()toiommu_domain_init(), that test became ineffective (becauseiommu_domain_init()is called beforepaging_enable()).
Quoted 6 lines
This patch replaces the test of
paging_mode_translate()with a test ofhap_enabled(), and also verifies 'strict' mode is turned on inarch_iommu_check_autotranslated_hwdom().Signed-off-by Paul Durrant <[email protected]>Reported-by Roger Pau Monne <[email protected]>
Oh, and I guess you've also meant to Cc Jürgen for a release ack (now done)?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Paul Durrant
PVH dom0 must operate with the iommu settings in 'strict' mode i.e. only the domain's own pages will be mapped in the IOMMU. The
check_hwdom_reqs()is supposed to ensure this. Unfortunately the test for a PVH dom0 is made usingpaging_mode_translate()and, when commitf89f5558"remove late (on-demand) construction of IOMMU page tables" moved the call ofcheck_hwdom_reqs()fromiommu_hwdom_init()toiommu_domain_init(), that test became ineffective (becauseiommu_domain_init()is called beforepaging_enable()).This patch replaces the test of
paging_mode_translate()with a test ofhap_enabled(), and also verifies 'strict' mode is turned on inarch_iommu_check_autotranslated_hwdom().
Quoted 5 lines
Quoted 2 lines
Signed-off-by Paul Durrant <[email protected]>Reported-by Roger Pau Monne <[email protected]>Oh, and I guess you've also meant to Cc Jürgen for a release ack (now done)?
Thanks for the Cc!
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 27 lines · Paul Durrant
PVH dom0 must operate with the iommu settings in 'strict' mode i.e. only the domain's own pages will be mapped in the IOMMU. The
check_hwdom_reqs()is supposed to ensure this. Unfortunately the test for a PVH dom0 is made usingpaging_mode_translate()and, when commitf89f5558"remove late (on-demand) construction of IOMMU page tables" moved the call ofcheck_hwdom_reqs()fromiommu_hwdom_init()toiommu_domain_init(), that test became ineffective (becauseiommu_domain_init()is called beforepaging_enable()).This patch replaces the test of
paging_mode_translate()with a test ofhap_enabled(), and also verifies 'strict' mode is turned on inarch_iommu_check_autotranslated_hwdom().Signed-off-by Paul Durrant <[email protected]>Reported-by Roger Pau Monne <[email protected]>---
Cc: Jan Beulich <[email protected]>--- xen/drivers/passthrough/iommu.c | 6 +++--- xen/drivers/passthrough/x86/iommu.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-)xen/drivers/passthrough/iommu.c +0
-0
xen/drivers/passthrough/iommu.c custom_param("dom0-iommu", parse_dom0_iommu_param); · line 157
Quoted 5 lines
xen/drivers/passthrough/iommu.c +1
-1@@ -154,13 +154,13 @@ custom_param("dom0-iommu", parse_dom0_iommu_param); static void __hwdom_init check_hwdom_reqs(struct domain *d) { -if ( iommu_hwdom_none || !paging_mode_translate (d) ) +if ( iommu_hwdom_none || !hap_enabled (d) )
Since dom0 PVH can also be used with shadow paging (not sure how useful that is TBH), I'm not sure explicitly checking for hap is fine. What about using is_hvm_domain instead?
That ought to cover both shadow and hap, and a classic PV dom0 won't be affected by it (which is the intention).
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 14 lines · Roger Pau Monné
xen/drivers/passthrough/iommu.c custom_param("dom0-iommu", parse_dom0_iommu_param); · line 157
Quoted 8 lines · Paul Durrant
xen/drivers/passthrough/iommu.c +1
-1@@ -154,13 +154,13 @@ custom_param("dom0-iommu", parse_dom0_iommu_param); static void __hwdom_init check_hwdom_reqs(struct domain *d) { -if ( iommu_hwdom_none || !paging_mode_translate (d) ) +if ( iommu_hwdom_none || !hap_enabled (d) )Since dom0 PVH can also be used with shadow paging (not sure how useful that is TBH), I'm not sure explicitly checking for hap is fine. What about using
is_hvm_domaininstead?
Quoted 2 lines
That ought to cover both shadow and hap, and a classic PV dom0 won't be affected by it (which is the intention).
Oh, indeed - we shouldn't prevent shadow mode use. That'll need to be an incremental change though, as I've already committed the one here.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel