diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2013-10-07 12:47:53 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2013-10-17 09:24:26 -0400 |
commit | 3a167beac07cba597856c12b87638a06b0d53db7 (patch) | |
tree | b7d484f8cb3519aec3177f914304b1d5e129d193 /arch/powerpc/kvm/powerpc.c | |
parent | 9975f5e3692d320b4259a4d2edd8a979adb1e535 (diff) |
kvm: powerpc: Add kvmppc_ops callback
This patch add a new callback kvmppc_ops. This will help us in enabling
both HV and PR KVM together in the same kernel. The actual change to
enable them together is done in the later patch in the series.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
[agraf: squash in booke changes]
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm/powerpc.c')
-rw-r--r-- | arch/powerpc/kvm/powerpc.c | 58 |
1 files changed, 14 insertions, 44 deletions
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 07c0106fab76..69b930550d2e 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
@@ -39,6 +39,8 @@ | |||
39 | #define CREATE_TRACE_POINTS | 39 | #define CREATE_TRACE_POINTS |
40 | #include "trace.h" | 40 | #include "trace.h" |
41 | 41 | ||
42 | struct kvmppc_ops *kvmppc_ops; | ||
43 | |||
42 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) | 44 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) |
43 | { | 45 | { |
44 | return !!(v->arch.pending_exceptions) || | 46 | return !!(v->arch.pending_exceptions) || |
@@ -1024,52 +1026,11 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
1024 | r = kvm_vm_ioctl_create_spapr_tce(kvm, &create_tce); | 1026 | r = kvm_vm_ioctl_create_spapr_tce(kvm, &create_tce); |
1025 | goto out; | 1027 | goto out; |
1026 | } | 1028 | } |
1027 | #endif /* CONFIG_PPC_BOOK3S_64 */ | ||
1028 | |||
1029 | #ifdef CONFIG_KVM_BOOK3S_64_HV | ||
1030 | case KVM_ALLOCATE_RMA: { | ||
1031 | struct kvm_allocate_rma rma; | ||
1032 | struct kvm *kvm = filp->private_data; | ||
1033 | |||
1034 | r = kvm_vm_ioctl_allocate_rma(kvm, &rma); | ||
1035 | if (r >= 0 && copy_to_user(argp, &rma, sizeof(rma))) | ||
1036 | r = -EFAULT; | ||
1037 | break; | ||
1038 | } | ||
1039 | |||
1040 | case KVM_PPC_ALLOCATE_HTAB: { | ||
1041 | u32 htab_order; | ||
1042 | |||
1043 | r = -EFAULT; | ||
1044 | if (get_user(htab_order, (u32 __user *)argp)) | ||
1045 | break; | ||
1046 | r = kvmppc_alloc_reset_hpt(kvm, &htab_order); | ||
1047 | if (r) | ||
1048 | break; | ||
1049 | r = -EFAULT; | ||
1050 | if (put_user(htab_order, (u32 __user *)argp)) | ||
1051 | break; | ||
1052 | r = 0; | ||
1053 | break; | ||
1054 | } | ||
1055 | |||
1056 | case KVM_PPC_GET_HTAB_FD: { | ||
1057 | struct kvm_get_htab_fd ghf; | ||
1058 | |||
1059 | r = -EFAULT; | ||
1060 | if (copy_from_user(&ghf, argp, sizeof(ghf))) | ||
1061 | break; | ||
1062 | r = kvm_vm_ioctl_get_htab_fd(kvm, &ghf); | ||
1063 | break; | ||
1064 | } | ||
1065 | #endif /* CONFIG_KVM_BOOK3S_64_HV */ | ||
1066 | |||
1067 | #ifdef CONFIG_PPC_BOOK3S_64 | ||
1068 | case KVM_PPC_GET_SMMU_INFO: { | 1029 | case KVM_PPC_GET_SMMU_INFO: { |
1069 | struct kvm_ppc_smmu_info info; | 1030 | struct kvm_ppc_smmu_info info; |
1070 | 1031 | ||
1071 | memset(&info, 0, sizeof(info)); | 1032 | memset(&info, 0, sizeof(info)); |
1072 | r = kvm_vm_ioctl_get_smmu_info(kvm, &info); | 1033 | r = kvmppc_ops->get_smmu_info(kvm, &info); |
1073 | if (r >= 0 && copy_to_user(argp, &info, sizeof(info))) | 1034 | if (r >= 0 && copy_to_user(argp, &info, sizeof(info))) |
1074 | r = -EFAULT; | 1035 | r = -EFAULT; |
1075 | break; | 1036 | break; |
@@ -1080,11 +1041,14 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
1080 | r = kvm_vm_ioctl_rtas_define_token(kvm, argp); | 1041 | r = kvm_vm_ioctl_rtas_define_token(kvm, argp); |
1081 | break; | 1042 | break; |
1082 | } | 1043 | } |
1083 | #endif /* CONFIG_PPC_BOOK3S_64 */ | 1044 | default: |
1045 | r = kvmppc_ops->arch_vm_ioctl(filp, ioctl, arg); | ||
1046 | |||
1047 | #else /* CONFIG_PPC_BOOK3S_64 */ | ||
1084 | default: | 1048 | default: |
1085 | r = -ENOTTY; | 1049 | r = -ENOTTY; |
1050 | #endif | ||
1086 | } | 1051 | } |
1087 | |||
1088 | out: | 1052 | out: |
1089 | return r; | 1053 | return r; |
1090 | } | 1054 | } |
@@ -1125,9 +1089,15 @@ void kvmppc_init_lpid(unsigned long nr_lpids_param) | |||
1125 | 1089 | ||
1126 | int kvm_arch_init(void *opaque) | 1090 | int kvm_arch_init(void *opaque) |
1127 | { | 1091 | { |
1092 | if (kvmppc_ops) { | ||
1093 | printk(KERN_ERR "kvm: already loaded the other module\n"); | ||
1094 | return -EEXIST; | ||
1095 | } | ||
1096 | kvmppc_ops = (struct kvmppc_ops *)opaque; | ||
1128 | return 0; | 1097 | return 0; |
1129 | } | 1098 | } |
1130 | 1099 | ||
1131 | void kvm_arch_exit(void) | 1100 | void kvm_arch_exit(void) |
1132 | { | 1101 | { |
1102 | kvmppc_ops = NULL; | ||
1133 | } | 1103 | } |