Message ID | 12-v5-cd1be8dd9c71+3fa-smmuv3_newapi_p1_jgg@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 5AD4DC4829E for <linux-arm-kernel@archiver.kernel.org>; Tue, 6 Feb 2024 15:13:34 +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=HT0cZSWcRzyi+FgSgRDSjYz6TKM9vI4ouV0mU+GRnv4=; b=sB/xjNk7Ulz/TA hcO3QwKDK6d49FDIyE1RoxOaEiRtwEIFcf8AsIv/WnOFGFSMzkz6F8bJbae75oFk/Ox/xLmMD192r sTSrtiN85w8R9Jwutb1ZFb7gLym43Mhzo4GNXT4VZnSPFC5M7WkDnU5ZLYhPc8uhIeP2dToDLJufb biYhtb2ZD/m+llqScCgYLMyhkSpn5LGJ9jsj/9cJ6jy5TA/dWTtcFYgxX7g1t0IcbGClw7AZ7zkGS LkEwiks6/lepPzkelcEOkJAudAHg4jE94DtVeQNb9QIcS0PrGus3PMZNLUbPblpl396AVVg8ptmdn /liR6vTH2BJZ6h0EMelg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXN8Q-000000081S6-2m0L; Tue, 06 Feb 2024 15:13:18 +0000 Received: from mail-bn8nam12on20601.outbound.protection.outlook.com ([2a01:111:f403:2418::601] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXN8I-000000081Kg-3Wcs for linux-arm-kernel@lists.infradead.org; Tue, 06 Feb 2024 15:13:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ii7rBI9JZiFn/eVJQx9I9EKmYmM+U72sEdt9nMm8DWSlqxmT4Fq/SzIbzwh9f7VCrxdX88renDPUWmrgeSXRStQQr0vBHUQ/OFdFvT37fWdeD0zlrzP4412fYxp1LcalugP2SMSABCsWOBEm8nzn95kklBUNknepXG+CjDQVI4JWkht3f0djMpzwhyVXPtahe3lnwYEb+vM8RFy7rQC6DrYBtz4OcJ7akQCBgJIzxomN/tKiUieLPovxHFHVHdH8viyLzueXQIRoGuJr/zodSvtF0MhidQNFxF/4/XHN23O17MyKCmnscxrU+IBkcgTd3As4mfYh/m8xiPh0E4xNWA== 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=qBx3y/XF/XyoM6h0gRPZSbM2AT00TTHUiueO5GMraww=; b=K+WZsEdT0/5Di/gM1oGvaUGwD414Q3oz9no0FFx4TaoGgJEh/8OhwHI8WkbQnfeT3uM6sUc9a+KgOXZEmh5kkUni4GndKdOOcRIVvH3d00DZUhQatk95WTopAXaGB0mOz/mQBxhoBkiMRZ7tyF9XU5ZJpV5slHnwOPvG86oMbSfgZEtSADBX9OiqarAd3N7I4F1AcoE7yw/vNqMpTECQRFTn6WkTmX97/7GMi0xML9G1/35ERbcakR6GYMhSlq5b4O2SS+/JZm/Qp633eOoa+82X3pxmazC7ODA3Cc1+n13UcKzRHV9KFC18bsm3VJRqfMg03hBN2F3JitZD/SsS5w== 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=qBx3y/XF/XyoM6h0gRPZSbM2AT00TTHUiueO5GMraww=; b=UsCST/33kvO7vfXVtUbhxM+wdaB3ec3uQabtHxFSxWJY9X5V/XNpYm2BB6hY2RlKTu39QaO3k1NmZQZz8WscOFU7ituUh5ZLdgkyYFSbNmuDIAgSdgokD7vo0NE/0DLcfhf7c8dT1ms3CYPw6ha+8cG65Mp0RJ3nayejyvjKyeYyuxjBsbdtEK4gVGpKWimjkKD25UC+qKDf4G7lHH+YcDOGsjqBtY5edD7WLmNMpHWV6cijkuW8yJJRrZWlj1ch1/oh74RPDpV2r3Nt+H9g5fOQ1SRezgXH8RbWmvFftNlhNmcg82WhCMiNzcrA1o642oI3m64pSVedO06YNoqB1A== 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 SJ0PR12MB6733.namprd12.prod.outlook.com (2603:10b6:a03:477::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.16; Tue, 6 Feb 2024 15:13:01 +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.7270.012; Tue, 6 Feb 2024 15:13:01 +0000 From: Jason Gunthorpe <jgg@nvidia.com> To: iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>, linux-arm-kernel@lists.infradead.org, Robin Murphy <robin.murphy@arm.com>, Will Deacon <will@kernel.org> Cc: Lu Baolu <baolu.lu@linux.intel.com>, Jean-Philippe Brucker <jean-philippe@linaro.org>, Joerg Roedel <jroedel@suse.de>, Moritz Fischer <mdf@kernel.org>, Moritz Fischer <moritzf@google.com>, Michael Shavit <mshavit@google.com>, Nicolin Chen <nicolinc@nvidia.com>, patches@lists.linux.dev, Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>, Mostafa Saleh <smostafa@google.com>, Zhangfei Gao <zhangfei.gao@linaro.org> Subject: [PATCH v5 12/17] iommu/arm-smmu-v3: Check that the RID domain is S1 in SVA Date: Tue, 6 Feb 2024 11:12:49 -0400 Message-ID: <12-v5-cd1be8dd9c71+3fa-smmuv3_newapi_p1_jgg@nvidia.com> In-Reply-To: <0-v5-cd1be8dd9c71+3fa-smmuv3_newapi_p1_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR15CA0055.namprd15.prod.outlook.com (2603:10b6:208:237::24) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6733:EE_ X-MS-Office365-Filtering-Correlation-Id: 91cef892-e048-450d-73f5-08dc27261897 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BTtGGSwfb8WUH9FmDvGWN8UH+8kT+mA7q5HOJi43CG5KQ/OvyZoBsl8nc0lLmLDKvZ9shCYIsJDJjpkrPMT9QlB/JFcEgSWuX2ZpYFCv9xhMbfIhp/m4FJq/1/7/cygM7e1JltiZRylRvJYU+U+s5Aa/3af2l0gV3sPNWDC3rV1P1hlhZJyBOL3rahpMSg6q6KZ+zgi/15K7KyLFoGqHflNEydbfyDdRWbiG0gAkLVv+sIxcqI9XG+ztGRQBvcsGxVI+cqc/8Cmr9JczaVza7c9Bbj5don+QMaQ/YJYiECKNL1bwxVVqtIicw5h/Ch8Zl1EbedQXtc1tnFnnE5DBhyogZcyamCOclczLjPB0b1VKoQVeDtqjo19G2KSI83HQ5mmqSKN6pAxsMNaCOL7cNOgeRx4NdV/IyEVIo4/4MnAdiBt3BSPM22b9LU4qDPiHUxkWKeVLDdYKbKV1Kuroa3ZAs0Ne+jDEEb89EvSpV8bkpZ8dpGsBNx3WORA54Zr/gOiifNXsjfwmIHQQZOMzxRxJg1Z3+TZHLYtwT2nIFwwMkpBIVBMgLeykwXalVZ86bLRjwdON2DeVIQnUlN0kqz6FRoJ5aiCu0hUHNFMtGHQ= 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)(39860400002)(366004)(376002)(396003)(136003)(230922051799003)(64100799003)(186009)(1800799012)(451199024)(54906003)(316002)(83380400001)(110136005)(38100700002)(2616005)(6506007)(6666004)(26005)(2906002)(7416002)(6512007)(6486002)(86362001)(5660300002)(966005)(478600001)(8676002)(66946007)(66556008)(4326008)(8936002)(36756003)(66476007)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JvCBl6mkDOzKFH6ZvaW1WEgttHoKI50tBf+x8S1KM2bF/v97M2JR09Qcxz5weOAJlNT9LJJPOXhvjB1EYTtsdBStjB+F66G0L0BvAQ3gEec9/8Vq243i3t1aiet9orPoLB1vHsehHfR4ZxdqCPfvYtWsNbDXuwnhf2dG4RyTDldbXPvb9fQZ0PCyZ0Z6PDupvADCT/V2qkP4N8J0wBVqRgZRI2ss+jDjWLtlUyzntXiFWx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o3fBbVkVhxGh1ItWa9bfh+rGIeVlFBJWpNCiidRi18BJpQrIj5wtcCGEVsHITj2MAC7MVgVnivR4PqRNBeoiBuLALTr1JkkijljFU6CC5XDfoWYIwdi+UNwguMYBVBRZIMgoWt7qVerpdJanlZKhDXg6ci+59mA3e/UWSRZdk2fZdPqaIrmxx+EhmCm9X4UQTqHZtkX/sRBk8xit3MgpQG43bZi7iEKHJpUIE8KYPECAxs41lmQokqqls6DN2bmVu4yVkyFCTBRz0DF431r6UJ+ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91cef892-e048-450d-73f5-08dc27261897 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2024 15:12:55.6007 (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: LrmafPwhvtAhOJRlORlY5196s0/QrJmtMztTIlW/+wAOPNIltkI8OAZd0+HKEEoG X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6733 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240206_071310_941550_19E06273 X-CRM114-Status: GOOD ( 13.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
[v5,01/17] iommu/arm-smmu-v3: Make STE programming independent of the callers
|
expand
|
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..540f524ecf018b 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(domain); + if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1) + return -ENODEV; if (!master || !master->sva_enabled) return -ENODEV;
The SVA code only works if the RID domain is a S1 domain and has already installed the cdtable. Originally the check for this was in arm_smmu_sva_bind() but when the op was removed the test didn't get copied over to the new arm_smmu_sva_set_dev_pasid(). Without the test wrong usage usually will hit a WARN_ON() in arm_smmu_write_ctx_desc() due to a missing ctx table. However, the next patches wil change things so that an IDENTITY domain is not a struct arm_smmu_domain and this will get into memory corruption if the struct is wrongly casted. Fail in arm_smmu_sva_set_dev_pasid() if the STE does not have a S1, which is a proxy for the STE having a pointer to the CD table. Write it in a way that will be compatible with the next patches. Fixes: 386fa64fd52b ("arm-smmu-v3/sva: Add SVA domain support") Reported-by: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com> Closes: https://lore.kernel.org/linux-iommu/2a828e481416405fb3a4cceb9e075a59@huawei.com/ Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)