linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] iommu/mediatek: Fix crash on isr after kexec()
@ 2022-11-28 22:16 Ricardo Ribalda
  2022-11-29 11:48 ` Robin Murphy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ricardo Ribalda @ 2022-11-28 22:16 UTC (permalink / raw)
  To: Joerg Roedel, Matthias Brugger, Yong Wu, Will Deacon,
	Robin Murphy
  Cc: linux-arm-kernel, linux-mediatek, Ricardo Ribalda, iommu,
	linux-kernel

If the system is rebooted via isr(), the IRQ handler might be triggerd
before the domain is initialized. Resulting on an invalid memory access
error.

Fix:
[    0.500930] Unable to handle kernel read from unreadable memory at virtual address 0000000000000070
[    0.501166] Call trace:
[    0.501174]  report_iommu_fault+0x28/0xfc
[    0.501180]  mtk_iommu_isr+0x10c/0x1c0

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
To: Yong Wu <yong.wu@mediatek.com>
To: Joerg Roedel <joro@8bytes.org>
To: Will Deacon <will@kernel.org>
To: Robin Murphy <robin.murphy@arm.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: iommu@lists.linux.dev
Cc: linux-mediatek@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
Changes in v2:
- Also print the error message if !dom (Thanks Yong)
- Link to v1: https://lore.kernel.org/r/20221125-mtk-iommu-v1-0-bb5ecac97a28@chromium.org
---
 drivers/iommu/mtk_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 2ab2ecfe01f8..3d913ab5029c 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -454,7 +454,7 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id)
 		fault_larb = data->plat_data->larbid_remap[fault_larb][sub_comm];
 	}
 
-	if (report_iommu_fault(&dom->domain, bank->parent_dev, fault_iova,
+	if (!dom || report_iommu_fault(&dom->domain, bank->parent_dev, fault_iova,
 			       write ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ)) {
 		dev_err_ratelimited(
 			bank->parent_dev,

---
base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4
change-id: 20221125-mtk-iommu-13023f971298

Best regards,
-- 
Ricardo Ribalda <ribalda@chromium.org>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iommu/mediatek: Fix crash on isr after kexec()
  2022-11-28 22:16 [PATCH v2] iommu/mediatek: Fix crash on isr after kexec() Ricardo Ribalda
@ 2022-11-29 11:48 ` Robin Murphy
  2022-11-29 15:08 ` AngeloGioacchino Del Regno
  2022-12-05 10:55 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2022-11-29 11:48 UTC (permalink / raw)
  To: Ricardo Ribalda, Joerg Roedel, Matthias Brugger, Yong Wu,
	Will Deacon
  Cc: linux-arm-kernel, linux-mediatek, iommu, linux-kernel

On 2022-11-28 22:16, Ricardo Ribalda wrote:
> If the system is rebooted via isr(), the IRQ handler might be triggerd
> before the domain is initialized. Resulting on an invalid memory access
> error.
> 
> Fix:
> [    0.500930] Unable to handle kernel read from unreadable memory at virtual address 0000000000000070
> [    0.501166] Call trace:
> [    0.501174]  report_iommu_fault+0x28/0xfc
> [    0.501180]  mtk_iommu_isr+0x10c/0x1c0

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> To: Yong Wu <yong.wu@mediatek.com>
> To: Joerg Roedel <joro@8bytes.org>
> To: Will Deacon <will@kernel.org>
> To: Robin Murphy <robin.murphy@arm.com>
> To: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: iommu@lists.linux.dev
> Cc: linux-mediatek@lists.infradead.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
> Changes in v2:
> - Also print the error message if !dom (Thanks Yong)
> - Link to v1: https://lore.kernel.org/r/20221125-mtk-iommu-v1-0-bb5ecac97a28@chromium.org
> ---
>   drivers/iommu/mtk_iommu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 2ab2ecfe01f8..3d913ab5029c 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -454,7 +454,7 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id)
>   		fault_larb = data->plat_data->larbid_remap[fault_larb][sub_comm];
>   	}
>   
> -	if (report_iommu_fault(&dom->domain, bank->parent_dev, fault_iova,
> +	if (!dom || report_iommu_fault(&dom->domain, bank->parent_dev, fault_iova,
>   			       write ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ)) {
>   		dev_err_ratelimited(
>   			bank->parent_dev,
> 
> ---
> base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4
> change-id: 20221125-mtk-iommu-13023f971298
> 
> Best regards,

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iommu/mediatek: Fix crash on isr after kexec()
  2022-11-28 22:16 [PATCH v2] iommu/mediatek: Fix crash on isr after kexec() Ricardo Ribalda
  2022-11-29 11:48 ` Robin Murphy
@ 2022-11-29 15:08 ` AngeloGioacchino Del Regno
  2022-12-05 10:55 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-11-29 15:08 UTC (permalink / raw)
  To: Ricardo Ribalda, Joerg Roedel, Matthias Brugger, Yong Wu,
	Will Deacon, Robin Murphy
  Cc: linux-arm-kernel, linux-mediatek, iommu, linux-kernel

Il 28/11/22 23:16, Ricardo Ribalda ha scritto:
> If the system is rebooted via isr(), the IRQ handler might be triggerd
> before the domain is initialized. Resulting on an invalid memory access
> error.
> 
> Fix:
> [    0.500930] Unable to handle kernel read from unreadable memory at virtual address 0000000000000070
> [    0.501166] Call trace:
> [    0.501174]  report_iommu_fault+0x28/0xfc
> [    0.501180]  mtk_iommu_isr+0x10c/0x1c0
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> Reviewed-by: Robin Murphy <robin.murphy@arm.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iommu/mediatek: Fix crash on isr after kexec()
  2022-11-28 22:16 [PATCH v2] iommu/mediatek: Fix crash on isr after kexec() Ricardo Ribalda
  2022-11-29 11:48 ` Robin Murphy
  2022-11-29 15:08 ` AngeloGioacchino Del Regno
@ 2022-12-05 10:55 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2022-12-05 10:55 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Matthias Brugger, Yong Wu, Will Deacon, Robin Murphy,
	linux-arm-kernel, linux-mediatek, iommu, linux-kernel

On Mon, Nov 28, 2022 at 11:16:48PM +0100, Ricardo Ribalda wrote:
> If the system is rebooted via isr(), the IRQ handler might be triggerd
> before the domain is initialized. Resulting on an invalid memory access
> error.
> 
> Fix:
> [    0.500930] Unable to handle kernel read from unreadable memory at virtual address 0000000000000070
> [    0.501166] Call trace:
> [    0.501174]  report_iommu_fault+0x28/0xfc
> [    0.501180]  mtk_iommu_isr+0x10c/0x1c0
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>

Applied with commit-message spelling fix.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-05 10:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-28 22:16 [PATCH v2] iommu/mediatek: Fix crash on isr after kexec() Ricardo Ribalda
2022-11-29 11:48 ` Robin Murphy
2022-11-29 15:08 ` AngeloGioacchino Del Regno
2022-12-05 10:55 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).