Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3975936pxb; Tue, 25 Jan 2022 00:26:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZIgCtL7ZQzKE0MJowy8ploD4B8ZI2ojV2t7OF+G78h7L23XDvqcJYalvIy3Nqcpz5FHuV X-Received: by 2002:a05:6402:408:: with SMTP id q8mr18993610edv.254.1643099173937; Tue, 25 Jan 2022 00:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099173; cv=none; d=google.com; s=arc-20160816; b=J836UvdbhXAVfN/UrJRP3wykZM9XpZDNh49qEnZmSrxVlga/pybVPxBoR/N6j62GKy M11HF37K4X6hGkP1JPGp7kLa2k5CnFp006toEOdHHHn7sJxG8pWvmCriVCtxQ8l9jjxQ zXOC9SMMQXbPJ7NJj8Jtk6HYc2SDiU/XRSDM2fWntk++7x4TdJnTZTpzYh4ISpbB1LqQ I5J/gXoDmk9JmUfyEvFQd5UHQdIqcwavNPTYvTonOx106GlQkxMgC16T7tl7/EkrUIug bQURoDQOZ/O4P1gpe9+N+MdM1BuSZU689svUN7Wn9y7OBlIfwhGeaEAAzFRzyRyfVAZF XTzA== 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=atqa1Fp1SGKlGdAMyk7diulRMip1qbw+9tWd453rYck=; b=saHb7ItxB9LYWo/9Gj3GR3Y1QnKzR2Ry3zrjIYpI0MnHZ1hmwr7tI0lUzcUfWPaXCC zVgw46CJetPcaH16/zBEa7Ijx+JUNSo+bVN9w0W53F09z5VNLqt5eCe5lLNP0JYqo6LM HWhsGXSBxv0SpvzXpyPrwOY8sk5ejWcWiq3WLTGPDD6sSHn/iVvLWCgZZepqqLPtb0fe +74kW59l8wE3APwruBVjMUIXhfcE+Ritp2eP1IhVT6H+33Zha2gm3bAI6J48hQoAVDe5 1RNtNdhmBseCYJrvWpZMSGW4iyMFbZN1gdshsHSM7LU/f6InCJRsOrfZ/VU0iJ8e2w+T 8aXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j2wXPH85; 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 u25si9601574edd.329.2022.01.25.00.25.48; Tue, 25 Jan 2022 00:26:13 -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=j2wXPH85; 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 S3421826AbiAYC3E (ORCPT + 99 others); Mon, 24 Jan 2022 21:29:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378673AbiAXUIS (ORCPT ); Mon, 24 Jan 2022 15:08:18 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 237E6C06E008; Mon, 24 Jan 2022 11:32:49 -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 ams.source.kernel.org (Postfix) with ESMTPS id D31C3B8123F; Mon, 24 Jan 2022 19:32:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5B0AC340E5; Mon, 24 Jan 2022 19:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052766; bh=Gb94Y9YdDnwpA1Wh+iUdsiCmxH8BNG5gik8azrh+w1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j2wXPH8583Oy+VUK88KQa8dd4S91TzXeDwhzaInji46X68HEXRXvgLbvkngNRlQ8M PB/umJlRJjbeIL+hcS+ONRBLvCJj+f1FRMufuqw5KRemY5xGn/BHhe/joTVmCYmrRb J2Z/kRHVnPmtjNyRqiOM7MRFxoDUgye7xB5xqgF8= 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.4 134/320] iommu/io-pgtable-arm: Fix table descriptor paddr formatting Date: Mon, 24 Jan 2022 19:41:58 +0100 Message-Id: <20220124183958.221993907@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 ca51036aa53c7..975237ca03267 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -351,11 +351,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; @@ -406,7 +407,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)) { @@ -575,7 +576,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