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

[PATCH v2] x86/CPUID: unconditionally set XEN_HVM_CPUID_IOMMU_MAPPINGS


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 19 Jan 2021 14:07:59 +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=sFna0gylKm6LftpF7LFT1HlbwT0SCRUUdEthkDBJJQM=; b=J6fUiRCFDiCB3pSCCBGeL5Y+wV0DTx/9eoKRzf2LdoDLUg7kBDzg75sSx50zvUmgamtcLGA+w0+4g0lMBsasorQCBoKIF4hsiTTeLJLnQqnhV45e4Dq0b0t+TMYJHLfQfCIYgxHmh54mOz+6+03zPz+hyyEBNmHwMMl+PJEmmHCsLpBLqIXHk+oISaEMT4Z1kCZOFSM1QkVs0+bCbpfN9K53Urn+8H65TlMbaNxu8Gr3hos3yezs2ZLdHp6whQ6cpJ2cSm9EdLsSkAfneUR0CKgy/p1iQJoDmL1O6aNxNgIPw+qaZ2qa/WDzkNGnQi8oiixqNX3JKTYoyDu2aMlqpA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VEscXi4AZPztcDFRH8OIiSmfqdEOpfMgdD7JSItx6DkEoOE4ikS1IwHo2LxXv1Qzx2nGbq/dGiqFF9gCEAuAqZ4nLbC37HEUdYS6Yb/t3rVa50wuq7Cq0zyMSFCWhE+fpJ4sMHAii8EoekK72u1i4qnn3GKR/FnAK+WkNYcKoAfWIjZX7v2rufBU/29HsrNeIiG6YmUity4DHccjUT0Hh9k2ocIR7alZ/4V7nluncf9cuobxxNiq7i01yzg4vWOFfAgJ2mPjpkWtvQuhWSzdZ6h1YC5dqVTkf4SsIRg8TP6KQMBrSSrD8VO4SqZaEaN2MN3+vkw3MyztcktqZRIBQw==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 19 Jan 2021 13:08:14 +0000
  • Ironport-sdr: ldAoJ53U8Qx+5moKlP3s9BpYHrZ3ZLHnMhJB0+mLJcfBJIr1enAp6Q7MuM6QjNC7JiOMRouC7q g17qK2/jOxOTS9dmg/GvCI1dRq3zfFCNSapyuJf4wqIfNebH+E7tj8BtQyf+SvSzGUuw6doL1U 637gLzemzDkiLw5tSHNxxZTTAjhdTN+3oylE3isHfmFlmRCWlUyGYcc9B6s3UZ1+An0FxEyMtN FuVp+ztPtxnrztpaKvqT8kGwcPJXuZfLCv/SvBHbQw/jOM0rtVI091TDoTtxKbRcXUQYwtAG1A J90=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This is a revert of f5cfa0985673 plus a rework of the comment that
accompanies the setting of the flag so we don't forget why it needs to
be unconditionally set: it's indicating whether the version of Xen has
the original issue fixed and IOMMU entries are created for
grant/foreign maps.

If the flag is only exposed when the IOMMU is enabled the guest could
resort to use bounce buffers when running backends as it would assume
the underlying Xen version still has the bug present and thus
grant/foreign maps cannot be used with devices.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v1:
 - Expand commit message.
 - Add slightly expanded comment from Andrew into the code.
---
 xen/arch/x86/traps.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 4bd2cb6a1a..a6f1d45e77 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -1049,11 +1049,17 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, 
uint32_t leaf,
             res->a |= XEN_HVM_CPUID_X2APIC_VIRT;
 
         /*
-         * Indicate that memory mapped from other domains (either grants or
-         * foreign pages) has valid IOMMU entries.
+         * 1) Xen 4.10 and older was broken WRT grant maps requesting a DMA
+         * mapping, and forgot to honour the guest's request.
+         * 2) 4.11 (and presumably backports) fixed the bug, so the map
+         * hypercall actually did what the guest asked.
+         * 3) To work around the bug, guests must bounce buffer all DMA that
+         * would otherwise use a grant map, because it doesn't know whether the
+         * DMA is originating from an emulated or a real device.
+         * 4) This flag tells guests it is safe not to bounce-buffer all DMA to
+         * work around the bug.
          */
-        if ( is_iommu_enabled(d) )
-            res->a |= XEN_HVM_CPUID_IOMMU_MAPPINGS;
+        res->a |= XEN_HVM_CPUID_IOMMU_MAPPINGS;
 
         /* Indicate presence of vcpu id and set it in ebx */
         res->a |= XEN_HVM_CPUID_VCPU_ID_PRESENT;
-- 
2.29.2




 


Rackspace

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