From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 97ED42DC765 for ; Tue, 19 May 2026 08:11:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779178311; cv=none; b=pXBpSSHT04+Si5LAMnKKom4y6YUWi2bFxiR0Ez0Nr1eHFHi0PA0e8vhKY9s4eJgXsCAvLYQ6S3bkxWctJKDAgTx4blDemvwlHS82EeXTbXP1+J2oUtp8zQPsrvLB4aag7xliLk7czwqEYPWmXqBnhpSBupfVdNHYF2lT6uBJps0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779178311; c=relaxed/simple; bh=yreApj1csXszXO5CKw+Pkc1FnIuaiI6WFdf2uHW2Ogs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IEJSflGcO6TZ0bfeIDpXdkvaCs8IaVishbjZIdrJ/CN4tYv/esH97qe+19kAKfwGLXB3BU2ALsbItFPwsMS4uZ4PE5dtNlryb+/rNuF3vPshxiXgckg392CYMtt9oHOn29ahrMI0kSSzAMwygSD9IaMuD6h1Rr0A+9elESIaAsk= 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=RChfONY/; arc=none smtp.client-ip=209.85.214.202 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="RChfONY/" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2b2e8bba2e6so48454695ad.1 for ; Tue, 19 May 2026 01:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779178310; x=1779783110; 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=7ut72Gkptn/NBySJV/auF15VVBqcdKlrwYtyzCOsNz0=; b=RChfONY/wLoOIM86FfYZXprI0QqDt5bIQ/DYcAsCC9GYRHnUa3bpF+OLWzT2yWLM0L V+yEABIJvQEsipvNmoL+VR+3MqX9IkUq6MfcyS5e9rvNb4dT+hv5t/xAVb0Nsmy/YzwF qk/C32YB/g4lIIorkPiphf4YCSXKBoCjrfPe8K5HjGzOYlfiBNVeu0JyV75LwIVTmg8Y hjwOqul3Jbug/4aDtQy3PmGg027QQtuMx449R737UwQYWk4du+elM7HBWGzlHH5FNH6b ib1zWjbY4UlbC9BYP/7g/agDmHUL1vLEgI2X55SHBM1py6ClrWbnx2YShhtDmv7rMRP3 FsqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779178310; x=1779783110; 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=7ut72Gkptn/NBySJV/auF15VVBqcdKlrwYtyzCOsNz0=; b=LhMKl6VZyK1BxmO3k//05vpW+hQRVwpaLJwU2fzlamrq8t8Y9t6q+9pctRoJhT5mY2 uILEpa4PFQo2DB4Lm5IiB1M1KvJiwcx0gbWW7Ni8WlkP89EFsagX664oG9UVdnyTPVKY vkfsXZxHwASeltyMdMDRhmnNOtRqRkM27cXCtkVaclZJ+jk22o6qwcze0Qv6cgvdtVpy 99rsaemKFr/ib+GTFmCumKsFscBleaSSlPyuhLXeUd6SAobrcj/25YCSiF+FBuKm/jeH NVFzo3/7aik91ypK/WYKmIkW7KqNE51ROwBhuyo8+6tmV/fUZuubLsIHvdcDl+SsXNeg VZCQ== X-Forwarded-Encrypted: i=1; AFNElJ88cJPpxf/F2CXUjOfBL4IwohTmijL6CSjspdRRHWKpIXw3SzT3tApon1xlNFaKwL1w1Nu/5C33PUDiYrY=@vger.kernel.org X-Gm-Message-State: AOJu0YwiZyi1rojmWnT8FR961BDRu7FRX2WU5D09xwUyuuncCUujBh/D fFBaF/WkoUtnVnalbg7083hLF3qgA4ehN1T4zvsssUQLbwjgkAxiRww9z8VFNfBCdLSnl2bv0e1 LT0Q4OzSlN+lG2kvf0XuLEF0gtw== X-Received: from plvv3.prod.google.com ([2002:a17:902:d083:b0:2be:3026:1d0f]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f08d:b0:2bd:2051:13ed with SMTP id d9443c01a7336-2bd7e87ef1amr129360345ad.23.1779178309741; Tue, 19 May 2026 01:11:49 -0700 (PDT) Date: Tue, 19 May 2026 08:11:47 +0000 In-Reply-To: <20260518175249.GS7702@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260518175249.GS7702@ziepe.ca> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260519081148.1301245-1-joonwonkang@google.com> Subject: Re: [PATCH] iommu: Allow device driver to use its own PASID space for SVA From: Joonwon Kang To: jgg@ziepe.ca 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, joonwonkang@google.com, joro@8bytes.org, jpb@kernel.org, kas@kernel.org, kees@kernel.org, kevin.tian@intel.com, kirill.shutemov@linux.intel.com, 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" > On Mon, May 18, 2026 at 09:06:54AM +0000, Joonwon Kang wrote: > > > On Fri, May 15, 2026 at 09:46:05AM +0000, Joonwon Kang wrote: > > > > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c > > > > index 0ca3912ecb7f..61e2e52105e5 100644 > > > > --- a/arch/x86/kernel/traps.c > > > > +++ b/arch/x86/kernel/traps.c > > > > @@ -864,6 +864,8 @@ static bool try_fixup_enqcmd_gp(void) > > > > return false; > > > > > > > > pasid = mm_get_enqcmd_pasid(current->mm); > > > > + if (pasid == IOMMU_PASID_INVALID) > > > > + return false; > > > > > > If you do this then probably you should get rid of mm_valid_pasid(), > > > mm_get_enqcmd_pasid() already has the NULL check so the two functions > > > are kind of pointless. > > > > > > You also missed the other place calling mm_valid_pasid() that should > > > really be sensitive to this as well: > > > > > > static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits) > > > { > > > [..] > > > if (mm_valid_pasid(mm) && > > > !test_bit(MM_CONTEXT_FORCE_TAGGED_SVA, &mm->context.flags)) > > > return -EINVAL; > > > > > > Make that removal a prep patch > > > > > > > Thanks for pointing this out. I think mm_valid_pasid() is to check if SVA > > is currently in action while mm_get_enqcmd_pasid() is to get the PASID for > > "ENQCMD instruction execution". > > > Since it is now possible with this patch to activate SVA without involving > > EL0(for ENQCMD-like instructions), > > I see, this thing about which is about LAM should remain, yes > > But all the "EL0" machinery about trapping and enabling ENQCMD should > be moved over to mm_get_enqcmd_pasid() and never call mm_valid_pasid() Yes, it makes sense. Let me fix that in the next version. Thanks, Joonwon Kang