x86/hvm: vmx/svm_cpu_up_prepare should be called only once
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Fri, 25 Aug 2017 12:07:12 +0000 (14:07 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 25 Aug 2017 12:07:12 +0000 (14:07 +0200)
These routines are first called via CPU_UP_PREPARE notifier by
the BSP and then by the booting ASP from vmx_cpu_up()/_svm_cpu_up().

Avoid the unnecessary second call. Because BSP doesn't go through
CPU_UP_PREPARE it is a special case. We pass 'bsp' flag to newly
added _vmx_cpu_up() (just like it's already done for _svm_cpu_up())
so they can decide whether or not to call vmx/svm_cpu_up_prepare().

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmcs.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/vmx/vmcs.h

index 599a8d32923b7bdd48e8ed4277375860e6a78f25..6b19b162f8c9ad6e5433ddece9425f93860c74d6 100644 (file)
@@ -1574,7 +1574,7 @@ static int _svm_cpu_up(bool bsp)
         return -EINVAL;
     }
 
-    if ( (rc = svm_cpu_up_prepare(cpu)) != 0 )
+    if ( bsp && (rc = svm_cpu_up_prepare(cpu)) != 0 )
         return rc;
 
     write_efer(read_efer() | EFER_SVME);
index 7854802cbaa36fec169aa65ef75b82fcf4e9f933..86cd316cfb4edd5f07938ef93f21b8584e1d5a36 100644 (file)
@@ -603,7 +603,7 @@ void vmx_cpu_dead(unsigned int cpu)
     vmx_pi_desc_fixup(cpu);
 }
 
-int vmx_cpu_up(void)
+int _vmx_cpu_up(bool bsp)
 {
     u32 eax, edx;
     int rc, bios_locked, cpu = smp_processor_id();
@@ -652,7 +652,7 @@ int vmx_cpu_up(void)
 
     INIT_LIST_HEAD(&this_cpu(active_vmcs_list));
 
-    if ( (rc = vmx_cpu_up_prepare(cpu)) != 0 )
+    if ( bsp && (rc = vmx_cpu_up_prepare(cpu)) != 0 )
         return rc;
 
     switch ( __vmxon(this_cpu(vmxon_region)) )
@@ -693,6 +693,11 @@ int vmx_cpu_up(void)
     return 0;
 }
 
+int vmx_cpu_up()
+{
+    return _vmx_cpu_up(false);
+}
+
 void vmx_cpu_down(void)
 {
     struct list_head *active_vmcs_list = &this_cpu(active_vmcs_list);
index 67fc85b2015c7a3fe15ec739f02d0383715f1dd7..f6da119c9f9f2e6dec4fbee453ecd048cf343978 100644 (file)
@@ -2433,7 +2433,7 @@ const struct hvm_function_table * __init start_vmx(void)
 {
     set_in_cr4(X86_CR4_VMXE);
 
-    if ( vmx_cpu_up() )
+    if ( _vmx_cpu_up(true) )
     {
         printk("VMX: failed to initialise.\n");
         return NULL;
index e3faf7807fbb5abc46c9bc7a3fbbb389afabbcfd..8fb9e3ceee4ecdfadf6cf530eebbe3e0b681b024 100644 (file)
@@ -26,6 +26,7 @@ extern void setup_vmcs_dump(void);
 extern int  vmx_cpu_up_prepare(unsigned int cpu);
 extern void vmx_cpu_dead(unsigned int cpu);
 extern int  vmx_cpu_up(void);
+extern int  _vmx_cpu_up(bool bsp);
 extern void vmx_cpu_down(void);
 
 struct vmcs_struct {