WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Bring up AP of VMX domain.

# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID cf1c1bb9f6d200ffa0bc0e7d7310feb03dd34481
# Parent  71f2d19cd3a5142c9e060913ad95cdd7e03ecbb4
Bring up AP of VMX domain.
1) add INIT-SIPI-SIPI IPI sequence handling code to HVM virtual lapic
code.
2) add an new interface init_ap_context to hvm_funcs, and implement the
VMX side.
3) add a hvm generic function hvm_bringup_ap, which in turn calls
init_ap_context.

Signed-off-by: Xin Li <xin.b.li@xxxxxxxxx>
Signed-off-by: Yunhong Jiang <yunhong.jiang@xxxxxxxxx>

diff -r 71f2d19cd3a5 -r cf1c1bb9f6d2 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Fri Feb 24 16:32:19 2006
+++ b/xen/arch/x86/hvm/hvm.c    Fri Feb 24 16:32:58 2006
@@ -25,6 +25,7 @@
 #include <xen/sched.h>
 #include <xen/irq.h>
 #include <xen/softirq.h>
+#include <xen/domain.h>
 #include <xen/domain_page.h>
 #include <asm/current.h>
 #include <asm/io.h>
@@ -59,9 +60,9 @@
 
     for ( i = 0; i < nr_pfn; i++ )
     {
-        if ( pfn + i >= 0xfffff ) 
+        if ( pfn + i >= 0xfffff )
             break;
-        
+
         __copy_to_user(&phys_to_machine_mapping[pfn + i], &val, sizeof (val));
     }
 }
@@ -217,7 +218,7 @@
     global_iodata_t *spg;
     u16   *virq_line, irqs;
     struct hvm_virpic *pic = &v->domain->arch.hvm_domain.vpic;
-    
+
     spg = &get_sp(v->domain)->sp_global;
     virq_line  = &spg->pic_clear_irr;
     if ( *virq_line ) {
@@ -312,6 +313,52 @@
 }
 
 /*
+ * only called in HVM domain BSP context
+ * when booting, vcpuid is always equal to apic_id
+ */
+int hvm_bringup_ap(int vcpuid, int trampoline_vector)
+{
+    struct vcpu *bsp = current, *v;
+    struct domain *d = bsp->domain;
+    struct vcpu_guest_context *ctxt;
+    int rc = 0;
+
+    /* current must be HVM domain BSP */
+    if ( !(HVM_DOMAIN(bsp) && bsp->vcpu_id == 0) ) {
+        printk("Not calling hvm_bringup_ap from BSP context.\n");
+        domain_crash_synchronous();
+    }
+
+    if ( (v = d->vcpu[vcpuid]) == NULL )
+        return -ENOENT;
+
+    if ( (ctxt = xmalloc(struct vcpu_guest_context)) == NULL ) {
+        printk("Failed to allocate memory in hvm_bringup_ap.\n");
+        return -ENOMEM;
+    }
+
+    hvm_init_ap_context(ctxt, vcpuid, trampoline_vector);
+
+    LOCK_BIGLOCK(d);
+    rc = -EEXIST;
+    if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
+        rc = boot_vcpu(d, vcpuid, ctxt);
+    UNLOCK_BIGLOCK(d);
+
+    if ( rc != 0 )
+        printk("AP %d bringup failed in boot_vcpu %x.\n", vcpuid, rc);
+    else {
+        if ( test_and_clear_bit(_VCPUF_down, &d->vcpu[vcpuid]->vcpu_flags) )
+            vcpu_wake(d->vcpu[vcpuid]);
+        printk("AP %d bringup suceeded.\n", vcpuid);
+    }
+
+    xfree(ctxt);
+
+    return rc;
+}
+
+/*
  * Local variables:
  * mode: C
  * c-set-style: "BSD"
diff -r 71f2d19cd3a5 -r cf1c1bb9f6d2 xen/arch/x86/hvm/vlapic.c
--- a/xen/arch/x86/hvm/vlapic.c Fri Feb 24 16:32:19 2006
+++ b/xen/arch/x86/hvm/vlapic.c Fri Feb 24 16:32:58 2006
@@ -225,27 +225,35 @@
         break;
 
     case VLAPIC_DELIV_MODE_INIT:
-        if (!level && trig_mode == 1) {        //Deassert
+        if ( !level && trig_mode == 1 ) {        //Deassert
             printk("This hvm_vlapic is for P4, no work for De-assert init\n");
         } else {
             /* FIXME How to check the situation after vcpu reset? */
