[PATCH] iommu/exynos: Remove initconst attribute to avoid potential kernel oops

2017-10-09 Thread Marek Szyprowski
Exynos SYSMMU registers standard platform device with sysmmu_of_match
table, what means that this table is accessed every time a new platform
device is registered in a system. This might happen also after the boot,
so the table must not be attributed as initconst to avoid potential kernel
oops caused by access to freed memory.

Fixes: 6b21a5db3642 ("iommu/exynos: Support for device tree")
Signed-off-by: Marek Szyprowski 
---
Hi!

This issue was there from the beggining of the device tree
support, I'm really surprised that it has not been noticed it till
now. This patch fixes the following hard-to-debug kernel issue:

Unable to handle kernel paging request at virtual address ff80090fb018
Mem abort info:
  Exception class = DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
Data abort info:
  ISV = 0, ISS = 0x0007
  CM = 0, WnR = 0
swapper pgtable: 4k pages, 39-bit VAs, pgd = ff80097f9000
[ff80090fb018] *pgd=0008e003, *pud=0008e003, 
*pmd=0008b003, *pte=
Internal error: Oops: 9607 [#1] PREEMPT SMP
Modules linked in:
CPU: 7 PID: 102 Comm: kworker/7:1 Tainted: G S  4.14.0-rc1+ #4572
Hardware name: Samsung DREAMLTE EUR rev10 board based on EXYNOS8895 (DT)
Workqueue: events deferred_probe_work_func
task: ffc87a7f1b00 task.stack: ff8009b88000
PC is at __of_match_node+0x24/0x7c
LR is at of_match_node+0x38/0x5c
pc : [] lr : [] pstate: a1c5
sp : ff8009b8bba0
x29: ff8009b8bba0 x28: ffc87ff8fc00
x27: ff80095c7000 x26: ff80096e76e0
x25: ff8008f1e7a0 x24: ff800965d000
x23: ff800977d008 x22: 
x21: ffc87ffcd598 x20: 
x19: ff80090fb018 x18: 
x17:  x16: 
x15: 0008 x14: 
x13: 0040 x12: 0038
x11: 0001 x10: 0101010101010101
x9 : 06fefeff01fefeff x8 : 7f7f7f7f7f7f7f7f
x7 : 2f2f2f2f382f3030 x6 : 4354571454455d5d
x5 : 5d5d455414575443 x4 : ff8009b8c000
x3 : ff8009b88000 x2 : 
x1 : ffc87ffcd598 x0 : ff80090fb018
Process kworker/7:1 (pid: 102, stack limit = 0xff8009b88000)
Call trace:
Exception stack(0xff8009b8ba60 to 0xff8009b8bba0)
ba60: ff80090fb018 ffc87ffcd598  ff8009b88000
ba80: ff8009b8c000 5d5d455414575443 4354571454455d5d 2f2f2f2f382f3030
baa0: 7f7f7f7f7f7f7f7f 06fefeff01fefeff 0101010101010101 0001
bac0: 0038 0040  0008
bae0:    ff80090fb018
bb00:  ffc87ffcd598  ff800977d008
bb20: ff800965d000 ff8008f1e7a0 ff80096e76e0 ff80095c7000
bb40: ffc87ff8fc00 ff8009b8bba0 ff800871acfc ff8009b8bba0
bb60: ff800871ac6c a1c5 ffc8 ff800871acec
bb80:  ff800871acec ff8009b8bba0 ff800871ac6c
[] __of_match_node+0x24/0x7c
[] of_match_node+0x38/0x5c
[] of_match_device+0x18/0x28
[] platform_match+0x4c/0xc8
[] __device_attach_driver+0x3c/0x138
[] bus_for_each_drv+0x54/0x94
[] __device_attach+0xc4/0x154
[] device_initial_probe+0x10/0x18
[] bus_probe_device+0x90/0x98
[] deferred_probe_work_func+0x64/0x18c
[] process_one_work+0x150/0x3dc
[] worker_thread+0x58/0x3b8
[] kthread+0x104/0x130
[] ret_from_fork+0x10/0x20
Code: aa0103f5 b40002a0 52800014 d2800016 (39400264)
---[ end trace 4a748776163027e1 ]---

I'm not sure however if it makes sense to add the above kernel log to the
commit message as it doesn't directly point to the code fixed by this patch.

Best regards
Marek Szyprowski
Samsung R&D Institute Poland
---
 drivers/iommu/exynos-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index d90cc9f2dd9c..1a7e8c2c89ea 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -740,7 +740,7 @@ static const struct dev_pm_ops sysmmu_pm_ops = {
pm_runtime_force_resume)
 };
 
