File 5bf41f9d-dom0-Fix-shadowing-of-PV-guests-with-2M-superpages.patch of Package xen.openSUSE_Leap_42.3_Update

Subject: x86/dom0: Fix shadowing of PV guests with 2M superpages
From: Andrew Cooper andrew.cooper3@citrix.com Tue Nov 20 15:52:13 2018 +0100
Date: Tue Nov 20 15:52:13 2018 +0100:
Git: e43f2ca943453f04383936727fa8f19827d5e596

This is a straight backport of c/s 28d9a9a2d41759b9e5163037b759ac557aea767c
but with a different justification.

Dom0 may have superpages (e.g. initial P2M), and may be shadowed
(e.g. PV-L1TF).  Because of this incorrect check, when PV superpages are
disallowed (which is the security supported configuration), attempting to
shadow the P2M with its superpages still intact will fail.  A #PF will be
handed back to the kernel, rather than the superpage being splintered and
shadowed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>

diff --git a/xen/include/asm-x86/guest_pt.h b/xen/include/asm-x86/guest_pt.h
index 72126d58d5..08031c803e 100644
--- a/xen/include/asm-x86/guest_pt.h
+++ b/xen/include/asm-x86/guest_pt.h
@@ -205,15 +205,17 @@ static inline guest_l4e_t guest_l4e_from_gfn(gfn_t gfn, u32 flags)
 static inline bool guest_can_use_l2_superpages(const struct vcpu *v)
 {
     /*
+     * PV guests use Xen's paging settings.  Being 4-level, 2M
+     * superpages are unconditionally supported.
+     *
      * The L2 _PAGE_PSE bit must be honoured in HVM guests, whenever
      * CR4.PSE is set or the guest is in PAE or long mode.
      * It's also used in the dummy PT for vcpus with CR0.PG cleared.
      */
-    return (is_pv_vcpu(v)
-            ? opt_allow_superpage
-            : (GUEST_PAGING_LEVELS != 2
-               || !hvm_paging_enabled(v)
-               || (v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PSE)));
+    return (is_pv_vcpu(v) ||
+            GUEST_PAGING_LEVELS != 2 ||
+            !hvm_paging_enabled(v) ||
+            (v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PSE));
 }
 
 static inline bool guest_can_use_l3_superpages(const struct domain *d)
openSUSE Build Service is sponsored by