-            vlapic->init_sipi_sipi_state = 
VLAPIC_INIT_SIPI_SIPI_STATE_WAIT_SIPI;
-            if (vlapic->vcpu) {
-                vcpu_pause(vlapic->vcpu);
+            if ( test_and_clear_bit(_VCPUF_initialised, &v->vcpu_flags) ) {
+                printk("Reset hvm vcpu not supported yet\n");
+                domain_crash_synchronous();
             }
+            v->arch.hvm_vcpu.init_sipi_sipi_state =
+                HVM_VCPU_INIT_SIPI_SIPI_STATE_WAIT_SIPI;
+            result = 1;
         }
         break;
 
     case VLAPIC_DELIV_MODE_STARTUP:
-        if (vlapic->init_sipi_sipi_state != 
VLAPIC_INIT_SIPI_SIPI_STATE_WAIT_SIPI)
+        if ( v->arch.hvm_vcpu.init_sipi_sipi_state ==
+                HVM_VCPU_INIT_SIPI_SIPI_STATE_NORM )
             break;
-        vlapic->init_sipi_sipi_state = VLAPIC_INIT_SIPI_SIPI_STATE_NORM;
-        if (!vlapic->vcpu) {
-            /* XXX Call hvm_bringup_ap here */
-             result = 0;
-        }else{
-            //hvm_vcpu_reset(vlapic->vcpu);
-        }
+
+        v->arch.hvm_vcpu.init_sipi_sipi_state =
+                HVM_VCPU_INIT_SIPI_SIPI_STATE_NORM;
+
+        if ( test_bit(_VCPUF_initialised, &v->vcpu_flags) ) {
+            printk("SIPI for initialized vcpu vcpuid %x\n", v->vcpu_id);
+            domain_crash_synchronous();
+        }
+
+        if ( hvm_bringup_ap(v->vcpu_id, vector) != 0 )
+            result = 0;
         break;
 
     default:
diff -r 71f2d19cd3a5 -r cf1c1bb9f6d2 xen/arch/x86/hvm/vmx/io.c
--- a/xen/arch/x86/hvm/vmx/io.c Fri Feb 24 16:32:19 2006
+++ b/xen/arch/x86/hvm/vmx/io.c Fri Feb 24 16:32:58 2006
@@ -113,13 +113,15 @@
     struct hvm_virpit *vpit = &plat->vpit;
     struct hvm_virpic *pic= &plat->vpic;
 
-    hvm_pic_assist(v);
-    __vmread_vcpu(v, CPU_BASED_VM_EXEC_CONTROL, &cpu_exec_control);
-    if ( vpit->pending_intr_nr ) {
+    if ( v->vcpu_id == 0 )
+        hvm_pic_assist(v);
+
+    if ( (v->vcpu_id == 0) && vpit->pending_intr_nr ) {
         pic_set_irq(pic, 0, 0);
         pic_set_irq(pic, 0, 1);
     }
 
+    __vmread_vcpu(v, CPU_BASED_VM_EXEC_CONTROL, &cpu_exec_control);
     __vmread(VM_ENTRY_INTR_INFO_FIELD, &intr_fields);
 
     if (intr_fields & INTR_INFO_VALID_MASK) {
diff -r 71f2d19cd3a5 -r cf1c1bb9f6d2 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Fri Feb 24 16:32:19 2006
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Fri Feb 24 16:32:58 2006
@@ -448,6 +448,37 @@
     return 0;                   /* dummy */
 }
 
+/* SMP VMX guest support */
+void vmx_init_ap_context(struct vcpu_guest_context *ctxt,
+                         int vcpuid, int trampoline_vector)
+{
+    int i;
+
+    memset(ctxt, 0, sizeof(*ctxt));
+
+    /*
+     * Initial register values:
+     */
+    ctxt->user_regs.eip = VMXASSIST_BASE;
+    ctxt->user_regs.edx = vcpuid;
+    ctxt->user_regs.ebx = trampoline_vector;
+
+    ctxt->flags = VGCF_HVM_GUEST;
+
+    /* Virtual IDT is empty at start-of-day. */
+    for ( i = 0; i < 256; i++ )
+    {
+        ctxt->trap_ctxt[i].vector = i;
+        ctxt->trap_ctxt[i].cs     = FLAT_KERNEL_CS;
+    }
+
+    /* No callback handlers. */
+#if defined(__i386__)
+    ctxt->event_callback_cs     = FLAT_KERNEL_CS;
+    ctxt->failsafe_callback_cs  = FLAT_KERNEL_CS;
+#endif
+}
+
 void do_nmi(struct cpu_user_regs *);
 
 static int check_vmx_controls(ctrls, msr)
@@ -544,6 +575,8 @@
     hvm_funcs.paging_enabled = vmx_paging_enabled;
     hvm_funcs.instruction_length = vmx_instruction_length;
     hvm_funcs.get_guest_ctrl_reg = vmx_get_ctrl_reg;
+
+    hvm_funcs.init_ap_context = vmx_init_ap_context;
 
     hvm_enabled = 1;
 
diff -r 71f2d19cd3a5 -r cf1c1bb9f6d2 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h     Fri Feb 24 16:32:19 2006
+++ b/xen/include/asm-x86/hvm/hvm.h     Fri Feb 24 16:32:58 2006
@@ -67,6 +67,9 @@
     int (*paging_enabled)(struct vcpu *v);
     int (*instruction_length)(struct vcpu *v);
     unsigned long (*get_guest_ctrl_reg)(struct vcpu *v, unsigned int num);
+
+    void (*init_ap_context)(struct vcpu_guest_context *ctxt,
+                            int vcpuid, int trampoline_vector);
 };
 
 extern struct hvm_function_table hvm_funcs;
