# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 6e11af443eb1cc3ff5533d531ab48c9964ad2dee
# Parent 07884fe7c5ce0efe7605a3dcbf8a026be9552145
Fix problem of can not create two or more vmx guest.
The original gdb server patch will cause the new vmx guest break the=20
old one. This patch make the arch_set_guest_info modify the correct
vmcs and also skip modifying during creating.
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@xxxxxxxxx>^
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>
diff -r 07884fe7c5ce -r 6e11af443eb1 xen/include/asm-x86/vmx.h
--- a/xen/include/asm-x86/vmx.h Thu Jul 21 13:59:49 2005
+++ b/xen/include/asm-x86/vmx.h Thu Jul 21 14:15:35 2005
@@ -447,4 +447,8 @@
return get_sp(d)->sp_global.eport;
}
+/* Prototypes */
+void load_cpu_user_regs(struct cpu_user_regs *regs);
+void store_cpu_user_regs(struct cpu_user_regs *regs);
+
#endif /* __ASM_X86_VMX_H__ */
diff -r 07884fe7c5ce -r 6e11af443eb1 xen/arch/x86/vmx_vmcs.c
--- a/xen/arch/x86/vmx_vmcs.c Thu Jul 21 13:59:49 2005
+++ b/xen/arch/x86/vmx_vmcs.c Thu Jul 21 14:15:35 2005
@@ -453,6 +453,35 @@
return -EINVAL;
}
+ if (regs->eflags & EF_TF)
+ __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
+ else
+ __vm_clear_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
+
+ return 0;
+}
+
+/*
+ * modify guest eflags and execption bitmap for gdb
+ */
+int modify_vmcs(struct arch_vmx_struct *arch_vmx,
+ struct cpu_user_regs *regs)
+{
+ int error;
+ u64 vmcs_phys_ptr, old, old_phys_ptr;
+ vmcs_phys_ptr = (u64) virt_to_phys(arch_vmx->vmcs);
+
+ old_phys_ptr = virt_to_phys(&old);
+ __vmptrst(old_phys_ptr);
+ if ((error = load_vmcs(arch_vmx, vmcs_phys_ptr))) {
+ printk("modify_vmcs: load_vmcs failed: VMCS = %lx\n",
+ (unsigned long) vmcs_phys_ptr);
+ return -EINVAL;
+ }
+ load_cpu_user_regs(regs);
+
+ __vmptrld(old_phys_ptr);
+
return 0;
}
diff -r 07884fe7c5ce -r 6e11af443eb1 xen/include/asm-x86/vmx_vmcs.h
--- a/xen/include/asm-x86/vmx_vmcs.h Thu Jul 21 13:59:49 2005
+++ b/xen/include/asm-x86/vmx_vmcs.h Thu Jul 21 14:15:35 2005
@@ -97,6 +97,8 @@
int store_vmcs(struct arch_vmx_struct *, u64);
int construct_vmcs(struct arch_vmx_struct *, struct cpu_user_regs *,
struct vcpu_guest_context *, int);
+int modify_vmcs(struct arch_vmx_struct *arch_vmx,
+ struct cpu_user_regs *regs);
#define VMCS_USE_HOST_ENV 1
#define VMCS_USE_SEPARATE_ENV 0
diff -r 07884fe7c5ce -r 6e11af443eb1 xen/arch/x86/vmx_io.c
--- a/xen/arch/x86/vmx_io.c Thu Jul 21 13:59:49 2005
+++ b/xen/arch/x86/vmx_io.c Thu Jul 21 14:15:35 2005
@@ -39,14 +39,20 @@
#ifdef CONFIG_VMX
#if defined (__i386__)
-static void load_cpu_user_regs(struct cpu_user_regs *regs)
+void load_cpu_user_regs(struct cpu_user_regs *regs)
{
/*
* Write the guest register value into VMCS
*/
__vmwrite(GUEST_SS_SELECTOR, regs->ss);
__vmwrite(GUEST_RSP, regs->esp);
+
__vmwrite(GUEST_RFLAGS, regs->eflags);
+ if (regs->eflags & EF_TF)
+ __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
+ else
+ __vm_clear_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
+
__vmwrite(GUEST_CS_SELECTOR, regs->cs);
__vmwrite(GUEST_RIP, regs->eip);
}
@@ -175,11 +181,17 @@
}
}
#else
-static void load_cpu_user_regs(struct cpu_user_regs *regs)
+void load_cpu_user_regs(struct cpu_user_regs *regs)
{
__vmwrite(GUEST_SS_SELECTOR, regs->ss);
__vmwrite(GUEST_RSP, regs->rsp);
+
__vmwrite(GUEST_RFLAGS, regs->rflags);
+ if (regs->rflags & EF_TF)
+ __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
+ else
+ __vm_clear_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
+
__vmwrite(GUEST_CS_SELECTOR, regs->cs);
__vmwrite(GUEST_RIP, regs->rip);
}
diff -r 07884fe7c5ce -r 6e11af443eb1 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c Thu Jul 21 13:59:49 2005
+++ b/xen/arch/x86/domain.c Thu Jul 21 14:15:35 2005
@@ -417,12 +417,12 @@
/* Ensure real hardware interrupts are enabled. */
v->arch.guest_context.user_regs.eflags |= EF_IE;
- } else {
- __vmwrite(GUEST_RFLAGS, v->arch.guest_context.user_regs.eflags);
- if (v->arch.guest_context.user_regs.eflags & EF_TF)
- __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
- else
- __vm_clear_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
+ }
+ else if ( test_bit(_VCPUF_initialised, &v->vcpu_flags) )
+ {
+ return modify_vmcs(
+ &v->arch.arch_vmx,
+ &v->arch.guest_context.user_regs);
}
if ( test_bit(_VCPUF_initialised, &v->vcpu_flags) )
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|