commit: 0516d30fad4f3ec1e6c5f821a798c695034f77f5 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org> AuthorDate: Thu Jul 8 03:23:26 2021 +0000 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org> CommitDate: Thu Jul 8 03:26:38 2021 +0000 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=0516d30f
Add KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path Signed-off-by: Alice Ferrazzi <alicef <AT> gentoo.org> 0000_README | 4 +++ 1700_P9_save_and_restore_fscr.patch | 56 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/0000_README b/0000_README index dc7b9b6..aefbc8e 100644 --- a/0000_README +++ b/0000_README @@ -243,6 +243,10 @@ Patch: 1510_fs-enable-link-security-restrictions-by-default.patch From: http://sources.debian.net/src/linux/3.16.7-ckt4-3/debian/patches/debian/fs-enable-link-security-restrictions-by-default.patch/ Desc: Enable link security restrictions by default. +Patch: 1700_P9_save_and_restore_fscr.patch +From: https://github.com/torvalds/linux/commit/25edcc50d76c.patch +Desc: Fix qemu on P9 ppc64. + Patch: 2000_BT-Check-key-sizes-only-if-Secure-Simple-Pairing-enabled.patch From: https://lore.kernel.org/linux-bluetooth/[email protected]/raw Desc: Bluetooth: Check key sizes only when Secure Simple Pairing is enabled. See bug #686758 diff --git a/1700_P9_save_and_restore_fscr.patch b/1700_P9_save_and_restore_fscr.patch new file mode 100644 index 0000000..59a7c7e --- /dev/null +++ b/1700_P9_save_and_restore_fscr.patch @@ -0,0 +1,56 @@ +From 25edcc50d76c834479d11fcc7de46f3da4d95121 Mon Sep 17 00:00:00 2001 +From: Fabiano Rosas <[email protected]> +Date: Thu, 4 Feb 2021 17:05:17 -0300 +Subject: [PATCH] KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path + +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 <[email protected]> +Signed-off-by: Paul Mackerras <[email protected]> +--- + arch/powerpc/kvm/book3s_hv.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c +index 89c686c17f0606..f6d470157fcb62 100644 +--- a/arch/powerpc/kvm/book3s_hv.c ++++ b/arch/powerpc/kvm/book3s_hv.c +@@ -3611,6 +3611,7 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit, + 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; +@@ -3751,6 +3752,9 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit, + 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
