|
|
|
|
|
|
|
|
|
|
xen-devel
[Xen-devel] [PATCH 12 of 20] Add APIs to switch n1/n2 VMCS
# HG changeset patch
# User Eddie Dong <eddie.dong@xxxxxxxxx>
# Date 1307607849 -28800
# Node ID 549f110b69dc235e8159079f38d8225ccd1db649
# Parent c9f43a690ed89169aecbf85940bd7fff390e7497
Add APIs to switch n1/n2 VMCS.
Signed-off-by: Qing He <qing.he@xxxxxxxxx>
Signed-off-by: Eddie Dong <eddie.dong@xxxxxxxxx>
diff -r c9f43a690ed8 -r 549f110b69dc xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c Thu Jun 09 16:24:09 2011 +0800
+++ b/xen/arch/x86/hvm/vmx/vmcs.c Thu Jun 09 16:24:09 2011 +0800
@@ -669,6 +669,31 @@ void vmx_disable_intercept_for_msr(struc
}
}
+/*
+ * Switch VMCS between layer 1 & 2 guest
+ */
+void vmx_vmcs_switch(struct vcpu *v,
+ struct vmcs_struct *from,
+ struct vmcs_struct *to)
+{
+ spin_lock(&v->arch.hvm_vmx.vmcs_lock);
+
+ __vmpclear(virt_to_maddr(from));
+ __vmptrld(virt_to_maddr(to));
+
+ v->arch.hvm_vmx.vmcs = to;
+ v->arch.hvm_vmx.launched = 0;
+ this_cpu(current_vmcs) = to;
+
+ if ( v->arch.hvm_vmx.hostenv_migrated )
+ {
+ v->arch.hvm_vmx.hostenv_migrated = 0;
+ vmx_set_host_env(v);
+ }
+
+ spin_unlock(&v->arch.hvm_vmx.vmcs_lock);
+}
+
static int construct_vmcs(struct vcpu *v)
{
struct domain *d = v->domain;
@@ -1078,6 +1103,13 @@ void vmx_do_resume(struct vcpu *v)
hvm_migrate_timers(v);
hvm_migrate_pirqs(v);
vmx_set_host_env(v);
+ /*
+ * Both n1 VMCS and n2 VMCS need to update the host environment after
+ * VCPU migration. The environment of current VMCS is updated in place,
+ * but the action of another VMCS is deferred till it is switched in.
+ */
+ v->arch.hvm_vmx.hostenv_migrated = 1;
+
hvm_asid_flush_vcpu(v);
}
diff -r c9f43a690ed8 -r 549f110b69dc xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h Thu Jun 09 16:24:09 2011 +0800
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h Thu Jun 09 16:24:09 2011 +0800
@@ -123,6 +123,7 @@ struct arch_vmx_struct {
struct segment_register vm86_saved_seg[x86_seg_tr + 1];
/* Remember EFLAGS while in virtual 8086 mode */
uint32_t vm86_saved_eflags;
+ int hostenv_migrated;
};
int vmx_create_vmcs(struct vcpu *v);
@@ -392,6 +393,9 @@ int vmx_read_guest_msr(u32 msr, u64 *val
int vmx_write_guest_msr(u32 msr, u64 val);
int vmx_add_guest_msr(u32 msr);
int vmx_add_host_load_msr(u32 msr);
+void vmx_vmcs_switch(struct vcpu *v,
+ struct vmcs_struct *from,
+ struct vmcs_struct *to);
#endif /* ASM_X86_HVM_VMX_VMCS_H__ */
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- [Xen-devel] [PATCH 01 of 20] pre-cleanup1: Extend nhvm_vmcx_guest_intercepts_trap to include errcode to, (continued)
- [Xen-devel] [PATCH 01 of 20] pre-cleanup1: Extend nhvm_vmcx_guest_intercepts_trap to include errcode to, Eddie Dong
- [Xen-devel] [PATCH 02 of 20] pre-cleanup2: Move IDT_VECTORING processing code out of intr_assist, Eddie Dong
- [Xen-devel] [PATCH 03 of 20] Add data structure for nestedvmx, Eddie Dong
- [Xen-devel] [PATCH 04 of 20] Add APIs for nestedhvm_ops, Eddie Dong
- [Xen-devel] [PATCH 07 of 20] Emulation of guest vmptrld, Eddie Dong
- [Xen-devel] [PATCH 05 of 20] Emulation of guest VMXON/OFF instruction, Eddie Dong
- [Xen-devel] [PATCH 06 of 20] Define structure and access APIs for virtual VMCS, Eddie Dong
- [Xen-devel] [PATCH 09 of 20] Emulation of guest VMCLEAR, Eddie Dong
- [Xen-devel] [PATCH 08 of 20] Emulation of guest VMPTRST, Eddie Dong
- [Xen-devel] [PATCH 12 of 20] Add APIs to switch n1/n2 VMCS,
Eddie Dong <=
- [Xen-devel] [PATCH 11 of 20] Emulation of guest VMREAD, Eddie Dong
- [Xen-devel] [PATCH 14 of 20] Extend VMCS control fields for n2 guest, Eddie Dong
- [Xen-devel] [PATCH 13 of 20] Emulation of VMRESUME/VMLAUNCH, Eddie Dong
- [Xen-devel] [PATCH 10 of 20] Emulation of guest VMWRITE, Eddie Dong
- [Xen-devel] [PATCH 15 of 20] Switch shadow/virtual VMCS between n1/n2 guests, Eddie Dong
- [Xen-devel] [PATCH 20 of 20] n2 MSR handling and capability exposure, Eddie Dong
|
|
|
|
|