From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796239237; b=dbr1K+r7odWrHO2NK3LHJUCTLalpjzlzVE18I0aEhvZXqmm5TVmmEOsyWx9f9ZRQwIDd W/yOR4LBexLNGeHYXq7omoFEouH98bmgqOmLnwSlh2VgGrv8CT+nlOEfkZIT6tTLJo5zx WIHEaL9e/bGgW4UfhNBcaGhE1sz9rEsTbk1aqTYkdVtnjrU/myzc3oBaMrz0mDxRO2hms LIBtx+rt9fniFxxS0EOhnouQCZZlqGkjOqax2tQgn8qWwI1fwurm3GVIZqF4Tq/dzpkiF y7vmoD88OlHy+Mhyj6JnjD+t4ZDWnYl5UtK913ovuogk3SQlgoj2bC1SgJkLln3h++w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796239237; h=Received:DKIM-Signature:Mime-Version:Content-Transfer-Encoding: Content-Type:Date:Message-Id:Subject:Cc:To:From:References: In-Reply-To; bh=fnzPREwRNBLhvQFsjyliBY1NA1xtnpuhUDUPSqm0LCU=; b=A21GuubqqFX+N2K3oK+iE8au5E7QLR7R1peVhdsUYZquAyhgMz88sI5ofj/FkZyJTCPt gMCUeX1Q3agudXn+ynIcncZ0hvmyVHm0PlS6AZB04CKp1VWu7wimtF6aKW8BK8B6LzT4w JcKZEW9L0tPzytnOBb5AiLAlr0q8w28K8Zhtxmwzd7eaC3c82ScCDMjqf5HfH5ezKuPad IXR74rIoMDzFYAeanCuIh/lj3IQuLJirf9OxShpdRyJ8Teeis3ZMkj8T+pyeR16laYP91 z1Q24aYKzuSoCAvtyKR1c9UN6j0jNiEP0FSaLZBKDf3992ps5R7PIM0n/98zYG16EXA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cIhEPkFG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FBCE606A322; Wed, 2 Dec 2026 19:20:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cIhEPkFG Received: by smtp.kernel.org (Postfix) with ESMTPSA id D81261F00893; Wed, 2 Dec 2026 19:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796239236; bh=fnzPREwRNBLhvQFsjyliBY1NA1xtnpuhUDUPSqm0LCU=; h=Date:Subject:Cc:To:From:References:In-Reply-To; b=cIhEPkFGgLgGzhkGpKDRtvpbIAImoFQ0c96F2+j635tutbuFujFcDahH4xX5jD90t IFjFYXhmX+jS0XVJOwnLgQWYx28zBUjcsjxQV66l2RleY/YznDkdPlXeSkWSHpC4ct KhE97xdlkdqjhDR8IXhAaHaAnae3MMF9ovhWK12kYRxfS8zYR4UB9W5zRzyn5QUVEw +OP15nRi73hRraVkiHKiAA/UJbJdK2JMVoo//loN/aw9rK5RUr+F9qNaQ9yQvF/qoH knbk/825sxBvphDxwRVA9BtjLmsYzxPSETA4qyoFdmb9qQnKBl6WIbSw4vavblrqH/ VNuRfNf4WGq0A== X-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 02 Dec 2026 20:20:26 +0100 Message-Id: Subject: Re: [PATCH v4 1/5] rust: vfio: add common VFIO device handling Cc: "Simon Song" , , , , , , "Zhi Wang" , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , "Liam R. Howlett" , , "Lorenzo Stoakes" To: "Gary Guo" From: "Danilo Krummrich" References: <20261127224928.1511382-1-xinmengs@nvidia.com> <20261127224928.1511382-2-xinmengs@nvidia.com> In-Reply-To: On Wed Dec 2, 2026 at 4:58 PM CET, Gary Guo wrote: >> +/// The context in which a VFIO device reference is valid. >> +/// >> +/// Callback views can only be borrowed from the corresponding VFIO tra= mpoline. >> +/// They cannot be refcounted or shared across threads. >> +pub trait DeviceContext: private::Sealed {} >> + >> +/// A callback context in which VFIO keeps the device open. >> +/// >> +/// Registration data and open data are available throughout such a cal= lback. >> +pub trait IoContext: DeviceContext {} >> + >> +/// An ordinary device reference, without callback-specific operations. >> +pub struct Normal; >> + >> +/// The device is undergoing its exclusive first-open callback. >> +pub struct Open; >> + >> +/// The device is borrowed for a VFIO ioctl callback on the current thr= ead. >> +pub struct Ioctl; >> + >> +/// The device is borrowed for a VFIO read callback on the current thre= ad. >> +pub struct Read; >> + >> +/// The device is borrowed for a VFIO write callback on the current thr= ead. >> +pub struct Write; >> + >> +/// The device is borrowed for a VFIO mmap callback on the current thre= ad. >> +pub struct Mmap; >> + >> +/// The device is borrowed for a VFIO region-info callback on the curre= nt thread. >> +pub struct GetRegionInfo; > > That's a lot of type states. It looks like all of these are only used to = ensure > only corresponding vfio_pci_core callbacks can be delegated to. Are these= really > needed for soundness? I can understand that the `Open` one might be neede= d, but > the rest might be mergeable? I think Read / Write and Ioctl / GetRegionInfo are technically mergeable wi= thout introducing soundness holes. However, core_write() makes no sense as delegation from read() and vice ver= sa. It also makes no sense to call core_ioctl() from get_region_info(), so I'd = keep them separate.