mirror of https://github.com/torvalds/linux.git
CRC updates for 6.16
Cleanups for the kernel's CRC (cyclic redundancy check) code: - Use __ro_after_init where appropriate - Remove unnecessary static_key on s390 - Rename some source code files - Rename the crc32 and crc32c crypto API modules - Use subsys_initcall instead of arch_initcall - Restore maintainers for crc_kunit.c - Fold crc16_byte() into crc16.c - Add some SPDX license identifiers -----BEGIN PGP SIGNATURE----- iIoEABYIADIWIQSacvsUNc7UX4ntmEPzXCl4vpKOKwUCaDNd3xQcZWJpZ2dlcnNA Z29vZ2xlLmNvbQAKCRDzXCl4vpKOKz0tAQCDqDA4Jd/54nnKpChMlKH8MTQDuwfz 8GHZi50mn4Rw5gD/f+hOGItPfswBId/+MZy+rKWL7bE2e9DdJdtoqRRtwA4= =RWFl -----END PGP SIGNATURE----- Merge tag 'crc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux Pull CRC updates from Eric Biggers: "Cleanups for the kernel's CRC (cyclic redundancy check) code: - Use __ro_after_init where appropriate - Remove unnecessary static_key on s390 - Rename some source code files - Rename the crc32 and crc32c crypto API modules - Use subsys_initcall instead of arch_initcall - Restore maintainers for crc_kunit.c - Fold crc16_byte() into crc16.c - Add some SPDX license identifiers" * tag 'crc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux: lib/crc32: add SPDX license identifier lib/crc16: unexport crc16_table and crc16_byte() w1: ds2406: use crc16() instead of crc16_byte() loop MAINTAINERS: add crc_kunit.c back to CRC LIBRARY lib/crc: make arch-optimized code use subsys_initcall crypto: crc32 - remove "generic" from file and module names x86/crc: drop "glue" from filenames sparc/crc: drop "glue" from filenames s390/crc: drop "glue" from filenames powerpc/crc: rename crc32-vpmsum_core.S to crc-vpmsum-template.S powerpc/crc: drop "glue" from filenames arm64/crc: drop "glue" from filenames arm/crc: drop "glue" from filenames s390/crc32: Remove no-op module init and exit functions s390/crc32: Remove have_vxrs static key lib/crc: make the CPU feature static keys __ro_after_init
This commit is contained in:
commit
15d90a5e55
|
|
@ -6263,6 +6263,7 @@ F: Documentation/staging/crc*
|
||||||
F: arch/*/lib/crc*
|
F: arch/*/lib/crc*
|
||||||
F: include/linux/crc*
|
F: include/linux/crc*
|
||||||
F: lib/crc*
|
F: lib/crc*
|
||||||
|
F: lib/tests/crc_kunit.c
|
||||||
F: scripts/gen-crc-consts.py
|
F: scripts/gen-crc-consts.py
|
||||||
|
|
||||||
CREATIVE SB0540
|
CREATIVE SB0540
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ endif
|
||||||
obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
|
obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
|
||||||
|
|
||||||
obj-$(CONFIG_CRC32_ARCH) += crc32-arm.o
|
obj-$(CONFIG_CRC32_ARCH) += crc32-arm.o
|
||||||
crc32-arm-y := crc32-glue.o crc32-core.o
|
crc32-arm-y := crc32.o crc32-core.o
|
||||||
|
|
||||||
obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-arm.o
|
obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-arm.o
|
||||||
crc-t10dif-arm-y := crc-t10dif-glue.o crc-t10dif-core.o
|
crc-t10dif-arm-y := crc-t10dif.o crc-t10dif-core.o
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
#include <asm/neon.h>
|
#include <asm/neon.h>
|
||||||
#include <asm/simd.h>
|
#include <asm/simd.h>
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_neon);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon);
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_pmull);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pmull);
|
||||||
|
|
||||||
#define CRC_T10DIF_PMULL_CHUNK_SIZE 16U
|
#define CRC_T10DIF_PMULL_CHUNK_SIZE 16U
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ static int __init crc_t10dif_arm_init(void)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc_t10dif_arm_init);
|
subsys_initcall(crc_t10dif_arm_init);
|
||||||
|
|
||||||
static void __exit crc_t10dif_arm_exit(void)
|
static void __exit crc_t10dif_arm_exit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
#include <asm/neon.h>
|
#include <asm/neon.h>
|
||||||
#include <asm/simd.h>
|
#include <asm/simd.h>
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_crc32);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32);
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_pmull);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pmull);
|
||||||
|
|
||||||
#define PMULL_MIN_LEN 64 /* min size of buffer for pmull functions */
|
#define PMULL_MIN_LEN 64 /* min size of buffer for pmull functions */
|
||||||
|
|
||||||
|
|
@ -103,7 +103,7 @@ static int __init crc32_arm_init(void)
|
||||||
static_branch_enable(&have_pmull);
|
static_branch_enable(&have_pmull);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc32_arm_init);
|
subsys_initcall(crc32_arm_init);
|
||||||
|
|
||||||
static void __exit crc32_arm_exit(void)
|
static void __exit crc32_arm_exit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -14,10 +14,10 @@ endif
|
||||||
lib-$(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) += uaccess_flushcache.o
|
lib-$(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) += uaccess_flushcache.o
|
||||||
|
|
||||||
obj-$(CONFIG_CRC32_ARCH) += crc32-arm64.o
|
obj-$(CONFIG_CRC32_ARCH) += crc32-arm64.o
|
||||||
crc32-arm64-y := crc32.o crc32-glue.o
|
crc32-arm64-y := crc32.o crc32-core.o
|
||||||
|
|
||||||
obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-arm64.o
|
obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-arm64.o
|
||||||
crc-t10dif-arm64-y := crc-t10dif-glue.o crc-t10dif-core.o
|
crc-t10dif-arm64-y := crc-t10dif.o crc-t10dif-core.o
|
||||||
|
|
||||||
obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
|
obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
#include <asm/neon.h>
|
#include <asm/neon.h>
|
||||||
#include <asm/simd.h>
|
#include <asm/simd.h>
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_asimd);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_asimd);
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_pmull);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pmull);
|
||||||
|
|
||||||
#define CRC_T10DIF_PMULL_CHUNK_SIZE 16U
|
#define CRC_T10DIF_PMULL_CHUNK_SIZE 16U
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ static int __init crc_t10dif_arm64_init(void)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc_t10dif_arm64_init);
|
subsys_initcall(crc_t10dif_arm64_init);
|
||||||
|
|
||||||
static void __exit crc_t10dif_arm64_exit(void)
|
static void __exit crc_t10dif_arm64_exit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -26,7 +26,7 @@ do { \
|
||||||
#define CRC32(crc, value, size) _CRC32(crc, value, size, crc)
|
#define CRC32(crc, value, size) _CRC32(crc, value, size, crc)
|
||||||
#define CRC32C(crc, value, size) _CRC32(crc, value, size, crcc)
|
#define CRC32C(crc, value, size) _CRC32(crc, value, size, crcc)
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_crc32);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32);
|
||||||
|
|
||||||
u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
|
u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
|
||||||
{
|
{
|
||||||
|
|
@ -114,7 +114,7 @@ static int __init crc32_loongarch_init(void)
|
||||||
static_branch_enable(&have_crc32);
|
static_branch_enable(&have_crc32);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc32_loongarch_init);
|
subsys_initcall(crc32_loongarch_init);
|
||||||
|
|
||||||
static void __exit crc32_loongarch_exit(void)
|
static void __exit crc32_loongarch_exit(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ do { \
|
||||||
#define CRC32C(crc, value, size) \
|
#define CRC32C(crc, value, size) \
|
||||||
_CRC32(crc, value, size, crc32c)
|
_CRC32(crc, value, size, crc32c)
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_crc32);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32);
|
||||||
|
|
||||||
u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
|
u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
|
||||||
{
|
{
|
||||||
|
|
@ -163,7 +163,7 @@ static int __init crc32_mips_init(void)
|
||||||
static_branch_enable(&have_crc32);
|
static_branch_enable(&have_crc32);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc32_mips_init);
|
subsys_initcall(crc32_mips_init);
|
||||||
|
|
||||||
static void __exit crc32_mips_exit(void)
|
static void __exit crc32_mips_exit(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -79,9 +79,9 @@ CFLAGS_xor_vmx.o += -mhard-float -maltivec $(call cc-option,-mabi=altivec)
|
||||||
CFLAGS_xor_vmx.o += -isystem $(shell $(CC) -print-file-name=include)
|
CFLAGS_xor_vmx.o += -isystem $(shell $(CC) -print-file-name=include)
|
||||||
|
|
||||||
obj-$(CONFIG_CRC32_ARCH) += crc32-powerpc.o
|
obj-$(CONFIG_CRC32_ARCH) += crc32-powerpc.o
|
||||||
crc32-powerpc-y := crc32-glue.o crc32c-vpmsum_asm.o
|
crc32-powerpc-y := crc32.o crc32c-vpmsum_asm.o
|
||||||
|
|
||||||
obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-powerpc.o
|
obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-powerpc.o
|
||||||
crc-t10dif-powerpc-y := crc-t10dif-glue.o crct10dif-vpmsum_asm.o
|
crc-t10dif-powerpc-y := crc-t10dif.o crct10dif-vpmsum_asm.o
|
||||||
|
|
||||||
obj-$(CONFIG_PPC64) += $(obj64-y)
|
obj-$(CONFIG_PPC64) += $(obj64-y)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define VECTOR_BREAKPOINT 64
|
#define VECTOR_BREAKPOINT 64
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
|
||||||
|
|
||||||
u32 __crct10dif_vpmsum(u32 crc, unsigned char const *p, size_t len);
|
u32 __crct10dif_vpmsum(u32 crc, unsigned char const *p, size_t len);
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ static int __init crc_t10dif_powerpc_init(void)
|
||||||
static_branch_enable(&have_vec_crypto);
|
static_branch_enable(&have_vec_crypto);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc_t10dif_powerpc_init);
|
subsys_initcall(crc_t10dif_powerpc_init);
|
||||||
|
|
||||||
static void __exit crc_t10dif_powerpc_exit(void)
|
static void __exit crc_t10dif_powerpc_exit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#define VECTOR_BREAKPOINT 512
|
#define VECTOR_BREAKPOINT 512
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
|
||||||
|
|
||||||
u32 __crc32c_vpmsum(u32 crc, const u8 *p, size_t len);
|
u32 __crc32c_vpmsum(u32 crc, const u8 *p, size_t len);
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ static int __init crc32_powerpc_init(void)
|
||||||
static_branch_enable(&have_vec_crypto);
|
static_branch_enable(&have_vec_crypto);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc32_powerpc_init);
|
subsys_initcall(crc32_powerpc_init);
|
||||||
|
|
||||||
static void __exit crc32_powerpc_exit(void)
|
static void __exit crc32_powerpc_exit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -839,4 +839,4 @@
|
||||||
|
|
||||||
#define CRC_FUNCTION_NAME __crc32c_vpmsum
|
#define CRC_FUNCTION_NAME __crc32c_vpmsum
|
||||||
#define REFLECT
|
#define REFLECT
|
||||||
#include "crc32-vpmsum_core.S"
|
#include "crc-vpmsum-template.S"
|
||||||
|
|
|
||||||
|
|
@ -842,4 +842,4 @@
|
||||||
.octa 0x0000000000000000000000018bb70000
|
.octa 0x0000000000000000000000018bb70000
|
||||||
|
|
||||||
#define CRC_FUNCTION_NAME __crct10dif_vpmsum
|
#define CRC_FUNCTION_NAME __crct10dif_vpmsum
|
||||||
#include "crc32-vpmsum_core.S"
|
#include "crc-vpmsum-template.S"
|
||||||
|
|
|
||||||
|
|
@ -26,4 +26,4 @@ lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
|
||||||
obj-$(CONFIG_EXPOLINE_EXTERN) += expoline.o
|
obj-$(CONFIG_EXPOLINE_EXTERN) += expoline.o
|
||||||
|
|
||||||
obj-$(CONFIG_CRC32_ARCH) += crc32-s390.o
|
obj-$(CONFIG_CRC32_ARCH) += crc32-s390.o
|
||||||
crc32-s390-y := crc32-glue.o crc32le-vx.o crc32be-vx.o
|
crc32-s390-y := crc32.o crc32le-vx.o crc32be-vx.o
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@
|
||||||
#define VX_ALIGNMENT 16L
|
#define VX_ALIGNMENT 16L
|
||||||
#define VX_ALIGN_MASK (VX_ALIGNMENT - 1)
|
#define VX_ALIGN_MASK (VX_ALIGNMENT - 1)
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_vxrs);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DEFINE_CRC32_VX() - Define a CRC-32 function using the vector extension
|
* DEFINE_CRC32_VX() - Define a CRC-32 function using the vector extension
|
||||||
*
|
*
|
||||||
|
|
@ -34,8 +32,7 @@ static DEFINE_STATIC_KEY_FALSE(have_vxrs);
|
||||||
unsigned long prealign, aligned, remaining; \
|
unsigned long prealign, aligned, remaining; \
|
||||||
DECLARE_KERNEL_FPU_ONSTACK16(vxstate); \
|
DECLARE_KERNEL_FPU_ONSTACK16(vxstate); \
|
||||||
\
|
\
|
||||||
if (datalen < VX_MIN_LEN + VX_ALIGN_MASK || \
|
if (datalen < VX_MIN_LEN + VX_ALIGN_MASK || !cpu_has_vx()) \
|
||||||
!static_branch_likely(&have_vxrs)) \
|
|
||||||
return ___crc32_sw(crc, data, datalen); \
|
return ___crc32_sw(crc, data, datalen); \
|
||||||
\
|
\
|
||||||
if ((unsigned long)data & VX_ALIGN_MASK) { \
|
if ((unsigned long)data & VX_ALIGN_MASK) { \
|
||||||
|
|
@ -64,25 +61,13 @@ DEFINE_CRC32_VX(crc32_le_arch, crc32_le_vgfm_16, crc32_le_base)
|
||||||
DEFINE_CRC32_VX(crc32_be_arch, crc32_be_vgfm_16, crc32_be_base)
|
DEFINE_CRC32_VX(crc32_be_arch, crc32_be_vgfm_16, crc32_be_base)
|
||||||
DEFINE_CRC32_VX(crc32c_arch, crc32c_le_vgfm_16, crc32c_base)
|
DEFINE_CRC32_VX(crc32c_arch, crc32c_le_vgfm_16, crc32c_base)
|
||||||
|
|
||||||
static int __init crc32_s390_init(void)
|
|
||||||
{
|
|
||||||
if (cpu_have_feature(S390_CPU_FEATURE_VXRS))
|
|
||||||
static_branch_enable(&have_vxrs);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
arch_initcall(crc32_s390_init);
|
|
||||||
|
|
||||||
static void __exit crc32_s390_exit(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
module_exit(crc32_s390_exit);
|
|
||||||
|
|
||||||
u32 crc32_optimizations(void)
|
u32 crc32_optimizations(void)
|
||||||
{
|
{
|
||||||
if (static_key_enabled(&have_vxrs))
|
if (cpu_has_vx()) {
|
||||||
return CRC32_LE_OPTIMIZATION |
|
return CRC32_LE_OPTIMIZATION |
|
||||||
CRC32_BE_OPTIMIZATION |
|
CRC32_BE_OPTIMIZATION |
|
||||||
CRC32C_OPTIMIZATION;
|
CRC32C_OPTIMIZATION;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(crc32_optimizations);
|
EXPORT_SYMBOL(crc32_optimizations);
|
||||||
|
|
@ -54,4 +54,4 @@ obj-$(CONFIG_SPARC64) += iomap.o
|
||||||
obj-$(CONFIG_SPARC32) += atomic32.o
|
obj-$(CONFIG_SPARC32) += atomic32.o
|
||||||
obj-$(CONFIG_SPARC64) += PeeCeeI.o
|
obj-$(CONFIG_SPARC64) += PeeCeeI.o
|
||||||
obj-$(CONFIG_CRC32_ARCH) += crc32-sparc.o
|
obj-$(CONFIG_CRC32_ARCH) += crc32-sparc.o
|
||||||
crc32-sparc-y := crc32_glue.o crc32c_asm.o
|
crc32-sparc-y := crc32.o crc32c_asm.o
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/* Glue code for CRC32C optimized for sparc64 crypto opcodes.
|
/* CRC32c (Castagnoli), sparc64 crc32c opcode accelerated
|
||||||
*
|
*
|
||||||
* This is based largely upon arch/x86/crypto/crc32c-intel.c
|
* This is based largely upon arch/x86/crypto/crc32c-intel.c
|
||||||
*
|
*
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
#include <asm/pstate.h>
|
#include <asm/pstate.h>
|
||||||
#include <asm/elf.h>
|
#include <asm/elf.h>
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_crc32c_opcode);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32c_opcode);
|
||||||
|
|
||||||
u32 crc32_le_arch(u32 crc, const u8 *data, size_t len)
|
u32 crc32_le_arch(u32 crc, const u8 *data, size_t len)
|
||||||
{
|
{
|
||||||
|
|
@ -74,7 +74,7 @@ static int __init crc32_sparc_init(void)
|
||||||
pr_info("Using sparc64 crc32c opcode optimized CRC32C implementation\n");
|
pr_info("Using sparc64 crc32c opcode optimized CRC32C implementation\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc32_sparc_init);
|
subsys_initcall(crc32_sparc_init);
|
||||||
|
|
||||||
static void __exit crc32_sparc_exit(void)
|
static void __exit crc32_sparc_exit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -39,14 +39,14 @@ lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
|
||||||
lib-$(CONFIG_MITIGATION_RETPOLINE) += retpoline.o
|
lib-$(CONFIG_MITIGATION_RETPOLINE) += retpoline.o
|
||||||
|
|
||||||
obj-$(CONFIG_CRC32_ARCH) += crc32-x86.o
|
obj-$(CONFIG_CRC32_ARCH) += crc32-x86.o
|
||||||
crc32-x86-y := crc32-glue.o crc32-pclmul.o
|
crc32-x86-y := crc32.o crc32-pclmul.o
|
||||||
crc32-x86-$(CONFIG_64BIT) += crc32c-3way.o
|
crc32-x86-$(CONFIG_64BIT) += crc32c-3way.o
|
||||||
|
|
||||||
obj-$(CONFIG_CRC64_ARCH) += crc64-x86.o
|
obj-$(CONFIG_CRC64_ARCH) += crc64-x86.o
|
||||||
crc64-x86-y := crc64-glue.o crc64-pclmul.o
|
crc64-x86-y := crc64.o crc64-pclmul.o
|
||||||
|
|
||||||
obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-x86.o
|
obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-x86.o
|
||||||
crc-t10dif-x86-y := crc-t10dif-glue.o crc16-msb-pclmul.o
|
crc-t10dif-x86-y := crc-t10dif.o crc16-msb-pclmul.o
|
||||||
|
|
||||||
obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
|
obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
|
||||||
obj-y += iomem.o
|
obj-y += iomem.o
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include "crc-pclmul-template.h"
|
#include "crc-pclmul-template.h"
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
|
||||||
|
|
||||||
DECLARE_CRC_PCLMUL_FUNCS(crc16_msb, u16);
|
DECLARE_CRC_PCLMUL_FUNCS(crc16_msb, u16);
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ static int __init crc_t10dif_x86_init(void)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc_t10dif_x86_init);
|
subsys_initcall(crc_t10dif_x86_init);
|
||||||
|
|
||||||
static void __exit crc_t10dif_x86_exit(void)
|
static void __exit crc_t10dif_x86_exit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include "crc-pclmul-template.h"
|
#include "crc-pclmul-template.h"
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_crc32);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32);
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
|
||||||
|
|
||||||
DECLARE_CRC_PCLMUL_FUNCS(crc32_lsb, u32);
|
DECLARE_CRC_PCLMUL_FUNCS(crc32_lsb, u32);
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ static int __init crc32_x86_init(void)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc32_x86_init);
|
subsys_initcall(crc32_x86_init);
|
||||||
|
|
||||||
static void __exit crc32_x86_exit(void)
|
static void __exit crc32_x86_exit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include "crc-pclmul-template.h"
|
#include "crc-pclmul-template.h"
|
||||||
|
|
||||||
static DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
|
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
|
||||||
|
|
||||||
DECLARE_CRC_PCLMUL_FUNCS(crc64_msb, u64);
|
DECLARE_CRC_PCLMUL_FUNCS(crc64_msb, u64);
|
||||||
DECLARE_CRC_PCLMUL_FUNCS(crc64_lsb, u64);
|
DECLARE_CRC_PCLMUL_FUNCS(crc64_lsb, u64);
|
||||||
|
|
@ -39,7 +39,7 @@ static int __init crc64_x86_init(void)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
arch_initcall(crc64_x86_init);
|
subsys_initcall(crc64_x86_init);
|
||||||
|
|
||||||
static void __exit crc64_x86_exit(void)
|
static void __exit crc64_x86_exit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -152,10 +152,12 @@ obj-$(CONFIG_CRYPTO_CHACHA20) += chacha_generic.o
|
||||||
obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o
|
obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o
|
||||||
obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
|
obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
|
||||||
obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
|
obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
|
||||||
obj-$(CONFIG_CRYPTO_CRC32C) += crc32c_generic.o
|
obj-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
|
||||||
obj-$(CONFIG_CRYPTO_CRC32) += crc32_generic.o
|
crc32c-cryptoapi-y := crc32c.o
|
||||||
CFLAGS_crc32c_generic.o += -DARCH=$(ARCH)
|
CFLAGS_crc32c.o += -DARCH=$(ARCH)
|
||||||
CFLAGS_crc32_generic.o += -DARCH=$(ARCH)
|
obj-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
|
||||||
|
crc32-cryptoapi-y := crc32.o
|
||||||
|
CFLAGS_crc32.o += -DARCH=$(ARCH)
|
||||||
obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
|
obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
|
||||||
obj-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
|
obj-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
|
||||||
obj-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
|
obj-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ static ssize_t w1_f12_read_state(
|
||||||
{
|
{
|
||||||
u8 w1_buf[6] = {W1_F12_FUNC_READ_STATUS, 7, 0, 0, 0, 0};
|
u8 w1_buf[6] = {W1_F12_FUNC_READ_STATUS, 7, 0, 0, 0, 0};
|
||||||
struct w1_slave *sl = kobj_to_w1_slave(kobj);
|
struct w1_slave *sl = kobj_to_w1_slave(kobj);
|
||||||
u16 crc = 0;
|
|
||||||
int i;
|
|
||||||
ssize_t rtnval = 1;
|
ssize_t rtnval = 1;
|
||||||
|
|
||||||
if (off != 0)
|
if (off != 0)
|
||||||
|
|
@ -47,9 +45,7 @@ static ssize_t w1_f12_read_state(
|
||||||
|
|
||||||
w1_write_block(sl->master, w1_buf, 3);
|
w1_write_block(sl->master, w1_buf, 3);
|
||||||
w1_read_block(sl->master, w1_buf+3, 3);
|
w1_read_block(sl->master, w1_buf+3, 3);
|
||||||
for (i = 0; i < 6; i++)
|
if (crc16(0, w1_buf, sizeof(w1_buf)) == 0xb001) /* good read? */
|
||||||
crc = crc16_byte(crc, w1_buf[i]);
|
|
||||||
if (crc == 0xb001) /* good read? */
|
|
||||||
*buf = ((w1_buf[3]>>5)&3)|0x30;
|
*buf = ((w1_buf[3]>>5)&3)|0x30;
|
||||||
else
|
else
|
||||||
rtnval = -EIO;
|
rtnval = -EIO;
|
||||||
|
|
@ -66,8 +62,6 @@ static ssize_t w1_f12_write_output(
|
||||||
{
|
{
|
||||||
struct w1_slave *sl = kobj_to_w1_slave(kobj);
|
struct w1_slave *sl = kobj_to_w1_slave(kobj);
|
||||||
u8 w1_buf[6] = {W1_F12_FUNC_WRITE_STATUS, 7, 0, 0, 0, 0};
|
u8 w1_buf[6] = {W1_F12_FUNC_WRITE_STATUS, 7, 0, 0, 0, 0};
|
||||||
u16 crc = 0;
|
|
||||||
int i;
|
|
||||||
ssize_t rtnval = 1;
|
ssize_t rtnval = 1;
|
||||||
|
|
||||||
if (count != 1 || off != 0)
|
if (count != 1 || off != 0)
|
||||||
|
|
@ -83,9 +77,7 @@ static ssize_t w1_f12_write_output(
|
||||||
w1_buf[3] = (((*buf)&3)<<5)|0x1F;
|
w1_buf[3] = (((*buf)&3)<<5)|0x1F;
|
||||||
w1_write_block(sl->master, w1_buf, 4);
|
w1_write_block(sl->master, w1_buf, 4);
|
||||||
w1_read_block(sl->master, w1_buf+4, 2);
|
w1_read_block(sl->master, w1_buf+4, 2);
|
||||||
for (i = 0; i < 6; i++)
|
if (crc16(0, w1_buf, sizeof(w1_buf)) == 0xb001) /* good read? */
|
||||||
crc = crc16_byte(crc, w1_buf[i]);
|
|
||||||
if (crc == 0xb001) /* good read? */
|
|
||||||
w1_write_8(sl->master, 0xFF);
|
w1_write_8(sl->master, 0xFF);
|
||||||
else
|
else
|
||||||
rtnval = -EIO;
|
rtnval = -EIO;
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,7 @@
|
||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
extern u16 const crc16_table[256];
|
u16 crc16(u16 crc, const u8 *p, size_t len);
|
||||||
|
|
||||||
extern u16 crc16(u16 crc, const u8 *buffer, size_t len);
|
|
||||||
|
|
||||||
static inline u16 crc16_byte(u16 crc, const u8 data)
|
|
||||||
{
|
|
||||||
return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __CRC16_H */
|
#endif /* __CRC16_H */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
/*
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
* crc32.h
|
|
||||||
* See linux/lib/crc32.c for license and changes
|
|
||||||
*/
|
|
||||||
#ifndef _LINUX_CRC32_H
|
#ifndef _LINUX_CRC32_H
|
||||||
#define _LINUX_CRC32_H
|
#define _LINUX_CRC32_H
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include <linux/crc16.h>
|
#include <linux/crc16.h>
|
||||||
|
|
||||||
/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
|
/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
|
||||||
u16 const crc16_table[256] = {
|
static const u16 crc16_table[256] = {
|
||||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
||||||
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
||||||
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
|
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
|
||||||
|
|
@ -42,20 +42,19 @@ u16 const crc16_table[256] = {
|
||||||
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
||||||
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||||
};
|
};
|
||||||
EXPORT_SYMBOL(crc16_table);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* crc16 - compute the CRC-16 for the data buffer
|
* crc16 - compute the CRC-16 for the data buffer
|
||||||
* @crc: previous CRC value
|
* @crc: previous CRC value
|
||||||
* @buffer: data pointer
|
* @p: data pointer
|
||||||
* @len: number of bytes in the buffer
|
* @len: number of bytes in the buffer
|
||||||
*
|
*
|
||||||
* Returns the updated CRC value.
|
* Returns the updated CRC value.
|
||||||
*/
|
*/
|
||||||
u16 crc16(u16 crc, u8 const *buffer, size_t len)
|
u16 crc16(u16 crc, const u8 *p, size_t len)
|
||||||
{
|
{
|
||||||
while (len--)
|
while (len--)
|
||||||
crc = crc16_byte(crc, *buffer++);
|
crc = (crc >> 8) ^ crc16_table[(crc & 0xff) ^ *p++];
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(crc16);
|
EXPORT_SYMBOL(crc16);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/*
|
/*
|
||||||
* Aug 8, 2011 Bob Pearson with help from Joakim Tjernlund and George Spelvin
|
* Aug 8, 2011 Bob Pearson with help from Joakim Tjernlund and George Spelvin
|
||||||
* cleaned up code to current version of sparse and added the slicing-by-8
|
* cleaned up code to current version of sparse and added the slicing-by-8
|
||||||
|
|
@ -19,9 +20,6 @@
|
||||||
* drivers/net/smc9194.c uses seed ~0, doesn't xor with ~0.
|
* drivers/net/smc9194.c uses seed ~0, doesn't xor with ~0.
|
||||||
* fs/jffs2 uses seed 0, doesn't xor with ~0.
|
* fs/jffs2 uses seed 0, doesn't xor with ~0.
|
||||||
* fs/partitions/efi.c uses seed ~0, xor's with ~0.
|
* fs/partitions/efi.c uses seed ~0, xor's with ~0.
|
||||||
*
|
|
||||||
* This source code is licensed under the GNU General Public License,
|
|
||||||
* Version 2. See the file COPYING for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* see: Documentation/staging/crc32.rst for a description of algorithms */
|
/* see: Documentation/staging/crc32.rst for a description of algorithms */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue