Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp791371rdb; Thu, 30 Nov 2023 20:31:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEutgeKVpD8piiN8V47UQyezfmCS64TG8h7hLkIcFfrHwAF6z5lL5KClp/NWHzd0vokLhfE X-Received: by 2002:a17:902:e9d5:b0:1cc:4a70:1373 with SMTP id 21-20020a170902e9d500b001cc4a701373mr23079640plk.58.1701405075888; Thu, 30 Nov 2023 20:31:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701405075; cv=pass; d=google.com; s=arc-20160816; b=JGR/PlhVhP58kvOARBVL2mgtkn4/+Raua/AwAdiHpCW/s4paXgo08AqiFYbULymG2k rVv7Wh10Fkx+nfLc2YIVDsDjcku75OhIfZ92TuKISOLkl6+kZntdEPoPYTHxZ0euN4Av nf9E5p4AhMGHxyL6gxlGr8vNz7lWt3UoRRZRmJORKhZgG8MMLvyPzSXN19Su3ETu5xMZ AcaAfH33JPGBg4sNDK797c1gYDfPdsaYrC+1znyoKFYltq4liEyeFbNAJ+ypCff0QrWs BiGtj+1YmNbVHDrHkp9Ib4l7varOofY/1ik2q89jQlKGGeLiHStL1PGXbbCtYqjn51Uf Xadw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R7bfv2GNRu619/VcJExT6hbn694ANxooW5meEWIjrjk=; fh=e+heDyPhC8R09C2aNoU4NskwSXEQ+su5qIjwJ6N1S8c=; b=nyspBa65KoHf6+U0CFsQ8uG0zQmaej8B/gvJ6PfeBjyIN/bjzmTttXH2qBxO9Ct+vK fYJ6Mf45/5NcAqeOW8eH4K+nMQmTwheS3YMPBtq7iBPwJSkvWqX33bT7/M69fkVScFP0 gXz3sO7eQGDehw6ZIvfxPziZ5PZ8HHnxnx365MCjkpy4P9n124PxVGYjUPbilurlyE5j jiefJ5+v8b3h5uUxuDjFOTQZzOa4MMF4HSmzldm5/kw2Z28+c5HJuNaP+/xkFBrYgDqz VH9eg/HN3S3NP0t6zMNJOH1pGrpSU+lHXZy9hmc9j1+cI5FEQQCGFUPDtWsrnEyJ9Uzq WbMQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=WxCnCpuS; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id lb12-20020a17090b4a4c00b002864ee5aadasi1476341pjb.186.2023.11.30.20.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 20:31:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=WxCnCpuS; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 003748081CDE; Thu, 30 Nov 2023 20:30:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbjLAE3v (ORCPT + 99 others); Thu, 30 Nov 2023 23:29:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbjLAE3u (ORCPT ); Thu, 30 Nov 2023 23:29:50 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2071.outbound.protection.outlook.com [40.107.237.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CBF9170D; Thu, 30 Nov 2023 20:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dyACTiyfvXJkJONBizzV2/oHR6rwCP6jTeWBMmuTrIRzDDWKQPd3tZvb/natCI6TAY/hiT3qNsnyMpQP0bqK40lcZpB6KNE2ilxzGjPkg/1Ui4kB7vkpnItUrMjkNAFNZ9qseGkqz6nZD+tVIPX467oo83JDMvZz3V3AyNLdayL7/zX9WF5S8xdR8mko2gS50ZXRdCTeMo21fuE5guWVBlKvnK1VdvQA4rax6ifQ19K3UV9N+kTbx2LpvKF76IKWKBolBkpCQT3lJk0fy/ti2WRyVG+ggksFmRqxYJ5xoYuQgqCUX4UWbxgWwMMFSCZUKzhRclOvFVctPnOhhYNdKw== 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=R7bfv2GNRu619/VcJExT6hbn694ANxooW5meEWIjrjk=; b=eDBNKFcDrCOOMqLG7VU4MXtScHoD8Cwx4Fftv7GHKYrzyBo7k4t6A/0Nj/87JQKAk9eEBsxLzziWaYm2CJAgQKBxBXZ6QSSNKchwKv2fUCXkJRTi+ZSJq6g+qhQZUDD0rn0dHsBW/HlYlda1CZ59PSelN56LvEU00b2zIqlDNYWQ1JS4IylZSpb8+fFGQ32G6BPRwbkKstsf8q5Bhw3ptM8bsApxNwi5EdkDKIFNGa6s+RoIrs5mY4ehZ38cvX9277aA/1MI2IZ/V7HSz1Lnqek71Jqamfgk1GzUctDP7M84exNz9/jIR862yZ30hGWh4O3rwRSZdZT0IflSMFPYXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=oracle.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=R7bfv2GNRu619/VcJExT6hbn694ANxooW5meEWIjrjk=; b=WxCnCpuSWKD7bYdi6yCe9jdHv71uVc7AtcfRch9Lmv+MuPTUvmFt1A2WJF/jl0yk+oG7e8yPFz0KhtxctVaSMul83O22b65SlK3KxyxztvRgpYWuqD6tGt8idIT/C7o295HO/ZIpIIWnvHht2ojvjN2g/OuV/N2f8rNW1yNvlp6Dq0IHtEwEaVHGy0FJToDcE8O5TNdKNcRSQXVSaBTEZ9YK/HTk92hS/AnX8gD2LtSAObCP8vIWwuhj98+oqiHY0w+bSk+rdfXzx0sGQqLFHTxAV5rqx17WYwCb59jCLmvlgJPBF041o+DVRxmDlgAujJwvfSrQOGjkqMlf1gqAdA== Received: from MW4PR04CA0306.namprd04.prod.outlook.com (2603:10b6:303:82::11) by DS7PR12MB6264.namprd12.prod.outlook.com (2603:10b6:8:94::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Fri, 1 Dec 2023 04:29:53 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:82:cafe::fc) by MW4PR04CA0306.outlook.office365.com (2603:10b6:303:82::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.24 via Frontend Transport; Fri, 1 Dec 2023 04:29:52 +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 CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.17 via Frontend Transport; Fri, 1 Dec 2023 04:29:52 +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.986.41; Thu, 30 Nov 2023 20:29:39 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.986.41; Thu, 30 Nov 2023 20:29:38 -0800 Received: from Asurada-Nvidia (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41 via Frontend Transport; Thu, 30 Nov 2023 20:29:36 -0800 Date: Thu, 30 Nov 2023 20:29:34 -0800 From: Nicolin Chen To: Jason Gunthorpe CC: "Tian, Kevin" , "Liu, Yi L" , "joro@8bytes.org" , "alex.williamson@redhat.com" , "robin.murphy@arm.com" , "baolu.lu@linux.intel.com" , "cohuck@redhat.com" , "eric.auger@redhat.com" , "kvm@vger.kernel.org" , "mjrosato@linux.ibm.com" , "chao.p.peng@linux.intel.com" , "yi.y.sun@linux.intel.com" , "peterx@redhat.com" , "jasowang@redhat.com" , "shameerali.kolothum.thodi@huawei.com" , "lulu@redhat.com" , "suravee.suthikulpanit@amd.com" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "linux-kselftest@vger.kernel.org" , "Duan, Zhenzhong" , "joao.m.martins@oracle.com" , "Zeng, Xin" , "Zhao, Yan Y" Subject: Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE Message-ID: References: <20231129005715.GS436702@nvidia.com> <20231129195804.GF436702@nvidia.com> <20231130000816.GB1389974@nvidia.com> <20231201004523.GJ1389974@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20231201004523.GJ1389974@nvidia.com> X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|DS7PR12MB6264:EE_ X-MS-Office365-Filtering-Correlation-Id: 70501838-9144-4d8a-9c4e-08dbf22629c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FuA8/wrxLDrwDPGQmMsQ5T1QiGX+7cJS3ZFVN1AD055ZRlddIKpX5yLJo+t/y3Czf0Zh0ND/Q59GjitWGZgZv0E8Q6RMXeAA+AtV+UZIhw0UuH6ytIbH5wS/etF97FYPSvNt5/X0huObRdxL6TW6aBil19+A7UVK+Ul2ohV1d4RSIZXy8EEusBkV4dP0El0+jlS6MNn/QJQwCgOVAcO8BDZX/f2gQROu6Btl3ezdHdv6TUEjrlgPkSbS9GOdOhAGEB+fO1OqffnVVafUph5uWvleZOrIobUCPKuwSID1W9YvEp9T3Qvx8N9NehxlnGUIvR0Wc6K0QKPv/MDxzwcoe5vYxeS9/c776YoS6yIgqHyI8J8mC3tuSU4eOv8TRrkVau9TSZ1ms4Vs4rVfAGSdZULg0IDsELbJrBB+35oS0Fxgh6fSPdlL0I0ZIeq0zaVtE4Gt92zzGb/1rC0RSfxq6vVn0qk+6ur/NJHbdmnQLAjmI6rv0orM9s7gI7C3lEA3M/6y2gJmV7I8vvO+tDoOGxFhy2jccGJ8YXJdRS5MGBS1tsbunOEWpaVUpFNqNCMLBAZ/XCqz75rcTECnNBYv6zRXDj5WmTOnZ4mNzNapko+6L/eSJxT/6LvOFMB036O+cvyRKsqXo3ceVr5b9T1phX5p0VHehYfXfCgmVMlHhuWKqnPJJmMJx7wmqnvtdOuKZlxbd/z1EOc7Y2deqXG27kgTOF33BT+mBif/VOEjBFOcGJjNxOw9K0CHykj3djGo 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:(13230031)(4636009)(346002)(376002)(136003)(396003)(39860400002)(230922051799003)(82310400011)(64100799003)(1800799012)(451199024)(186009)(40470700004)(36840700001)(46966006)(4326008)(2906002)(6862004)(8676002)(8936002)(55016003)(41300700001)(336012)(26005)(316002)(70586007)(54906003)(6636002)(70206006)(7416002)(5660300002)(9686003)(426003)(40480700001)(83380400001)(47076005)(36860700001)(7636003)(356005)(86362001)(40460700003)(82740400003)(33716001)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 04:29:52.5746 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70501838-9144-4d8a-9c4e-08dbf22629c7 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: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6264 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 20:30:13 -0800 (PST) On Thu, Nov 30, 2023 at 08:45:23PM -0400, Jason Gunthorpe wrote: > On Thu, Nov 30, 2023 at 12:41:20PM -0800, Nicolin Chen wrote: > > > > So userspace would have to read the event FD > > > before returning to be correct? > > > > > > Maybe the kernel can somehow return a flag to indicate the event fd > > > has data in it? > > > > > > If yes then all errors would flow through the event fd? > > > > I think it'd be nicer to return an immediate error to stop guest > > CMDQ to raise a fault there accordingly, similar to returning a > > -EIO for a bad STE in your SMMU part-3 series. > > > > If the "return a flag" is an errno of the ioctl, it could work by > > reading from a separate memory that belongs to the event fd. Yet, > > in this case, an eventfd signal (assuming there is one to trigger > > VMM's fault handler) becomes unnecessary, since the invalidation > > ioctl is already handling it? > > My concern is how does all this fit together and do we push the right > things to the right places in the right order when an error occurs. > > I did not study the spec carefully to see what exactly is supposed to > happen here, and I don't see things in Linux that make me think it > particularly cares.. > > ie Linux doesn't seem like it will know that an async event was even > triggered while processing the sync to generate an EIO. It looks like > it just gets ETIMEDOUT? Presumably we should be checking the event > queue to detect a pushed error? > > It is worth understanding if the spec has language that requires > certain order so we can try to follow it. Oh, I replied one misinformation previously. Actually eventq doesn't report a CERROR. The global error interrupt does. 7.1 has that sequence: 1) CMDQ stops 2) Log current index to the CONS register 3) Log error code to the CONS register 4) Set bit-0 "CMDQ error" of GERROR register to rise an irq. FWIW, both gerror and cmdq are global. So we can't know if the error is for which master or domain. So, the only way is to get errno from the arm_smmu_cmdq_issue_cmd_with_sync call in our user invalidate function, where we can then get the error code. But this feels very much synchronous, since both the error code and faulty CONS index could be simply returned without an async eventfd. Thanks Nic