-static const struct of_device_id sysmmu_of_match[] __initconst = {
+static const struct of_device_id sysmmu_of_match[] = {
{ .compatible   = "samsung,exynos-sysmmu", },
{ },
 };
-- 
2.14.2

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH] iommu/exynos: Remove initconst attribute to avoid potential kernel oops

2017-10-09 Thread Krzysztof Kozlowski
On Mon, Oct 9, 2017 at 1:40 PM, Marek Szyprowski
 wrote:
> Exynos SYSMMU registers standard platform device with sysmmu_of_match
> table, what means that this table is accessed every time a new platform
> device is registered in a system. This might happen also after the boot,
> so the table must not be attributed as initconst to avoid potential kernel
> oops caused by access to freed memory.
>
> Fixes: 6b21a5db3642 ("iommu/exynos: Support for device tree")
> Signed-off-by: Marek Szyprowski 
> ---
> Hi!
>
> This issue was there from the beggining of the device tree
> support, I'm really surprised that it has not been noticed it till
> now. This patch fixes the following hard-to-debug kernel issue:
>
> Unable to handle kernel paging request at virtual address ff80090fb018
> Mem abort info:
>   Exception class = DABT (current EL), IL = 32 bits
>   SET = 0, FnV = 0
>   EA = 0, S1PTW = 0
> Data abort info:
>   ISV = 0, ISS = 0x0007
>   CM = 0, WnR = 0
> swapper pgtable: 4k pages, 39-bit VAs, pgd = ff80097f9000
> [ff80090fb018] *pgd=0008e003, *pud=0008e003, 
> *pmd=0008b003, *pte=
> Internal error: Oops: 9607 [#1] PREEMPT SMP
> Modules linked in:
> CPU: 7 PID: 102 Comm: kworker/7:1 Tainted: G S  4.14.0-rc1+ #4572
> Hardware name: Samsung DREAMLTE EUR rev10 board based on EXYNOS8895 (DT)
> Workqueue: events deferred_probe_work_func
> task: ffc87a7f1b00 task.stack: ff8009b88000
> PC is at __of_match_node+0x24/0x7c
> LR is at of_match_node+0x38/0x5c
> pc : [] lr : [] pstate: a1c5
> sp : ff8009b8bba0
> x29: ff8009b8bba0 x28: ffc87ff8fc00
> x27: ff80095c7000 x26: ff80096e76e0
> x25: ff8008f1e7a0 x24: ff800965d000
> x23: ff800977d008 x22: 
> x21: ffc87ffcd598 x20: 
> x19: ff80090fb018 x18: 
> x17:  x16: 
> x15: 0008 x14: 
> x13: 0040 x12: 0038
> x11: 0001 x10: 0101010101010101
> x9 : 06fefeff01fefeff x8 : 7f7f7f7f7f7f7f7f
> x7 : 2f2f2f2f382f3030 x6 : 4354571454455d5d
> x5 : 5d5d455414575443 x4 : ff8009b8c000
> x3 : ff8009b88000 x2 : 
> x1 : ffc87ffcd598 x0 : ff80090fb018
> Process kworker/7:1 (pid: 102, stack limit = 0xff8009b88000)
> Call trace:
> Exception stack(0xff8009b8ba60 to 0xff8009b8bba0)
> ba60: ff80090fb018 ffc87ffcd598  ff8009b88000
> ba80: ff8009b8c000 5d5d455414575443 4354571454455d5d 2f2f2f2f382f3030
> baa0: 7f7f7f7f7f7f7f7f 06fefeff01fefeff 0101010101010101 0001
> bac0: 0038 0040  0008
> bae0:    ff80090fb018
> bb00:  ffc87ffcd598  ff800977d008
> bb20: ff800965d000 ff8008f1e7a0 ff80096e76e0 ff80095c7000
> bb40: ffc87ff8fc00 ff8009b8bba0 ff800871acfc ff8009b8bba0
> bb60: ff800871ac6c a1c5 ffc8 ff800871acec
> bb80:  ff800871acec ff8009b8bba0 ff800871ac6c
> [] __of_match_node+0x24/0x7c
> [] of_match_node+0x38/0x5c
> [] of_match_device+0x18/0x28
> [] platform_match+0x4c/0xc8
> [] __device_attach_driver+0x3c/0x138
> [] bus_for_each_drv+0x54/0x94
> [] __device_attach+0xc4/0x154
> [] device_initial_probe+0x10/0x18
> [] bus_probe_device+0x90/0x98
> [] deferred_probe_work_func+0x64/0x18c
> [] process_one_work+0x150/0x3dc
> [] worker_thread+0x58/0x3b8
> [] kthread+0x104/0x130
> [] ret_from_fork+0x10/0x20
> Code: aa0103f5 b40002a0 52800014 d2800016 (39400264)
> ---[ end trace 4a748776163027e1 ]---
>
> I'm not sure however if it makes sense to add the above kernel log to the
> commit message as it doesn't directly point to the code fixed by this patch.
>
> Best regards
> Marek Szyprowski
> Samsung R&D Institute Poland
> ---
>  drivers/iommu/exynos-iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Krzysztof Kozlowski 

Best regards,
Krzysztof
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH] iommu/exynos: Remove initconst attribute to avoid potential kernel oops

