Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3642841pxb; Mon, 24 Jan 2022 14:14:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQbpBHvKHDtanTd/QmrSaOmXz26hgwy6268CaxHwb8sjXCbRJYbEQUMHtYhBwgHW6XHGmL X-Received: by 2002:a17:903:22c4:b0:14b:4035:e166 with SMTP id y4-20020a17090322c400b0014b4035e166mr9177636plg.144.1643062454482; Mon, 24 Jan 2022 14:14:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643062454; cv=none; d=google.com; s=arc-20160816; b=cJhk9nMW4RJJ0HUE/NW9OXlSYFVLKhgpS3Jk8yXInd3MDfgsYu/Hqau4xjjh2WC1hB 8fpICyhCmpM0qn6YiW9gPyqL/ZRqhcf5CtSPmotZCyIB+HyiQftSUZgr8S5JL7PzN+0T A+TyAdbX849m4LkScQc93MntX5GLPI/48I7Rvdk/2VgG/J5YgPO3KgFv8Xwxble+3dfV BIZt85ol4H9lSWPJhyc/LUpCOPwDf2zaSgYKw0zNU5z/Pv4pGC/nI931wlI9dovaIb7V hXfFR3FPaRljSMU1pu1oK4gUxW8J1u6LqPtXF3F0wtujA5Ow50BQfhMT+p8ExcBgowOX xzUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ggw4svMbO9kUa2uo3Hp8rRHL+r1HFj+fRL2Viv1tINg=; b=pFc5Iy2ATXXeACIZLRZQZl/zjUnQ4r944yY1MzPFJ0HLZKajUVlqb3Yj5HF89rjN4T qX0Ijv7H0SL/8G5xnfMqDd2pUveBsFTkkTeTCGiJ3i8GS2v8hBH+kvva0D8SXhin4cvF 5egKj0V+Q/JfMzq2PaHYy6eUMsy/8wr6RqAcukqC1VEzBnGMOlmoDLLP/8O9wBFsX2U5 rR8FFIFCGCGwC4mX1db2N4tCJTBBzoJYSZ8LqkPHeB/UqDxhITaww1s+NV4lk/o+wgnz dpZ4Rv6prhb68RvFHr6jh9EmKLsOTUtS4hcn8uGRd3Ld/26I21LOU2gtO9BPHRlSWAu8 ZPMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mLa9tCdH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si16495858pfc.28.2022.01.24.14.14.02; Mon, 24 Jan 2022 14:14:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mLa9tCdH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1449358AbiAXWD1 (ORCPT + 99 others); Mon, 24 Jan 2022 17:03:27 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:37392 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377231AbiAXVRu (ORCPT ); Mon, 24 Jan 2022 16:17:50 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D9BFFB81188; Mon, 24 Jan 2022 21:17:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0571AC340E4; Mon, 24 Jan 2022 21:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059066; bh=eXld64SAj0/uBme7zFW+YGIPcTAU5bs5ccJa8NjUrcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mLa9tCdHORe/pKLsgK4jEF02WRtUT1M6we7t/VRZxarZAIiCsH23KxO8dmIxZFyUw i9AUzFpI6HPMcLTJ1PkxXHv5S1Am45jvACsrUKNqP8xYm1ledgASo12ANZUzdf9R0i ZJR99UJKfDpCAwb9HFuSe1mwq1Cukr07WM08/Cqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robin Murphy , Hector Martin , Joerg Roedel , Sasha Levin Subject: [PATCH 5.16 0476/1039] iommu/io-pgtable-arm: Fix table descriptor paddr formatting Date: Mon, 24 Jan 2022 19:37:45 +0100 Message-Id: <20220124184141.276711853@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hector Martin [ Upstream commit 9abe2ac834851a7d0b0756e295cf7a292c45ca53 ] Table descriptors were being installed without properly formatting the address using paddr_to_iopte, which does not match up with the iopte_deref in __arm_lpae_map. This is incorrect for the LPAE pte format, as it does not handle the high bits properly. This was found on Apple T6000 DARTs, which require a new pte format (different shift); adding support for that to paddr_to_iopte/iopte_to_paddr caused it to break badly, as even <48-bit addresses would end up incorrect in that case. Fixes: 6c89928ff7a0 ("iommu/io-pgtable-arm: Support 52-bit physical address") Acked-by: Robin Murphy Signed-off-by: Hector Martin Link: https://lore.kernel.org/r/20211120031343.88034-1-marcan@marcan.st Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/io-pgtable-arm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index dd9e47189d0d9..94ff319ae8acc 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -315,11 +315,12 @@ static int arm_lpae_init_pte(struct arm_lpae_io_pgtable *data, static arm_lpae_iopte arm_lpae_install_table(arm_lpae_iopte *table, arm_lpae_iopte *ptep, arm_lpae_iopte curr, - struct io_pgtable_cfg *cfg) + struct arm_lpae_io_pgtable *data) { arm_lpae_iopte old, new; + struct io_pgtable_cfg *cfg = &data->iop.cfg; - new = __pa(table) | ARM_LPAE_PTE_TYPE_TABLE; + new = paddr_to_iopte(__pa(table), data) | ARM_LPAE_PTE_TYPE_TABLE; if (cfg->quirks & IO_PGTABLE_QUIRK_ARM_NS) new |= ARM_LPAE_PTE_NSTABLE; @@ -380,7 +381,7 @@ static int __arm_lpae_map(struct arm_lpae_io_pgtable *data, unsigned long iova, if (!cptep) return -ENOMEM; - pte = arm_lpae_install_table(cptep, ptep, 0, cfg); + pte = arm_lpae_install_table(cptep, ptep, 0, data); if (pte) __arm_lpae_free_pages(cptep, tblsz, cfg); } else if (!cfg->coherent_walk && !(pte & ARM_LPAE_PTE_SW_SYNC)) { @@ -592,7 +593,7 @@ static size_t arm_lpae_split_blk_unmap(struct arm_lpae_io_pgtable *data, __arm_lpae_init_pte(data, blk_paddr, pte, lvl, 1, &tablep[i]); } - pte = arm_lpae_install_table(tablep, ptep, blk_pte, cfg); + pte = arm_lpae_install_table(tablep, ptep, blk_pte, data); if (pte != blk_pte) { __arm_lpae_free_pages(tablep, tablesz, cfg); /* -- 2.34.1