aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2011-04-27 18:24:10 -0400
committerAvi Kivity <avi@redhat.com>2011-05-22 08:47:50 -0400
commiteab176722f4628b2d9cf76221a43dd3a0e37e632 (patch)
tree4b1e9e9ecb6adc4fb97c47ad5a3c174d3ad942ef /arch
parent1a040b26c5c915b317103b87ae7006d40443f197 (diff)
KVM: PPC: booke: save/restore VRSAVE (a.k.a. USPRG0)
Linux doesn't use USPRG0 (now renamed VRSAVE in the architecture, even when Altivec isn't involved), but a guest might. Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/include/asm/kvm_host.h1
-rw-r--r--arch/powerpc/kernel/asm-offsets.c1
-rw-r--r--arch/powerpc/kvm/booke_interrupts.S1
-rw-r--r--arch/powerpc/kvm/powerpc.c13
4 files changed, 15 insertions, 1 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 890897cee050..a16804399165 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -223,6 +223,7 @@ struct kvm_vcpu_arch {
223 ulong hflags; 223 ulong hflags;
224 ulong guest_owned_ext; 224 ulong guest_owned_ext;
225#endif 225#endif
226 u32 vrsave; /* also USPRG0 */
226 u32 mmucr; 227 u32 mmucr;
227 ulong sprg4; 228 ulong sprg4;
228 ulong sprg5; 229 ulong sprg5;
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 23e6a93145ab..cf0d82278951 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -395,6 +395,7 @@ int main(void)
395 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack)); 395 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack));
396 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid)); 396 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid));
397 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr)); 397 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr));
398 DEFINE(VCPU_VRSAVE, offsetof(struct kvm_vcpu, arch.vrsave));
398 DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, arch.sprg4)); 399 DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, arch.sprg4));
399 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5)); 400 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5));
400 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6)); 401 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6));
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S
index 1cc471faac2d..b58ccae95904 100644
--- a/arch/powerpc/kvm/booke_interrupts.S
+++ b/arch/powerpc/kvm/booke_interrupts.S
@@ -380,7 +380,6 @@ lightweight_exit:
380 * because host interrupt handlers would get confused. */ 380 * because host interrupt handlers would get confused. */
381 lwz r1, VCPU_GPR(r1)(r4) 381 lwz r1, VCPU_GPR(r1)(r4)
382 382
383 /* XXX handle USPRG0 */
384 /* Host interrupt handlers may have clobbered these guest-readable 383 /* Host interrupt handlers may have clobbered these guest-readable
385 * SPRGs, so we need to reload them here with the guest's values. */ 384 * SPRGs, so we need to reload them here with the guest's values. */
386 lwz r3, VCPU_SPRG4(r4) 385 lwz r3, VCPU_SPRG4(r4)
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index ec3d2e75c0a8..9e6aa8bfd160 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -298,12 +298,25 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
298 298
299void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 299void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
300{ 300{
301#ifdef CONFIG_BOOKE
302 /*
303 * vrsave (formerly usprg0) isn't used by Linux, but may
304 * be used by the guest.
305 *
306 * On non-booke this is associated with Altivec and
307 * is handled by code in book3s.c.
308 */
309 mtspr(SPRN_VRSAVE, vcpu->arch.vrsave);
310#endif
301 kvmppc_core_vcpu_load(vcpu, cpu); 311 kvmppc_core_vcpu_load(vcpu, cpu);
302} 312}
303 313
304void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) 314void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
305{ 315{
306 kvmppc_core_vcpu_put(vcpu); 316 kvmppc_core_vcpu_put(vcpu);
317#ifdef CONFIG_BOOKE
318 vcpu->arch.vrsave = mfspr(SPRN_VRSAVE);
319#endif
307} 320}
308 321
309int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, 322int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,