From: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
To: Will Deacon <will@kernel.org>, Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: kvm@vger.kernel.org, Steven Price <steven.price@arm.com>,
Julien Thierry <julien.thierry.kdev@gmail.com>
Subject: Re: [RFC PATCH kvmtool 09/10] vfio/iommufd: Add viommu and vdevice objects
Date: Mon, 11 Aug 2025 11:46:09 +0530 [thread overview]
Message-ID: <yq5ajz3agz86.fsf@kernel.org> (raw)
In-Reply-To: <aJX089pd81f6vMCu@willie-the-truck>
Will Deacon <will@kernel.org> writes:
> On Mon, Aug 04, 2025 at 11:33:27PM +0100, Suzuki K Poulose wrote:
>> On 24/07/2025 15:09, Aneesh Kumar K.V wrote:
>> > Will Deacon <will@kernel.org> writes:
>> > > On Sun, May 25, 2025 at 01:19:15PM +0530, Aneesh Kumar K.V (Arm) wrote:
>> > > > + dev_num = vdev->dev_hdr.dev_num;
>> > > > + /* kvmtool only do 0 domain, 0 bus and 0 function devices. */
>> > > > + guest_bdf = (0ULL << 32) | (0 << 16) | dev_num << 11 | (0 << 8);
>> > >
>> > > I don't understand this. Shouldn't the BDF correspond to the virtual
>> > > configuration space? That's not allocated until later, but just going
>> > > with 0 isn't going to work.
>> > >
>> > > What am I missing?
>> > >
>> >
>> > As I understand it, kvmtool supports only bus 0 and does not allow
>> > multifunction devices. Based on that, I derived the guest BDF as follows
>> > (correcting what was wrong in the original patch):
>> >
>> > guest_bdf = (0ULL << 16) | (0 << 8) | dev_num << 3 | (0 << 0);
>> >
>> > Are you suggesting that this approach is incorrect, and that we can use
>> > a bus number other than 0?
>>
>> To put this other way, the emulation of the configuration space is based
>> on the "dev_num". i.e., CFG address is converted to the offset and
>> mapped to the "dev_num". So I think what we have here is correct.
>
> My point is that 'dev_num' isn't allocated until vfio_pci_setup_device(),
> which is called from __iommufd_configure_device() _after_ we've called
> iommufd_alloc_s1bypass_hwpt().
>
> So I don't see how this works. You have to allocate the virtual config
> space before you can allocate the virtual device with iommufd.
>
I did fix that in https://lore.kernel.org/all/yq5att31brz2.fsf@kernel.org/
-aneesh
next prev parent reply other threads:[~2025-08-11 6:16 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-25 7:49 [RFC PATCH kvmtool 01/10] vfio: Associate vm instance with vfio fd Aneesh Kumar K.V (Arm)
2025-05-25 7:49 ` [RFC PATCH kvmtool 02/10] vfio: Rename some functions Aneesh Kumar K.V (Arm)
2025-07-27 18:20 ` Mostafa Saleh
2025-07-29 4:53 ` Aneesh Kumar K.V
2025-05-25 7:49 ` [RFC PATCH kvmtool 03/10] vfio: Create new file legacy.c Aneesh Kumar K.V (Arm)
2025-07-27 18:23 ` Mostafa Saleh
2025-07-29 4:59 ` Aneesh Kumar K.V
2025-05-25 7:49 ` [RFC PATCH kvmtool 04/10] vfio: Update vfio header from linux kernel Aneesh Kumar K.V (Arm)
2025-07-27 18:23 ` Mostafa Saleh
2025-05-25 7:49 ` [RFC PATCH kvmtool 05/10] vfio: Add dma map/unmap handlers Aneesh Kumar K.V (Arm)
2025-07-27 18:25 ` Mostafa Saleh
2025-07-29 5:03 ` Aneesh Kumar K.V
2025-05-25 7:49 ` [RFC PATCH kvmtool 06/10] vfio/iommufd: Import iommufd header from kernel Aneesh Kumar K.V (Arm)
2025-07-27 18:25 ` Mostafa Saleh
2025-05-25 7:49 ` [RFC PATCH kvmtool 07/10] vfio/iommufd: Add basic iommufd support Aneesh Kumar K.V (Arm)
2025-07-27 18:31 ` Mostafa Saleh
2025-07-29 5:12 ` Aneesh Kumar K.V
2025-07-29 9:38 ` Mostafa Saleh
2025-05-25 7:49 ` [RFC PATCH kvmtool 08/10] vfio/iommufd: Move the hwpt allocation to helper Aneesh Kumar K.V (Arm)
2025-07-27 18:32 ` Mostafa Saleh
2025-07-29 5:14 ` Aneesh Kumar K.V
2025-07-29 9:43 ` Mostafa Saleh
2025-05-25 7:49 ` [RFC PATCH kvmtool 09/10] vfio/iommufd: Add viommu and vdevice objects Aneesh Kumar K.V (Arm)
2025-07-21 12:27 ` Will Deacon
2025-07-24 14:09 ` Aneesh Kumar K.V
2025-08-04 22:33 ` Suzuki K Poulose
2025-08-08 13:00 ` Will Deacon
2025-08-11 6:16 ` Aneesh Kumar K.V [this message]
2025-07-27 18:35 ` Mostafa Saleh
2025-07-29 5:19 ` Aneesh Kumar K.V
2025-07-29 9:41 ` Mostafa Saleh
2025-07-30 8:13 ` Aneesh Kumar K.V
2025-07-30 14:15 ` Mostafa Saleh
2025-07-31 4:39 ` Aneesh Kumar K.V
2025-08-04 15:07 ` Mostafa Saleh
2025-05-25 7:49 ` [RFC PATCH kvmtool 10/10] util/update_headers: Add vfio related header files to update list Aneesh Kumar K.V (Arm)
2025-07-27 18:35 ` Mostafa Saleh
2025-07-27 18:19 ` [RFC PATCH kvmtool 01/10] vfio: Associate vm instance with vfio fd Mostafa Saleh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yq5ajz3agz86.fsf@kernel.org \
--to=aneesh.kumar@kernel.org \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=steven.price@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.