Commit 9ef78b62 authored by Michael Ellerman's avatar Michael Ellerman

Merge branch 'topic/ppc-kvm' into next

Merge our topic branch containing powerpc KVM related commits.

Alexey Kardashevskiy (1):
      KVM: PPC: Merge powerpc's debugfs entry content into generic entry

Fabiano Rosas (9):
      KVM: PPC: Book3S HV: Stop returning internal values to userspace
      KVM: PPC: Fix vmx/vsx mixup in mmio emulation
      KVM: PPC: mmio: Reject instructions that access more than mmio.data size
      KVM: PPC: mmio: Return to guest after emulation failure
      KVM: PPC: Book3s: mmio: Deliver DSI after emulation failure
      KVM: PPC: Book3S HV: Check return value of kvmppc_radix_init
      KVM: PPC: Book3S HV: Delay setting of kvm ops
      KVM: PPC: Book3S HV: Free allocated memory if module init fails
      KVM: PPC: Decrement module refcount if init_vm fails

Jason Wang (1):
      powerpc/kvm: no need to initialise statics to 0

Nour-eddine Taleb (1):
      KVM: PPC: Book3S HV: remove unnecessary casts
parents 4bc06c59 e40b38a4
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <asm/hvcall.h> #include <asm/hvcall.h>
#include <asm/mce.h> #include <asm/mce.h>
#define __KVM_HAVE_ARCH_VCPU_DEBUGFS
#define KVM_MAX_VCPUS NR_CPUS #define KVM_MAX_VCPUS NR_CPUS
#define KVM_MAX_VCORES NR_CPUS #define KVM_MAX_VCORES NR_CPUS
...@@ -295,7 +297,6 @@ struct kvm_arch { ...@@ -295,7 +297,6 @@ struct kvm_arch {
bool dawr1_enabled; bool dawr1_enabled;
pgd_t *pgtable; pgd_t *pgtable;
u64 process_table; u64 process_table;
struct dentry *debugfs_dir;
struct kvm_resize_hpt *resize_hpt; /* protected by kvm->lock */ struct kvm_resize_hpt *resize_hpt; /* protected by kvm->lock */
#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
...@@ -673,7 +674,6 @@ struct kvm_vcpu_arch { ...@@ -673,7 +674,6 @@ struct kvm_vcpu_arch {
u64 timing_min_duration[__NUMBER_OF_KVM_EXIT_TYPES]; u64 timing_min_duration[__NUMBER_OF_KVM_EXIT_TYPES];
u64 timing_max_duration[__NUMBER_OF_KVM_EXIT_TYPES]; u64 timing_max_duration[__NUMBER_OF_KVM_EXIT_TYPES];
u64 timing_last_exit; u64 timing_last_exit;
struct dentry *debugfs_exit_timing;
#endif #endif
#ifdef CONFIG_PPC_BOOK3S #ifdef CONFIG_PPC_BOOK3S
...@@ -831,8 +831,6 @@ struct kvm_vcpu_arch { ...@@ -831,8 +831,6 @@ struct kvm_vcpu_arch {
struct kvmhv_tb_accumulator rm_exit; /* real-mode exit code */ struct kvmhv_tb_accumulator rm_exit; /* real-mode exit code */
struct kvmhv_tb_accumulator guest_time; /* guest execution */ struct kvmhv_tb_accumulator guest_time; /* guest execution */
struct kvmhv_tb_accumulator cede_time; /* time napping inside guest */ struct kvmhv_tb_accumulator cede_time; /* time napping inside guest */
struct dentry *debugfs_dir;
#endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */ #endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */
}; };
......
...@@ -314,6 +314,8 @@ struct kvmppc_ops { ...@@ -314,6 +314,8 @@ struct kvmppc_ops {
int (*svm_off)(struct kvm *kvm); int (*svm_off)(struct kvm *kvm);
int (*enable_dawr1)(struct kvm *kvm); int (*enable_dawr1)(struct kvm *kvm);
bool (*hash_v3_possible)(void); bool (*hash_v3_possible)(void);
int (*create_vm_debugfs)(struct kvm *kvm);
int (*create_vcpu_debugfs)(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry);
}; };
extern struct kvmppc_ops *kvmppc_hv_ops; extern struct kvmppc_ops *kvmppc_hv_ops;
......
...@@ -228,7 +228,7 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid) ...@@ -228,7 +228,7 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)
struct kvmppc_sid_map *map; struct kvmppc_sid_map *map;
struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu); struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
u16 sid_map_mask; u16 sid_map_mask;
static int backwards_map = 0; static int backwards_map;
if (kvmppc_get_msr(vcpu) & MSR_PR) if (kvmppc_get_msr(vcpu) & MSR_PR)
gvsid |= VSID_PR; gvsid |= VSID_PR;
......
...@@ -2112,7 +2112,7 @@ static const struct file_operations debugfs_htab_fops = { ...@@ -2112,7 +2112,7 @@ static const struct file_operations debugfs_htab_fops = {
void kvmppc_mmu_debugfs_init(struct kvm *kvm) void kvmppc_mmu_debugfs_init(struct kvm *kvm)
{ {
debugfs_create_file("htab", 0400, kvm->arch.debugfs_dir, kvm, debugfs_create_file("htab", 0400, kvm->debugfs_dentry, kvm,
&debugfs_htab_fops); &debugfs_htab_fops);
} }
......
...@@ -1454,7 +1454,7 @@ static const struct file_operations debugfs_radix_fops = { ...@@ -1454,7 +1454,7 @@ static const struct file_operations debugfs_radix_fops = {
void kvmhv_radix_debugfs_init(struct kvm *kvm) void kvmhv_radix_debugfs_init(struct kvm *kvm)
{ {
debugfs_create_file("radix", 0400, kvm->arch.debugfs_dir, kvm, debugfs_create_file("radix", 0400, kvm->debugfs_dentry, kvm,
&debugfs_radix_fops); &debugfs_radix_fops);
} }
......
...@@ -2767,20 +2767,17 @@ static const struct file_operations debugfs_timings_ops = { ...@@ -2767,20 +2767,17 @@ static const struct file_operations debugfs_timings_ops = {
}; };
/* Create a debugfs directory for the vcpu */ /* Create a debugfs directory for the vcpu */
static void debugfs_vcpu_init(struct kvm_vcpu *vcpu, unsigned int id) static int kvmppc_arch_create_vcpu_debugfs_hv(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry)
{ {
char buf[16]; debugfs_create_file("timings", 0444, debugfs_dentry, vcpu,
struct kvm *kvm = vcpu->kvm;
snprintf(buf, sizeof(buf), "vcpu%u", id);
vcpu->arch.debugfs_dir = debugfs_create_dir(buf, kvm->arch.debugfs_dir);
debugfs_create_file("timings", 0444, vcpu->arch.debugfs_dir, vcpu,
&debugfs_timings_ops); &debugfs_timings_ops);
return 0;
} }
#else /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */ #else /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */
static void debugfs_vcpu_init(struct kvm_vcpu *vcpu, unsigned int id) static int kvmppc_arch_create_vcpu_debugfs_hv(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry)
{ {
return 0;
} }
#endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */ #endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */
...@@ -2903,8 +2900,6 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu) ...@@ -2903,8 +2900,6 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu)
vcpu->arch.cpu_type = KVM_CPU_3S_64; vcpu->arch.cpu_type = KVM_CPU_3S_64;
kvmppc_sanity_check(vcpu); kvmppc_sanity_check(vcpu);
debugfs_vcpu_init(vcpu, id);
return 0; return 0;
} }
...@@ -5223,7 +5218,6 @@ void kvmppc_free_host_rm_ops(void) ...@@ -5223,7 +5218,6 @@ void kvmppc_free_host_rm_ops(void)
static int kvmppc_core_init_vm_hv(struct kvm *kvm) static int kvmppc_core_init_vm_hv(struct kvm *kvm)
{ {
unsigned long lpcr, lpid; unsigned long lpcr, lpid;
char buf[32];
int ret; int ret;
mutex_init(&kvm->arch.uvmem_lock); mutex_init(&kvm->arch.uvmem_lock);
...@@ -5356,15 +5350,14 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm) ...@@ -5356,15 +5350,14 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
kvm->arch.smt_mode = 1; kvm->arch.smt_mode = 1;
kvm->arch.emul_smt_mode = 1; kvm->arch.emul_smt_mode = 1;
/* return 0;
* Create a debugfs directory for the VM }
*/
snprintf(buf, sizeof(buf), "vm%d", current->pid); static int kvmppc_arch_create_vm_debugfs_hv(struct kvm *kvm)
kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir); {
kvmppc_mmu_debugfs_init(kvm); kvmppc_mmu_debugfs_init(kvm);
if (radix_enabled()) if (radix_enabled())
kvmhv_radix_debugfs_init(kvm); kvmhv_radix_debugfs_init(kvm);
return 0; return 0;
} }
...@@ -5379,8 +5372,6 @@ static void kvmppc_free_vcores(struct kvm *kvm) ...@@ -5379,8 +5372,6 @@ static void kvmppc_free_vcores(struct kvm *kvm)
static void kvmppc_core_destroy_vm_hv(struct kvm *kvm) static void kvmppc_core_destroy_vm_hv(struct kvm *kvm)
{ {
debugfs_remove_recursive(kvm->arch.debugfs_dir);
if (!cpu_has_feature(CPU_FTR_ARCH_300)) if (!cpu_has_feature(CPU_FTR_ARCH_300))
kvm_hv_vm_deactivated(); kvm_hv_vm_deactivated();
...@@ -6042,6 +6033,8 @@ static struct kvmppc_ops kvm_ops_hv = { ...@@ -6042,6 +6033,8 @@ static struct kvmppc_ops kvm_ops_hv = {
.svm_off = kvmhv_svm_off, .svm_off = kvmhv_svm_off,
.enable_dawr1 = kvmhv_enable_dawr1, .enable_dawr1 = kvmhv_enable_dawr1,
.hash_v3_possible = kvmppc_hash_v3_possible, .hash_v3_possible = kvmppc_hash_v3_possible,
.create_vcpu_debugfs = kvmppc_arch_create_vcpu_debugfs_hv,
.create_vm_debugfs = kvmppc_arch_create_vm_debugfs_hv,
}; };
static int kvm_init_subcore_bitmap(void) static int kvm_init_subcore_bitmap(void)
...@@ -6103,7 +6096,7 @@ static int kvmppc_book3s_init_hv(void) ...@@ -6103,7 +6096,7 @@ static int kvmppc_book3s_init_hv(void)
if (!cpu_has_feature(CPU_FTR_ARCH_300)) { if (!cpu_has_feature(CPU_FTR_ARCH_300)) {
r = kvm_init_subcore_bitmap(); r = kvm_init_subcore_bitmap();
if (r) if (r)
return r; goto err;
} }
/* /*
...@@ -6119,30 +6112,42 @@ static int kvmppc_book3s_init_hv(void) ...@@ -6119,30 +6112,42 @@ static int kvmppc_book3s_init_hv(void)
np = of_find_compatible_node(NULL, NULL, "ibm,opal-intc"); np = of_find_compatible_node(NULL, NULL, "ibm,opal-intc");
if (!np) { if (!np) {
pr_err("KVM-HV: Cannot determine method for accessing XICS\n"); pr_err("KVM-HV: Cannot determine method for accessing XICS\n");
return -ENODEV; r = -ENODEV;
goto err;
} }
/* presence of intc confirmed - node can be dropped again */ /* presence of intc confirmed - node can be dropped again */
of_node_put(np); of_node_put(np);
} }
#endif #endif
kvm_ops_hv.owner = THIS_MODULE;
kvmppc_hv_ops = &kvm_ops_hv;
init_default_hcalls(); init_default_hcalls();
init_vcore_lists(); init_vcore_lists();
r = kvmppc_mmu_hv_init(); r = kvmppc_mmu_hv_init();
if (r) if (r)
return r; goto err;
if (kvmppc_radix_possible()) if (kvmppc_radix_possible()) {
r = kvmppc_radix_init(); r = kvmppc_radix_init();
if (r)
goto err;
}
r = kvmppc_uvmem_init(); r = kvmppc_uvmem_init();
if (r < 0) if (r < 0) {
pr_err("KVM-HV: kvmppc_uvmem_init failed %d\n", r); pr_err("KVM-HV: kvmppc_uvmem_init failed %d\n", r);
return r;
}
kvm_ops_hv.owner = THIS_MODULE;
kvmppc_hv_ops = &kvm_ops_hv;
return 0;
err:
kvmhv_nested_exit();
kvmppc_radix_exit();
return r; return r;
} }
......
...@@ -1016,19 +1016,10 @@ DEFINE_SHOW_ATTRIBUTE(xics_debug); ...@@ -1016,19 +1016,10 @@ DEFINE_SHOW_ATTRIBUTE(xics_debug);
static void xics_debugfs_init(struct kvmppc_xics *xics) static void xics_debugfs_init(struct kvmppc_xics *xics)
{ {
char *name; xics->dentry = debugfs_create_file("xics", 0444, xics->kvm->debugfs_dentry,
name = kasprintf(GFP_KERNEL, "kvm-xics-%p", xics);
if (!name) {
pr_err("%s: no memory for name\n", __func__);
return;
}
xics->dentry = debugfs_create_file(name, 0444, arch_debugfs_dir,
xics, &xics_debug_fops); xics, &xics_debug_fops);
pr_debug("%s: created %s\n", __func__, name); pr_debug("%s: created\n", __func__);
kfree(name);
} }
static struct kvmppc_ics *kvmppc_xics_create_ics(struct kvm *kvm, static struct kvmppc_ics *kvmppc_xics_create_ics(struct kvm *kvm,
...@@ -1440,7 +1431,7 @@ static int kvmppc_xics_create(struct kvm_device *dev, u32 type) ...@@ -1440,7 +1431,7 @@ static int kvmppc_xics_create(struct kvm_device *dev, u32 type)
static void kvmppc_xics_init(struct kvm_device *dev) static void kvmppc_xics_init(struct kvm_device *dev)
{ {
struct kvmppc_xics *xics = (struct kvmppc_xics *)dev->private; struct kvmppc_xics *xics = dev->private;
xics_debugfs_init(xics); xics_debugfs_init(xics);
} }
......
...@@ -2354,24 +2354,15 @@ DEFINE_SHOW_ATTRIBUTE(xive_debug); ...@@ -2354,24 +2354,15 @@ DEFINE_SHOW_ATTRIBUTE(xive_debug);
static void xive_debugfs_init(struct kvmppc_xive *xive) static void xive_debugfs_init(struct kvmppc_xive *xive)
{ {
char *name; xive->dentry = debugfs_create_file("xive", S_IRUGO, xive->kvm->debugfs_dentry,
name = kasprintf(GFP_KERNEL, "kvm-xive-%p", xive);
if (!name) {
pr_err("%s: no memory for name\n", __func__);
return;
}
xive->dentry = debugfs_create_file(name, S_IRUGO, arch_debugfs_dir,
xive, &xive_debug_fops); xive, &xive_debug_fops);
pr_debug("%s: created %s\n", __func__, name); pr_debug("%s: created\n", __func__);
kfree(name);
} }
static void kvmppc_xive_init(struct kvm_device *dev) static void kvmppc_xive_init(struct kvm_device *dev)
{ {
struct kvmppc_xive *xive = (struct kvmppc_xive *)dev->private; struct kvmppc_xive *xive = dev->private;
/* Register some debug interfaces */ /* Register some debug interfaces */
xive_debugfs_init(xive); xive_debugfs_init(xive);
......
...@@ -1259,24 +1259,15 @@ DEFINE_SHOW_ATTRIBUTE(xive_native_debug); ...@@ -1259,24 +1259,15 @@ DEFINE_SHOW_ATTRIBUTE(xive_native_debug);
static void xive_native_debugfs_init(struct kvmppc_xive *xive) static void xive_native_debugfs_init(struct kvmppc_xive *xive)
{ {
char *name; xive->dentry = debugfs_create_file("xive", 0444, xive->kvm->debugfs_dentry,
name = kasprintf(GFP_KERNEL, "kvm-xive-%p", xive);
if (!name) {
pr_err("%s: no memory for name\n", __func__);
return;
}
xive->dentry = debugfs_create_file(name, 0444, arch_debugfs_dir,
xive, &xive_native_debug_fops); xive, &xive_native_debug_fops);
pr_debug("%s: created %s\n", __func__, name); pr_debug("%s: created\n", __func__);
kfree(name);
} }
static void kvmppc_xive_native_init(struct kvm_device *dev) static void kvmppc_xive_native_init(struct kvm_device *dev)
{ {
struct kvmppc_xive *xive = (struct kvmppc_xive *)dev->private; struct kvmppc_xive *xive = dev->private;
/* Register some debug interfaces */ /* Register some debug interfaces */
xive_native_debugfs_init(xive); xive_native_debugfs_init(xive);
......
...@@ -495,6 +495,7 @@ static struct kvmppc_ops kvm_ops_e500 = { ...@@ -495,6 +495,7 @@ static struct kvmppc_ops kvm_ops_e500 = {
.emulate_op = kvmppc_core_emulate_op_e500, .emulate_op = kvmppc_core_emulate_op_e500,
.emulate_mtspr = kvmppc_core_emulate_mtspr_e500, .emulate_mtspr = kvmppc_core_emulate_mtspr_e500,
.emulate_mfspr = kvmppc_core_emulate_mfspr_e500, .emulate_mfspr = kvmppc_core_emulate_mfspr_e500,
.create_vcpu_debugfs = kvmppc_create_vcpu_debugfs_e500,
}; };
static int __init kvmppc_e500_init(void) static int __init kvmppc_e500_init(void)
......
...@@ -381,6 +381,7 @@ static struct kvmppc_ops kvm_ops_e500mc = { ...@@ -381,6 +381,7 @@ static struct kvmppc_ops kvm_ops_e500mc = {
.emulate_op = kvmppc_core_emulate_op_e500, .emulate_op = kvmppc_core_emulate_op_e500,
.emulate_mtspr = kvmppc_core_emulate_mtspr_e500, .emulate_mtspr = kvmppc_core_emulate_mtspr_e500,
.emulate_mfspr = kvmppc_core_emulate_mfspr_e500, .emulate_mfspr = kvmppc_core_emulate_mfspr_e500,
.create_vcpu_debugfs = kvmppc_create_vcpu_debugfs_e500,
}; };
static int __init kvmppc_e500mc_init(void) static int __init kvmppc_e500mc_init(void)
......
...@@ -73,7 +73,6 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) ...@@ -73,7 +73,6 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
{ {
u32 inst; u32 inst;
enum emulation_result emulated = EMULATE_FAIL; enum emulation_result emulated = EMULATE_FAIL;
int advance = 1;
struct instruction_op op; struct instruction_op op;
/* this default type might be overwritten by subcategories */ /* this default type might be overwritten by subcategories */
...@@ -98,6 +97,8 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) ...@@ -98,6 +97,8 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
int type = op.type & INSTR_TYPE_MASK; int type = op.type & INSTR_TYPE_MASK;
int size = GETSIZE(op.type); int size = GETSIZE(op.type);
vcpu->mmio_is_write = OP_IS_STORE(type);
switch (type) { switch (type) {
case LOAD: { case LOAD: {
int instr_byte_swap = op.type & BYTEREV; int instr_byte_swap = op.type & BYTEREV;
...@@ -355,15 +356,10 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) ...@@ -355,15 +356,10 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
} }
} }
if (emulated == EMULATE_FAIL) {
advance = 0;
kvmppc_core_queue_program(vcpu, 0);
}
trace_kvm_ppc_instr(inst, kvmppc_get_pc(vcpu), emulated); trace_kvm_ppc_instr(inst, kvmppc_get_pc(vcpu), emulated);
/* Advance past emulated instruction. */ /* Advance past emulated instruction. */
if (advance) if (emulated != EMULATE_FAIL)
kvmppc_set_pc(vcpu, kvmppc_get_pc(vcpu) + 4); kvmppc_set_pc(vcpu, kvmppc_get_pc(vcpu) + 4);
return emulated; return emulated;
......
...@@ -307,9 +307,31 @@ int kvmppc_emulate_mmio(struct kvm_vcpu *vcpu) ...@@ -307,9 +307,31 @@ int kvmppc_emulate_mmio(struct kvm_vcpu *vcpu)
u32 last_inst; u32 last_inst;
kvmppc_get_last_inst(vcpu, INST_GENERIC, &last_inst); kvmppc_get_last_inst(vcpu, INST_GENERIC, &last_inst);
/* XXX Deliver Program interrupt to guest. */ kvm_debug_ratelimited("Guest access to device memory using unsupported instruction (opcode: %#08x)\n",
pr_emerg("%s: emulation failed (%08x)\n", __func__, last_inst); last_inst);
r = RESUME_HOST;
/*
* Injecting a Data Storage here is a bit more
* accurate since the instruction that caused the
* access could still be a valid one.
*/
if (!IS_ENABLED(CONFIG_BOOKE)) {
ulong dsisr = DSISR_BADACCESS;
if (vcpu->mmio_is_write)
dsisr |= DSISR_ISSTORE;
kvmppc_core_queue_data_storage(vcpu, vcpu->arch.vaddr_accessed, dsisr);
} else {
/*
* BookE does not send a SIGBUS on a bad
* fault, so use a Program interrupt instead
* to avoid a fault loop.
*/
kvmppc_core_queue_program(vcpu, 0);
}
r = RESUME_GUEST;
break; break;
} }
default: default:
...@@ -431,6 +453,8 @@ int kvm_arch_check_processor_compat(void *opaque) ...@@ -431,6 +453,8 @@ int kvm_arch_check_processor_compat(void *opaque)
int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
{ {
struct kvmppc_ops *kvm_ops = NULL; struct kvmppc_ops *kvm_ops = NULL;
int r;
/* /*
* if we have both HV and PR enabled, default is HV * if we have both HV and PR enabled, default is HV
*/ */
...@@ -452,11 +476,14 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) ...@@ -452,11 +476,14 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
} else } else
goto err_out; goto err_out;
if (kvm_ops->owner && !try_module_get(kvm_ops->owner)) if (!try_module_get(kvm_ops->owner))
return -ENOENT; return -ENOENT;
kvm->arch.kvm_ops = kvm_ops; kvm->arch.kvm_ops = kvm_ops;
return kvmppc_core_init_vm(kvm); r = kvmppc_core_init_vm(kvm);
if (r)
module_put(kvm_ops->owner);
return r;
err_out: err_out:
return -EINVAL; return -EINVAL;
} }
...@@ -755,7 +782,6 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) ...@@ -755,7 +782,6 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
rcuwait_init(&vcpu->arch.wait); rcuwait_init(&vcpu->arch.wait);
vcpu->arch.waitp = &vcpu->arch.wait; vcpu->arch.waitp = &vcpu->arch.wait;
kvmppc_create_vcpu_debugfs(vcpu, vcpu->vcpu_id);
return 0; return 0;
out_vcpu_uninit: out_vcpu_uninit:
...@@ -772,8 +798,6 @@ void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) ...@@ -772,8 +798,6 @@ void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
/* Make sure we're not using the vcpu anymore */ /* Make sure we're not using the vcpu anymore */
hrtimer_cancel(&vcpu->arch.dec_timer); hrtimer_cancel(&vcpu->arch.dec_timer);
kvmppc_remove_vcpu_debugfs(vcpu);
switch (vcpu->arch.irq_type) { switch (vcpu->arch.irq_type) {
case KVMPPC_IRQ_MPIC: case KVMPPC_IRQ_MPIC:
kvmppc_mpic_disconnect_vcpu(vcpu->arch.mpic, vcpu); kvmppc_mpic_disconnect_vcpu(vcpu->arch.mpic, vcpu);
...@@ -1114,10 +1138,8 @@ static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu) ...@@ -1114,10 +1138,8 @@ static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu)
struct kvm_run *run = vcpu->run; struct kvm_run *run = vcpu->run;
u64 gpr; u64 gpr;
if (run->mmio.len > sizeof(gpr)) { if (run->mmio.len > sizeof(gpr))
printk(KERN_ERR "bad MMIO length: %d\n", run->mmio.len);
return; return;
}
if (!vcpu->arch.mmio_host_swabbed) { if (!vcpu->arch.mmio_host_swabbed) {
switch (run->mmio.len) { switch (run->mmio.len) {
...@@ -1236,10 +1258,8 @@ static int __kvmppc_handle_load(struct kvm_vcpu *vcpu, ...@@ -1236,10 +1258,8 @@ static int __kvmppc_handle_load(struct kvm_vcpu *vcpu,
host_swabbed = !is_default_endian; host_swabbed = !is_default_endian;
} }
if (bytes > sizeof(run->mmio.data)) { if (bytes > sizeof(run->mmio.data))
printk(KERN_ERR "%s: bad MMIO length: %d\n", __func__, return EMULATE_FAIL;
run->mmio.len);
}
run->mmio.phys_addr = vcpu->arch.paddr_accessed; run->mmio.phys_addr = vcpu->arch.paddr_accessed;
run->mmio.len = bytes; run->mmio.len = bytes;
...@@ -1325,10 +1345,8 @@ int kvmppc_handle_store(struct kvm_vcpu *vcpu, ...@@ -1325,10 +1345,8 @@ int kvmppc_handle_store(struct kvm_vcpu *vcpu,
host_swabbed = !is_default_endian; host_swabbed = !is_default_endian;
} }
if (bytes > sizeof(run->mmio.data)) { if (bytes > sizeof(run->mmio.data))
printk(KERN_ERR "%s: bad MMIO length: %d\n", __func__, return EMULATE_FAIL;
run->mmio.len);
}
run->mmio.phys_addr = vcpu->arch.paddr_accessed; run->mmio.phys_addr = vcpu->arch.paddr_accessed;
run->mmio.len = bytes; run->mmio.len = bytes;
...@@ -1499,7 +1517,7 @@ int kvmppc_handle_vmx_load(struct kvm_vcpu *vcpu, ...@@ -1499,7 +1517,7 @@ int kvmppc_handle_vmx_load(struct kvm_vcpu *vcpu,
{ {
enum emulation_result emulated = EMULATE_DONE; enum emulation_result emulated = EMULATE_DONE;
if (vcpu->arch.mmio_vsx_copy_nums > 2) if (vcpu->arch.mmio_vmx_copy_nums > 2)
return EMULATE_FAIL; return EMULATE_FAIL;
while (vcpu->arch.mmio_vmx_copy_nums) { while (vcpu->arch.mmio_vmx_copy_nums) {
...@@ -1596,7 +1614,7 @@ int kvmppc_handle_vmx_store(struct kvm_vcpu *vcpu, ...@@ -1596,7 +1614,7 @@ int kvmppc_handle_vmx_store(struct kvm_vcpu *vcpu,
unsigned int index = rs & KVM_MMIO_REG_MASK; unsigned int index = rs & KVM_MMIO_REG_MASK;
enum emulation_result emulated = EMULATE_DONE; enum emulation_result emulated = EMULATE_DONE;
if (vcpu->arch.mmio_vsx_copy_nums > 2) if (vcpu->arch.mmio_vmx_copy_nums > 2)
return EMULATE_FAIL; return EMULATE_FAIL;
vcpu->arch.io_gpr = rs; vcpu->arch.io_gpr = rs;
...@@ -1841,6 +1859,14 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) ...@@ -1841,6 +1859,14 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
#ifdef CONFIG_ALTIVEC #ifdef CONFIG_ALTIVEC
out: out:
#endif #endif
/*
* We're already returning to userspace, don't pass the
* RESUME_HOST flags along.
*/
if (r > 0)
r = 0;
vcpu_put(vcpu); vcpu_put(vcpu);
return r; return r;
} }
...@@ -2497,3 +2523,16 @@ int kvm_arch_init(void *opaque) ...@@ -2497,3 +2523,16 @@ int kvm_arch_init(void *opaque)
} }
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_ppc_instr); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_ppc_instr);
void kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry)
{
if (vcpu->kvm->arch.kvm_ops->create_vcpu_debugfs)
vcpu->kvm->arch.kvm_ops->create_vcpu_debugfs(vcpu, debugfs_dentry);
}
int kvm_arch_create_vm_debugfs(struct kvm *kvm)
{
if (kvm->arch.kvm_ops->create_vm_debugfs)
kvm->arch.kvm_ops->create_vm_debugfs(kvm);
return 0;
}
...@@ -204,21 +204,10 @@ static const struct file_operations kvmppc_exit_timing_fops = { ...@@ -204,21 +204,10 @@ static const struct file_operations kvmppc_exit_timing_fops = {
.release = single_release, .release = single_release,
}; };
void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id) int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
struct dentry *debugfs_dentry)
{ {
static char dbg_fname[50]; debugfs_create_file("timing", 0666, debugfs_dentry,
struct dentry *debugfs_file; vcpu, &kvmppc_exit_timing_fops);
return 0;
snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%u_timing",
current->pid, id);
debugfs_file = debugfs_create_file(dbg_fname, 0666, kvm_debugfs_dir,
vcpu, &kvmppc_exit_timing_fops);
vcpu->arch.debugfs_exit_timing = debugfs_file;
}
void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu)
{
debugfs_remove(vcpu->arch.debugfs_exit_timing);
vcpu->arch.debugfs_exit_timing = NULL;
} }
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#ifdef CONFIG_KVM_EXIT_TIMING #ifdef CONFIG_KVM_EXIT_TIMING
void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu); void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu);
void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu); void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu);
void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id); int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu); struct dentry *debugfs_dentry);
static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type)
{ {
...@@ -26,9 +26,11 @@ static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) ...@@ -26,9 +26,11 @@ static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type)
/* if exit timing is not configured there is no need to build the c file */ /* if exit timing is not configured there is no need to build the c file */
static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {} static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {}
static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {} static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {}
static inline void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, static inline int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
unsigned int id) {} struct dentry *debugfs_dentry)
static inline void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu) {} {
return 0;
}
static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {} static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {}
#endif /* CONFIG_KVM_EXIT_TIMING */ #endif /* CONFIG_KVM_EXIT_TIMING */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment