All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Ragiadakou, Xenia" <Xenia.Ragiadakou@amd.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	jason.andryuk@amd.com, agarciav@amd.com,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH] xen/x86: allow Dom0 PVH to call XENMEM_exchange
Date: Tue, 6 May 2025 10:54:27 +0200	[thread overview]
Message-ID: <aBnOQyXSz-j33Wux@macbook.lan> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2505051100050.3879245@ubuntu-linux-20-04-desktop>

On Mon, May 05, 2025 at 11:11:10AM -0700, Stefano Stabellini wrote:
> On Mon, 5 May 2025, Roger Pau Monné wrote:
> > On Mon, May 05, 2025 at 12:40:18PM +0200, Marek Marczykowski-Górecki wrote:
> > > On Mon, Apr 28, 2025 at 01:00:01PM -0700, Stefano Stabellini wrote:
> > > > On Mon, 28 Apr 2025, Jan Beulich wrote:
> > > > > On 25.04.2025 22:19, Stefano Stabellini wrote:
> > > > > > From: Xenia Ragiadakou <Xenia.Ragiadakou@amd.com>
> > > > > > 
> > > > > > Dom0 PVH might need XENMEM_exchange when passing contiguous memory
> > > > > > addresses to firmware or co-processors not behind an IOMMU.
> > > > > 
> > > > > I definitely don't understand the firmware part: It's subject to the
> > > > > same transparent P2M translations as the rest of the VM; it's just
> > > > > another piece of software running there.
> > > > > 
> > > > > "Co-processors not behind an IOMMU" is also interesting; a more
> > > > > concrete scenario might be nice, yet I realize you may be limited in
> > > > > what you're allowed to say.
> > > > 
> > > > Sure. On AMD x86 platforms there is a co-processor called PSP running
> > > > TEE firmware. The PSP is not behind an IOMMU. Dom0 needs occasionally to
> > > > pass addresses to it.  See drivers/tee/amdtee/ and
> > > > include/linux/psp-tee.h in Linux.
> > > 
> > > We had (have?) similar issue with amdgpu (for integrated graphics) - it
> > > uses PSP for loading its firmware. With PV dom0 there is a workaround as
> > > dom0 kinda knows MFN. I haven't tried PVH dom0 on such system yet, but I
> > > expect troubles (BTW, hw1 aka zen2 gitlab runner has amdgpu, and it's
> > > the one I used for debugging this issue).
> > 
> > That's ugly, and problematic when used in conjunction with AMD-SEV.
> > 
> > I wonder if Xen could emulate/mediate some parts of the PSP for dom0
> > to use, while allowing Xen to be the sole owner of the device.  Having
> > both Xen and dom0 use it (for different purposes) seems like asking
> > for trouble.  But I also have no idea how complex the PSP interface
> > is, neither whether it would be feasible to emulate the
> > interfaces/registers needed for firmware loading.
> 
> Let me take a step back from the PSP for a moment. I am not opposed to a
> PSP mediator in Xen, but I want to emphasize that the issue is more
> general and extends well beyond the PSP.
> 
> In my years working in embedded systems, I have consistently seen cases
> where Dom0 needs to communicate with something that does not go through
> the IOMMU. This could be due to special firmware on a co-processor, a
> hardware erratum that prevents proper IOMMU usage, or a high-bandwidth
> device that technically supports the IOMMU but performs poorly unless
> the IOMMU is disabled. All of these are real-world examples that I have
> seen personally.

I wouldn't be surprised, classic PV dom0 avoided those issues because
it was dealing directly with host addresses (mfns), but that's not the
case with PVH dom0.

> In my opinion, we definitely need a solution like this patch for Dom0
> PVH to function correctly in all scenarios.

I'm not opposed to having such interface available for PVH hardware
domains.  I find it ugly, but I don't see much other way to deal with
those kind of "devices".  Xen mediating accesses for each one of them
is unlikely to be doable.

How do you hook this exchange interface into Linux to differentiate
which drivers need to use mfns when interacting with the hardware?

> Additionally, we could add a PSP mediator in Xen to provide best PSP
> support, and also for cases where both Xen and Dom0 need access, but I
> cannot fully assess the complexity involved, as I am not very familiar
> with the API. Probably it is not going to be simple.

For the specific PSP example, and kind of following from the question
above: if we add some mediation layer in Xen for PSP registers, how
could Linux differentiate whether it needs to use mfn of gfns when
interacting with the device?

Thanks, Roger.


  parent reply	other threads:[~2025-05-06  8:54 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-25 20:19 [PATCH] xen/x86: allow Dom0 PVH to call XENMEM_exchange Stefano Stabellini
2025-04-28  7:14 ` Jan Beulich
2025-04-28 20:00   ` Stefano Stabellini
2025-04-29  6:43     ` Jan Beulich
2025-04-29 21:52       ` Stefano Stabellini
2025-04-30  6:27         ` Jan Beulich
2025-04-30  7:41           ` Roger Pau Monné
2025-05-01  0:19             ` Stefano Stabellini
2025-05-01 13:44               ` Jason Andryuk
2025-05-02  7:19                 ` Jan Beulich
2025-05-02 16:49                   ` Stefano Stabellini
2025-05-05  7:57                     ` Roger Pau Monné
2025-05-12  9:14                     ` Jan Beulich
2025-05-05 10:40     ` Marek Marczykowski-Górecki
2025-05-05 14:30       ` Roger Pau Monné
2025-05-05 18:11         ` Stefano Stabellini
2025-05-05 20:36           ` Demi Marie Obenour
2025-05-06  8:54           ` Roger Pau Monné [this message]
2025-05-07 23:02             ` Stefano Stabellini
2025-05-08  9:12               ` Roger Pau Monné
2025-05-08 10:28                 ` Marek Marczykowski-Górecki
2025-05-08 23:28                   ` Stefano Stabellini
2025-05-08 23:25                 ` Stefano Stabellini
2025-05-09  8:32                   ` Roger Pau Monné
2025-05-09 21:10                     ` Stefano Stabellini
2025-05-09 22:16                       ` Teddy Astie
2025-05-09 22:31                         ` Stefano Stabellini
2025-05-12  8:51                       ` Roger Pau Monné
2025-05-12  9:24                     ` Jan Beulich
2025-04-28  8:11 ` Teddy Astie
2025-04-28 20:02   ` Stefano Stabellini
2025-04-29  6:24     ` Jan Beulich

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=aBnOQyXSz-j33Wux@macbook.lan \
    --to=roger.pau@citrix.com \
    --cc=Xenia.Ragiadakou@amd.com \
    --cc=agarciav@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jason.andryuk@amd.com \
    --cc=jbeulich@suse.com \
    --cc=marmarek@invisiblethingslab.com \
    --cc=sstabellini@kernel.org \
    --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 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.