mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jürgen Groß" <jgross@suse.com>
To: Teddy Astie <teddy.astie@vates.tech>,
	xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH] xen/virtio: Don't use grant-dma-ops when running as Dom0
Date: Tue, 6 Jan 2026 20:03:39 +0100	[thread overview]
Message-ID: <995f7ac8-0a8b-43d9-9cc7-63622ec52ca1@suse.com> (raw)
In-Reply-To: <6698564dd2270a9f7377b78ebfb20cb425cabbe8.1767720955.git.teddy.astie@vates.tech>


[-- Attachment #1.1.1: Type: text/plain, Size: 1795 bytes --]

On 06.01.26 18:36, Teddy Astie wrote:
> Dom0 inherit devices from the machine and is usually in PV mode.
> If we are running in a virtual that has virtio devices, these devices
> would be considered as using grants with Dom0 as backend, while being
> the said Dom0 itself, while we want to use these devices like regular
> PCI devices.
> 
> Fix this by preventing grant-dma-ops from being used when running as Dom0
> (initial domain). We still keep the device-tree logic as-is.
> 
> Signed-off-by: Teddy Astie <teddy.astie@vates.tech>
> Fixes: 61367688f1fb0 ("xen/virtio: enable grant based virtio on x86")
> ---
> CC: Juergen Gross <jgross@suse.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> 
>   drivers/xen/grant-dma-ops.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/xen/grant-dma-ops.c b/drivers/xen/grant-dma-ops.c
> index 14077d23f2a1..c2603e700178 100644
> --- a/drivers/xen/grant-dma-ops.c
> +++ b/drivers/xen/grant-dma-ops.c
> @@ -366,7 +366,8 @@ static int xen_grant_init_backend_domid(struct device *dev,
>   	if (np) {
>   		ret = xen_dt_grant_init_backend_domid(dev, np, backend_domid);
>   		of_node_put(np);
> -	} else if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT) || xen_pv_domain()) {
> +	} else if (!xen_initial_domain() &&
> +		   (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT) || xen_pv_domain())) {
>   		dev_info(dev, "Using dom0 as backend\n");
>   		*backend_domid = 0;
>   		ret = 0;

Please make this controllable, e.g. via a boot parameter.

It is completely valid to have a virtio device in dom0 with the backend in
a domU. You'll need grants in this case.


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  reply	other threads:[~2026-01-06 19:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06 17:36 Teddy Astie
2026-01-06 19:03 ` Jürgen Groß [this message]
2026-01-06 22:47   ` Teddy Astie
2026-01-07  7:36     ` Jürgen Groß

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=995f7ac8-0a8b-43d9-9cc7-63622ec52ca1@suse.com \
    --to=jgross@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=sstabellini@kernel.org \
    --cc=teddy.astie@vates.tech \
    --cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®