Gentoo Archives: gentoo-commits

From: Alice Ferrazzi <alicef@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.10 commit in: /
Date: Thu, 08 Jul 2021 03:27:13
Message-Id: 1625714798.0516d30fad4f3ec1e6c5f821a798c695034f77f5.alicef@gentoo
1 commit: 0516d30fad4f3ec1e6c5f821a798c695034f77f5
2 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jul 8 03:23:26 2021 +0000
4 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
5 CommitDate: Thu Jul 8 03:26:38 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=0516d30f
7
8 Add KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path
9
10 Signed-off-by: Alice Ferrazzi <alicef <AT> gentoo.org>
11
12 0000_README | 4 +++
13 1700_P9_save_and_restore_fscr.patch | 56 +++++++++++++++++++++++++++++++++++++
14 2 files changed, 60 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index dc7b9b6..aefbc8e 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -243,6 +243,10 @@ Patch: 1510_fs-enable-link-security-restrictions-by-default.patch
21 From: http://sources.debian.net/src/linux/3.16.7-ckt4-3/debian/patches/debian/fs-enable-link-security-restrictions-by-default.patch/
22 Desc: Enable link security restrictions by default.
23
24 +Patch: 1700_P9_save_and_restore_fscr.patch
25 +From: https://github.com/torvalds/linux/commit/25edcc50d76c.patch
26 +Desc: Fix qemu on P9 ppc64.
27 +
28 Patch: 2000_BT-Check-key-sizes-only-if-Secure-Simple-Pairing-enabled.patch
29 From: https://lore.kernel.org/linux-bluetooth/20190522070540.48895-1-marcel@××××××××.org/raw
30 Desc: Bluetooth: Check key sizes only when Secure Simple Pairing is enabled. See bug #686758
31
32 diff --git a/1700_P9_save_and_restore_fscr.patch b/1700_P9_save_and_restore_fscr.patch
33 new file mode 100644
34 index 0000000..59a7c7e
35 --- /dev/null
36 +++ b/1700_P9_save_and_restore_fscr.patch
37 @@ -0,0 +1,56 @@
38 +From 25edcc50d76c834479d11fcc7de46f3da4d95121 Mon Sep 17 00:00:00 2001
39 +From: Fabiano Rosas <farosas@×××××××××.com>
40 +Date: Thu, 4 Feb 2021 17:05:17 -0300
41 +Subject: [PATCH] KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path
42 +
43 +The Facility Status and Control Register is a privileged SPR that
44 +defines the availability of some features in problem state. Since it
45 +can be written by the guest, we must restore it to the previous host
46 +value after guest exit.
47 +
48 +This restoration is currently done by taking the value from
49 +current->thread.fscr, which in the P9 path is not enough anymore
50 +because the guest could context switch the QEMU thread, causing the
51 +guest-current value to be saved into the thread struct.
52 +
53 +The above situation manifested when running a QEMU linked against a
54 +libc with System Call Vectored support, which causes scv
55 +instructions to be run by QEMU early during the guest boot (during
56 +SLOF), at which point the FSCR is 0 due to guest entry. After a few
57 +scv calls (1 to a couple hundred), the context switching happens and
58 +the QEMU thread runs with the guest value, resulting in a Facility
59 +Unavailable interrupt.
60 +
61 +This patch saves and restores the host value of FSCR in the inner
62 +guest entry loop in a way independent of current->thread.fscr. The old
63 +way of doing it is still kept in place because it works for the old
64 +entry path.
65 +
66 +Signed-off-by: Fabiano Rosas <farosas@×××××××××.com>
67 +Signed-off-by: Paul Mackerras <paulus@××××××.org>
68 +---
69 + arch/powerpc/kvm/book3s_hv.c | 4 ++++
70 + 1 file changed, 4 insertions(+)
71 +
72 +diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
73 +index 89c686c17f0606..f6d470157fcb62 100644
74 +--- a/arch/powerpc/kvm/book3s_hv.c
75 ++++ b/arch/powerpc/kvm/book3s_hv.c
76 +@@ -3611,6 +3611,7 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
77 + unsigned long host_tidr = mfspr(SPRN_TIDR);
78 + unsigned long host_iamr = mfspr(SPRN_IAMR);
79 + unsigned long host_amr = mfspr(SPRN_AMR);
80 ++ unsigned long host_fscr = mfspr(SPRN_FSCR);
81 + s64 dec;
82 + u64 tb;
83 + int trap, save_pmu;
84 +@@ -3751,6 +3752,9 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
85 + if (host_amr != vcpu->arch.amr)
86 + mtspr(SPRN_AMR, host_amr);
87 +
88 ++ if (host_fscr != vcpu->arch.fscr)
89 ++ mtspr(SPRN_FSCR, host_fscr);
90 ++
91 + msr_check_and_set(MSR_FP | MSR_VEC | MSR_VSX);
92 + store_fp_state(&vcpu->arch.fp);
93 + #ifdef CONFIG_ALTIVEC