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

Re: [for-4.15][PATCH v2 1/5] xen/x86: p2m: Don't map the special pages in the IOMMU page-tables

  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 10 Feb 2021 12:34:41 +0100
  • 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-SenderADCheck; bh=cBPUQwNO59+m/qq75DvFxWl+Mqnh1M7vO6RzVX0hR/Y=; b=HnM3L0tCJMEiwxEtI4ivUjbQKpUzow6nZFIjhh6i8qu/6s4LXxei6aePWahveZCX3+HkvCeUGNB4vl7roXN25NyYeLgbBhLUul+CjngmsbqyFeRcuSYFWU57Hyj1ZGpPSC4NweD8wiOUSVK1mzhGSAObWycKtkBvpBIhmh3ShkF1NlL2aqrVbPsUqx8q6x+HTBvQAOV7jXVDTT/nrSP8SmJbqGNguCXhRPAesEgCPIG0GS3ifPdWdbS6c0vBh3iTmjrB9aNKE1hHab6t0GpsVGbAfWNgy+vT3+INctl7vcNfUJ3vZlp8m2IjeiU2MWCiOZRpO5CcaOErRHQfeJHbUQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KxdPddOXRJllKSyhL1lYZHd4PqYTR0sojJD0FC5Z61hmvMyjkn+VjkT0Dds7Q1XoqD8Zs2pkFDh/BujaOic/nEcDofV1FpVze0wf7m6Neo9DB8wyLjJWazRDQiH1bo9EzGePRPZ+Zry6HM1cWH/nHkA1Eez9lnnnGOOs3BN/spgDe7Dgj46m5UIMCfAzUKTSTEoZAUbdUcePMraPF46KrKXCgLpkTp0sKSho1AVB2TRIngWfX/ElvA2r24SfcUYGvQ5RcgTLP7sxKZpqVnqUCCwbtqPOmyM/emKcEZNEfcaNvBD2byCAG1ZY8/2F8CoHIXfKU6Po8H0KotwEoPbUMA==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <hongyxia@xxxxxxxxxxxx>, <iwj@xxxxxxxxxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Wed, 10 Feb 2021 11:35:16 +0000
  • Ironport-sdr: y4W28styJ7zUg9W1wrkYS9Wu7IQwFRs3hDEp6qddv3y6P+nWQC/exe1e3UAX8mRbpnNMWt9g5z e2xWzb8Ijoq2mKDiy6MxO1B1gXomOG4gjfh1hUcoCmtCikVSaGt0XjqcPwyPqMhNBPRXX+v9IB L/pAQA5rffTBTDAhdRMcEwYNqwumDuhc4dgs0HnYNTqsqy8Sz/7yPB6Yoocl3NRvJ3ELHbvj26 MJBHtXpz17GG8sVqtbQfCm4RTBrkd3VJByStcXxwqsQ/Fm5B41GHQZVeNym62sdkOD7H5/HitV u78=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxxxx>
> >>
> >> 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.




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