s390/vx: fix save/restore of fpu kernel context
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 8 Dec 2023 14:03:15 +0000 (15:03 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Mon, 18 Dec 2023 09:53:41 +0000 (10:53 +0100)
The KERNEL_FPR mask only contains a flag for the first eight vector
registers. However floating point registers overlay parts of the first
sixteen vector registers.

This could lead to vector register corruption if a kernel fpu context uses
any of the vector registers 8 to 15 and is interrupted or calls a
KERNEL_FPR context. If that context uses also vector registers 8 to 15,
their contents will be corrupted on return.

Luckily this is currently not a real bug, since the kernel has only one
KERNEL_FPR user with s390_adjust_jiffies() and it is only using floating
point registers 0 to 2.

Fix this by using the correct bits for KERNEL_FPR.

Fixes: 7f79695cc1b6 ("s390/fpu: improve kernel_fpu_[begin|end]")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/include/asm/fpu/api.h

index b714ed0ef68853b734bdec7d52e59af5d587e5bc..9acf48e53a87fb842e04f333f85c071e03f5c672 100644 (file)
@@ -79,7 +79,7 @@ static inline int test_fp_ctl(u32 fpc)
 #define KERNEL_VXR_HIGH                (KERNEL_VXR_V16V23|KERNEL_VXR_V24V31)
 
 #define KERNEL_VXR             (KERNEL_VXR_LOW|KERNEL_VXR_HIGH)
-#define KERNEL_FPR             (KERNEL_FPC|KERNEL_VXR_V0V7)
+#define KERNEL_FPR             (KERNEL_FPC|KERNEL_VXR_LOW)
 
 struct kernel_fpu;