From patchwork Tue Oct 22 00:20:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13844931 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 0424AD1714E for ; Tue, 22 Oct 2024 00:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=XSbWpjlywMOQL7nsKHhi2eFpjFX7SWJuA+kw/e8LUbY=; b=WLRFj9urOIM4XmQjfcsSPuHZGR 71NWQoNuseiR/4Ybnd5jWQlfPWbOQzUJLYmt7UOD98rA8rkMnk9aWvrkwoYEsCW6TYurrF2ytP00S v8cH0w7am8dPc3Horr3QZS62pH+0emE5cLHdPoqqgdCWTselY8UK2todEU/EKphEcAJ+XXNzMO7ft /y+554LbGOGUpGKn0CFQ1CLG48NGjv7Y0D6k+K8nRt96BzsMksZGQ11+qoRIYMG2O5SMRmEVCcVe/ x6FgxoJMR5u0axLvMnu7NznB0wG09O5fLkkmbLDtmPpOATHTIp5oMwUFGFHSgfCdHjlYy3V+0zwUm M41xkAqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t332Z-000000096qy-3SaK; Tue, 22 Oct 2024 00:46:27 +0000 Received: from mail-sn1nam02on20607.outbound.protection.outlook.com ([2a01:111:f403:2406::607] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t32ds-000000092SV-450D for linux-arm-kernel@lists.infradead.org; Tue, 22 Oct 2024 00:20:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d/khjHRKoEy3vLYM0V99D6hpDxBoe6b8PLXunzNe+We2sL2RkJAeZKnR4AE+IbTt2muKjwQ5NUAzj/cegMMp3Mo92RDbbfRAcQ1/BUzBvWKDuih3xjQ4XwdJf8wpGFcbtUFzREEpnFG0rzBIh8EMMWrk+StltL5G/gPcRnZYlWe7uiMvrvmTjUTmzE9mOKU6GpBaZuZiw5jlN/HPfeJh5DP23HYVg94qp9gnB7+4bcG/Hhc6OZgGUYKZi+A+Op1OpnC6pCBP52pip/oAL5/MRAiOqDSoXsGnVsCWUyTG/XVbe8DEmrOrqt1K4s+YYg0E8yJF2SBZmKc1jXooI4NhtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=XSbWpjlywMOQL7nsKHhi2eFpjFX7SWJuA+kw/e8LUbY=; b=hHH5pW1CvvDTgg4UNq+2+mxhHftA8qWhaXZtKd+IMlE8/oJNh6MBY7lCRQj0SaMl+UtU3F94ZhDvWndtIEsmewvg9nP4oXZ+h0nMDdEBjEiCh+ndXYVCEZItadPoocsU8qvhgi8QcaorYjOmhgwz4OyKHNzwnsLjBEMyPxJwrHyejpV+KNR/5hsz9qzFQmtQV8DI5keHPMhGMXd+MUpRI95/d2GJOQbr+mRZCMVVy3IRGSRvo8tx569ZcLiv3iBYfuYVqHN/Qk7bjwRVRAnLnEx4rINN6fN98/6RVCGCxP0uwE9yEfJtUvWrRiwkvu4dWc5XsXzExeefAYu96adzWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=amd.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=XSbWpjlywMOQL7nsKHhi2eFpjFX7SWJuA+kw/e8LUbY=; b=YzP6ryzfSRt11VCZOdigzEETMTzvFwGT0DSFQ6/MYMF7eyNP4sJYiFPY4zsajSD5XfJfFt49k4l7Q/3lJpdsCcnZOgjLye57lrJupFe4Eql/JeJKjzBn+UYfCOmrqGvkSc0EkQSkPbXF5lATFpFeiK0aq7BnBDXUVGSdG+W/ZfHiz0ciHQCm/+5QY3ubBms4v4nWCQixARhqQt0UITgTEY171muL0WPJFZIXoM+4Wfp5zHks/mws8VWgp8FGk9tAcoRkikGv9X46ADs90w7hgVOavW2uuVGH+DA4rDlyH11IC0rPi97n5NsytIADHOMZIKLF1Pdb0a74RDBSUzb8mw== Received: from BL1P222CA0027.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::32) by CH2PR12MB4231.namprd12.prod.outlook.com (2603:10b6:610:7d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Tue, 22 Oct 2024 00:20:51 +0000 Received: from BL02EPF0001A101.namprd05.prod.outlook.com (2603:10b6:208:2c7:cafe::82) by BL1P222CA0027.outlook.office365.com (2603:10b6:208:2c7::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 00:20:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL02EPF0001A101.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 00:20:50 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 21 Oct 2024 17:20:35 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 21 Oct 2024 17:20:34 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 21 Oct 2024 17:20:33 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 05/14] iommufd/hw_pagetable: Enforce cache invalidation op on vIOMMU-based hwpt_nested Date: Mon, 21 Oct 2024 17:20:14 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A101:EE_|CH2PR12MB4231:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e1b31bb-5586-43ba-979a-08dcf22f62a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: XtleWZAdQbBFx8GbESclpaYFe0LPxtvVQv2J3ULamReC74jeH5vF8H9fPxDbuA88JCGbTlxTawGu93ymMMrPz53dVN3YyUZMmgp7asHxDVAKu3K9j36jvcQXXYcfCkN71rH3Ouf04vfphwEXY5cJOqK+j1IV2EzKVL0Hbgnqna/p3e7iXQorC04u9CmiHoD83Ee6WaDW099fWjQc7U+/yWvA4EU/uANK+iRY6CcUnNBgTPCJlRG8a9E4MoD2j4ttgFpW2xA/wYrd2R5CfhV2hKTqE7BKIFkwyAv43s1SUYNYlGprdtkuu5y3adWwEsCnSOH6bn9lNvQ5Cg2oflR/oFO/GyL8ovROC33PMQV3zmWU46zKfzgh3RrBKgoSpJ1IyH90mtoCzGR70U/62h4xse1+PRmUYGTlLrxWwYcmFlQwvT+Xj4IXErplpMLPdM7RfH3kIYIBkqFiHeFkot0uvC6LNUPUIhFlScm44vpVNBwU5v8Ow43bBL3u0g51uq6Z7yF0jKM03tgRRcjLHHiMcEJHRkcLJzsuklOK+dLrCF3XVQonWPlvWPfSjG7CwZkLj5hNhup6qZThg2q+6RE4nKNX7haStd/lGpFaXXogzWcfBxsa+qokFAxvF/z8qQrMv0VJuPQWXZQdMiX9nM8uZk4KAH1aZcLSVdHrRZsiAfLGRajQ3TKZmjGs7DNSojrNdaV8t6+r8IBorqmitbxfvw1AeBDyPjCjofLoVd+cnj64+LFpoecPEHOb77kHz2MEUa+IP5PGP7poQR/XoWSUYcc/VKOSqa3SOIFFQJpYlb0nMX3e/HzeeJ90uvwDAiAYtAgQDRzLNdgXOJ/4Qu6M8k1hAz3mb7bzu0hOk7pCccW9GJx8hDNRfqqXfO+eejoeglFcD/oPQfu4kGItXk+TSFqRLKRa25Vi5Vgo1/z2HnY6wWabW+oYb11sQ+wewyzCQwj/kkbVS3BYUJEvrTDgmWjeB2pSrsppOHjQlE9azsXJnFZfswouuwakVKVgjZfizScCzoNPAUeTzF7hJ1iIpCijmge9Mj+iyAdhORykaJMzPW4dKdPsxlOlO4tq6YT0Vjuq1Hk/DfJys+jWyk3x1PmnRxr9nGQYq6FwFUQPy4j45CZlwjJnDsd18/1nbjTzklYDp344E98Fex5gqFCrzB85IypfX2kfrwNuD+WXY3dHpkpzHGrmOD0kwTsCAbcBJGrsZUpbSG3XoxMDOHah/GLGPUJBouaz0GAgeyHSYarb00Vmk/x2O+ZIZTl5F29JBLdp573e2CjsMpgH5e6N6xBAJ+EZBJSfyuTr4nlBck0qM+V/ozuCGIw0bl091ek4WLP0NxAX3ox+mCQRUkunLOtMy1nE9Eg2FmZ+ymU2pGDE6WSoOxmfG1416G57Dhcz1SDgUh9U0g7DZFECfTKasA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 00:20:50.9878 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e1b31bb-5586-43ba-979a-08dcf22f62a1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A101.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4231 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_172057_081786_8B9D5FD9 X-CRM114-Status: UNSURE ( 9.97 ) X-CRM114-Notice: Please train this message. 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 A vIOMMU-based hwpt_nested requires a cache invalidation op too, either using the one in iommu_domain_ops or the one in viommu_ops. Enforce that upon the allocated hwpt_nested. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/hw_pagetable.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c index 5314cd486ddb..7af6cbe6dbf2 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -300,7 +300,9 @@ iommufd_hwpt_nested_alloc_for_viommu(struct iommufd_viommu *viommu, } hwpt->domain->owner = viommu->iommu_dev->ops; - if (WARN_ON_ONCE(hwpt->domain->type != IOMMU_DOMAIN_NESTED)) { + if (WARN_ON_ONCE(hwpt->domain->type != IOMMU_DOMAIN_NESTED || + (!viommu->ops->cache_invalidate && + !hwpt->domain->ops->cache_invalidate_user))) { rc = -EINVAL; goto out_abort; }