From a0df45f8baaba6bab25fdc2d6d9475fd7cba5bd2 Mon Sep 17 00:00:00 2001 From: Alexey Makhalov Date: Fri, 3 Feb 2017 07:11:28 -0800 Subject: [PATCH 3/3] Added rap_plugin Functions signature fixing is probably still required. --- arch/x86/crypto/aesni-intel_asm.S | 10 +- arch/x86/crypto/aesni-intel_glue.c | 4 +- arch/x86/crypto/blowfish-x86_64-asm_64.S | 4 +- arch/x86/crypto/camellia-aesni-avx-asm_64.S | 12 +- arch/x86/crypto/camellia-aesni-avx2-asm_64.S | 12 +- arch/x86/crypto/camellia-x86_64-asm_64.S | 4 +- arch/x86/crypto/cast5-avx-x86_64-asm_64.S | 4 +- arch/x86/crypto/cast6-avx-x86_64-asm_64.S | 12 +- arch/x86/crypto/serpent-avx-x86_64-asm_64.S | 12 +- arch/x86/crypto/serpent-avx2-asm_64.S | 12 +- arch/x86/crypto/sha1-mb/sha1_mb_mgr_flush_avx2.S | 4 +- arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.S | 2 +- arch/x86/crypto/sha1_ssse3_glue.c | 56 +-- arch/x86/crypto/sha256-avx-asm.S | 2 +- arch/x86/crypto/sha256-avx2-asm.S | 2 +- .../crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S | 4 +- .../crypto/sha256-mb/sha256_mb_mgr_submit_avx2.S | 2 +- arch/x86/crypto/sha256-ssse3-asm.S | 2 +- arch/x86/crypto/sha256_ni_asm.S | 2 +- arch/x86/crypto/sha256_ssse3_glue.c | 26 +- arch/x86/crypto/sha512-avx-asm.S | 2 +- arch/x86/crypto/sha512-avx2-asm.S | 2 +- .../crypto/sha512-mb/sha512_mb_mgr_flush_avx2.S | 4 +- .../crypto/sha512-mb/sha512_mb_mgr_submit_avx2.S | 2 +- arch/x86/crypto/sha512-ssse3-asm.S | 2 +- arch/x86/crypto/twofish-avx-x86_64-asm_64.S | 12 +- arch/x86/crypto/twofish-i586-asm_32.S | 4 +- arch/x86/crypto/twofish-x86_64-asm_64-3way.S | 2 +- arch/x86/crypto/twofish-x86_64-asm_64.S | 4 +- arch/x86/entry/Makefile | 2 + arch/x86/entry/common.c | 61 +++ arch/x86/events/amd/iommu.h | 2 +- arch/x86/include/asm/e820/api.h | 2 +- arch/x86/include/asm/fixmap.h | 2 +- arch/x86/include/asm/module.h | 9 +- arch/x86/kernel/cpu/vmware.c | 8 +- arch/x86/kernel/e820.c | 2 +- arch/x86/kernel/ftrace_64.S | 2 +- arch/x86/kernel/traps.c | 4 + arch/x86/mm/pgtable.c | 2 +- arch/x86/oprofile/nmi_int.c | 2 +- arch/x86/xen/xen-asm.S | 8 +- drivers/acpi/button.c | 4 +- drivers/acpi/ec.c | 4 +- drivers/acpi/sysfs.c | 6 +- drivers/char/ipmi/ipmi_poweroff.c | 2 +- drivers/char/ipmi/ipmi_si_intf.c | 4 +- drivers/char/tpm/tpm-chip.c | 9 +- drivers/edac/edac_mc_sysfs.c | 2 +- drivers/firmware/dmi-id.c | 7 +- drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c | 7 +- .../gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 7 +- drivers/gpu/drm/radeon/radeon_kms.c | 4 +- drivers/hid/hid-magicmouse.c | 2 +- drivers/ide/ide.c | 4 +- drivers/md/md.c | 6 +- drivers/media/usb/uvc/uvc_driver.c | 4 +- drivers/message/fusion/mptbase.c | 4 +- drivers/misc/kgdbts.c | 2 +- drivers/mtd/devices/block2mtd.c | 2 +- drivers/mtd/devices/phram.c | 2 +- drivers/mtd/ubi/build.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 216 ++++---- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h | 4 +- drivers/net/ethernet/brocade/bna/bfa_cs.h | 42 +- drivers/net/ethernet/brocade/bna/bfa_ioc.c | 10 +- drivers/net/ethernet/brocade/bna/bfa_ioc.h | 4 +- drivers/net/ethernet/brocade/bna/bfa_msgq.h | 8 +- drivers/net/ethernet/brocade/bna/bna_enet.c | 6 +- drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 6 +- drivers/net/ethernet/brocade/bna/bna_types.h | 24 +- drivers/net/ethernet/brocade/bna/bnad.c | 11 +- drivers/pci/pcie/aspm.c | 4 +- drivers/platform/x86/thinkpad_acpi.c | 2 +- drivers/ras/ras.c | 2 +- drivers/scsi/aacraid/aachba.c | 7 +- drivers/scsi/aic7xxx/aic79xx.h | 2 +- drivers/scsi/aic7xxx/aic79xx_core.c | 11 +- drivers/scsi/bfa/bfa.h | 4 +- drivers/scsi/bfa/bfa_core.c | 4 +- drivers/scsi/bfa/bfa_cs.h | 124 ++++- drivers/scsi/bfa/bfa_fcpim.h | 12 +- drivers/scsi/bfa/bfa_fcs.h | 34 +- drivers/scsi/bfa/bfa_fcs_fcpim.c | 6 +- drivers/scsi/bfa/bfa_fcs_lport.c | 4 +- drivers/scsi/bfa/bfa_fcs_rport.c | 4 +- drivers/scsi/bfa/bfa_ioc.c | 8 +- drivers/scsi/bfa/bfa_ioc.h | 12 +- drivers/scsi/bfa/bfa_svc.c | 12 +- drivers/scsi/bfa/bfa_svc.h | 20 +- drivers/scsi/bfa/bfad.c | 12 +- drivers/scsi/bfa/bfad_bsg.c | 8 +- drivers/scsi/bfa/bfad_drv.h | 5 +- drivers/scsi/csiostor/csio_defs.h | 19 +- drivers/scsi/csiostor/csio_hw.c | 69 ++- drivers/scsi/csiostor/csio_init.c | 2 +- drivers/scsi/csiostor/csio_lnode.c | 32 +- drivers/scsi/csiostor/csio_rnode.c | 28 +- drivers/scsi/csiostor/csio_scsi.c | 37 +- drivers/scsi/fcoe/fcoe_transport.c | 16 +- drivers/scsi/ipr.c | 26 +- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +- drivers/scsi/pmcraid.c | 26 +- drivers/tty/serial/kgdboc.c | 2 +- drivers/video/console/dummycon.c | 77 ++- fs/afs/file.c | 8 +- fs/afs/internal.h | 2 +- fs/exofs/inode.c | 7 +- fs/fuse/file.c | 4 +- fs/fuse/inode.c | 4 +- fs/lockd/svc.c | 2 +- fs/nfs/dir.c | 5 +- fs/nfs/read.c | 2 +- fs/nfs/symlink.c | 6 +- fs/nfsd/nfs4xdr.c | 556 ++++++++++++--------- include/linux/compiler.h | 84 +--- include/linux/linkage.h | 28 +- include/linux/moduleparam.h | 8 +- include/linux/netfilter/ipset/ip_set_comment.h | 3 +- include/linux/pagemap.h | 4 +- include/linux/syscalls.h | 18 +- include/linux/timer.h | 2 +- include/net/netfilter/nf_conntrack.h | 2 +- kernel/bpf/core.c | 15 + kernel/events/core.c | 6 +- kernel/module.c | 9 +- kernel/sched/core.c | 4 +- kernel/sched/deadline.c | 4 +- kernel/sched/rt.c | 4 +- kernel/sched/sched.h | 9 +- mm/filemap.c | 6 +- mm/readahead.c | 2 +- net/bridge/br_private.h | 3 +- net/netfilter/ipset/ip_set_core.c | 3 +- net/netfilter/nf_conntrack_core.c | 2 +- net/netfilter/nf_nat_ftp.c | 2 +- net/netfilter/nf_nat_irc.c | 2 +- net/sunrpc/svc.c | 4 +- scripts/Makefile.gcc-plugins | 13 + scripts/gcc-plugins/rap_plugin/Makefile | 6 + scripts/gcc-plugins/rap_plugin/rap.h | 36 ++ scripts/gcc-plugins/rap_plugin/rap_fptr_pass.c | 220 ++++++++ scripts/gcc-plugins/rap_plugin/rap_hash.c | 382 ++++++++++++++ scripts/gcc-plugins/rap_plugin/rap_plugin.c | 534 ++++++++++++++++++++ scripts/gcc-plugins/rap_plugin/sip.c | 96 ++++ security/Kconfig | 18 + security/apparmor/lsm.c | 16 +- 148 files changed, 2659 insertions(+), 860 deletions(-) create mode 100644 scripts/gcc-plugins/rap_plugin/Makefile create mode 100644 scripts/gcc-plugins/rap_plugin/rap.h create mode 100644 scripts/gcc-plugins/rap_plugin/rap_fptr_pass.c create mode 100644 scripts/gcc-plugins/rap_plugin/rap_hash.c create mode 100644 scripts/gcc-plugins/rap_plugin/rap_plugin.c create mode 100644 scripts/gcc-plugins/rap_plugin/sip.c diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S index 12e8484..dea170b 100644 --- a/arch/x86/crypto/aesni-intel_asm.S +++ b/arch/x86/crypto/aesni-intel_asm.S @@ -1332,7 +1332,7 @@ _esb_loop_\@: * poly = x^128 + x^127 + x^126 + x^121 + 1 * *****************************************************************************/ -ENTRY(aesni_gcm_dec) +RAP_ENTRY(aesni_gcm_dec) push %r12 push %r13 push %r14 @@ -1595,7 +1595,7 @@ ENDPROC(aesni_gcm_dec) * * poly = x^128 + x^127 + x^126 + x^121 + 1 ***************************************************************************/ -ENTRY(aesni_gcm_enc) +RAP_ENTRY(aesni_gcm_enc) push %r12 push %r13 push %r14 @@ -1980,7 +1980,7 @@ ENDPROC(aesni_set_key) /* * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src) */ -ENTRY(aesni_enc) +RAP_ENTRY(aesni_enc) FRAME_BEGIN #ifndef __x86_64__ pushl KEYP @@ -2171,7 +2171,7 @@ ENDPROC(_aesni_enc4) /* * void aesni_dec (struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src) */ -ENTRY(aesni_dec) +RAP_ENTRY(aesni_dec) FRAME_BEGIN #ifndef __x86_64__ pushl KEYP @@ -2680,7 +2680,7 @@ ENDPROC(_aesni_inc) * void aesni_ctr_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src, * size_t len, u8 *iv) */ -ENTRY(aesni_ctr_enc) +RAP_ENTRY(aesni_ctr_enc) FRAME_BEGIN cmp $16, LEN jb .Lctr_enc_just_ret diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index c690ddc..ca0084c 100644 --- a/arch/x86/crypto/aesni-intel_glue.c +++ b/arch/x86/crypto/aesni-intel_glue.c @@ -74,9 +74,9 @@ struct aesni_xts_ctx { asmlinkage int aesni_set_key(struct crypto_aes_ctx *ctx, const u8 *in_key, unsigned int key_len); -asmlinkage void aesni_enc(struct crypto_aes_ctx *ctx, u8 *out, +asmlinkage void aesni_enc(void *ctx, u8 *out, const u8 *in); -asmlinkage void aesni_dec(struct crypto_aes_ctx *ctx, u8 *out, +asmlinkage void aesni_dec(void *ctx, u8 *out, const u8 *in); asmlinkage void aesni_ecb_enc(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in, unsigned int len); diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S index 8c1fcb6..9c229bdd8 100644 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S @@ -156,7 +156,7 @@ ENTRY(__blowfish_enc_blk) ret; ENDPROC(__blowfish_enc_blk) -ENTRY(blowfish_dec_blk) +RAP_ENTRY(blowfish_dec_blk) /* input: * %rdi: ctx * %rsi: dst @@ -347,7 +347,7 @@ ENTRY(__blowfish_enc_blk_4way) ret; ENDPROC(__blowfish_enc_blk_4way) -ENTRY(blowfish_dec_blk_4way) +RAP_ENTRY(blowfish_dec_blk_4way) /* input: * %rdi: ctx * %rsi: dst diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S index a14af6e..f24f291 100644 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S @@ -893,7 +893,7 @@ __camellia_dec_blk16: jmp .Ldec_max24; ENDPROC(__camellia_dec_blk16) -ENTRY(camellia_ecb_enc_16way) +RAP_ENTRY(camellia_ecb_enc_16way) /* input: * %rdi: ctx, CTX * %rsi: dst (16 blocks) @@ -918,7 +918,7 @@ ENTRY(camellia_ecb_enc_16way) ret; ENDPROC(camellia_ecb_enc_16way) -ENTRY(camellia_ecb_dec_16way) +RAP_ENTRY(camellia_ecb_dec_16way) /* input: * %rdi: ctx, CTX * %rsi: dst (16 blocks) @@ -948,7 +948,7 @@ ENTRY(camellia_ecb_dec_16way) ret; ENDPROC(camellia_ecb_dec_16way) -ENTRY(camellia_cbc_dec_16way) +RAP_ENTRY(camellia_cbc_dec_16way) /* input: * %rdi: ctx, CTX * %rsi: dst (16 blocks) @@ -1005,7 +1005,7 @@ ENDPROC(camellia_cbc_dec_16way) vpslldq $8, tmp, tmp; \ vpsubq tmp, x, x; -ENTRY(camellia_ctr_16way) +RAP_ENTRY(camellia_ctr_16way) /* input: * %rdi: ctx, CTX * %rsi: dst (16 blocks) @@ -1256,7 +1256,7 @@ camellia_xts_crypt_16way: ret; ENDPROC(camellia_xts_crypt_16way) -ENTRY(camellia_xts_enc_16way) +RAP_ENTRY(camellia_xts_enc_16way) /* input: * %rdi: ctx, CTX * %rsi: dst (16 blocks) @@ -1270,7 +1270,7 @@ ENTRY(camellia_xts_enc_16way) jmp camellia_xts_crypt_16way; ENDPROC(camellia_xts_enc_16way) -ENTRY(camellia_xts_dec_16way) +RAP_ENTRY(camellia_xts_dec_16way) /* input: * %rdi: ctx, CTX * %rsi: dst (16 blocks) diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S index b66bbfa..10093da 100644 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S @@ -936,7 +936,7 @@ __camellia_dec_blk32: jmp .Ldec_max24; ENDPROC(__camellia_dec_blk32) -ENTRY(camellia_ecb_enc_32way) +RAP_ENTRY(camellia_ecb_enc_32way) /* input: * %rdi: ctx, CTX * %rsi: dst (32 blocks) @@ -965,7 +965,7 @@ ENTRY(camellia_ecb_enc_32way) ret; ENDPROC(camellia_ecb_enc_32way) -ENTRY(camellia_ecb_dec_32way) +RAP_ENTRY(camellia_ecb_dec_32way) /* input: * %rdi: ctx, CTX * %rsi: dst (32 blocks) @@ -999,7 +999,7 @@ ENTRY(camellia_ecb_dec_32way) ret; ENDPROC(camellia_ecb_dec_32way) -ENTRY(camellia_cbc_dec_32way) +RAP_ENTRY(camellia_cbc_dec_32way) /* input: * %rdi: ctx, CTX * %rsi: dst (32 blocks) @@ -1081,7 +1081,7 @@ ENDPROC(camellia_cbc_dec_32way) vpslldq $8, tmp1, tmp1; \ vpsubq tmp1, x, x; -ENTRY(camellia_ctr_32way) +RAP_ENTRY(camellia_ctr_32way) /* input: * %rdi: ctx, CTX * %rsi: dst (32 blocks) @@ -1374,7 +1374,7 @@ camellia_xts_crypt_32way: ret; ENDPROC(camellia_xts_crypt_32way) -ENTRY(camellia_xts_enc_32way) +RAP_ENTRY(camellia_xts_enc_32way) /* input: * %rdi: ctx, CTX * %rsi: dst (32 blocks) @@ -1389,7 +1389,7 @@ ENTRY(camellia_xts_enc_32way) jmp camellia_xts_crypt_32way; ENDPROC(camellia_xts_enc_32way) -ENTRY(camellia_xts_dec_32way) +RAP_ENTRY(camellia_xts_dec_32way) /* input: * %rdi: ctx, CTX * %rsi: dst (32 blocks) diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S index 95ba695..3d6f034 100644 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S @@ -237,7 +237,7 @@ ENTRY(__camellia_enc_blk) ret; ENDPROC(__camellia_enc_blk) -ENTRY(camellia_dec_blk) +RAP_ENTRY(camellia_dec_blk) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -473,7 +473,7 @@ ENTRY(__camellia_enc_blk_2way) ret; ENDPROC(__camellia_enc_blk_2way) -ENTRY(camellia_dec_blk_2way) +RAP_ENTRY(camellia_dec_blk_2way) /* input: * %rdi: ctx, CTX * %rsi: dst diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S index 86107c9..529710e 100644 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S @@ -374,7 +374,7 @@ __cast5_dec_blk16: jmp .L__dec_tail; ENDPROC(__cast5_dec_blk16) -ENTRY(cast5_ecb_enc_16way) +RAP_ENTRY(cast5_ecb_enc_16way) /* input: * %rdi: ctx * %rsi: dst @@ -411,7 +411,7 @@ ENTRY(cast5_ecb_enc_16way) ret; ENDPROC(cast5_ecb_enc_16way) -ENTRY(cast5_ecb_dec_16way) +RAP_ENTRY(cast5_ecb_dec_16way) /* input: * %rdi: ctx * %rsi: dst diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S index 7f30b6f..ceea523 100644 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S @@ -356,7 +356,7 @@ __cast6_dec_blk8: ret; ENDPROC(__cast6_dec_blk8) -ENTRY(cast6_ecb_enc_8way) +RAP_ENTRY(cast6_ecb_enc_8way) /* input: * %rdi: ctx * %rsi: dst @@ -379,7 +379,7 @@ ENTRY(cast6_ecb_enc_8way) ret; ENDPROC(cast6_ecb_enc_8way) -ENTRY(cast6_ecb_dec_8way) +RAP_ENTRY(cast6_ecb_dec_8way) /* input: * %rdi: ctx * %rsi: dst @@ -402,7 +402,7 @@ ENTRY(cast6_ecb_dec_8way) ret; ENDPROC(cast6_ecb_dec_8way) -ENTRY(cast6_cbc_dec_8way) +RAP_ENTRY(cast6_cbc_dec_8way) /* input: * %rdi: ctx * %rsi: dst @@ -428,7 +428,7 @@ ENTRY(cast6_cbc_dec_8way) ret; ENDPROC(cast6_cbc_dec_8way) -ENTRY(cast6_ctr_8way) +RAP_ENTRY(cast6_ctr_8way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -456,7 +456,7 @@ ENTRY(cast6_ctr_8way) ret; ENDPROC(cast6_ctr_8way) -ENTRY(cast6_xts_enc_8way) +RAP_ENTRY(cast6_xts_enc_8way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -483,7 +483,7 @@ ENTRY(cast6_xts_enc_8way) ret; ENDPROC(cast6_xts_enc_8way) -ENTRY(cast6_xts_dec_8way) +RAP_ENTRY(cast6_xts_dec_8way) /* input: * %rdi: ctx, CTX * %rsi: dst diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S index 2925077..38c62f8 100644 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S @@ -677,7 +677,7 @@ __serpent_dec_blk8_avx: ret; ENDPROC(__serpent_dec_blk8_avx) -ENTRY(serpent_ecb_enc_8way_avx) +RAP_ENTRY(serpent_ecb_enc_8way_avx) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -695,7 +695,7 @@ ENTRY(serpent_ecb_enc_8way_avx) ret; ENDPROC(serpent_ecb_enc_8way_avx) -ENTRY(serpent_ecb_dec_8way_avx) +RAP_ENTRY(serpent_ecb_dec_8way_avx) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -713,7 +713,7 @@ ENTRY(serpent_ecb_dec_8way_avx) ret; ENDPROC(serpent_ecb_dec_8way_avx) -ENTRY(serpent_cbc_dec_8way_avx) +RAP_ENTRY(serpent_cbc_dec_8way_avx) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -731,7 +731,7 @@ ENTRY(serpent_cbc_dec_8way_avx) ret; ENDPROC(serpent_cbc_dec_8way_avx) -ENTRY(serpent_ctr_8way_avx) +RAP_ENTRY(serpent_ctr_8way_avx) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -751,7 +751,7 @@ ENTRY(serpent_ctr_8way_avx) ret; ENDPROC(serpent_ctr_8way_avx) -ENTRY(serpent_xts_enc_8way_avx) +RAP_ENTRY(serpent_xts_enc_8way_avx) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -773,7 +773,7 @@ ENTRY(serpent_xts_enc_8way_avx) ret; ENDPROC(serpent_xts_enc_8way_avx) -ENTRY(serpent_xts_dec_8way_avx) +RAP_ENTRY(serpent_xts_dec_8way_avx) /* input: * %rdi: ctx, CTX * %rsi: dst diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S index d67888f..1b8c6b4 100644 --- a/arch/x86/crypto/serpent-avx2-asm_64.S +++ b/arch/x86/crypto/serpent-avx2-asm_64.S @@ -673,7 +673,7 @@ __serpent_dec_blk16: ret; ENDPROC(__serpent_dec_blk16) -ENTRY(serpent_ecb_enc_16way) +RAP_ENTRY(serpent_ecb_enc_16way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -695,7 +695,7 @@ ENTRY(serpent_ecb_enc_16way) ret; ENDPROC(serpent_ecb_enc_16way) -ENTRY(serpent_ecb_dec_16way) +RAP_ENTRY(serpent_ecb_dec_16way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -717,7 +717,7 @@ ENTRY(serpent_ecb_dec_16way) ret; ENDPROC(serpent_ecb_dec_16way) -ENTRY(serpent_cbc_dec_16way) +RAP_ENTRY(serpent_cbc_dec_16way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -740,7 +740,7 @@ ENTRY(serpent_cbc_dec_16way) ret; ENDPROC(serpent_cbc_dec_16way) -ENTRY(serpent_ctr_16way) +RAP_ENTRY(serpent_ctr_16way) /* input: * %rdi: ctx, CTX * %rsi: dst (16 blocks) @@ -765,7 +765,7 @@ ENTRY(serpent_ctr_16way) ret; ENDPROC(serpent_ctr_16way) -ENTRY(serpent_xts_enc_16way) +RAP_ENTRY(serpent_xts_enc_16way) /* input: * %rdi: ctx, CTX * %rsi: dst (16 blocks) @@ -791,7 +791,7 @@ ENTRY(serpent_xts_enc_16way) ret; ENDPROC(serpent_xts_enc_16way) -ENTRY(serpent_xts_dec_16way) +RAP_ENTRY(serpent_xts_dec_16way) /* input: * %rdi: ctx, CTX * %rsi: dst (16 blocks) diff --git a/arch/x86/crypto/sha1-mb/sha1_mb_mgr_flush_avx2.S b/arch/x86/crypto/sha1-mb/sha1_mb_mgr_flush_avx2.S index 7cfba73..e077bb6 100644 --- a/arch/x86/crypto/sha1-mb/sha1_mb_mgr_flush_avx2.S +++ b/arch/x86/crypto/sha1-mb/sha1_mb_mgr_flush_avx2.S @@ -103,7 +103,7 @@ offset = \_offset # JOB* sha1_mb_mgr_flush_avx2(MB_MGR *state) # arg 1 : rcx : state -ENTRY(sha1_mb_mgr_flush_avx2) +RAP_ENTRY(sha1_mb_mgr_flush_avx2) FRAME_BEGIN push %rbx @@ -226,7 +226,7 @@ ENDPROC(sha1_mb_mgr_flush_avx2) ################################################################# .align 16 -ENTRY(sha1_mb_mgr_get_comp_job_avx2) +RAP_ENTRY(sha1_mb_mgr_get_comp_job_avx2) push %rbx ## if bit 32+3 is set, then all lanes are empty diff --git a/arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.S b/arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.S index 7a93b1c..7c64e59 100644 --- a/arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.S +++ b/arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.S @@ -98,7 +98,7 @@ lane_data = %r10 # JOB* submit_mb_mgr_submit_avx2(MB_MGR *state, job_sha1 *job) # arg 1 : rcx : state # arg 2 : rdx : job -ENTRY(sha1_mb_mgr_submit_avx2) +RAP_ENTRY(sha1_mb_mgr_submit_avx2) FRAME_BEGIN push %rbx push %r12 diff --git a/arch/x86/crypto/sha1_ssse3_glue.c b/arch/x86/crypto/sha1_ssse3_glue.c index fc61739..03f7efe 100644 --- a/arch/x86/crypto/sha1_ssse3_glue.c +++ b/arch/x86/crypto/sha1_ssse3_glue.c @@ -31,8 +31,8 @@ #include #include -typedef void (sha1_transform_fn)(u32 *digest, const char *data, - unsigned int rounds); +typedef void (sha1_transform_fn)(struct sha1_state *digest, const u8 *data, + int rounds); static int sha1_update(struct shash_desc *desc, const u8 *data, unsigned int len, sha1_transform_fn *sha1_xform) @@ -47,8 +47,7 @@ static int sha1_update(struct shash_desc *desc, const u8 *data, BUILD_BUG_ON(offsetof(struct sha1_state, state) != 0); kernel_fpu_begin(); - sha1_base_do_update(desc, data, len, - (sha1_block_fn *)sha1_xform); + sha1_base_do_update(desc, data, len, sha1_xform); kernel_fpu_end(); return 0; @@ -62,29 +61,26 @@ static int sha1_finup(struct shash_desc *desc, const u8 *data, kernel_fpu_begin(); if (len) - sha1_base_do_update(desc, data, len, - (sha1_block_fn *)sha1_xform); - sha1_base_do_finalize(desc, (sha1_block_fn *)sha1_xform); + sha1_base_do_update(desc, data, len, sha1_xform); + sha1_base_do_finalize(desc, sha1_xform); kernel_fpu_end(); return sha1_base_finish(desc, out); } -asmlinkage void sha1_transform_ssse3(u32 *digest, const char *data, - unsigned int rounds); +asmlinkage void sha1_transform_ssse3(struct sha1_state *digest, const u8 *data, + int rounds); static int sha1_ssse3_update(struct shash_desc *desc, const u8 *data, unsigned int len) { - return sha1_update(desc, data, len, - (sha1_transform_fn *) sha1_transform_ssse3); + return sha1_update(desc, data, len, sha1_transform_ssse3); } static int sha1_ssse3_finup(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out) { - return sha1_finup(desc, data, len, out, - (sha1_transform_fn *) sha1_transform_ssse3); + return sha1_finup(desc, data, len, out, sha1_transform_ssse3); } /* Add padding and return the message digest. */ @@ -124,21 +120,19 @@ static void unregister_sha1_ssse3(void) } #ifdef CONFIG_AS_AVX -asmlinkage void sha1_transform_avx(u32 *digest, const char *data, - unsigned int rounds); +asmlinkage void sha1_transform_avx(struct sha1_state *digest, const u8 *data, + int rounds); static int sha1_avx_update(struct shash_desc *desc, const u8 *data, unsigned int len) { - return sha1_update(desc, data, len, - (sha1_transform_fn *) sha1_transform_avx); + return sha1_update(desc, data, len, sha1_transform_avx); } static int sha1_avx_finup(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out) { - return sha1_finup(desc, data, len, out, - (sha1_transform_fn *) sha1_transform_avx); + return sha1_finup(desc, data, len, out, sha1_transform_avx); } static int sha1_avx_final(struct shash_desc *desc, u8 *out) @@ -196,8 +190,8 @@ static inline void unregister_sha1_avx(void) { } #if defined(CONFIG_AS_AVX2) && (CONFIG_AS_AVX) #define SHA1_AVX2_BLOCK_OPTSIZE 4 /* optimal 4*64 bytes of SHA1 blocks */ -asmlinkage void sha1_transform_avx2(u32 *digest, const char *data, - unsigned int rounds); +asmlinkage void sha1_transform_avx2(struct sha1_state *digest, const u8 *data, + int rounds); static bool avx2_usable(void) { @@ -209,8 +203,8 @@ static bool avx2_usable(void) return false; } -static void sha1_apply_transform_avx2(u32 *digest, const char *data, - unsigned int rounds) +static void sha1_apply_transform_avx2(struct sha1_state *digest, const u8 *data, + int rounds) { /* Select the optimal transform based on data block size */ if (rounds >= SHA1_AVX2_BLOCK_OPTSIZE) @@ -222,15 +216,13 @@ static void sha1_apply_transform_avx2(u32 *digest, const char *data, static int sha1_avx2_update(struct shash_desc *desc, const u8 *data, unsigned int len) { - return sha1_update(desc, data, len, - (sha1_transform_fn *) sha1_apply_transform_avx2); + return sha1_update(desc, data, len, sha1_apply_transform_avx2); } static int sha1_avx2_finup(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out) { - return sha1_finup(desc, data, len, out, - (sha1_transform_fn *) sha1_apply_transform_avx2); + return sha1_finup(desc, data, len, out, sha1_apply_transform_avx2); } static int sha1_avx2_final(struct shash_desc *desc, u8 *out) @@ -274,21 +266,19 @@ static inline void unregister_sha1_avx2(void) { } #endif #ifdef CONFIG_AS_SHA1_NI -asmlinkage void sha1_ni_transform(u32 *digest, const char *data, - unsigned int rounds); +asmlinkage void sha1_ni_transform(struct sha1_state *digest, const u8 *data, + int rounds); static int sha1_ni_update(struct shash_desc *desc, const u8 *data, unsigned int len) { - return sha1_update(desc, data, len, - (sha1_transform_fn *) sha1_ni_transform); + return sha1_update(desc, data, len, sha1_ni_transform); } static int sha1_ni_finup(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out) { - return sha1_finup(desc, data, len, out, - (sha1_transform_fn *) sha1_ni_transform); + return sha1_finup(desc, data, len, out, sha1_ni_transform); } static int sha1_ni_final(struct shash_desc *desc, u8 *out) diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S index 001bbcf..8fa0448 100644 --- a/arch/x86/crypto/sha256-avx-asm.S +++ b/arch/x86/crypto/sha256-avx-asm.S @@ -347,7 +347,7 @@ a = TMP_ ## arg 3 : Num blocks ######################################################################## .text -ENTRY(sha256_transform_avx) +RAP_ENTRY(sha256_transform_avx) .align 32 pushq %rbx pushq %r12 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S index 1420db1..e476cdf 100644 --- a/arch/x86/crypto/sha256-avx2-asm.S +++ b/arch/x86/crypto/sha256-avx2-asm.S @@ -526,7 +526,7 @@ STACK_SIZE = _RSP + _RSP_SIZE ## arg 3 : Num blocks ######################################################################## .text -ENTRY(sha256_transform_rorx) +RAP_ENTRY(sha256_transform_rorx) .align 32 pushq %rbx pushq %r12 diff --git a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S index 16c4ccb..2b5ffce 100644 --- a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S +++ b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S @@ -101,7 +101,7 @@ offset = \_offset # JOB_SHA256* sha256_mb_mgr_flush_avx2(MB_MGR *state) # arg 1 : rcx : state -ENTRY(sha256_mb_mgr_flush_avx2) +RAP_ENTRY(sha256_mb_mgr_flush_avx2) FRAME_BEGIN push %rbx @@ -225,7 +225,7 @@ ENDPROC(sha256_mb_mgr_flush_avx2) ############################################################################## .align 16 -ENTRY(sha256_mb_mgr_get_comp_job_avx2) +RAP_ENTRY(sha256_mb_mgr_get_comp_job_avx2) push %rbx ## if bit 32+3 is set, then all lanes are empty diff --git a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_submit_avx2.S b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_submit_avx2.S index b36ae74..1a0045b 100644 --- a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_submit_avx2.S +++ b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_submit_avx2.S @@ -96,7 +96,7 @@ lane_data = %r10 # JOB* sha256_mb_mgr_submit_avx2(MB_MGR *state, JOB_SHA256 *job) # arg 1 : rcx : state # arg 2 : rdx : job -ENTRY(sha256_mb_mgr_submit_avx2) +RAP_ENTRY(sha256_mb_mgr_submit_avx2) FRAME_BEGIN push %rbx push %r12 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S index c6c05ed..2557f7b 100644 --- a/arch/x86/crypto/sha256-ssse3-asm.S +++ b/arch/x86/crypto/sha256-ssse3-asm.S @@ -353,7 +353,7 @@ a = TMP_ ## arg 3 : Num blocks ######################################################################## .text -ENTRY(sha256_transform_ssse3) +RAP_ENTRY(sha256_transform_ssse3) .align 32 pushq %rbx pushq %r12 diff --git a/arch/x86/crypto/sha256_ni_asm.S b/arch/x86/crypto/sha256_ni_asm.S index fb58f58..cf67f33 100644 --- a/arch/x86/crypto/sha256_ni_asm.S +++ b/arch/x86/crypto/sha256_ni_asm.S @@ -97,7 +97,7 @@ .text .align 32 -ENTRY(sha256_ni_transform) +RAP_ENTRY(sha256_ni_transform) shl $6, NUM_BLKS /* convert to bytes */ jz .Ldone_hash diff --git a/arch/x86/crypto/sha256_ssse3_glue.c b/arch/x86/crypto/sha256_ssse3_glue.c index 9e79baf..c5186c74 100644 --- a/arch/x86/crypto/sha256_ssse3_glue.c +++ b/arch/x86/crypto/sha256_ssse3_glue.c @@ -40,9 +40,9 @@ #include #include -asmlinkage void sha256_transform_ssse3(u32 *digest, const char *data, - u64 rounds); -typedef void (sha256_transform_fn)(u32 *digest, const char *data, u64 rounds); +asmlinkage void sha256_transform_ssse3(struct sha256_state *digest, const u8 *data, + int rounds); +typedef void (sha256_transform_fn)(struct sha256_state *digest, const u8 *data, int rounds); static int sha256_update(struct shash_desc *desc, const u8 *data, unsigned int len, sha256_transform_fn *sha256_xform) @@ -57,8 +57,7 @@ static int sha256_update(struct shash_desc *desc, const u8 *data, BUILD_BUG_ON(offsetof(struct sha256_state, state) != 0); kernel_fpu_begin(); - sha256_base_do_update(desc, data, len, - (sha256_block_fn *)sha256_xform); + sha256_base_do_update(desc, data, len, sha256_xform); kernel_fpu_end(); return 0; @@ -72,9 +71,8 @@ static int sha256_finup(struct shash_desc *desc, const u8 *data, kernel_fpu_begin(); if (len) - sha256_base_do_update(desc, data, len, - (sha256_block_fn *)sha256_xform); - sha256_base_do_finalize(desc, (sha256_block_fn *)sha256_xform); + sha256_base_do_update(desc, data, len, sha256_xform); + sha256_base_do_finalize(desc, sha256_xform); kernel_fpu_end(); return sha256_base_finish(desc, out); @@ -146,8 +144,8 @@ static void unregister_sha256_ssse3(void) } #ifdef CONFIG_AS_AVX -asmlinkage void sha256_transform_avx(u32 *digest, const char *data, - u64 rounds); +asmlinkage void sha256_transform_avx(struct sha256_state *digest, const u8 *data, + int rounds); static int sha256_avx_update(struct shash_desc *desc, const u8 *data, unsigned int len) @@ -230,8 +228,8 @@ static inline void unregister_sha256_avx(void) { } #endif #if defined(CONFIG_AS_AVX2) && defined(CONFIG_AS_AVX) -asmlinkage void sha256_transform_rorx(u32 *digest, const char *data, - u64 rounds); +asmlinkage void sha256_transform_rorx(struct sha256_state *digest, const u8 *data, + int rounds); static int sha256_avx2_update(struct shash_desc *desc, const u8 *data, unsigned int len) @@ -312,8 +310,8 @@ static inline void unregister_sha256_avx2(void) { } #endif #ifdef CONFIG_AS_SHA256_NI -asmlinkage void sha256_ni_transform(u32 *digest, const char *data, - u64 rounds); /*unsigned int rounds);*/ +asmlinkage void sha256_ni_transform(struct sha256_state *digest, const u8 *data, + int rounds); /*unsigned int rounds);*/ static int sha256_ni_update(struct shash_desc *desc, const u8 *data, unsigned int len) diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S index 39235fe..7e51f52 100644 --- a/arch/x86/crypto/sha512-avx-asm.S +++ b/arch/x86/crypto/sha512-avx-asm.S @@ -277,7 +277,7 @@ frame_size = frame_GPRSAVE + GPRSAVE_SIZE # message blocks. # L is the message length in SHA512 blocks ######################################################################## -ENTRY(sha512_transform_avx) +RAP_ENTRY(sha512_transform_avx) cmp $0, msglen je nowork diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S index b16d560..dbfb27b 100644 --- a/arch/x86/crypto/sha512-avx2-asm.S +++ b/arch/x86/crypto/sha512-avx2-asm.S @@ -569,7 +569,7 @@ frame_size = frame_GPRSAVE + GPRSAVE_SIZE # message blocks. # L is the message length in SHA512 blocks ######################################################################## -ENTRY(sha512_transform_rorx) +RAP_ENTRY(sha512_transform_rorx) # Allocate Stack Space mov %rsp, %rax sub $frame_size, %rsp diff --git a/arch/x86/crypto/sha512-mb/sha512_mb_mgr_flush_avx2.S b/arch/x86/crypto/sha512-mb/sha512_mb_mgr_flush_avx2.S index 7c629ca..ebf3d77 100644 --- a/arch/x86/crypto/sha512-mb/sha512_mb_mgr_flush_avx2.S +++ b/arch/x86/crypto/sha512-mb/sha512_mb_mgr_flush_avx2.S @@ -107,7 +107,7 @@ offset = \_offset # JOB* sha512_mb_mgr_flush_avx2(MB_MGR *state) # arg 1 : rcx : state -ENTRY(sha512_mb_mgr_flush_avx2) +RAP_ENTRY(sha512_mb_mgr_flush_avx2) FRAME_BEGIN push %rbx @@ -220,7 +220,7 @@ return_null: ENDPROC(sha512_mb_mgr_flush_avx2) .align 16 -ENTRY(sha512_mb_mgr_get_comp_job_avx2) +RAP_ENTRY(sha512_mb_mgr_get_comp_job_avx2) push %rbx mov _unused_lanes(state), unused_lanes diff --git a/arch/x86/crypto/sha512-mb/sha512_mb_mgr_submit_avx2.S b/arch/x86/crypto/sha512-mb/sha512_mb_mgr_submit_avx2.S index 4ba709b..8730bfd 100644 --- a/arch/x86/crypto/sha512-mb/sha512_mb_mgr_submit_avx2.S +++ b/arch/x86/crypto/sha512-mb/sha512_mb_mgr_submit_avx2.S @@ -98,7 +98,7 @@ # JOB* sha512_mb_mgr_submit_avx2(MB_MGR *state, JOB *job) # arg 1 : rcx : state # arg 2 : rdx : job -ENTRY(sha512_mb_mgr_submit_avx2) +RAP_ENTRY(sha512_mb_mgr_submit_avx2) FRAME_BEGIN push %rbx push %r12 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S index 66bbd90..4d2e909 100644 --- a/arch/x86/crypto/sha512-ssse3-asm.S +++ b/arch/x86/crypto/sha512-ssse3-asm.S @@ -275,7 +275,7 @@ frame_size = frame_GPRSAVE + GPRSAVE_SIZE # message blocks. # L is the message length in SHA512 blocks. ######################################################################## -ENTRY(sha512_transform_ssse3) +RAP_ENTRY(sha512_transform_ssse3) cmp $0, msglen je nowork diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S index 73b471d..eb9ca63 100644 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S @@ -330,7 +330,7 @@ __twofish_dec_blk8: ret; ENDPROC(__twofish_dec_blk8) -ENTRY(twofish_ecb_enc_8way) +RAP_ENTRY(twofish_ecb_enc_8way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -350,7 +350,7 @@ ENTRY(twofish_ecb_enc_8way) ret; ENDPROC(twofish_ecb_enc_8way) -ENTRY(twofish_ecb_dec_8way) +RAP_ENTRY(twofish_ecb_dec_8way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -370,7 +370,7 @@ ENTRY(twofish_ecb_dec_8way) ret; ENDPROC(twofish_ecb_dec_8way) -ENTRY(twofish_cbc_dec_8way) +RAP_ENTRY(twofish_cbc_dec_8way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -395,7 +395,7 @@ ENTRY(twofish_cbc_dec_8way) ret; ENDPROC(twofish_cbc_dec_8way) -ENTRY(twofish_ctr_8way) +RAP_ENTRY(twofish_ctr_8way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -422,7 +422,7 @@ ENTRY(twofish_ctr_8way) ret; ENDPROC(twofish_ctr_8way) -ENTRY(twofish_xts_enc_8way) +RAP_ENTRY(twofish_xts_enc_8way) /* input: * %rdi: ctx, CTX * %rsi: dst @@ -446,7 +446,7 @@ ENTRY(twofish_xts_enc_8way) ret; ENDPROC(twofish_xts_enc_8way) -ENTRY(twofish_xts_dec_8way) +RAP_ENTRY(twofish_xts_dec_8way) /* input: * %rdi: ctx, CTX * %rsi: dst diff --git a/arch/x86/crypto/twofish-i586-asm_32.S b/arch/x86/crypto/twofish-i586-asm_32.S index 694ea45..f2c1418 100644 --- a/arch/x86/crypto/twofish-i586-asm_32.S +++ b/arch/x86/crypto/twofish-i586-asm_32.S @@ -220,7 +220,7 @@ xor %esi, d ## D;\ ror $1, d ## D; -ENTRY(twofish_enc_blk) +RAP_ENTRY(twofish_enc_blk) push %ebp /* save registers according to calling convention*/ push %ebx push %esi @@ -276,7 +276,7 @@ ENTRY(twofish_enc_blk) ret ENDPROC(twofish_enc_blk) -ENTRY(twofish_dec_blk) +RAP_ENTRY(twofish_dec_blk) push %ebp /* save registers according to calling convention*/ push %ebx push %esi diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S index e7273a6..dd44bac 100644 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S @@ -284,7 +284,7 @@ ENTRY(__twofish_enc_blk_3way) ret; ENDPROC(__twofish_enc_blk_3way) -ENTRY(twofish_dec_blk_3way) +RAP_ENTRY(twofish_dec_blk_3way) /* input: * %rdi: ctx, CTX * %rsi: dst diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S index a350c99..32a5e60 100644 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S @@ -215,7 +215,7 @@ xor %r8d, d ## D;\ ror $1, d ## D; -ENTRY(twofish_enc_blk) +RAP_ENTRY(twofish_enc_blk) pushq R1 /* %rdi contains the ctx address */ @@ -268,7 +268,7 @@ ENTRY(twofish_enc_blk) ret ENDPROC(twofish_enc_blk) -ENTRY(twofish_dec_blk) +RAP_ENTRY(twofish_dec_blk) pushq R1 /* %rdi contains the ctx address */ diff --git a/arch/x86/entry/Makefile b/arch/x86/entry/Makefile index 06fc70c..03f4755 100644 --- a/arch/x86/entry/Makefile +++ b/arch/x86/entry/Makefile @@ -15,3 +15,5 @@ obj-y += vsyscall/ obj-$(CONFIG_IA32_EMULATION) += entry_64_compat.o syscall_32.o +CFLAGS_REMOVE_syscall_32.o = $(RAP_PLUGIN_ABS_CFLAGS) +CFLAGS_REMOVE_syscall_64.o = $(RAP_PLUGIN_ABS_CFLAGS) diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 60e21cc..0d2d08f 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -285,10 +285,30 @@ __visible void do_syscall_64(struct pt_regs *regs) * regs->orig_ax, which changes the behavior of some syscalls. */ if (likely((nr & __SYSCALL_MASK) < NR_syscalls)) { +#ifdef CONFIG_PAX_RAP + asm volatile("movq %[param1],%%rdi\n\t" + "movq %[param2],%%rsi\n\t" + "movq %[param3],%%rdx\n\t" + "movq %[param4],%%rcx\n\t" + "movq %[param5],%%r8\n\t" + "movq %[param6],%%r9\n\t" + "call *%P[syscall]\n\t" + "mov %%rax,%[result]\n\t" + : [result] "=m" (regs->ax) + : [syscall] "m" (sys_call_table[nr & __SYSCALL_MASK]), + [param1] "m" (regs->di), + [param2] "m" (regs->si), + [param3] "m" (regs->dx), + [param4] "m" (regs->r10), + [param5] "m" (regs->r8), + [param6] "m" (regs->r9) + : "ax", "di", "si", "dx", "cx", "r8", "r9", "r10", "r11", "memory"); +#else nr = array_index_nospec(nr & __SYSCALL_MASK, NR_syscalls); regs->ax = sys_call_table[nr]( regs->di, regs->si, regs->dx, regs->r10, regs->r8, regs->r9); +#endif } syscall_return_slowpath(regs); @@ -329,10 +349,51 @@ static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs) * the high bits are zero. Make sure we zero-extend all * of the args. */ +#ifdef CONFIG_PAX_RAP +#ifdef CONFIG_X86_64 + asm volatile("movl %[param1],%%edi\n\t" + "movl %[param2],%%esi\n\t" + "movl %[param3],%%edx\n\t" + "movl %[param4],%%ecx\n\t" + "movl %[param5],%%r8d\n\t" + "movl %[param6],%%r9d\n\t" + "call *%P[syscall]\n\t" + "mov %%rax,%[result]\n\t" + : [result] "=m" (regs->ax) + : [syscall] "m" (ia32_sys_call_table[nr]), + [param1] "m" (regs->bx), + [param2] "m" (regs->cx), + [param3] "m" (regs->dx), + [param4] "m" (regs->si), + [param5] "m" (regs->di), + [param6] "m" (regs->bp) + : "ax", "di", "si", "dx", "cx", "r8", "r9", "r10", "r11", "memory"); +#else + asm volatile("pushl %[param6]\n\t" + "pushl %[param5]\n\t" + "pushl %[param4]\n\t" + "pushl %[param3]\n\t" + "pushl %[param2]\n\t" + "pushl %[param1]\n\t" + "call *%P[syscall]\n\t" + "addl $6*8,%%esp\n\t" + "mov %%eax,%[result]\n\t" + : [result] "=m" (regs->ax) + : [syscall] "m" (ia32_sys_call_table[nr]), + [param1] "m" (regs->bx), + [param2] "m" (regs->cx), + [param3] "m" (regs->dx), + [param4] "m" (regs->si), + [param5] "m" (regs->di), + [param6] "m" (regs->bp) + : "ax", "dx", "cx", "memory"); +#endif +#else regs->ax = ia32_sys_call_table[nr]( (unsigned int)regs->bx, (unsigned int)regs->cx, (unsigned int)regs->dx, (unsigned int)regs->si, (unsigned int)regs->di, (unsigned int)regs->bp); +#endif } syscall_return_slowpath(regs); diff --git a/arch/x86/events/amd/iommu.h b/arch/x86/events/amd/iommu.h index 62e0702..bc87ec5 100644 --- a/arch/x86/events/amd/iommu.h +++ b/arch/x86/events/amd/iommu.h @@ -41,6 +41,6 @@ extern int amd_iommu_pc_set_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, extern int amd_iommu_pc_get_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn, u64 *value); -extern struct amd_iommu *get_amd_iommu(int idx); +extern struct amd_iommu *get_amd_iommu(unsigned int idx); #endif /*_PERF_EVENT_AMD_IOMMU_H_*/ diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h index 62be73b..4133797 100644 --- a/arch/x86/include/asm/e820/api.h +++ b/arch/x86/include/asm/e820/api.h @@ -11,7 +11,7 @@ extern struct e820_table *e820_table_firmware; extern unsigned long pci_mem_start; extern bool e820__mapped_any(u64 start, u64 end, enum e820_type type); -extern bool e820__mapped_all(u64 start, u64 end, enum e820_type type); +extern bool e820__mapped_all(u64 start, u64 end, unsigned type); extern void e820__range_add (u64 start, u64 size, enum e820_type type); extern u64 e820__range_update(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type); diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index e203169..0ef405e 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h @@ -149,7 +149,7 @@ extern pte_t *kmap_pte; extern pte_t *pkmap_page_table; void __native_set_fixmap(enum fixed_addresses idx, pte_t pte); -void native_set_fixmap(enum fixed_addresses idx, +void native_set_fixmap(unsigned int idx, phys_addr_t phys, pgprot_t flags); #ifndef CONFIG_PARAVIRT diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h index 7948a17..bc2b010 100644 --- a/arch/x86/include/asm/module.h +++ b/arch/x86/include/asm/module.h @@ -15,6 +15,7 @@ struct mod_arch_specific { #ifdef CONFIG_X86_64 /* X86_64 does not define MODULE_PROC_FAMILY */ +#define MODULE_PROC_FAMILY "" #elif defined CONFIG_M486 #define MODULE_PROC_FAMILY "486 " #elif defined CONFIG_M586 @@ -67,8 +68,12 @@ struct mod_arch_specific { #error unknown processor family #endif -#ifdef CONFIG_X86_32 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY +#ifdef CONFIG_PAX_RAP +#define MODULE_PAX_RAP "RAP " +#else +#define MODULE_PAX_RAP "" #endif +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_RAP + #endif /* _ASM_X86_MODULE_H */ diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index e05babd..da8005e 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -262,11 +262,17 @@ static __init int activate_jump_labels(void) } arch_initcall(activate_jump_labels); +/* + * No need for any "IO delay" on VMware hypervisor + */ +static void vmware_io_delay(void) +{ +} static void __init vmware_paravirt_ops_setup(void) { pv_info.name = "VMware hypervisor"; - pv_cpu_ops.io_delay = paravirt_nop; + pv_cpu_ops.io_delay = vmware_io_delay; if (vmware_tsc_khz == 0) return; diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 71c11ad..35d8c4d 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -132,7 +132,7 @@ static struct e820_entry *__e820__mapped_all(u64 start, u64 end, /* * This function checks if the entire range is mapped with type. */ -bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type) +bool __init e820__mapped_all(u64 start, u64 end, unsigned type) { return __e820__mapped_all(start, end, type); } diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S index 7cb8ba0..fd9df42 100644 --- a/arch/x86/kernel/ftrace_64.S +++ b/arch/x86/kernel/ftrace_64.S @@ -182,7 +182,7 @@ GLOBAL(ftrace_graph_call) #endif /* This is weak to keep gas from relaxing the jumps */ -WEAK(ftrace_stub) +RAP_WEAK(ftrace_stub) retq END(ftrace_caller) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index a66428dc..bed821f 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -210,6 +210,10 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str, tsk->thread.error_code = error_code; tsk->thread.trap_nr = trapnr; +#ifdef CONFIG_PAX_RAP + if (trapnr == X86_TRAP_UD) + str = "PAX: overwritten function pointer or return address detected"; +#endif die(str, regs, error_code); } diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 004abf9..9db5ce3 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -580,7 +580,7 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte) fixmaps_set++; } -void native_set_fixmap(enum fixed_addresses idx, phys_addr_t phys, +void native_set_fixmap(unsigned int idx, phys_addr_t phys, pgprot_t flags) { __native_set_fixmap(idx, pfn_pte(phys >> PAGE_SHIFT, flags)); diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c index abff76b..a7a7677 100644 --- a/arch/x86/oprofile/nmi_int.c +++ b/arch/x86/oprofile/nmi_int.c @@ -592,7 +592,7 @@ enum __force_cpu_type { static int force_cpu_type; -static int set_cpu_type(const char *str, struct kernel_param *kp) +static int set_cpu_type(const char *str, const struct kernel_param *kp) { if (!strcmp(str, "timer")) { force_cpu_type = timer; diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S index 8019edd..1ce2907 100644 --- a/arch/x86/xen/xen-asm.S +++ b/arch/x86/xen/xen-asm.S @@ -18,7 +18,7 @@ * event status with one and operation. If there are pending events, * then enter the hypervisor to get them handled. */ -ENTRY(xen_irq_enable_direct) +RAP_ENTRY(xen_irq_enable_direct) FRAME_BEGIN /* Unmask events */ movb $0, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask @@ -44,7 +44,7 @@ ENTRY(xen_irq_enable_direct) * Disabling events is simply a matter of making the event mask * non-zero. */ -ENTRY(xen_irq_disable_direct) +RAP_ENTRY(xen_irq_disable_direct) movb $1, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask ret ENDPROC(xen_irq_disable_direct) @@ -58,7 +58,7 @@ ENDPROC(xen_irq_disable_direct) * undefined. We need to toggle the state of the bit, because Xen and * x86 use opposite senses (mask vs enable). */ -ENTRY(xen_save_fl_direct) +RAP_ENTRY(xen_save_fl_direct) testb $0xff, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask setz %ah addb %ah, %ah @@ -73,7 +73,7 @@ ENTRY(xen_save_fl_direct) * interrupt mask state, it checks for unmasked pending events and * enters the hypervisor to get them delivered if so. */ -ENTRY(xen_restore_fl_direct) +RAP_ENTRY(xen_restore_fl_direct) FRAME_BEGIN #ifdef CONFIG_X86_64 testw $X86_EFLAGS_IF, %di diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index ef1856b..efcd68a 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -557,7 +557,7 @@ static int acpi_button_remove(struct acpi_device *device) return 0; } -static int param_set_lid_init_state(const char *val, struct kernel_param *kp) +static int param_set_lid_init_state(const char *val, const struct kernel_param *kp) { int result = 0; @@ -575,7 +575,7 @@ static int param_set_lid_init_state(const char *val, struct kernel_param *kp) return result; } -static int param_get_lid_init_state(char *buffer, struct kernel_param *kp) +static int param_get_lid_init_state(char *buffer, const struct kernel_param *kp) { switch (lid_init_state) { case ACPI_BUTTON_LID_INIT_OPEN: diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index df84246..2c4c0e9 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1956,7 +1956,7 @@ static const struct dev_pm_ops acpi_ec_pm = { SET_SYSTEM_SLEEP_PM_OPS(acpi_ec_suspend, acpi_ec_resume) }; -static int param_set_event_clearing(const char *val, struct kernel_param *kp) +static int param_set_event_clearing(const char *val, const struct kernel_param *kp) { int result = 0; @@ -1974,7 +1974,7 @@ static int param_set_event_clearing(const char *val, struct kernel_param *kp) return result; } -static int param_get_event_clearing(char *buffer, struct kernel_param *kp) +static int param_get_event_clearing(char *buffer, const struct kernel_param *kp) { switch (ec_event_clearing) { case ACPI_EC_EVT_TIMING_STATUS: diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 0fd57bf..4307ad7 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -230,7 +230,7 @@ module_param_cb(trace_method_name, ¶m_ops_trace_method, &trace_method_name, module_param_cb(trace_debug_layer, ¶m_ops_trace_attrib, &acpi_gbl_trace_dbg_layer, 0644); module_param_cb(trace_debug_level, ¶m_ops_trace_attrib, &acpi_gbl_trace_dbg_level, 0644); -static int param_set_trace_state(const char *val, struct kernel_param *kp) +static int param_set_trace_state(const char *val, const struct kernel_param *kp) { acpi_status status; const char *method = trace_method_name; @@ -266,7 +266,7 @@ static int param_set_trace_state(const char *val, struct kernel_param *kp) return 0; } -static int param_get_trace_state(char *buffer, struct kernel_param *kp) +static int param_get_trace_state(char *buffer, const struct kernel_param *kp) { if (!(acpi_gbl_trace_flags & ACPI_TRACE_ENABLED)) return sprintf(buffer, "disable"); @@ -295,7 +295,7 @@ MODULE_PARM_DESC(aml_debug_output, "To enable/disable the ACPI Debug Object output."); /* /sys/module/acpi/parameters/acpica_version */ -static int param_get_acpica_version(char *buffer, struct kernel_param *kp) +static int param_get_acpica_version(char *buffer, const struct kernel_param *kp) { int result; diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c index 9f2e3be..676c910 100644 --- a/drivers/char/ipmi/ipmi_poweroff.c +++ b/drivers/char/ipmi/ipmi_poweroff.c @@ -66,7 +66,7 @@ static void (*specific_poweroff_func)(ipmi_user_t user); /* Holds the old poweroff function so we can restore it on removal. */ static void (*old_poweroff_func)(void); -static int set_param_ifnum(const char *val, struct kernel_param *kp) +static int set_param_ifnum(const char *val, const struct kernel_param *kp) { int rv = param_set_int(val, kp); if (rv) diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index c04aa11..9abc067 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -1345,7 +1345,7 @@ static unsigned int num_slave_addrs; #define IPMI_MEM_ADDR_SPACE 1 static const char * const addr_space_to_str[] = { "i/o", "mem" }; -static int hotmod_handler(const char *val, struct kernel_param *kp); +static int hotmod_handler(const char *val, const struct kernel_param *kp); module_param_call(hotmod, hotmod_handler, NULL, NULL, 0200); MODULE_PARM_DESC(hotmod, "Add and remove interfaces. See" @@ -1811,7 +1811,7 @@ static struct smi_info *smi_info_alloc(void) return info; } -static int hotmod_handler(const char *val, struct kernel_param *kp) +static int hotmod_handler(const char *val, const struct kernel_param *kp) { char *str = kstrdup(val, GFP_KERNEL); int rv; diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 0eca20c..32a2682 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -267,6 +267,11 @@ struct tpm_chip *tpm_chip_alloc(struct device *pdev, } EXPORT_SYMBOL_GPL(tpm_chip_alloc); +static void tpm_put_device(void *dev) +{ + put_device(dev); +} + /** * tpmm_chip_alloc() - allocate a new struct tpm_chip instance * @pdev: parent device to which the chip is associated @@ -284,9 +289,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *pdev, if (IS_ERR(chip)) return chip; - rc = devm_add_action_or_reset(pdev, - (void (*)(void *)) put_device, - &chip->dev); + rc = devm_add_action_or_reset(pdev, tpm_put_device, &chip->dev); if (rc) return ERR_PTR(rc); diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index e4fcfa8..c70ea82 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c @@ -50,7 +50,7 @@ int edac_mc_get_poll_msec(void) return edac_mc_poll_msec; } -static int edac_set_poll_msec(const char *val, struct kernel_param *kp) +static int edac_set_poll_msec(const char *val, const struct kernel_param *kp) { unsigned long l; int ret; diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c index 951b6c7..13563a9 100644 --- a/drivers/firmware/dmi-id.c +++ b/drivers/firmware/dmi-id.c @@ -160,9 +160,14 @@ static int dmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env) return 0; } +static void dmi_dev_release(struct device *dev) +{ + kfree(dev); +} + static struct class dmi_class = { .name = "dmi", - .dev_release = (void(*)(struct device *)) kfree, + .dev_release = dmi_dev_release, .dev_uevent = dmi_dev_uevent, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c index 7deb81b..bb22bc2 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c @@ -154,11 +154,16 @@ shadow_fw_init(struct nvkm_bios *bios, const char *name) return (void *)fw; } +static void shadow_fw_fini(void *fw) +{ + release_firmware(fw); +} + static const struct nvbios_source shadow_fw = { .name = "firmware", .init = shadow_fw_init, - .fini = (void(*)(void *))release_firmware, + .fini = shadow_fw_fini, .read = shadow_fw_read, .rw = false, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c index 9b91da0..b3fa90d 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c @@ -111,11 +111,16 @@ platform_init(struct nvkm_bios *bios, const char *name) return ERR_PTR(ret); } +static void platform_fini(void *data) +{ + kfree(data); +} + const struct nvbios_source nvbios_platform = { .name = "PLATFORM", .init = platform_init, - .fini = (void(*)(void *))kfree, + .fini = platform_fini, .read = pcirom_read, .rw = true, }; diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index dfee8f7..48706e6 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c @@ -841,7 +841,7 @@ u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe) * Enable the interrupt on the requested crtc (all asics). * Returns 0 on success, -EINVAL on failure. */ -int radeon_enable_vblank_kms(struct drm_device *dev, int crtc) +int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int crtc) { struct radeon_device *rdev = dev->dev_private; unsigned long irqflags; @@ -867,7 +867,7 @@ int radeon_enable_vblank_kms(struct drm_device *dev, int crtc) * * Disable the interrupt on the requested crtc (all asics). */ -void radeon_disable_vblank_kms(struct drm_device *dev, int crtc) +void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int crtc) { struct radeon_device *rdev = dev->dev_private; unsigned long irqflags; diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index 20b40ad..7eb5632 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -34,7 +34,7 @@ module_param(emulate_scroll_wheel, bool, 0644); MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel"); static unsigned int scroll_speed = 32; -static int param_set_scroll_speed(const char *val, struct kernel_param *kp) { +static int param_set_scroll_speed(const char *val, const struct kernel_param *kp) { unsigned long speed; if (!val || kstrtoul(val, 0, &speed) || speed > 63) return -EINVAL; diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index d127ace..6ee866f 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -244,7 +244,7 @@ struct chs_geom { static unsigned int ide_disks; static struct chs_geom ide_disks_chs[MAX_HWIFS * MAX_DRIVES]; -static int ide_set_disk_chs(const char *str, struct kernel_param *kp) +static int ide_set_disk_chs(const char *str, const struct kernel_param *kp) { unsigned int a, b, c = 0, h = 0, s = 0, i, j = 1; @@ -328,7 +328,7 @@ static void ide_dev_apply_params(ide_drive_t *drive, u8 unit) static unsigned int ide_ignore_cable; -static int ide_set_ignore_cable(const char *s, struct kernel_param *kp) +static int ide_set_ignore_cable(const char *s, const struct kernel_param *kp) { int i, j = 1; diff --git a/drivers/md/md.c b/drivers/md/md.c index e058c20..7671b14 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5357,7 +5357,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) return NULL; } -static int add_named_array(const char *val, struct kernel_param *kp) +static int add_named_array(const char *val, const struct kernel_param *kp) { /* * val must be "md_*" or "mdNNN". @@ -9278,11 +9278,11 @@ static __exit void md_exit(void) subsys_initcall(md_init); module_exit(md_exit) -static int get_ro(char *buffer, struct kernel_param *kp) +static int get_ro(char *buffer, const struct kernel_param *kp) { return sprintf(buffer, "%d", start_readonly); } -static int set_ro(const char *val, struct kernel_param *kp) +static int set_ro(const char *val, const struct kernel_param *kp) { return kstrtouint(val, 10, (unsigned int *)&start_readonly); } diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 6d22b22..28b91b7 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2230,7 +2230,7 @@ static int uvc_reset_resume(struct usb_interface *intf) * Module parameters */ -static int uvc_clock_param_get(char *buffer, struct kernel_param *kp) +static int uvc_clock_param_get(char *buffer, const struct kernel_param *kp) { if (uvc_clock_param == CLOCK_MONOTONIC) return sprintf(buffer, "CLOCK_MONOTONIC"); @@ -2238,7 +2238,7 @@ static int uvc_clock_param_get(char *buffer, struct kernel_param *kp) return sprintf(buffer, "CLOCK_REALTIME"); } -static int uvc_clock_param_set(const char *val, struct kernel_param *kp) +static int uvc_clock_param_set(const char *val, const struct kernel_param *kp) { if (strncasecmp(val, "clock_", strlen("clock_")) == 0) val += strlen("clock_"); diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 84eab28..7a93400 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -99,7 +99,7 @@ module_param(mpt_channel_mapping, int, 0); MODULE_PARM_DESC(mpt_channel_mapping, " Mapping id's to channels (default=0)"); static int mpt_debug_level; -static int mpt_set_debug_level(const char *val, struct kernel_param *kp); +static int mpt_set_debug_level(const char *val, const struct kernel_param *kp); module_param_call(mpt_debug_level, mpt_set_debug_level, param_get_int, &mpt_debug_level, 0600); MODULE_PARM_DESC(mpt_debug_level, @@ -242,7 +242,7 @@ pci_enable_io_access(struct pci_dev *pdev) pci_write_config_word(pdev, PCI_COMMAND, command_reg); } -static int mpt_set_debug_level(const char *val, struct kernel_param *kp) +static int mpt_set_debug_level(const char *val, const struct kernel_param *kp) { int ret = param_set_int(val, kp); MPT_ADAPTER *ioc; diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c index fc7efed..f356053 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c @@ -1132,7 +1132,7 @@ static void kgdbts_put_char(u8 chr) ts.run_test(0, chr); } -static int param_set_kgdbts_var(const char *kmessage, struct kernel_param *kp) +static int param_set_kgdbts_var(const char *kmessage, const struct kernel_param *kp) { int len = strlen(kmessage); diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 7c887f1..62fd690 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -431,7 +431,7 @@ static int block2mtd_setup2(const char *val) } -static int block2mtd_setup(const char *val, struct kernel_param *kp) +static int block2mtd_setup(const char *val, const struct kernel_param *kp) { #ifdef MODULE return block2mtd_setup2(val); diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 8b66e52..7287696 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c @@ -266,7 +266,7 @@ static int phram_setup(const char *val) return ret; } -static int phram_param_call(const char *val, struct kernel_param *kp) +static int phram_param_call(const char *val, const struct kernel_param *kp) { #ifdef MODULE return phram_setup(val); diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 842550b..136ce05 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -1334,7 +1334,7 @@ static int bytes_str_to_int(const char *str) * This function returns zero in case of success and a negative error code in * case of error. */ -static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp) +static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp) { int i, len; struct mtd_dev_param *p; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c index 7dd83d0..fbae662 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c @@ -5615,7 +5615,7 @@ static int bnx2x_get_link_speed_duplex(struct bnx2x_phy *phy, return 0; } -static int bnx2x_link_settings_status(struct bnx2x_phy *phy, +static u8 bnx2x_link_settings_status(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -5689,7 +5689,7 @@ static int bnx2x_link_settings_status(struct bnx2x_phy *phy, return rc; } -static int bnx2x_warpcore_read_status(struct bnx2x_phy *phy, +static u8 bnx2x_warpcore_read_status(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -7367,7 +7367,7 @@ static void bnx2x_8073_specific_func(struct bnx2x_phy *phy, } } -static int bnx2x_8073_config_init(struct bnx2x_phy *phy, +static void bnx2x_8073_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -7430,7 +7430,7 @@ static int bnx2x_8073_config_init(struct bnx2x_phy *phy, if (params->loopback_mode == LOOPBACK_EXT) { bnx2x_807x_force_10G(bp, phy); DP(NETIF_MSG_LINK, "Forced speed 10G on 807X\n"); - return 0; + return; } else { bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0002); @@ -7512,7 +7512,6 @@ static int bnx2x_8073_config_init(struct bnx2x_phy *phy, bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); DP(NETIF_MSG_LINK, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n", ((val & (1<<5)) > 0), ((val & (1<<7)) > 0)); - return 0; } static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy, @@ -7679,7 +7678,7 @@ static void bnx2x_8073_link_reset(struct bnx2x_phy *phy, /******************************************************************/ /* BCM8705 PHY SECTION */ /******************************************************************/ -static int bnx2x_8705_config_init(struct bnx2x_phy *phy, +static void bnx2x_8705_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -7703,7 +7702,6 @@ static int bnx2x_8705_config_init(struct bnx2x_phy *phy, MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_CNTL, 0x1); /* BCM8705 doesn't have microcode, hence the 0 */ bnx2x_save_spirom_version(bp, params->port, params->shmem_base, 0); - return 0; } static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy, @@ -8890,7 +8888,7 @@ static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy, /******************************************************************/ /* BCM8706 PHY SECTION */ /******************************************************************/ -static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy, +static void bnx2x_8706_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -8992,11 +8990,9 @@ static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy, bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, tmp1); } - - return 0; } -static int bnx2x_8706_read_status(struct bnx2x_phy *phy, +static u8 bnx2x_8706_read_status(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -9073,7 +9069,7 @@ static u8 bnx2x_8726_read_status(struct bnx2x_phy *phy, } -static int bnx2x_8726_config_init(struct bnx2x_phy *phy, +static void bnx2x_8726_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -9154,8 +9150,6 @@ static int bnx2x_8726_config_init(struct bnx2x_phy *phy, phy->tx_preemphasis[1]); } - return 0; - } static void bnx2x_8726_link_reset(struct bnx2x_phy *phy, @@ -9291,7 +9285,7 @@ static void bnx2x_8727_config_speed(struct bnx2x_phy *phy, } } -static int bnx2x_8727_config_init(struct bnx2x_phy *phy, +static void bnx2x_8727_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -9373,8 +9367,6 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, (tmp2 & 0x7fff)); } - - return 0; } static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy *phy, @@ -9949,7 +9941,7 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, return 0; } -static int bnx2x_8481_config_init(struct bnx2x_phy *phy, +static void bnx2x_8481_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -9963,7 +9955,7 @@ static int bnx2x_8481_config_init(struct bnx2x_phy *phy, bnx2x_wait_reset_complete(bp, phy, params); bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); - return bnx2x_848xx_cmn_config_init(phy, params, vars); + bnx2x_848xx_cmn_config_init(phy, params, vars); } #define PHY848xx_CMDHDLR_WAIT 300 @@ -10213,7 +10205,7 @@ static u8 bnx2x_84833_get_reset_gpios(struct bnx2x *bp, return reset_gpios; } -static int bnx2x_84833_hw_reset_phy(struct bnx2x_phy *phy, +static void bnx2x_84833_hw_reset_phy(struct bnx2x_phy *phy, struct link_params *params) { struct bnx2x *bp = params->bp; @@ -10242,8 +10234,6 @@ static int bnx2x_84833_hw_reset_phy(struct bnx2x_phy *phy, udelay(10); DP(NETIF_MSG_LINK, "84833 hw reset on pin values 0x%x\n", reset_gpios); - - return 0; } static int bnx2x_8483x_disable_eee(struct bnx2x_phy *phy, @@ -10286,7 +10276,7 @@ static int bnx2x_8483x_enable_eee(struct bnx2x_phy *phy, } #define PHY84833_CONSTANT_LATENCY 1193 -static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, +static void bnx2x_848x3_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -10433,7 +10423,7 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, if (rc) { DP(NETIF_MSG_LINK, "Failed to configure EEE timers\n"); bnx2x_8483x_disable_eee(phy, params, vars); - return rc; + return; } if ((phy->req_duplex == DUPLEX_FULL) && @@ -10445,7 +10435,7 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, rc = bnx2x_8483x_disable_eee(phy, params, vars); if (rc) { DP(NETIF_MSG_LINK, "Failed to set EEE advertisement\n"); - return rc; + return; } } else { vars->eee_status &= ~SHMEM_EEE_SUPPORTED_MASK; @@ -10484,7 +10474,6 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, MDIO_84833_TOP_CFG_XGPHY_STRAP1, (u16)~MDIO_84833_SUPER_ISOLATE); } - return rc; } static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy, @@ -11041,7 +11030,7 @@ static void bnx2x_54618se_specific_func(struct bnx2x_phy *phy, } } -static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, +static void bnx2x_54618se_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -11243,8 +11232,6 @@ static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, bnx2x_cl22_write(bp, phy, MDIO_PMA_REG_CTRL, autoneg_val); - - return 0; } @@ -11468,7 +11455,7 @@ static void bnx2x_7101_config_loopback(struct bnx2x_phy *phy, MDIO_XS_DEVAD, MDIO_XS_SFX7101_XGXS_TEST1, 0x100); } -static int bnx2x_7101_config_init(struct bnx2x_phy *phy, +static void bnx2x_7101_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -11505,7 +11492,6 @@ static int bnx2x_7101_config_init(struct bnx2x_phy *phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER2, &fw_ver2); bnx2x_save_spirom_version(bp, params->port, (u32)(fw_ver1<<16 | fw_ver2), phy->ver_addr); - return 0; } static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy, @@ -11674,9 +11660,9 @@ static const struct bnx2x_phy phy_serdes = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_xgxs_config_init, - .read_status = (read_status_t)bnx2x_link_settings_status, - .link_reset = (link_reset_t)bnx2x_int_link_reset, + .config_init = bnx2x_xgxs_config_init, + .read_status = bnx2x_link_settings_status, + .link_reset = bnx2x_int_link_reset, .config_loopback = (config_loopback_t)NULL, .format_fw_ver = (format_fw_ver_t)NULL, .hw_reset = (hw_reset_t)NULL, @@ -11710,14 +11696,14 @@ static const struct bnx2x_phy phy_xgxs = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_xgxs_config_init, - .read_status = (read_status_t)bnx2x_link_settings_status, - .link_reset = (link_reset_t)bnx2x_int_link_reset, - .config_loopback = (config_loopback_t)bnx2x_set_xgxs_loopback, + .config_init = bnx2x_xgxs_config_init, + .read_status = bnx2x_link_settings_status, + .link_reset = bnx2x_int_link_reset, + .config_loopback = bnx2x_set_xgxs_loopback, .format_fw_ver = (format_fw_ver_t)NULL, .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)NULL, - .phy_specific_func = (phy_specific_func_t)bnx2x_xgxs_specific_func + .phy_specific_func = bnx2x_xgxs_specific_func }; static const struct bnx2x_phy phy_warpcore = { .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, @@ -11748,12 +11734,12 @@ static const struct bnx2x_phy phy_warpcore = { .speed_cap_mask = 0, /* req_duplex = */0, /* rsrv = */0, - .config_init = (config_init_t)bnx2x_warpcore_config_init, - .read_status = (read_status_t)bnx2x_warpcore_read_status, - .link_reset = (link_reset_t)bnx2x_warpcore_link_reset, - .config_loopback = (config_loopback_t)bnx2x_set_warpcore_loopback, + .config_init = bnx2x_warpcore_config_init, + .read_status = bnx2x_warpcore_read_status, + .link_reset = bnx2x_warpcore_link_reset, + .config_loopback = bnx2x_set_warpcore_loopback, .format_fw_ver = (format_fw_ver_t)NULL, - .hw_reset = (hw_reset_t)bnx2x_warpcore_hw_reset, + .hw_reset = bnx2x_warpcore_hw_reset, .set_link_led = (set_link_led_t)NULL, .phy_specific_func = (phy_specific_func_t)NULL }; @@ -11779,13 +11765,13 @@ static const struct bnx2x_phy phy_7101 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_7101_config_init, - .read_status = (read_status_t)bnx2x_7101_read_status, - .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, - .config_loopback = (config_loopback_t)bnx2x_7101_config_loopback, - .format_fw_ver = (format_fw_ver_t)bnx2x_7101_format_ver, - .hw_reset = (hw_reset_t)bnx2x_7101_hw_reset, - .set_link_led = (set_link_led_t)bnx2x_7101_set_link_led, + .config_init = bnx2x_7101_config_init, + .read_status = bnx2x_7101_read_status, + .link_reset = bnx2x_common_ext_link_reset, + .config_loopback = bnx2x_7101_config_loopback, + .format_fw_ver = bnx2x_7101_format_ver, + .hw_reset = bnx2x_7101_hw_reset, + .set_link_led = bnx2x_7101_set_link_led, .phy_specific_func = (phy_specific_func_t)NULL }; static const struct bnx2x_phy phy_8073 = { @@ -11810,14 +11796,14 @@ static const struct bnx2x_phy phy_8073 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_8073_config_init, - .read_status = (read_status_t)bnx2x_8073_read_status, - .link_reset = (link_reset_t)bnx2x_8073_link_reset, + .config_init = bnx2x_8073_config_init, + .read_status = bnx2x_8073_read_status, + .link_reset = bnx2x_8073_link_reset, .config_loopback = (config_loopback_t)NULL, - .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, + .format_fw_ver = bnx2x_format_ver, .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)NULL, - .phy_specific_func = (phy_specific_func_t)bnx2x_8073_specific_func + .phy_specific_func = bnx2x_8073_specific_func }; static const struct bnx2x_phy phy_8705 = { .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705, @@ -11838,11 +11824,11 @@ static const struct bnx2x_phy phy_8705 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_8705_config_init, - .read_status = (read_status_t)bnx2x_8705_read_status, - .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, + .config_init = bnx2x_8705_config_init, + .read_status = bnx2x_8705_read_status, + .link_reset = bnx2x_common_ext_link_reset, .config_loopback = (config_loopback_t)NULL, - .format_fw_ver = (format_fw_ver_t)bnx2x_null_format_ver, + .format_fw_ver = bnx2x_null_format_ver, .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)NULL, .phy_specific_func = (phy_specific_func_t)NULL @@ -11867,11 +11853,11 @@ static const struct bnx2x_phy phy_8706 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_8706_config_init, - .read_status = (read_status_t)bnx2x_8706_read_status, - .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, + .config_init = bnx2x_8706_config_init, + .read_status = bnx2x_8706_read_status, + .link_reset = bnx2x_common_ext_link_reset, .config_loopback = (config_loopback_t)NULL, - .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, + .format_fw_ver = bnx2x_format_ver, .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)NULL, .phy_specific_func = (phy_specific_func_t)NULL @@ -11899,11 +11885,11 @@ static const struct bnx2x_phy phy_8726 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_8726_config_init, - .read_status = (read_status_t)bnx2x_8726_read_status, - .link_reset = (link_reset_t)bnx2x_8726_link_reset, - .config_loopback = (config_loopback_t)bnx2x_8726_config_loopback, - .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, + .config_init = bnx2x_8726_config_init, + .read_status = bnx2x_8726_read_status, + .link_reset = bnx2x_8726_link_reset, + .config_loopback = bnx2x_8726_config_loopback, + .format_fw_ver = bnx2x_format_ver, .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)NULL, .phy_specific_func = (phy_specific_func_t)NULL @@ -11930,14 +11916,14 @@ static const struct bnx2x_phy phy_8727 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_8727_config_init, - .read_status = (read_status_t)bnx2x_8727_read_status, - .link_reset = (link_reset_t)bnx2x_8727_link_reset, + .config_init = bnx2x_8727_config_init, + .read_status = bnx2x_8727_read_status, + .link_reset = bnx2x_8727_link_reset, .config_loopback = (config_loopback_t)NULL, - .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, - .hw_reset = (hw_reset_t)bnx2x_8727_hw_reset, - .set_link_led = (set_link_led_t)bnx2x_8727_set_link_led, - .phy_specific_func = (phy_specific_func_t)bnx2x_8727_specific_func + .format_fw_ver = bnx2x_format_ver, + .hw_reset = bnx2x_8727_hw_reset, + .set_link_led = bnx2x_8727_set_link_led, + .phy_specific_func = bnx2x_8727_specific_func }; static const struct bnx2x_phy phy_8481 = { .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481, @@ -11965,13 +11951,13 @@ static const struct bnx2x_phy phy_8481 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_8481_config_init, - .read_status = (read_status_t)bnx2x_848xx_read_status, - .link_reset = (link_reset_t)bnx2x_8481_link_reset, + .config_init = bnx2x_8481_config_init, + .read_status = bnx2x_848xx_read_status, + .link_reset = bnx2x_8481_link_reset, .config_loopback = (config_loopback_t)NULL, - .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, - .hw_reset = (hw_reset_t)bnx2x_8481_hw_reset, - .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, + .format_fw_ver = bnx2x_848xx_format_ver, + .hw_reset = bnx2x_8481_hw_reset, + .set_link_led = bnx2x_848xx_set_link_led, .phy_specific_func = (phy_specific_func_t)NULL }; @@ -12002,14 +11988,14 @@ static const struct bnx2x_phy phy_84823 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_848x3_config_init, - .read_status = (read_status_t)bnx2x_848xx_read_status, - .link_reset = (link_reset_t)bnx2x_848x3_link_reset, + .config_init = bnx2x_848x3_config_init, + .read_status = bnx2x_848xx_read_status, + .link_reset = bnx2x_848x3_link_reset, .config_loopback = (config_loopback_t)NULL, - .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, + .format_fw_ver = bnx2x_848xx_format_ver, .hw_reset = (hw_reset_t)NULL, - .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, - .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func + .set_link_led = bnx2x_848xx_set_link_led, + .phy_specific_func = bnx2x_848xx_specific_func }; static const struct bnx2x_phy phy_84833 = { @@ -12037,14 +12023,14 @@ static const struct bnx2x_phy phy_84833 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_848x3_config_init, - .read_status = (read_status_t)bnx2x_848xx_read_status, - .link_reset = (link_reset_t)bnx2x_848x3_link_reset, + .config_init = bnx2x_848x3_config_init, + .read_status = bnx2x_848xx_read_status, + .link_reset = bnx2x_848x3_link_reset, .config_loopback = (config_loopback_t)NULL, - .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, - .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, - .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, - .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func + .format_fw_ver = bnx2x_848xx_format_ver, + .hw_reset = bnx2x_84833_hw_reset_phy, + .set_link_led = bnx2x_848xx_set_link_led, + .phy_specific_func = bnx2x_848xx_specific_func }; static const struct bnx2x_phy phy_84834 = { @@ -12071,14 +12057,14 @@ static const struct bnx2x_phy phy_84834 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_848x3_config_init, - .read_status = (read_status_t)bnx2x_848xx_read_status, - .link_reset = (link_reset_t)bnx2x_848x3_link_reset, + .config_init = bnx2x_848x3_config_init, + .read_status = bnx2x_848xx_read_status, + .link_reset = bnx2x_848x3_link_reset, .config_loopback = (config_loopback_t)NULL, - .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, - .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, - .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, - .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func + .format_fw_ver = bnx2x_848xx_format_ver, + .hw_reset = bnx2x_84833_hw_reset_phy, + .set_link_led = bnx2x_848xx_set_link_led, + .phy_specific_func = bnx2x_848xx_specific_func }; static const struct bnx2x_phy phy_84858 = { @@ -12105,14 +12091,14 @@ static const struct bnx2x_phy phy_84858 = { .speed_cap_mask = 0, .req_duplex = 0, .rsrv = 0, - .config_init = (config_init_t)bnx2x_848x3_config_init, - .read_status = (read_status_t)bnx2x_848xx_read_status, - .link_reset = (link_reset_t)bnx2x_848x3_link_reset, + .config_init = bnx2x_848x3_config_init, + .read_status = bnx2x_848xx_read_status, + .link_reset = bnx2x_848x3_link_reset, .config_loopback = (config_loopback_t)NULL, - .format_fw_ver = (format_fw_ver_t)bnx2x_8485x_format_ver, - .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, - .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, - .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func + .format_fw_ver = bnx2x_8485x_format_ver, + .hw_reset = bnx2x_84833_hw_reset_phy, + .set_link_led = bnx2x_848xx_set_link_led, + .phy_specific_func = bnx2x_848xx_specific_func }; static const struct bnx2x_phy phy_54618se = { @@ -12139,14 +12125,14 @@ static const struct bnx2x_phy phy_54618se = { .speed_cap_mask = 0, /* req_duplex = */0, /* rsrv = */0, - .config_init = (config_init_t)bnx2x_54618se_config_init, - .read_status = (read_status_t)bnx2x_54618se_read_status, - .link_reset = (link_reset_t)bnx2x_54618se_link_reset, - .config_loopback = (config_loopback_t)bnx2x_54618se_config_loopback, + .config_init = bnx2x_54618se_config_init, + .read_status = bnx2x_54618se_read_status, + .link_reset = bnx2x_54618se_link_reset, + .config_loopback = bnx2x_54618se_config_loopback, .format_fw_ver = (format_fw_ver_t)NULL, .hw_reset = (hw_reset_t)NULL, - .set_link_led = (set_link_led_t)bnx2x_5461x_set_link_led, - .phy_specific_func = (phy_specific_func_t)bnx2x_54618se_specific_func + .set_link_led = bnx2x_5461x_set_link_led, + .phy_specific_func = bnx2x_54618se_specific_func }; /*****************************************************************/ /* */ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h index b7d2511..a625bae 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h @@ -126,7 +126,7 @@ struct link_vars; struct link_params; struct bnx2x_phy; -typedef u8 (*config_init_t)(struct bnx2x_phy *phy, struct link_params *params, +typedef void (*config_init_t)(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars); typedef u8 (*read_status_t)(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars); @@ -134,7 +134,7 @@ typedef void (*link_reset_t)(struct bnx2x_phy *phy, struct link_params *params); typedef void (*config_loopback_t)(struct bnx2x_phy *phy, struct link_params *params); -typedef u8 (*format_fw_ver_t)(u32 raw, u8 *str, u16 *len); +typedef int (*format_fw_ver_t)(u32 raw, u8 *str, u16 *len); typedef void (*hw_reset_t)(struct bnx2x_phy *phy, struct link_params *params); typedef void (*set_link_led_t)(struct bnx2x_phy *phy, struct link_params *params, u8 mode); diff --git a/drivers/net/ethernet/brocade/bna/bfa_cs.h b/drivers/net/ethernet/brocade/bna/bfa_cs.h index 1d11d66..8f7a3cb 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_cs.h +++ b/drivers/net/ethernet/brocade/bna/bfa_cs.h @@ -34,10 +34,19 @@ struct bfa_sm_table { int state; /*!< state machine encoding */ char *name; /*!< state name for display */ }; -#define BFA_SM(_sm) ((bfa_sm_t)(_sm)) +#define BFA_SM(_sm) (_sm) + +#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (_state)) +#define bfa_sm_cmp_state(_sm, _state) ((_sm)->sm == (_state)) /* State machine with entry actions. */ -typedef void (*bfa_fsm_t)(void *fsm, int event); +struct bfa_ioc; +enum ioc_event; +struct bfa_iocpf; +enum iocpf_event; + +typedef void (*bfa_fsm_ioc_t)(struct bfa_ioc *fsm, enum ioc_event event); +typedef void (*bfa_fsm_iocpf_t)(struct bfa_iocpf *fsm, enum iocpf_event event); /* oc - object class eg. bfa_ioc * st - state, eg. reset @@ -49,16 +58,37 @@ typedef void (*bfa_fsm_t)(void *fsm, int event); static void oc ## _sm_ ## st ## _entry(otype * fsm) #define bfa_fsm_set_state(_fsm, _state) do { \ - (_fsm)->fsm = (bfa_fsm_t)(_state); \ + (_fsm)->fsm = (_state); \ _state ## _entry(_fsm); \ } while (0) #define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event))) -#define bfa_fsm_cmp_state(_fsm, _state) \ - ((_fsm)->fsm == (bfa_fsm_t)(_state)) +#define bfa_fsm_cmp_state(_fsm, _state) ((_fsm)->fsm == (_state)) + +/* For converting from state machine function to state encoding. */ +struct iocpf_sm_table { + bfa_fsm_iocpf_t sm; /*!< state machine function */ + int state; /*!< state machine encoding */ + char *name; /*!< state name for display */ +}; +struct ioc_sm_table { + bfa_fsm_ioc_t sm; /*!< state machine function */ + int state; /*!< state machine encoding */ + char *name; /*!< state name for display */ +}; + +static inline int +iocpf_sm_to_state(const struct iocpf_sm_table *smt, bfa_fsm_iocpf_t sm) +{ + int i = 0; + + while (smt[i].sm && smt[i].sm != sm) + i++; + return smt[i].state; +} static inline int -bfa_sm_to_state(const struct bfa_sm_table *smt, bfa_sm_t sm) +ioc_sm_to_state(const struct ioc_sm_table *smt, bfa_fsm_ioc_t sm) { int i = 0; diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c b/drivers/net/ethernet/brocade/bna/bfa_ioc.c index a36e386..725b042 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c +++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c @@ -122,7 +122,7 @@ bfa_fsm_state_decl(bfa_ioc, disabling, struct bfa_ioc, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, disabled, struct bfa_ioc, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, hwfail, struct bfa_ioc, enum ioc_event); -static struct bfa_sm_table ioc_sm_table[] = { +static struct ioc_sm_table ioc_sm_table[] = { {BFA_SM(bfa_ioc_sm_uninit), BFA_IOC_UNINIT}, {BFA_SM(bfa_ioc_sm_reset), BFA_IOC_RESET}, {BFA_SM(bfa_ioc_sm_enabling), BFA_IOC_ENABLING}, @@ -191,7 +191,7 @@ bfa_fsm_state_decl(bfa_iocpf, disabling_sync, struct bfa_iocpf, enum iocpf_event); bfa_fsm_state_decl(bfa_iocpf, disabled, struct bfa_iocpf, enum iocpf_event); -static struct bfa_sm_table iocpf_sm_table[] = { +static struct iocpf_sm_table iocpf_sm_table[] = { {BFA_SM(bfa_iocpf_sm_reset), BFA_IOCPF_RESET}, {BFA_SM(bfa_iocpf_sm_fwcheck), BFA_IOCPF_FWMISMATCH}, {BFA_SM(bfa_iocpf_sm_mismatch), BFA_IOCPF_FWMISMATCH}, @@ -2866,12 +2866,12 @@ static enum bfa_ioc_state bfa_ioc_get_state(struct bfa_ioc *ioc) { enum bfa_iocpf_state iocpf_st; - enum bfa_ioc_state ioc_st = bfa_sm_to_state(ioc_sm_table, ioc->fsm); + enum bfa_ioc_state ioc_st = ioc_sm_to_state(ioc_sm_table, ioc->fsm); if (ioc_st == BFA_IOC_ENABLING || ioc_st == BFA_IOC_FAIL || ioc_st == BFA_IOC_INITFAIL) { - iocpf_st = bfa_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm); + iocpf_st = iocpf_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm); switch (iocpf_st) { case BFA_IOCPF_SEMWAIT: @@ -2989,7 +2989,7 @@ bfa_nw_iocpf_timeout(struct bfa_ioc *ioc) { enum bfa_iocpf_state iocpf_st; - iocpf_st = bfa_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm); + iocpf_st = iocpf_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm); if (iocpf_st == BFA_IOCPF_HWINIT) bfa_ioc_poll_fwinit(ioc); diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.h b/drivers/net/ethernet/brocade/bna/bfa_ioc.h index 2c0b4c0..97873eb 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_ioc.h +++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.h @@ -156,7 +156,7 @@ struct bfa_ioc_notify { } while (0) struct bfa_iocpf { - bfa_fsm_t fsm; + bfa_fsm_iocpf_t fsm; struct bfa_ioc *ioc; bool fw_mismatch_notified; bool auto_recover; @@ -164,7 +164,7 @@ struct bfa_iocpf { }; struct bfa_ioc { - bfa_fsm_t fsm; + bfa_fsm_ioc_t fsm; struct bfa *bfa; struct bfa_pcidev pcidev; struct timer_list ioc_timer; diff --git a/drivers/net/ethernet/brocade/bna/bfa_msgq.h b/drivers/net/ethernet/brocade/bna/bfa_msgq.h index 66bc8b5..bf64466 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_msgq.h +++ b/drivers/net/ethernet/brocade/bna/bfa_msgq.h @@ -63,8 +63,10 @@ enum bfa_msgq_cmdq_flags { BFA_MSGQ_CMDQ_F_DB_UPDATE = 1, }; +enum cmdq_event; + struct bfa_msgq_cmdq { - bfa_fsm_t fsm; + void (*fsm)(struct bfa_msgq_cmdq *, enum cmdq_event); enum bfa_msgq_cmdq_flags flags; u16 producer_index; @@ -89,8 +91,10 @@ enum bfa_msgq_rspq_flags { typedef void (*bfa_msgq_mcfunc_t)(void *cbarg, struct bfi_msgq_mhdr *mhdr); +enum rspq_event; + struct bfa_msgq_rspq { - bfa_fsm_t fsm; + void (*fsm)(struct bfa_msgq_rspq *, enum rspq_event); enum bfa_msgq_rspq_flags flags; u16 producer_index; diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c b/drivers/net/ethernet/brocade/bna/bna_enet.c index bba8173..0791dab 100644 --- a/drivers/net/ethernet/brocade/bna/bna_enet.c +++ b/drivers/net/ethernet/brocade/bna/bna_enet.c @@ -1265,7 +1265,7 @@ bna_enet_mtu_get(struct bna_enet *enet) void bna_enet_enable(struct bna_enet *enet) { - if (enet->fsm != (bfa_sm_t)bna_enet_sm_stopped) + if (enet->fsm != bna_enet_sm_stopped) return; enet->flags |= BNA_ENET_F_ENABLED; @@ -1759,12 +1759,12 @@ bna_ioceth_uninit(struct bna_ioceth *ioceth) void bna_ioceth_enable(struct bna_ioceth *ioceth) { - if (ioceth->fsm == (bfa_fsm_t)bna_ioceth_sm_ready) { + if (ioceth->fsm == bna_ioceth_sm_ready) { bnad_cb_ioceth_ready(ioceth->bna->bnad); return; } - if (ioceth->fsm == (bfa_fsm_t)bna_ioceth_sm_stopped) + if (ioceth->fsm == bna_ioceth_sm_stopped) bfa_fsm_send_event(ioceth, IOCETH_E_ENABLE); } diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c index 95bc470..c12be9f 100644 --- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c +++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c @@ -1964,7 +1964,7 @@ static void bna_rx_stop(struct bna_rx *rx) { rx->rx_flags &= ~BNA_RX_F_ENET_STARTED; - if (rx->fsm == (bfa_fsm_t) bna_rx_sm_stopped) + if (rx->fsm == bna_rx_sm_stopped) bna_rx_mod_cb_rx_stopped(&rx->bna->rx_mod, rx); else { rx->stop_cbfn = bna_rx_mod_cb_rx_stopped; @@ -2543,7 +2543,7 @@ bna_rx_destroy(struct bna_rx *rx) void bna_rx_enable(struct bna_rx *rx) { - if (rx->fsm != (bfa_sm_t)bna_rx_sm_stopped) + if (rx->fsm != bna_rx_sm_stopped) return; rx->rx_flags |= BNA_RX_F_ENABLED; @@ -3531,7 +3531,7 @@ bna_tx_destroy(struct bna_tx *tx) void bna_tx_enable(struct bna_tx *tx) { - if (tx->fsm != (bfa_sm_t)bna_tx_sm_stopped) + if (tx->fsm != bna_tx_sm_stopped) return; tx->flags |= BNA_TX_F_ENABLED; diff --git a/drivers/net/ethernet/brocade/bna/bna_types.h b/drivers/net/ethernet/brocade/bna/bna_types.h index c438d03..4653f43 100644 --- a/drivers/net/ethernet/brocade/bna/bna_types.h +++ b/drivers/net/ethernet/brocade/bna/bna_types.h @@ -320,8 +320,10 @@ struct bna_attr { /* IOCEth */ +enum bna_ioceth_event; + struct bna_ioceth { - bfa_fsm_t fsm; + void (*fsm)(struct bna_ioceth *, enum bna_ioceth_event); struct bfa_ioc ioc; struct bna_attr attr; @@ -342,8 +344,10 @@ struct bna_pause_config { enum bna_status rx_pause; }; +enum bna_enet_event; + struct bna_enet { - bfa_fsm_t fsm; + void (*fsm)(struct bna_enet *, enum bna_enet_event); enum bna_enet_flags flags; enum bna_enet_type type; @@ -368,8 +372,10 @@ struct bna_enet { /* Ethport */ +enum bna_ethport_event; + struct bna_ethport { - bfa_fsm_t fsm; + void (*fsm)(struct bna_ethport *, enum bna_ethport_event); enum bna_ethport_flags flags; enum bna_link_status link_status; @@ -462,13 +468,15 @@ struct bna_txq { }; /* Tx object */ +enum bna_tx_event; + struct bna_tx { /* This should be the first one */ struct list_head qe; int rid; int hw_id; - bfa_fsm_t fsm; + void (*fsm)(struct bna_tx *, enum bna_tx_event); enum bna_tx_flags flags; enum bna_tx_type type; @@ -706,8 +714,10 @@ struct bna_rxp { }; /* RxF structure (hardware Rx Function) */ +enum bna_rxf_event; + struct bna_rxf { - bfa_fsm_t fsm; + void (*fsm)(struct bna_rxf *, enum bna_rxf_event); struct bfa_msgq_cmd_entry msgq_cmd; union { @@ -777,13 +787,15 @@ struct bna_rxf { }; /* Rx object */ +enum bna_rx_event; + struct bna_rx { /* This should be the first one */ struct list_head qe; int rid; int hw_id; - bfa_fsm_t fsm; + void (*fsm)(struct bna_rx *, enum bna_rx_event); enum bna_rx_type type; diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index 6e13c93..839dd12 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c @@ -1100,8 +1100,9 @@ bnad_cb_tx_resume(struct bnad *bnad, struct bna_tx *tx) * Free all TxQs buffers and then notify TX_E_CLEANUP_DONE to Tx fsm. */ static void -bnad_tx_cleanup(struct delayed_work *work) +bnad_tx_cleanup(struct work_struct *_work) { + struct delayed_work *work = (struct delayed_work *)_work; struct bnad_tx_info *tx_info = container_of(work, struct bnad_tx_info, tx_cleanup_work); struct bnad *bnad = NULL; @@ -1179,7 +1180,7 @@ bnad_cb_rx_stall(struct bnad *bnad, struct bna_rx *rx) * Free all RxQs buffers and then notify RX_E_CLEANUP_DONE to Rx fsm. */ static void -bnad_rx_cleanup(void *work) +bnad_rx_cleanup(struct work_struct *work) { struct bnad_rx_info *rx_info = container_of(work, struct bnad_rx_info, rx_cleanup_work); @@ -2003,8 +2004,7 @@ bnad_setup_tx(struct bnad *bnad, u32 tx_id) } tx_info->tx = tx; - INIT_DELAYED_WORK(&tx_info->tx_cleanup_work, - (work_func_t)bnad_tx_cleanup); + INIT_DELAYED_WORK(&tx_info->tx_cleanup_work, bnad_tx_cleanup); /* Register ISR for the Tx object */ if (intr_info->intr_type == BNA_INTR_T_MSIX) { @@ -2260,8 +2260,7 @@ bnad_setup_rx(struct bnad *bnad, u32 rx_id) rx_info->rx = rx; spin_unlock_irqrestore(&bnad->bna_lock, flags); - INIT_WORK(&rx_info->rx_cleanup_work, - (work_func_t)(bnad_rx_cleanup)); + INIT_WORK(&rx_info->rx_cleanup_work, bnad_rx_cleanup); /* * Init NAPI, so that state is set to NAPI_STATE_SCHED, diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 633e55c..b9ad02a 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1065,7 +1065,7 @@ void pci_disable_link_state(struct pci_dev *pdev, int state) } EXPORT_SYMBOL(pci_disable_link_state); -static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp) +static int pcie_aspm_set_policy(const char *val, const struct kernel_param *kp) { int i; struct pcie_link_state *link; @@ -1092,7 +1092,7 @@ static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp) return 0; } -static int pcie_aspm_get_policy(char *buffer, struct kernel_param *kp) +static int pcie_aspm_get_policy(char *buffer, const struct kernel_param *kp) { int i, cnt = 0; for (i = 0; i < ARRAY_SIZE(policy_str); i++) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 2242d60..3887dfe 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -9543,7 +9543,7 @@ static struct ibm_init_struct ibms_init[] __initdata = { }, }; -static int __init set_ibm_param(const char *val, struct kernel_param *kp) +static int __init set_ibm_param(const char *val, const struct kernel_param *kp) { unsigned int i; struct ibm_struct *ibm; diff --git a/drivers/ras/ras.c b/drivers/ras/ras.c index 3f38907..95540ea 100644 --- a/drivers/ras/ras.c +++ b/drivers/ras/ras.c @@ -14,7 +14,7 @@ #define TRACE_INCLUDE_PATH ../../include/ras #include -void log_non_standard_event(const uuid_le *sec_type, const uuid_le *fru_id, +void log_non_standard_event(const guid_t *sec_type, const guid_t *fru_id, const char *fru_text, const u8 sev, const u8 *err, const u32 len) { diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 7173ae5..039ba66 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -812,6 +812,11 @@ static int aac_probe_container_callback1(struct scsi_cmnd * scsicmd) return 0; } +static void aac_probe_container_scsi_done(struct scsi_cmnd * scsicmd) +{ + scsicmd->device = NULL; +} + int aac_probe_container(struct aac_dev *dev, int cid) { struct scsi_cmnd *scsicmd = kmalloc(sizeof(*scsicmd), GFP_KERNEL); @@ -824,7 +829,7 @@ int aac_probe_container(struct aac_dev *dev, int cid) return -ENOMEM; } scsicmd->list.next = NULL; - scsicmd->scsi_done = (void (*)(struct scsi_cmnd*))aac_probe_container_callback1; + scsicmd->scsi_done = aac_probe_container_scsi_done; scsicmd->device = scsidev; scsidev->sdev_state = 0; diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h index d47b527..f2c4a89 100644 --- a/drivers/scsi/aic7xxx/aic79xx.h +++ b/drivers/scsi/aic7xxx/aic79xx.h @@ -1046,7 +1046,7 @@ typedef enum { typedef uint8_t ahd_mode_state; -typedef void ahd_callback_t (void *); +typedef void ahd_linux_callback_t (u_long); struct ahd_completion { diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index 95d8f25..3f151eb 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -207,7 +207,7 @@ static void ahd_add_scb_to_free_list(struct ahd_softc *ahd, static u_int ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid, u_int prev, u_int next, u_int tid); static void ahd_reset_current_bus(struct ahd_softc *ahd); -static ahd_callback_t ahd_stat_timer; +static ahd_linux_callback_t ahd_stat_timer; #ifdef AHD_DUMP_SEQ static void ahd_dumpseq(struct ahd_softc *ahd); #endif @@ -7041,10 +7041,9 @@ static const char *termstat_strings[] = { /***************************** Timer Facilities *******************************/ #define ahd_timer_init init_timer #define ahd_timer_stop del_timer_sync -typedef void ahd_linux_callback_t (u_long); static void -ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg) +ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_linux_callback_t *func, void *arg) { struct ahd_softc *ahd; @@ -7052,7 +7051,7 @@ ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg) del_timer(timer); timer->data = (u_long)arg; timer->expires = jiffies + (usec * HZ)/1000000; - timer->function = (ahd_linux_callback_t*)func; + timer->function = func; add_timer(timer); } @@ -8878,9 +8877,9 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset) /**************************** Statistics Processing ***************************/ static void -ahd_stat_timer(void *arg) +ahd_stat_timer(unsigned long arg) { - struct ahd_softc *ahd = arg; + struct ahd_softc *ahd = (struct ahd_softc *)arg; u_long s; int enint_coal; diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h index 0e119d8..1bf8a49 100644 --- a/drivers/scsi/bfa/bfa.h +++ b/drivers/scsi/bfa/bfa.h @@ -225,8 +225,10 @@ struct bfa_faa_args_s { bfa_boolean_t busy; }; +enum iocfc_event; + struct bfa_iocfc_s { - bfa_fsm_t fsm; + void (*fsm)(struct bfa_iocfc_s *, enum iocfc_event); struct bfa_s *bfa; struct bfa_iocfc_cfg_s cfg; u32 req_cq_pi[BFI_IOC_MAX_CQS]; diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c index 3e1caec..d609d18 100644 --- a/drivers/scsi/bfa/bfa_core.c +++ b/drivers/scsi/bfa/bfa_core.c @@ -1915,15 +1915,13 @@ bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q) struct list_head *qe; struct list_head *qen; struct bfa_cb_qe_s *hcb_qe; - bfa_cb_cbfn_status_t cbfn; list_for_each_safe(qe, qen, comp_q) { hcb_qe = (struct bfa_cb_qe_s *) qe; if (hcb_qe->pre_rmv) { /* qe is invalid after return, dequeue before cbfn() */ list_del(qe); - cbfn = (bfa_cb_cbfn_status_t)(hcb_qe->cbfn); - cbfn(hcb_qe->cbarg, hcb_qe->fw_status); + hcb_qe->cbfn(hcb_qe->cbarg, hcb_qe->fw_status); } else hcb_qe->cbfn(hcb_qe->cbarg, BFA_TRUE); } diff --git a/drivers/scsi/bfa/bfa_cs.h b/drivers/scsi/bfa/bfa_cs.h index df6760c..3b22f4d 100644 --- a/drivers/scsi/bfa/bfa_cs.h +++ b/drivers/scsi/bfa/bfa_cs.h @@ -184,8 +184,6 @@ bfa_q_is_on_q_func(struct list_head *q, struct list_head *qe) * @ BFA state machine interfaces */ -typedef void (*bfa_sm_t)(void *sm, int event); - /* * oc - object class eg. bfa_ioc * st - state, eg. reset @@ -195,20 +193,75 @@ typedef void (*bfa_sm_t)(void *sm, int event); #define bfa_sm_state_decl(oc, st, otype, etype) \ static void oc ## _sm_ ## st(otype * fsm, etype event) -#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state)) +#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (_state)) #define bfa_sm_send_event(_sm, _event) ((_sm)->sm((_sm), (_event))) #define bfa_sm_get_state(_sm) ((_sm)->sm) -#define bfa_sm_cmp_state(_sm, _state) ((_sm)->sm == (bfa_sm_t)(_state)) +#define bfa_sm_cmp_state(_sm, _state) ((_sm)->sm == (_state)) /* * For converting from state machine function to state encoding. */ -struct bfa_sm_table_s { - bfa_sm_t sm; /* state machine function */ +struct bfa_iocpf_s; +enum iocpf_event; +typedef void (*bfa_fsm_iocpf_t)(struct bfa_iocpf_s *, enum iocpf_event); + +struct iocpf_sm_table_s { + bfa_fsm_iocpf_t sm; /* state machine function */ + int state; /* state machine encoding */ + char *name; /* state name for display */ +}; + +struct bfa_ioc_s; +enum ioc_event; +typedef void (*bfa_fsm_ioc_t)(struct bfa_ioc_s *, enum ioc_event); + +struct ioc_sm_table_s { + bfa_fsm_ioc_t sm; /* state machine function */ int state; /* state machine encoding */ char *name; /* state name for display */ }; -#define BFA_SM(_sm) ((bfa_sm_t)(_sm)) + +struct bfa_fcs_rport_s; +enum rport_event; +typedef void(*bfa_fcs_rport_t)(struct bfa_fcs_rport_s *, enum rport_event); + +struct rport_sm_table_s { + bfa_fcs_rport_t sm; /* state machine function */ + int state; /* state machine encoding */ + char *name; /* state name for display */ +}; + +struct bfa_fcs_vport_s; +enum bfa_fcs_vport_event; +typedef void(*bfa_fcs_vport_t)(struct bfa_fcs_vport_s *, enum bfa_fcs_vport_event); + +struct vport_sm_table_s { + bfa_fcs_vport_t sm; /* state machine function */ + int state; /* state machine encoding */ + char *name; /* state name for display */ +}; + +struct bfa_fcs_itnim_s; +enum bfa_fcs_itnim_event; +typedef void(*bfa_fcs_itnim_t)(struct bfa_fcs_itnim_s *, enum bfa_fcs_itnim_event); + +struct itnim_sm_table_s { + bfa_fcs_itnim_t sm; /* state machine function */ + int state; /* state machine encoding */ + char *name; /* state name for display */ +}; + +struct bfa_fcport_s; +enum bfa_fcport_sm_event; +typedef void(*bfa_fcport_t)(struct bfa_fcport_s *, enum bfa_fcport_sm_event); + +struct fcport_sm_table_s { + bfa_fcport_t sm; /* state machine function */ + int state; /* state machine encoding */ + char *name; /* state name for display */ +}; + +#define BFA_SM(_sm) (_sm) /* * State machine with entry actions. @@ -226,17 +279,66 @@ typedef void (*bfa_fsm_t)(void *fsm, int event); static void oc ## _sm_ ## st ## _entry(otype * fsm) #define bfa_fsm_set_state(_fsm, _state) do { \ - (_fsm)->fsm = (bfa_fsm_t)(_state); \ + (_fsm)->fsm = (_state); \ _state ## _entry(_fsm); \ } while (0) #define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event))) #define bfa_fsm_get_state(_fsm) ((_fsm)->fsm) -#define bfa_fsm_cmp_state(_fsm, _state) \ - ((_fsm)->fsm == (bfa_fsm_t)(_state)) +#define bfa_fsm_cmp_state(_fsm, _state) ((_fsm)->fsm == (_state)) + +static inline int +iocpf_sm_to_state(struct iocpf_sm_table_s *smt, bfa_fsm_iocpf_t sm) +{ + int i = 0; + + while (smt[i].sm && smt[i].sm != sm) + i++; + return smt[i].state; +} + +static inline int +ioc_sm_to_state(struct ioc_sm_table_s *smt, bfa_fsm_ioc_t sm) +{ + int i = 0; + + while (smt[i].sm && smt[i].sm != sm) + i++; + return smt[i].state; +} + +static inline int +rport_sm_to_state(struct rport_sm_table_s *smt, bfa_fcs_rport_t sm) +{ + int i = 0; + + while (smt[i].sm && smt[i].sm != sm) + i++; + return smt[i].state; +} + +static inline int +vport_sm_to_state(struct vport_sm_table_s *smt, bfa_fcs_vport_t sm) +{ + int i = 0; + + while (smt[i].sm && smt[i].sm != sm) + i++; + return smt[i].state; +} + +static inline int +itnim_sm_to_state(struct itnim_sm_table_s *smt, bfa_fcs_itnim_t sm) +{ + int i = 0; + + while (smt[i].sm && smt[i].sm != sm) + i++; + return smt[i].state; +} static inline int -bfa_sm_to_state(struct bfa_sm_table_s *smt, bfa_sm_t sm) +fcport_sm_to_state(struct fcport_sm_table_s *smt, bfa_fcport_t sm) { int i = 0; diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h index e93921d..0617a43 100644 --- a/drivers/scsi/bfa/bfa_fcpim.h +++ b/drivers/scsi/bfa/bfa_fcpim.h @@ -165,9 +165,11 @@ struct bfa_fcp_mod_s { /* * BFA IO (initiator mode) */ +enum bfa_ioim_event; + struct bfa_ioim_s { struct list_head qe; /* queue elememt */ - bfa_sm_t sm; /* BFA ioim state machine */ + void (*sm)(struct bfa_ioim_s *, enum bfa_ioim_event);/* BFA ioim state machine */ struct bfa_s *bfa; /* BFA module */ struct bfa_fcpim_s *fcpim; /* parent fcpim module */ struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */ @@ -197,9 +199,11 @@ struct bfa_ioim_sp_s { /* * BFA Task management command (initiator mode) */ +enum bfa_tskim_event; + struct bfa_tskim_s { struct list_head qe; - bfa_sm_t sm; + void (*sm)(struct bfa_tskim_s *, enum bfa_tskim_event); struct bfa_s *bfa; /* BFA module */ struct bfa_fcpim_s *fcpim; /* parent fcpim module */ struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */ @@ -219,9 +223,11 @@ struct bfa_tskim_s { /* * BFA i-t-n (initiator mode) */ +enum bfa_itnim_event; + struct bfa_itnim_s { struct list_head qe; /* queue element */ - bfa_sm_t sm; /* i-t-n im BFA state machine */ + void (*sm)(struct bfa_itnim_s *, enum bfa_itnim_event);/* i-t-n im BFA state machine */ struct bfa_s *bfa; /* bfa instance */ struct bfa_rport_s *rport; /* bfa rport */ void *ditn; /* driver i-t-n structure */ diff --git a/drivers/scsi/bfa/bfa_fcs.h b/drivers/scsi/bfa/bfa_fcs.h index e60f72b..3606b00 100644 --- a/drivers/scsi/bfa/bfa_fcs.h +++ b/drivers/scsi/bfa/bfa_fcs.h @@ -67,8 +67,10 @@ struct bfa_fcs_s; #define BFA_FCS_PID_IS_WKA(pid) ((bfa_ntoh3b(pid) > 0xFFF000) ? 1 : 0) #define BFA_FCS_MAX_RPORT_LOGINS 1024 +enum vport_ns_event; + struct bfa_fcs_lport_ns_s { - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_lport_ns_s *, enum vport_ns_event);/* state machine */ struct bfa_timer_s timer; struct bfa_fcs_lport_s *port; /* parent port */ struct bfa_fcxp_s *fcxp; @@ -77,18 +79,20 @@ struct bfa_fcs_lport_ns_s { u8 num_rsnn_nn_retries; }; +enum port_scn_event; struct bfa_fcs_lport_scn_s { - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_lport_scn_s *, enum port_scn_event);/* state machine */ struct bfa_timer_s timer; struct bfa_fcs_lport_s *port; /* parent port */ struct bfa_fcxp_s *fcxp; struct bfa_fcxp_wqe_s fcxp_wqe; }; +enum port_fdmi_event; struct bfa_fcs_lport_fdmi_s { - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_lport_fdmi_s *, enum port_fdmi_event);/* state machine */ struct bfa_timer_s timer; struct bfa_fcs_lport_ms_s *ms; /* parent ms */ struct bfa_fcxp_s *fcxp; @@ -97,9 +101,10 @@ struct bfa_fcs_lport_fdmi_s { u8 rsvd[3]; }; +enum port_ms_event; struct bfa_fcs_lport_ms_s { - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_lport_ms_s *, enum port_ms_event);/* state machine */ struct bfa_timer_s timer; struct bfa_fcs_lport_s *port; /* parent port */ struct bfa_fcxp_s *fcxp; @@ -139,10 +144,11 @@ union bfa_fcs_lport_topo_u { struct bfa_fcs_lport_n2n_s pn2n; }; +enum bfa_fcs_lport_event; struct bfa_fcs_lport_s { struct list_head qe; /* used by port/vport */ - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_lport_s *, enum bfa_fcs_lport_event); /* state machine */ struct bfa_fcs_fabric_s *fabric; /* parent fabric */ struct bfa_lport_cfg_s port_cfg; /* port configuration */ struct bfa_timer_s link_timer; /* timer for link offline */ @@ -179,10 +185,11 @@ enum bfa_fcs_fabric_type { BFA_FCS_FABRIC_LOOP = 3, }; +enum bfa_fcs_fabric_event; struct bfa_fcs_fabric_s { struct list_head qe; /* queue element */ - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_fabric_s *, enum bfa_fcs_fabric_event); /* state machine */ struct bfa_fcs_s *fcs; /* FCS instance */ struct bfa_fcs_lport_s bport; /* base logical port */ enum bfa_fcs_fabric_type fab_type; /* fabric type */ @@ -355,9 +362,11 @@ void bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port, struct fchs_s *rx_frame, u32 len); void bfa_fcs_lport_lip_scn_online(bfa_fcs_lport_t *port); +enum bfa_fcs_vport_event; + struct bfa_fcs_vport_s { struct list_head qe; /* queue elem */ - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_vport_s *, enum bfa_fcs_vport_event);/* state machine */ bfa_fcs_lport_t lport; /* logical port */ struct bfa_timer_s timer; struct bfad_vport_s *vport_drv; /* Driver private */ @@ -409,8 +418,10 @@ struct bfa_fcs_tin_s; struct bfa_fcs_iprp_s; /* Rport Features (RPF) */ +enum rpf_event; + struct bfa_fcs_rpf_s { - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_rpf_s *, enum rpf_event); /* state machine */ struct bfa_fcs_rport_s *rport; /* parent rport */ struct bfa_timer_s timer; /* general purpose timer */ struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */ @@ -425,6 +436,8 @@ struct bfa_fcs_rpf_s { */ }; +enum rport_event; + struct bfa_fcs_rport_s { struct list_head qe; /* used by port/vport */ struct bfa_fcs_lport_s *port; /* parent FCS port */ @@ -441,7 +454,7 @@ struct bfa_fcs_rport_s { wwn_t pwwn; /* port wwn of rport */ wwn_t nwwn; /* node wwn of rport */ struct bfa_rport_symname_s psym_name; /* port symbolic name */ - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_rport_s *, enum rport_event); /* state machine */ struct bfa_timer_s timer; /* general purpose timer */ struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */ struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */ @@ -502,9 +515,10 @@ void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport); * forward declarations */ struct bfad_itnim_s; +enum bfa_fcs_itnim_event; struct bfa_fcs_itnim_s { - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_fcs_itnim_s *, enum bfa_fcs_itnim_event);/* state machine */ struct bfa_fcs_rport_s *rport; /* parent remote rport */ struct bfad_itnim_s *itnim_drv; /* driver peer instance */ struct bfa_fcs_s *fcs; /* fcs instance */ diff --git a/drivers/scsi/bfa/bfa_fcs_fcpim.c b/drivers/scsi/bfa/bfa_fcs_fcpim.c index 2e3b19e..7a9b729 100644 --- a/drivers/scsi/bfa/bfa_fcs_fcpim.c +++ b/drivers/scsi/bfa/bfa_fcs_fcpim.c @@ -60,7 +60,7 @@ static void bfa_fcs_itnim_sm_hcb_offline(struct bfa_fcs_itnim_s *itnim, static void bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim, enum bfa_fcs_itnim_event event); -static struct bfa_sm_table_s itnim_sm_table[] = { +static struct itnim_sm_table_s itnim_sm_table[] = { {BFA_SM(bfa_fcs_itnim_sm_offline), BFA_ITNIM_OFFLINE}, {BFA_SM(bfa_fcs_itnim_sm_prli_send), BFA_ITNIM_PRLI_SEND}, {BFA_SM(bfa_fcs_itnim_sm_prli), BFA_ITNIM_PRLI_SENT}, @@ -673,7 +673,7 @@ bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim) { bfa_trc(itnim->fcs, itnim->rport->pid); - switch (bfa_sm_to_state(itnim_sm_table, itnim->sm)) { + switch (itnim_sm_to_state(itnim_sm_table, itnim->sm)) { case BFA_ITNIM_ONLINE: case BFA_ITNIM_INITIATIOR: return BFA_STATUS_OK; @@ -773,7 +773,7 @@ bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn, if (itnim == NULL) return BFA_STATUS_NO_FCPIM_NEXUS; - attr->state = bfa_sm_to_state(itnim_sm_table, itnim->sm); + attr->state = itnim_sm_to_state(itnim_sm_table, itnim->sm); attr->retry = itnim->seq_rec; attr->rec_support = itnim->rec_support; attr->conf_comp = itnim->conf_comp; diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c index 638c0a2..59739f8 100644 --- a/drivers/scsi/bfa/bfa_fcs_lport.c +++ b/drivers/scsi/bfa/bfa_fcs_lport.c @@ -6051,7 +6051,7 @@ static void bfa_fcs_vport_sm_stopping(struct bfa_fcs_vport_s *vport, static void bfa_fcs_vport_sm_logo_for_stop(struct bfa_fcs_vport_s *vport, enum bfa_fcs_vport_event event); -static struct bfa_sm_table_s vport_sm_table[] = { +static struct vport_sm_table_s vport_sm_table[] = { {BFA_SM(bfa_fcs_vport_sm_uninit), BFA_FCS_VPORT_UNINIT}, {BFA_SM(bfa_fcs_vport_sm_created), BFA_FCS_VPORT_CREATED}, {BFA_SM(bfa_fcs_vport_sm_offline), BFA_FCS_VPORT_OFFLINE}, @@ -6882,7 +6882,7 @@ bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport, memset(attr, 0, sizeof(struct bfa_vport_attr_s)); bfa_fcs_lport_get_attr(&vport->lport, &attr->port_attr); - attr->vport_state = bfa_sm_to_state(vport_sm_table, vport->sm); + attr->vport_state = vport_sm_to_state(vport_sm_table, vport->sm); } diff --git a/drivers/scsi/bfa/bfa_fcs_rport.c b/drivers/scsi/bfa/bfa_fcs_rport.c index de50349..6d676be 100644 --- a/drivers/scsi/bfa/bfa_fcs_rport.c +++ b/drivers/scsi/bfa/bfa_fcs_rport.c @@ -144,7 +144,7 @@ static void bfa_fcs_rport_sm_fc4_off_delete(struct bfa_fcs_rport_s *rport, static void bfa_fcs_rport_sm_delete_pending(struct bfa_fcs_rport_s *rport, enum rport_event event); -static struct bfa_sm_table_s rport_sm_table[] = { +static struct rport_sm_table_s rport_sm_table[] = { {BFA_SM(bfa_fcs_rport_sm_uninit), BFA_RPORT_UNINIT}, {BFA_SM(bfa_fcs_rport_sm_plogi_sending), BFA_RPORT_PLOGI}, {BFA_SM(bfa_fcs_rport_sm_plogiacc_sending), BFA_RPORT_ONLINE}, @@ -2980,7 +2980,7 @@ bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s *rport, struct fchs_s *rx_fchs, int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport) { - return bfa_sm_to_state(rport_sm_table, rport->sm); + return rport_sm_to_state(rport_sm_table, rport->sm); } diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c index 256f4af..2d5b6b8 100644 --- a/drivers/scsi/bfa/bfa_ioc.c +++ b/drivers/scsi/bfa/bfa_ioc.c @@ -148,7 +148,7 @@ bfa_fsm_state_decl(bfa_ioc, disabling, struct bfa_ioc_s, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, disabled, struct bfa_ioc_s, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, hwfail, struct bfa_ioc_s, enum ioc_event); -static struct bfa_sm_table_s ioc_sm_table[] = { +static struct ioc_sm_table_s ioc_sm_table[] = { {BFA_SM(bfa_ioc_sm_uninit), BFA_IOC_UNINIT}, {BFA_SM(bfa_ioc_sm_reset), BFA_IOC_RESET}, {BFA_SM(bfa_ioc_sm_enabling), BFA_IOC_ENABLING}, @@ -236,7 +236,7 @@ bfa_fsm_state_decl(bfa_iocpf, disabling_sync, struct bfa_iocpf_s, enum iocpf_event); bfa_fsm_state_decl(bfa_iocpf, disabled, struct bfa_iocpf_s, enum iocpf_event); -static struct bfa_sm_table_s iocpf_sm_table[] = { +static struct iocpf_sm_table_s iocpf_sm_table[] = { {BFA_SM(bfa_iocpf_sm_reset), BFA_IOCPF_RESET}, {BFA_SM(bfa_iocpf_sm_fwcheck), BFA_IOCPF_FWMISMATCH}, {BFA_SM(bfa_iocpf_sm_mismatch), BFA_IOCPF_FWMISMATCH}, @@ -2830,12 +2830,12 @@ enum bfa_ioc_state bfa_ioc_get_state(struct bfa_ioc_s *ioc) { enum bfa_iocpf_state iocpf_st; - enum bfa_ioc_state ioc_st = bfa_sm_to_state(ioc_sm_table, ioc->fsm); + enum bfa_ioc_state ioc_st = ioc_sm_to_state(ioc_sm_table, ioc->fsm); if (ioc_st == BFA_IOC_ENABLING || ioc_st == BFA_IOC_FAIL || ioc_st == BFA_IOC_INITFAIL) { - iocpf_st = bfa_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm); + iocpf_st = iocpf_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm); switch (iocpf_st) { case BFA_IOCPF_SEMWAIT: diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h index 0f9fab7..51a3f75 100644 --- a/drivers/scsi/bfa/bfa_ioc.h +++ b/drivers/scsi/bfa/bfa_ioc.h @@ -290,16 +290,20 @@ struct bfa_ioc_notify_s { (__notify)->cbarg = (__cbarg); \ } while (0) +enum iocpf_event; + struct bfa_iocpf_s { - bfa_fsm_t fsm; + void (*fsm)(struct bfa_iocpf_s *, enum iocpf_event); struct bfa_ioc_s *ioc; bfa_boolean_t fw_mismatch_notified; bfa_boolean_t auto_recover; u32 poll_time; }; +enum ioc_event; + struct bfa_ioc_s { - bfa_fsm_t fsm; + void (*fsm)(struct bfa_ioc_s *, enum ioc_event); struct bfa_s *bfa; struct bfa_pcidev_s pcidev; struct bfa_timer_mod_s *timer_mod; @@ -783,8 +787,10 @@ struct bfa_dconf_s { }; #pragma pack() +enum bfa_dconf_event; + struct bfa_dconf_mod_s { - bfa_sm_t sm; + void (*sm)(struct bfa_dconf_mod_s *, enum bfa_dconf_event); u8 instance; bfa_boolean_t read_data_valid; bfa_boolean_t min_cfg; diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c index e640223..8e4898e 100644 --- a/drivers/scsi/bfa/bfa_svc.c +++ b/drivers/scsi/bfa/bfa_svc.c @@ -209,7 +209,7 @@ static void bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln, static void bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln, enum bfa_fcport_ln_sm_event event); -static struct bfa_sm_table_s hal_port_sm_table[] = { +static struct fcport_sm_table_s hal_port_sm_table[] = { {BFA_SM(bfa_fcport_sm_uninit), BFA_PORT_ST_UNINIT}, {BFA_SM(bfa_fcport_sm_enabling_qwait), BFA_PORT_ST_ENABLING_QWAIT}, {BFA_SM(bfa_fcport_sm_enabling), BFA_PORT_ST_ENABLING}, @@ -3578,7 +3578,7 @@ bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg) fcport->event_arg.i2hmsg = i2hmsg; bfa_trc(bfa, msg->mhdr.msg_id); - bfa_trc(bfa, bfa_sm_to_state(hal_port_sm_table, fcport->sm)); + bfa_trc(bfa, fcport_sm_to_state(hal_port_sm_table, fcport->sm)); switch (msg->mhdr.msg_id) { case BFI_FCPORT_I2H_ENABLE_RSP: @@ -4013,7 +4013,7 @@ bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr) attr->pport_cfg.path_tov = bfa_fcpim_path_tov_get(bfa); attr->pport_cfg.q_depth = bfa_fcpim_qdepth_get(bfa); - attr->port_state = bfa_sm_to_state(hal_port_sm_table, fcport->sm); + attr->port_state = fcport_sm_to_state(hal_port_sm_table, fcport->sm); attr->fec_state = fcport->fec_state; @@ -4095,7 +4095,7 @@ bfa_fcport_is_disabled(struct bfa_s *bfa) { struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); - return bfa_sm_to_state(hal_port_sm_table, fcport->sm) == + return fcport_sm_to_state(hal_port_sm_table, fcport->sm) == BFA_PORT_ST_DISABLED; } @@ -4105,7 +4105,7 @@ bfa_fcport_is_dport(struct bfa_s *bfa) { struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); - return (bfa_sm_to_state(hal_port_sm_table, fcport->sm) == + return (fcport_sm_to_state(hal_port_sm_table, fcport->sm) == BFA_PORT_ST_DPORT); } @@ -4114,7 +4114,7 @@ bfa_fcport_is_ddport(struct bfa_s *bfa) { struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); - return (bfa_sm_to_state(hal_port_sm_table, fcport->sm) == + return (fcport_sm_to_state(hal_port_sm_table, fcport->sm) == BFA_PORT_ST_DDPORT); } diff --git a/drivers/scsi/bfa/bfa_svc.h b/drivers/scsi/bfa/bfa_svc.h index ea2278b..6f51a73 100644 --- a/drivers/scsi/bfa/bfa_svc.h +++ b/drivers/scsi/bfa/bfa_svc.h @@ -160,6 +160,8 @@ struct bfa_fcxp_rsp_info_s { u32 rsp_maxlen; /* max response length expected */ }; +typedef void (*bfa_sm_t)(void *sm, int event); + struct bfa_fcxp_s { struct list_head qe; /* fcxp queue element */ bfa_sm_t sm; /* state machine */ @@ -295,9 +297,11 @@ struct bfa_rport_info_s { /* * BFA rport data structure */ +enum bfa_rport_event; + struct bfa_rport_s { struct list_head qe; /* queue element */ - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfa_rport_s *, enum bfa_rport_event);/* state machine */ struct bfa_s *bfa; /* backpointer to BFA */ void *rport_drv; /* fcs/driver rport object */ u16 fw_handle; /* firmware rport handle */ @@ -388,10 +392,12 @@ void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw); /* * LPS - bfa lport login/logout service interface */ +enum bfa_lps_event; + struct bfa_lps_s { struct list_head qe; /* queue element */ struct bfa_s *bfa; /* parent bfa instance */ - bfa_sm_t sm; /* finite state machine */ + void (*sm)(struct bfa_lps_s *, enum bfa_lps_event);/* finite state machine */ u8 bfa_tag; /* lport tag */ u8 fw_tag; /* lport fw tag */ u8 reqq; /* lport request queue */ @@ -450,9 +456,11 @@ void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); /* * Link notification data structure */ +enum bfa_fcport_ln_sm_event; + struct bfa_fcport_ln_s { struct bfa_fcport_s *fcport; - bfa_sm_t sm; + void (*sm)(struct bfa_fcport_ln_s *, enum bfa_fcport_ln_sm_event); struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */ enum bfa_port_linkstate ln_event; /* ln event for callback */ }; @@ -466,7 +474,7 @@ struct bfa_fcport_trunk_s { */ struct bfa_fcport_s { struct bfa_s *bfa; /* parent BFA instance */ - bfa_sm_t sm; /* port state machine */ + void (*sm)(struct bfa_fcport_s *, enum bfa_fcport_sm_event); /* port state machine */ wwn_t nwwn; /* node wwn of physical port */ wwn_t pwwn; /* port wwn of physical oprt */ enum bfa_port_speed speed_sup; @@ -714,9 +722,11 @@ struct bfa_fcdiag_lb_s { u32 status; }; +enum bfa_dport_sm_event; + struct bfa_dport_s { struct bfa_s *bfa; /* Back pointer to BFA */ - bfa_sm_t sm; /* finite state machine */ + void (*sm)(struct bfa_dport_s *, enum bfa_dport_sm_event);/* finite state machine */ struct bfa_reqq_wait_s reqq_wait; bfa_cb_diag_t cbfn; void *cbarg; diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c index 5caf5f3..fcff931 100644 --- a/drivers/scsi/bfa/bfad.c +++ b/drivers/scsi/bfa/bfad.c @@ -408,6 +408,16 @@ bfad_hcb_comp(void *arg, bfa_status_t status) complete(&fcomp->comp); } +void +bfad_stats_comp(void *arg, bfa_boolean_t _status) +{ + struct bfad_hal_comp *fcomp = (struct bfad_hal_comp *)arg; + bfa_status_t status = (bfa_status_t)_status; + + fcomp->status = status; + complete(&fcomp->comp); +} + /* * bfa_init callback */ @@ -1442,7 +1452,7 @@ bfad_pci_remove(struct pci_dev *pdev) * PCI Error Recovery entry, error detected. */ static pci_ers_result_t -bfad_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) +bfad_pci_error_detected(struct pci_dev *pdev, enum pci_channel_state state) { struct bfad_s *bfad = pci_get_drvdata(pdev); unsigned long flags; diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c index 1aa46d0..5e4fa77 100644 --- a/drivers/scsi/bfa/bfad_bsg.c +++ b/drivers/scsi/bfa/bfad_bsg.c @@ -2145,7 +2145,7 @@ bfad_iocmd_fcport_get_stats(struct bfad_s *bfad, void *cmd) struct bfa_cb_pending_q_s cb_qe; init_completion(&fcomp.comp); - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, + bfa_pending_q_init(&cb_qe, bfad_stats_comp, &fcomp, &iocmd->stats); spin_lock_irqsave(&bfad->bfad_lock, flags); iocmd->status = bfa_fcport_get_stats(&bfad->bfa, &cb_qe); @@ -2169,7 +2169,7 @@ bfad_iocmd_fcport_reset_stats(struct bfad_s *bfad, void *cmd) struct bfa_cb_pending_q_s cb_qe; init_completion(&fcomp.comp); - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, &fcomp, NULL); + bfa_pending_q_init(&cb_qe, bfad_stats_comp, &fcomp, NULL); spin_lock_irqsave(&bfad->bfad_lock, flags); iocmd->status = bfa_fcport_clear_stats(&bfad->bfa, &cb_qe); @@ -2453,7 +2453,7 @@ bfad_iocmd_qos_get_stats(struct bfad_s *bfad, void *cmd) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); init_completion(&fcomp.comp); - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, + bfa_pending_q_init(&cb_qe, bfad_stats_comp, &fcomp, &iocmd->stats); spin_lock_irqsave(&bfad->bfad_lock, flags); @@ -2484,7 +2484,7 @@ bfad_iocmd_qos_reset_stats(struct bfad_s *bfad, void *cmd) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); init_completion(&fcomp.comp); - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, + bfa_pending_q_init(&cb_qe, bfad_stats_comp, &fcomp, NULL); spin_lock_irqsave(&bfad->bfad_lock, flags); diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h index cfcfff4..18a01f7 100644 --- a/drivers/scsi/bfa/bfad_drv.h +++ b/drivers/scsi/bfa/bfad_drv.h @@ -187,8 +187,10 @@ union bfad_tmp_buf { /* * BFAD (PCI function) data structure */ +enum bfad_sm_event; + struct bfad_s { - bfa_sm_t sm; /* state machine */ + void (*sm)(struct bfad_s *, enum bfad_sm_event); /* state machine */ struct list_head list_entry; struct bfa_s bfa; struct bfa_fcs_s bfa_fcs; @@ -309,6 +311,7 @@ void bfad_fcs_stop(struct bfad_s *bfad); void bfad_remove_intr(struct bfad_s *bfad); void bfad_hal_mem_release(struct bfad_s *bfad); void bfad_hcb_comp(void *arg, bfa_status_t status); +void bfad_stats_comp(void *arg, bfa_boolean_t _status); int bfad_setup_intr(struct bfad_s *bfad); void bfad_remove_intr(struct bfad_s *bfad); diff --git a/drivers/scsi/csiostor/csio_defs.h b/drivers/scsi/csiostor/csio_defs.h index c38017b..3268e62 100644 --- a/drivers/scsi/csiostor/csio_defs.h +++ b/drivers/scsi/csiostor/csio_defs.h @@ -73,7 +73,8 @@ csio_list_deleted(struct list_head *list) #define csio_list_prev(elem) (((struct list_head *)(elem))->prev) /* State machine */ -typedef void (*csio_sm_state_t)(void *, uint32_t); +struct csio_sm; +typedef void (*csio_sm_state_t)(struct csio_sm *, uint32_t); struct csio_sm { struct list_head sm_list; @@ -81,9 +82,9 @@ struct csio_sm { }; static inline void -csio_set_state(void *smp, void *state) +csio_set_state(struct csio_sm *smp, csio_sm_state_t state) { - ((struct csio_sm *)smp)->sm_state = (csio_sm_state_t)state; + smp->sm_state = state; } static inline void @@ -93,21 +94,21 @@ csio_init_state(struct csio_sm *smp, void *state) } static inline void -csio_post_event(void *smp, uint32_t evt) +csio_post_event(struct csio_sm *smp, uint32_t evt) { - ((struct csio_sm *)smp)->sm_state(smp, evt); + smp->sm_state(smp, evt); } static inline csio_sm_state_t -csio_get_state(void *smp) +csio_get_state(struct csio_sm *smp) { - return ((struct csio_sm *)smp)->sm_state; + return smp->sm_state; } static inline bool -csio_match_state(void *smp, void *state) +csio_match_state(struct csio_sm *smp, csio_sm_state_t state) { - return (csio_get_state(smp) == (csio_sm_state_t)state); + return (csio_get_state(smp) == state); } #define CSIO_ASSERT(cond) BUG_ON(!(cond)) diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c index 5be0086..e869d00 100644 --- a/drivers/scsi/csiostor/csio_hw.c +++ b/drivers/scsi/csiostor/csio_hw.c @@ -89,15 +89,15 @@ static void csio_mgmtm_cleanup(struct csio_mgmtm *); static void csio_hw_mbm_cleanup(struct csio_hw *); /* State machine forward declarations */ -static void csio_hws_uninit(struct csio_hw *, enum csio_hw_ev); -static void csio_hws_configuring(struct csio_hw *, enum csio_hw_ev); -static void csio_hws_initializing(struct csio_hw *, enum csio_hw_ev); -static void csio_hws_ready(struct csio_hw *, enum csio_hw_ev); -static void csio_hws_quiescing(struct csio_hw *, enum csio_hw_ev); -static void csio_hws_quiesced(struct csio_hw *, enum csio_hw_ev); -static void csio_hws_resetting(struct csio_hw *, enum csio_hw_ev); -static void csio_hws_removing(struct csio_hw *, enum csio_hw_ev); -static void csio_hws_pcierr(struct csio_hw *, enum csio_hw_ev); +static void csio_hws_uninit(struct csio_sm *, uint32_t); +static void csio_hws_configuring(struct csio_sm *, uint32_t); +static void csio_hws_initializing(struct csio_sm *, uint32_t); +static void csio_hws_ready(struct csio_sm *, uint32_t); +static void csio_hws_quiescing(struct csio_sm *, uint32_t); +static void csio_hws_quiesced(struct csio_sm *, uint32_t); +static void csio_hws_resetting(struct csio_sm *, uint32_t); +static void csio_hws_removing(struct csio_sm *, uint32_t); +static void csio_hws_pcierr(struct csio_sm *, uint32_t); static void csio_hw_initialize(struct csio_hw *hw); static void csio_evtq_stop(struct csio_hw *hw); @@ -105,12 +105,12 @@ static void csio_evtq_start(struct csio_hw *hw); int csio_is_hw_ready(struct csio_hw *hw) { - return csio_match_state(hw, csio_hws_ready); + return csio_match_state(&hw->sm, csio_hws_ready); } int csio_is_hw_removing(struct csio_hw *hw) { - return csio_match_state(hw, csio_hws_removing); + return csio_match_state(&hw->sm, csio_hws_removing); } @@ -2388,8 +2388,11 @@ csio_hw_fatal_err(struct csio_hw *hw) * */ static void -csio_hws_uninit(struct csio_hw *hw, enum csio_hw_ev evt) +csio_hws_uninit(struct csio_sm *_hw, uint32_t _evt) { + struct csio_hw *hw = container_of(_hw, struct csio_hw, sm); + enum csio_hw_ev evt = _evt; + hw->prev_evt = hw->cur_evt; hw->cur_evt = evt; CSIO_INC_STATS(hw, n_evt_sm[evt]); @@ -2413,8 +2416,11 @@ csio_hws_uninit(struct csio_hw *hw, enum csio_hw_ev evt) * */ static void -csio_hws_configuring(struct csio_hw *hw, enum csio_hw_ev evt) +csio_hws_configuring(struct csio_sm *_hw, uint32_t _evt) { + struct csio_hw *hw = container_of(_hw, struct csio_hw, sm); + enum csio_hw_ev evt = _evt; + hw->prev_evt = hw->cur_evt; hw->cur_evt = evt; CSIO_INC_STATS(hw, n_evt_sm[evt]); @@ -2451,8 +2457,11 @@ csio_hws_configuring(struct csio_hw *hw, enum csio_hw_ev evt) * */ static void -csio_hws_initializing(struct csio_hw *hw, enum csio_hw_ev evt) +csio_hws_initializing(struct csio_sm *_hw, uint32_t _evt) { + struct csio_hw *hw = container_of(_hw, struct csio_hw, sm); + enum csio_hw_ev evt = _evt; + hw->prev_evt = hw->cur_evt; hw->cur_evt = evt; CSIO_INC_STATS(hw, n_evt_sm[evt]); @@ -2489,8 +2498,11 @@ csio_hws_initializing(struct csio_hw *hw, enum csio_hw_ev evt) * */ static void -csio_hws_ready(struct csio_hw *hw, enum csio_hw_ev evt) +csio_hws_ready(struct csio_sm *_hw, uint32_t _evt) { + struct csio_hw *hw = container_of(_hw, struct csio_hw, sm); + enum csio_hw_ev evt = _evt; + /* Remember the event */ hw->evtflag = evt; @@ -2538,8 +2550,11 @@ csio_hws_ready(struct csio_hw *hw, enum csio_hw_ev evt) * */ static void -csio_hws_quiescing(struct csio_hw *hw, enum csio_hw_ev evt) +csio_hws_quiescing(struct csio_sm *_hw, uint32_t _evt) { + struct csio_hw *hw = container_of(_hw, struct csio_hw, sm); + enum csio_hw_ev evt = _evt; + hw->prev_evt = hw->cur_evt; hw->cur_evt = evt; CSIO_INC_STATS(hw, n_evt_sm[evt]); @@ -2598,8 +2613,11 @@ csio_hws_quiescing(struct csio_hw *hw, enum csio_hw_ev evt) * */ static void -csio_hws_quiesced(struct csio_hw *hw, enum csio_hw_ev evt) +csio_hws_quiesced(struct csio_sm *_hw, uint32_t _evt) { + struct csio_hw *hw = container_of(_hw, struct csio_hw, sm); + enum csio_hw_ev evt = _evt; + hw->prev_evt = hw->cur_evt; hw->cur_evt = evt; CSIO_INC_STATS(hw, n_evt_sm[evt]); @@ -2623,8 +2641,11 @@ csio_hws_quiesced(struct csio_hw *hw, enum csio_hw_ev evt) * */ static void -csio_hws_resetting(struct csio_hw *hw, enum csio_hw_ev evt) +csio_hws_resetting(struct csio_sm *_hw, uint32_t _evt) { + struct csio_hw *hw = container_of(_hw, struct csio_hw, sm); + enum csio_hw_ev evt = _evt; + hw->prev_evt = hw->cur_evt; hw->cur_evt = evt; CSIO_INC_STATS(hw, n_evt_sm[evt]); @@ -2649,8 +2670,11 @@ csio_hws_resetting(struct csio_hw *hw, enum csio_hw_ev evt) * */ static void -csio_hws_removing(struct csio_hw *hw, enum csio_hw_ev evt) +csio_hws_removing(struct csio_sm *_hw, uint32_t _evt) { + struct csio_hw *hw = container_of(_hw, struct csio_hw, sm); + enum csio_hw_ev evt = _evt; + hw->prev_evt = hw->cur_evt; hw->cur_evt = evt; CSIO_INC_STATS(hw, n_evt_sm[evt]); @@ -2684,8 +2708,11 @@ csio_hws_removing(struct csio_hw *hw, enum csio_hw_ev evt) * */ static void -csio_hws_pcierr(struct csio_hw *hw, enum csio_hw_ev evt) +csio_hws_pcierr(struct csio_sm *_hw, uint32_t _evt) { + struct csio_hw *hw = container_of(_hw, struct csio_hw, sm); + enum csio_hw_ev evt = _evt; + hw->prev_evt = hw->cur_evt; hw->cur_evt = evt; CSIO_INC_STATS(hw, n_evt_sm[evt]); @@ -3845,7 +3872,7 @@ csio_hw_start(struct csio_hw *hw) if (csio_is_hw_ready(hw)) return 0; - else if (csio_match_state(hw, csio_hws_uninit)) + else if (csio_match_state(&hw->sm, csio_hws_uninit)) return -EINVAL; else return -ENODEV; diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c index 28a9c7d..3bdcd86 100644 --- a/drivers/scsi/csiostor/csio_init.c +++ b/drivers/scsi/csiostor/csio_init.c @@ -1059,7 +1059,7 @@ static void csio_remove_one(struct pci_dev *pdev) * */ static pci_ers_result_t -csio_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) +csio_pci_error_detected(struct pci_dev *pdev, enum pci_channel_state state) { struct csio_hw *hw = pci_get_drvdata(pdev); diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c index be5ee2d..5d4cf04 100644 --- a/drivers/scsi/csiostor/csio_lnode.c +++ b/drivers/scsi/csiostor/csio_lnode.c @@ -55,10 +55,10 @@ int csio_fdmi_enable = 1; #define PORT_ID_PTR(_x) ((uint8_t *)(&_x) + 1) /* Lnode SM declarations */ -static void csio_lns_uninit(struct csio_lnode *, enum csio_ln_ev); -static void csio_lns_online(struct csio_lnode *, enum csio_ln_ev); -static void csio_lns_ready(struct csio_lnode *, enum csio_ln_ev); -static void csio_lns_offline(struct csio_lnode *, enum csio_ln_ev); +static void csio_lns_uninit(struct csio_sm *, uint32_t); +static void csio_lns_online(struct csio_sm *, uint32_t); +static void csio_lns_ready(struct csio_sm *, uint32_t); +static void csio_lns_offline(struct csio_sm *, uint32_t); static int csio_ln_mgmt_submit_req(struct csio_ioreq *, void (*io_cbfn) (struct csio_hw *, struct csio_ioreq *), @@ -1084,7 +1084,7 @@ csio_handle_link_down(struct csio_hw *hw, uint8_t portid, uint32_t fcfi, int csio_is_lnode_ready(struct csio_lnode *ln) { - return (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)); + return (csio_get_state(&ln->sm) == csio_lns_ready); } /*****************************************************************************/ @@ -1100,8 +1100,10 @@ csio_is_lnode_ready(struct csio_lnode *ln) * Return - none. */ static void -csio_lns_uninit(struct csio_lnode *ln, enum csio_ln_ev evt) +csio_lns_uninit(struct csio_sm *_ln, uint32_t _evt) { + struct csio_lnode *ln = container_of(_ln, struct csio_lnode, sm); + enum csio_ln_ev evt = _evt; struct csio_hw *hw = csio_lnode_to_hw(ln); struct csio_lnode *rln = hw->rln; int rv; @@ -1153,8 +1155,10 @@ csio_lns_uninit(struct csio_lnode *ln, enum csio_ln_ev evt) * Return - none. */ static void -csio_lns_online(struct csio_lnode *ln, enum csio_ln_ev evt) +csio_lns_online(struct csio_sm *_ln, uint32_t _evt) { + struct csio_lnode *ln = container_of(_ln, struct csio_lnode, sm); + enum csio_ln_ev evt = _evt; struct csio_hw *hw = csio_lnode_to_hw(ln); CSIO_INC_STATS(ln, n_evt_sm[evt]); @@ -1205,8 +1209,10 @@ csio_lns_online(struct csio_lnode *ln, enum csio_ln_ev evt) * Return - none. */ static void -csio_lns_ready(struct csio_lnode *ln, enum csio_ln_ev evt) +csio_lns_ready(struct csio_sm *_ln, uint32_t _evt) { + struct csio_lnode *ln = container_of(_ln, struct csio_lnode, sm); + enum csio_ln_ev evt = _evt; struct csio_hw *hw = csio_lnode_to_hw(ln); CSIO_INC_STATS(ln, n_evt_sm[evt]); @@ -1279,8 +1285,10 @@ csio_lns_ready(struct csio_lnode *ln, enum csio_ln_ev evt) * Return - none. */ static void -csio_lns_offline(struct csio_lnode *ln, enum csio_ln_ev evt) +csio_lns_offline(struct csio_sm *_ln, uint32_t _evt) { + struct csio_lnode *ln = container_of(_ln, struct csio_lnode, sm); + enum csio_ln_ev evt = _evt; struct csio_hw *hw = csio_lnode_to_hw(ln); struct csio_lnode *rln = hw->rln; int rv; @@ -1356,15 +1364,15 @@ csio_free_fcfinfo(struct kref *kref) void csio_lnode_state_to_str(struct csio_lnode *ln, int8_t *str) { - if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_uninit)) { + if (csio_get_state(&ln->sm) == csio_lns_uninit) { strcpy(str, "UNINIT"); return; } - if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)) { + if (csio_get_state(&ln->sm) == csio_lns_ready) { strcpy(str, "READY"); return; } - if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_offline)) { + if (csio_get_state(&ln->sm) == csio_lns_offline) { strcpy(str, "OFFLINE"); return; } diff --git a/drivers/scsi/csiostor/csio_rnode.c b/drivers/scsi/csiostor/csio_rnode.c index e9c3b04..4ba3a59 100644 --- a/drivers/scsi/csiostor/csio_rnode.c +++ b/drivers/scsi/csiostor/csio_rnode.c @@ -46,10 +46,10 @@ static int csio_rnode_init(struct csio_rnode *, struct csio_lnode *); static void csio_rnode_exit(struct csio_rnode *); /* Static machine forward declarations */ -static void csio_rns_uninit(struct csio_rnode *, enum csio_rn_ev); -static void csio_rns_ready(struct csio_rnode *, enum csio_rn_ev); -static void csio_rns_offline(struct csio_rnode *, enum csio_rn_ev); -static void csio_rns_disappeared(struct csio_rnode *, enum csio_rn_ev); +static void csio_rns_uninit(struct csio_sm *, uint32_t); +static void csio_rns_ready(struct csio_sm *, uint32_t); +static void csio_rns_offline(struct csio_sm *, uint32_t); +static void csio_rns_disappeared(struct csio_sm *, uint32_t); /* RNF event mapping */ static enum csio_rn_ev fwevt_to_rnevt[] = { @@ -88,13 +88,13 @@ static enum csio_rn_ev fwevt_to_rnevt[] = { int csio_is_rnode_ready(struct csio_rnode *rn) { - return csio_match_state(rn, csio_rns_ready); + return csio_match_state(&rn->sm, csio_rns_ready); } static int csio_is_rnode_uninit(struct csio_rnode *rn) { - return csio_match_state(rn, csio_rns_uninit); + return csio_match_state(&rn->sm, csio_rns_uninit); } static int @@ -601,8 +601,10 @@ __csio_unreg_rnode(struct csio_rnode *rn) * */ static void -csio_rns_uninit(struct csio_rnode *rn, enum csio_rn_ev evt) +csio_rns_uninit(struct csio_sm *_rn, uint32_t _evt) { + struct csio_rnode *rn = container_of(_rn, struct csio_rnode, sm); + enum csio_rn_ev evt = _evt; struct csio_lnode *ln = csio_rnode_to_lnode(rn); int ret = 0; @@ -641,8 +643,10 @@ csio_rns_uninit(struct csio_rnode *rn, enum csio_rn_ev evt) * */ static void -csio_rns_ready(struct csio_rnode *rn, enum csio_rn_ev evt) +csio_rns_ready(struct csio_sm *_rn, uint32_t _evt) { + struct csio_rnode *rn = container_of(_rn, struct csio_rnode, sm); + enum csio_rn_ev evt = _evt; struct csio_lnode *ln = csio_rnode_to_lnode(rn); int ret = 0; @@ -726,8 +730,10 @@ csio_rns_ready(struct csio_rnode *rn, enum csio_rn_ev evt) * */ static void -csio_rns_offline(struct csio_rnode *rn, enum csio_rn_ev evt) +csio_rns_offline(struct csio_sm *_rn, uint32_t _evt) { + struct csio_rnode *rn = container_of(_rn, struct csio_rnode, sm); + enum csio_rn_ev evt = _evt; struct csio_lnode *ln = csio_rnode_to_lnode(rn); int ret = 0; @@ -785,8 +791,10 @@ csio_rns_offline(struct csio_rnode *rn, enum csio_rn_ev evt) * */ static void -csio_rns_disappeared(struct csio_rnode *rn, enum csio_rn_ev evt) +csio_rns_disappeared(struct csio_sm *_rn, uint32_t _evt) { + struct csio_rnode *rn = container_of(_rn, struct csio_rnode, sm); + enum csio_rn_ev evt = _evt; struct csio_lnode *ln = csio_rnode_to_lnode(rn); int ret = 0; diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c index dab0d3f..770ffbf 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -65,12 +65,12 @@ static int csio_ddp_descs = 128; static int csio_do_abrt_cls(struct csio_hw *, struct csio_ioreq *, bool); -static void csio_scsis_uninit(struct csio_ioreq *, enum csio_scsi_ev); -static void csio_scsis_io_active(struct csio_ioreq *, enum csio_scsi_ev); -static void csio_scsis_tm_active(struct csio_ioreq *, enum csio_scsi_ev); -static void csio_scsis_aborting(struct csio_ioreq *, enum csio_scsi_ev); -static void csio_scsis_closing(struct csio_ioreq *, enum csio_scsi_ev); -static void csio_scsis_shost_cmpl_await(struct csio_ioreq *, enum csio_scsi_ev); +static void csio_scsis_uninit(struct csio_sm *, uint32_t); +static void csio_scsis_io_active(struct csio_sm *, uint32_t); +static void csio_scsis_tm_active(struct csio_sm *, uint32_t); +static void csio_scsis_aborting(struct csio_sm *, uint32_t); +static void csio_scsis_closing(struct csio_sm *, uint32_t); +static void csio_scsis_shost_cmpl_await(struct csio_sm *, uint32_t); /* * csio_scsi_match_io - Match an ioreq with the given SCSI level data. @@ -700,8 +700,10 @@ csio_scsi_abrt_cls(struct csio_ioreq *req, bool abort) /* START: SCSI SM */ /*****************************************************************************/ static void -csio_scsis_uninit(struct csio_ioreq *req, enum csio_scsi_ev evt) +csio_scsis_uninit(struct csio_sm *_req, uint32_t _evt) { + struct csio_ioreq *req = container_of(_req, struct csio_ioreq, sm); + enum csio_scsi_ev evt = _evt; struct csio_hw *hw = req->lnode->hwp; struct csio_scsim *scsim = csio_hw_to_scsim(hw); @@ -770,8 +772,10 @@ csio_scsis_uninit(struct csio_ioreq *req, enum csio_scsi_ev evt) } static void -csio_scsis_io_active(struct csio_ioreq *req, enum csio_scsi_ev evt) +csio_scsis_io_active(struct csio_sm *_req, uint32_t _evt) { + struct csio_ioreq *req = container_of(_req, struct csio_ioreq, sm); + enum csio_scsi_ev evt = _evt; struct csio_hw *hw = req->lnode->hwp; struct csio_scsim *scm = csio_hw_to_scsim(hw); struct csio_rnode *rn; @@ -842,8 +846,10 @@ csio_scsis_io_active(struct csio_ioreq *req, enum csio_scsi_ev evt) } static void -csio_scsis_tm_active(struct csio_ioreq *req, enum csio_scsi_ev evt) +csio_scsis_tm_active(struct csio_sm *_req, uint32_t _evt) { + struct csio_ioreq *req = container_of(_req, struct csio_ioreq, sm); + enum csio_scsi_ev evt = _evt; struct csio_hw *hw = req->lnode->hwp; struct csio_scsim *scm = csio_hw_to_scsim(hw); @@ -885,8 +891,10 @@ csio_scsis_tm_active(struct csio_ioreq *req, enum csio_scsi_ev evt) } static void -csio_scsis_aborting(struct csio_ioreq *req, enum csio_scsi_ev evt) +csio_scsis_aborting(struct csio_sm *_req, uint32_t _evt) { + struct csio_ioreq *req = container_of(_req, struct csio_ioreq, sm); + enum csio_scsi_ev evt = _evt; struct csio_hw *hw = req->lnode->hwp; struct csio_scsim *scm = csio_hw_to_scsim(hw); @@ -982,8 +990,10 @@ csio_scsis_aborting(struct csio_ioreq *req, enum csio_scsi_ev evt) } static void -csio_scsis_closing(struct csio_ioreq *req, enum csio_scsi_ev evt) +csio_scsis_closing(struct csio_sm *_req, uint32_t _evt) { + struct csio_ioreq *req = container_of(_req, struct csio_ioreq, sm); + enum csio_scsi_ev evt = _evt; struct csio_hw *hw = req->lnode->hwp; struct csio_scsim *scm = csio_hw_to_scsim(hw); @@ -1046,8 +1056,11 @@ csio_scsis_closing(struct csio_ioreq *req, enum csio_scsi_ev evt) } static void -csio_scsis_shost_cmpl_await(struct csio_ioreq *req, enum csio_scsi_ev evt) +csio_scsis_shost_cmpl_await(struct csio_sm *_req, uint32_t _evt) { + struct csio_ioreq *req = container_of(_req, struct csio_ioreq, sm); + enum csio_scsi_ev evt = _evt; + switch (evt) { case CSIO_SCSIE_ABORT: case CSIO_SCSIE_CLOSE: diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c index 375c536..618843b 100644 --- a/drivers/scsi/fcoe/fcoe_transport.c +++ b/drivers/scsi/fcoe/fcoe_transport.c @@ -32,13 +32,13 @@ MODULE_AUTHOR("Open-FCoE.org"); MODULE_DESCRIPTION("FIP discovery protocol and FCoE transport for FCoE HBAs"); MODULE_LICENSE("GPL v2"); -static int fcoe_transport_create(const char *, struct kernel_param *); -static int fcoe_transport_destroy(const char *, struct kernel_param *); +static int fcoe_transport_create(const char *, const struct kernel_param *); +static int fcoe_transport_destroy(const char *, const struct kernel_param *); static int fcoe_transport_show(char *buffer, const struct kernel_param *kp); static struct fcoe_transport *fcoe_transport_lookup(struct net_device *device); static struct fcoe_transport *fcoe_netdev_map_lookup(struct net_device *device); -static int fcoe_transport_enable(const char *, struct kernel_param *); -static int fcoe_transport_disable(const char *, struct kernel_param *); +static int fcoe_transport_enable(const char *, const struct kernel_param *); +static int fcoe_transport_disable(const char *, const struct kernel_param *); static int libfcoe_device_notification(struct notifier_block *notifier, ulong event, void *ptr); @@ -865,7 +865,7 @@ EXPORT_SYMBOL(fcoe_ctlr_destroy_store); * * Returns: 0 for success */ -static int fcoe_transport_create(const char *buffer, struct kernel_param *kp) +static int fcoe_transport_create(const char *buffer, const struct kernel_param *kp) { int rc = -ENODEV; struct net_device *netdev = NULL; @@ -930,7 +930,7 @@ static int fcoe_transport_create(const char *buffer, struct kernel_param *kp) * * Returns: 0 for success */ -static int fcoe_transport_destroy(const char *buffer, struct kernel_param *kp) +static int fcoe_transport_destroy(const char *buffer, const struct kernel_param *kp) { int rc = -ENODEV; struct net_device *netdev = NULL; @@ -974,7 +974,7 @@ static int fcoe_transport_destroy(const char *buffer, struct kernel_param *kp) * * Returns: 0 for success */ -static int fcoe_transport_disable(const char *buffer, struct kernel_param *kp) +static int fcoe_transport_disable(const char *buffer, const struct kernel_param *kp) { int rc = -ENODEV; struct net_device *netdev = NULL; @@ -1008,7 +1008,7 @@ static int fcoe_transport_disable(const char *buffer, struct kernel_param *kp) * * Returns: 0 for success */ -static int fcoe_transport_enable(const char *buffer, struct kernel_param *kp) +static int fcoe_transport_enable(const char *buffer, const struct kernel_param *kp) { int rc = -ENODEV; struct net_device *netdev = NULL; diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index f838bd7..0a7bb19 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -990,7 +990,7 @@ static void ipr_send_command(struct ipr_cmnd *ipr_cmd) **/ static void ipr_do_req(struct ipr_cmnd *ipr_cmd, void (*done) (struct ipr_cmnd *), - void (*timeout_func) (struct ipr_cmnd *), u32 timeout) + void (*timeout_func) (unsigned long), u32 timeout) { list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_pending_q); @@ -998,7 +998,7 @@ static void ipr_do_req(struct ipr_cmnd *ipr_cmd, ipr_cmd->timer.data = (unsigned long) ipr_cmd; ipr_cmd->timer.expires = jiffies + timeout; - ipr_cmd->timer.function = (void (*)(unsigned long))timeout_func; + ipr_cmd->timer.function = timeout_func; add_timer(&ipr_cmd->timer); @@ -1080,7 +1080,7 @@ static void ipr_init_ioadl(struct ipr_cmnd *ipr_cmd, dma_addr_t dma_addr, * none **/ static void ipr_send_blocking_cmd(struct ipr_cmnd *ipr_cmd, - void (*timeout_func) (struct ipr_cmnd *ipr_cmd), + void (*timeout_func) (unsigned long ipr_cmd), u32 timeout) { struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; @@ -2664,8 +2664,9 @@ static void ipr_process_error(struct ipr_cmnd *ipr_cmd) * Return value: * none **/ -static void ipr_timeout(struct ipr_cmnd *ipr_cmd) +static void ipr_timeout(unsigned long _ipr_cmd) { + struct ipr_cmnd *ipr_cmd = (struct ipr_cmnd *)_ipr_cmd; unsigned long lock_flags = 0; struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; @@ -2696,8 +2697,9 @@ static void ipr_timeout(struct ipr_cmnd *ipr_cmd) * Return value: * none **/ -static void ipr_oper_timeout(struct ipr_cmnd *ipr_cmd) +static void ipr_oper_timeout(unsigned long _ipr_cmd) { + struct ipr_cmnd *ipr_cmd = (struct ipr_cmnd *)_ipr_cmd; unsigned long lock_flags = 0; struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; @@ -5449,8 +5451,9 @@ static void ipr_bus_reset_done(struct ipr_cmnd *ipr_cmd) * Return value: * none **/ -static void ipr_abort_timeout(struct ipr_cmnd *ipr_cmd) +static void ipr_abort_timeout(unsigned long _ipr_cmd) { + struct ipr_cmnd *ipr_cmd = (struct ipr_cmnd *)_ipr_cmd; struct ipr_cmnd *reset_cmd; struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; struct ipr_cmd_pkt *cmd_pkt; @@ -8271,8 +8274,9 @@ static int ipr_ioafp_identify_hrrq(struct ipr_cmnd *ipr_cmd) * Return value: * none **/ -static void ipr_reset_timer_done(struct ipr_cmnd *ipr_cmd) +static void ipr_reset_timer_done(unsigned long _ipr_cmd) { + struct ipr_cmnd *ipr_cmd = (struct ipr_cmnd *)_ipr_cmd; struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; unsigned long lock_flags = 0; @@ -8310,7 +8314,7 @@ static void ipr_reset_start_timer(struct ipr_cmnd *ipr_cmd, ipr_cmd->timer.data = (unsigned long) ipr_cmd; ipr_cmd->timer.expires = jiffies + timeout; - ipr_cmd->timer.function = (void (*)(unsigned long))ipr_reset_timer_done; + ipr_cmd->timer.function = ipr_reset_timer_done; add_timer(&ipr_cmd->timer); } @@ -8396,7 +8400,7 @@ static int ipr_reset_next_stage(struct ipr_cmnd *ipr_cmd) ipr_cmd->timer.data = (unsigned long) ipr_cmd; ipr_cmd->timer.expires = jiffies + stage_time * HZ; - ipr_cmd->timer.function = (void (*)(unsigned long))ipr_oper_timeout; + ipr_cmd->timer.function = ipr_oper_timeout; ipr_cmd->done = ipr_reset_ioa_job; add_timer(&ipr_cmd->timer); @@ -8468,7 +8472,7 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd) ipr_cmd->timer.data = (unsigned long) ipr_cmd; ipr_cmd->timer.expires = jiffies + (ioa_cfg->transop_timeout * HZ); - ipr_cmd->timer.function = (void (*)(unsigned long))ipr_oper_timeout; + ipr_cmd->timer.function = ipr_oper_timeout; ipr_cmd->done = ipr_reset_ioa_job; add_timer(&ipr_cmd->timer); list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_pending_q); @@ -9458,7 +9462,7 @@ static void ipr_pci_perm_failure(struct pci_dev *pdev) * PCI_ERS_RESULT_NEED_RESET or PCI_ERS_RESULT_DISCONNECT */ static pci_ers_result_t ipr_pci_error_detected(struct pci_dev *pdev, - pci_channel_state_t state) + enum pci_channel_state state) { switch (state) { case pci_channel_io_frozen: diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 8799990..3d36dee 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -105,7 +105,7 @@ _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc); * */ static int -_scsih_set_fwfault_debug(const char *val, struct kernel_param *kp) +_scsih_set_fwfault_debug(const char *val, const struct kernel_param *kp) { int ret = param_set_int(val, kp); struct MPT3SAS_ADAPTER *ioc; diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 33ff691..483fe89 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -281,7 +281,7 @@ struct _scsi_io_transfer { * Note: The logging levels are defined in mpt3sas_debug.h. */ static int -_scsih_set_debug_level(const char *val, struct kernel_param *kp) +_scsih_set_debug_level(const char *val, const struct kernel_param *kp) { int ret = param_set_int(val, kp); struct MPT3SAS_ADAPTER *ioc; diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index b4d6cd8..5da9eee 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -557,8 +557,9 @@ static void pmcraid_reset_type(struct pmcraid_instance *pinstance) static void pmcraid_ioa_reset(struct pmcraid_cmd *); -static void pmcraid_bist_done(struct pmcraid_cmd *cmd) +static void pmcraid_bist_done(unsigned long _cmd) { + struct pmcraid_cmd *cmd = (struct pmcraid_cmd *)_cmd; struct pmcraid_instance *pinstance = cmd->drv_inst; unsigned long lock_flags; int rc; @@ -573,8 +574,7 @@ static void pmcraid_bist_done(struct pmcraid_cmd *cmd) cmd->timer.expires = jiffies + cmd->time_left; cmd->time_left = 0; cmd->timer.data = (unsigned long)cmd; - cmd->timer.function = - (void (*)(unsigned long))pmcraid_bist_done; + cmd->timer.function = pmcraid_bist_done; add_timer(&cmd->timer); } else { cmd->time_left = 0; @@ -607,7 +607,7 @@ static void pmcraid_start_bist(struct pmcraid_cmd *cmd) cmd->time_left = msecs_to_jiffies(PMCRAID_BIST_TIMEOUT); cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + msecs_to_jiffies(PMCRAID_BIST_TIMEOUT); - cmd->timer.function = (void (*)(unsigned long))pmcraid_bist_done; + cmd->timer.function = pmcraid_bist_done; add_timer(&cmd->timer); } @@ -617,8 +617,9 @@ static void pmcraid_start_bist(struct pmcraid_cmd *cmd) * Return value * None */ -static void pmcraid_reset_alert_done(struct pmcraid_cmd *cmd) +static void pmcraid_reset_alert_done(unsigned long _cmd) { + struct pmcraid_cmd *cmd = (struct pmcraid_cmd *)_cmd; struct pmcraid_instance *pinstance = cmd->drv_inst; u32 status = ioread32(pinstance->ioa_status); unsigned long lock_flags; @@ -639,8 +640,7 @@ static void pmcraid_reset_alert_done(struct pmcraid_cmd *cmd) cmd->time_left -= PMCRAID_CHECK_FOR_RESET_TIMEOUT; cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + PMCRAID_CHECK_FOR_RESET_TIMEOUT; - cmd->timer.function = - (void (*)(unsigned long))pmcraid_reset_alert_done; + cmd->timer.function = pmcraid_reset_alert_done; add_timer(&cmd->timer); } } @@ -678,8 +678,7 @@ static void pmcraid_reset_alert(struct pmcraid_cmd *cmd) cmd->time_left = PMCRAID_RESET_TIMEOUT; cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + PMCRAID_CHECK_FOR_RESET_TIMEOUT; - cmd->timer.function = - (void (*)(unsigned long))pmcraid_reset_alert_done; + cmd->timer.function = pmcraid_reset_alert_done; add_timer(&cmd->timer); iowrite32(DOORBELL_IOA_RESET_ALERT, @@ -704,8 +703,9 @@ static void pmcraid_reset_alert(struct pmcraid_cmd *cmd) * Return value: * None */ -static void pmcraid_timeout_handler(struct pmcraid_cmd *cmd) +static void pmcraid_timeout_handler(unsigned long _cmd) { + struct pmcraid_cmd *cmd = (struct pmcraid_cmd *)_cmd; struct pmcraid_instance *pinstance = cmd->drv_inst; unsigned long lock_flags; @@ -919,7 +919,7 @@ static void pmcraid_send_cmd( struct pmcraid_cmd *cmd, void (*cmd_done) (struct pmcraid_cmd *), unsigned long timeout, - void (*timeout_func) (struct pmcraid_cmd *) + void (*timeout_func) (unsigned long) ) { /* initialize done function */ @@ -929,7 +929,7 @@ static void pmcraid_send_cmd( /* setup timeout handler */ cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + timeout; - cmd->timer.function = (void (*)(unsigned long))timeout_func; + cmd->timer.function = timeout_func; add_timer(&cmd->timer); } @@ -1958,7 +1958,7 @@ static void pmcraid_soft_reset(struct pmcraid_cmd *cmd) cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + msecs_to_jiffies(PMCRAID_TRANSOP_TIMEOUT); - cmd->timer.function = (void (*)(unsigned long))pmcraid_timeout_handler; + cmd->timer.function = pmcraid_timeout_handler; if (!timer_pending(&cmd->timer)) add_timer(&cmd->timer); diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index a260cde..1b99d3b 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -245,7 +245,7 @@ static void kgdboc_put_char(u8 chr) kgdb_tty_line, chr); } -static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp) +static int param_set_kgdboc_var(const char *kmessage, const struct kernel_param *kp) { int len = strlen(kmessage); diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index b90ef96..48c94ba 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -41,12 +41,61 @@ static void dummycon_init(struct vc_data *vc, int init) vc_resize(vc, DUMMY_COLUMNS, DUMMY_ROWS); } -static int dummycon_dummy(void) +static void dummycon_deinit(struct vc_data *a) +{ +} + +static void dummycon_clear(struct vc_data *a, int b, int c, int d, int e) +{ +} + +static void dummycon_putc(struct vc_data *a, int b, int c, int d) +{ +} + +static void dummycon_putcs(struct vc_data *a, const unsigned short *b, int c, int d, int e) +{ +} + +static void dummycon_cursor(struct vc_data *a, int b) +{ +} + +static bool dummycon_scroll(struct vc_data *a, unsigned int b, unsigned int c, + enum con_scroll d, unsigned int e) +{ + return 0; +} + +static int dummycon_switch(struct vc_data *a) { return 0; } -#define DUMMY (void *)dummycon_dummy +static int dummycon_blank(struct vc_data *a, int b, int c) +{ + return 0; +} + +static int dummycon_font_set(struct vc_data *a, struct console_font *b, unsigned c) +{ + return 0; +} + +static int dummycon_font_get(struct vc_data *a, struct console_font *b) +{ + return 0; +} + +static int dummycon_font_default(struct vc_data *a, struct console_font *b , char *c) +{ + return 0; +} + +static int dummycon_font_copy(struct vc_data *a, int b) +{ + return 0; +} /* * The console `switch' structure for the dummy console @@ -58,16 +107,16 @@ const struct consw dummy_con = { .owner = THIS_MODULE, .con_startup = dummycon_startup, .con_init = dummycon_init, - .con_deinit = DUMMY, - .con_clear = DUMMY, - .con_putc = DUMMY, - .con_putcs = DUMMY, - .con_cursor = DUMMY, - .con_scroll = DUMMY, - .con_switch = DUMMY, - .con_blank = DUMMY, - .con_font_set = DUMMY, - .con_font_default = DUMMY, - .con_font_copy = DUMMY, + .con_deinit = dummycon_deinit, + .con_clear = dummycon_clear, + .con_putc = dummycon_putc, + .con_putcs = dummycon_putcs, + .con_cursor = dummycon_cursor, + .con_scroll = dummycon_scroll, + .con_switch = dummycon_switch, + .con_blank = dummycon_blank, + .con_font_set = dummycon_font_set, + .con_font_default = dummycon_font_default, + .con_font_copy = dummycon_font_copy, }; EXPORT_SYMBOL_GPL(dummy_con); diff --git a/fs/afs/file.c b/fs/afs/file.c index 510cba1..2e6fc23 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -140,12 +140,12 @@ static void afs_file_readpage_read_complete(struct page *page, /* * read page from file, directory or symlink, given a key to use */ -int afs_page_filler(void *data, struct page *page) +int afs_page_filler(struct file *data, struct page *page) { struct inode *inode = page->mapping->host; struct afs_vnode *vnode = AFS_FS_I(inode); struct afs_read *req; - struct key *key = data; + struct key *key = (struct file *)data; int ret; _enter("{%x},{%lu},{%lu}", key_serial(key), inode->i_ino, page->index); @@ -261,14 +261,14 @@ static int afs_readpage(struct file *file, struct page *page) if (file) { key = file->private_data; ASSERT(key != NULL); - ret = afs_page_filler(key, page); + ret = afs_page_filler((struct file *)key, page); } else { struct inode *inode = page->mapping->host; key = afs_request_key(AFS_FS_S(inode->i_sb)->volume->cell); if (IS_ERR(key)) { ret = PTR_ERR(key); } else { - ret = afs_page_filler(key, page); + ret = afs_page_filler((struct file *)key, page); key_put(key); } } diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 82e1655..ed42f21 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -485,7 +485,7 @@ extern const struct file_operations afs_file_operations; extern int afs_open(struct inode *, struct file *); extern int afs_release(struct inode *, struct file *); -extern int afs_page_filler(void *, struct page *); +extern int afs_page_filler(struct file *, struct page *); extern void afs_put_read(struct afs_read *); /* diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index 0ac6281..cec5adf 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c @@ -470,6 +470,11 @@ static int readpage_strip(void *data, struct page *page) return ret; } +static int readpage_filler(struct file *data, struct page *page) +{ + return readpage_strip(data, page); +} + static int exofs_readpages(struct file *file, struct address_space *mapping, struct list_head *pages, unsigned nr_pages) { @@ -478,7 +483,7 @@ static int exofs_readpages(struct file *file, struct address_space *mapping, _pcol_init(&pcol, nr_pages, mapping->host); - ret = read_cache_pages(mapping, pages, readpage_strip, &pcol); + ret = read_cache_pages(mapping, pages, readpage_filler, &pcol); if (ret) { EXOFS_ERR("read_cache_pages => %d\n", ret); return ret; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index cb7dff5..3bbbc0c 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -837,9 +837,9 @@ struct fuse_fill_data { unsigned nr_pages; }; -static int fuse_readpages_fill(void *_data, struct page *page) +static int fuse_readpages_fill(struct file *_data, struct page *page) { - struct fuse_fill_data *data = _data; + struct fuse_fill_data *data = (struct fuse_fill_data *)_data; struct fuse_req *req = data->req; struct inode *inode = data->inode; struct fuse_conn *fc = get_fuse_conn(inode); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 94a745a..a79e320 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -31,7 +31,7 @@ static struct kmem_cache *fuse_inode_cachep; struct list_head fuse_conn_list; DEFINE_MUTEX(fuse_mutex); -static int set_global_limit(const char *val, struct kernel_param *kp); +static int set_global_limit(const char *val, const struct kernel_param *kp); unsigned max_user_bgreq; module_param_call(max_user_bgreq, set_global_limit, param_get_uint, @@ -823,7 +823,7 @@ static void sanitize_global_limit(unsigned *limit) *limit = (1 << 16) - 1; } -static int set_global_limit(const char *val, struct kernel_param *kp) +static int set_global_limit(const char *val, const struct kernel_param *kp) { int rv; diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 809cbcc..6525c05 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -614,7 +614,7 @@ static struct ctl_table nlm_sysctl_root[] = { */ #define param_set_min_max(name, type, which_strtol, min, max) \ -static int param_set_##name(const char *val, struct kernel_param *kp) \ +static int param_set_##name(const char *val, const struct kernel_param *kp)\ { \ char *endp; \ __typeof__(type) num = which_strtol(val, &endp, 0); \ diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index bf2c436..d04d41b 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -671,8 +671,9 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, * We only need to convert from xdr once so future lookups are much simpler */ static -int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page* page) +int nfs_readdir_filler(struct file *_desc, struct page* page) { + nfs_readdir_descriptor_t *desc = (nfs_readdir_descriptor_t *)_desc; struct inode *inode = file_inode(desc->file); int ret; @@ -705,7 +706,7 @@ static struct page *get_cache_page(nfs_readdir_descriptor_t *desc) { return read_cache_page(desc->file->f_mapping, - desc->page_index, (filler_t *)nfs_readdir_filler, desc); + desc->page_index, nfs_readdir_filler, desc); } /* diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 48d7277..42dbf4f 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -354,7 +354,7 @@ struct nfs_readdesc { }; static int -readpage_async_filler(void *data, struct page *page) +readpage_async_filler(struct file *data, struct page *page) { struct nfs_readdesc *desc = (struct nfs_readdesc *)data; struct nfs_page *new; diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c index 06eb44b..53274f8 100644 --- a/fs/nfs/symlink.c +++ b/fs/nfs/symlink.c @@ -26,9 +26,10 @@ * and straight-forward than readdir caching. */ -static int nfs_symlink_filler(struct inode *inode, struct page *page) +static int nfs_symlink_filler(struct file *_inode, struct page *page) { int error; + struct inode *inode = (struct inode *)_inode; error = NFS_PROTO(inode)->readlink(inode, page, 0, PAGE_SIZE); if (error < 0) @@ -65,8 +66,7 @@ static const char *nfs_get_link(struct dentry *dentry, err = ERR_PTR(nfs_revalidate_mapping(inode, inode->i_mapping)); if (err) return err; - page = read_cache_page(&inode->i_data, 0, - (filler_t *)nfs_symlink_filler, inode); + page = read_cache_page(&inode->i_data, 0, nfs_symlink_filler, inode); if (IS_ERR(page)) return ERR_CAST(page); } diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2c61c6b..43a01c7 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -495,8 +495,9 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, } static __be32 -nfsd4_decode_stateid(struct nfsd4_compoundargs *argp, stateid_t *sid) +nfsd4_decode_stateid(struct nfsd4_compoundargs *argp, void *_sid) { + stateid_t *sid = _sid; DECODE_HEAD; READ_BUF(sizeof(stateid_t)); @@ -507,8 +508,9 @@ nfsd4_decode_stateid(struct nfsd4_compoundargs *argp, stateid_t *sid) } static __be32 -nfsd4_decode_access(struct nfsd4_compoundargs *argp, struct nfsd4_access *access) +nfsd4_decode_access(struct nfsd4_compoundargs *argp, void *_access) { + struct nfsd4_access *access = _access; DECODE_HEAD; READ_BUF(4); @@ -517,8 +519,9 @@ nfsd4_decode_access(struct nfsd4_compoundargs *argp, struct nfsd4_access *access DECODE_TAIL; } -static __be32 nfsd4_decode_cb_sec(struct nfsd4_compoundargs *argp, struct nfsd4_cb_sec *cbs) +static __be32 nfsd4_decode_cb_sec(struct nfsd4_compoundargs *argp, void *_cbs) { + struct nfsd4_cb_sec *cbs = _cbs; DECODE_HEAD; u32 dummy, uid, gid; char *machine_name; @@ -597,8 +600,9 @@ static __be32 nfsd4_decode_cb_sec(struct nfsd4_compoundargs *argp, struct nfsd4_ DECODE_TAIL; } -static __be32 nfsd4_decode_backchannel_ctl(struct nfsd4_compoundargs *argp, struct nfsd4_backchannel_ctl *bc) +static __be32 nfsd4_decode_backchannel_ctl(struct nfsd4_compoundargs *argp, void *_bc) { + struct nfsd4_backchannel_ctl *bc = _bc; DECODE_HEAD; READ_BUF(4); @@ -608,8 +612,9 @@ static __be32 nfsd4_decode_backchannel_ctl(struct nfsd4_compoundargs *argp, stru DECODE_TAIL; } -static __be32 nfsd4_decode_bind_conn_to_session(struct nfsd4_compoundargs *argp, struct nfsd4_bind_conn_to_session *bcts) +static __be32 nfsd4_decode_bind_conn_to_session(struct nfsd4_compoundargs *argp, void *_bcts) { + struct nfsd4_bind_conn_to_session *bcts = _bcts; DECODE_HEAD; READ_BUF(NFS4_MAX_SESSIONID_LEN + 8); @@ -621,8 +626,9 @@ static __be32 nfsd4_decode_bind_conn_to_session(struct nfsd4_compoundargs *argp, } static __be32 -nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close) +nfsd4_decode_close(struct nfsd4_compoundargs *argp, void *_close) { + struct nfsd4_close *close = _close; DECODE_HEAD; READ_BUF(4); @@ -634,8 +640,9 @@ nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close) static __be32 -nfsd4_decode_commit(struct nfsd4_compoundargs *argp, struct nfsd4_commit *commit) +nfsd4_decode_commit(struct nfsd4_compoundargs *argp, void *_commit) { + struct nfsd4_commit *commit = _commit; DECODE_HEAD; READ_BUF(12); @@ -646,8 +653,9 @@ nfsd4_decode_commit(struct nfsd4_compoundargs *argp, struct nfsd4_commit *commit } static __be32 -nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create) +nfsd4_decode_create(struct nfsd4_compoundargs *argp, void *_create) { + struct nfsd4_create *create = _create; DECODE_HEAD; READ_BUF(4); @@ -691,20 +699,25 @@ nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create } static inline __be32 -nfsd4_decode_delegreturn(struct nfsd4_compoundargs *argp, struct nfsd4_delegreturn *dr) +nfsd4_decode_delegreturn(struct nfsd4_compoundargs *argp, void *_dr) { + struct nfsd4_delegreturn *dr = _dr; + return nfsd4_decode_stateid(argp, &dr->dr_stateid); } static inline __be32 -nfsd4_decode_getattr(struct nfsd4_compoundargs *argp, struct nfsd4_getattr *getattr) +nfsd4_decode_getattr(struct nfsd4_compoundargs *argp, void *_getattr) { + struct nfsd4_getattr *getattr = _getattr; + return nfsd4_decode_bitmap(argp, getattr->ga_bmval); } static __be32 -nfsd4_decode_link(struct nfsd4_compoundargs *argp, struct nfsd4_link *link) +nfsd4_decode_link(struct nfsd4_compoundargs *argp, void *_link) { + struct nfsd4_link *link = _link; DECODE_HEAD; READ_BUF(4); @@ -718,8 +731,9 @@ nfsd4_decode_link(struct nfsd4_compoundargs *argp, struct nfsd4_link *link) } static __be32 -nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) +nfsd4_decode_lock(struct nfsd4_compoundargs *argp, void *_lock) { + struct nfsd4_lock *lock = _lock; DECODE_HEAD; /* @@ -758,8 +772,9 @@ nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) } static __be32 -nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, struct nfsd4_lockt *lockt) +nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, void *_lockt) { + struct nfsd4_lockt *lockt = _lockt; DECODE_HEAD; READ_BUF(32); @@ -777,8 +792,9 @@ nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, struct nfsd4_lockt *lockt) } static __be32 -nfsd4_decode_locku(struct nfsd4_compoundargs *argp, struct nfsd4_locku *locku) +nfsd4_decode_locku(struct nfsd4_compoundargs *argp, void *_locku) { + struct nfsd4_locku *locku = _locku; DECODE_HEAD; READ_BUF(8); @@ -797,8 +813,9 @@ nfsd4_decode_locku(struct nfsd4_compoundargs *argp, struct nfsd4_locku *locku) } static __be32 -nfsd4_decode_lookup(struct nfsd4_compoundargs *argp, struct nfsd4_lookup *lookup) +nfsd4_decode_lookup(struct nfsd4_compoundargs *argp, void *_lookup) { + struct nfsd4_lookup *lookup = _lookup; DECODE_HEAD; READ_BUF(4); @@ -896,8 +913,9 @@ static __be32 nfsd4_decode_opaque(struct nfsd4_compoundargs *argp, struct xdr_ne } static __be32 -nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) +nfsd4_decode_open(struct nfsd4_compoundargs *argp, void *_open) { + struct nfsd4_open *open = _open; DECODE_HEAD; u32 dummy; @@ -1012,8 +1030,9 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) } static __be32 -nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_open_confirm *open_conf) +nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, void *_open_conf) { + struct nfsd4_open_confirm *open_conf = _open_conf; DECODE_HEAD; if (argp->minorversion >= 1) @@ -1029,8 +1048,9 @@ nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_open_con } static __be32 -nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, struct nfsd4_open_downgrade *open_down) +nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, void *_open_down) { + struct nfsd4_open_downgrade *open_down = _open_down; DECODE_HEAD; status = nfsd4_decode_stateid(argp, &open_down->od_stateid); @@ -1049,8 +1069,9 @@ nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, struct nfsd4_open_d } static __be32 -nfsd4_decode_putfh(struct nfsd4_compoundargs *argp, struct nfsd4_putfh *putfh) +nfsd4_decode_putfh(struct nfsd4_compoundargs *argp, void *_putfh) { + struct nfsd4_putfh *putfh = _putfh; DECODE_HEAD; READ_BUF(4); @@ -1072,8 +1093,9 @@ nfsd4_decode_putpubfh(struct nfsd4_compoundargs *argp, void *p) } static __be32 -nfsd4_decode_read(struct nfsd4_compoundargs *argp, struct nfsd4_read *read) +nfsd4_decode_read(struct nfsd4_compoundargs *argp, void *_read) { + struct nfsd4_read *read = _read; DECODE_HEAD; status = nfsd4_decode_stateid(argp, &read->rd_stateid); @@ -1087,8 +1109,9 @@ nfsd4_decode_read(struct nfsd4_compoundargs *argp, struct nfsd4_read *read) } static __be32 -nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, struct nfsd4_readdir *readdir) +nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, void *_readdir) { + struct nfsd4_readdir *readdir = _readdir; DECODE_HEAD; READ_BUF(24); @@ -1103,8 +1126,9 @@ nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, struct nfsd4_readdir *read } static __be32 -nfsd4_decode_remove(struct nfsd4_compoundargs *argp, struct nfsd4_remove *remove) +nfsd4_decode_remove(struct nfsd4_compoundargs *argp, void *_remove) { + struct nfsd4_remove *remove = _remove; DECODE_HEAD; READ_BUF(4); @@ -1118,8 +1142,9 @@ nfsd4_decode_remove(struct nfsd4_compoundargs *argp, struct nfsd4_remove *remove } static __be32 -nfsd4_decode_rename(struct nfsd4_compoundargs *argp, struct nfsd4_rename *rename) +nfsd4_decode_rename(struct nfsd4_compoundargs *argp, void *_rename) { + struct nfsd4_rename *rename = _rename; DECODE_HEAD; READ_BUF(4); @@ -1139,7 +1164,7 @@ nfsd4_decode_rename(struct nfsd4_compoundargs *argp, struct nfsd4_rename *rename } static __be32 -nfsd4_decode_renew(struct nfsd4_compoundargs *argp, clientid_t *clientid) +nfsd4_decode_renew(struct nfsd4_compoundargs *argp, void *clientid) { DECODE_HEAD; @@ -1154,8 +1179,9 @@ nfsd4_decode_renew(struct nfsd4_compoundargs *argp, clientid_t *clientid) static __be32 nfsd4_decode_secinfo(struct nfsd4_compoundargs *argp, - struct nfsd4_secinfo *secinfo) + void *_secinfo) { + struct nfsd4_secinfo *secinfo = _secinfo; DECODE_HEAD; READ_BUF(4); @@ -1170,8 +1196,9 @@ nfsd4_decode_secinfo(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_secinfo_no_name(struct nfsd4_compoundargs *argp, - struct nfsd4_secinfo_no_name *sin) + void *_sin) { + struct nfsd4_secinfo_no_name *sin = _sin; DECODE_HEAD; READ_BUF(4); @@ -1180,8 +1207,9 @@ nfsd4_decode_secinfo_no_name(struct nfsd4_compoundargs *argp, } static __be32 -nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *setattr) +nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, void *_setattr) { + struct nfsd4_setattr *setattr = _setattr; __be32 status; status = nfsd4_decode_stateid(argp, &setattr->sa_stateid); @@ -1192,8 +1220,9 @@ nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *seta } static __be32 -nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, struct nfsd4_setclientid *setclientid) +nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, void *_setclientid) { + struct nfsd4_setclientid *setclientid = _setclientid; DECODE_HEAD; if (argp->minorversion >= 1) @@ -1222,8 +1251,9 @@ nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, struct nfsd4_setclient } static __be32 -nfsd4_decode_setclientid_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_setclientid_confirm *scd_c) +nfsd4_decode_setclientid_confirm(struct nfsd4_compoundargs *argp, void *_scd_c) { + struct nfsd4_setclientid_confirm *scd_c = _scd_c; DECODE_HEAD; if (argp->minorversion >= 1) @@ -1238,8 +1268,9 @@ nfsd4_decode_setclientid_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_s /* Also used for NVERIFY */ static __be32 -nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify) +nfsd4_decode_verify(struct nfsd4_compoundargs *argp, void *_verify) { + struct nfsd4_verify *verify = _verify; DECODE_HEAD; if ((status = nfsd4_decode_bitmap(argp, verify->ve_bmval))) @@ -1257,8 +1288,9 @@ nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify } static __be32 -nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) +nfsd4_decode_write(struct nfsd4_compoundargs *argp, void *_write) { + struct nfsd4_write *write = _write; int avail; int len; DECODE_HEAD; @@ -1306,8 +1338,9 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) } static __be32 -nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, struct nfsd4_release_lockowner *rlockowner) +nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, void *_rlockowner) { + struct nfsd4_release_lockowner *rlockowner = _rlockowner; DECODE_HEAD; if (argp->minorversion >= 1) @@ -1326,8 +1359,9 @@ nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, struct nfsd4_rel static __be32 nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, - struct nfsd4_exchange_id *exid) + void *_exid) { + struct nfsd4_exchange_id *exid = _exid; int dummy, tmp; DECODE_HEAD; @@ -1428,8 +1462,9 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_create_session(struct nfsd4_compoundargs *argp, - struct nfsd4_create_session *sess) + void *_sess) { + struct nfsd4_create_session *sess = _sess; DECODE_HEAD; u32 dummy; @@ -1480,8 +1515,9 @@ nfsd4_decode_create_session(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_destroy_session(struct nfsd4_compoundargs *argp, - struct nfsd4_destroy_session *destroy_session) + void *_destroy_session) { + struct nfsd4_destroy_session *destroy_session = _destroy_session; DECODE_HEAD; READ_BUF(NFS4_MAX_SESSIONID_LEN); COPYMEM(destroy_session->sessionid.data, NFS4_MAX_SESSIONID_LEN); @@ -1491,8 +1527,9 @@ nfsd4_decode_destroy_session(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_free_stateid(struct nfsd4_compoundargs *argp, - struct nfsd4_free_stateid *free_stateid) + void *_free_stateid) { + struct nfsd4_free_stateid *free_stateid = _free_stateid; DECODE_HEAD; READ_BUF(sizeof(stateid_t)); @@ -1504,8 +1541,9 @@ nfsd4_decode_free_stateid(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_sequence(struct nfsd4_compoundargs *argp, - struct nfsd4_sequence *seq) + void *_seq) { + struct nfsd4_sequence *seq = _seq; DECODE_HEAD; READ_BUF(NFS4_MAX_SESSIONID_LEN + 16); @@ -1519,8 +1557,9 @@ nfsd4_decode_sequence(struct nfsd4_compoundargs *argp, } static __be32 -nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_stateid *test_stateid) +nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, void *_test_stateid) { + struct nfsd4_test_stateid *test_stateid = _test_stateid; int i; __be32 *p, status; struct nfsd4_test_stateid_id *stateid; @@ -1554,8 +1593,9 @@ nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_sta goto out; } -static __be32 nfsd4_decode_destroy_clientid(struct nfsd4_compoundargs *argp, struct nfsd4_destroy_clientid *dc) +static __be32 nfsd4_decode_destroy_clientid(struct nfsd4_compoundargs *argp, void *_dc) { + struct nfsd4_destroy_clientid *dc = _dc; DECODE_HEAD; READ_BUF(8); @@ -1564,8 +1604,9 @@ static __be32 nfsd4_decode_destroy_clientid(struct nfsd4_compoundargs *argp, str DECODE_TAIL; } -static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, struct nfsd4_reclaim_complete *rc) +static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, void *_rc) { + struct nfsd4_reclaim_complete *rc = _rc; DECODE_HEAD; READ_BUF(4); @@ -1577,8 +1618,9 @@ static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, str #ifdef CONFIG_NFSD_PNFS static __be32 nfsd4_decode_getdeviceinfo(struct nfsd4_compoundargs *argp, - struct nfsd4_getdeviceinfo *gdev) + void *_gdev) { + struct nfsd4_getdeviceinfo *gdev = _gdev; DECODE_HEAD; u32 num, i; @@ -1602,8 +1644,9 @@ nfsd4_decode_getdeviceinfo(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_layoutget(struct nfsd4_compoundargs *argp, - struct nfsd4_layoutget *lgp) + void *_lgp) { + struct nfsd4_layoutget *lgp = _lgp; DECODE_HEAD; READ_BUF(36); @@ -1626,8 +1669,9 @@ nfsd4_decode_layoutget(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_layoutcommit(struct nfsd4_compoundargs *argp, - struct nfsd4_layoutcommit *lcp) + void *_lcp) { + struct nfsd4_layoutcommit *lcp = _lcp; DECODE_HEAD; u32 timechange; @@ -1674,8 +1718,9 @@ nfsd4_decode_layoutcommit(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_layoutreturn(struct nfsd4_compoundargs *argp, - struct nfsd4_layoutreturn *lrp) + void *_lrp) { + struct nfsd4_layoutreturn *lrp = _lrp; DECODE_HEAD; READ_BUF(16); @@ -1709,8 +1754,9 @@ nfsd4_decode_layoutreturn(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_fallocate(struct nfsd4_compoundargs *argp, - struct nfsd4_fallocate *fallocate) + void *_fallocate) { + struct nfsd4_fallocate *fallocate = _fallocate; DECODE_HEAD; status = nfsd4_decode_stateid(argp, &fallocate->falloc_stateid); @@ -1725,8 +1771,9 @@ nfsd4_decode_fallocate(struct nfsd4_compoundargs *argp, } static __be32 -nfsd4_decode_clone(struct nfsd4_compoundargs *argp, struct nfsd4_clone *clone) +nfsd4_decode_clone(struct nfsd4_compoundargs *argp, void *_clone) { + struct nfsd4_clone *clone = _clone; DECODE_HEAD; status = nfsd4_decode_stateid(argp, &clone->cl_src_stateid); @@ -1744,8 +1791,9 @@ nfsd4_decode_clone(struct nfsd4_compoundargs *argp, struct nfsd4_clone *clone) } static __be32 -nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy) +nfsd4_decode_copy(struct nfsd4_compoundargs *argp, void *_copy) { + struct nfsd4_copy *copy = _copy; DECODE_HEAD; unsigned int tmp; @@ -1768,8 +1816,9 @@ nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy) } static __be32 -nfsd4_decode_seek(struct nfsd4_compoundargs *argp, struct nfsd4_seek *seek) +nfsd4_decode_seek(struct nfsd4_compoundargs *argp, void *_seek) { + struct nfsd4_seek *seek = _seek; DECODE_HEAD; status = nfsd4_decode_stateid(argp, &seek->seek_stateid); @@ -1798,87 +1847,87 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p) typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *); static const nfsd4_dec nfsd4_dec_ops[] = { - [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access, - [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close, - [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit, - [OP_CREATE] = (nfsd4_dec)nfsd4_decode_create, - [OP_DELEGPURGE] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_DELEGRETURN] = (nfsd4_dec)nfsd4_decode_delegreturn, - [OP_GETATTR] = (nfsd4_dec)nfsd4_decode_getattr, - [OP_GETFH] = (nfsd4_dec)nfsd4_decode_noop, - [OP_LINK] = (nfsd4_dec)nfsd4_decode_link, - [OP_LOCK] = (nfsd4_dec)nfsd4_decode_lock, - [OP_LOCKT] = (nfsd4_dec)nfsd4_decode_lockt, - [OP_LOCKU] = (nfsd4_dec)nfsd4_decode_locku, - [OP_LOOKUP] = (nfsd4_dec)nfsd4_decode_lookup, - [OP_LOOKUPP] = (nfsd4_dec)nfsd4_decode_noop, - [OP_NVERIFY] = (nfsd4_dec)nfsd4_decode_verify, - [OP_OPEN] = (nfsd4_dec)nfsd4_decode_open, - [OP_OPENATTR] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_OPEN_CONFIRM] = (nfsd4_dec)nfsd4_decode_open_confirm, - [OP_OPEN_DOWNGRADE] = (nfsd4_dec)nfsd4_decode_open_downgrade, - [OP_PUTFH] = (nfsd4_dec)nfsd4_decode_putfh, - [OP_PUTPUBFH] = (nfsd4_dec)nfsd4_decode_putpubfh, - [OP_PUTROOTFH] = (nfsd4_dec)nfsd4_decode_noop, - [OP_READ] = (nfsd4_dec)nfsd4_decode_read, - [OP_READDIR] = (nfsd4_dec)nfsd4_decode_readdir, - [OP_READLINK] = (nfsd4_dec)nfsd4_decode_noop, - [OP_REMOVE] = (nfsd4_dec)nfsd4_decode_remove, - [OP_RENAME] = (nfsd4_dec)nfsd4_decode_rename, - [OP_RENEW] = (nfsd4_dec)nfsd4_decode_renew, - [OP_RESTOREFH] = (nfsd4_dec)nfsd4_decode_noop, - [OP_SAVEFH] = (nfsd4_dec)nfsd4_decode_noop, - [OP_SECINFO] = (nfsd4_dec)nfsd4_decode_secinfo, - [OP_SETATTR] = (nfsd4_dec)nfsd4_decode_setattr, - [OP_SETCLIENTID] = (nfsd4_dec)nfsd4_decode_setclientid, - [OP_SETCLIENTID_CONFIRM] = (nfsd4_dec)nfsd4_decode_setclientid_confirm, - [OP_VERIFY] = (nfsd4_dec)nfsd4_decode_verify, - [OP_WRITE] = (nfsd4_dec)nfsd4_decode_write, - [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner, + [OP_ACCESS] = nfsd4_decode_access, + [OP_CLOSE] = nfsd4_decode_close, + [OP_COMMIT] = nfsd4_decode_commit, + [OP_CREATE] = nfsd4_decode_create, + [OP_DELEGPURGE] = nfsd4_decode_notsupp, + [OP_DELEGRETURN] = nfsd4_decode_delegreturn, + [OP_GETATTR] = nfsd4_decode_getattr, + [OP_GETFH] = nfsd4_decode_noop, + [OP_LINK] = nfsd4_decode_link, + [OP_LOCK] = nfsd4_decode_lock, + [OP_LOCKT] = nfsd4_decode_lockt, + [OP_LOCKU] = nfsd4_decode_locku, + [OP_LOOKUP] = nfsd4_decode_lookup, + [OP_LOOKUPP] = nfsd4_decode_noop, + [OP_NVERIFY] = nfsd4_decode_verify, + [OP_OPEN] = nfsd4_decode_open, + [OP_OPENATTR] = nfsd4_decode_notsupp, + [OP_OPEN_CONFIRM] = nfsd4_decode_open_confirm, + [OP_OPEN_DOWNGRADE] = nfsd4_decode_open_downgrade, + [OP_PUTFH] = nfsd4_decode_putfh, + [OP_PUTPUBFH] = nfsd4_decode_putpubfh, + [OP_PUTROOTFH] = nfsd4_decode_noop, + [OP_READ] = nfsd4_decode_read, + [OP_READDIR] = nfsd4_decode_readdir, + [OP_READLINK] = nfsd4_decode_noop, + [OP_REMOVE] = nfsd4_decode_remove, + [OP_RENAME] = nfsd4_decode_rename, + [OP_RENEW] = nfsd4_decode_renew, + [OP_RESTOREFH] = nfsd4_decode_noop, + [OP_SAVEFH] = nfsd4_decode_noop, + [OP_SECINFO] = nfsd4_decode_secinfo, + [OP_SETATTR] = nfsd4_decode_setattr, + [OP_SETCLIENTID] = nfsd4_decode_setclientid, + [OP_SETCLIENTID_CONFIRM] = nfsd4_decode_setclientid_confirm, + [OP_VERIFY] = nfsd4_decode_verify, + [OP_WRITE] = nfsd4_decode_write, + [OP_RELEASE_LOCKOWNER] = nfsd4_decode_release_lockowner, /* new operations for NFSv4.1 */ - [OP_BACKCHANNEL_CTL] = (nfsd4_dec)nfsd4_decode_backchannel_ctl, - [OP_BIND_CONN_TO_SESSION]= (nfsd4_dec)nfsd4_decode_bind_conn_to_session, - [OP_EXCHANGE_ID] = (nfsd4_dec)nfsd4_decode_exchange_id, - [OP_CREATE_SESSION] = (nfsd4_dec)nfsd4_decode_create_session, - [OP_DESTROY_SESSION] = (nfsd4_dec)nfsd4_decode_destroy_session, - [OP_FREE_STATEID] = (nfsd4_dec)nfsd4_decode_free_stateid, - [OP_GET_DIR_DELEGATION] = (nfsd4_dec)nfsd4_decode_notsupp, + [OP_BACKCHANNEL_CTL] = nfsd4_decode_backchannel_ctl, + [OP_BIND_CONN_TO_SESSION]= nfsd4_decode_bind_conn_to_session, + [OP_EXCHANGE_ID] = nfsd4_decode_exchange_id, + [OP_CREATE_SESSION] = nfsd4_decode_create_session, + [OP_DESTROY_SESSION] = nfsd4_decode_destroy_session, + [OP_FREE_STATEID] = nfsd4_decode_free_stateid, + [OP_GET_DIR_DELEGATION] = nfsd4_decode_notsupp, #ifdef CONFIG_NFSD_PNFS - [OP_GETDEVICEINFO] = (nfsd4_dec)nfsd4_decode_getdeviceinfo, - [OP_GETDEVICELIST] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_LAYOUTCOMMIT] = (nfsd4_dec)nfsd4_decode_layoutcommit, - [OP_LAYOUTGET] = (nfsd4_dec)nfsd4_decode_layoutget, - [OP_LAYOUTRETURN] = (nfsd4_dec)nfsd4_decode_layoutreturn, + [OP_GETDEVICEINFO] = nfsd4_decode_getdeviceinfo, + [OP_GETDEVICELIST] = nfsd4_decode_notsupp, + [OP_LAYOUTCOMMIT] = nfsd4_decode_layoutcommit, + [OP_LAYOUTGET] = nfsd4_decode_layoutget, + [OP_LAYOUTRETURN] = nfsd4_decode_layoutreturn, #else - [OP_GETDEVICEINFO] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_GETDEVICELIST] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_LAYOUTCOMMIT] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_LAYOUTGET] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_LAYOUTRETURN] = (nfsd4_dec)nfsd4_decode_notsupp, + [OP_GETDEVICEINFO] = nfsd4_decode_notsupp, + [OP_GETDEVICELIST] = nfsd4_decode_notsupp, + [OP_LAYOUTCOMMIT] = nfsd4_decode_notsupp, + [OP_LAYOUTGET] = nfsd4_decode_notsupp, + [OP_LAYOUTRETURN] = nfsd4_decode_notsupp, #endif - [OP_SECINFO_NO_NAME] = (nfsd4_dec)nfsd4_decode_secinfo_no_name, - [OP_SEQUENCE] = (nfsd4_dec)nfsd4_decode_sequence, - [OP_SET_SSV] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_TEST_STATEID] = (nfsd4_dec)nfsd4_decode_test_stateid, - [OP_WANT_DELEGATION] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_DESTROY_CLIENTID] = (nfsd4_dec)nfsd4_decode_destroy_clientid, - [OP_RECLAIM_COMPLETE] = (nfsd4_dec)nfsd4_decode_reclaim_complete, + [OP_SECINFO_NO_NAME] = nfsd4_decode_secinfo_no_name, + [OP_SEQUENCE] = nfsd4_decode_sequence, + [OP_SET_SSV] = nfsd4_decode_notsupp, + [OP_TEST_STATEID] = nfsd4_decode_test_stateid, + [OP_WANT_DELEGATION] = nfsd4_decode_notsupp, + [OP_DESTROY_CLIENTID] = nfsd4_decode_destroy_clientid, + [OP_RECLAIM_COMPLETE] = nfsd4_decode_reclaim_complete, /* new operations for NFSv4.2 */ - [OP_ALLOCATE] = (nfsd4_dec)nfsd4_decode_fallocate, - [OP_COPY] = (nfsd4_dec)nfsd4_decode_copy, - [OP_COPY_NOTIFY] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_DEALLOCATE] = (nfsd4_dec)nfsd4_decode_fallocate, - [OP_IO_ADVISE] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_LAYOUTERROR] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_LAYOUTSTATS] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_OFFLOAD_CANCEL] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_OFFLOAD_STATUS] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_READ_PLUS] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_SEEK] = (nfsd4_dec)nfsd4_decode_seek, - [OP_WRITE_SAME] = (nfsd4_dec)nfsd4_decode_notsupp, - [OP_CLONE] = (nfsd4_dec)nfsd4_decode_clone, + [OP_ALLOCATE] = nfsd4_decode_fallocate, + [OP_COPY] = nfsd4_decode_copy, + [OP_COPY_NOTIFY] = nfsd4_decode_notsupp, + [OP_DEALLOCATE] = nfsd4_decode_fallocate, + [OP_IO_ADVISE] = nfsd4_decode_notsupp, + [OP_LAYOUTERROR] = nfsd4_decode_notsupp, + [OP_LAYOUTSTATS] = nfsd4_decode_notsupp, + [OP_OFFLOAD_CANCEL] = nfsd4_decode_notsupp, + [OP_OFFLOAD_STATUS] = nfsd4_decode_notsupp, + [OP_READ_PLUS] = nfsd4_decode_notsupp, + [OP_SEEK] = nfsd4_decode_seek, + [OP_WRITE_SAME] = nfsd4_decode_notsupp, + [OP_CLONE] = nfsd4_decode_clone, }; static inline bool @@ -3117,8 +3166,9 @@ nfsd4_encode_stateid(struct xdr_stream *xdr, stateid_t *sid) } static __be32 -nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_access *access) +nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, void *_access) { + struct nfsd4_access *access = _access; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3130,8 +3180,9 @@ nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ return 0; } -static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_bind_conn_to_session *bcts) +static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp, __be32 nfserr, void *_bcts) { + struct nfsd4_bind_conn_to_session *bcts = _bcts; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3147,8 +3198,10 @@ static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp, } static __be32 -nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_close *close) +nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, void *_close) { + struct nfsd4_close *close = _close; + struct xdr_stream *xdr = &resp->xdr; return nfsd4_encode_stateid(xdr, &close->cl_stateid); @@ -3156,8 +3209,9 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_c static __be32 -nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_commit *commit) +nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, void *_commit) { + struct nfsd4_commit *commit = _commit; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3170,8 +3224,9 @@ nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ } static __be32 -nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_create *create) +nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, void *_create) { + struct nfsd4_create *create = _create; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3185,8 +3240,9 @@ nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ } static __be32 -nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_getattr *getattr) +nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, void *_getattr) { + struct nfsd4_getattr *getattr = _getattr; struct svc_fh *fhp = getattr->ga_fhp; struct xdr_stream *xdr = &resp->xdr; @@ -3195,8 +3251,9 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 } static __be32 -nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh **fhpp) +nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, void *_fhpp) { + struct svc_fh **fhpp = (struct svc_fh **)_fhpp; struct xdr_stream *xdr = &resp->xdr; struct svc_fh *fhp = *fhpp; unsigned int len; @@ -3250,8 +3307,10 @@ nfsd4_encode_lock_denied(struct xdr_stream *xdr, struct nfsd4_lock_denied *ld) } static __be32 -nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lock *lock) +nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, void *_lock) { + struct nfsd4_lock *lock = _lock; + struct xdr_stream *xdr = &resp->xdr; if (!nfserr) @@ -3263,8 +3322,9 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo } static __be32 -nfsd4_encode_lockt(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lockt *lockt) +nfsd4_encode_lockt(struct nfsd4_compoundres *resp, __be32 nfserr, void *_lockt) { + struct nfsd4_lockt *lockt = _lockt; struct xdr_stream *xdr = &resp->xdr; if (nfserr == nfserr_denied) @@ -3273,8 +3333,9 @@ nfsd4_encode_lockt(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l } static __be32 -nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_locku *locku) +nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, void *_locku) { + struct nfsd4_locku *locku = _locku; struct xdr_stream *xdr = &resp->xdr; return nfsd4_encode_stateid(xdr, &locku->lu_stateid); @@ -3282,8 +3343,9 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l static __be32 -nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_link *link) +nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr, void *_link) { + struct nfsd4_link *link = _link; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3296,8 +3358,9 @@ nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_li static __be32 -nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open *open) +nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, void *_open) { + struct nfsd4_open *open = _open; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3390,16 +3453,20 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op } static __be32 -nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_confirm *oc) +nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, void *_oc) { + struct nfsd4_open_confirm *oc = _oc; + struct xdr_stream *xdr = &resp->xdr; return nfsd4_encode_stateid(xdr, &oc->oc_resp_stateid); } static __be32 -nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_downgrade *od) +nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, void *_od) { + struct nfsd4_open_downgrade *od = _od; + struct xdr_stream *xdr = &resp->xdr; return nfsd4_encode_stateid(xdr, &od->od_stateid); @@ -3529,9 +3596,9 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp, } static __be32 -nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_read *read) +nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, void *_read) { + struct nfsd4_read *read = _read; unsigned long maxcount; struct xdr_stream *xdr = &resp->xdr; struct file *file = read->rd_filp; @@ -3575,8 +3642,9 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, } static __be32 -nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_readlink *readlink) +nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, void *_readlink) { + struct nfsd4_readlink *readlink = _readlink; int maxcount; __be32 wire_count; int zero = 0; @@ -3617,8 +3685,9 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd } static __be32 -nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_readdir *readdir) +nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, void *_readdir) { + struct nfsd4_readdir *readdir = _readdir; int maxcount; int bytes_left; loff_t offset; @@ -3707,8 +3776,9 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 } static __be32 -nfsd4_encode_remove(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_remove *remove) +nfsd4_encode_remove(struct nfsd4_compoundres *resp, __be32 nfserr, void *_remove) { + struct nfsd4_remove *remove = _remove; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3720,8 +3790,9 @@ nfsd4_encode_remove(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ } static __be32 -nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_rename *rename) +nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, void *_rename) { + struct nfsd4_rename *rename = _rename; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3734,8 +3805,9 @@ nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ } static __be32 -nfsd4_do_encode_secinfo(struct xdr_stream *xdr, struct svc_export *exp) +nfsd4_do_encode_secinfo(struct xdr_stream *xdr, void *_exp) { + struct svc_export *exp = _exp; u32 i, nflavs, supported; struct exp_flavor_info *flavs; struct exp_flavor_info def_flavs[2]; @@ -3803,8 +3875,9 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, struct svc_export *exp) static __be32 nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_secinfo *secinfo) + void *_secinfo) { + struct nfsd4_secinfo *secinfo = _secinfo; struct xdr_stream *xdr = &resp->xdr; return nfsd4_do_encode_secinfo(xdr, secinfo->si_exp); @@ -3812,8 +3885,9 @@ nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, __be32 nfserr, static __be32 nfsd4_encode_secinfo_no_name(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_secinfo_no_name *secinfo) + void *_secinfo) { + struct nfsd4_secinfo_no_name *secinfo = _secinfo; struct xdr_stream *xdr = &resp->xdr; return nfsd4_do_encode_secinfo(xdr, secinfo->sin_exp); @@ -3824,8 +3898,9 @@ nfsd4_encode_secinfo_no_name(struct nfsd4_compoundres *resp, __be32 nfserr, * regardless of the error status. */ static __be32 -nfsd4_encode_setattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_setattr *setattr) +nfsd4_encode_setattr(struct nfsd4_compoundres *resp, __be32 nfserr, void *_setattr) { + struct nfsd4_setattr *setattr = _setattr; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3848,8 +3923,9 @@ nfsd4_encode_setattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 } static __be32 -nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_setclientid *scd) +nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, void *_scd) { + struct nfsd4_setclientid *scd = _scd; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3872,8 +3948,9 @@ nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, struct n } static __be32 -nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_write *write) +nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, void *_write) { + struct nfsd4_write *write = _write; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -3889,8 +3966,9 @@ nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_w static __be32 nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_exchange_id *exid) + void *_exid) { + struct nfsd4_exchange_id *exid = _exid; struct xdr_stream *xdr = &resp->xdr; __be32 *p; char *major_id; @@ -3966,8 +4044,9 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, static __be32 nfsd4_encode_create_session(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_create_session *sess) + void *_sess) { + struct nfsd4_create_session *sess = _sess; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -4019,8 +4098,9 @@ nfsd4_encode_create_session(struct nfsd4_compoundres *resp, __be32 nfserr, static __be32 nfsd4_encode_sequence(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_sequence *seq) + void *_seq) { + struct nfsd4_sequence *seq = _seq; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -4042,8 +4122,9 @@ nfsd4_encode_sequence(struct nfsd4_compoundres *resp, __be32 nfserr, static __be32 nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_test_stateid *test_stateid) + void *_test_stateid) { + struct nfsd4_test_stateid *test_stateid = _test_stateid; struct xdr_stream *xdr = &resp->xdr; struct nfsd4_test_stateid_id *stateid, *next; __be32 *p; @@ -4062,9 +4143,9 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr, #ifdef CONFIG_NFSD_PNFS static __be32 -nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_getdeviceinfo *gdev) +nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr, void *_gdev) { + struct nfsd4_getdeviceinfo *gdev = _gdev; struct xdr_stream *xdr = &resp->xdr; const struct nfsd4_layout_ops *ops; u32 starting_len = xdr->buf->len, needed_len; @@ -4118,9 +4199,9 @@ nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr, } static __be32 -nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_layoutget *lgp) +nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr, void *_lgp) { + struct nfsd4_layoutget *lgp = _lgp; struct xdr_stream *xdr = &resp->xdr; const struct nfsd4_layout_ops *ops; __be32 *p; @@ -4145,9 +4226,9 @@ nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr, } static __be32 -nfsd4_encode_layoutcommit(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_layoutcommit *lcp) +nfsd4_encode_layoutcommit(struct nfsd4_compoundres *resp, __be32 nfserr, void *_lcp) { + struct nfsd4_layoutcommit *lcp = _lcp; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -4166,9 +4247,9 @@ nfsd4_encode_layoutcommit(struct nfsd4_compoundres *resp, __be32 nfserr, } static __be32 -nfsd4_encode_layoutreturn(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_layoutreturn *lrp) +nfsd4_encode_layoutreturn(struct nfsd4_compoundres *resp, __be32 nfserr, void *_lrp) { + struct nfsd4_layoutreturn *lrp = _lrp; struct xdr_stream *xdr = &resp->xdr; __be32 *p; @@ -4200,9 +4281,9 @@ nfsd42_encode_write_res(struct nfsd4_compoundres *resp, struct nfsd42_write_res } static __be32 -nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_copy *copy) +nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr, void *_copy) { + struct nfsd4_copy *copy = _copy; __be32 *p; nfserr = nfsd42_encode_write_res(resp, ©->cp_res); @@ -4217,8 +4298,9 @@ nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr, static __be32 nfsd4_encode_seek(struct nfsd4_compoundres *resp, __be32 nfserr, - struct nfsd4_seek *seek) + void *_seek) { + struct nfsd4_seek *seek= (struct nfsd4_seek *)_seek; __be32 *p; p = xdr_reserve_space(&resp->xdr, 4 + 8); @@ -4242,87 +4324,87 @@ typedef __be32(* nfsd4_enc)(struct nfsd4_compoundres *, __be32, void *); * done in the decoding phase. */ static const nfsd4_enc nfsd4_enc_ops[] = { - [OP_ACCESS] = (nfsd4_enc)nfsd4_encode_access, - [OP_CLOSE] = (nfsd4_enc)nfsd4_encode_close, - [OP_COMMIT] = (nfsd4_enc)nfsd4_encode_commit, - [OP_CREATE] = (nfsd4_enc)nfsd4_encode_create, - [OP_DELEGPURGE] = (nfsd4_enc)nfsd4_encode_noop, - [OP_DELEGRETURN] = (nfsd4_enc)nfsd4_encode_noop, - [OP_GETATTR] = (nfsd4_enc)nfsd4_encode_getattr, - [OP_GETFH] = (nfsd4_enc)nfsd4_encode_getfh, - [OP_LINK] = (nfsd4_enc)nfsd4_encode_link, - [OP_LOCK] = (nfsd4_enc)nfsd4_encode_lock, - [OP_LOCKT] = (nfsd4_enc)nfsd4_encode_lockt, - [OP_LOCKU] = (nfsd4_enc)nfsd4_encode_locku, - [OP_LOOKUP] = (nfsd4_enc)nfsd4_encode_noop, - [OP_LOOKUPP] = (nfsd4_enc)nfsd4_encode_noop, - [OP_NVERIFY] = (nfsd4_enc)nfsd4_encode_noop, - [OP_OPEN] = (nfsd4_enc)nfsd4_encode_open, - [OP_OPENATTR] = (nfsd4_enc)nfsd4_encode_noop, - [OP_OPEN_CONFIRM] = (nfsd4_enc)nfsd4_encode_open_confirm, - [OP_OPEN_DOWNGRADE] = (nfsd4_enc)nfsd4_encode_open_downgrade, - [OP_PUTFH] = (nfsd4_enc)nfsd4_encode_noop, - [OP_PUTPUBFH] = (nfsd4_enc)nfsd4_encode_noop, - [OP_PUTROOTFH] = (nfsd4_enc)nfsd4_encode_noop, - [OP_READ] = (nfsd4_enc)nfsd4_encode_read, - [OP_READDIR] = (nfsd4_enc)nfsd4_encode_readdir, - [OP_READLINK] = (nfsd4_enc)nfsd4_encode_readlink, - [OP_REMOVE] = (nfsd4_enc)nfsd4_encode_remove, - [OP_RENAME] = (nfsd4_enc)nfsd4_encode_rename, - [OP_RENEW] = (nfsd4_enc)nfsd4_encode_noop, - [OP_RESTOREFH] = (nfsd4_enc)nfsd4_encode_noop, - [OP_SAVEFH] = (nfsd4_enc)nfsd4_encode_noop, - [OP_SECINFO] = (nfsd4_enc)nfsd4_encode_secinfo, - [OP_SETATTR] = (nfsd4_enc)nfsd4_encode_setattr, - [OP_SETCLIENTID] = (nfsd4_enc)nfsd4_encode_setclientid, - [OP_SETCLIENTID_CONFIRM] = (nfsd4_enc)nfsd4_encode_noop, - [OP_VERIFY] = (nfsd4_enc)nfsd4_encode_noop, - [OP_WRITE] = (nfsd4_enc)nfsd4_encode_write, - [OP_RELEASE_LOCKOWNER] = (nfsd4_enc)nfsd4_encode_noop, + [OP_ACCESS] = nfsd4_encode_access, + [OP_CLOSE] = nfsd4_encode_close, + [OP_COMMIT] = nfsd4_encode_commit, + [OP_CREATE] = nfsd4_encode_create, + [OP_DELEGPURGE] = nfsd4_encode_noop, + [OP_DELEGRETURN] = nfsd4_encode_noop, + [OP_GETATTR] = nfsd4_encode_getattr, + [OP_GETFH] = nfsd4_encode_getfh, + [OP_LINK] = nfsd4_encode_link, + [OP_LOCK] = nfsd4_encode_lock, + [OP_LOCKT] = nfsd4_encode_lockt, + [OP_LOCKU] = nfsd4_encode_locku, + [OP_LOOKUP] = nfsd4_encode_noop, + [OP_LOOKUPP] = nfsd4_encode_noop, + [OP_NVERIFY] = nfsd4_encode_noop, + [OP_OPEN] = nfsd4_encode_open, + [OP_OPENATTR] = nfsd4_encode_noop, + [OP_OPEN_CONFIRM] = nfsd4_encode_open_confirm, + [OP_OPEN_DOWNGRADE] = nfsd4_encode_open_downgrade, + [OP_PUTFH] = nfsd4_encode_noop, + [OP_PUTPUBFH] = nfsd4_encode_noop, + [OP_PUTROOTFH] = nfsd4_encode_noop, + [OP_READ] = nfsd4_encode_read, + [OP_READDIR] = nfsd4_encode_readdir, + [OP_READLINK] = nfsd4_encode_readlink, + [OP_REMOVE] = nfsd4_encode_remove, + [OP_RENAME] = nfsd4_encode_rename, + [OP_RENEW] = nfsd4_encode_noop, + [OP_RESTOREFH] = nfsd4_encode_noop, + [OP_SAVEFH] = nfsd4_encode_noop, + [OP_SECINFO] = nfsd4_encode_secinfo, + [OP_SETATTR] = nfsd4_encode_setattr, + [OP_SETCLIENTID] = nfsd4_encode_setclientid, + [OP_SETCLIENTID_CONFIRM] = nfsd4_encode_noop, + [OP_VERIFY] = nfsd4_encode_noop, + [OP_WRITE] = nfsd4_encode_write, + [OP_RELEASE_LOCKOWNER] = nfsd4_encode_noop, /* NFSv4.1 operations */ - [OP_BACKCHANNEL_CTL] = (nfsd4_enc)nfsd4_encode_noop, - [OP_BIND_CONN_TO_SESSION] = (nfsd4_enc)nfsd4_encode_bind_conn_to_session, - [OP_EXCHANGE_ID] = (nfsd4_enc)nfsd4_encode_exchange_id, - [OP_CREATE_SESSION] = (nfsd4_enc)nfsd4_encode_create_session, - [OP_DESTROY_SESSION] = (nfsd4_enc)nfsd4_encode_noop, - [OP_FREE_STATEID] = (nfsd4_enc)nfsd4_encode_noop, - [OP_GET_DIR_DELEGATION] = (nfsd4_enc)nfsd4_encode_noop, + [OP_BACKCHANNEL_CTL] = nfsd4_encode_noop, + [OP_BIND_CONN_TO_SESSION] = nfsd4_encode_bind_conn_to_session, + [OP_EXCHANGE_ID] = nfsd4_encode_exchange_id, + [OP_CREATE_SESSION] = nfsd4_encode_create_session, + [OP_DESTROY_SESSION] = nfsd4_encode_noop, + [OP_FREE_STATEID] = nfsd4_encode_noop, + [OP_GET_DIR_DELEGATION] = nfsd4_encode_noop, #ifdef CONFIG_NFSD_PNFS - [OP_GETDEVICEINFO] = (nfsd4_enc)nfsd4_encode_getdeviceinfo, - [OP_GETDEVICELIST] = (nfsd4_enc)nfsd4_encode_noop, - [OP_LAYOUTCOMMIT] = (nfsd4_enc)nfsd4_encode_layoutcommit, - [OP_LAYOUTGET] = (nfsd4_enc)nfsd4_encode_layoutget, - [OP_LAYOUTRETURN] = (nfsd4_enc)nfsd4_encode_layoutreturn, + [OP_GETDEVICEINFO] = nfsd4_encode_getdeviceinfo, + [OP_GETDEVICELIST] = nfsd4_encode_noop, + [OP_LAYOUTCOMMIT] = nfsd4_encode_layoutcommit, + [OP_LAYOUTGET] = nfsd4_encode_layoutget, + [OP_LAYOUTRETURN] = nfsd4_encode_layoutreturn, #else - [OP_GETDEVICEINFO] = (nfsd4_enc)nfsd4_encode_noop, - [OP_GETDEVICELIST] = (nfsd4_enc)nfsd4_encode_noop, - [OP_LAYOUTCOMMIT] = (nfsd4_enc)nfsd4_encode_noop, - [OP_LAYOUTGET] = (nfsd4_enc)nfsd4_encode_noop, - [OP_LAYOUTRETURN] = (nfsd4_enc)nfsd4_encode_noop, + [OP_GETDEVICEINFO] = nfsd4_encode_noop, + [OP_GETDEVICELIST] = nfsd4_encode_noop, + [OP_LAYOUTCOMMIT] = nfsd4_encode_noop, + [OP_LAYOUTGET] = nfsd4_encode_noop, + [OP_LAYOUTRETURN] = nfsd4_encode_noop, #endif - [OP_SECINFO_NO_NAME] = (nfsd4_enc)nfsd4_encode_secinfo_no_name, - [OP_SEQUENCE] = (nfsd4_enc)nfsd4_encode_sequence, - [OP_SET_SSV] = (nfsd4_enc)nfsd4_encode_noop, - [OP_TEST_STATEID] = (nfsd4_enc)nfsd4_encode_test_stateid, - [OP_WANT_DELEGATION] = (nfsd4_enc)nfsd4_encode_noop, - [OP_DESTROY_CLIENTID] = (nfsd4_enc)nfsd4_encode_noop, - [OP_RECLAIM_COMPLETE] = (nfsd4_enc)nfsd4_encode_noop, + [OP_SECINFO_NO_NAME] = nfsd4_encode_secinfo_no_name, + [OP_SEQUENCE] = nfsd4_encode_sequence, + [OP_SET_SSV] = nfsd4_encode_noop, + [OP_TEST_STATEID] = nfsd4_encode_test_stateid, + [OP_WANT_DELEGATION] = nfsd4_encode_noop, + [OP_DESTROY_CLIENTID] = nfsd4_encode_noop, + [OP_RECLAIM_COMPLETE] = nfsd4_encode_noop, /* NFSv4.2 operations */ - [OP_ALLOCATE] = (nfsd4_enc)nfsd4_encode_noop, - [OP_COPY] = (nfsd4_enc)nfsd4_encode_copy, - [OP_COPY_NOTIFY] = (nfsd4_enc)nfsd4_encode_noop, - [OP_DEALLOCATE] = (nfsd4_enc)nfsd4_encode_noop, - [OP_IO_ADVISE] = (nfsd4_enc)nfsd4_encode_noop, - [OP_LAYOUTERROR] = (nfsd4_enc)nfsd4_encode_noop, - [OP_LAYOUTSTATS] = (nfsd4_enc)nfsd4_encode_noop, - [OP_OFFLOAD_CANCEL] = (nfsd4_enc)nfsd4_encode_noop, - [OP_OFFLOAD_STATUS] = (nfsd4_enc)nfsd4_encode_noop, - [OP_READ_PLUS] = (nfsd4_enc)nfsd4_encode_noop, - [OP_SEEK] = (nfsd4_enc)nfsd4_encode_seek, - [OP_WRITE_SAME] = (nfsd4_enc)nfsd4_encode_noop, - [OP_CLONE] = (nfsd4_enc)nfsd4_encode_noop, + [OP_ALLOCATE] = nfsd4_encode_noop, + [OP_COPY] = nfsd4_encode_copy, + [OP_COPY_NOTIFY] = nfsd4_encode_noop, + [OP_DEALLOCATE] = nfsd4_encode_noop, + [OP_IO_ADVISE] = nfsd4_encode_noop, + [OP_LAYOUTERROR] = nfsd4_encode_noop, + [OP_LAYOUTSTATS] = nfsd4_encode_noop, + [OP_OFFLOAD_CANCEL] = nfsd4_encode_noop, + [OP_OFFLOAD_STATUS] = nfsd4_encode_noop, + [OP_READ_PLUS] = nfsd4_encode_noop, + [OP_SEEK] = nfsd4_encode_seek, + [OP_WRITE_SAME] = nfsd4_encode_noop, + [OP_CLONE] = nfsd4_encode_noop, }; /* diff --git a/include/linux/compiler.h b/include/linux/compiler.h index e8c9cd1..247e6d0 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -158,27 +158,18 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, #include -#define __READ_ONCE_SIZE \ -({ \ - switch (size) { \ - case 1: *(__u8 *)res = *(volatile __u8 *)p; break; \ - case 2: *(__u16 *)res = *(volatile __u16 *)p; break; \ - case 4: *(__u32 *)res = *(volatile __u32 *)p; break; \ - case 8: *(__u64 *)res = *(volatile __u64 *)p; break; \ - default: \ - barrier(); \ - __builtin_memcpy((void *)res, (const void *)p, size); \ - barrier(); \ - } \ +#ifdef CONFIG_KASAN +/* + * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need + * to hide memory access from KASAN. + */ +#define READ_ONCE_NOCHECK(x) \ +({ \ + union { typeof(x) __val; char __c[sizeof(x)]; } __u; \ + __read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \ + __u.__val; \ }) -static __always_inline -void __read_once_size(const volatile void *p, void *res, int size) -{ - __READ_ONCE_SIZE; -} - -#ifdef CONFIG_KASAN /* * This function is not 'inline' because __no_sanitize_address confilcts * with inlining. Attempt to inline it may cause a build failure. @@ -188,29 +179,20 @@ void __read_once_size(const volatile void *p, void *res, int size) static __no_sanitize_address __maybe_unused void __read_once_size_nocheck(const volatile void *p, void *res, int size) { - __READ_ONCE_SIZE; -} -#else -static __always_inline -void __read_once_size_nocheck(const volatile void *p, void *res, int size) -{ - __READ_ONCE_SIZE; -} -#endif - -static __always_inline void __write_once_size(volatile void *p, void *res, int size) -{ switch (size) { - case 1: *(volatile __u8 *)p = *(__u8 *)res; break; - case 2: *(volatile __u16 *)p = *(__u16 *)res; break; - case 4: *(volatile __u32 *)p = *(__u32 *)res; break; - case 8: *(volatile __u64 *)p = *(__u64 *)res; break; + case 1: *(__u8 *)res = *(const volatile __u8 *)p; break; + case 2: *(__u16 *)res = *(const volatile __u16 *)p; break; + case 4: *(__u32 *)res = *(const volatile __u32 *)p; break; + case 8: *(__u64 *)res = *(const volatile __u64 *)p; break; default: barrier(); - __builtin_memcpy((void *)p, (const void *)res, size); + __builtin_memcpy(res, (const void *)p, size); barrier(); } } +#else +#define READ_ONCE_NOCHECK(x) READ_ONCE(x) +#endif /* * Prevent the compiler from merging or refetching reads or writes. The @@ -236,30 +218,15 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s */ #include -#define __READ_ONCE(x, check) \ -({ \ - union { typeof(x) __val; char __c[1]; } __u; \ - if (check) \ - __read_once_size(&(x), __u.__c, sizeof(x)); \ - else \ - __read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \ - smp_read_barrier_depends(); /* Enforce dependency ordering from x */ \ - __u.__val; \ +#define READ_ONCE(x) ({ \ + typeof(x) __val = *(volatile typeof(x) *)&(x); \ + __val; \ }) -#define READ_ONCE(x) __READ_ONCE(x, 1) -/* - * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need - * to hide memory access from KASAN. - */ -#define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0) - -#define WRITE_ONCE(x, val) \ -({ \ - union { typeof(x) __val; char __c[1]; } __u = \ - { .__val = (__force typeof(x)) (val) }; \ - __write_once_size(&(x), __u.__c, sizeof(x)); \ - __u.__val; \ +#define WRITE_ONCE(x, val) ({ \ + typeof(x) __val = (val); \ + (x) = *(volatile typeof(x) *)&__val; \ + __val; \ }) #endif /* __KERNEL__ */ diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 6b79a9b..5ddfac5 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -266,6 +266,8 @@ struct ftrace_likely_data { # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) #endif +#define __type_is_unsigned(t) (__same_type((t)0, 0UL) || __same_type((t)0, 0U) || __same_type((t)0, (unsigned short)0) || __same_type((t)0, (unsigned char)0)) + /* Is this type a native word size -- useful for atomic operations */ #ifndef __native_word # define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) diff --git a/include/linux/linkage.h b/include/linux/linkage.h index f68db9e..30ed811 100644 --- a/include/linux/linkage.h +++ b/include/linux/linkage.h @@ -6,6 +6,7 @@ #include #include #include +#include /* Some toolchains use other characters (e.g. '`') to mark new line in macro */ #ifndef ASM_NL @@ -80,17 +81,38 @@ #define ALIGN_STR __ALIGN_STR #ifndef ENTRY -#define ENTRY(name) \ +#define __ENTRY(name, rap_hash) \ .globl name ASM_NL \ ALIGN ASM_NL \ + rap_hash \ name: + +#define ENTRY(name) __ENTRY(name,) #endif #endif /* LINKER_SCRIPT */ #ifndef WEAK -#define WEAK(name) \ - .weak name ASM_NL \ +#define __WEAK(name, rap_hash) \ + .weak name ASM_NL \ + rap_hash \ name: + +#define WEAK(name) __WEAK(name, ) +#endif + +#ifdef CONFIG_PAX_RAP +#if BITS_PER_LONG == 64 +#define __ASM_RAP_HASH(hash) .quad 0, hash ASM_NL +#elif BITS_PER_LONG == 32 +#define __ASM_RAP_HASH(hash) .long 0, 0, 0, hash ASM_NL +#else +#error incompatible BITS_PER_LONG +#endif +#define RAP_ENTRY(name) __ENTRY(name, __ASM_RAP_HASH(__rap_hash_##name)) +#define RAP_WEAK(name) __WEAK(name, __ASM_RAP_HASH(__rap_hash_##name)) +#else +#define RAP_ENTRY(name) ENTRY(name) +#define RAP_WEAK(name) WEAK(name) #endif #ifndef END diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 1d7140f..c8671b8 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -230,14 +230,14 @@ struct kparam_array /* Obsolete - use module_param_cb() */ #define module_param_call(name, set, get, arg, perm) \ static const struct kernel_param_ops __param_ops_##name = \ - { .flags = 0, (void *)set, (void *)get }; \ + { .flags = 0, set, get }; \ __module_param_call(MODULE_PARAM_PREFIX, \ name, &__param_ops_##name, arg, \ (perm) + sizeof(__check_old_set_param(set))*0, -1, 0) /* We don't get oldget: it's often a new-style param_get_uint, etc. */ static inline int -__check_old_set_param(int (*oldset)(const char *, struct kernel_param *)) +__check_old_set_param(int (*oldset)(const char *, const struct kernel_param *)) { return 0; } @@ -292,7 +292,7 @@ static inline void kernel_param_unlock(struct module *mod) * @len is usually just sizeof(string). */ #define module_param_string(name, string, len, perm) \ - static const struct kparam_string __param_string_##name \ + static const struct kparam_string __param_string_##name __used \ = { len, string }; \ __module_param_call(MODULE_PARAM_PREFIX, name, \ ¶m_ops_string, \ @@ -444,7 +444,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp); */ #define module_param_array_named(name, array, type, nump, perm) \ param_check_##type(name, &(array)[0]); \ - static const struct kparam_array __param_arr_##name \ + static const struct kparam_array __param_arr_##name __used \ = { .max = ARRAY_SIZE(array), .num = nump, \ .ops = ¶m_ops_##type, \ .elemsize = sizeof(array[0]), .elem = array }; \ diff --git a/include/linux/netfilter/ipset/ip_set_comment.h b/include/linux/netfilter/ipset/ip_set_comment.h index 8e2bab1..1517a6f 100644 --- a/include/linux/netfilter/ipset/ip_set_comment.h +++ b/include/linux/netfilter/ipset/ip_set_comment.h @@ -60,8 +60,9 @@ ip_set_put_comment(struct sk_buff *skb, const struct ip_set_comment *comment) * of the set data anymore. */ static inline void -ip_set_comment_free(struct ip_set *set, struct ip_set_comment *comment) +ip_set_comment_free(struct ip_set *set, void *_comment) { + struct ip_set_comment *comment = _comment; struct ip_set_comment_rcu *c; c = rcu_dereference_protected(comment->c, 1); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index e08b533..9369e9c 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -243,7 +243,7 @@ static inline gfp_t readahead_gfp_mask(struct address_space *x) __GFP_COLD | __GFP_NORETRY | __GFP_NOWARN; } -typedef int filler_t(void *, struct page *); +typedef int filler_t(struct file *, struct page *); pgoff_t page_cache_next_hole(struct address_space *mapping, pgoff_t index, unsigned long max_scan); @@ -394,7 +394,7 @@ extern int read_cache_pages(struct address_space *mapping, static inline struct page *read_mapping_page(struct address_space *mapping, pgoff_t index, void *data) { - filler_t *filler = (filler_t *)mapping->a_ops->readpage; + filler_t *filler = mapping->a_ops->readpage; return read_cache_page(mapping, index, filler, data); } diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index a78186d..ef7fd29 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -104,7 +104,14 @@ union bpf_attr; #define __TYPE_IS_L(t) (__TYPE_AS(t, 0L)) #define __TYPE_IS_UL(t) (__TYPE_AS(t, 0UL)) #define __TYPE_IS_LL(t) (__TYPE_AS(t, 0LL) || __TYPE_AS(t, 0ULL)) -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a +#define __SC_TYPE(t) __typeof__( \ + __builtin_choose_expr( \ + sizeof(t) > sizeof(int), \ + (t) 0, \ + __builtin_choose_expr(__type_is_unsigned(t), 0UL, 0L) \ + )) +#define __SC_LONG(t, a) __SC_TYPE(t) a +#define __SC_WRAP(t, a) (__SC_TYPE(t)) a #define __SC_CAST(t, a) (__force t) a #define __SC_ARGS(t, a) a #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long)) @@ -208,17 +215,18 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event) #define __PROTECT(...) asmlinkage_protect(__VA_ARGS__) #define __SYSCALL_DEFINEx(x, name, ...) \ - asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ - __attribute__((alias(__stringify(SyS##name)))); \ static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ - asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ - asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ + static inline asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ { \ long ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ __MAP(x,__SC_TEST,__VA_ARGS__); \ __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ return ret; \ } \ + asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ + { \ + return SyS##name(__MAP(x,__SC_WRAP,__VA_ARGS__)); \ + } \ static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)) /* diff --git a/include/linux/timer.h b/include/linux/timer.h index e0ea1fe..f5d5636 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -173,7 +173,7 @@ static inline void init_timer_on_stack_key(struct timer_list *timer, #define TIMER_FUNC_TYPE void (*)(TIMER_DATA_TYPE) static inline void timer_setup(struct timer_list *timer, - void (*callback)(struct timer_list *), + void (*callback)(TIMER_DATA_TYPE), unsigned int flags) { __setup_timer(timer, (TIMER_FUNC_TYPE)callback, diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index 792c3f6..f5223bf 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h @@ -285,7 +285,7 @@ static inline bool nf_ct_should_gc(const struct nf_conn *ct) struct kernel_param; -int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp); +int nf_conntrack_set_hashsize(const char *val, const struct kernel_param *kp); int nf_conntrack_hash_resize(unsigned int hashsize); extern struct hlist_nulls_head *nf_conntrack_hash; diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index d203a5d6..6d32f69 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -485,6 +485,8 @@ int bpf_get_kallsym(unsigned int symnum, unsigned long *value, char *type, return ret; } +extern long __rap_hash___bpf_prog_run; + struct bpf_binary_header * bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr, unsigned int alignment, @@ -508,11 +510,24 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr, hdr->pages = size / PAGE_SIZE; hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)), PAGE_SIZE - sizeof(*hdr)); +#ifdef CONFIG_PAX_RAP + hole -= 8; +#endif start = (get_random_int() % hole) & ~(alignment - 1); +#ifdef CONFIG_PAX_RAP + start += 8; +#endif /* Leave a random number of instructions before BPF code. */ *image_ptr = &hdr->image[start]; +#ifdef CONFIG_PAX_RAP +#ifdef CONFIG_RELOCATABLE + *(long *)(*image_ptr - 8) = 0x17eeb8a2LL; +#else + *(long *)(*image_ptr - 8) = (long)&__rap_hash___bpf_prog_run; +#endif +#endif return hdr; } diff --git a/kernel/events/core.c b/kernel/events/core.c index f42f7c7..444b7b9 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1046,8 +1046,9 @@ static void __perf_mux_hrtimer_init(struct perf_cpu_context *cpuctx, int cpu) timer->function = perf_mux_hrtimer_handler; } -static int perf_mux_hrtimer_restart(struct perf_cpu_context *cpuctx) +static int perf_mux_hrtimer_restart(void *_cpuctx) { + struct perf_cpu_context *cpuctx = _cpuctx; struct hrtimer *timer = &cpuctx->hrtimer; struct pmu *pmu = cpuctx->ctx.pmu; unsigned long flags; @@ -9039,8 +9040,7 @@ perf_event_mux_interval_ms_store(struct device *dev, cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu); cpuctx->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * timer); - cpu_function_call(cpu, - (remote_function_f)perf_mux_hrtimer_restart, cpuctx); + cpu_function_call(cpu, perf_mux_hrtimer_restart, cpuctx); } cpus_read_unlock(); mutex_unlock(&mux_interval_mutex); diff --git a/kernel/module.c b/kernel/module.c index 690c065..550cb81 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3007,8 +3007,15 @@ static struct module *setup_load_info(struct load_info *info, int flags) static int check_modinfo(struct module *mod, struct load_info *info, int flags) { const char *modmagic = get_modinfo(info, "vermagic"); + const char *license = get_modinfo(info, "license"); int err; +#if defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR) || defined(CONFIG_PAX_RAP) + if (!license || !license_is_gpl_compatible(license)) { + pr_err("%s: module is not compatible with the KERNEXEC 'or' method and RAP\n", mod->name); + return -ENOEXEC; + } +#endif if (flags & MODULE_INIT_IGNORE_VERMAGIC) modmagic = NULL; @@ -3043,7 +3050,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags) return err; /* Set up license info based on the info section */ - set_license(mod, get_modinfo(info, "license")); + set_license(mod, license); return 0; } diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5506246..91811a7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2684,7 +2684,7 @@ static struct rq *finish_task_switch(struct task_struct *prev) /* rq->lock is NOT held, but preemption is disabled */ static void __balance_callback(struct rq *rq) { - struct callback_head *head, *next; + struct balance_callback *head, *next; void (*func)(struct rq *rq); unsigned long flags; @@ -2692,7 +2692,7 @@ static void __balance_callback(struct rq *rq) head = rq->balance_callback; rq->balance_callback = NULL; while (head) { - func = (void (*)(struct rq *))head->func; + func = head->func; next = head->next; head->next = NULL; head = next; diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 4ae5c1e..04c05f8 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -471,8 +471,8 @@ static inline bool need_pull_dl_task(struct rq *rq, struct task_struct *prev) return dl_task(prev); } -static DEFINE_PER_CPU(struct callback_head, dl_push_head); -static DEFINE_PER_CPU(struct callback_head, dl_pull_head); +static DEFINE_PER_CPU(struct balance_callback, dl_push_head); +static DEFINE_PER_CPU(struct balance_callback, dl_pull_head); static void push_dl_tasks(struct rq *); static void pull_dl_task(struct rq *); diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 298f62b..6f2e85f 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -353,8 +353,8 @@ static inline int has_pushable_tasks(struct rq *rq) return !plist_head_empty(&rq->rt.pushable_tasks); } -static DEFINE_PER_CPU(struct callback_head, rt_push_head); -static DEFINE_PER_CPU(struct callback_head, rt_pull_head); +static DEFINE_PER_CPU(struct balance_callback, rt_push_head); +static DEFINE_PER_CPU(struct balance_callback, rt_pull_head); static void push_rt_tasks(struct rq *); static void pull_rt_task(struct rq *); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 307c35d..555b429 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -740,7 +740,10 @@ struct rq { unsigned long cpu_capacity; unsigned long cpu_capacity_orig; - struct callback_head *balance_callback; + struct balance_callback { + struct balance_callback *next; + void (*func)(struct rq *rq); + } *balance_callback; unsigned char idle_balance; /* For active balancing */ @@ -995,7 +998,7 @@ extern int migrate_swap(struct task_struct *, struct task_struct *); static inline void queue_balance_callback(struct rq *rq, - struct callback_head *head, + struct balance_callback *head, void (*func)(struct rq *rq)) { lockdep_assert_held(&rq->lock); @@ -1003,7 +1006,7 @@ queue_balance_callback(struct rq *rq, if (unlikely(head->next)) return; - head->func = (void (*)(struct callback_head *))func; + head->func = func; head->next = rq->balance_callback; rq->balance_callback = head; } diff --git a/mm/filemap.c b/mm/filemap.c index 594d73f..fc9d65f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2666,7 +2666,7 @@ static struct page *wait_on_page_read(struct page *page) static struct page *do_read_cache_page(struct address_space *mapping, pgoff_t index, - int (*filler)(void *, struct page *), + filler_t *filler, void *data, gfp_t gfp) { @@ -2773,7 +2773,7 @@ static struct page *do_read_cache_page(struct address_space *mapping, */ struct page *read_cache_page(struct address_space *mapping, pgoff_t index, - int (*filler)(void *, struct page *), + filler_t *filler, void *data) { return do_read_cache_page(mapping, index, filler, data, mapping_gfp_mask(mapping)); @@ -2795,7 +2795,7 @@ struct page *read_cache_page_gfp(struct address_space *mapping, pgoff_t index, gfp_t gfp) { - filler_t *filler = (filler_t *)mapping->a_ops->readpage; + filler_t *filler = mapping->a_ops->readpage; return do_read_cache_page(mapping, index, filler, NULL, gfp); } diff --git a/mm/readahead.c b/mm/readahead.c index c4ca702..8ec9019 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -81,7 +81,7 @@ static void read_cache_pages_invalidate_pages(struct address_space *mapping, * Hides the details of the LRU cache etc from the filesystems. */ int read_cache_pages(struct address_space *mapping, struct list_head *pages, - int (*filler)(void *, struct page *), void *data) + filler_t *filler, void *data) { struct page *page; int ret = 0; diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index e870cfc..06c0090 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -572,7 +572,8 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb); static inline bool br_rx_handler_check_rcu(const struct net_device *dev) { - return rcu_dereference(dev->rx_handler) == br_handle_frame; + //return rcu_dereference(dev->rx_handler) == br_handle_frame; + return br_handle_frame == rcu_dereference(dev->rx_handler); } static inline struct net_bridge_port *br_port_get_check_rcu(const struct net_device *dev) diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c index cf84f7b..1194f88 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -326,7 +326,6 @@ ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr) } EXPORT_SYMBOL_GPL(ip_set_get_ipaddr6); -typedef void (*destroyer)(struct ip_set *, void *); /* ipset data extension types, in size order */ const struct ip_set_ext_type ip_set_extensions[] = { @@ -352,7 +351,7 @@ const struct ip_set_ext_type ip_set_extensions[] = { .flag = IPSET_FLAG_WITH_COMMENT, .len = sizeof(struct ip_set_comment), .align = __alignof__(struct ip_set_comment), - .destroy = (destroyer) ip_set_comment_free, + .destroy = ip_set_comment_free, }, }; EXPORT_SYMBOL_GPL(ip_set_extensions); diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 0113039..5e50c54 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -1940,7 +1940,7 @@ int nf_conntrack_hash_resize(unsigned int hashsize) return 0; } -int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp) +int nf_conntrack_set_hashsize(const char *val, const struct kernel_param *kp) { unsigned int hashsize; int rc; diff --git a/net/netfilter/nf_nat_ftp.c b/net/netfilter/nf_nat_ftp.c index e84a578..d76afaf 100644 --- a/net/netfilter/nf_nat_ftp.c +++ b/net/netfilter/nf_nat_ftp.c @@ -134,7 +134,7 @@ static int __init nf_nat_ftp_init(void) } /* Prior to 2.6.11, we had a ports param. No longer, but don't break users. */ -static int warn_set(const char *val, struct kernel_param *kp) +static int warn_set(const char *val, const struct kernel_param *kp) { printk(KERN_INFO KBUILD_MODNAME ": kernel >= 2.6.10 only uses 'ports' for conntrack modules\n"); diff --git a/net/netfilter/nf_nat_irc.c b/net/netfilter/nf_nat_irc.c index 0648cb0..dcb5f63 100644 --- a/net/netfilter/nf_nat_irc.c +++ b/net/netfilter/nf_nat_irc.c @@ -106,7 +106,7 @@ static int __init nf_nat_irc_init(void) } /* Prior to 2.6.11, we had a ports param. No longer, but don't break users. */ -static int warn_set(const char *val, struct kernel_param *kp) +static int warn_set(const char *val, const struct kernel_param *kp) { printk(KERN_INFO KBUILD_MODNAME ": kernel >= 2.6.10 only uses 'ports' for conntrack modules\n"); diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index aa04666..e5e4e18 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -50,7 +50,7 @@ EXPORT_SYMBOL_GPL(svc_pool_map); static DEFINE_MUTEX(svc_pool_map_mutex);/* protects svc_pool_map.count only */ static int -param_set_pool_mode(const char *val, struct kernel_param *kp) +param_set_pool_mode(const char *val, const struct kernel_param *kp) { int *ip = (int *)kp->arg; struct svc_pool_map *m = &svc_pool_map; @@ -80,7 +80,7 @@ param_set_pool_mode(const char *val, struct kernel_param *kp) } static int -param_get_pool_mode(char *buf, struct kernel_param *kp) +param_get_pool_mode(char *buf, const struct kernel_param *kp) { int *ip = (int *)kp->arg; diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins index b2a95af..ec8023f 100644 --- a/scripts/Makefile.gcc-plugins +++ b/scripts/Makefile.gcc-plugins @@ -35,10 +35,22 @@ ifdef CONFIG_GCC_PLUGINS gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode + gcc-plugin-subdir-$(CONFIG_PAX_RAP) += rap_plugin + gcc-plugin-$(CONFIG_PAX_RAP) += rap_plugin/rap_plugin.so + gcc-plugin-cflags-$(CONFIG_PAX_RAP) += -DRAP_PLUGIN -fplugin-arg-rap_plugin-check=call +# gcc-plugin-cflags-$(CONFIG_PAX_RAP) += -fplugin-arg-rap_plugin-report=func,fptr,abs + gcc-plugin-aflags-$(CONFIG_PAX_RAP) += -DRAP_PLUGIN + ifdef CONFIG_PAX_RAP + RAP_PLUGIN_ABS_CFLAGS := -fplugin-arg-rap_plugin-hash=abs-finish + endif + gcc-plugin-cflags-$(CONFIG_PAX_RAP) += $(RAP_PLUGIN_ABS_CFLAGS) + GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) + GCC_PLUGINS_AFLAGS := $(gcc-plugin-aflags-y) export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR export SANCOV_PLUGIN DISABLE_LATENT_ENTROPY_PLUGIN + export RAP_PLUGIN_ABS_CFLAGS GCC_PLUGINS_AFLAGS ifneq ($(PLUGINCC),) # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication. @@ -46,6 +58,7 @@ ifdef CONFIG_GCC_PLUGINS endif KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) + KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS) GCC_PLUGIN := $(gcc-plugin-y) GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y) endif diff --git a/scripts/gcc-plugins/rap_plugin/Makefile b/scripts/gcc-plugins/rap_plugin/Makefile new file mode 100644 index 0000000..f2a0a03 --- /dev/null +++ b/scripts/gcc-plugins/rap_plugin/Makefile @@ -0,0 +1,6 @@ +$(HOSTLIBS)-$(CONFIG_PAX_RAP) += rap_plugin.so +always := $($(HOSTLIBS)-y) + +rap_plugin-objs := $(patsubst $(srctree)/$(src)/%.c,%.o,$(wildcard $(srctree)/$(src)/*.c)) + +clean-files += *.so diff --git a/scripts/gcc-plugins/rap_plugin/rap.h b/scripts/gcc-plugins/rap_plugin/rap.h new file mode 100644 index 0000000..f6a284d --- /dev/null +++ b/scripts/gcc-plugins/rap_plugin/rap.h @@ -0,0 +1,36 @@ +#ifndef RAP_H_INCLUDED +#define RAP_H_INCLUDED + +#include "gcc-common.h" + +typedef struct { + int hash; // will be sign extended to long in reality +} rap_hash_t; + +typedef struct { + unsigned int qual_const:1; + unsigned int qual_volatile:1; +} rap_hash_flags_t; +extern rap_hash_flags_t imprecise_rap_hash_flags; + +extern bool report_fptr_hash; + +extern GTY(()) tree rap_hash_type_node; + +void siphash24fold(unsigned char *out, const unsigned char *in, unsigned long long inlen, const unsigned char *k); +void rap_calculate_func_hashes(void *event_data, void *data); +rap_hash_t rap_hash_function_type(const_tree fntype, rap_hash_flags_t flags); +rap_hash_t rap_hash_function_decl(const_tree fndecl, rap_hash_flags_t flags); +rap_hash_t rap_hash_function_node_imprecise(cgraph_node_ptr node); +const_tree type_name(const_tree type); +tree create_new_var(tree type, const char *name); + +gimple barrier(tree var, bool full); + +#if BUILDING_GCC_VERSION >= 4009 +opt_pass *make_rap_fptr_pass(void); +#else +struct opt_pass *make_rap_fptr_pass(void); +#endif + +#endif diff --git a/scripts/gcc-plugins/rap_plugin/rap_fptr_pass.c b/scripts/gcc-plugins/rap_plugin/rap_fptr_pass.c new file mode 100644 index 0000000..2f53f14 --- /dev/null +++ b/scripts/gcc-plugins/rap_plugin/rap_fptr_pass.c @@ -0,0 +1,220 @@ +/* + * Copyright 2012-2016 by PaX Team + * Licensed under the GPL v2 + * + * Homepage: http://pax.grsecurity.net/ + */ + +#include "rap.h" + +bool report_fptr_hash; + +static bool rap_fptr_gate(void) +{ +#ifdef TARGET_386 + tree section; + + if (!TARGET_64BIT || ix86_cmodel != CM_KERNEL) + return true; + + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl)); + if (!section || !TREE_VALUE(section)) + return true; + + section = TREE_VALUE(TREE_VALUE(section)); + return strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10); +#else +#error unsupported target +#endif +} + +static tree build_rap_hash(gimple call_stmt, tree fntype) +{ + rap_hash_t hash; + + hash = rap_hash_function_type(fntype, imprecise_rap_hash_flags); + if (report_fptr_hash) + inform(gimple_location(call_stmt), "fptr rap_hash: %x", hash.hash); + return build_int_cst_type(rap_hash_type_node, hash.hash); +} + +// check the function hash of the target of the fptr +static basic_block rap_instrument_fptr(gimple_stmt_iterator *gsi) +{ + gimple assign_hash, check_hash, call_stmt, stmt; + location_t loc; + tree computed_hash, target_hash, fptr, fntype; +#if BUILDING_GCC_VERSION == 4005 + tree fptr2; +#endif + basic_block cond_bb, join_bb, true_bb; + edge e; + const HOST_WIDE_INT rap_hash_offset = TARGET_64BIT ? 2 * sizeof(rap_hash_t) : sizeof(rap_hash_t); + + call_stmt = gsi_stmt(*gsi); + loc = gimple_location(call_stmt); + fptr = gimple_call_fn(call_stmt); + fntype = TREE_TYPE(TREE_TYPE(fptr)); + + if (TREE_CODE(fntype) == FUNCTION_TYPE) { + computed_hash = build_rap_hash(call_stmt, fntype); + } else { + debug_tree(fntype); + gcc_unreachable(); + } + + // target_hash = ((s64*)fptr)[-rap_hash_offset] + target_hash = create_tmp_var(rap_hash_type_node, "rap_hash"); + add_referenced_var(target_hash); + target_hash = make_ssa_name(target_hash, NULL); +#if BUILDING_GCC_VERSION == 4005 + fptr2 = create_tmp_var(ptr_type_node, "rap_fptr2"); + fptr2 = make_ssa_name(fptr2, NULL); + assign_hash = gimple_build_assign(fptr2, build2(POINTER_PLUS_EXPR, ptr_type_node, fptr, build_int_cst_type(sizetype, -rap_hash_offset))); + gimple_set_location(assign_hash, loc); + SSA_NAME_DEF_STMT(fptr2) = assign_hash; + gsi_insert_before(gsi, assign_hash, GSI_SAME_STMT); + update_stmt(assign_hash); + fptr = gimple_get_lhs(assign_hash); + + fptr2 = create_tmp_var(build_pointer_type(rap_hash_type_node), "rap_fptr2"); + fptr2 = make_ssa_name(fptr2, NULL); + assign_hash = gimple_build_assign(fptr2, fold_convert(build_pointer_type(TREE_TYPE(target_hash)), fptr)); + gimple_set_location(assign_hash, loc); + SSA_NAME_DEF_STMT(fptr2) = assign_hash; + gsi_insert_before(gsi, assign_hash, GSI_SAME_STMT); + update_stmt(assign_hash); + fptr = gimple_get_lhs(assign_hash); + + assign_hash = gimple_build_assign(target_hash, build1(INDIRECT_REF, rap_hash_type_node, fptr)); +#else + assign_hash = gimple_build_assign(target_hash, build2(MEM_REF, rap_hash_type_node, fptr, build_int_cst_type(build_pointer_type(rap_hash_type_node), -rap_hash_offset))); +#endif + gimple_set_location(assign_hash, loc); + SSA_NAME_DEF_STMT(target_hash) = assign_hash; + gsi_insert_before(gsi, assign_hash, GSI_NEW_STMT); + update_stmt(assign_hash); + + // compare target_hash against computed function hash + // bail out on mismatch + check_hash = gimple_build_cond(NE_EXPR, target_hash, computed_hash, NULL_TREE, NULL_TREE); + gimple_set_location(check_hash, loc); + gsi_insert_after(gsi, check_hash, GSI_NEW_STMT); + + cond_bb = gimple_bb(gsi_stmt(*gsi)); + gcc_assert(!gsi_end_p(*gsi)); + gcc_assert(check_hash == gsi_stmt(*gsi)); + + e = split_block(cond_bb, gsi_stmt(*gsi)); + cond_bb = e->src; + join_bb = e->dest; + e->flags = EDGE_FALSE_VALUE; + e->probability = REG_BR_PROB_BASE; + + true_bb = create_empty_bb(EXIT_BLOCK_PTR_FOR_FN(cfun)->prev_bb); + make_edge(cond_bb, true_bb, EDGE_TRUE_VALUE | EDGE_PRESERVE); + + gcc_assert(dom_info_available_p(CDI_DOMINATORS)); + set_immediate_dominator(CDI_DOMINATORS, true_bb, cond_bb); + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb); + + gcc_assert(cond_bb->loop_father == join_bb->loop_father); + add_bb_to_loop(true_bb, cond_bb->loop_father); + + *gsi = gsi_start_bb(true_bb); + + // this fake dependency is to prevent PRE from merging this BB with others of the same kind + stmt = barrier(fptr, false); + gimple_set_location(stmt, loc); + gsi_insert_after(gsi, stmt, GSI_CONTINUE_LINKING); + + stmt = gimple_build_call(builtin_decl_implicit(BUILT_IN_TRAP), 0); + gimple_set_location(stmt, loc); + gsi_insert_after(gsi, stmt, GSI_CONTINUE_LINKING); + + return join_bb; +} + +// find all language level function pointer dereferences and verify the target function +static unsigned int rap_fptr_execute(void) +{ + basic_block bb; + + loop_optimizer_init(LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS); + gcc_assert(current_loops); + + calculate_dominance_info(CDI_DOMINATORS); + calculate_dominance_info(CDI_POST_DOMINATORS); + + // 1. loop through BBs and GIMPLE statements + FOR_EACH_BB_FN(bb, cfun) { + gimple_stmt_iterator gsi; + + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) { + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D)); + tree fptr, fntype; + gimple call_stmt; + + // is it a call ... + call_stmt = gsi_stmt(gsi); + if (!is_gimple_call(call_stmt)) + continue; + + fptr = gimple_call_fn(call_stmt); + if (!fptr) + continue; + + switch (TREE_CODE(fptr)) { + default: + debug_gimple_stmt(call_stmt); + debug_tree(fptr); + debug_tree(TREE_TYPE(fptr)); + gcc_unreachable(); + + case ADDR_EXPR: + continue; + + case SSA_NAME: + if (SSA_NAME_VAR(fptr) == NULL_TREE) + break; + + switch (TREE_CODE(SSA_NAME_VAR(fptr))) { + default: + debug_gimple_stmt(call_stmt); + debug_tree(fptr); + gcc_unreachable(); + + case VAR_DECL: + case PARM_DECL: + break; + } + break; + + case INTEGER_CST: + case OBJ_TYPE_REF: + break; + } + + // ... through a function pointer + fntype = TREE_TYPE(fptr); + if (TREE_CODE(fntype) != POINTER_TYPE) + continue; + + fntype = TREE_TYPE(fntype); + gcc_assert(TREE_CODE(fntype) == FUNCTION_TYPE || TREE_CODE(fntype) == METHOD_TYPE); + + bb = rap_instrument_fptr(&gsi); + gsi = gsi_start_bb(bb); + } + } + + free_dominance_info(CDI_DOMINATORS); + free_dominance_info(CDI_POST_DOMINATORS); + loop_optimizer_finalize(); + + return 0; +} + +#define PASS_NAME rap_fptr +#define TODO_FLAGS_FINISH TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa | TODO_cleanup_cfg | TODO_rebuild_cgraph_edges | TODO_verify_flow +#include "gcc-generate-gimple-pass.h" diff --git a/scripts/gcc-plugins/rap_plugin/rap_hash.c b/scripts/gcc-plugins/rap_plugin/rap_hash.c new file mode 100644 index 0000000..7c59f38 --- /dev/null +++ b/scripts/gcc-plugins/rap_plugin/rap_hash.c @@ -0,0 +1,382 @@ +/* + * Copyright 2012-2016 by PaX Team + * Licensed under the GPL v2 + * + * Homepage: http://pax.grsecurity.net/ + */ + +#include "rap.h" + +static rap_hash_t *rap_imprecise_hashes; +static int rap_cgraph_max_uid; + +static void rap_hash_function(const_tree fntype, rap_hash_flags_t flags, unsigned char sip_hash[8]); + +static const unsigned char rap_hash_tree_code[MAX_TREE_CODES] = { + [0] = 0, + [1] = 0, + [2] = 0, + [3] = 0, + [4] = 0, + [OFFSET_TYPE] = 10, + [ENUMERAL_TYPE] = 20, + [BOOLEAN_TYPE] = 30, + [INTEGER_TYPE] = 40, + [REAL_TYPE] = 50, + [POINTER_TYPE] = 60, + [REFERENCE_TYPE] = 70, +#if BUILDING_GCC_VERSION >= 4006 + [NULLPTR_TYPE] = 80, +#endif + [FIXED_POINT_TYPE] = 0, + [COMPLEX_TYPE] = 100, + [VECTOR_TYPE] = 110, + [ARRAY_TYPE] = 120, + [RECORD_TYPE] = 130, + [UNION_TYPE] = 140, + [QUAL_UNION_TYPE] = 0, + [VOID_TYPE] = 160, +#if BUILDING_GCC_VERSION >= 5000 + [POINTER_BOUNDS_TYPE] = 170, +#endif + [FUNCTION_TYPE] = 180, + [METHOD_TYPE] = 0, + [LANG_TYPE] = 0, +}; + +static void rap_fold_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen) +{ + static const unsigned char rap_sip_key[16] = { + 'P', 'a', 'X', ' ', 'T', 'e', 'a', 'm', + 'R', 'A', 'P', ' ', 'H', 'A', 'S', 'H', + }; + + siphash24fold(out, in, inlen, rap_sip_key); +} + +// compute the final hash value in the range [1,INT_MAX] +// the % and +1 trick leaves the value 0 available for marking non-indirectly callable functions +// and INT_MIN (0x80000000) for longjmp targets (sign extended) +// return places will use the (sign extended) range [INT_MIN+1,-1] ([0x8000001,0xffffffff]) +static rap_hash_t rap_extract_hash(const unsigned char sip_hash[8]) +{ + rap_hash_t hash; + unsigned long long dividend, divisor; + + memcpy(÷nd, sip_hash, sizeof dividend); +// divisor = 1ULL << (sizeof hash * 8 - 1); +// divisor |= divisor - 1; + divisor = 0x7fffffffUL; + hash.hash = dividend % divisor + 1; + return hash; +} + +static void rap_hash_type_name(const_tree type, unsigned char sip_hash[8]) +{ + const_tree name = type_name(TYPE_MAIN_VARIANT(type)); + + // handle typedefs of anonymous structs/unions + if (name == NULL_TREE) + name = type_name(type); + + if (name == NULL_TREE) + return; + + gcc_assert(TREE_CODE(name) == IDENTIFIER_NODE); + rap_fold_hash(sip_hash, (const unsigned char *)IDENTIFIER_POINTER(name), IDENTIFIER_LENGTH(name)); +} + +static void rap_hash_type_precision(const_tree type, unsigned char sip_hash[8]) +{ + unsigned HOST_WIDE_INT size; + + gcc_assert(TYPE_PRECISION(type)); + + size = TYPE_PRECISION(type); + rap_fold_hash(sip_hash, (const unsigned char *)&size, sizeof size); +} + +const_tree type_name(const_tree type) +{ + const_tree name; + + name = TYPE_NAME(type); + if (!name) + return NULL_TREE; + + switch (TREE_CODE(name)) { + case IDENTIFIER_NODE: + return name; + + case TYPE_DECL: + gcc_assert(DECL_NAME(name)); + return DECL_NAME(name); + + default: + gcc_unreachable(); + } +} + +__attribute__((weak)) tree c_global_trees[CTI_MAX]; + +// the core computation of the rap hash +// the first piece is a (hopefully) compiler independent encondig of the type, derived from the gcc tree code +// the second piece is type specific information, such as the size, qualifiers, (recursively) referenced types, etc +static void rap_hash_tree(const_tree type, rap_hash_flags_t flags, unsigned char sip_hash[8]) +{ + enum tree_code code; + unsigned int attrs; + + code = TREE_CODE(type); + attrs = rap_hash_tree_code[code]; + if (!attrs) { + fprintf(stderr, "unhandled tree_code %s %d\n", get_tree_code_name(code), code); + debug_tree(type); + gcc_unreachable(); + } + rap_fold_hash(sip_hash, (const unsigned char *)&attrs, sizeof attrs); + + enum { + // attrs layout for + // - all types: + RAP_HASH_VOLATILE = 1U << 31, + RAP_HASH_NOT_VOLATILE = 1U << 30, + RAP_HASH_CONST = 1U << 29, + RAP_HASH_NOT_CONST = 1U << 28, + + // - pointer types: + RAP_HASH_RESTRICT = 1U << 27, + RAP_HASH_NOT_RESTRICT = 1U << 26, + + // - C integer types: + RAP_HASH_UNSIGNED = 1U << 25, + RAP_HASH_SIGNED = 1U << 24, + + RAP_HASH_UNQUALIFIED_CHAR = 1U << 23, + RAP_HASH_CHAR = 1U << 22, + RAP_HASH_SHORT = 1U << 21, + RAP_HASH_INT = 1U << 20, + RAP_HASH_LONG = 1U << 19, + RAP_HASH_LONG_LONG = 1U << 18, + RAP_HASH_WCHAR = 1U << 17, + RAP_HASH_CHAR16 = 1U << 16, + RAP_HASH_CHAR32 = 1U << 15, + + // - C float types + RAP_HASH_FLOAT = 1U << 14, + RAP_HASH_DOUBLE = 1U << 13, + RAP_HASH_LONG_DOUBLE = 1U << 12, + RAP_HASH_DFLOAT32 = 1U << 11, + RAP_HASH_DFLOAT64 = 1U << 10, + RAP_HASH_DFLOAT128 = 1U << 9, + }; + + attrs = 0; + if (flags.qual_volatile) + attrs |= TYPE_VOLATILE(type) ? RAP_HASH_VOLATILE : RAP_HASH_NOT_VOLATILE; + if (flags.qual_const) + attrs |= TYPE_READONLY(type) ? RAP_HASH_CONST : RAP_HASH_NOT_CONST; + + switch (code) { + default: + debug_tree(type); + gcc_unreachable(); + break; + + case VOID_TYPE: + break; + + case OFFSET_TYPE: + rap_hash_tree(TREE_TYPE(type), flags, sip_hash); + rap_hash_tree(TYPE_OFFSET_BASETYPE(type), flags, sip_hash); + break; + + case FUNCTION_TYPE: + rap_hash_function(type, flags, sip_hash); + break; + + case RECORD_TYPE: + rap_hash_type_name(type, sip_hash); + break; + + case UNION_TYPE: + rap_hash_type_name(type, sip_hash); + break; + + case POINTER_TYPE: + case REFERENCE_TYPE: + rap_hash_tree(TREE_TYPE(type), flags, sip_hash); + break; + + case VECTOR_TYPE: + rap_hash_tree(TREE_TYPE(type), flags, sip_hash); + rap_hash_type_precision(TREE_TYPE(type), sip_hash); + break; + + case ARRAY_TYPE: + rap_hash_tree(TREE_TYPE(type), flags, sip_hash); + break; + + case REAL_TYPE: { + const_tree main_variant = TYPE_MAIN_VARIANT(type); + + switch (TYPE_PRECISION(main_variant)) { + default: + debug_tree(type); + debug_tree(TYPE_MAIN_VARIANT(type)); + gcc_unreachable(); + + case 32: +// attrs |= RAP_HASH_FLOAT; + break; + + case 64: +// attrs |= RAP_HASH_DOUBLE; + break; + + case 80: + case 128: + attrs |= RAP_HASH_LONG_DOUBLE; + break; + } + rap_hash_type_precision(main_variant, sip_hash); + break; + } + + case ENUMERAL_TYPE: + rap_hash_type_name(type, sip_hash); + case BOOLEAN_TYPE: + rap_hash_type_precision(type, sip_hash); + break; + + case INTEGER_TYPE: { + attrs |= TYPE_UNSIGNED(type) ? RAP_HASH_UNSIGNED : RAP_HASH_SIGNED; + rap_hash_type_precision(type, sip_hash); + break; + } + } + + rap_fold_hash(sip_hash, (const unsigned char *)&attrs, sizeof attrs); +} + +static const_tree rap_dequal_argtype(const_tree argtype) +{ + // since gcc/tree.c:free_lang_data_in_type removes const/volatile from the top level param decl + // we have to simulate it here as this can be called earlier from the frontend as well + if (TYPE_READONLY(argtype) || TYPE_VOLATILE(argtype)) { + int quals; + + quals = TYPE_QUALS(argtype) & ~TYPE_QUAL_CONST & ~TYPE_QUAL_VOLATILE; + argtype = build_qualified_type(CONST_CAST_TREE(argtype), quals); + } + + return argtype; +} + +// main function to compute the rap hash for function types +// while virtual class methods are always replaced with their ancestor, +// callers can decide whether to fully utilize that information via flags.method_ancestor +static void rap_hash_function(const_tree fntype, rap_hash_flags_t flags, unsigned char sip_hash[8]) +{ + function_args_iterator args_iter; + const_tree arg; + + switch (TREE_CODE(fntype)) { + default: + debug_tree(fntype); + gcc_unreachable(); + + case FUNCTION_TYPE: + // 1. hash the result + rap_hash_tree(TREE_TYPE(fntype), flags, sip_hash); + + // 2. hash the function parameters + FOREACH_FUNCTION_ARGS(fntype, arg, args_iter) { + const_tree argtype = arg; + + argtype = rap_dequal_argtype(argtype); + rap_hash_tree(argtype, flags, sip_hash); + } + break; + } +} + +rap_hash_t rap_hash_function_type(const_tree fntype, rap_hash_flags_t flags) +{ + unsigned char sip_hash[8] = { }; + rap_hash_t hash; + + rap_hash_function(fntype, flags, sip_hash); + hash = rap_extract_hash(sip_hash); + + gcc_assert(hash.hash); + return hash; +} + +rap_hash_t rap_hash_function_decl(const_tree fndecl, rap_hash_flags_t flags) +{ + tree fntype; + + gcc_assert(TREE_CODE(fndecl) == FUNCTION_DECL); + fntype = TREE_TYPE(fndecl); + + switch (TREE_CODE(fntype)) { + default: + debug_tree(fndecl); + gcc_unreachable(); + + case FUNCTION_TYPE: + return rap_hash_function_type(fntype, flags); + } +} + +rap_hash_t rap_hash_function_node_imprecise(cgraph_node_ptr node) +{ + rap_hash_t hash; + tree fndecl; + + gcc_assert(rap_imprecise_hashes); + + hash.hash = 0; + if (node->uid < rap_cgraph_max_uid) + hash = rap_imprecise_hashes[node->uid]; + + if (hash.hash) + return hash; + + fndecl = NODE_DECL(node); + if (TREE_CODE(TREE_TYPE(fndecl)) == FUNCTION_TYPE) + return rap_hash_function_decl(fndecl, imprecise_rap_hash_flags); + + debug_cgraph_node(node); + debug_tree(fndecl); + error("indirect call to function %qD with a reserved hash value", fndecl); + return hash; +} + +void rap_calculate_func_hashes(void *event_data __unused, void *data __unused) +{ + cgraph_node_ptr node; + int uid; + + gcc_assert(!rap_imprecise_hashes); + + rap_imprecise_hashes = (rap_hash_t *)xcalloc(cgraph_max_uid, sizeof(*rap_imprecise_hashes)); + rap_cgraph_max_uid = cgraph_max_uid; + + FOR_EACH_FUNCTION(node) { + const_tree fndecl; + + uid = node->uid; + gcc_assert(uid < rap_cgraph_max_uid); + + if (node->global.inlined_to) + continue; + + fndecl = NODE_DECL(node); + gcc_assert(fndecl); + + rap_imprecise_hashes[uid] = rap_hash_function_decl(fndecl, imprecise_rap_hash_flags); + gcc_assert(rap_imprecise_hashes[uid].hash); + } +} diff --git a/scripts/gcc-plugins/rap_plugin/rap_plugin.c b/scripts/gcc-plugins/rap_plugin/rap_plugin.c new file mode 100644 index 0000000..658c305 --- /dev/null +++ b/scripts/gcc-plugins/rap_plugin/rap_plugin.c @@ -0,0 +1,534 @@ +/* + * Copyright 2012-2016 by PaX Team + * Licensed under the GPL v2 + * + * Homepage: http://pax.grsecurity.net/ + * + * Usage: + * $ # for 4.5/4.6/C based 4.7 + * $ gcc -I`gcc -print-file-name=plugin`/include -I`gcc -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o rap_plugin.so rap_plugin.c + * $ # for C++ based 4.7/4.8+ + * $ g++ -I`g++ -print-file-name=plugin`/include -I`g++ -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o rap_plugin.so rap_plugin.c + * $ gcc -fplugin=./rap_plugin.so -fplugin-arg-rap_plugin-check=call test.c -O2 + */ + +#include "rap.h" + +__visible int plugin_is_GPL_compatible; + +static struct plugin_info rap_plugin_info = { + .version = "201604272100", + .help = "check=call\tenable the corresponding features\n" + "hash=abs,abs-finish,const,volatile\n" + "report=func,fptr,abs\n" +}; + +rap_hash_flags_t imprecise_rap_hash_flags = { + .qual_const = 1, + .qual_volatile = 1, +}; + +tree rap_hash_type_node; + +static bool report_func_hash, report_abs_hash; + +// create the equivalent of +// asm volatile("" : : : "memory"); +// or +// asm("" : "+rm"(var)); +// or +// asm("" : : "rm"(var)); +gimple barrier(tree var, bool full) +{ + gimple stmt; + gasm *asm_stmt; +#if BUILDING_GCC_VERSION <= 4007 + VEC(tree, gc) *inputs = NULL; + VEC(tree, gc) *outputs = NULL; + VEC(tree, gc) *clobbers = NULL; +#else + vec *inputs = NULL; + vec *outputs = NULL; + vec *clobbers = NULL; +#endif + + if (!var && full) { + tree clobber; + + clobber = build_tree_list(NULL_TREE, build_string(7, "memory")); +#if BUILDING_GCC_VERSION <= 4007 + VEC_safe_push(tree, gc, clobbers, clobber); +#else + vec_safe_push(clobbers, clobber); +#endif + } else if (full) { + tree input, output; + + input = build_tree_list(NULL_TREE, build_string(2, "0")); + input = chainon(NULL_TREE, build_tree_list(input, var)); +#if BUILDING_GCC_VERSION <= 4007 + VEC_safe_push(tree, gc, inputs, input); +#else + vec_safe_push(inputs, input); +#endif + + output = build_tree_list(NULL_TREE, build_string(4, "=rm")); + gcc_assert(SSA_NAME_VAR(var)); + var = make_ssa_name(SSA_NAME_VAR(var), NULL); + output = chainon(NULL_TREE, build_tree_list(output, var)); +#if BUILDING_GCC_VERSION <= 4007 + VEC_safe_push(tree, gc, outputs, output); +#else + vec_safe_push(outputs, output); +#endif + } else { + tree input; + + input = build_tree_list(NULL_TREE, build_string(3, "rm")); + input = chainon(NULL_TREE, build_tree_list(input, var)); +#if BUILDING_GCC_VERSION <= 4007 + VEC_safe_push(tree, gc, inputs, input); +#else + vec_safe_push(inputs, input); +#endif + } + + stmt = gimple_build_asm_vec("", inputs, outputs, clobbers, NULL); + asm_stmt = as_a_gasm(stmt); + if (!var && full) + gimple_asm_set_volatile(asm_stmt, true); + else if (full) + SSA_NAME_DEF_STMT(var) = stmt; + return stmt; +} + +static const struct gcc_debug_hooks *old_debug_hooks; +static struct gcc_debug_hooks rap_debug_hooks; + +static bool __rap_cgraph_indirectly_callable(cgraph_node_ptr node, void *data) +{ +#if BUILDING_GCC_VERSION >= 4008 + if (NODE_SYMBOL(node)->externally_visible) +#else + if (node->local.externally_visible) +#endif + return true; + + if (NODE_SYMBOL(node)->address_taken) + return true; + + return false; +} + +static bool rap_cgraph_indirectly_callable(cgraph_node_ptr node) +{ + return cgraph_for_node_and_aliases(node, __rap_cgraph_indirectly_callable, NULL, true); +} + +static void rap_hash_align(tree decl) +{ + const unsigned HOST_WIDE_INT rap_hash_offset = TARGET_64BIT ? 2 * sizeof(rap_hash_t) : sizeof(rap_hash_t); + unsigned HOST_WIDE_INT skip; + + skip = 1ULL << align_functions_log; + if (DECL_USER_ALIGN(decl)) + return; + + if (!optimize_function_for_speed_p(cfun)) + return; + + if (skip <= rap_hash_offset) + return; + +#ifdef TARGET_386 + { + char padding[skip - rap_hash_offset]; + + // this byte sequence helps disassemblers not trip up on the following rap hash + memset(padding, 0xcc, sizeof padding - 1); + padding[sizeof padding - 1] = 0xb8; + ASM_OUTPUT_ASCII(asm_out_file, padding, sizeof padding); + } +#else + ASM_OUTPUT_SKIP(asm_out_file, skip - rap_hash_offset); +#endif +} + +static void rap_begin_function(tree decl) +{ + cgraph_node_ptr node; + rap_hash_t imprecise_rap_hash; + + gcc_assert(debug_hooks == &rap_debug_hooks); + + // chain to previous callback + if (old_debug_hooks && old_debug_hooks->begin_function) + old_debug_hooks->begin_function(decl); + + // align the rap hash if necessary + rap_hash_align(decl); + + // don't compute hash for functions called only directly + node = cgraph_get_node(decl); + gcc_assert(node); + if (!rap_cgraph_indirectly_callable(node)) { + imprecise_rap_hash.hash = 0; + } else { + imprecise_rap_hash = rap_hash_function_node_imprecise(node); + } + + if (report_func_hash) + inform(DECL_SOURCE_LOCATION(decl), "func rap_hash: %x %s", imprecise_rap_hash.hash, IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(decl))); + + if (TARGET_64BIT) + fprintf(asm_out_file, "\t.quad %#lx\t%s __rap_hash_%s\n", (long)imprecise_rap_hash.hash, ASM_COMMENT_START, IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(decl))); + else + fprintf(asm_out_file, "\t.long %#x\t%s __rap_hash_%s\n", imprecise_rap_hash.hash, ASM_COMMENT_START, IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(decl))); +} + +static void rap_start_unit_common(void *gcc_data __unused, void *user_data __unused) +{ + rap_hash_type_node = long_integer_type_node; + + if (debug_hooks) + rap_debug_hooks = *debug_hooks; + rap_debug_hooks.begin_function = rap_begin_function; + old_debug_hooks = debug_hooks; + debug_hooks = &rap_debug_hooks; +} + +/* + emit an absolute symbol for each function that may be referenced through the plt + - all externs + - non-static functions + - use visibility instead? + + .globl __rap_hash_func + .offset 0xhash_for_func + .type __rap_hash_func, @object + __rap_hash_func: + .previous +*/ +static void rap_finish_unit(void *gcc_data __unused, void *user_data __unused) +{ + cgraph_node_ptr node; + rap_hash_t hash; + + gcc_assert(debug_hooks == &rap_debug_hooks); + + hash.hash = 0; + FOR_EACH_FUNCTION(node) { + tree fndecl; + const char *asmname; + char *name = NULL; + + if (cgraph_function_body_availability(node) >= AVAIL_INTERPOSABLE) { + if (node->thunk.thunk_p || node->alias) + continue; + if (!rap_cgraph_indirectly_callable(node)) + continue; + } + +#if BUILDING_GCC_VERSION >= 4007 + gcc_assert(cgraph_function_or_thunk_node(node, NULL) == node); +#endif + + fndecl = NODE_DECL(node); + gcc_assert(fndecl); + if (DECL_IS_BUILTIN(fndecl) && DECL_BUILT_IN_CLASS(fndecl) == BUILT_IN_NORMAL) + continue; + + if (!TREE_PUBLIC(fndecl)) + continue; + + if (DECL_ARTIFICIAL(fndecl)) + continue; + + if (DECL_ABSTRACT_ORIGIN(fndecl) && DECL_ABSTRACT_ORIGIN(fndecl) != fndecl) + continue; + + gcc_assert(DECL_ASSEMBLER_NAME(fndecl)); + asmname = IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(fndecl)); + if (strchr(asmname, '.')) + continue; + + if (asmname[0] == '*') + asmname++; + + gcc_assert(asmname[0]); + gcc_assert(asprintf(&name, "__rap_hash_%s", asmname) != -1); + + hash = rap_hash_function_node_imprecise(node); + if (report_abs_hash) + inform(DECL_SOURCE_LOCATION(fndecl), "abs rap_hash: %x %s", hash.hash, IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(fndecl))); + + fprintf(asm_out_file, GLOBAL_ASM_OP " %s\n", name); + if (TARGET_64BIT) + fprintf(asm_out_file, "\t.offset %#lx\n", (long)hash.hash); + else + fprintf(asm_out_file, "\t.offset %#x\n", hash.hash); + ASM_OUTPUT_TYPE_DIRECTIVE(asm_out_file, name, "object"); + ASM_OUTPUT_LABEL(asm_out_file, name); + free(name); + } + + if (hash.hash) + fprintf(asm_out_file, "\t.previous\n"); +} + +#if BUILDING_GCC_VERSION >= 4007 +// emit the rap hash as an absolute symbol for all functions seen in the frontend +// this is necessary as later unreferenced nodes will be removed yet we'd like to emit as many hashes as possible +static void rap_finish_decl(void *event_data, void *data __unused) +{ + tree fndecl = (tree)event_data; + rap_hash_t hash; + const char *asmname; + char *name = NULL; + + if (fndecl == error_mark_node) + return; + + if (TREE_CODE(fndecl) != FUNCTION_DECL) + return; + + if (!TREE_PUBLIC(fndecl)) + return; + + if (DECL_ARTIFICIAL(fndecl)) + return; + + if (DECL_ABSTRACT_ORIGIN(fndecl) && DECL_ABSTRACT_ORIGIN(fndecl) != fndecl) + return; + + asmname = DECL_NAME_POINTER(fndecl); + gcc_assert(asmname[0]); + + if (strchr(asmname, '.')) + return; + + gcc_assert(asprintf(&name, "__rap_hash_%s", asmname) != -1); + + hash = rap_hash_function_decl(fndecl, imprecise_rap_hash_flags); + + if (report_abs_hash) + inform(DECL_SOURCE_LOCATION(fndecl), "abs rap_hash: %x %s", hash.hash, asmname); + + fprintf(asm_out_file, GLOBAL_ASM_OP " %s\n", name); + if (TARGET_64BIT) + fprintf(asm_out_file, "\t.offset %#lx\n", (long)hash.hash); + else + fprintf(asm_out_file, "\t.offset %#x\n", hash.hash); + ASM_OUTPUT_TYPE_DIRECTIVE(asm_out_file, name, "object"); + ASM_OUTPUT_LABEL(asm_out_file, name); + free(name); + + fprintf(asm_out_file, "\t.previous\n"); +} +#endif + +static bool rap_unignore_gate(void) +{ + if (!DECL_IGNORED_P(current_function_decl)) + return false; + + inform(DECL_SOURCE_LOCATION(current_function_decl), "DECL_IGNORED fixed"); + + DECL_IGNORED_P(current_function_decl) = 0; + return false; +} + +#define PASS_NAME rap_unignore +#define NO_EXECUTE +#define TODO_FLAGS_FINISH TODO_dump_func +#include "gcc-generate-rtl-pass.h" + +static bool rap_version_check(struct plugin_gcc_version *gcc_version, struct plugin_gcc_version *plugin_version) +{ + if (!gcc_version || !plugin_version) + return false; + +#if BUILDING_GCC_VERSION >= 5000 + if (strncmp(gcc_version->basever, plugin_version->basever, 4)) +#else + if (strcmp(gcc_version->basever, plugin_version->basever)) +#endif + return false; + if (strcmp(gcc_version->datestamp, plugin_version->datestamp)) + return false; + if (strcmp(gcc_version->devphase, plugin_version->devphase)) + return false; + if (strcmp(gcc_version->revision, plugin_version->revision)) + return false; +// if (strcmp(gcc_version->configuration_arguments, plugin_version->configuration_arguments)) +// return false; + return true; +} + +EXPORTED_CONST struct ggc_root_tab gt_ggc_r_gt_rap[] = { + { + .base = &rap_hash_type_node, + .nelt = 1, + .stride = sizeof(rap_hash_type_node), + .cb = >_ggc_mx_tree_node, + .pchw = >_pch_nx_tree_node + }, + LAST_GGC_ROOT_TAB +}; + +static void +handle_type_cast (void *gcc_data, void *user_data) +{ + (void) user_data; + tree *t = (tree *) gcc_data; + tree type = t[0]; + tree otype = t[1]; + + if (TREE_CODE (type) == POINTER_TYPE + && TREE_CODE (otype) == POINTER_TYPE + && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE + && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE +// && type != TYPE_MAIN_VARIANT (otype) + && TYPE_CANONICAL (TREE_TYPE (type)) != TYPE_CANONICAL (TREE_TYPE (otype))) + error (G_("cast from function type %qT " + "to non-matching type %qT"), otype, type); + +} + +__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) +{ + int i; + const char * const plugin_name = plugin_info->base_name; + const int argc = plugin_info->argc; + const struct plugin_argument * const argv = plugin_info->argv; + bool enable_call = false; + bool enable_abs = false, enable_abs_finish = false; + + struct register_pass_info rap_fptr_pass_info; + struct register_pass_info rap_unignore_pass_info; + + rap_fptr_pass_info.pass = make_rap_fptr_pass(); + rap_fptr_pass_info.reference_pass_name = "nrv"; + rap_fptr_pass_info.ref_pass_instance_number = 1; + rap_fptr_pass_info.pos_op = PASS_POS_INSERT_AFTER; + + rap_unignore_pass_info.pass = make_rap_unignore_pass(); + rap_unignore_pass_info.reference_pass_name = "final"; + rap_unignore_pass_info.ref_pass_instance_number = 1; + rap_unignore_pass_info.pos_op = PASS_POS_INSERT_BEFORE; + + if (!rap_version_check(version, &gcc_version)) { + error(G_("incompatible gcc/plugin versions")); + return 1; + } + +#if BUILDING_GCC_VERSION >= 5000 + if (flag_ipa_icf_functions) { +// warning_at(UNKNOWN_LOCATION, 0, G_("-fipa-icf is incompatible with %s, disabling..."), plugin_name); +// inform(UNKNOWN_LOCATION, G_("-fipa-icf is incompatible with %s, disabling..."), plugin_name); + flag_ipa_icf_functions = 0; + } +#endif + + for (i = 0; i < argc; ++i) { + if (!strcmp(argv[i].key, "disable")) + continue; + + if (!strcmp(argv[i].key, "check")) { + char *values, *value, *saveptr; + + if (!argv[i].value) { + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key); + continue; + } + + values = xstrdup(argv[i].value); + value = strtok_r(values, ",", &saveptr); + while (value) { + if (!strcmp(value, "call")) + enable_call = true; + else + error(G_("unknown value supplied for option '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, value); + value = strtok_r(NULL, ",", &saveptr); + } + free(values); + continue; + } + + if (!strcmp(argv[i].key, "hash")) { + char *values, *value, *saveptr; + + if (!argv[i].value) { + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key); + continue; + } + + values = xstrdup(argv[i].value); + value = strtok_r(values, ",", &saveptr); + while (value) { + if (!strcmp(value, "abs")) + enable_abs = enable_abs_finish = true; + else if (!strcmp(value, "abs-finish")) + enable_abs_finish = true; +// else if (!strcmp(value, "const")) +// imprecise_rap_hash_flags.qual_const = 1; +// else if (!strcmp(value, "volatile")) +// imprecise_rap_hash_flags.qual_volatile = 1; + else + error(G_("unknown value supplied for option '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, value); + value = strtok_r(NULL, ",", &saveptr); + } + free(values); + continue; + } + + if (!strcmp(argv[i].key, "report")) { + char *values, *value, *saveptr; + + if (!argv[i].value) { + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key); + continue; + } + + values = xstrdup(argv[i].value); + value = strtok_r(values, ",", &saveptr); + while (value) { + if (!strcmp(value, "func")) + report_func_hash = true; + else if (!strcmp(value, "fptr")) + report_fptr_hash = true; + else if (!strcmp(value, "abs")) + report_abs_hash = true; + else + error(G_("unknown value supplied for option '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, value); + value = strtok_r(NULL, ",", &saveptr); + } + free(values); + continue; + } + + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key); + } + + register_callback(plugin_name, PLUGIN_INFO, NULL, &rap_plugin_info); + + if (enable_call) { +#if BUILDING_GCC_VERSION >= 4007 + if (enable_abs) + register_callback(plugin_name, PLUGIN_FINISH_DECL, rap_finish_decl, NULL); +#else +#warning TODO +#endif + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &rap_unignore_pass_info); + register_callback(plugin_name, PLUGIN_START_UNIT, rap_start_unit_common, NULL); + register_callback(plugin_name, PLUGIN_REGISTER_GGC_ROOTS, NULL, (void *)>_ggc_r_gt_rap); + if (enable_abs_finish) + register_callback(plugin_name, PLUGIN_FINISH_UNIT, rap_finish_unit, NULL); + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &rap_fptr_pass_info); + register_callback(plugin_name, PLUGIN_ALL_IPA_PASSES_START, rap_calculate_func_hashes, NULL); + register_callback (plugin_name, PLUGIN_TYPE_CAST, handle_type_cast, NULL); + + } + + return 0; +} diff --git a/scripts/gcc-plugins/rap_plugin/sip.c b/scripts/gcc-plugins/rap_plugin/sip.c new file mode 100644 index 0000000..65bc1cd --- /dev/null +++ b/scripts/gcc-plugins/rap_plugin/sip.c @@ -0,0 +1,96 @@ +// SipHash-2-4 adapted by the PaX Team from the public domain version written by +// Jean-Philippe Aumasson +// Daniel J. Bernstein + +#include + +#define ROTL(x, b) (u64)(((x) << (b)) | ((x) >> (64 - (b)))) + +#define U32TO8_LE(p, v) \ + (p)[0] = (u8)((v) ); (p)[1] = (u8)((v) >> 8); \ + (p)[2] = (u8)((v) >> 16); (p)[3] = (u8)((v) >> 24); + +#define U64TO8_LE(p, v) \ + U32TO8_LE((p), (u32)((v) )); \ + U32TO8_LE((p) + 4, (u32)((v) >> 32)); + +#define U8TO64_LE(p) ( \ + ((u64)((p)[0]) ) | \ + ((u64)((p)[1]) << 8) | \ + ((u64)((p)[2]) << 16) | \ + ((u64)((p)[3]) << 24) | \ + ((u64)((p)[4]) << 32) | \ + ((u64)((p)[5]) << 40) | \ + ((u64)((p)[6]) << 48) | \ + ((u64)((p)[7]) << 56)) + +#define SIPROUND \ +do { \ + v0 += v1; v1 = ROTL(v1, 13); v1 ^= v0; v0 = ROTL(v0, 32); \ + v2 += v3; v3 = ROTL(v3, 16); v3 ^= v2; \ + v0 += v3; v3 = ROTL(v3, 21); v3 ^= v0; \ + v2 += v1; v1 = ROTL(v1, 17); v1 ^= v2; v2 = ROTL(v2, 32); \ +} while(0) + +typedef uint64_t u64; +typedef uint32_t u32; +typedef uint8_t u8; + +/* SipHash-2-4 with previous output folding, a poor man's streaming interface */ +void siphash24fold(unsigned char *out, const unsigned char *in, unsigned long long inlen, const unsigned char *k); + +void siphash24fold(unsigned char *out, const unsigned char *in, unsigned long long inlen, const unsigned char *k) +{ + u64 k0 = U8TO64_LE(k); + u64 k1 = U8TO64_LE(k + 8); + /* "somepseudorandomlygeneratedbytes" */ + u64 v0 = 0x736f6d6570736575ULL ^ k0; + u64 v1 = 0x646f72616e646f6dULL ^ k1; + u64 v2 = 0x6c7967656e657261ULL ^ k0; + u64 v3 = 0x7465646279746573ULL ^ k1; + u64 b, m; + const u8 * const end = in + inlen - (inlen % sizeof(u64)); + const int left = inlen & 7; + b = ((u64)inlen) << 56; + + // fold in the previous output + m = U8TO64_LE(out); + v3 ^= m; + SIPROUND; + SIPROUND; + v0 ^= m; + + // consume full input blocks + for (; in != end; in += 8) { + m = U8TO64_LE(in); + v3 ^= m; + SIPROUND; + SIPROUND; + v0 ^= m; + } + + // consume the last potentially partial block + switch (left) { + case 7: b |= ((u64)in[6]) << 48; + case 6: b |= ((u64)in[5]) << 40; + case 5: b |= ((u64)in[4]) << 32; + case 4: b |= ((u64)in[3]) << 24; + case 3: b |= ((u64)in[2]) << 16; + case 2: b |= ((u64)in[1]) << 8; + case 1: b |= ((u64)in[0]); break; + case 0: break; + } + + // finalize + v3 ^= b; + SIPROUND; + SIPROUND; + v0 ^= b; + v2 ^= 0xff; + SIPROUND; + SIPROUND; + SIPROUND; + SIPROUND; + b = v0 ^ v1 ^ v2 ^ v3; + U64TO8_LE(out, b); +} diff --git a/security/Kconfig b/security/Kconfig index 08d4882..bbb8aad 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -81,6 +81,24 @@ config PAX_MPROTECT endif +config PAX_RAP + bool "Prevent code reuse attacks" + depends on X86_64 && GCC_PLUGINS + help + By saying Y here the kernel will check indirect control transfers + in order to detect and prevent attacks that try to hijack control + flow by overwriting code pointers. + + If you have an amd64 processor that does not support SMEP then you + must also enable a KERNEXEC code pointer instrumentation method + (see PAX_KERNEXEC_PLUGIN). + + Note that binary modules cannot be instrumented by this approach. + + Note that the implementation requires a gcc with plugin support, + i.e., gcc 4.5 or newer. You may need to install the supporting + headers explicitly in addition to the normal gcc package. + config PAX_RANDKSTACK bool "Randomize kernel stack base" depends on X86_TSC && X86 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index 1346ee5..17893fd 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -813,11 +813,11 @@ static const struct kernel_param_ops param_ops_aalockpolicy = { .get = param_get_aalockpolicy }; -static int param_set_audit(const char *val, struct kernel_param *kp); -static int param_get_audit(char *buffer, struct kernel_param *kp); +static int param_set_audit(const char *val, const struct kernel_param *kp); +static int param_get_audit(char *buffer, const struct kernel_param *kp); -static int param_set_mode(const char *val, struct kernel_param *kp); -static int param_get_mode(char *buffer, struct kernel_param *kp); +static int param_set_mode(const char *val, const struct kernel_param *kp); +static int param_get_mode(char *buffer, const struct kernel_param *kp); /* Flag values, also controllable via /sys/module/apparmor/parameters * We define special types as we want to do additional mediation. @@ -951,7 +951,7 @@ static int param_get_aauint(char *buffer, const struct kernel_param *kp) return param_get_uint(buffer, kp); } -static int param_get_audit(char *buffer, struct kernel_param *kp) +static int param_get_audit(char *buffer, const struct kernel_param *kp) { if (!apparmor_enabled) return -EINVAL; @@ -960,7 +960,7 @@ static int param_get_audit(char *buffer, struct kernel_param *kp) return sprintf(buffer, "%s", audit_mode_names[aa_g_audit]); } -static int param_set_audit(const char *val, struct kernel_param *kp) +static int param_set_audit(const char *val, const struct kernel_param *kp) { int i; @@ -981,7 +981,7 @@ static int param_set_audit(const char *val, struct kernel_param *kp) return -EINVAL; } -static int param_get_mode(char *buffer, struct kernel_param *kp) +static int param_get_mode(char *buffer, const struct kernel_param *kp) { if (!apparmor_enabled) return -EINVAL; @@ -991,7 +991,7 @@ static int param_get_mode(char *buffer, struct kernel_param *kp) return sprintf(buffer, "%s", aa_profile_mode_names[aa_g_profile_mode]); } -static int param_set_mode(const char *val, struct kernel_param *kp) +static int param_set_mode(const char *val, const struct kernel_param *kp) { int i;