]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
s390/fpu: make use of __uninitialized macro
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 5 Feb 2024 15:48:44 +0000 (16:48 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Fri, 9 Feb 2024 12:58:16 +0000 (13:58 +0100)
Code sections in s390 specific kernel code which use floating point or
vector registers all come with a 520 byte stack variable to save already in
use registers, if required.

With INIT_STACK_ALL_PATTERN or INIT_STACK_ALL_ZERO enabled this variable
will always be initialized on function entry in addition to saving register
contents, which contradicts the intention (performance improvement) of such
code sections.

Therefore provide a DECLARE_KERNEL_FPU_ONSTACK() macro which provides
struct kernel_fpu variables with an __uninitialized attribute, and convert
all existing code to use this.

This way only this specific type of stack variable will not be initialized,
regardless of config options.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20240205154844.3757121-3-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/crypto/chacha-glue.c
arch/s390/crypto/crc32-vx.c
arch/s390/include/asm/fpu/types.h
arch/s390/kernel/sysinfo.c
lib/raid6/s390vx.uc

index ed9959e6f7149e2c0b2645ad38ef3bf9138b69ac..a823132fc5639b70cb8c0005936e782c563f2158 100644 (file)
@@ -22,7 +22,7 @@ static void chacha20_crypt_s390(u32 *state, u8 *dst, const u8 *src,
                                unsigned int nbytes, const u32 *key,
                                u32 *counter)
 {
-       struct kernel_fpu vxstate;
+       DECLARE_KERNEL_FPU_ONSTACK(vxstate);
 
        kernel_fpu_begin(&vxstate, KERNEL_VXR);
        chacha20_vx(dst, src, nbytes, key, counter);
index 017143e9cef715887647746800f9bae2fc5434cb..6ae3e3ff5b0ae799d1c9d10e1b664977f7b21d1a 100644 (file)
@@ -49,8 +49,8 @@ u32 crc32c_le_vgfm_16(u32 crc, unsigned char const *buf, size_t size);
        static u32 __pure ___fname(u32 crc,                                 \
                                unsigned char const *data, size_t datalen)  \
        {                                                                   \
-               struct kernel_fpu vxstate;                                  \
                unsigned long prealign, aligned, remaining;                 \
+               DECLARE_KERNEL_FPU_ONSTACK(vxstate);                        \
                                                                            \
                if (datalen < VX_MIN_LEN + VX_ALIGN_MASK)                   \
                        return ___crc32_sw(crc, data, datalen);             \
index d889e9436865e3571900bc040be043a885dd74c4..b1afa13c07b79dd06fe89f87b12caf45f4f69486 100644 (file)
@@ -35,4 +35,7 @@ struct kernel_fpu {
        };
 };
 
+#define DECLARE_KERNEL_FPU_ONSTACK(name)       \
+       struct kernel_fpu name __uninitialized
+
 #endif /* _ASM_S390_FPU_TYPES_H */
index f6f8f498c9be3959a433ffd7c1241ed6af663a2c..b439f17516ebc9f105af7c861b6b5c110411f795 100644 (file)
@@ -426,9 +426,9 @@ subsys_initcall(create_proc_service_level);
  */
 void s390_adjust_jiffies(void)
 {
+       DECLARE_KERNEL_FPU_ONSTACK(fpu);
        struct sysinfo_1_2_2 *info;
        unsigned long capability;
-       struct kernel_fpu fpu;
 
        info = (void *) get_zeroed_page(GFP_KERNEL);
        if (!info)
index cd0b9e95f499d2424c3bb92abbc668529224a15b..7b0b355e1a26041ab47c8784b6855c9a06dba406 100644 (file)
@@ -81,7 +81,7 @@ static inline void COPY_VEC(int x, int y)
 
 static void raid6_s390vx$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
 {
-       struct kernel_fpu vxstate;
+       DECLARE_KERNEL_FPU_ONSTACK(vxstate);
        u8 **dptr, *p, *q;
        int d, z, z0;
 
@@ -114,7 +114,7 @@ static void raid6_s390vx$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
 static void raid6_s390vx$#_xor_syndrome(int disks, int start, int stop,
                                        size_t bytes, void **ptrs)
 {
-       struct kernel_fpu vxstate;
+       DECLARE_KERNEL_FPU_ONSTACK(vxstate);
        u8 **dptr, *p, *q;
        int d, z, z0;