[SRU][B/master-next][PATCH] iommu/ipmmu-vmsa: Don't register as BUS IOMMU if machine doesn't have

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[SRU][B/master-next][PATCH] iommu/ipmmu-vmsa: Don't register as BUS IOMMU if machine doesn't have

Paolo Pisati-5
BugLink: https://bugs.launchpad.net/bugs/1783746

[Impact]

The ipmmu-vmsa driver registers itself to the system via an initcall() to
ipmmu_init(), and in case it's the first (or the only) iommu driver, it
registers its iommu ops to the platform bus - in the tegra2 case, there's no
iommu hardware, so all drivers bail out, except for the ipmmu-vmsa.

Later on, during boot, when the Tegra host1x is probing
(drivers/gpu/host1x/dev.c::host1x_probe()), it checks if an iommu device is
present (drivers/iommu/iommu.c::iommu_present() that does so by identifying if
any iommu ops were registered) and attach to the supposedly present device,
incurring in a null pointer dereference.

Upstream quickly acknowledged the problem, and rolled a patch to restrict the
ipmmu-vmsa driver to register if and only if a compatible device is present.

The fix appeared initially in 4.19, and was later backported via stable to
4.18.x, and this is a clean cherry pick of that commit.

[Fix]

Apply the attached patch and recompile.

[How to test]

Try to boot a patched kernel on a Tegra2 board.

[Regession potential]

None, the fix is trivial.

--

Dmitry Osipenko (1):
  iommu/ipmmu-vmsa: Don't register as BUS IOMMU if machine doesn't have
    IPMMU-VMSA

 drivers/iommu/ipmmu-vmsa.c | 7 +++++++
 1 file changed, 7 insertions(+)

--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH] iommu/ipmmu-vmsa: Don't register as BUS IOMMU if machine doesn't have IPMMU-VMSA

Paolo Pisati-5
From: Dmitry Osipenko <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1783746

commit 5c5c87411488af3cd082221e567498d813d0fe83 upstream.

This fixes kernel crashing on NVIDIA Tegra if kernel is compiled in
a multiplatform configuration and IPMMU-VMSA driver is enabled.

Cc: <[hidden email]> # v3.20+
Signed-off-by: Dmitry Osipenko <[hidden email]>
Signed-off-by: Joerg Roedel <[hidden email]>
Signed-off-by: Greg Kroah-Hartman <[hidden email]>

(cherry picked from commit 3245925a8e9c4fb5f2ccb2b7c21d2cb35ce8725a)
Signed-off-by: Paolo Pisati <[hidden email]>
---
 drivers/iommu/ipmmu-vmsa.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 8dce3a9..2435103 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -1081,12 +1081,19 @@ static struct platform_driver ipmmu_driver = {
 
 static int __init ipmmu_init(void)
 {
+ struct device_node *np;
  static bool setup_done;
  int ret;
 
  if (setup_done)
  return 0;
 
+ np = of_find_matching_node(NULL, ipmmu_of_ids);
+ if (!np)
+ return 0;
+
+ of_node_put(np);
+
  ret = platform_driver_register(&ipmmu_driver);
  if (ret < 0)
  return ret;
--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [PATCH] iommu/ipmmu-vmsa: Don't register as BUS IOMMU if machine doesn't have IPMMU-VMSA

Stefan Bader-2
On 11.09.2018 13:00, Paolo Pisati wrote:

> From: Dmitry Osipenko <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1783746
>
> commit 5c5c87411488af3cd082221e567498d813d0fe83 upstream.
>
> This fixes kernel crashing on NVIDIA Tegra if kernel is compiled in
> a multiplatform configuration and IPMMU-VMSA driver is enabled.
>
> Cc: <[hidden email]> # v3.20+
> Signed-off-by: Dmitry Osipenko <[hidden email]>
> Signed-off-by: Joerg Roedel <[hidden email]>
> Signed-off-by: Greg Kroah-Hartman <[hidden email]>
>
> (cherry picked from commit 3245925a8e9c4fb5f2ccb2b7c21d2cb35ce8725a)
> Signed-off-by: Paolo Pisati <[hidden email]>
Acked-by: Stefan Bader <[hidden email]>

> ---
>  drivers/iommu/ipmmu-vmsa.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index 8dce3a9..2435103 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -1081,12 +1081,19 @@ static struct platform_driver ipmmu_driver = {
>  
>  static int __init ipmmu_init(void)
>  {
> + struct device_node *np;
>   static bool setup_done;
>   int ret;
>  
>   if (setup_done)
>   return 0;
>  
> + np = of_find_matching_node(NULL, ipmmu_of_ids);
> + if (!np)
> + return 0;
> +
> + of_node_put(np);
> +
>   ret = platform_driver_register(&ipmmu_driver);
>   if (ret < 0)
>   return ret;
>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

ACK: [PATCH] iommu/ipmmu-vmsa: Don't register as BUS IOMMU if machine doesn't have IPMMU-VMSA

Colin Ian King-2
In reply to this post by Paolo Pisati-5
On 11/09/18 12:00, Paolo Pisati wrote:

> From: Dmitry Osipenko <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1783746
>
> commit 5c5c87411488af3cd082221e567498d813d0fe83 upstream.
>
> This fixes kernel crashing on NVIDIA Tegra if kernel is compiled in
> a multiplatform configuration and IPMMU-VMSA driver is enabled.
>
> Cc: <[hidden email]> # v3.20+
> Signed-off-by: Dmitry Osipenko <[hidden email]>
> Signed-off-by: Joerg Roedel <[hidden email]>
> Signed-off-by: Greg Kroah-Hartman <[hidden email]>
>
> (cherry picked from commit 3245925a8e9c4fb5f2ccb2b7c21d2cb35ce8725a)
> Signed-off-by: Paolo Pisati <[hidden email]>
> ---
>  drivers/iommu/ipmmu-vmsa.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index 8dce3a9..2435103 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -1081,12 +1081,19 @@ static struct platform_driver ipmmu_driver = {
>  
>  static int __init ipmmu_init(void)
>  {
> + struct device_node *np;
>   static bool setup_done;
>   int ret;
>  
>   if (setup_done)
>   return 0;
>  
> + np = of_find_matching_node(NULL, ipmmu_of_ids);
> + if (!np)
> + return 0;
> +
> + of_node_put(np);
> +
>   ret = platform_driver_register(&ipmmu_driver);
>   if (ret < 0)
>   return ret;
>

Clean cherry pick.

Acked-by: Colin Ian King <[hidden email]>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team