Gentoo Archives: gentoo-commits

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-kernel/gentoo-kernel/files/, sys-kernel/gentoo-kernel/
Date: Thu, 08 Jul 2021 02:32:12
Message-Id: 1625710339.14561011b6e2f7e5a3d62ad4e7565fec4f326512.gyakovlev@gentoo
1 commit: 14561011b6e2f7e5a3d62ad4e7565fec4f326512
2 Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jul 8 02:09:36 2021 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Thu Jul 8 02:12:19 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=14561011
7
8 sys-kernel/gentoo-kernel: add power9 kvm patch to 5.10.47
9
10 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
11
12 .../gentoo-kernel/files/5.10.47-ppc64-kvm.patch | 56 ++++++++++++++++++++++
13 .../gentoo-kernel/gentoo-kernel-5.10.47.ebuild | 1 +
14 2 files changed, 57 insertions(+)
15
16 diff --git a/sys-kernel/gentoo-kernel/files/5.10.47-ppc64-kvm.patch b/sys-kernel/gentoo-kernel/files/5.10.47-ppc64-kvm.patch
17 new file mode 100644
18 index 00000000000..59a7c7e7581
19 --- /dev/null
20 +++ b/sys-kernel/gentoo-kernel/files/5.10.47-ppc64-kvm.patch
21 @@ -0,0 +1,56 @@
22 +From 25edcc50d76c834479d11fcc7de46f3da4d95121 Mon Sep 17 00:00:00 2001
23 +From: Fabiano Rosas <farosas@×××××××××.com>
24 +Date: Thu, 4 Feb 2021 17:05:17 -0300
25 +Subject: [PATCH] KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path
26 +
27 +The Facility Status and Control Register is a privileged SPR that
28 +defines the availability of some features in problem state. Since it
29 +can be written by the guest, we must restore it to the previous host
30 +value after guest exit.
31 +
32 +This restoration is currently done by taking the value from
33 +current->thread.fscr, which in the P9 path is not enough anymore
34 +because the guest could context switch the QEMU thread, causing the
35 +guest-current value to be saved into the thread struct.
36 +
37 +The above situation manifested when running a QEMU linked against a
38 +libc with System Call Vectored support, which causes scv
39 +instructions to be run by QEMU early during the guest boot (during
40 +SLOF), at which point the FSCR is 0 due to guest entry. After a few
41 +scv calls (1 to a couple hundred), the context switching happens and
42 +the QEMU thread runs with the guest value, resulting in a Facility
43 +Unavailable interrupt.
44 +
45 +This patch saves and restores the host value of FSCR in the inner
46 +guest entry loop in a way independent of current->thread.fscr. The old
47 +way of doing it is still kept in place because it works for the old
48 +entry path.
49 +
50 +Signed-off-by: Fabiano Rosas <farosas@×××××××××.com>
51 +Signed-off-by: Paul Mackerras <paulus@××××××.org>
52 +---
53 + arch/powerpc/kvm/book3s_hv.c | 4 ++++
54 + 1 file changed, 4 insertions(+)
55 +
56 +diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
57 +index 89c686c17f0606..f6d470157fcb62 100644
58 +--- a/arch/powerpc/kvm/book3s_hv.c
59 ++++ b/arch/powerpc/kvm/book3s_hv.c
60 +@@ -3611,6 +3611,7 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
61 + unsigned long host_tidr = mfspr(SPRN_TIDR);
62 + unsigned long host_iamr = mfspr(SPRN_IAMR);
63 + unsigned long host_amr = mfspr(SPRN_AMR);
64 ++ unsigned long host_fscr = mfspr(SPRN_FSCR);
65 + s64 dec;
66 + u64 tb;
67 + int trap, save_pmu;
68 +@@ -3751,6 +3752,9 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
69 + if (host_amr != vcpu->arch.amr)
70 + mtspr(SPRN_AMR, host_amr);
71 +
72 ++ if (host_fscr != vcpu->arch.fscr)
73 ++ mtspr(SPRN_FSCR, host_fscr);
74 ++
75 + msr_check_and_set(MSR_FP | MSR_VEC | MSR_VSX);
76 + store_fp_state(&vcpu->arch.fp);
77 + #ifdef CONFIG_ALTIVEC
78
79 diff --git a/sys-kernel/gentoo-kernel/gentoo-kernel-5.10.47.ebuild b/sys-kernel/gentoo-kernel/gentoo-kernel-5.10.47.ebuild
80 index 484c3c53d62..85ca3ef0d12 100644
81 --- a/sys-kernel/gentoo-kernel/gentoo-kernel-5.10.47.ebuild
82 +++ b/sys-kernel/gentoo-kernel/gentoo-kernel-5.10.47.ebuild
83 @@ -55,6 +55,7 @@ src_prepare() {
84 local PATCHES=(
85 # meh, genpatches have no directory
86 "${WORKDIR}"/*.patch
87 + "${FILESDIR}"/5.10.47-ppc64-kvm.patch
88 )
89 default