Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3149701pxj; Mon, 10 May 2021 20:30:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI11f2nQwZiw2wtuAB67nxLjrBygDT5pLWKsW8R5aghMbNV6U+ImYxv+KDILIIL4rDlHWU X-Received: by 2002:a05:6e02:48b:: with SMTP id b11mr13346447ils.110.1620703808942; Mon, 10 May 2021 20:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620703808; cv=none; d=google.com; s=arc-20160816; b=jRWH189qzm2sXD7zk2FidNMY5nx79nxw0AXjKqAkrQG20Z2pT1A8kPpgFjw0eKdtAc XOb5k2VKnQoUxokexKleaUACEX69UpTGMc1DNMOkl1mGqYzIWeJBne1ZQGkHRilxNXL1 86JobOHUTkSMpTKTHWStw+FLr5yhksMFawLvmkacz+0jlGzIzBYg0e0UbgwLruS4SY89 E+WbuUlv5qYV6but6WtlxgaPgwlx3sAqFDBVFXQwr3VWuG+d84NMDcFPYQ59Y0sz3ry0 uhNIbzvHNApmB9puCes3Hgaw+hDlNJiTsyrU3O17ZAkhEtwWyaf67x12ABsL5UITyF+x UpqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:ironport-sdr:ironport-sdr; bh=pVPrTvUvGO1svs9VR+foPBrV/EAhzIQ+t9LdctdM3Ew=; b=D4HWhtQBzqY1b52ckFX47tdgMl0iulXiZrmOX0K/IWX4CtTjUISn4+Z9ei9F2KnopP T9tzaDcG47KKD9VM+86ecxQ/3JXL74iNvYYDHJKZM+511+t74+rVkUm+PUOH5OXrmp/D ojkYt9BWoqw50N8Fsgv85sZHXmj2+1jBSqTNGjzIcy/lW9AZTtoXZII2SJdKSPFNXBkN YY3YaRd6uuHfiKj9/mu6xDF1KDQYUhdKRIWpHDK495BJh2XH16obTAzoJmqdnGBG6Nrv T/tRBYNRAh1jFjEHGKCZvSek+GyU0DvRjWMF3Px0PNDctQyhwiQuEgxU103lxAXIgkyw I8pA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y18si18030168jak.36.2021.05.10.20.29.56; Mon, 10 May 2021 20:30:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230016AbhEKDab convert rfc822-to-8bit (ORCPT + 99 others); Mon, 10 May 2021 23:30:31 -0400 Received: from mga09.intel.com ([134.134.136.24]:27291 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbhEKDa1 (ORCPT ); Mon, 10 May 2021 23:30:27 -0400 IronPort-SDR: NlyUZ2m1UehV7iVXdKTNH0tj/pZBS0B1KVQtNdM31ULfQ8Fr2cMho3NC3HiOxQ4ki6IbM0qDPP kI7n6CTBOBIg== X-IronPort-AV: E=McAfee;i="6200,9189,9980"; a="199413708" X-IronPort-AV: E=Sophos;i="5.82,290,1613462400"; d="scan'208";a="199413708" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2021 20:29:21 -0700 IronPort-SDR: Uhpb1DvDD4VWPvQUKBbuZtT0+KRdRivARUbZUC56WRz1l0s45RJxsvGjfZ0Rq+c/5mOehZQAfH TrML/fzG6MxA== X-IronPort-AV: E=Sophos;i="5.82,290,1613462400"; d="scan'208";a="436443967" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2021 20:29:21 -0700 Date: Mon, 10 May 2021 20:31:45 -0700 From: Jacob Pan To: Jason Gunthorpe Cc: LKML , iommu@lists.linux-foundation.org, Joerg Roedel , Lu Baolu , Jean-Philippe Brucker , Christoph Hellwig , Yi Liu , Raj Ashok , "Tian, Kevin" , Dave Jiang , wangzhou1@hisilicon.com, zhangfei.gao@linaro.org, vkoul@kernel.org, jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v4 1/2] iommu/sva: Tighten SVA bind API with explicit flags Message-ID: <20210510203145.086835cc@jacob-builder> In-Reply-To: <20210510233749.GG1002214@nvidia.com> References: <1620653108-44901-1-git-send-email-jacob.jun.pan@linux.intel.com> <1620653108-44901-2-git-send-email-jacob.jun.pan@linux.intel.com> <20210510233749.GG1002214@nvidia.com> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason, On Mon, 10 May 2021 20:37:49 -0300, Jason Gunthorpe wrote: > On Mon, May 10, 2021 at 06:25:07AM -0700, Jacob Pan wrote: > > > +/* > > + * The IOMMU_SVA_BIND_SUPERVISOR flag requests a PASID which can be > > used only > > + * for access to kernel addresses. No IOTLB flushes are automatically > > done > > + * for kernel mappings; it is valid only for access to the kernel's > > static > > + * 1:1 mapping of physical memory — not to vmalloc or even module > > mappings. > > + * A future API addition may permit the use of such ranges, by means > > of an > > + * explicit IOTLB flush call (akin to the DMA API's unmap method). > > + * > > + * It is unlikely that we will ever hook into flush_tlb_kernel_range() > > to > > + * do such IOTLB flushes automatically. > > + */ > > +#define IOMMU_SVA_BIND_SUPERVISOR BIT(0) > > Huh? That isn't really SVA, can you call it something saner please? > This is shared kernel virtual address, I am following the SVA lib naming since this is where the flag will be used. Why this is not SVA? Kernel virtual address is still virtual address. Is it due to direct map? > Is it really a PASID that always has all of physical memory mapped > into it? Sounds dangerous. What is it for? > Yes. It is to bind DMA request w/ PASID with init_mm/init_top_pgt. Per PCIe spec PASID TLP prefix has "Privileged Mode Requested" bit. VT-d supports this with "Privileged-mode-Requested (PR) flag (to distinguish user versus supervisor access)". Each PASID entry has a SRE (Supervisor Request Enable) bit. Perhaps we should limit that to trusted device, e.g. RCIEP device? > Jason Thanks, Jacob