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-devel

[Xen-devel] [PATCH] Allocate vmcs pages when system booting

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Allocate vmcs pages when system booting
From: "Jiang, Yunhong" <yunhong.jiang@xxxxxxxxx>
Date: Thu, 12 Nov 2009 18:52:11 +0800
Accept-language: en-US
Acceptlanguage: en-US
Cc:
Delivery-date: Thu, 12 Nov 2009 02:52:38 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acpjhi/FowWYJHS9QX+XJREOh9n85g==
Thread-topic: [PATCH] Allocate vmcs pages when system booting
Currently the VMCS page is allocated when the CPU is brought-up and identified, 
and then spin_debug_enable() is called.

This does not work for cpu hot-add. When hot-added CPU is brought-up and try to 
allocate the vmcs page, it will hit check_lock, because irq is disabled still.

This patch allocate the vmcs pages for all possible pages when system booting, 
so that we don't allocate vmcs anymore when secondary CPU is up.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@xxxxxxxxx>

diff -r 1db7034f4498 xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c       Thu Nov 12 00:05:59 2009 +0800
+++ b/xen/arch/x86/hvm/vmx/vmcs.c       Thu Nov 12 04:08:25 2009 +0800
@@ -267,6 +267,34 @@ static void vmx_free_vmcs(struct vmcs_st
 static void vmx_free_vmcs(struct vmcs_struct *vmcs)
 {
     free_xenheap_page(vmcs);
+}
+
+int vmx_allocate_vmcs_pages(void)
+{
+    int cpu, ret = 0;
+
+    for_each_possible_cpu(cpu)
+    {
+        if (per_cpu(host_vmcs, cpu) == NULL)
+        {
+            per_cpu(host_vmcs, cpu) = vmx_alloc_vmcs();
+            if (per_cpu(host_vmcs, cpu) == NULL)
+            {
+                ret = -1;
+                break;
+            }
+        }
+    }
+
+    if (ret < 0)
+    {
+        for_each_possible_cpu(cpu)
+        {
+            if (per_cpu(host_vmcs, cpu))
+                vmx_free_vmcs(per_cpu(host_vmcs, cpu));
+        }
+    }
+    return ret;
 }
 
 static void __vmx_clear_vmcs(void *info)
diff -r 1db7034f4498 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Thu Nov 12 00:05:59 2009 +0800
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Thu Nov 12 04:08:25 2009 +0800
@@ -1450,6 +1450,16 @@ void start_vmx(void)
     if ( !test_bit(X86_FEATURE_VMXE, &boot_cpu_data.x86_capability) )
         return;
 
+    /*
+     * We can't allocate VMCS pages when start_secondary for hot-added CPU
+     * because allocate page at that time will trigger check_lock error
+     */
+    if (vmx_allocate_vmcs_pages())
+    {
+        printk("VMX: failed to alloca vmcs pages\n");
+        return;
+    }
+
     set_in_cr4(X86_CR4_VMXE);
 
     if ( !vmx_cpu_up() )
diff -r 1db7034f4498 xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h        Thu Nov 12 00:05:59 2009 +0800
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h        Thu Nov 12 04:08:25 2009 +0800
@@ -28,6 +28,7 @@ extern void setup_vmcs_dump(void);
 extern void setup_vmcs_dump(void);
 extern int  vmx_cpu_up(void);
 extern void vmx_cpu_down(void);
+extern int vmx_allocate_vmcs_pages(void);
 
 struct vmcs_struct {
     u32 vmcs_revision_id;

Attachment: vmcs_allocation.patch
Description: vmcs_allocation.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>