From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 7C2EB3D47CD for ; Fri, 13 Mar 2026 18:31:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773426687; cv=none; b=AmT/9BIyp532TBbyV231KxroS+LQSWBfZy92/U2EbVrkn2ZqW4KV81G5BY217btSKQ5ySHtzdr1pQ+3eUVmc0OWe8d0WZmdLNkGM5QI0g1P6hgeuhhR6gzznJAwcKo/EjG5MVHmVxI3TZOQDvls9yeypmvZG+6XVhveH/jtitUo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773426687; c=relaxed/simple; bh=0qxNb0CImZ7Y6yg+F786kCKDYDie+t88orCSqmVuTBQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q06mJj3KKGkPXwS1SdInvqSpYwwRYFKP2OtXX4f5UJahXA9imxDfPKmZxk+2XVYicDDpoDKSU60ezpIV/NGtn0g080b4jeWTOlpDEWjhewW2M05K7BYulwCZUqR0PJHP5WV0UQDiWTquGXxZtQTFuzBUtDEbN7PVbRO1r41A918= 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=aEn/Dcan; arc=none smtp.client-ip=209.85.222.171 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="aEn/Dcan" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-8cd7ecedf2cso255807185a.3 for ; Fri, 13 Mar 2026 11:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1773426685; x=1774031485; 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=zQGCXWZbNaSYnb2f/K2OJx848xGu9ABhmecVVHvXBkw=; b=aEn/Dcan9fbzdOpDqq8UJchJPC7LtsnN15ih5exltAYBYXiuVJ1fkBrsLUlf4GL2Z6 ENqdDAJ7ZI2jSEq4eWYATlImM+WU8RCjOFM9Pz+IC1MWKD3Pfp2qkmlgk++MUtVtRf5x 4fs9/gn0+gBqMBsgLvHjDuiKe/H5xKGkhlopTBkiZeETrAFjzzhxj8ZA8Zs75vOS+9qG xwBiP7icnYblODWtVEUdp4JUatgckLHlWDkn3uGei6gQDS4UcRlv6N2scjKFyav0hh5w Qrib41uAs7H3K70g8Hfwn4oerEX1D5xRz99Td27gP6HhlHRsTkSu/VegMsx1OVyYKqw3 QCUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773426685; x=1774031485; 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=zQGCXWZbNaSYnb2f/K2OJx848xGu9ABhmecVVHvXBkw=; b=opRG4ofBjJL/HfBizHj2fF2XvakeIiSFm+RokLdkgyPX+jGvrTF4/npMBtsbWzNNX0 maojJeaIYVeQdYN6UQ58pg/idwveOZ3/11usxo9VJQ96cFhPMwxqkDRivphnSiGOQGar aCugu+I7pesyfmh0zqdLVvYXAxycIrZM63JMUIZyGtIlLPkFxDkzxgsNDWcuYYgWeCQ8 uydFQi+7R2ULkS+plPeeJ4uL4Gghyjqb50io9dM2jFSSZqqfzoGUwa8FXH/Tbh+EZxyS D62K9TjxBmFn0nnwislSP0167NrDhPxl9CvsXzuDLWbYZrGHiDulL7RnGKZ9SzBQgU1z 23CA== X-Forwarded-Encrypted: i=1; AJvYcCWoLzZidbUQfptD3tf/LZakpk2xBNswSfZ2H+GkNqyqxYaIlSg1iblbIdAzk6/j6hEv7e0l1jpXm20gpr8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5I/MAPo1mft/7RvTYbysENBF9jWOVwjv3RKATeX8ArSCHIwKE e4sWqCaY4ezQoAk/tINQ4U9jKWVd8Dru1b4mvgFg4PMfQ7KNpKmPCYDeQJ6dyljidAg= X-Gm-Gg: ATEYQzy2oIw8p8f0/xLgv0ZEULx6wpT6Un8BEo2SWV+0i2r6COpJKiDCGkgMhfbKtWA jyh7JeKYYUqWBzgIJpsKVFgGIxOdGXfWXPptGFhfERTKOvzT9DXZtSWRamYUTrCfLYVk5xz0q5k 7MHRDc668rgnIB4dgfjJkfvTQIrzT++LpoNBEwmnRCOWF4K8+QlhJTfsgWu0jsjxSNLDbZYJIoa c1yLQ47RxeG3Lncqb2MHGsZpBQlscUQFu7En1fUHqWx4H51lXkV5/OxpcRlSQnjJXAbwMZwKDmI tJE/010p4V2AbJ5tH0qMGNi46aqEPRZRXyCS6i1L8qXSyoxni4DeG3Jmbsc4A0thYn2k2uJC56z GW9lgUXkT8RuHnXTP+4kQV99BDmmRr3RatYchD+bDC3/rhUb/3n2x4sXWkVdyJRC1Ac/KH1HO08 SEN2A/iYW/exIUc5yW6oH3dVeoGmENixqT+3sSvMArKu7hwJsPGSPj6C0xA3/tn9AuXdKUA7V+b lsB/GQF X-Received: by 2002:a05:620a:254f:b0:883:c768:200a with SMTP id af79cd13be357-8cdb5ab3617mr580862385a.32.1773426685412; Fri, 13 Mar 2026 11:31:25 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-112-119.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.112.119]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cda2152a41sm611787885a.43.2026.03.13.11.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 11:31:24 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1w17IB-00000007Lp5-3hF7; Fri, 13 Mar 2026 15:31:23 -0300 Date: Fri, 13 Mar 2026 15:31:23 -0300 From: Jason Gunthorpe To: "Aneesh Kumar K.V (Arm)" Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Kevin Tian , Joerg Roedel , Will Deacon , Bjorn Helgaas , Jonathan Cameron , Dan Williams , Alexey Kardashevskiy , Samuel Ortiz , Xu Yilun , Suzuki K Poulose , Steven Price Subject: Re: [PATCH v2 1/3] iommufd/viommu: Allow associating a KVM VM fd with a vIOMMU Message-ID: <20260313183123.GK1704121@ziepe.ca> References: <20260309111704.2330479-1-aneesh.kumar@kernel.org> <20260309111704.2330479-2-aneesh.kumar@kernel.org> 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: <20260309111704.2330479-2-aneesh.kumar@kernel.org> On Mon, Mar 09, 2026 at 04:47:02PM +0530, Aneesh Kumar K.V (Arm) wrote: > Add optional KVM association to IOMMU_VIOMMU_ALLOC by introducing > IOMMU_VIOMMU_KVM_FD and iommu_viommu_alloc::kvm_vm_fd. > > When the flag is set, iommufd validates that kvm_vm_fd refers to a KVM > VM file and stores a referenced struct file in the vIOMMU object, so > later iommufd operations can safely resolve the owning VM. > > This is preparatory plumbing for subsequent patches that bind TDI state > to the associated KVM VM. > > The patch also switch file_is_kvm from EXPORT_SYMBOL_FOR_KVM_INTERNAL to > EXPORT_SYMBOL_GPL so that iommu module can use that. I'd want Sean to approve this.. But given we once discussed it is better to hold on to the file * than the kvm as it leaks less kvm stuff I think this is the right approach. > #include > #include > +#include > #include > > struct device; > @@ -58,6 +59,7 @@ struct iommufd_object { > unsigned int id; > }; > > +struct kvm; That is a weird place to put the forward declaration? How about at the top of the file with the others? > +/** > + * define IOMMU_VIOMMU_KVM_FD - Flag indicating a valid KVM VM file descriptor > + * > + * Set this flag when allocating a viommu instance that should be associated > + * with a specific KVM VM. If this flag is not provided, > + * @iommu_viommu_alloc::kvm_vm_fd is ignored. > + */ > +#define IOMMU_VIOMMU_KVM_FD BIT(0) BIT isn't used in this uapi header, lets not start. Other cases are using an enum to group the flags > /** > * struct iommu_viommu_alloc - ioctl(IOMMU_VIOMMU_ALLOC) > * @size: sizeof(struct iommu_viommu_alloc) > - * @flags: Must be 0 > + * @flags: Supported flags (IOMMU_VIOMMU_KVM_FD) So you can say 'see enum xyz' here > @@ -1105,6 +1115,7 @@ struct iommu_viommu_alloc { > __u32 data_len; > __u32 __reserved; > __aligned_u64 data_uptr; > + __s32 kvm_vm_fd; Add padding to keep to 8 byte alignment > @@ -5481,7 +5481,7 @@ bool file_is_kvm(struct file *file) > { > return file && file->f_op == &kvm_vm_fops; > } > -EXPORT_SYMBOL_FOR_KVM_INTERNAL(file_is_kvm); > +EXPORT_SYMBOL_GPL(file_is_kvm); Probably put this in its own patch Jason