Skip to content

Commit 1b8af65

Browse files
committed
Merge tag 'powerpc-6.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Fix corruption of f0/vs0 during FP/Vector save, seen as userspace crashes when using io-uring workers (in particular with MariaDB) - Fix KVM_RUN potentially clobbering all host userspace FP/Vector registers Thanks to Timothy Pearson, Jens Axboe, and Nicholas Piggin. * tag 'powerpc-6.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: KVM: PPC: Book3S HV: Fix KVM_RUN clobbering FP/VEC user registers powerpc: Don't clobber f0/vs0 during fp|altivec register save
2 parents 17b17be + dc158d2 commit 1b8af65

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

arch/powerpc/kernel/fpu.S

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
#include <asm/feature-fixups.h>
2424

2525
#ifdef CONFIG_VSX
26+
#define __REST_1FPVSR(n,c,base) \
27+
BEGIN_FTR_SECTION \
28+
b 2f; \
29+
END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
30+
REST_FPR(n,base); \
31+
b 3f; \
32+
2: REST_VSR(n,c,base); \
33+
3:
34+
2635
#define __REST_32FPVSRS(n,c,base) \
2736
BEGIN_FTR_SECTION \
2837
b 2f; \
@@ -41,9 +50,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
4150
2: SAVE_32VSRS(n,c,base); \
4251
3:
4352
#else
53+
#define __REST_1FPVSR(n,b,base) REST_FPR(n, base)
4454
#define __REST_32FPVSRS(n,b,base) REST_32FPRS(n, base)
4555
#define __SAVE_32FPVSRS(n,b,base) SAVE_32FPRS(n, base)
4656
#endif
57+
#define REST_1FPVSR(n,c,base) __REST_1FPVSR(n,__REG_##c,__REG_##base)
4758
#define REST_32FPVSRS(n,c,base) __REST_32FPVSRS(n,__REG_##c,__REG_##base)
4859
#define SAVE_32FPVSRS(n,c,base) __SAVE_32FPVSRS(n,__REG_##c,__REG_##base)
4960

@@ -67,6 +78,7 @@ _GLOBAL(store_fp_state)
6778
SAVE_32FPVSRS(0, R4, R3)
6879
mffs fr0
6980
stfd fr0,FPSTATE_FPSCR(r3)
81+
REST_1FPVSR(0, R4, R3)
7082
blr
7183
EXPORT_SYMBOL(store_fp_state)
7284

@@ -138,4 +150,5 @@ _GLOBAL(save_fpu)
138150
2: SAVE_32FPVSRS(0, R4, R6)
139151
mffs fr0
140152
stfd fr0,FPSTATE_FPSCR(r6)
153+
REST_1FPVSR(0, R4, R6)
141154
blr

arch/powerpc/kernel/process.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,11 +1198,11 @@ void kvmppc_save_user_regs(void)
11981198

11991199
usermsr = current->thread.regs->msr;
12001200

1201+
/* Caller has enabled FP/VEC/VSX/TM in MSR */
12011202
if (usermsr & MSR_FP)
1202-
save_fpu(current);
1203-
1203+
__giveup_fpu(current);
12041204
if (usermsr & MSR_VEC)
1205-
save_altivec(current);
1205+
__giveup_altivec(current);
12061206

12071207
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
12081208
if (usermsr & MSR_TM) {

arch/powerpc/kernel/vector.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ _GLOBAL(store_vr_state)
3333
mfvscr v0
3434
li r4, VRSTATE_VSCR
3535
stvx v0, r4, r3
36+
lvx v0, 0, r3
3637
blr
3738
EXPORT_SYMBOL(store_vr_state)
3839

@@ -109,6 +110,7 @@ _GLOBAL(save_altivec)
109110
mfvscr v0
110111
li r4,VRSTATE_VSCR
111112
stvx v0,r4,r7
113+
lvx v0,0,r7
112114
blr
113115

114116
#ifdef CONFIG_VSX

0 commit comments

Comments
 (0)