From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
qemu-devel@nongnu.org, eric.auger@redhat.com,
"Peter Maydell" <peter.maydell@linaro.org>
Subject: Re: [PATCH] vhost-vdpa: skip TPM CRB memory section
Date: Wed, 23 Nov 2022 04:37:20 -0500 [thread overview]
Message-ID: <20221123043249-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAJaqyWdmGPeGxTyYgzYK-G+7Bqk2Mr0BrVtvdX4tjnTv=qUnQQ@mail.gmail.com>
On Wed, Nov 23, 2022 at 08:31:52AM +0100, Eugenio Perez Martin wrote:
> On Wed, Nov 23, 2022 at 8:20 AM Marc-André Lureau
> <marcandre.lureau@redhat.com> wrote:
> >
> > Hi
> >
> > On Wed, Nov 23, 2022 at 12:32 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> >>
> >> On Tue, Nov 22, 2022 at 06:53:49PM +0400, marcandre.lureau@redhat.com wrote:
> >> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> >
> >> > 851d6d1a0f ("vfio/common: remove spurious tpm-crb-cmd misalignment
> >> > warning") removed the warning on vfio_listener_region_add() path.
> >> >
> >> > An error is reported for vhost-vdpa case:
> >> > qemu-kvm: vhost_vdpa_listener_region_add received unaligned region
> >> >
> >> > Skip the CRB device.
> >> >
> >> > Fixes:
> >> > https://bugzilla.redhat.com/show_bug.cgi?id=2141965
> >> >
> >> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> > ---
> >> > hw/virtio/vhost-vdpa.c | 6 ++++++
> >> > 1 file changed, 6 insertions(+)
> >> >
> >> > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> >> > index 7468e44b87..9d7206e4b8 100644
> >> > --- a/hw/virtio/vhost-vdpa.c
> >> > +++ b/hw/virtio/vhost-vdpa.c
> >> > @@ -19,6 +19,7 @@
> >> > #include "hw/virtio/virtio-net.h"
> >> > #include "hw/virtio/vhost-shadow-virtqueue.h"
> >> > #include "hw/virtio/vhost-vdpa.h"
> >> > +#include "sysemu/tpm.h"
> >> > #include "exec/address-spaces.h"
> >> > #include "migration/blocker.h"
> >> > #include "qemu/cutils.h"
> >> > @@ -46,6 +47,11 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section,
> >> > {
> >> > Int128 llend;
> >> >
> >> > + if (TPM_IS_CRB(section->mr->owner)) {
> >> > + /* The CRB command buffer has its base address unaligned. */
> >> > + return true;
> >> > + }
> >> > +
> >>
> >> Quite a hack. We can't really keep adding dependency on random devices
> >
> >
> > Agree it's not great. but it's not strictly a dependency. At least you can still build with !CONFIG_TPM.
> >
> >> to vhost. And would you add hacks like this to listeners?
> >> Pls figure out what's special about this buffer.
> >> Also if this section is unaligned then doesn't it break up
> >> other aligned sections?
> >
> >
> > See the original discussion:
> > https://patchew.org/QEMU/20220208133842.112017-1-eric.auger@redhat.com/20220208133842.112017-2-eric.auger@redhat.com/
> >
>
> Based on that, I'd tune the comment to something like:
> QEMU represents the CRB cmd/response buffer as a standard RAM region
> to the listeners, but real HW would not be able to access them.
But e.g. virtio can access it now with no issues, no?
Is that a problem? Given it's TPM ...
> Besides, these regions may not be properly page aligned.
>
> Is that more accurate?
>
> Thanks!
>
> > It is not clear whether aligning the tpm-crb-cmd region would work (overlapping tpm-crb-mmio).
> >
> > Peter Maydell said: "There's nothing that guarantees alignment for memory regions at all, whether they're RAM, IO or anything else.".
> >
> > Maybe vfio/vhost should simply skip those odd regions silently.
> >
> >
> >>
> >>
> >> > if ((!memory_region_is_ram(section->mr) &&
> >> > !memory_region_is_iommu(section->mr)) ||
> >> > memory_region_is_protected(section->mr) ||
> >> > --
> >> > 2.38.1
> >>
prev parent reply other threads:[~2022-11-23 9:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 14:53 [PATCH] vhost-vdpa: skip TPM CRB memory section marcandre.lureau
2022-11-22 15:18 ` [PATCH-for-7.2] " Philippe Mathieu-Daudé
2022-11-22 16:05 ` [PATCH] " Eric Auger
2022-11-22 16:49 ` Eugenio Perez Martin
2022-11-23 4:25 ` Jason Wang
2022-11-22 20:32 ` Michael S. Tsirkin
2022-11-23 7:20 ` Marc-André Lureau
2022-11-23 7:23 ` Michael S. Tsirkin
2022-11-23 11:25 ` Philippe Mathieu-Daudé
2022-11-23 12:20 ` Michael S. Tsirkin
2022-11-23 13:30 ` Michael S. Tsirkin
2022-11-23 7:31 ` Eugenio Perez Martin
2022-11-23 9:37 ` Michael S. Tsirkin [this message]
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=20221123043249-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=eric.auger@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).