Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202272
b: refs/heads/master
c: 4610c9c
h: refs/heads/master
v: v3
  • Loading branch information
Dongxiao Xu authored and Avi Kivity committed Aug 1, 2010
1 parent e69e511 commit 249053d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b923e62e4d48bc5242b32a6ef5ba0f886137668a
refs/heads/master: 4610c9cc6d9c84f7d585583699f04d5f51c83671
38 changes: 31 additions & 7 deletions trunk/arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ static inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu)

static int init_rmode(struct kvm *kvm);
static u64 construct_eptp(unsigned long root_hpa);
static void kvm_cpu_vmxon(u64 addr);
static void kvm_cpu_vmxoff(void);

static DEFINE_PER_CPU(struct vmcs *, vmxarea);
static DEFINE_PER_CPU(struct vmcs *, current_vmcs);
Expand Down Expand Up @@ -847,8 +849,11 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
u64 tsc_this, delta, new_offset;
u64 phys_addr = __pa(per_cpu(vmxarea, cpu));

if (vmm_exclusive && vcpu->cpu != cpu)
if (!vmm_exclusive)
kvm_cpu_vmxon(phys_addr);
else if (vcpu->cpu != cpu)
vcpu_clear(vmx);

if (per_cpu(current_vmcs, cpu) != vmx->vmcs) {
Expand Down Expand Up @@ -894,8 +899,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
static void vmx_vcpu_put(struct kvm_vcpu *vcpu)
{
__vmx_load_host_state(to_vmx(vcpu));
if (!vmm_exclusive)
if (!vmm_exclusive) {
__vcpu_clear(to_vmx(vcpu));
kvm_cpu_vmxoff();
}
}

static void vmx_fpu_activate(struct kvm_vcpu *vcpu)
Expand Down Expand Up @@ -1327,9 +1334,11 @@ static int hardware_enable(void *garbage)
wrmsrl(MSR_IA32_FEATURE_CONTROL, old | test_bits);
}
write_cr4(read_cr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */
kvm_cpu_vmxon(phys_addr);

ept_sync_global();
if (vmm_exclusive) {
kvm_cpu_vmxon(phys_addr);
ept_sync_global();
}

return 0;
}
Expand All @@ -1355,8 +1364,10 @@ static void kvm_cpu_vmxoff(void)

static void hardware_disable(void *garbage)
{
vmclear_local_vcpus();
kvm_cpu_vmxoff();
if (vmm_exclusive) {
vmclear_local_vcpus();
kvm_cpu_vmxoff();
}
write_cr4(read_cr4() & ~X86_CR4_VMXE);
}

Expand Down Expand Up @@ -3991,6 +4002,19 @@ static void vmx_free_vcpu(struct kvm_vcpu *vcpu)
kmem_cache_free(kvm_vcpu_cache, vmx);
}

static inline void vmcs_init(struct vmcs *vmcs)
{
u64 phys_addr = __pa(per_cpu(vmxarea, raw_smp_processor_id()));

if (!vmm_exclusive)
kvm_cpu_vmxon(phys_addr);

vmcs_clear(vmcs);

if (!vmm_exclusive)
kvm_cpu_vmxoff();
}

static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
{
int err;
Expand All @@ -4016,7 +4040,7 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
if (!vmx->vmcs)
goto free_msrs;

vmcs_clear(vmx->vmcs);
vmcs_init(vmx->vmcs);

cpu = get_cpu();
vmx_vcpu_load(&vmx->vcpu, cpu);
Expand Down

0 comments on commit 249053d

Please sign in to comment.