iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
PATCH 1/1 iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
...when the IOMMU is not enabled.
80ff3d338dc9 "iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync() macros" introduced CONFIG_IOMMU_FORCE_PT_SHARE, which causes the global 'iommu_hap_pt_share' option to be replaced with a #define-d value of true. In this configuration, calling clear_iommu_hap_pt_share() will result trigger the aforementioned ASSERT.
CONFIG_IOMMU_FORCE_PT_SHARE is always selected for ARM builds and, because clear_iommu_hap_pt_share() is called by the common iommu_setup() function if the IOMMU is not enabled, it is no longer safe to disable the IOMMU on ARM systems.
However, running with the IOMMU disabled is a valid configuration for ARM systems, so this patch rectifies the problem by removing the call to clear_iommu_hap_pt_share() from common code. As a side effect of this, however, it becomes possible on x86 systems for iommu_enabled to be false but iommu_hap_pt_share to be true. Thus the code in sysctl.c needs to be changed to make sure that XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share is not erroneously advertised when the IOMMU has been disabled.
---
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]>
--- xen/common/sysctl.c | 6 ++++-- xen/drivers/passthrough/iommu.c | 1 - 2 files changed, 4 insertions(+), 3 deletions(-)
xen/common/sysctl.c +4 -2
@@ -268,9 +268,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) pi->max_mfn =get_upper_mfn_bound ();arch_do_physinfo (pi);if ( iommu_enabled ) + { pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio; -if ( iommu_hap_pt_share ) - pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share; +if ( iommu_hap_pt_share ) + pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share; + }if (copy_to_guest (u_sysctl, op,1 ) ) ret = -EFAULT ;
xen/drivers/passthrough/iommu.c +0 -1
@@ -456,7 +456,6 @@ int __init iommu_setup(void)if ( !iommu_enabled ) { iommu_intremap =0 ; -clear_iommu_hap_pt_share (); } if ( (force_iommu && !iommu_enabled) ||
Signature · 7 lines
2.20.1.2.gb21ebb671 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Paul,
Quoted 21 lines · Paul Durrant
...when the IOMMU is not enabled.
80ff3d338dc9"iommu: tidy upiommu_use_hap_pt()andneed_iommu_pt_sync()macros" introducedCONFIG_IOMMU_FORCE_PT_SHARE, which causes the global 'iommu_hap_pt_share' option to be replaced with a #define-d value of true. In this configuration, callingclear_iommu_hap_pt_share()will result trigger the aforementioned ASSERT.
CONFIG_IOMMU_FORCE_PT_SHAREis always selected for ARM builds and, becauseclear_iommu_hap_pt_share()is called by the commoniommu_setup()function if the IOMMU is not enabled, it is no longer safe to disable the IOMMU on ARM systems.However, running with the IOMMU disabled is a valid configuration for ARM systems, so this patch rectifies the problem by removing the call to
clear_iommu_hap_pt_share()from common code. As a side effect of this, however, it becomes possible on x86 systems foriommu_enabledto be false butiommu_hap_pt_shareto be true. Thus the code insysctl.cneeds to be changed to make sure thatXEN_SYSCTL_PHYSCAP_iommu_hap_pt_shareis not erroneously advertised when the IOMMU has been disabled.
Quoted 2 lines
Signed-off-by Paul Durrant <[email protected]>Reported-by Oleksandr <[email protected]>
With one NIT below:
Quoted 38 lines
---
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]>--- xen/common/sysctl.c | 6 ++++-- xen/drivers/passthrough/iommu.c | 1 - 2 files changed, 4 insertions(+), 3 deletions(-)xen/common/sysctl.c +4
-2@@ -268,9 +268,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) pi->max_mfn =get_upper_mfn_bound ();arch_do_physinfo (pi);if ( iommu_enabled ) + { pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio; -if ( iommu_hap_pt_share ) - pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share; +if ( iommu_hap_pt_share ) + pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share; + }if (copy_to_guest (u_sysctl, op,1 ) ) ret = -EFAULT ;xen/drivers/passthrough/iommu.c +0
-0
xen/drivers/passthrough/iommu.c int __init iommu_setup(void) · line 459
Quoted 5 lines
xen/drivers/passthrough/iommu.c +0
-1@@ -456,7 +456,6 @@ int __init iommu_setup(void)if ( !iommu_enabled ) { iommu_intremap =0 ; -clear_iommu_hap_pt_share (); }
NIT: The {} can now be removed.
I can fix it on commit.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Oleksandr
Tested-by Oleksandr TyshchenkoHi Paul, Julien
Quoted 24 lines · Julien Grall
Hi Paul,
Quoted 21 lines · Paul Durrant
...when the IOMMU is not enabled.
80ff3d338dc9"iommu: tidy upiommu_use_hap_pt()andneed_iommu_pt_sync()macros" introducedCONFIG_IOMMU_FORCE_PT_SHARE, which causes the global 'iommu_hap_pt_share' option to be replaced with a #define-d value of true. In this configuration, callingclear_iommu_hap_pt_share()will result trigger the aforementioned ASSERT.
CONFIG_IOMMU_FORCE_PT_SHAREis always selected for ARM builds and, becauseclear_iommu_hap_pt_share()is called by the commoniommu_setup()function if the IOMMU is not enabled, it is no longer safe to disable the IOMMU on ARM systems.However, running with the IOMMU disabled is a valid configuration for ARM systems, so this patch rectifies the problem by removing the call to
clear_iommu_hap_pt_share()from common code. As a side effect of this, however, it becomes possible on x86 systems foriommu_enabledto be false butiommu_hap_pt_shareto be true. Thus the code insysctl.cneeds to be changed to make sure thatXEN_SYSCTL_PHYSCAP_iommu_hap_pt_shareis not erroneously advertised when the IOMMU has been disabled.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Paul Durrant <[email protected]>Reported-by Oleksandr <[email protected]>With one NIT below:
Acked-by Julien Grall <[email protected]>
Could you, please, change to:
You can also add if really needed:
[with IOMMU disabled on Arm]
Signature · 9 lines
Regards, Oleksandr Tyshchenko _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 87 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 26 September 2019 12:24
To: Paul Durrant <[email protected]>; [email protected]
Cc: Oleksandr <[email protected]>; Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Jan Beulich <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim (Xen.org) <[email protected]>; Wei Liu <[email protected]>
Subject: Re: [PATCH] iommu: avoid triggeringASSERT_UNREACHABLE()on ARM...Hi Paul,
Quoted 21 lines · Paul Durrant
...when the IOMMU is not enabled.
80ff3d338dc9"iommu: tidy upiommu_use_hap_pt()andneed_iommu_pt_sync()macros" introducedCONFIG_IOMMU_FORCE_PT_SHARE, which causes the global 'iommu_hap_pt_share' option to be replaced with a #define-d value of true. In this configuration, callingclear_iommu_hap_pt_share()will result trigger the aforementioned ASSERT.
CONFIG_IOMMU_FORCE_PT_SHAREis always selected for ARM builds and, becauseclear_iommu_hap_pt_share()is called by the commoniommu_setup()function if the IOMMU is not enabled, it is no longer safe to disable the IOMMU on ARM systems.However, running with the IOMMU disabled is a valid configuration for ARM systems, so this patch rectifies the problem by removing the call to
clear_iommu_hap_pt_share()from common code. As a side effect of this, however, it becomes possible on x86 systems foriommu_enabledto be false butiommu_hap_pt_shareto be true. Thus the code insysctl.cneeds to be changed to make sure thatXEN_SYSCTL_PHYSCAP_iommu_hap_pt_shareis not erroneously advertised when the IOMMU has been disabled.Quoted 2 lines
Signed-off-by Paul Durrant <[email protected]>Reported-by Oleksandr <[email protected]>With one NIT below:
Acked-by Julien Grall <[email protected]>Quoted 38 lines
---
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]>--- xen/common/sysctl.c | 6 ++++-- xen/drivers/passthrough/iommu.c | 1 - 2 files changed, 4 insertions(+), 3 deletions(-)xen/common/sysctl.c +4
-2@@ -268,9 +268,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) pi->max_mfn =get_upper_mfn_bound ();arch_do_physinfo (pi);if ( iommu_enabled ) + { pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio; -if ( iommu_hap_pt_share ) - pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share; +if ( iommu_hap_pt_share ) + pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share; + }if (copy_to_guest (u_sysctl, op,1 ) ) ret = -EFAULT ;xen/drivers/passthrough/iommu.c +0
-0xen/drivers/passthrough/iommu.c int __init iommu_setup(void) · line 459
Quoted 5 lines
xen/drivers/passthrough/iommu.c +0
-1@@ -456,7 +456,6 @@ int __init iommu_setup(void)if ( !iommu_enabled ) { iommu_intremap =0 ; -clear_iommu_hap_pt_share (); }NIT: The {} can now be removed.
Quoted 1 line
I can fix it on commit.
Good point. Thanks,
Paul
Quoted 5 lines
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 21 lines · Paul Durrant
...when the IOMMU is not enabled.
80ff3d338dc9"iommu: tidy upiommu_use_hap_pt()andneed_iommu_pt_sync()macros" introducedCONFIG_IOMMU_FORCE_PT_SHARE, which causes the global 'iommu_hap_pt_share' option to be replaced with a #define-d value of true. In this configuration, callingclear_iommu_hap_pt_share()will result trigger the aforementioned ASSERT.
CONFIG_IOMMU_FORCE_PT_SHAREis always selected for ARM builds and, becauseclear_iommu_hap_pt_share()is called by the commoniommu_setup()function if the IOMMU is not enabled, it is no longer safe to disable the IOMMU on ARM systems.However, running with the IOMMU disabled is a valid configuration for ARM systems, so this patch rectifies the problem by removing the call to
clear_iommu_hap_pt_share()from common code. As a side effect of this, however, it becomes possible on x86 systems foriommu_enabledto be false butiommu_hap_pt_shareto be true. Thus the code insysctl.cneeds to be changed to make sure thatXEN_SYSCTL_PHYSCAP_iommu_hap_pt_shareis not erroneously advertised when the IOMMU has been disabled.
Quoted 2 lines
Signed-off-by Paul Durrant <[email protected]>Reported-by Oleksandr <[email protected]>
Preferably with the adjustments mantioned elsewhere
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Jan,
Quoted 22 lines · Jan Beulich
Quoted 21 lines · Paul Durrant
...when the IOMMU is not enabled.
80ff3d338dc9"iommu: tidy upiommu_use_hap_pt()andneed_iommu_pt_sync()macros" introducedCONFIG_IOMMU_FORCE_PT_SHARE, which causes the global 'iommu_hap_pt_share' option to be replaced with a #define-d value of true. In this configuration, callingclear_iommu_hap_pt_share()will result trigger the aforementioned ASSERT.
CONFIG_IOMMU_FORCE_PT_SHAREis always selected for ARM builds and, becauseclear_iommu_hap_pt_share()is called by the commoniommu_setup()function if the IOMMU is not enabled, it is no longer safe to disable the IOMMU on ARM systems.However, running with the IOMMU disabled is a valid configuration for ARM systems, so this patch rectifies the problem by removing the call to
clear_iommu_hap_pt_share()from common code. As a side effect of this, however, it becomes possible on x86 systems foriommu_enabledto be false butiommu_hap_pt_shareto be true. Thus the code insysctl.cneeds to be changed to make sure thatXEN_SYSCTL_PHYSCAP_iommu_hap_pt_shareis not erroneously advertised when the IOMMU has been disabled.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Paul Durrant <[email protected]>Reported-by Oleksandr <[email protected]>Preferably with the adjustments mantioned elsewhere
Reviewed-by Jan Beulich <[email protected]>
I have done it while committing the patch.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel