All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Fabiano Rosas <farosas@linux.ibm.com>,
	Paul Mackerras <paulus@ozlabs.org>,
	Georgy Yakovlev <gyakovlev@gentoo.org>
Subject: [PATCH 5.10 1/6] KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path
Date: Fri,  9 Jul 2021 15:21:10 +0200	[thread overview]
Message-ID: <20210709131538.737957977@linuxfoundation.org> (raw)
In-Reply-To: <20210709131537.035851348@linuxfoundation.org>

From: Fabiano Rosas <farosas@linux.ibm.com>

commit 25edcc50d76c834479d11fcc7de46f3da4d95121 upstream.

The Facility Status and Control Register is a privileged SPR that
defines the availability of some features in problem state. Since it
can be written by the guest, we must restore it to the previous host
value after guest exit.

This restoration is currently done by taking the value from
current->thread.fscr, which in the P9 path is not enough anymore
because the guest could context switch the QEMU thread, causing the
guest-current value to be saved into the thread struct.

The above situation manifested when running a QEMU linked against a
libc with System Call Vectored support, which causes scv
instructions to be run by QEMU early during the guest boot (during
SLOF), at which point the FSCR is 0 due to guest entry. After a few
scv calls (1 to a couple hundred), the context switching happens and
the QEMU thread runs with the guest value, resulting in a Facility
Unavailable interrupt.

This patch saves and restores the host value of FSCR in the inner
guest entry loop in a way independent of current->thread.fscr. The old
way of doing it is still kept in place because it works for the old
entry path.

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Cc: Georgy Yakovlev <gyakovlev@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/powerpc/kvm/book3s_hv.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3583,6 +3583,7 @@ static int kvmhv_p9_guest_entry(struct k
 	unsigned long host_tidr = mfspr(SPRN_TIDR);
 	unsigned long host_iamr = mfspr(SPRN_IAMR);
 	unsigned long host_amr = mfspr(SPRN_AMR);
+	unsigned long host_fscr = mfspr(SPRN_FSCR);
 	s64 dec;
 	u64 tb;
 	int trap, save_pmu;
@@ -3726,6 +3727,9 @@ static int kvmhv_p9_guest_entry(struct k
 	if (host_amr != vcpu->arch.amr)
 		mtspr(SPRN_AMR, host_amr);
 
+	if (host_fscr != vcpu->arch.fscr)
+		mtspr(SPRN_FSCR, host_fscr);
+
 	msr_check_and_set(MSR_FP | MSR_VEC | MSR_VSX);
 	store_fp_state(&vcpu->arch.fp);
 #ifdef CONFIG_ALTIVEC



  reply	other threads:[~2021-07-09 13:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 13:21 [PATCH 5.10 0/6] 5.10.49-rc1 review Greg Kroah-Hartman
2021-07-09 13:21 ` Greg Kroah-Hartman [this message]
2021-07-09 13:21 ` [PATCH 5.10 2/6] media: uvcvideo: Support devices that report an OT as an entity source Greg Kroah-Hartman
2021-07-09 13:21 ` [PATCH 5.10 3/6] Hexagon: fix build errors Greg Kroah-Hartman
2021-07-09 13:21 ` [PATCH 5.10 4/6] Hexagon: add target builtins to kernel Greg Kroah-Hartman
2021-07-09 13:21 ` [PATCH 5.10 5/6] Hexagon: change jumps to must-extend in futex_atomic_* Greg Kroah-Hartman
2021-07-09 13:21 ` [PATCH 5.10 6/6] xen/events: reset active flag for lateeoi events later Greg Kroah-Hartman
2021-07-09 17:11 ` [PATCH 5.10 0/6] 5.10.49-rc1 review Jon Hunter
2021-07-09 20:00 ` Fox Chen
2021-07-09 21:40 ` Shuah Khan
2021-07-10  6:40 ` Samuel Zou
2021-07-10 10:21 ` Naresh Kamboju
2021-07-10 10:35 ` Sudip Mukherjee
2021-07-10 19:52 ` Guenter Roeck
2021-07-11  8:00 ` Pavel Machek
2021-07-11 22:15 ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210709131538.737957977@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=farosas@linux.ibm.com \
    --cc=gyakovlev@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@ozlabs.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.