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;
vmcs_allocation.patch
Description: vmcs_allocation.patch
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|