[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] xen/virtio: Avoid use of the dom0 backend in dom0


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 6 Jul 2023 10:17:00 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ebr3eL0nExbOnagfNqFlIad5XC9VJWJ+dIUg48dt3K8=; b=EJq1yjsYdQnpJJaZFj1hmLB5rVPg9jb9Omu454ffJmFLX/nIVfG1Cc6cQEMxDeJAVVukGxoT7RP1umnch14W0RXUiFOS01D98Rp9Egih8ppXNwo4vkM1p1UyOlnp+B1EDVx66MV6xOROdL9Z/pZAXBNyhFxOBXbwz2+j2nu/ofvI5wDYyXcZPEEaJHLmer81V+dygHyTJqXEr7+rF0apgaQsk8HO7j8cbwfwBpIGkP+XtkwVhP9l0wI4CcvwPbjbDvpOCp91r0vid7VjnSPZpIgN52JtdltQooYOXX9w3yDQa7ID7KoPX12xkcAkV9Y3XSu6OkT7ykgSCwft2Y83qg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NlfysLimKAF6NbirKNIGaWhnU07ITXIjwyARK7Ek9UsMTMrVQ1oh/X+sS4klUMcBEz8CQ0wMpcfl+FUH7Tdv6f/C6C5Ur+UjeC6qj/5S3dM985Hp1USiLKU4JF3RWZI70Uh0FS/fSlfgTpXK48cR2Mq9g6bNmepE1Z/+OAf6/trs3/xZsI8DFKc6gfM1K6fTPxsn5+7rXFOIp8Q7iCKcDsOCnc/WjiNDuF02bw14/CKCGGvU1isDI6gIPAiMLvDTb4jcs6mNwR3QGU+JDvVk0v3lPolLbG7xTr6RrVONpsYpsk0tNyLYQhq+/qfjDCf9aKiWEZEUYxiqhdZfrpp7dA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Petr Pavlu <petr.pavlu@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, vikram.garhwal@xxxxxxx
  • Delivery-date: Thu, 06 Jul 2023 08:17:32 +0000
  • Ironport-data: A9a23:wZwIganq+rDK5RMIwqAVeuDo5gzIJkRdPkR7XQ2eYbSJt1+Wr1Gzt xIZWGuOMvvcMzHyetl1OY++8UoDvsKDm4A3QQQ6rC4wHyMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+a6U6icfHgqH2eIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE0p5K2aVA8w5ARkPqgU5AGGzhH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 b88LTEEXyyBvaW3yurqRONd1+h8K8a+aevzulk4pd3YJdAPZMmZBoD1v5pf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVklI3jOmF3Nn9I7RmQe1PmUmVv CTe9nnRCRAGLt2PjzGC9xpAg8eWxHyrCd1LRe3QGvhC2AyQnkEtLSIqTlqphtyk0WjufohbN BlBksYphe1onKCxdfHmRAGxqnOAuh8aWvJTHvc85QXLzbDbiy6eAmUHVSJQc9wOu8o/RDhs3 ViM9/vrCiZoq6a9Um+G+/GfqjbaES0cN2oLfyIHZQoD/dj4oYs3gw7PT9BsC6q8hJv+HjSY6 xeOoSsljrMfl/k3xr679lDKhTGrjpXRRwtz7QLSNkq94x9jIpaseYi1wUPG9vsGJ4GcJnGRs X5Bl8WA4eQmCZCWiDfLUOgLBKuu5fuOLHvbm1EHN50g8Sm9vn2uZ4Zd5BlgK0pzdMUJYznkZ AnUoww5zIFSP2GjaOl4apixFM0u5aHlGZLuUfW8UzZVSp14dQvC+T40Y0eVhjrpiBJ0zfB5P oqHe8GxC3pcEb5g0De9W+Ya1/ks2zw6wmTQA5v8ynxLzIajWZJccp9dWHPmUwzzxPrsTNn9m zqHC/a39g==
  • Ironport-hdrordr: A9a23:QrgGfq7A2YlwAb5tiAPXwAzXdLJyesId70hD6qkQc3Fom62j5q WTdZEgvyMc5wx/ZJhNo7690cq7MBHhHPxOgbX5VI3KNGXbUQOTR72KhrGSoAEIdReeygZcv5 0QCZSXCrfLfCVHZRCR2njFLz4iquP3j5xBnY3lvhNQpZkBUdAZ0+9+YDzrdXFedU19KrcSMo GT3cZDryrIQwVtUizqbkN1OdQqvrfw5evbXSI=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jul 05, 2023 at 03:41:10PM -0700, Stefano Stabellini wrote:
