From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 D89EC3E51EC for ; Mon, 18 May 2026 09:06:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779095218; cv=none; b=br0Uu4eQbXt4po5mzeXpJm4CT5WSfIUrkSMgoVyuaAZhnRZug4lKeHWhcWRdpD/SbQpfN3nwRo+tZ0zk6k7wbGA7md6e1nCLZGBZH1zjhslr3KElhrJ06YnQ1TuBFwiWB2qj4TdEn1doz4cRnoG0D8lRILbr7GmeOaKddyVW8vk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779095218; c=relaxed/simple; bh=2qZ5Z7v49mZdp9tTq4z3AExRs8n1ya/74CMZmv6hrg8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FrWD6ABCajwsIdpRTHuoF3xAS3eILAWpzryG3q3QSK8L8KAuPLxbSXC7hjJzQhzbWdCo6Ml5ETsUEdEIJGn9xNUJfbhxUHfo1Dd5vRys3G1+tCq/QzfcE9dv0A4Bb6a3StdNjHGg+gSfTEyaYW3ztC/pqzieyihsvkDR80SxMW8= 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=OVljQjDA; arc=none smtp.client-ip=209.85.214.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="OVljQjDA" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2baedd2fd43so15354135ad.1 for ; Mon, 18 May 2026 02:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779095216; x=1779700016; 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=UOPk9lUKmu3dyT3km0TD9pgYxeOvFnYVbbb0LRmiqBQ=; b=OVljQjDAL8S3UHogU1s48/SsO6XEPRxZ5ypnxSpGV/5d9vD/Jzh5Qg5BMA09jUXlyf 8Ui6QvhfevrZTEqEZcTJWbGYkJ8ZQGtQDk9KaVrzf7g5yV9C3lYG8ZaVKyQ4Oj7Rl1TV RHVpf8pRfPUXbjP3ywK3NrZkroEr4/henxOQ2GQ00HzUte1G2XzO1Fq3595NPH7beiFt 20xUBOawkSb1tz+8x9INcvsr1wxfkJDTXbF5un4BZb0o9lpJw1p0al5F591QEQuSwzE3 PIz5Qv1KQaQtAijnFfxUQb9HGT9tjB/QtaJ0IZzUfXYlbYwlFVPl7mKGBmm+aCLsBkkI OH8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779095216; x=1779700016; 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=UOPk9lUKmu3dyT3km0TD9pgYxeOvFnYVbbb0LRmiqBQ=; b=dpg9XyBC5AqFzihDcduLVxGOKX6lJj8f12PHp/IwTtztxDbTYHQflOG5i+Sfxqahtd dNSAdZHsuDrasdJT4c6AIRc2rzPX6Odamdi3V4zQaUEG5cJk4QFLmMDvuJs0U0kXXWZE Yw9lweFElBjGkmgtdUIqdSi1ivPP5wY7eM9EGitCtSF4ZMJfv8DMsPWwQsyelwvjm48i n6mY8hp/L4gVthO6WhyD3bWbS1WeA2cPCV+fmHmF4H0lYAB0rO7YQi58P83iBYjDfA80 g/Q+TycQlJbUj9eurgjU3Mc3XjEgBvCLg0uMwRGFfP17O4nOyMUwqH6Ns8x39eHCg5Xb gfnw== X-Forwarded-Encrypted: i=1; AFNElJ92hP8s4TMaVVcaR9rBMLox0zjzpK+I48TjRiaRE6nlTeGk9niaDjUMgZ+xvs/7MhUAIMo+WvDe+AVFa+Q=@vger.kernel.org X-Gm-Message-State: AOJu0YyJe6H+sFHtbLp2TsbBTLF8zmjdOOyftKmn4kggnHu3ZXHCRB/E 0Sre3RYQcsQBo3YJQwSoxE0v4xor8Lx4wP48qDW9m8D/XHqmPOxbq993wgK6aKaHbAQNqTDT8yR bnya6nfChtlCN4jo5Qb5apR1O/Q== X-Received: from plbv16.prod.google.com ([2002:a17:903:44d0:b0:2b2:488e:b71]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:384c:b0:2bc:6d46:ae9d with SMTP id d9443c01a7336-2bd7e8ca92cmr152641245ad.17.1779095215808; Mon, 18 May 2026 02:06:55 -0700 (PDT) Date: Mon, 18 May 2026 09:06:54 +0000 In-Reply-To: <20260515231808.GQ7702@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260515231808.GQ7702@ziepe.ca> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260518090654.730478-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, kirill.shutemov@linux.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, joonwonkang@google.com, joro@8bytes.org, jpb@kernel.org, kas@kernel.org, kees@kernel.org, kevin.tian@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 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". What prctl_enable_tagged_addr() semantically requires here seems to be only checking if SVA is activated or not regardless of whether EL0 can execute ENQCMD instruction; the function wants to return error if SVA has been activated when LAM is to be activated as they are mutually exclusive [1]. So, I think we should leave it as-is. I am adding the author Kiryl as a reviewer for confirmation. Since it is now possible with this patch to activate SVA without involving EL0(for ENQCMD-like instructions), callers should be able to distinguish between if SVA is activated and if EL0 can execute ENQCMD-like instructions in addition to the SVA activation. mm_valid_pasid() is for the former and mm_get_enqcmd_pasid() is for the latter. So, I think there will be loss if we make the latter API serve for the former. Or, I guess we could rename mm_valid_pasid() to be more specific like mm_sva_activated() or mm_sva_in_use(). What do you think? > I didn't try to check the rest closely but the approach looked sane to > me Thanks. Sashiko reported valid points [2] and I will handle them in the meantime. [1] https://lore.kernel.org/all/20230312112612.31869-12-kirill.shutemov@linux.intel.com/ [2] https://sashiko.dev/#/patchset/20260515094605.3195841-1-joonwonkang%40google.com Thanks, Joonwon Kang