aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm/book3s_hv.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2013-09-21 00:35:02 -0400
committerAlexander Graf <agraf@suse.de>2013-10-17 08:45:02 -0400
commit388cc6e133132e6c9b64e7d5361114a3a7d57663 (patch)
tree15414bef7bf1bc0d190d4b5cdb6d55fc2589fa44 /arch/powerpc/kvm/book3s_hv.c
parent4b8473c9c19dff1b0c672f182cc50b9952cf42e7 (diff)
KVM: PPC: Book3S HV: Support POWER6 compatibility mode on POWER7
This enables us to use the Processor Compatibility Register (PCR) on POWER7 to put the processor into architecture 2.05 compatibility mode when running a guest. In this mode the new instructions and registers that were introduced on POWER7 are disabled in user mode. This includes all the VSX facilities plus several other instructions such as ldbrx, stdbrx, popcntw, popcntd, etc. To select this mode, we have a new register accessible through the set/get_one_reg interface, called KVM_REG_PPC_ARCH_COMPAT. Setting this to zero gives the full set of capabilities of the processor. Setting it to one of the "logical" PVR values defined in PAPR puts the vcpu into the compatibility mode for the corresponding architecture level. The supported values are: 0x0f000002 Architecture 2.05 (POWER6) 0x0f000003 Architecture 2.06 (POWER7) 0x0f100003 Architecture 2.06+ (POWER7+) Since the PCR is per-core, the architecture compatibility level and the corresponding PCR value are stored in the struct kvmppc_vcore, and are therefore shared between all vcpus in a virtual core. Signed-off-by: Paul Mackerras <paulus@samba.org> [agraf: squash in fix to add missing break statements and documentation] Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm/book3s_hv.c')
-rw-r--r--arch/powerpc/kvm/book3s_hv.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 2a0e38feec1d..e42fb5448608 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -166,6 +166,35 @@ void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr)
166 vcpu->arch.pvr = pvr; 166 vcpu->arch.pvr = pvr;
167} 167}
168 168
169int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
170{
171 unsigned long pcr = 0;
172 struct kvmppc_vcore *vc = vcpu->arch.vcore;
173
174 if (arch_compat) {
175 if (!cpu_has_feature(CPU_FTR_ARCH_206))
176 return -EINVAL; /* 970 has no compat mode support */
177
178 switch (arch_compat) {
179 case PVR_ARCH_205:
180 pcr = PCR_ARCH_205;
181 break;
182 case PVR_ARCH_206:
183 case PVR_ARCH_206p:
184 break;
185 default:
186 return -EINVAL;
187 }
188 }
189
190 spin_lock(&vc->lock);
191 vc->arch_compat = arch_compat;
192 vc->pcr = pcr;
193 spin_unlock(&vc->lock);
194
195 return 0;
196}
197
169void kvmppc_dump_regs(struct kvm_vcpu *vcpu) 198void kvmppc_dump_regs(struct kvm_vcpu *vcpu)
170{ 199{
171 int r; 200 int r;
@@ -826,6 +855,9 @@ int kvmppc_get_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *val)
826 case KVM_REG_PPC_PPR: 855 case KVM_REG_PPC_PPR:
827 *val = get_reg_val(id, vcpu->arch.ppr); 856 *val = get_reg_val(id, vcpu->arch.ppr);
828 break; 857 break;
858 case KVM_REG_PPC_ARCH_COMPAT:
859 *val = get_reg_val(id, vcpu->arch.vcore->arch_compat);
860 break;
829 default: 861 default:
830 r = -EINVAL; 862 r = -EINVAL;
831 break; 863 break;
@@ -936,6 +968,9 @@ int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *val)
936 case KVM_REG_PPC_PPR: 968 case KVM_REG_PPC_PPR:
937 vcpu->arch.ppr = set_reg_val(id, *val); 969 vcpu->arch.ppr = set_reg_val(id, *val);
938 break; 970 break;
971 case KVM_REG_PPC_ARCH_COMPAT:
972 r = kvmppc_set_arch_compat(vcpu, set_reg_val(id, *val));
973 break;
939 default: 974 default:
940 r = -EINVAL; 975 r = -EINVAL;
941 break; 976 break;