From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 C87D2384CCA for ; Mon, 25 May 2026 15:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779722968; cv=none; b=Lm8poKX+pRtcSBPEeTDMvXWMp8DZxZb9m1UlRV/LmoaQ0uptxhSDhotHQQH5AMXi8z9GEFnl4et1LVeXbkqoYX1QoRGbYL2K22tZEP1gmhRRgHgwOqA+qwsUUtt+8fgUZYKwIfRiI3wWitOeHXYv4es5SLUIMKyGSUBntXxXMp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779722968; c=relaxed/simple; bh=fKq4aVwbvax1aR4yy8POrWwpM2YYfG4hq56u4z+Cm4w=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bfR9tlZQwp68IiG6EgV09rRFZRh4btNoVEtQcpbXGpgbLugUrljrREf8ZxXcvCxPH7XjQxyM2h/4LEQ7koDGosam72dt8k2haSgOcHvY3HDIIoFdac3jN81loBETxGHqvZlxTXhFjD8oZPKwEn9DrEsY2Vdn/sq9HZpHjwj2uKE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kiX4V3BO; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kiX4V3BO" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-82fa1c94b37so9734569b3a.0 for ; Mon, 25 May 2026 08:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779722966; x=1780327766; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4b1oC5HhUnRhm7z2afBn84VUcPa5B5EWRXQvz0Iqfxc=; b=kiX4V3BO4SABqVC3Im179fX1cVw07HRywHh8QGfgQBY1D7Y+CCDoh5DKriMaLZ74Z3 vuk1ch0bbP4fmAPH7OGlc44gXUci4pM079UEdm4VqWcikSIclX46Qw/VmLQ5q0N/oF1P Hu36euJcbHDtpiWuc4JOnYZxabwW77S0vBgXD8X9EU014MLu3uSMRXiPzTPsOKfTc7ny ejd6/RfcIT44d1w7pQxmhvPm1D2QrYqP1j0lvhH+axiKMlRbFlZz+40Vhdi/kQEc/L3H Ctk7yPxH03JUTuN35ga0zJecJjmH/HSdJAbMmEIbI0SINRCbVJi0Wk0xrahn5fqlHocV 2UaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779722966; x=1780327766; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4b1oC5HhUnRhm7z2afBn84VUcPa5B5EWRXQvz0Iqfxc=; b=TzoLZOmzO7UgkvreOSvS9uIDosSGi1VWx5ADMpbsQUzuJRrPu1+TTT0pN8R/SzraNW 4T8PaAgDBC85odtFE9Plt4jRGybsjDyx/mmdLuYwo7pAVyzbslvU9U8qIjQJv3luWgPL Bx5BS4X6O2apuwEKrP7W6iYLUBuryWH//J2Tf7y81CMSJ4bU1aGXXMo/uanO6TpVjBRM GMfSuk2a/qZ9iDsI4zDChTCU5+I/zJ/fiyNHZ6ZnnO42HEzRNoTYuNbfq9qrtORYnAb5 NolCrLYIrTK9mW7lnf7HkCS7osjCuH8NEvZFO2k8i1Gt8jhTgNSpajYyWpiXTr6VmJiA 0Zug== X-Forwarded-Encrypted: i=1; AFNElJ857atWfAzh050lpbTOa9hDV3MBkLXYfSJsHDEbk9VAcGbA6sXwT0IfhOkLXH61i0saLCQgyMif/0Fr3Is=@vger.kernel.org X-Gm-Message-State: AOJu0Yyt6CKcWwb+mix4n0Sr3DAROCAR6U1qxoX+x2rNYaY9/1YI8mTq b7AFXdeuwjdrXsCxAd3TBocBO9wv2PETZeOxaRwSxesBLZqE2GFu6CTLqwI4tHbfbIermY5NOzn N3Utjb1xvJfDg/nuzKFwCsWFsOA== X-Received: from pffv22.prod.google.com ([2002:aa7:8096:0:b0:83f:8b6a:7319]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:808f:b0:837:21dc:6ad4 with SMTP id d2e1a72fcca58-84160b8441cmr10891888b3a.2.1779722965809; Mon, 25 May 2026 08:29:25 -0700 (PDT) Date: Mon, 25 May 2026 15:29:24 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.54.0.746.g67dd491aae-goog Message-ID: <20260525152924.524721-1-joonwonkang@google.com> Subject: RE: [PATCH v2] iommu: Allow device driver to use its own PASID space for SVA From: Joonwon Kang To: kevin.tian@intel.com Cc: Alexander.Grest@microsoft.com, alexander.shishkin@linux.intel.com, amhetre@nvidia.com, baolu.lu@linux.intel.com, bp@alien8.de, dave.hansen@linux.intel.com, easwar.hariharan@linux.microsoft.com, hpa@zytor.com, iommu@lists.linux.dev, jacob.jun.pan@linux.intel.com, jgg@ziepe.ca, joonwonkang@google.com, joro@8bytes.org, jpb@kernel.org, kas@kernel.org, kees@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mingo@redhat.com, nicolinc@nvidia.com, peterz@infradead.org, praan@google.com, robin.murphy@arm.com, ryasuoka@redhat.com, smostafa@google.com, sohil.mehta@intel.com, tglx@kernel.org, will@kernel.org, x86@kernel.org, xin@zytor.com Content-Type: text/plain; charset="UTF-8" Hi Kevin, thanks for your review. > > This commit resolves the issue by allowing device driver to maintain its > > own PASID space and assign a PASID from that for the process-device bond > > via a new API called `iommu_sva_bind_device_pasid(dev, mm, pasid)`. Doing > > that, however, will disallow the process to execute the ENQCMD-like > > instructions at EL0. It is because the process cannot change its PASID in > > IA32_PASID(or ACCDATA_EL1 on ARM) for each device without the kernel's > > intervention. For this reason, calling `iommu_sva_bind_device()` and then > > `iommu_sva_bind_device_pasid()` for the same process will not be allowed > > and vice versa. > > > > Currently, there is a limitation that a process simultaneously doing SVA > > with multiple devices with different PASIDs is not supported. So, calling > > `iommu_sva_bind_device_pasid()` multiple times for the same process with > > different devices will not be allowed for now while that for > > `iommu_sva_bind_device()` will be. > > > > Another limitation is that a process cannot do `iommu_sva_bind_device()` > > if it has ever done `iommu_sva_bind_device_pasid()` even though it has > > been unbound after use. > > Why not making it clean in one step instead of leaving many unsupported > cases which are likely required soon in this "1" to "many" transition? > Since I did not know much about the IOMMU team's future plans on the IOMMU core structure, I narrowed down the scope just enough to resolve our specific problem and avoided introducing big change. But now that I have two queries to support the 1-to-many relationships in this patchset, not in a later one, I think it is fair enough to start working on it now. I will try it and lift the limitations. > for each mm: > - one global pasid for ENQCMD or ST64BV0 > - an array of device local pasids tracked in [struct device *, pasid] tuple. > > upon gp fault or equivalent, fetch the global pasid. > > upon device-specific bind, match [dev, pasid]. > > > > > Suggested-by: Jason Gunthorpe > > Suggested-by: Kevin Tian > > Signed-off-by: Joonwon Kang > > --- > > v2: Reuse iommu_mm->pasid after SVA bound by > > iommu_sva_bind_device_pasid() > > is unbound. > > No idea what it talks about. > There was a bug in v1 that the second call for `iommu_sva_bind_device_pasid()` failed after the first call with a different PASID was released. Will rephrase it in a clearer language in v3. > btw a new kAPI always needs accompanied users to review together. Currently, the only known expected user of the new kAPI is our team. Since I test if the patch resolves our problem before sending it, I believe it should be good enough. Do you mean more than our team by "accompanied users"? Thanks, Joonwon Kang