Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2fa3e9f authored by Gregory Haskins's avatar Gregory Haskins Committed by Avi Kivity
Browse files

KVM: Remove arch specific components from the general code



struct kvm_vcpu has vmx-specific members; remove them to a private structure.

Signed-off-by: default avatarGregory Haskins <ghaskins@novell.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent c820c2aa
Loading
Loading
Loading
Loading
+2 −29
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
#include <linux/mm.h>
#include <asm/signal.h>

#include "vmx.h"
#include <linux/kvm.h>
#include <linux/kvm_para.h>

@@ -140,14 +139,6 @@ struct kvm_mmu_page {
	};
};

struct vmcs {
	u32 revision_id;
	u32 abort;
	char data[0];
};

#define vmx_msr_entry kvm_msr_entry

struct kvm_vcpu;

/*
@@ -309,15 +300,12 @@ void kvm_io_bus_register_dev(struct kvm_io_bus *bus,
			     struct kvm_io_device *dev);

struct kvm_vcpu {
	int valid;
	struct kvm *kvm;
	int vcpu_id;
	union {
		struct vmcs *vmcs;
		struct vcpu_svm *svm;
	};
	void *_priv;
	struct mutex mutex;
	int   cpu;
	int   launched;
	u64 host_tsc;
	struct kvm_run *run;
	int interrupt_window_open;
@@ -340,14 +328,6 @@ struct kvm_vcpu {
	u64 shadow_efer;
	u64 apic_base;
	u64 ia32_misc_enable_msr;
	int nmsrs;
	int save_nmsrs;
	int msr_offset_efer;
#ifdef CONFIG_X86_64
	int msr_offset_kernel_gs_base;
#endif
	struct vmx_msr_entry *guest_msrs;
	struct vmx_msr_entry *host_msrs;

	struct kvm_mmu mmu;

@@ -366,11 +346,6 @@ struct kvm_vcpu {
	char *guest_fx_image;
	int fpu_active;
	int guest_fpu_loaded;
	struct vmx_host_state {
		int loaded;
		u16 fs_sel, gs_sel, ldt_sel;
		int fs_gs_ldt_reload_needed;
	} vmx_host_state;

	int mmio_needed;
	int mmio_read_completed;
@@ -579,8 +554,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data);

void fx_init(struct kvm_vcpu *vcpu);

void load_msrs(struct vmx_msr_entry *e, int n);
void save_msrs(struct vmx_msr_entry *e, int n);
void kvm_resched(struct kvm_vcpu *vcpu);
void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
+5 −21
Original line number Diff line number Diff line
@@ -367,7 +367,7 @@ static void free_pio_guest_pages(struct kvm_vcpu *vcpu)

static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)
{
	if (!vcpu->vmcs)
	if (!vcpu->valid)
		return;

	vcpu_load(vcpu);
@@ -377,7 +377,7 @@ static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)

static void kvm_free_vcpu(struct kvm_vcpu *vcpu)
{
	if (!vcpu->vmcs)
	if (!vcpu->valid)
		return;

	vcpu_load(vcpu);
@@ -1645,24 +1645,6 @@ void kvm_resched(struct kvm_vcpu *vcpu)
}
EXPORT_SYMBOL_GPL(kvm_resched);

void load_msrs(struct vmx_msr_entry *e, int n)
{
	int i;

	for (i = 0; i < n; ++i)
		wrmsrl(e[i].index, e[i].data);
}
EXPORT_SYMBOL_GPL(load_msrs);

void save_msrs(struct vmx_msr_entry *e, int n)
{
	int i;

	for (i = 0; i < n; ++i)
		rdmsrl(e[i].index, e[i].data);
}
EXPORT_SYMBOL_GPL(save_msrs);

void kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
{
	int i;
@@ -2401,7 +2383,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)

	mutex_lock(&vcpu->mutex);

	if (vcpu->vmcs) {
	if (vcpu->valid) {
		mutex_unlock(&vcpu->mutex);
		return -EEXIST;
	}
@@ -2449,6 +2431,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
		kvm->nvcpus = n + 1;
	spin_unlock(&kvm_lock);

	vcpu->valid = 1;

	return r;

out_free_vcpus:
+3 −0
Original line number Diff line number Diff line
@@ -20,7 +20,10 @@ static const u32 host_save_user_msrs[] = {
#define NR_HOST_SAVE_USER_MSRS ARRAY_SIZE(host_save_user_msrs)
#define NUM_DB_REGS 4

struct kvm_vcpu;

struct vcpu_svm {
	struct kvm_vcpu *vcpu;
	struct vmcb *vmcb;
	unsigned long vmcb_pa;
	struct svm_cpu_data *svm_data;