x86/hvm: set 'ipat' in EPT for special pages
authorPaul Durrant <pdurrant@amazon.com>
Fri, 7 Aug 2020 15:11:10 +0000 (17:11 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 7 Aug 2020 15:11:10 +0000 (17:11 +0200)
commit864d5701ec5dc5af028d415e86bf5cf6aaed3a7c
treebd0b49b2fa473183267755667e83c13993225382
parentafed8e4365f0dec26a040ea0670b654e00d8c869
x86/hvm: set 'ipat' in EPT for special pages

All non-MMIO ranges (i.e those not mapping real device MMIO regions) that
map valid MFNs are normally marked MTRR_TYPE_WRBACK and 'ipat' is set. Hence
when PV drivers running in a guest populate the BAR space of the Xen Platform
PCI Device with pages such as the Shared Info page or Grant Table pages,
accesses to these pages will be cachable.

However, should IOMMU mappings be enabled be enabled for the guest then these
accesses become uncachable. This has a substantial negative effect on I/O
throughput of PV devices. Arguably PV drivers should bot be using BAR space to
host the Shared Info and Grant Table pages but it is currently commonplace for
them to do this and so this problem needs mitigation. Hence this patch makes
sure the 'ipat' bit is set for any special page regardless of where in GFN
space it is mapped.

NOTE: Clearly this mitigation only applies to Intel EPT. It is not obvious
      that there is any similar mitigation possible for AMD NPT. Downstreams
      such as Citrix XenServer have been carrying a patch similar to this for
      several releases though.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: ca24b2ffdbd9a25b2d313a547ccbe97baf3e5a8d
master date: 2020-07-31 17:42:47 +0200
xen/arch/x86/hvm/mtrr.c