Workaround for Linux PowerPC GPL-only cpu_has_feature()

Linux since 4.7 makes interface 'cpu_has_feature' to use jump labels on
powerpc if CONFIG_JUMP_LABEL_FEATURE_CHECKS is enabled, in this case
however the inline function references GPL-only symbol
'cpu_feature_keys'.

ZFS currently uses 'cpu_has_feature' either directly or indirectly from
several places; while it is unknown how this issue didn't break ZFS on
64-bit little-endian powerpc, it is known to break ZFS with many Linux
versions on both 32-bit and 64-bit big-endian powerpc.

Until this issue is fixed in Linux, we have to workaround it by
overriding affected inline functions without depending on
'cpu_feature_keys'.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: WHR <msl0000023508@gmail.com>
Closes #14590
This commit is contained in:
Low-power
2023-03-11 01:35:00 +08:00
committed by Tony Hutter
parent 3ad6c1692f
commit 35d43ba8ea
5 changed files with 93 additions and 0 deletions
@@ -39,6 +39,21 @@
#define d_alias d_u.d_alias
#endif
/*
* Starting from Linux 5.13, flush_dcache_page() becomes an inline function
* and under some configurations, may indirectly referencing GPL-only
* cpu_feature_keys on powerpc. Override this function when it is detected
* being GPL-only.
*/
#if defined __powerpc__ && defined HAVE_FLUSH_DCACHE_PAGE_GPL_ONLY
#include <linux/simd_powerpc.h>
#define flush_dcache_page(page) do { \
if (!cpu_has_feature(CPU_FTR_COHERENT_ICACHE) && \
test_bit(PG_dcache_clean, &(page)->flags)) \
clear_bit(PG_dcache_clean, &(page)->flags); \
} while (0)
#endif
/*
* 2.6.30 API change,
* The const keyword was added to the 'struct dentry_operations' in
@@ -76,6 +76,17 @@
#define kfpu_init() 0
#define kfpu_fini() ((void) 0)
/*
* Linux 4.7 makes cpu_has_feature to use jump labels on powerpc if
* CONFIG_JUMP_LABEL_FEATURE_CHECKS is enabled, in this case however it
* references GPL-only symbol cpu_feature_keys. Therefore we overrides this
* interface when it is detected being GPL-only.
*/
#if defined(CONFIG_JUMP_LABEL_FEATURE_CHECKS) && \
defined(HAVE_CPU_HAS_FEATURE_GPL_ONLY)
#define cpu_has_feature(feature) early_cpu_has_feature(feature)
#endif
/*
* Check if AltiVec instruction set is available
*/