> On Wed, 5 Jul 2023, Roger Pau Monné wrote:
> > On Tue, Jul 04, 2023 at 08:14:59PM +0300, Oleksandr Tyshchenko wrote:
> > > **********
> > > 
> > > Part 1 (intro):
> > > 
> > > We could reuse a PCI config space register to expose the backend id.
> > > However this solution requires a backend change (QEMU) to expose the
> > > backend id via an emulated register for each emulated device.
> > > 
> > > To avoid having to introduce a special config space register in all
> > > emulated PCI devices (virtio-net, virtio-block, etc) I wonder if we
> > > could add a special PCI config space register at the emulated PCI Root
> > > Complex level.
> > > 
> > > Basically the workflow would be as follow:
> > > 
> > > - Linux recognizes the PCI Root Complex as a Xen PCI Root Complex
> > > - Linux writes to special PCI config space register of the Xen PCI Root
> > >   Complex the PCI device id (basically the BDF)
> > > - The Xen PCI Root Complex emulated by Xen answers by writing back to
> > >   the same location the backend id (domid of the backend)
> > > - Linux reads back the same PCI config space register of the Xen PCI
> > >   Root Complex and learn the relevant domid
> > 
> > IMO this seems awfully complex.  I'm not familiar with the VirtIO
> > spec, but I see there's a Vendor data capability, could we possibly
> > expose Xen-specific information on that capability?
> 
> That is also a possibility too. Also we could use a PCI conf register
> which is known to be unused in the Virtio spec to expose the grant
> capability and backend domid.

Capabilities don't have a fixed config space register, they are a
linked list, and so capabilities end up at different positions
depending on the specific device layout.  The only fixed part is the
range from [0, 0x3F), and that's fully defined in the specification.

Trying to define a fixed address for Xen use after the 3f boundary
seems like a bad idea, as it's going to be hard to make sure that such
address is not used on all possible devices.  IMO the only way is to
place such information in a capability, whether that's an existing
capability or a new one I don't really know.

> 
> > > Part 2 (clarification):
> > > 
> > > I think using a special config space register in the root complex would
> > > not be terrible in terms of guest changes because it is easy to
> > > introduce a new root complex driver in Linux and other OSes. The root
> > > complex would still be ECAM compatible so the regular ECAM driver would
> > > still work. A new driver would only be necessary if you want to be able
> > > to access the special config space register.
> > 
> > I'm slightly worry of this approach, we end up modifying a root
> > complex emulation in order to avoid modifying a PCI device emulation
> > on QEMU, not sure that's a good trade off.
> > 
> > Note also that different architectures will likely have different root
> > complex, and so you might need to modify several of them, plus then
> > arrange the PCI layout correctly in order to have the proper hierarchy
> > so that devices belonging to different driver domains are assigned to
> > different bridges.
> 
> I do think that adding something to the PCI conf register somewhere is
> the best option because it is not dependent on ACPI and it is not
> dependent on xenstore both of which are very undesirable.
> 
> I am not sure where specifically is the best place. These are 3 ideas
> we came up with:
> 1. PCI root complex
> 2. a register on the device itself
> 3. a new capability of the device
> 4. add one extra dummy PCI device for the sole purpose of exposing the
>    grants capability
> 
> 
> Looking at the spec, there is a way to add a vendor-specific capability
> (cap_vndr = 0x9). Could we use that? It doesn't look like it is used
> today, Linux doesn't parse it.

I did wonder the same from a quick look at the spec.  There's however
a text in the specification that says:

"The driver SHOULD NOT use the Vendor data capability except for
debugging and reporting purposes."

So we would at least need to change that because the capability would
then be used by other purposes different than debugging and reporting.

Seems like a minor adjustment, so might we worth asking upstream about
their opinion, and to get a conversation started.

> 
> > > 
> > > 
> > > **********
> > > What do you think about it? Are there any pitfalls, etc? This also 
> > > requires
> > > system changes, but at least without virtio spec changes.
> > 
> > Why are we so reluctant to add spec changes?  I understand this might
> > take time an effort, but it's the only way IMO to build a sustainable
> > VirtIO Xen implementation.  Did we already attempt to negotiate with
> > Oasis Xen related spec changes and those where refused?
> 
> That's because spec changes can be very slow. This is a bug that we need
> a relatively quick solution for and waiting 12-24 months for a spec
> update is not realistic.
> 
> I think a spec change would be best as a long term solution. We also
> need a short term solution. The short term solution doesn't have to be
> ideal but it has to work now.

My fear with such approach is that once a bodge is in place people
move on to other stuff and this never gets properly fixed.

I know this might not be a well received opinion, but it would be
better if such bodge is kept in each interested party patchqueue for
the time being, until a proper solution is implemented.  That way
there's an interest from parties into properly fixing it upstream.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.