From e42c7990ca1db370fef5b4187b4078fc79ae8d6f Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Wed, 4 Dec 2024 15:17:38 -0500 Subject: [PATCH] kpatch-syscall: update for s390x RHEL-9.6 backports RHEL-9.6 backported the upstream v6.3 s390x syscall updates, so add a distro-specific kernel version check around the correct definitions. Signed-off-by: Joe Lawrence --- kmod/patch/kpatch-syscall.h | 80 ++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/kmod/patch/kpatch-syscall.h b/kmod/patch/kpatch-syscall.h index ec8d24d5..f26a3201 100644 --- a/kmod/patch/kpatch-syscall.h +++ b/kmod/patch/kpatch-syscall.h @@ -91,40 +91,23 @@ #elif defined(CONFIG_S390) -/* arch/s390/include/asm/syscall_wrapper.h versions */ # if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) +# define KPATCH_SYSCALL_WRAPPERS_V2 +# else +# define KPATCH_SYSCALL_WRAPPERS_V1 +# endif -#define __KPATCH_S390_SYS_STUBx(x, name, ...) \ - long __s390_sys##name(struct pt_regs *regs); \ - ALLOW_ERROR_INJECTION(__s390_sys##name, ERRNO); \ - static inline long ___se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__)); \ - long __s390_sys##name(struct pt_regs *regs) \ - { \ - return ___se_sys##name(SC_S390_REGS_TO_ARGS(x, __VA_ARGS__)); \ - } \ - static inline long ___se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__)) \ - { \ - __MAP(x, __SC_TEST, __VA_ARGS__); \ - return __kpatch_do_sys##name(__MAP(x, __SC_COMPAT_CAST, __VA_ARGS__)); \ - } +# if defined(RHEL_RELEASE_CODE) +# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 6) +# define KPATCH_SYSCALL_WRAPPERS_V2 +# else +# define KPATCH_SYSCALL_WRAPPERS_V1 +# endif +# endif -#define __KPATCH_SYSCALL_DEFINEx(x, name, ...) \ - long __s390x_sys##name(struct pt_regs *regs); \ - ALLOW_ERROR_INJECTION(__s390x_sys##name, ERRNO); \ - static inline long __se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__)); \ - static inline long __kpatch_do_sys##name(__MAP(x, __SC_DECL, __VA_ARGS__)); \ - __KPATCH_S390_SYS_STUBx(x, name, __VA_ARGS__); \ - long __s390x_sys##name(struct pt_regs *regs) \ - { \ - return __se_sys##name(SC_S390_REGS_TO_ARGS(x, __VA_ARGS__)); \ - } \ - static inline long __se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__)) \ - { \ - __MAP(x, __SC_TEST, __VA_ARGS__); \ - return __kpatch_do_sys##name(__MAP(x, __SC_CAST, __VA_ARGS__)); \ - } \ - static inline long __kpatch_do_sys##name(__MAP(x, __SC_DECL, __VA_ARGS__)) -# else + +/* arch/s390/include/asm/syscall_wrapper.h versions */ +#if defined(KPATCH_SYSCALL_WRAPPERS_V1) #define __KPATCH_S390_SYS_STUBx(x, name, ...) \ long __s390_sys##name(struct pt_regs *regs); \ @@ -157,7 +140,40 @@ __diag_pop(); \ static inline long __kpatch_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) -#endif /* LINUX_VERSION_CODE */ +# else /* KPATCH_SYSCALL_WRAPPERS_V2 */ + +#define __KPATCH_S390_SYS_STUBx(x, name, ...) \ + long __s390_sys##name(struct pt_regs *regs); \ + ALLOW_ERROR_INJECTION(__s390_sys##name, ERRNO); \ + static inline long ___se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__)); \ + long __s390_sys##name(struct pt_regs *regs) \ + { \ + return ___se_sys##name(SC_S390_REGS_TO_ARGS(x, __VA_ARGS__)); \ + } \ + static inline long ___se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__)) \ + { \ + __MAP(x, __SC_TEST, __VA_ARGS__); \ + return __kpatch_do_sys##name(__MAP(x, __SC_COMPAT_CAST, __VA_ARGS__)); \ + } + +#define __KPATCH_SYSCALL_DEFINEx(x, name, ...) \ + long __s390x_sys##name(struct pt_regs *regs); \ + ALLOW_ERROR_INJECTION(__s390x_sys##name, ERRNO); \ + static inline long __se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__)); \ + static inline long __kpatch_do_sys##name(__MAP(x, __SC_DECL, __VA_ARGS__)); \ + __KPATCH_S390_SYS_STUBx(x, name, __VA_ARGS__); \ + long __s390x_sys##name(struct pt_regs *regs) \ + { \ + return __se_sys##name(SC_S390_REGS_TO_ARGS(x, __VA_ARGS__)); \ + } \ + static inline long __se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__)) \ + { \ + __MAP(x, __SC_TEST, __VA_ARGS__); \ + return __kpatch_do_sys##name(__MAP(x, __SC_CAST, __VA_ARGS__)); \ + } \ + static inline long __kpatch_do_sys##name(__MAP(x, __SC_DECL, __VA_ARGS__)) + +#endif /* KPATCH_SYSCALL_WRAPPERS_V2 */ #elif defined(CONFIG_PPC64)