Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1177166rdb; Wed, 6 Dec 2023 10:32:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoqT0IP7RKk91JUtkMwepEXDry1rsvOE6sEyuC21XM3d+fsdGfWPsG4AT7dZZs3yuFVrbF X-Received: by 2002:a17:902:bc84:b0:1cc:4eb0:64cf with SMTP id bb4-20020a170902bc8400b001cc4eb064cfmr1247546plb.52.1701887565888; Wed, 06 Dec 2023 10:32:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701887565; cv=pass; d=google.com; s=arc-20160816; b=lSWpfQCZwBrigNuFeQb5wW1OMV/KmJM1fLhprUzXC0XiymRe1Gn5/nLjbSq2Bu2lnV SbwHrmIooh5UmmigFij6Qz6wR5nC/cYVKGKCycLz7lorg+00kxpzxPVXZ9+uMIMLXB0c qg7eR8aVajpnToF772wBWgNsc32+Uj+t9WELlKar0Ba9I9NmZfc4+h6mP0doH0KoUFFi cn722E6sjqjGvzWt1AdUM7LOT0LHJZqZsn8RAJVM5S4wDJVEc9kxn0e8FrRn9tXSRhwE 7AAhVXJvSvbi2cyERNYThXfHNgjB0pgbrPd8zW0Ee8DTyz4VoZ0nouePwH/+8uKv1bR4 +ReQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ASEAT9jBmCqkBackiVAIXVBcP11rwrA5tTsX4oQ88rQ=; fh=k5doefdr4QcVQGZUqMnaKlCK1MFVWRK7THwtnyoqv5s=; b=cahL/+446FIf61goleWrdBfMJ7OsFSk0EMM+8yCZ10cjxUFHX1CeVsPo7CKDmf304H wL8VZFxS6sZYmjxnxq32Qi+FTW9iaGQdDANaXoGhTroPzFoubk0zDcVLtz0/6LUQMR5j 6JKN9ms6bBasR4L2+wID3a2kCBs+vxa5zODAFf82o/xeq2b8Ovs+ncTXUxKW2mwDHc0H sJRO8WAMUZ/zQ//GZColwYGZFlVA9z0Ty/IvcH0u3uQjHqGFaEq6dLd3x+2b2yZBL1cJ pmZpazqANlJsIhadeTJHTDNIbGZSeJ+wZawmO9ufOi4yF1Hcd/Lh/cY6kae+MqWHPGlr 1PxA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="Av/p3BCX"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c2-20020a6566c2000000b005b16e351343si291609pgw.241.2023.12.06.10.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 10:32:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="Av/p3BCX"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 4328A807B4BB; Wed, 6 Dec 2023 10:32:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378349AbjLFScJ (ORCPT + 99 others); Wed, 6 Dec 2023 13:32:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbjLFScH (ORCPT ); Wed, 6 Dec 2023 13:32:07 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2048.outbound.protection.outlook.com [40.107.94.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B198ED40; Wed, 6 Dec 2023 10:32:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YfnBocwpyoOv+GCpWbasZuhvxvEFly9vX2MMlyEkXorF8VPaMJOMxwHnFmlx6/RvBgUxy7rZ+wIuD4LNBry/QdGgBikw/EDItQwWzQcgTrULQcVtZzdw+a7u/zZTsa5I3GQ3TkOS9qLSYoNmorsrfupgxWm+7yLs1TjEg/g8QJgMX2cDbcNrvsVsnvBvGXF7ArpD/gnLVxhMQll6Xp24rpisY6+I1AfsVvxFOVQmKLZtzz5IbG8JoB/ryA3J97e3HmivvLegu46tmPjsdIUCXK/Bn2tD8xWb7T3lSGmtvP0s2s3mk60F/5xGDE9zYuErqKrLgqVg0FXAv2uW/Nf3+Q== 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=ASEAT9jBmCqkBackiVAIXVBcP11rwrA5tTsX4oQ88rQ=; b=gqKcH5bSxUnFU/2lvVXAok+l26kTq8vc+apQeWU+y+s0Id4dk4aNfhDZ1X8LfAYjfsGNYm83FiH9sT71ZJ1BoAudXa4s3KRuuzcUvU2IwejNPpmzeOBMuaOvKrQdGsp31Judxr1GKuTmvD5Wl1Hud1dNoWUsxC4M1Ma9raRsM+X0M89NS5CMadxe5bZX9Z5EV2UBn4HhhfI0K+pMs5d2XmmBz9mZPAxWhgXN6aZe+zhV37NKudUCY45bOdGU3EBoiRkKDP8nbLauhEtK3F4nVQ5K8eUvDu+SYQJo8lINMRtejqmYEkFp1WEg3KTq+mnofwdagESYGzI7Wj8i6JC0Vg== 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=ASEAT9jBmCqkBackiVAIXVBcP11rwrA5tTsX4oQ88rQ=; b=Av/p3BCXrDdgD+JN6uC+X531+lAsp4H5nN06duuJ6duVmYRDJEfPB0FgYuxyEjygqpySSnKvPGgO/Y12Irzp9eQnfGVH9V7kuXOk3TokcMaeiHI2YNU3ZP2u0X18Uk/AxQnatkVUgeY5tjmgLocZCVVn+7G3/4qjFBJUkD1wRc4AppYVtqNpxmg6uV7dybuPFOUtt0xQYiC/SXZVknKZqEFAxQBb7u9biePB/CyyR1Hg+1PgBcnKOo+gdUiV1V957DVnUiDTduNnENvJ4iIHQiKhOqszGEJnBXp5LgoTWAVTGjCR2y+kZzat53fxWcGDturTlKcwkh55Uff9YtOTYA== 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 SN7PR12MB8026.namprd12.prod.outlook.com (2603:10b6:806:34b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 18:32:11 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93%4]) with mapi id 15.20.7046.034; Wed, 6 Dec 2023 18:32:10 +0000 Date: Wed, 6 Dec 2023 14:32:09 -0400 From: Jason Gunthorpe To: Yi Liu Cc: joro@8bytes.org, alex.williamson@redhat.com, kevin.tian@intel.com, robin.murphy@arm.com, baolu.lu@linux.intel.com, cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.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, zhenzhong.duan@intel.com, joao.m.martins@oracle.com, xin.zeng@intel.com, yan.y.zhao@intel.com Subject: Re: [PATCH v6 1/6] iommu: Add cache_invalidate_user op Message-ID: <20231206183209.GZ2692119@nvidia.com> References: <20231117130717.19875-1-yi.l.liu@intel.com> <20231117130717.19875-2-yi.l.liu@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231117130717.19875-2-yi.l.liu@intel.com> X-ClientProxiedBy: MN2PR16CA0047.namprd16.prod.outlook.com (2603:10b6:208:234::16) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SN7PR12MB8026:EE_ X-MS-Office365-Filtering-Correlation-Id: 960c16b9-eb15-44bb-42aa-08dbf689a8d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6gY6ubHI8USWvvZlyy6CxhpQV9hisXYLeHyMe7IDYA+CX3bLcYKoSlqh9mWgJIBhCv0+z4u1a0PO5A+FAgH7GGPmwbBdySJTRMr7HRVkW7qXbFtgTexNV5uAc57d7CrnKkm80XpTGxvRry9OWHk4seRYE7Hm4xOxvYEjl0W3/E55Yqw4Jn6lsd4rSWiv6hC4f6Ao6yKZcrCtCLHox/yImiIhw19ThhoI0HNfkDefrmexW27AEcyc7aEzvd/wZasCXQpp25zH8aDpudfz3VdIMaUk49AZTjPoekCZyBpMqB0xSQyy3BNNdIOnjXr4xzi0TXuC2HZpkzigDXnz0IDN5hpNINZZy7hFJl5tZWwZN6KnmfHu2686sKIP+MXN5Twyg4dqSUYGHFBQF3snJtjgD4RTTpmavwcQUASDXTl13/Z22fnULbXqjlgBMI6r6j+c5p19CqsYbLsCVlUBZNf9xcoF2GCE4dCuzpzFloxcpBKWWspudwJRb2sqym2iLpWqzg78NL096W3Co1qTktD99CALZz7krmcybPuxHyei3Psv369GezFYzKN2WgbmGmF5 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)(39860400002)(376002)(136003)(396003)(346002)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(33656002)(2906002)(7416002)(5660300002)(36756003)(41300700001)(86362001)(4326008)(8676002)(8936002)(316002)(6916009)(66476007)(66556008)(66946007)(38100700002)(6486002)(478600001)(1076003)(83380400001)(6506007)(26005)(6512007)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?IjFjst8kbYA9JuEeFxcLYS8g6EVpM2dhnqp9VKRdq9whttMELOOXbgRebHk2?= =?us-ascii?Q?dl9LLHcPxfsBtZnl43PNoQR70Gk1tQGO2IAn3PLfhE5mLXX+SdA4Lmz0/pVv?= =?us-ascii?Q?EnspZuiCkx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zbi?= =?us-ascii?Q?1dGnmEtpQC7VPM5inoIWYr1sygWPzhI5IE1iD9PBJ3Ad2jQLpT1bPpaX5rJM?= =?us-ascii?Q?4jo9D02iuTIFfOixeBPdXuKDSjTStWKFdCL33Oto5FPwG/D2g/qG56saD/lM?= =?us-ascii?Q?LGKj3zoRUuINOAqj0etMPIzCF//qqwX1SefWCKBYZRt5ml3IA1Nv4n4XsUa3?= =?us-ascii?Q?RDfK8OJMHGbpCOaLbu/SimMbPMNThGLAXri4X29aBCz8Sthvdql1e+bKUt1P?= =?us-ascii?Q?8CaNIDdLkkBGhycSeuO0iTNJifcubzStAPiLjsaYR5fpS5ZNrJGMYn3/I8LJ?= =?us-ascii?Q?Pqp8wR+GpIekOfpdlCH3T+F6iJnfMqjKafejtgh0xLqs29JhGCVUAogt7Twg?= =?us-ascii?Q?k/1CyrAwW5sQud0aBDoMQPGgx2CVCOoTGkN0dljqWl6qVFyhtq3Zg06Rk4SS?= =?us-ascii?Q?Ys8gJjlspCnWKVR3Hs+/7bbYapKaqKoK+RY/RLQJ29gZmKnOCfaC1JwHei3A?= =?us-ascii?Q?rzdSDstqt4HrlH6HttLpW7ShCf9agvGgEn4msYJ/Q0209UkQ5hBZyHsJUl2p?= =?us-ascii?Q?8S7Hx5JCl2whaOiTtOMoEEC/bi8eObYrNxHW5WpL?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 960c16b9-eb15-44bb-42aa-08dbf689a8d0 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 18:32:10.7675 (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: JXuEgBsvmQCTAQ4SAc5Omd8oO1lRJERSU09BfYR0JiuLIrRXO2lEhNyuJPGNaai3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8026 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 10:32:23 -0800 (PST) On Fri, Nov 17, 2023 at 05:07:12AM -0800, Yi Liu wrote: > +/** > + * struct iommu_user_data_array - iommu driver specific user space data array > + * @type: The data type of all the entries in the user buffer array > + * @uptr: Pointer to the user buffer array for copy_from_user() > + * @entry_len: The fixed-width length of a entry in the array, in bytes > + * @entry_num: The number of total entries in the array > + * > + * A array having a @entry_num number of @entry_len sized entries, each entry is > + * user space data, an uAPI defined in include/uapi/linux/iommufd.h where @type > + * is also defined as enum iommu_xyz_data_type. > + */ > +struct iommu_user_data_array { > + unsigned int type; > + void __user *uptr; > + size_t entry_len; > + int entry_num; These are u32 in the uapi, they should probably be u32 here too. Otherwise we have to worry about truncation. > @@ -465,6 +492,9 @@ struct iommu_domain_ops { > size_t size); > void (*iotlb_sync)(struct iommu_domain *domain, > struct iommu_iotlb_gather *iotlb_gather); > + int (*cache_invalidate_user)(struct iommu_domain *domain, > + struct iommu_user_data_array *array, > + u32 *error_code); Regarding the other conversation I worry a u32 error_code is too small. Unfortunately there is no obvious place to put something better so if we reach it we will have to add more error_code space via normal extension. Maybe expand this to u64? That is 64 bits of error register data and the consumer index. It should do for SMMUv3 at least? Jason