-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 this 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 providing our own version of the inline function without using jump labels. Signed-off-by: WHR <msl0000023508@gmail.com>
- Loading branch information
Showing
8 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
dnl # | ||
dnl # cpu_has_feature() may referencing GPL-only cpu_feature_keys on powerpc | ||
dnl # | ||
|
||
dnl # | ||
dnl # Checking if cpu_has_feature is exported GPL-only | ||
dnl # | ||
AC_DEFUN([ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE], [ | ||
ZFS_LINUX_TEST_SRC([cpu_has_feature], [ | ||
#include <linux/version.h> | ||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) | ||
#include <asm/cpu_has_feature.h> | ||
#else | ||
#include <asm/cputable.h> | ||
#endif | ||
], [ | ||
return cpu_has_feature(CPU_FTR_ALTIVEC) ? 0 : 1; | ||
], [], [ZFS_META_LICENSE]) | ||
]) | ||
AC_DEFUN([ZFS_AC_KERNEL_CPU_HAS_FEATURE], [ | ||
AC_MSG_CHECKING([whether cpu_has_feature() is GPL-only]) | ||
ZFS_LINUX_TEST_RESULT([cpu_has_feature_license], [ | ||
AC_MSG_RESULT(no) | ||
], [ | ||
AC_MSG_RESULT(yes) | ||
AC_DEFINE(HAVE_CPU_HAS_FEATURE_GPL_ONLY, 1, | ||
[cpu_has_feature() is GPL-only]) | ||
]) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
include/os/linux/kernel/linux/powerpc_cpu_has_feature_compat.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
|
||
#if defined __powerpc__ && defined CONFIG_JUMP_LABEL_FEATURE_CHECKS && \ | ||
defined HAVE_CPU_HAS_FEATURE_GPL_ONLY | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#ifndef __ASM_POWERPC_CPU_HAS_FEATURE_H | ||
#define __ASM_POWERPC_CPU_HAS_FEATURE_H | ||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#include <asm/cputable.h> | ||
|
||
static __always_inline bool early_cpu_has_feature(unsigned long feature) | ||
{ | ||
return (!!((CPU_FTRS_ALWAYS & feature) || | ||
(CPU_FTRS_POSSIBLE & cur_cpu_spec->cpu_features & feature))); | ||
} | ||
|
||
static __always_inline bool cpu_has_feature(unsigned long feature) | ||
{ | ||
return (early_cpu_has_feature(feature)); | ||
} | ||
|
||
#endif /* __ASSEMBLY__ */ | ||
|
||
#endif /* __ASM_POWERPC_CPU_HAS_FEATURE_H */ | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters