From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63B1D28EE for ; Mon, 2 Jan 2023 11:29:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC26CC433EF; Mon, 2 Jan 2023 11:29:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672658980; bh=8UzLM8lk4JXvM4Q8xVHemJEOKdJIpQYeSnpkKm/eAzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wf2tVXtGZiktiO/R/UFZaErh/Q9vUOISuQMdaiQjUEmo3F70ZYgog8YzO1X/pniEB H+wPUXf61t1cKhRf2cKR0zChdGvFGASacJ+Zwe8+0ybK9TGz/duNaaaCU8rmtIjsG3 3EyUWnKEGDN1O1PCez02Q/rWVGBJPYLWAGGWwbNI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ricardo Ribalda , AngeloGioacchino Del Regno , Robin Murphy , Joerg Roedel , Sasha Levin Subject: [PATCH 6.0 40/74] iommu/mediatek: Fix crash on isr after kexec() Date: Mon, 2 Jan 2023 12:22:13 +0100 Message-Id: <20230102110553.814296693@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230102110552.061937047@linuxfoundation.org> References: <20230102110552.061937047@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Ricardo Ribalda [ Upstream commit 00ef8885a945c37551547d8ac8361cacd20c4e42 ] If the system is rebooted via isr(), the IRQ handler might be triggered 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 Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Robin Murphy Link: https://lore.kernel.org/r/20221125-mtk-iommu-v2-0-e168dff7d43e@chromium.org [ joro: Fixed spelling in commit message ] Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- 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 ec73720e239b..15fa380b1f84 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -452,7 +452,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, -- 2.35.1