From patchwork Wed Mar 27 18:07:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13607324 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 A8DF3C54E67 for ; Wed, 27 Mar 2024 19:18:24 +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=ywewusmc0LK+r9YbqYwra4i5ft8TRmlT3UcTzwPoyTU=; b=YZgfD/CcUvy3Gf 6l6eNTBhNaCUrhAXBJGMDWSPIW+OeN5t+sEbjhTVBCgoNnVwoLHp876KZtHZLVs5c3uWx/JC/mG6A EqQmXJXUWRZZfjsu/rpaaAuF9QqUYcoMsz7avbzMBHnajp2CYpipGiuL1f6ASYOAWcmsHx9hG1yg4 Z0SvDpXYhdOIWZ9nU6UrUOFxiBHOb1gzsVyMtSEtIyOSk37RjLAMLAYxfKsj9BI5Ze3ZM3Bh79PPB hT0iihFh16EJaqg58rl39Z7ViuzAddI0G1Z5aqCkgUN3VNoUYJ3jatj0gh2D3VDGRWXNCHQS0pe8A OHMF8UGVgDyB/7F56ADg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpYn2-0000000Akw2-0rdN; Wed, 27 Mar 2024 19:18:24 +0000 Received: from mail-dm6nam10on20604.outbound.protection.outlook.com ([2a01:111:f400:7e88::604] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpXhV-0000000ATY9-2mVi for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 18:08:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xnvh1FLhRnn49a01NqAfug52JiQXfsVPj51foa1z7zDL5eSOH0pblPomijiK42DW03SCrogeids1aPC4bM261weRAHkTq2UI5W89vg0RzUvCIIX0oWWza6i0DCvKCdLFt/cI0u7P91NjiqYOEBeN/RFFplSRkfg5oA8FUWiy4713bB8oT2RoQ6RuNIV7y+kuWNObLb7OYa6nZsQIP5XbnX7K7IbRb/InNW3TQ2B+P//0nY+EWUGEW2FW5OV7qd6jMBrxM2H+doqFJtRJGJ2AXFyPvG9QcpvCP17TLlmBfR/cylvOjlwD05qFfDAa+e6TmPOflQtNwRAaeIiHPw9+0w== 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=EYplJVT6i2QO8Qki5MFmA2QlS4i7sXa+pl68wMcz9v4=; b=PactBvjsMJHLVMEekzPy+YxeYAc6P4pyrRxGoc72vxv4KiXOESCPGmluIhvD1CU94AlcTs+H5W1AC2vr7YQq/q61AaWfGe3qZPzMdXrWuHz0FyladTwghH+LSBipeQXosAFf9CrDPCAKMqtjjsxk93l8kK7cWaq+aRSvzF9rREIJcKWDxkeNHCu/f+5FwXnPokV90eIJ0VCIzUKoB80jwMRmLSPEuJwodKGn9CFzyPViGKdeg7HCCfWqqTWpmseXEJ4DexO+pxDPILZmiidlXeFiP5nlSsGyPXswxXS1Fca/us1/3/emp7uIIxD7+AUow+A8W4cca1rvbm8HcrWHYQ== 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=EYplJVT6i2QO8Qki5MFmA2QlS4i7sXa+pl68wMcz9v4=; b=IdAN5VgsBXYxYGJt/2biJb2/cQJSCAjUIB0cs0Ouqkqv1iHp/p/R0XrQb85TtNWaFAXz9pFEIjJu0v7up+KeB4xU2kByGDLjAaq8YkXcf1/z+bxqP/4qOTSjFLFTPie439kgfiek5xeAyNJDOU195KyLhVRAhb+pPrZKMESPu9tg4W9l4vi44ZesIcN2NDp3da31tf0ocWvvWA+pY82Su1BQ1DoXONVy8OY1J8KWIACCfgkApiVfd1sNy3euGXZ0MV2ZhRUQt5Z7q+z7Em1NwR84eRrrow4Kv9JtU7WCr1wJN9uqEiwvYeXt3nR3xdiCsiVr2IwtWl9SGDqGjs8EwA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by CH0PR12MB8487.namprd12.prod.outlook.com (2603:10b6:610:18c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.32; Wed, 27 Mar 2024 18:08:23 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::6aec:dbca:a593:a222]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::6aec:dbca:a593:a222%5]) with mapi id 15.20.7409.031; Wed, 27 Mar 2024 18:08:23 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Lu Baolu , Eric Auger , Jean-Philippe Brucker , Joerg Roedel , Kevin Tian , kernel test robot , Moritz Fischer , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameer Kolothum , Mostafa Saleh , Tony Zhu , Yi Liu , Zhangfei Gao Subject: [PATCH v6 03/29] iommu/arm-smmu-v3: Do not allow a SVA domain to be set on the wrong PASID Date: Wed, 27 Mar 2024 15:07:49 -0300 Message-ID: <3-v6-228e7adf25eb+4155-smmuv3_newapi_p2_jgg@nvidia.com> In-Reply-To: <0-v6-228e7adf25eb+4155-smmuv3_newapi_p2_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0312.namprd13.prod.outlook.com (2603:10b6:208:2c1::17) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|CH0PR12MB8487:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b05ab97-48a3-45fe-893d-08dc4e88e14a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yS83FIXJw/rNUHZ0fQ6cB5R/E2wyGRo6nKfH5c6iS5LxkH+7bEE7GS43f3RvlhtKMAOag5G84PtQDDzfmRO7no52ol4jSy0KJaN7JPn5r5fsQ8t6ESIUZD6GLC1gz9v0/v8wKz/G1OcnD3GGse1aQLQESYrh15bWKFn2q4DIB1Vbqun8M5ayDuU66x13kCsx3ostOLyn3HiA8C55YgKOSu1jtjz+Kx+oBfwfXN9OOVPfF08NjjhmnznDIQW2ctLWV2q1Si6rNW0of9lto24YFEDqrCgv80ysOf4ijsmUqd5ryMfYLh9i9CqXBAqXcU7Xqkrlrgp0zbNnG3Ke4s8B6jG73YD5XyvD+OroKvsb6CY4Gwri3CBngZYtIDNFMsURyvTFjLJXaNc9PbFk7jNp7dlc2VI57EPaTXkATZFWa1slBywBDmJx+Efe3udY6rn80oYVpBnwgms/RIWQ9RRC+8Abfs7PvcrVUhpv/gusiPX2gDrixrkFVwHvFaCvgJ/OeGDMFschEuN4JPaFIgGSHH/P80AQ/JM9vU0jSFKRDhsmkrNy5OrMRSgazViH/LCPEVjYgSlPlppWZ5TJSqp5rUeThA4HPIRHbcQjZzsbbEoabUkkPsd3nvyVrNECRBFYyVbJt2JX+rNW40Eaek+yHIR4pvoHDgh2frGlfzsj9Ug= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(7416005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I10IeHzrwokqWPwR8pV/AkVxrifCcG/zzKkfbBJOSb7QAclE5tU/T+77qxTiCf+QlNRo4TO5rAzaq7qLSVTv9q4lQJGdea2BFtGxZ6u/H5LJ6fzRs3wLp+pHW/EMrZUH3NqNeo/f4KjT1amCHZ0bxin9x2lk2QlWm1jiDmyoumzdQdvhh5tM0KKnWF9EtqKct03u7DLVqPdph1TsFDsxjMihj2Zmp+34v0s95Lu4/NVU14kt/60Buk2XFCxuoNmfj5OHATr0Nuy5v+X2/gPwgPQMgGspcJADpxt4aN0lQv2Zi136Ddrs5ZiQ3Rp6MfJaw9ojp8688ZF6bZ+98tGoW3P9eCMUgcaeycZP/GMrO4NASyfelnLxglukpZU1Q2SHMsOkoLSPlBHPasBDF+yR/dKJF+GPoi7iGC5dxPkx6NxIIy2jCX9bZKx7IUZGsLvYzo+3nQO7XIS5vlUuumIX9qz6JWSLd4RbQJvzLDQywC/zjSdpV/N3ySYkFaIKwOTSx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wi69FWBK X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b05ab97-48a3-45fe-893d-08dc4e88e14a X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2024 18:08:18.3188 (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: XkFZWYEIma5zz8NaP3JvgZJ8BPxTqJyFVuzTDmqDvrnd3s7J3XDK+XawEVu2kDgk X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8487 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_110837_829196_84F4BD75 X-CRM114-Status: GOOD ( 10.23 ) 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 The SVA code is wired to assume that the SVA is programmed onto the mm->pasid. The current core code always does this, so it is fine. Add a check for clarity. Fixes: 386fa64fd52b ("arm-smmu-v3/sva: Add SVA domain support") Tested-by: Nicolin Chen Tested-by: Shameer Kolothum Reviewed-by: Mostafa Saleh Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 3 +++ 1 file changed, 3 insertions(+) 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 2cd433a9c8a0fa..41b44baef15e80 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 @@ -569,6 +569,9 @@ static int arm_smmu_sva_set_dev_pasid(struct iommu_domain *domain, int ret = 0; struct mm_struct *mm = domain->mm; + if (mm_get_enqcmd_pasid(mm) != id) + return -EINVAL; + mutex_lock(&sva_lock); ret = __arm_smmu_sva_bind(dev, id, mm); mutex_unlock(&sva_lock);