From patchwork Fri Jan 26 18:15:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13533239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 639BDC47422 for ; Fri, 26 Jan 2024 19:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ViGx5YDfrJOMOG7FQ+7BSNoDoE2vGzoWfR+ECVN8q3A=; b=3bpYkm9OX73ykL qTOtahF0x74eMoBm9C2JrQkaPR0guK1wMaE4K9fqoUYgws3FmPruEUyvPFYeuh7CVVtgQiGj38BL/ GFtboFpoeFO+hKvJjz2GMQijNDUhDbPS4bAR/knqjYXiyaZC3iXS4IUPNpuRVZ5EuP9QXWoKSV0Od ABI14wVVHF0nvPplXA5YSIJWAbnF5JQGZpN8OeVLBxWr0xVKq63K+L3so/FWPWjQMkrljNAZ9ymOb XSl2lE17+M18wJIvrxGDMWWNuLJ6dXE4/SuMrZF7eNCSO1aiRR+J3d+RQp6mCF55tlJE7TuY3avOJ MwR6bvqBTbQcJltb6bKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTRk8-00000005Bzl-2x5c; Fri, 26 Jan 2024 19:20:00 +0000 Received: from mail-bn7nam10on20601.outbound.protection.outlook.com ([2a01:111:f403:2009::601] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTQk6-000000051UQ-32jt for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2024 18:16:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UOwuUZkaaRrQYgaqaucKNhs8NhLguMeBSdgt6sztEvwPWG/o9wCakh6pklsm3JxvbzsET8WOFfXm1qgKDDaK6zX0ixhJA+tAa+lB2ovNaJyTX8Z8FYKztd1a2VR439xvejIGOdQNRCcypRyTu8UUN/g2C0X4jqMaeXTe/YVUErfpkhbu70eMVP3GbAZHBAF1cxfy163midzxEpHPXymuwPXqh1hGiV2kuNrwF7gx4qOJts8V/ABl+4xfLbWsPAqfCKf4efUzNCUfLwmCyrpoC/eqSY8JfjkWjxV39KwxAE9QC1SQcjhA1T9zRY6trNm9ZqDa0jU0tKvoY1XdpdtTPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RG+E+V9Cw7653vTWJJ8EHj5QXr8LZWLPCvwRN0xt32c=; b=ESTrA7i4H5bZGKYtUgvaxe+JuGqdix1ue3Ux6LE5Lq07P2qQUo3tRyTm5XTYCnM2PR4WijfgE8ZuSZ1nLv8pTm5dvHMm78sb0X5k7lsq9hu4LB+f4NzfShoJQK65xsGoo7jsBWyNuZBDhHiBg+EkKohQxu7hNcwppuoIywhwnqONdbRu6R/9/wwYELVaWstRu3ndOCR2elNTkT/RcjKLkelzqVZ5IUOvZRNT5bfUXEVW2ZFajzlbTtwxGh8kxqVodNtem0CzjQVnUb1mdwoajYF3YHrfPykilG6N/zgoJobgjEgAB7fq4hOU2ilM4BUjTuwRtmcR3QQilZHBp6P+9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RG+E+V9Cw7653vTWJJ8EHj5QXr8LZWLPCvwRN0xt32c=; b=gx3eAx+anld4uWd5udgHNvAiLYsNZuZhSmh6wMHmfJny06QtDRhQ5tAzZDrpv2QYDEtlK1c80gqky1G0NHiKkohiPJBjGMd21lTDgKgDctVXt46AZRlhhh74Qvi0DKSEdFGQZdlifJ1b/HqWXhalFq81j1K/6kjXnEwHm0MNGw1y2Lsaez9vTNyQImI4TSZ2GNOwJubvMjM7x5SHPSIGSJaXeHfuLDcOG1q4QAMDp/sJYvssQR5fSePOrkBrm2rBRea7/pNPTl/1JO2IWOst5LzMEJy9gEi+rHdPFriaZGHB7eVPH6MmjBtK119tlc1xAhZlokvSOwZxU1wOL2OqLg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by PH7PR12MB7185.namprd12.prod.outlook.com (2603:10b6:510:201::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.29; Fri, 26 Jan 2024 18:15:38 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873%6]) with mapi id 15.20.7228.022; Fri, 26 Jan 2024 18:15:38 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Eric Auger , Jean-Philippe Brucker , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameerali Kolothum Thodi Subject: [PATCH v4 01/27] iommu/arm-smmu-v3: Check that the RID domain is S1 in SVA Date: Fri, 26 Jan 2024 14:15:03 -0400 Message-ID: <1-v4-e7091cdd9e8d+43b1-smmuv3_newapi_p2_jgg@nvidia.com> In-Reply-To: <0-v4-e7091cdd9e8d+43b1-smmuv3_newapi_p2_jgg@nvidia.com> References: X-ClientProxiedBy: SA1PR03CA0008.namprd03.prod.outlook.com (2603:10b6:806:2d3::7) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|PH7PR12MB7185:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d4b8b71-d714-4598-0545-08dc1e9ac92f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CdmfPJX1h86R7SfLO5gtY/+njwZG4llxsk1ndGxelNb049SiyuVs+P1JtvwqSPdMP1uyO++/3IwRnqn2F4BDUZoZop+MJE+tt2gWEmjTqkJcHo8Yz/9kkapiZK291+dPU6FHCTwzOlGSIDS9DTKVKOCPNLu23s2kmVB81Tgkqa1F2XUFqcBHz2NPldkhQv7PUn7XKyor9Rn3/g7B6hmZbOmaHhIiUNwgqWjThRUMZ+d1x+ZbA+a+E1SZNmi4kZ7EoIn2b5ufPZ8/j+WOuUtady9959b46FodX0ARATUkkbHgAmkHePfrjaKTILcFHJKejD81nZZflLoW1eT9rrdVOqhqc/aLzLL1nFLBwx9AzlzqLk+WIcmbbbzGAcMyrEnnCLRGGW0Edke08gJGV1y/bavw2zsdLPlceT54Cx2/N2RxGlzvrVGW7tIbVMReSe96sqqQARtt8IkNb9ioIf/xQJQW4t5+XybJAgmfECP7HiPwly17z0QeX+NY2Jt93PCXKnZy10MQyKu2aISh001N7kWYvSD3D+vmWuecEqYQm7Z5EyjTZobYD8EeewBkwISneV3OigJN7gTA6YQKRX1EWMzHl0hYI9Ui93cAA050tD4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(396003)(39860400002)(376002)(136003)(366004)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(8676002)(5660300002)(66946007)(316002)(66476007)(478600001)(110136005)(54906003)(26005)(6486002)(6512007)(6666004)(2906002)(8936002)(7416002)(2616005)(66556008)(4326008)(6506007)(36756003)(38100700002)(83380400001)(41300700001)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TeN8skbQo9kuBMP8ZqxxFXTV80EEmmqVqVI2nOrw4+Yoq+i7cAVvLi0kshNiB/OguK1+4ZkT0sEGmbKxmKQWYXNjMc4f6yVU+sMMWcJHv7dHmRbF1RgNLJjbQmj/w0y0jb2A9GTFUwwojeqYfw/4JRx3MHI51OKl67++SlKHJ1m+Y3HAHtuD8b/0bM+B+2TojRpcQ07zUzMp+YRivsDUUuGUGgO5sVUYuyUt/1BUJXTMwI9xWdSBqgG6zZ48nr7EumZcR4Y6ZRDt79TE449rGyuATnJc7tsGd9N82ZP4OTlMdVOxO9if8k9qybt4nuRNeUs8Yv8WyCjNWHpNrjfk9wWfy5fi73YjeYcx9C4qRAAYGCbVc0AY5zzqKXj2toCkGzBsufpllX8IO+Xa9YAswLK8dvz5NiLbuoDgtFwTfUJWsKtyhm0V1cxHqqrZQsJsjt70F4RA3wGhYJ8hQw5kb2bC7rD1Tpwx0vIH18RbMNadyNvXc8a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X8dxW0m3KFf7dFghdKayRd4nPbRhNgp5C X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d4b8b71-d714-4598-0545-08dc1e9ac92f X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 18:15:32.9584 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ixlxdMhezFAFN/RKcBWtOqezBnD13AMIwm9YDlS5Qf8WADB4OyIkNELfXPV2wVUc X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7185 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_101554_890785_09290854 X-CRM114-Status: GOOD ( 10.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This code only works if the RID domain is a S1 domain and has already installed the cdtable. Reviewed-by: Nicolin Chen Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index 05722121f00e70..b4549d698f3569 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -387,7 +387,13 @@ static int __arm_smmu_sva_bind(struct device *dev, struct mm_struct *mm) struct arm_smmu_bond *bond; struct arm_smmu_master *master = dev_iommu_priv_get(dev); struct iommu_domain *domain = iommu_get_domain_for_dev(dev); - struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); + struct arm_smmu_domain *smmu_domain; + + if (!(domain->type & __IOMMU_DOMAIN_PAGING)) + return -ENODEV; + smmu_domain = to_smmu_domain(iommu_get_domain_for_dev(dev)); + if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1) + return -ENODEV; if (!master || !master->sva_enabled) return -ENODEV;