Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3622097pxb; Mon, 24 Jan 2022 13:43:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyA8XFCtEh2MRPlXbhNZKTp4NR9KvqaXAzo+HxPpB3SAMQfI81GtT2Cb8Wvz8IuCtnbP4Gt X-Received: by 2002:a17:902:7ec1:b0:14b:7484:9876 with SMTP id p1-20020a1709027ec100b0014b74849876mr344910plb.90.1643060622117; Mon, 24 Jan 2022 13:43:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060622; cv=none; d=google.com; s=arc-20160816; b=kCxsM2eiON5qDQW1bTI7uOu8Ir+9QDZorRAPUXzfzSu6bRbYr+VCwe3eVmklb4OUl8 zKgMigCk+71a9TgL4n0hUWQJb2ZBGWDpXU1kMSCUMDfL05B5l55LSYxoWhuO/H73ePNu wyMyeFfQhvF7hxJ/p5+jDIj6ckgBmnb5/dejP88ICKsPEjV7se+8Cnju5f3kOan9eZH3 Y5kt1ESVGN6OvFAAKb4ygOLLT6Xcb6lQJdfoK2DoLcThxD0OypTtdgt4cymu9RnByJFW CuZXUOP3JeXyqoXYCBwIKcfhRXEAve3fQu79SyUtuZNljZTuz3QCc8doANgHqV9hpw7y cPpA== 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=zg42cyW4W4M9qnr3Nkt2h6FQdVrGZP4MSCid8olk+as=; b=u3fAdC1XLYZnJwf/A3rnszwoZPclZys752D6Yz9HD8RKH+67vYra4NPY0ZN+7h9L7w OVks9p4dlidJj2jRKU4pTe7b8eU8nBwxewMdKi6Q4O+g5Wf7pj2XObr9PliEPclwpuJz Yc16gqPSjtC2RJYy/uwRAH6ejWP5TrQiuFfnEMhyMGmm7Q1a3TgVdQLFvnbJZvZcIRQy dAHlG0jGDFg861Wm5U705gIlMtPkjLtiIpNbOkxQWuNZmjle9Hlwld2Gg/+Fmp+4FW/V XqC5qokkPteJmhlB25tJlIm5MOMVGM9XAUnCI/vnd7NbdiKcZAkPkBNvN/8PuBQDQdD6 pQnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UDrCgavj; 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 d4si406050pju.141.2022.01.24.13.43.26; Mon, 24 Jan 2022 13:43:42 -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=UDrCgavj; 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 S1452127AbiAXVYG (ORCPT + 99 others); Mon, 24 Jan 2022 16:24:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350425AbiAXU5F (ORCPT ); Mon, 24 Jan 2022 15:57:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2076C110F33; Mon, 24 Jan 2022 11:18:28 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 5191A60918; Mon, 24 Jan 2022 19:18:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31F0CC340E5; Mon, 24 Jan 2022 19:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051907; bh=I5g32WXKgHPSR8SEIEeB0HviWhU+yo4ohTjx1FEUO9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UDrCgavj08fU8wtHvmDBD7op80DCQqCWzr8BQS6w1bFO6J2MGCV6IEHiY3F26rzVD vBuDQLULRdNw3WHi0MD93rSwIodCGZ9l6qijFXTSAMhn00Mw2FWAyuVi0eGi5OgRcj PFVpS1cyPv24M0MTBqOYhzH3GB+rwz66w/4mZC08= 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 4.19 108/239] iommu/io-pgtable-arm: Fix table descriptor paddr formatting Date: Mon, 24 Jan 2022 19:42:26 +0100 Message-Id: <20220124183946.539996444@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@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 2f79efd16a052..4bd2dd70acaec 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -346,11 +346,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; @@ -402,7 +403,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->quirks & IO_PGTABLE_QUIRK_NO_DMA) && @@ -562,7 +563,7 @@ static size_t arm_lpae_split_blk_unmap(struct arm_lpae_io_pgtable *data, __arm_lpae_init_pte(data, blk_paddr, pte, lvl, &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