From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6058033F5A2 for ; Wed, 13 May 2026 17:11:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778692262; cv=none; b=TNlNFsKnCROv53m1QRQHqXJvHFiHfqyZQ/1M5yyMxC1Og3YNA7TVPE0PHLdCaN62gnCb99ha04WCbrZNAUC5JhJsjBy+j8FQSE7yk4wxWHzae10EySFA+KsH0NeRm9UzmJo0hdH6y+QvMCymINKUrlHM34FzGUkDKHMIDwwsW0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778692262; c=relaxed/simple; bh=QW93lb1fdkpsnUJto5D4XyEklvCRZfMWCbZsUem2uAk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sO9hUv0E244T7Md5jb6XsH5m6PSJqrJYEadbHKZ2pM3rtqxxnK8n24MBiANUtHsjNAtkpcipm6/QQdUnYKMrz0uxetB6y4VnWdi+ZEv8gAxsUskWrTfeP5mnG0PH6YOKTxtHFDohwLPX7uoYC27nXbEGCXkMLgFaa38YlrWy2K4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=cDlMkJE/; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="cDlMkJE/" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-8b3d6b215cfso107179066d6.3 for ; Wed, 13 May 2026 10:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1778692260; x=1779297060; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LFS+fpNwj5CoQBfOxdsT86bztMTzUd1XUisAgFNuBCE=; b=cDlMkJE/iKVO2wsQrAgm6Eo61hICSe1W9iwcAvgPCJBeC9ePDfssBzL5Hw3858umLK 0w/SDZw8U1njmcAZH9wNjypc/x7wP0V8tWwz/QWzX/T+MMbuyDNl/gty0sbHsH/pwYRe CtdDWzs9kQjlpnsbtwVLm6YBTdyqte/ilQlkg6nBGeQHvfAyNItr8cTBxHgrLuwMq9V5 BfpFtRfG+7jCgRqfGQaaZAjF11E51gQomOv0ek2TBGPx51J7/Gc+rS1RbCCoXc/a1inv Eyp0ErNep9T5eAk83tFLeCpZa1dAj33QcEnpuPaOZvq58e6UD4yDbiWX/1nzVzh3FuI7 sGWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778692260; x=1779297060; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LFS+fpNwj5CoQBfOxdsT86bztMTzUd1XUisAgFNuBCE=; b=lWw/61CVXII6taioGN0EBHusYCTpFXh7CbjUrr40783f57S1dh/UJWeRGdrI8q5Fvz i8+kqxfB5D9rfswxW7xUTLeuCs/oQFAV+IUQN4jrE+8m8c0CQczXALGkHYZvDuWmdONp 2y0xTj8FdDb5dUMW8/fLB6cnwOunIMMYfQEWIqgrQWCyT+QXYwKT9T7Dtgek/PzzyTEv nnJAbcE4VjwX+To81/GjrHV96JjJ7g0YzIaASbVy21gWg3vIpyAXZEzVWO8GiCRh/dAK 5xsaj9qQZlAtx4TDrRpz7sCHcYhf49Aasbo6U4BXEXNCJTBkbnD3wjEZW09xZ5VAervU vrpQ== X-Forwarded-Encrypted: i=1; AFNElJ/1KNd0aUfCer3NrnZkhxbb/HPHcNxCin5LkfnGbTQxNWNkxBZcBRcK6mWK8saNDQzDD9J47EBpD9l40oI=@vger.kernel.org X-Gm-Message-State: AOJu0YxqRn7a1jvFDcvxz76ndWcheNCUorbZj44D96Ui9dFHXRBQowKg QQJksEcKP4+WMR9E1+MfwhgVFZuh62Q9eYCczRhjgEAlKzi2LL/zCAKdgc6XNL00+u0= X-Gm-Gg: Acq92OHwZrr2B3KUwOvrVTSloWz5y24T5DoActIDLFvg3MmbzDY6PWcJj5aS/2Hjcvl nLc3D6Tuj3Fa7K7bQSOYxKRMDbcPGVXHKiCoIxPK3mrRVGJhlGNGXgHHIWh0lEjGTkJRLrR8u+R WI258d/IB2uJgPtvyIKldCPTuHjh0gfv7/rmXQDnVitaiIFCHhp4SFMRyZZu3t1xQmc2hsg37mJ /KG2WQVwcCzIN+p/UBfjbSibgUMbzdopX1grsQ/FraiKrgaxweNAzHgVNKH0wNt8O1gGU1WdbQN 1SUEsyVX6kdRb2JAAeEhGKWnDofPmETd/9kNLXW55g0lQNzIS45U+5YD8GF1S4MzxXZLxGfDz79 f+apt/nUuS5z7YWMf7ZT6AxyQ055B+Iw6ls+NeyX9BiApbYzAGcp2WDfsT4KAwDBCtyph+Evsul Qun3/EoX89uQROO48ScuMBUItPdYNup8HNItIrOb8apNllBASMeM7jCfYLyt9Ui2NPrJujYpzdV WaqeQ== X-Received: by 2002:a05:6214:4697:b0:8c6:1e19:80a4 with SMTP id 6a1803df08f44-8c7bc91b0d7mr58558936d6.26.1778692260161; Wed, 13 May 2026 10:11:00 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8c90c358539sm710716d6.41.2026.05.13.10.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2026 10:10:59 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wND6p-00000003cRB-0Am8; Wed, 13 May 2026 14:10:59 -0300 Date: Wed, 13 May 2026 14:10:59 -0300 From: Jason Gunthorpe To: Joonwon Kang Cc: Alexander.Grest@microsoft.com, amhetre@nvidia.com, baolu.lu@linux.intel.com, easwar.hariharan@linux.microsoft.com, iommu@lists.linux.dev, jacob.jun.pan@linux.intel.com, joro@8bytes.org, jpb@kernel.org, kees@kernel.org, kevin.tian@intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, nicolinc@nvidia.com, praan@google.com, robin.murphy@arm.com, smostafa@google.com, will@kernel.org Subject: Re: [PATCH RFC] iommu: Enable per-device SSID space for SVA Message-ID: <20260513171059.GP7702@ziepe.ca> References: <20260512151133.GD7702@ziepe.ca> <20260513170333.1235601-1-joonwonkang@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260513170333.1235601-1-joonwonkang@google.com> On Wed, May 13, 2026 at 05:03:33PM +0000, Joonwon Kang wrote: > > On Tue, May 12, 2026 at 02:51:38PM +0000, Joonwon Kang wrote: > > > > > Appreciate all your clarifications here. So, my understanding is that if > > > our system does not support ST64BV and ST64BV0 or if our device does not > > > distinguish between the posted write and the non-posted write regarding > > > PASID, then we can lift the use of the global PASID space. Can I say this? > > > > You should do what Robin said - just have your driver use a per-device > > PASID that it allocates and never use the global pasid allocator. > > > > To do this lightly re-organize the SVA code so the driver can supply > > its own PASID, and in this mode we wouldn't activate the ENQCMD > > features in the mm. > > Ah, we could actively disallow EL0 to execute ENQCMD-like instructions > when the device driver explicitly shows the intention via a new API like > `iommu_sva_bind_device_pasid()` that Tian mentioned earlier. You shouldn't need to do anything like this. All you need is to ensure that mm_get_enqcmd_pasid() returns IOMMU_PASID_INVALID so long as a the normal iommu_sva_bind_device() hasn't been called. Once it is called it is fine to allow the ENQCMD. Your new iommu_sva_bind_device_pasid() needs to establish the SVA and attach it without triggering mm_get_enqcmd_pasid(). The arch code is required to block the ENQCMD like instructions when IOMMU_PASID_INVALID. Devices that can mmap an ENQCMD sensitive BAR region must not do so unless iommu_sva_bind_device() has been called. > To allocate a per-device PASID, I think we should do it using > `dev->iommu_group->pasid_array` instead of making the device driver No, make the driver manage this, don't mess with the core code. PASID isn't supported with multi-device groups already. Jason