Skip to contentSkip to conversation

hvm: vmx/svm_cpu_up_prepare should be called only once

PATCH Superseded Boris Ostrovsky 2 participants 3 messages Aug 17, 2017 – Aug 18, 2017

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hvm: vmx/svm_cpu_up_prepare should be called only once

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.

---
V2:
* Call *cpu_up_prepare() on BSP from start_svm/vmx()

 xen/arch/x86/hvm/svm/svm.c  | 6 +-----
 xen/arch/x86/hvm/vmx/vmcs.c | 3 ---
 xen/arch/x86/hvm/vmx/vmx.c  | 2 +-
 3 files changed, 2 insertions(+), 9 deletions(-)
xen/arch/x86/hvm/svm/svm.c +1 -5
index 0dc9442..2b51e4d 100644
@@ -1526,7 +1526,6 @@ static int svm_handle_osvw(struct vcpu *v, uint32_t msr, uint64_t *val, bool_t r
 static int _svm_cpu_up(bool bsp)
 {
     uint64_t msr_content;
-    int rc;
     unsigned int cpu = smp_processor_id();
     const struct cpuinfo_x86 *c = &cpu_data[cpu];
  
@@ -1538,9 +1537,6 @@ static int _svm_cpu_up(bool bsp)
         return -EINVAL;
     }
 
-    if ( (rc = svm_cpu_up_prepare(cpu)) != 0 )
-        return rc;
-
     write_efer(read_efer() | EFER_SVME);
 
     /* Initialize the HSA for this core. */
@@ -1589,7 +1585,7 @@ const struct hvm_function_table * __init start_svm(void)
 
     svm_host_osvw_reset();
 
-    if ( _svm_cpu_up(true) )
+    if ( svm_cpu_up_prepare(smp_processor_id()) || _svm_cpu_up(true) )
     {
         printk("SVM: failed to initialise.\n");
         return NULL;
xen/arch/x86/hvm/vmx/vmcs.c +0 -3
index 7854802..73b4731 100644
@@ -652,9 +652,6 @@ int vmx_cpu_up(void)
 
     INIT_LIST_HEAD(&this_cpu(active_vmcs_list));
 
-    if ( (rc = vmx_cpu_up_prepare(cpu)) != 0 )
-        return rc;
-
     switch ( __vmxon(this_cpu(vmxon_region)) )
     {
     case -2: /* #UD or #GP */
xen/arch/x86/hvm/vmx/vmx.c +1 -1
index 67fc85b..f8c2d01 100644
@@ -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_prepare(smp_processor_id()) || vmx_cpu_up() )
     {
         printk("VMX: failed to initialise.\n");
         return NULL;
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

xen/arch/x86/hvm/svm/svm.c const struct hvm_function_table * __init start_svm(void) · line 1588

Quoted 6 lines · Boris Ostrovsky
xen/arch/x86/hvm/svm/svm.c +1 -1
@@ -1589,7 +1585,7 @@ const struct hvm_function_table * __init start_svm(void)
 
     svm_host_osvw_reset();
 
-    if ( _svm_cpu_up(true) )
+    if ( svm_cpu_up_prepare(smp_processor_id()) || _svm_cpu_up(true) )

Both of these could pass 0 rather than smp_processor_id(), but either way, Reviewed-by: Andrew Cooper <[email protected]>

xen/arch/x86/hvm/svm/svm.c const struct hvm_function_table * __init start_svm(void) · line 1591

Quoted 3 lines
xen/arch/x86/hvm/svm/svm.c +0 -0
     {
         printk("SVM: failed to initialise.\n");
         return NULL;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 9 lines · Andrew Cooper

xen/arch/x86/hvm/svm/svm.c const struct hvm_function_table * __init start_svm(void) · line 1588

Quoted 6 lines · Boris Ostrovsky
xen/arch/x86/hvm/svm/svm.c +1 -1
@@ -1589,7 +1585,7 @@ const struct hvm_function_table * __init start_svm(void)
 
     svm_host_osvw_reset();
 
-    if ( _svm_cpu_up(true) )
+    if ( svm_cpu_up_prepare(smp_processor_id()) || _svm_cpu_up(true) )

Both of these could pass 0 rather than smp_processor_id(), but either way, Reviewed-by: Andrew Cooper <[email protected]>

This patch breaks VMX on Intel, let me rework it.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel