* [PATCH] KVM: PPC: Book3S HV: Save/restore vrsave register in kvmhv_p9_guest_entry()
@ 2019-04-30 0:41 Suraj Jitindar Singh
2019-04-30 10:08 ` Paul Mackerras
0 siblings, 1 reply; 2+ messages in thread
From: Suraj Jitindar Singh @ 2019-04-30 0:41 UTC (permalink / raw)
To: kvm-ppc; +Cc: paulus, kvm, Suraj Jitindar Singh
On POWER9 and later processors where the host can schedule vcpus on a
per thread basis, there is a streamlined entry path used when the guest
is radix. This entry path saves/restores the fp and vr state in
kvmhv_p9_guest_entry() by calling store_[fp/vr]_state() and
load_[fp/vr]_state(). This is the same as the old entry path however the
old entry path also saved/restored the VRSAVE register, which isn't done
in the new entry path.
This means that the vrsave register is now volatile across guest exit,
which is an incorrect change in behaviour.
Fix this by saving/restoring the vrsave register in kvmhv_p9_guest_entry().
This restores the old, correct, behaviour.
Fixes: 95a6432ce9038 ("KVM: PPC: Book3S HV: Streamlined guest entry/exit path on P9 for radix guests")
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
---
arch/powerpc/kvm/book3s_hv.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 06964350b97a..700e125c08ce 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3511,6 +3511,7 @@ int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
#ifdef CONFIG_ALTIVEC
load_vr_state(&vcpu->arch.vr);
#endif
+ mtspr(SPRN_VRSAVE, vcpu->arch.vrsave);
mtspr(SPRN_DSCR, vcpu->arch.dscr);
mtspr(SPRN_IAMR, vcpu->arch.iamr);
@@ -3602,6 +3603,7 @@ int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
#ifdef CONFIG_ALTIVEC
store_vr_state(&vcpu->arch.vr);
#endif
+ vcpu->arch.vrsave = mfspr(SPRN_VRSAVE);
if (cpu_has_feature(CPU_FTR_TM) ||
cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST))
--
2.13.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: Save/restore vrsave register in kvmhv_p9_guest_entry()
2019-04-30 0:41 [PATCH] KVM: PPC: Book3S HV: Save/restore vrsave register in kvmhv_p9_guest_entry() Suraj Jitindar Singh
@ 2019-04-30 10:08 ` Paul Mackerras
0 siblings, 0 replies; 2+ messages in thread
From: Paul Mackerras @ 2019-04-30 10:08 UTC (permalink / raw)
To: Suraj Jitindar Singh; +Cc: kvm-ppc, kvm
On Tue, Apr 30, 2019 at 10:41:23AM +1000, Suraj Jitindar Singh wrote:
> On POWER9 and later processors where the host can schedule vcpus on a
> per thread basis, there is a streamlined entry path used when the guest
> is radix. This entry path saves/restores the fp and vr state in
> kvmhv_p9_guest_entry() by calling store_[fp/vr]_state() and
> load_[fp/vr]_state(). This is the same as the old entry path however the
> old entry path also saved/restored the VRSAVE register, which isn't done
> in the new entry path.
>
> This means that the vrsave register is now volatile across guest exit,
> which is an incorrect change in behaviour.
>
> Fix this by saving/restoring the vrsave register in kvmhv_p9_guest_entry().
> This restores the old, correct, behaviour.
>
> Fixes: 95a6432ce9038 ("KVM: PPC: Book3S HV: Streamlined guest entry/exit path on P9 for radix guests")
>
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Thanks, patch applied to my kvm-ppc-next tree.
Paul.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-30 10:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-30 0:41 [PATCH] KVM: PPC: Book3S HV: Save/restore vrsave register in kvmhv_p9_guest_entry() Suraj Jitindar Singh
2019-04-30 10:08 ` Paul Mackerras
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).