@@ -173,4 +176,14 @@
         return hvm_funcs.get_guest_ctrl_reg(v, num);
     return 0;                   /* force to fail */
 }
+
+static inline void
+hvm_init_ap_context(struct vcpu_guest_context *ctxt,
+                    int vcpuid, int trampoline_vector)
+{
+    return hvm_funcs.init_ap_context(ctxt, vcpuid, trampoline_vector);
+}
+
+extern int hvm_bringup_ap(int vcpuid, int trampoline_vector);
+
 #endif /* __ASM_X86_HVM_HVM_H__ */
diff -r 71f2d19cd3a5 -r cf1c1bb9f6d2 xen/include/asm-x86/hvm/vcpu.h
--- a/xen/include/asm-x86/hvm/vcpu.h    Fri Feb 24 16:32:19 2006
+++ b/xen/include/asm-x86/hvm/vcpu.h    Fri Feb 24 16:32:58 2006
@@ -25,10 +25,15 @@
 #include <asm/hvm/vmx/vmcs.h>
 #include <asm/hvm/svm/vmcb.h>
 
+#define HVM_VCPU_INIT_SIPI_SIPI_STATE_NORM          0
+#define HVM_VCPU_INIT_SIPI_SIPI_STATE_WAIT_SIPI     1
+
 struct hvm_vcpu {
-    unsigned long       ioflags;
-    struct mmio_op      mmio_op;
-    struct vlapic       *vlapic;
+    unsigned long   ioflags;
+    struct mmio_op  mmio_op;
+    struct vlapic   *vlapic;
+    /* For AP startup */
+    unsigned long   init_sipi_sipi_state;
 
     union {
         struct arch_vmx_struct vmx;
diff -r 71f2d19cd3a5 -r cf1c1bb9f6d2 xen/include/asm-x86/hvm/vlapic.h
--- a/xen/include/asm-x86/hvm/vlapic.h  Fri Feb 24 16:32:19 2006
+++ b/xen/include/asm-x86/hvm/vlapic.h  Fri Feb 24 16:32:58 2006
@@ -158,9 +158,6 @@
     int deliver_mode;
     int source[6];
 } direct_intr_info_t;
-
-#define VLAPIC_INIT_SIPI_SIPI_STATE_NORM          0
-#define VLAPIC_INIT_SIPI_SIPI_STATE_WAIT_SIPI     1
 
 struct vlapic
 {
@@ -197,7 +194,6 @@
     unsigned long      init_ticks;
     uint32_t           err_write_count;
     uint64_t           apic_base_msr;
-    uint32_t           init_sipi_sipi_state;
     struct vcpu        *vcpu;
     struct domain      *domain;
 };

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Bring up AP of VMX domain., Xen patchbot -unstable <=