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

[Xen-changelog] [xen staging-4.8] x86/vvmx: Fix livelock with XSA-304 fix



commit 1486caf8a0cf30f93c12c098c28681e4713d0aa0
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Fri Nov 29 10:19:07 2019 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Nov 29 10:19:07 2019 +0100

    x86/vvmx: Fix livelock with XSA-304 fix
    
    It turns out that the XSA-304 / CVE-2018-12207 fix of disabling executable
    superpages doesn't work well with the nested p2m code.
    
    Nested virt is experimental and not security supported, but is useful for
    development purposes.  In order to not regress the status quo, disable the
    XSA-304 workaround until the nested p2m code can be improved.
    
    Introduce a per-domain exec_sp control and set it based on the current
    opt_ept_exec_sp setting.  Take the oppotunity to omit a PVH hardware domain
    from the performance hit, because it is already permitted to DoS the system 
in
    such ways as issuing a reboot.
    
    When nested virt is enabled on a domain, force it to using executable
    superpages and rebuild the p2m.
    
    Having the setting per-domain involves rearranging the internals of
    parse_ept_param_runtime() but it still retains the same overall semantics -
    for each applicable domain whose setting needs to change, rebuild the p2m.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
 xen/arch/x86/hvm/vmx/vmx.c         |  6 ++++++
 xen/arch/x86/hvm/vmx/vvmx.c        | 13 +++++++++++++
 xen/arch/x86/mm/p2m-ept.c          |  2 +-
 xen/include/asm-x86/hvm/vmx/vmcs.h |  6 ++++++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 8d4d973ff0..e95b4c2d1f 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -229,6 +229,12 @@ static int vmx_domain_initialise(struct domain *d)
 {
     int rc;
 
+    /*
+     * Work around CVE-2018-12207?  The hardware domain is already permitted
+     * to reboot the system, so doesn't need mitigating against DoS's.
+     */
+    d->arch.hvm_domain.vmx.exec_sp = is_hardware_domain(d) || opt_ept_exec_sp;
+
     if ( !has_vlapic(d) )
         return 0;
 
diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index 71c8fc3361..a8e354d998 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -55,10 +55,23 @@ void nvmx_cpu_dead(unsigned int cpu)
 
 int nvmx_vcpu_initialise(struct vcpu *v)
 {
+    struct domain *d = v->domain;
     struct nestedvmx *nvmx = &vcpu_2_nvmx(v);
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct page_info *pg = alloc_domheap_page(NULL, 0);
 
+    /*
+     * Gross bodge.  The nested p2m logic can't cope with the CVE-2018-12207
+     * workaround of using NX EPT superpages, and livelocks.  Nested HVM isn't
+     * security supported, so disable the workaround until the nested p2m
+     * logic can be improved.
+     */
+    if ( !d->arch.hvm_domain.vmx.exec_sp )
+    {
+        d->arch.hvm_domain.vmx.exec_sp = true;
+        p2m_change_entry_type_global(d, p2m_ram_rw, p2m_ram_rw);
+    }
+
     if ( !pg )
     {
         gdprintk(XENLOG_ERR, "nest: allocation for shadow vmcs failed\n");
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index d0637eeb15..7e0d93a4c0 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -214,7 +214,7 @@ static void ept_p2m_type_to_flags(struct p2m_domain *p2m, 
ept_entry_t *entry,
      * Don't create executable superpages if we need to shatter them to
      * protect against CVE-2018-12207.
      */
-    if ( !opt_ept_exec_sp && is_epte_superpage(entry) )
+    if ( !p2m->domain->arch.hvm_domain.vmx.exec_sp && is_epte_superpage(entry) 
)
         entry->x = 0;
 }
 
diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h 
b/xen/include/asm-x86/hvm/vmx/vmcs.h
index 3a67a31326..001e95d4be 100644
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h
@@ -79,6 +79,12 @@ struct vmx_domain {
     unsigned int status;
 
     /*
+     * Domain permitted to use Executable EPT Superpages?  Cleared to work
+     * around CVE-2018-12207 as appropriate.
+     */
+    bool exec_sp;
+
+    /*
      * To handle posted interrupts correctly, we need to set the following
      * state:
      *
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.8

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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