2017-10-10 Thread Joerg Roedel
On Mon, Oct 09, 2017 at 01:40:23PM +0200, Marek Szyprowski wrote:
> Exynos SYSMMU registers standard platform device with sysmmu_of_match
> table, what means that this table is accessed every time a new platform
> device is registered in a system. This might happen also after the boot,
> so the table must not be attributed as initconst to avoid potential kernel
> oops caused by access to freed memory.
> 
> Fixes: 6b21a5db3642 ("iommu/exynos: Support for device tree")
> Signed-off-by: Marek Szyprowski 

Applied, thanks.

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH] iommu/exynos: Remove initconst attribute to avoid potential kernel oops

2017-10-10 Thread Marek Szyprowski

Hi Joerg,

On 2017-10-10 14:13, Joerg Roedel wrote:

On Mon, Oct 09, 2017 at 01:40:23PM +0200, Marek Szyprowski wrote:

Exynos SYSMMU registers standard platform device with sysmmu_of_match
table, what means that this table is accessed every time a new platform
device is registered in a system. This might happen also after the boot,
so the table must not be attributed as initconst to avoid potential kernel
oops caused by access to freed memory.

Fixes: 6b21a5db3642 ("iommu/exynos: Support for device tree")
Signed-off-by: Marek Szyprowski 

Applied, thanks.


Could you also apply it to v4.14-fixes, or is it too late for that?

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH] iommu/exynos: Remove initconst attribute to avoid potential kernel oops

2017-10-11 Thread Joerg Roedel
On Wed, Oct 11, 2017 at 07:49:05AM +0200, Marek Szyprowski wrote:
> Could you also apply it to v4.14-fixes, or is it too late for that?

Well, I already pushed it out, but I guess I can still move the patch to
another branch.


Joerg
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu