From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: <xen-devel@lists.xenproject.org>, <hongyxia@amazon.co.uk>,
<iwj@xenproject.org>, Julien Grall <jgrall@amazon.com>,
Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
Julien Grall <julien@xen.org>
Subject: Re: [for-4.15][PATCH v2 1/5] xen/x86: p2m: Don't map the special pages in the IOMMU page-tables
Date: Wed, 10 Feb 2021 12:34:41 +0100 [thread overview]
Message-ID: <YCPE0byWKlf/uOFT@Air-de-Roger> (raw)
In-Reply-To: <5bf0a2de-3f0e-8860-7bc7-f667437aa3a7@suse.com>
On Wed, Feb 10, 2021 at 12:10:09PM +0100, Jan Beulich wrote:
> On 10.02.2021 09:29, Roger Pau Monné wrote:
> > On Tue, Feb 09, 2021 at 03:28:12PM +0000, Julien Grall wrote:
> >> From: Julien Grall <jgrall@amazon.com>
> >>
> >> Currently, the IOMMU page-tables will be populated early in the domain
> >> creation if the hardware is able to virtualize the local APIC. However,
> >> the IOMMU page tables will not be freed during early failure and will
> >> result to a leak.
> >>
> >> An assigned device should not need to DMA into the vLAPIC page, so we
> >> can avoid to map the page in the IOMMU page-tables.
> >>
> >> This statement is also true for any special pages (the vLAPIC page is
> >> one of them). So to take the opportunity to prevent the mapping for all
> >> of them.
> >
> > Hm, OK, while I assume it's likely for special pages to not be target
> > of DMA operations, it's not easy to spot what are special pages.
> >
> >> Note that:
> >> - This is matching the existing behavior with PV guest
> >
> > You might make HVM guests not sharing page-tables 'match' PV
> > behavior, but you are making behavior between HVM guests themselves
> > diverge.
> >
> >
> >> - This doesn't change the behavior when the P2M is shared with the
> >> IOMMU. IOW, the special pages will still be accessibled by the
> >> device.
> >
> > I have to admit I don't like this part at all. Having diverging device
> > mappings depending on whether the page tables are shared or not is
> > bad IMO, as there might be subtle bugs affecting one of the two
> > modes.
>
> This is one way to look at things, yes. But if you take the
> other perspective that special pages shouldn't be
> IOMMU-mapped, then the divergence is the price to pay for
> being able to share pages (and it's not Julien introducing
> bad behavior here).
Since when sharing we have no option but to make whatever is
accessible to the CPU also available to devices, it would seem
reasonable to also do it when not sharing.
> Additionally it may be possible to utilize the divergence to
> our advantage: If one way of setting up things works and the
> other doesn't, we have a reasonable clue where to look. In
> fact the aspect above may, together with possible future
> findings, end up being a reason to not default to or even
> disallow (like for AMD) page table sharing.
I think such approach is risky: we don't likely test VT-d without
sharing that much (or at all?), now that IOMMUs support the same page
sizes as EPT, hence it's likely for bugs to go unnoticed.
> > I get the feeling this is just papering over an existing issue instead
> > of actually fixing it: IOMMU page tables need to be properly freed
> > during early failure.
>
> I take a different perspective: IOMMU page tables shouldn't
> get created (yet) at all in the course of
> XEN_DOMCTL_createdomain - this op is supposed to produce an
> empty container for a VM.
The same would apply for CPU page-tables then, yet they seem to be
created and populating them (ie: adding the lapic access page) doesn't
leak such entries, which points at an asymmetry. Either we setup both
tables and handle freeing them properly, or we set none of them.
Roger.
next prev parent reply other threads:[~2021-02-10 11:35 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 15:28 [for-4.15][PATCH v2 0/5] xen/iommu: Collection of bug fixes for IOMMU teadorwn Julien Grall
2021-02-09 15:28 ` [for-4.15][PATCH v2 1/5] xen/x86: p2m: Don't map the special pages in the IOMMU page-tables Julien Grall
2021-02-09 20:19 ` Paul Durrant
2021-02-10 8:29 ` Roger Pau Monné
2021-02-10 8:50 ` Julien Grall
2021-02-10 9:34 ` Julien Grall
2021-02-10 11:10 ` Jan Beulich
2021-02-10 11:34 ` Roger Pau Monné [this message]
2021-02-10 11:38 ` Jan Beulich
2021-02-10 11:40 ` Julien Grall
2021-02-10 11:45 ` Jan Beulich
2021-02-10 11:48 ` Julien Grall
2021-02-10 11:54 ` Roger Pau Monné
2021-02-10 13:12 ` Jan Beulich
2021-02-10 15:24 ` Roger Pau Monné
2021-02-10 15:53 ` Jan Beulich
2021-02-10 13:08 ` Jan Beulich
2021-02-10 11:26 ` Jan Beulich
2021-02-15 11:38 ` Julien Grall
2021-02-15 12:36 ` Jan Beulich
2021-02-15 12:54 ` Julien Grall
2021-02-15 13:14 ` Jan Beulich
2021-02-17 11:21 ` Julien Grall
2021-02-09 15:28 ` [for-4.15][PATCH v2 2/5] xen/iommu: Check if the IOMMU was initialized before tearing down Julien Grall
2021-02-09 20:22 ` Paul Durrant
2021-02-17 11:25 ` Julien Grall
2021-02-09 15:28 ` [for-4.15][PATCH v2 3/5] xen/iommu: iommu_map: Don't crash the domain if it is dying Julien Grall
2021-02-09 20:28 ` Paul Durrant
2021-02-09 21:14 ` Julien Grall
2021-02-10 14:14 ` Jan Beulich
2021-02-10 14:58 ` Julien Grall
2021-02-10 15:56 ` Jan Beulich
2021-02-09 15:28 ` [for-4.15][PATCH v2 4/5] xen/iommu: x86: Don't leak the IOMMU page-tables Julien Grall
2021-02-09 20:33 ` Paul Durrant
2021-02-10 14:32 ` Jan Beulich
2021-02-10 15:04 ` Julien Grall
2021-02-10 16:12 ` Jan Beulich
2021-02-17 11:49 ` Julien Grall
2021-02-17 12:57 ` Jan Beulich
2021-02-10 14:44 ` Jan Beulich
2021-02-09 15:28 ` [for-4.15][PATCH v2 5/5] xen/iommu: x86: Clear the root page-table before freeing the page-tables Julien Grall
2021-02-09 20:36 ` Paul Durrant
2021-02-10 2:21 ` Tian, Kevin
2021-02-17 13:54 ` Julien Grall
2021-02-10 14:39 ` Jan Beulich
2021-02-09 16:47 ` [for-4.15][PATCH v2 0/5] xen/iommu: Collection of bug fixes for IOMMU teadorwn Ian Jackson
2021-02-17 11:33 ` Julien Grall
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=YCPE0byWKlf/uOFT@Air-de-Roger \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=hongyxia@amazon.co.uk \
--cc=iwj@xenproject.org \
--cc=jbeulich@suse.com \
--cc=jgrall@amazon.com \
--cc=julien@xen.org \
--cc=wl@xen.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.