Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5105551yba; Mon, 13 May 2019 05:33:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqya3NcwWMJvBH65eECzGdjOZsPmwwyl62e1/I6yzDFhmV2GQVGXjvkmx4Nbqftrrz4FbVJZ X-Received: by 2002:a62:6807:: with SMTP id d7mr32008997pfc.75.1557750827217; Mon, 13 May 2019 05:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557750827; cv=none; d=google.com; s=arc-20160816; b=fkpke/wFUQhoOTMT4rL7K9IIk4RltXQdg8r0gKEpW/3SGCEegDnlhBK0MxhTLPwCja XvZWsW9dvZ+2IfXc1/jz2u+XYeKL5z2ASl/iwTPPfL+rpk90NiHRswVTTQzsqAaIgqqg JV3mXefu0HqRXrqob62jCu8UVlVN8VtSTAhusU8+OW469WqBifwGsX0f1O0VwTFLX7uC +DIK593eXHdiYQVxbcsD1Yn8Z5dw04vW1DGXgUcttTuI4U+F0Qwl37y+a1ftnmLpPC8o SmOsDHr+9/KA7L2AnG6+0IWHtuNxjYBB0QUBfF6Xqb5rn8mLVANb12J1/4lt2MMKIsgd 01/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=9SXqdaZnW51xoVlmJDc5Kel6lBJzQ8LPsH/LcMr7WvM=; b=JPAWBVfNhpJD+OphbhShI6DDS8c9f6g/Kw2io996JHFrvjVV6BYWB3A8y9zUjW4a1f 5/Z/89Yim9k3u/TDTw7snePtZG7tDQT1jV3NBj4sgSXy285YvIPiUcGzF0dgNtrg4RBF rWJnrnom+bcBXC+xbzOXbaj+c1H5H9+ZkXMVz6Kyi79SOQzKWMVWJRf8cgHF5qj0Wg/F jtb9WWzVoL8Mct4Y/hsKgVRzKdM6qQU6IOR/5IXFhVFPbf7jK00yGFUKABU72psRTbsX emz6i6g9R3rJ+pfznE4Jhk9p2Q/Tqd4mymsw89UBdxKIEYYI3NoPlrFqqsT138pGAvSV gXHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d31si15980438pla.89.2019.05.13.05.33.31; Mon, 13 May 2019 05:33:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbfEMLUv (ORCPT + 99 others); Mon, 13 May 2019 07:20:51 -0400 Received: from foss.arm.com ([217.140.101.70]:52982 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726103AbfEMLUv (ORCPT ); Mon, 13 May 2019 07:20:51 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1BDCC374; Mon, 13 May 2019 04:20:51 -0700 (PDT) Received: from [10.1.196.129] (ostrya.cambridge.arm.com [10.1.196.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 00B7D3F703; Mon, 13 May 2019 04:20:48 -0700 (PDT) Subject: Re: [PATCH v3 02/16] iommu: Introduce cache_invalidate API To: Auger Eric , Jacob Pan , "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , David Woodhouse , Alex Williamson Cc: Yi Liu , "Tian, Kevin" , Raj Ashok , Christoph Hellwig , Lu Baolu , Andriy Shevchenko References: <1556922737-76313-1-git-send-email-jacob.jun.pan@linux.intel.com> <1556922737-76313-3-git-send-email-jacob.jun.pan@linux.intel.com> From: Jean-Philippe Brucker Message-ID: <44d5ba37-a9e9-cc7a-2a3a-d32b840afa29@arm.com> Date: Mon, 13 May 2019 12:20:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric, On 13/05/2019 10:14, Auger Eric wrote: > I noticed my qemu integration was currently incorrectly using PASID > invalidation for ASID based invalidation (SMMUV3 Stage1 CMD_TLBI_NH_ASID > invalidation command). So I think we also need ARCHID invalidation. > Sorry for the late notice. >> >> +/* defines the granularity of the invalidation */ >> +enum iommu_inv_granularity { >> + IOMMU_INV_GRANU_DOMAIN, /* domain-selective invalidation */ > IOMMU_INV_GRANU_ARCHID, /* archid-selective invalidation */ >> + IOMMU_INV_GRANU_PASID, /* pasid-selective invalidation */ In terms of granularity, these values have the same meaning: invalidate the whole address space of a context. Then you can communicate two things using the same struct: * If ATS is enables an Arm host needs to invalidate all ATC entries using PASID. * If BTM isn't used by the guest, the host needs to invalidate all TLB entries using ARCHID. Rather than introducing a new granule here, could we just add an archid field to the struct associated with IOMMU_INV_GRANU_PASID? Something like... >> + IOMMU_INV_GRANU_ADDR, /* page-selective invalidation */ >> + IOMMU_INVAL_GRANU_NR, /* number of invalidation granularities */ >> +}; >> + >> +/** >> + * Address Selective Invalidation Structure >> + * >> + * @flags indicates the granularity of the address-selective invalidation >> + * - if PASID bit is set, @pasid field is populated and the invalidation >> + * relates to cache entries tagged with this PASID and matching the >> + * address range. >> + * - if ARCHID bit is set, @archid is populated and the invalidation relates >> + * to cache entries tagged with this architecture specific id and matching >> + * the address range. >> + * - Both PASID and ARCHID can be set as they may tag different caches. >> + * - if neither PASID or ARCHID is set, global addr invalidation applies >> + * - LEAF flag indicates whether only the leaf PTE caching needs to be >> + * invalidated and other paging structure caches can be preserved. >> + * @pasid: process address space id >> + * @archid: architecture-specific id >> + * @addr: first stage/level input address >> + * @granule_size: page/block size of the mapping in bytes >> + * @nb_granules: number of contiguous granules to be invalidated >> + */ >> +struct iommu_inv_addr_info { >> +#define IOMMU_INV_ADDR_FLAGS_PASID (1 << 0) >> +#define IOMMU_INV_ADDR_FLAGS_ARCHID (1 << 1) >> +#define IOMMU_INV_ADDR_FLAGS_LEAF (1 << 2) >> + __u32 flags; >> + __u32 archid; >> + __u64 pasid; >> + __u64 addr; >> + __u64 granule_size; >> + __u64 nb_granules; >> +}; struct iommu_inv_pasid_info { #define IOMMU_INV_PASID_FLAGS_PASID (1 << 0) #define IOMMU_INV_PASID_FLAGS_ARCHID (1 << 1) __u32 flags; __u32 archid; __u64 pasid; }; >> + >> +/** >> + * First level/stage invalidation information >> + * @cache: bitfield that allows to select which caches to invalidate >> + * @granularity: defines the lowest granularity used for the invalidation: >> + * domain > pasid > addr >> + * >> + * Not all the combinations of cache/granularity make sense: >> + * >> + * type | DEV_IOTLB | IOTLB | PASID | >> + * granularity | | | cache | >> + * -------------+---------------+---------------+---------------+ >> + * DOMAIN | N/A | Y | Y | > * ARCHID | N/A | Y | N/A | > >> + * PASID | Y | Y | Y | >> + * ADDR | Y | Y | N/A | >> + * >> + * Invalidations by %IOMMU_INV_GRANU_ADDR use field @addr_info. > * Invalidations by %IOMMU_INV_GRANU_ARCHID use field @archid. >> + * Invalidations by %IOMMU_INV_GRANU_PASID use field @pasid. >> + * Invalidations by %IOMMU_INV_GRANU_DOMAIN don't take any argument. >> + * >> + * If multiple cache types are invalidated simultaneously, they all >> + * must support the used granularity. >> + */ >> +struct iommu_cache_invalidate_info { >> +#define IOMMU_CACHE_INVALIDATE_INFO_VERSION_1 1 >> + __u32 version; >> +/* IOMMU paging structure cache */ >> +#define IOMMU_CACHE_INV_TYPE_IOTLB (1 << 0) /* IOMMU IOTLB */ >> +#define IOMMU_CACHE_INV_TYPE_DEV_IOTLB (1 << 1) /* Device IOTLB */ >> +#define IOMMU_CACHE_INV_TYPE_PASID (1 << 2) /* PASID cache */ >> +#define IOMMU_CACHE_TYPE_NR (3) >> + __u8 cache; >> + __u8 granularity; >> + __u8 padding[2]; >> + union { >> + __u64 pasid; > __u32 archid; struct iommu_inv_pasid_info pasid_info; Thanks, Jean > > Thanks > > Eric >> + struct iommu_inv_addr_info addr_info; >> + }; >> +}; >> + >> + >> #endif /* _UAPI_IOMMU_H */ >>