History

Merge tag 's390-5.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 updates from Heiko Carstens: - Make use of the IBM z16 processor activity instrumentation facility to count cryptography operations: add a new PMU device driver so that perf can make use of this. - Add new IBM z16 extended counter set to cpumf support. - Add vdso randomization support. - Add missing KCSAN instrumentation to barriers and spinlocks, which should make s390's KCSAN support complete. - Add support for IPL-complete-control facility: notify the hypervisor that kexec finished work and the kernel starts. - Improve error logging for PCI. - Various small changes to workaround llvm's integrated assembler limitations, and one bug, to make it finally possible to compile the kernel with llvm's integrated assembler. This also requires to raise the minimum clang version to 14.0.0. - Various other small enhancements, bug fixes, and cleanups all over the place. * tag 's390-5.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (48 commits) s390/head: get rid of 31 bit leftovers scripts/min-tool-version.sh: raise minimum clang version to 14.0.0 for s390 s390/boot: do not emit debug info for assembly with llvm's IAS s390/boot: workaround llvm IAS bug s390/purgatory: workaround llvm's IAS limitations s390/entry: workaround llvm's IAS limitations s390/alternatives: remove padding generation code s390/alternatives: provide identical sized orginal/alternative sequences s390/cpumf: add new extended counter set for IBM z16 s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES s390/stp: clock_delta should be signed s390/stp: fix todoff size s390/pai: add support for cryptography counters entry: Rename arch_check_user_regs() to arch_enter_from_user_mode() s390/compat: cleanup compat_linux.h header file s390/entry: remove broken and not needed code s390/boot: convert parmarea to C s390/boot: convert initial lowcore to C s390/ptrace: move short psw definitions to ptrace header file s390/head: initialize all new psws ...

Linus Torvalds committed 4 years ago

Commit 95fbef12 parents 67c642e 94d347798 files · +2553 −1534Browse files

Unified · Split

98 files
  1. arch/s390/Makefile +2 −0
  2. arch/s390/boot/.gitignore +3 −0
  3. arch/s390/boot/Makefile +69 −9
  4. arch/s390/boot/boot.h +5 −1
  5. arch/s390/boot/clz_ctz.c +0 −0
  6. arch/s390/boot/compressed/.gitignore +0 −4
  7. arch/s390/boot/compressed/Makefile +0 −86
  8. arch/s390/boot/decompressor.c +0 −0
  9. arch/s390/boot/decompressor.h +0 −0
  10. arch/s390/boot/head.S +148 −218
  11. arch/s390/boot/ipl_data.c +84 −0
  12. arch/s390/boot/ipl_parm.c +7 −0
  13. arch/s390/boot/kaslr.c +1 −1
  14. arch/s390/boot/mem_detect.c +1 −1
  15. arch/s390/boot/startup.c +1 −1
  16. arch/s390/boot/vmlinux.lds.S +9 −0
  17. arch/s390/crypto/des_s390.c +1 −1
  18. arch/s390/crypto/prng.c +1 −1
  19. arch/s390/hypfs/hypfs_vm.c +1 −1
  20. arch/s390/include/asm/alternative-asm.h +9 −67
  21. arch/s390/include/asm/alternative.h +20 −73
  22. arch/s390/include/asm/asm-extable.h +6 −6
  23. arch/s390/include/asm/barrier.h +8 −8
  24. arch/s390/include/asm/cio.h +1 −1
  25. arch/s390/include/asm/compat.h +1 −24
  26. arch/s390/include/asm/ctl_reg.h +3 −1
  27. arch/s390/include/asm/entry-common.h +9 −5
  28. arch/s390/include/asm/ipl.h +6 −0
  29. arch/s390/include/asm/lowcore.h +4 −1
  30. arch/s390/include/asm/nmi.h +1 −1
  31. arch/s390/include/asm/nospec-insn.h +6 −6
  32. arch/s390/include/asm/pai.h +74 −0
  33. arch/s390/include/asm/pci_debug.h +6 −1
  34. arch/s390/include/asm/preempt.h +11 −4
  35. arch/s390/include/asm/processor.h +5 −3
  36. arch/s390/include/asm/ptrace.h +29 −0
  37. arch/s390/include/asm/sclp.h +1 −0
  38. arch/s390/include/asm/scsw.h +68 −15
  39. arch/s390/include/asm/spinlock.h +2 −1
  40. arch/s390/include/asm/stp.h +2 −2
  41. arch/s390/include/asm/vx-insn.h +3 −3
  42. arch/s390/include/uapi/asm/pkey.h +1 −1
  43. arch/s390/include/uapi/asm/zcrypt.h +20 −22
  44. arch/s390/kernel/Makefile +1 −0
  45. arch/s390/kernel/alternative.c +2 −59
  46. arch/s390/kernel/compat_linux.h +30 −59
  47. arch/s390/kernel/entry.S +24 −16
  48. arch/s390/kernel/irq.c +2 −2
  49. arch/s390/kernel/machine_kexec.c +8 −2
  50. arch/s390/kernel/nmi.c +5 −1
  51. arch/s390/kernel/perf_cpum_cf_events.c +148 −0
  52. arch/s390/kernel/perf_pai_crypto.c +688 −0
  53. arch/s390/kernel/relocate_kernel.S +2 −1
  54. arch/s390/kernel/setup.c +1 −1
  55. arch/s390/kernel/time.c +5 −7
  56. arch/s390/kernel/vdso.c +50 −5
  57. arch/s390/kvm/priv.c +0 −1
  58. arch/s390/lib/spinlock.c +2 −2
  59. arch/s390/mm/mmap.c +2 −2
  60. arch/s390/pci/pci.c +1 −1
  61. arch/s390/pci/pci_clp.c +1 −1
  62. arch/s390/pci/pci_debug.c +1 −1
  63. arch/s390/pci/pci_event.c +0 −3
  64. arch/s390/pci/pci_insn.c +86 −22
  65. arch/s390/purgatory/head.S +23 −7
  66. arch/x86/include/asm/entry-common.h +2 −2
  67. drivers/s390/char/con3215.c +13 −12
  68. drivers/s390/char/con3270.c +16 −15
  69. drivers/s390/char/raw3270.c +15 −0
  70. drivers/s390/char/raw3270.h +1 −0
  71. drivers/s390/char/sclp_con.c +15 −11
  72. drivers/s390/char/sclp_early.c +3 −1
  73. drivers/s390/char/sclp_vt220.c +23 −19
  74. drivers/s390/cio/chsc.c +2 −2
  75. drivers/s390/crypto/ap_bus.c +63 −33
  76. drivers/s390/crypto/ap_bus.h +1 −0
  77. drivers/s390/crypto/ap_queue.c +4 −3
  78. drivers/s390/crypto/pkey_api.c +78 −71
  79. drivers/s390/crypto/vfio_ap_drv.c +0 −2
  80. drivers/s390/crypto/zcrypt_api.c +108 −107
  81. drivers/s390/crypto/zcrypt_api.h +2 −2
  82. drivers/s390/crypto/zcrypt_card.c +1 −1
  83. drivers/s390/crypto/zcrypt_cca_key.h +29 −29
  84. drivers/s390/crypto/zcrypt_ccamisc.c +141 −131
  85. drivers/s390/crypto/zcrypt_ccamisc.h +6 −0
  86. drivers/s390/crypto/zcrypt_cex2a.c +5 −6
  87. drivers/s390/crypto/zcrypt_cex2c.c +5 −5
  88. drivers/s390/crypto/zcrypt_cex4.c +37 −7
  89. drivers/s390/crypto/zcrypt_ep11misc.c +84 −84
  90. drivers/s390/crypto/zcrypt_ep11misc.h +1 −1
  91. drivers/s390/crypto/zcrypt_error.h +2 −1
  92. drivers/s390/crypto/zcrypt_msgtype50.c +18 −13
  93. drivers/s390/crypto/zcrypt_msgtype6.c +147 −193
  94. drivers/s390/crypto/zcrypt_msgtype6.h +13 −13
  95. drivers/s390/crypto/zcrypt_queue.c +1 −1
  96. include/linux/entry-common.h +4 −4
  97. kernel/entry/common.c +1 −1
  98. scripts/min-tool-version.sh +1 −2
arch/s390/Makefile+2−0
@@ -20,7 +20,9 @@ LDFLAGS_vmlinux := -pie · 19 unmodified lines
2020 endif
2121 aflags_dwarf := -Wa,-gdwarf-2
2222 KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
23+ifndef CONFIG_AS_IS_LLVM
2324 KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
25+endif
2426 KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack
2527 KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
2628 KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain
arch/s390/boot/.gitignore+3−0
@@ -2,3 +2,6 @@ · 1 unmodified line
22 image
33 bzImage
44 section_cmp.*
5+vmlinux
6+vmlinux.lds
7+vmlinux.syms
arch/s390/boot/Makefile+69−9
@@ -37,14 +37,21 @@ CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char · 36 unmodified lines
3737
3838 obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o
3939 obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
40−obj-y += version.o pgm_check_info.o ctype.o
40+obj-y += version.o pgm_check_info.o ctype.o ipl_data.o
4141 obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o
4242 obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o
4343 obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
44−targets := bzImage startup.a section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
45−subdir- := compressed
44+obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
45+obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
46+obj-all := $(obj-y) piggy.o syms.o
47+
48+targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
49+targets += vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
50+targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
51+targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
4652
4753 OBJECTS := $(addprefix $(obj)/,$(obj-y))
54+OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
4855
4956 quiet_cmd_section_cmp = SECTCMP $*
5057 define cmd_section_cmp
@@ -59,14 +66,67 @@ define cmd_section_cmp · 8 unmodified lines
5966 touch $@
6067 endef
6168
62−$(obj)/bzImage: $(obj)/compressed/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
69+$(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
6370 $(call if_changed,objcopy)
6471
65−$(obj)/section_cmp%: vmlinux $(obj)/compressed/vmlinux FORCE
72+$(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
6673 $(call if_changed,section_cmp)
6774
68−$(obj)/compressed/vmlinux: $(obj)/startup.a FORCE
69− $(Q)$(MAKE) $(build)=$(obj)/compressed $@
75+LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T
76+$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
77+ $(call if_changed,ld)
78+
79+LDFLAGS_vmlinux.syms := --oformat $(LD_BFD) -e startup -T
80+$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
81+ $(call if_changed,ld)
82+
83+quiet_cmd_dumpsyms = DUMPSYMS $<
84+define cmd_dumpsyms
85+ $(NM) -n -S --format=bsd "$<" | sed -nE 's/^0*([0-9a-fA-F]+) 0*([0-9a-fA-F]+) [tT] ([^ ]*)$$/\1 \2 \3/p' | tr '\n' '\0' > "$@"
86+endef
87+
88+$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
89+ $(call if_changed,dumpsyms)
90+
91+OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
92+$(obj)/syms.o: $(obj)/syms.bin FORCE
93+ $(call if_changed,objcopy)
94+
95+OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load
96+$(obj)/info.bin: vmlinux FORCE
97+ $(call if_changed,objcopy)
98+
99+OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
100+$(obj)/info.o: $(obj)/info.bin FORCE
101+ $(call if_changed,objcopy)
102+
103+OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
104+$(obj)/vmlinux.bin: vmlinux FORCE
105+ $(call if_changed,objcopy)
106+
107+suffix-$(CONFIG_KERNEL_GZIP) := .gz
108+suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
109+suffix-$(CONFIG_KERNEL_LZ4) := .lz4
110+suffix-$(CONFIG_KERNEL_LZMA) := .lzma
111+suffix-$(CONFIG_KERNEL_LZO) := .lzo
112+suffix-$(CONFIG_KERNEL_XZ) := .xz
113+suffix-$(CONFIG_KERNEL_ZSTD) := .zst
70114
71−$(obj)/startup.a: $(OBJECTS) FORCE
72− $(call if_changed,ar)
115+$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
116+ $(call if_changed,gzip)
117+$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
118+ $(call if_changed,bzip2_with_size)
119+$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
120+ $(call if_changed,lz4_with_size)
121+$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
122+ $(call if_changed,lzma_with_size)
123+$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
124+ $(call if_changed,lzo_with_size)
125+$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
126+ $(call if_changed,xzkern_with_size)
127+$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
128+ $(call if_changed,zstd22_with_size)
129+
130+OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
131+$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
132+ $(call if_changed,objcopy)
arch/s390/boot/boot.h+5−1
@@ -2,9 +2,12 @@ · 1 unmodified line
22 #ifndef BOOT_BOOT_H
33 #define BOOT_BOOT_H
44
5−#include <asm/extable.h>
65 #include <linux/types.h>
76
7+#define IPL_START 0x200
8+
9+#ifndef __ASSEMBLY__
10+
811 void startup_kernel(void);
912 unsigned long detect_memory(void);
1013 bool is_ipl_block_dump(void);
@@ -31,4 +34,5 @@ extern char _stack_start[], _stack_end[]; · 20 unmodified lines
3134
3235 unsigned long read_ipl_report(unsigned long safe_offset);
3336
37+#endif /* __ASSEMBLY__ */
3438 #endif /* BOOT_BOOT_H */
arch/s390/boot/clz_ctz.crenamed from arch/s390/boot/compressed/clz_ctz.c+0−0

File renamed without changes.

arch/s390/boot/compressed/.gitignore+0−4
@@ -1,4 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0-only
2−vmlinux
3−vmlinux.lds
4−vmlinux.syms
arch/s390/boot/compressed/Makefile+0−86
@@ -1,86 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0
2−#
3−# linux/arch/s390/boot/compressed/Makefile
4−#
5−# create a compressed vmlinux image from the original vmlinux
6−#
7−
8−KCOV_INSTRUMENT := n
9−GCOV_PROFILE := n
10−UBSAN_SANITIZE := n
11−KASAN_SANITIZE := n
12−KCSAN_SANITIZE := n
13−
14−obj-y := $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
15−obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
16−obj-all := $(obj-y) piggy.o syms.o
17−targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
18−targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
19−targets += vmlinux.bin.zst
20−targets += info.bin syms.bin vmlinux.syms $(obj-all)
21−
22−KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
23−KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
24−OBJCOPYFLAGS :=
25−
26−OBJECTS := $(addprefix $(obj)/,$(obj-y))
27−OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
28−
29−LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T
30−$(obj)/vmlinux: $(obj)/vmlinux.lds $(objtree)/arch/s390/boot/startup.a $(OBJECTS_ALL) FORCE
31− $(call if_changed,ld)
32−
33−LDFLAGS_vmlinux.syms := --oformat $(LD_BFD) -e startup -T
34−$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(objtree)/arch/s390/boot/startup.a $(OBJECTS) FORCE
35− $(call if_changed,ld)
36−
37−quiet_cmd_dumpsyms = DUMPSYMS $<
38−define cmd_dumpsyms
39− $(NM) -n -S --format=bsd "$<" | sed -nE 's/^0*([0-9a-fA-F]+) 0*([0-9a-fA-F]+) [tT] ([^ ]*)$$/\1 \2 \3/p' | tr '\n' '\0' > "$@"
40−endef
41−
42−$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
43− $(call if_changed,dumpsyms)
44−
45−OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
46−$(obj)/syms.o: $(obj)/syms.bin FORCE
47− $(call if_changed,objcopy)
48−
49−OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load
50−$(obj)/info.bin: vmlinux FORCE
51− $(call if_changed,objcopy)
52−
53−OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
54−$(obj)/info.o: $(obj)/info.bin FORCE
55− $(call if_changed,objcopy)
56−
57−OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
58−$(obj)/vmlinux.bin: vmlinux FORCE
59− $(call if_changed,objcopy)
60−
61−suffix-$(CONFIG_KERNEL_GZIP) := .gz
62−suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
63−suffix-$(CONFIG_KERNEL_LZ4) := .lz4
64−suffix-$(CONFIG_KERNEL_LZMA) := .lzma
65−suffix-$(CONFIG_KERNEL_LZO) := .lzo
66−suffix-$(CONFIG_KERNEL_XZ) := .xz
67−suffix-$(CONFIG_KERNEL_ZSTD) := .zst
68−
69−$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
70− $(call if_changed,gzip)
71−$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
72− $(call if_changed,bzip2_with_size)
73−$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
74− $(call if_changed,lz4_with_size)
75−$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
76− $(call if_changed,lzma_with_size)
77−$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
78− $(call if_changed,lzo_with_size)
79−$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
80− $(call if_changed,xzkern_with_size)
81−$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
82− $(call if_changed,zstd22_with_size)
83−
84−OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
85−$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
86− $(call if_changed,objcopy)
arch/s390/boot/decompressor.crenamed from arch/s390/boot/compressed/decompressor.c+0−0

File renamed without changes.

arch/s390/boot/decompressor.hrenamed from arch/s390/boot/compressed/decompressor.h+0−0

File renamed without changes.

arch/s390/boot/head.S+148−218
@@ -27,234 +27,181 @@ · 26 unmodified lines
2727 #include <asm/page.h>
2828 #include <asm/ptrace.h>
2929 #include <asm/sclp.h>
30−
31−#define ARCH_OFFSET 4
30+#include "boot.h"
3231
3332 #define EP_OFFSET 0x10008
3433 #define EP_STRING "S390EP"
34+#define IPL_BS 0x730
3535
3636 __HEAD
37−
38−#define IPL_BS 0x730
39− .org 0
40− .long 0x00080000,0x80000000+iplstart # The first 24 bytes are loaded
41− .long 0x02000018,0x60000050 # by ipl to addresses 0-23.
42− .long 0x02000068,0x60000050 # (a PSW and two CCWs).
43− .fill 80-24,1,0x40 # bytes 24-79 are discarded !!
44− .long 0x020000f0,0x60000050 # The next 160 byte are loaded
45− .long 0x02000140,0x60000050 # to addresses 0x18-0xb7
46− .long 0x02000190,0x60000050 # They form the continuation
47− .long 0x020001e0,0x60000050 # of the CCW program started
48− .long 0x02000230,0x60000050 # by ipl and load the range
49− .long 0x02000280,0x60000050 # 0x0f0-0x730 from the image
50− .long 0x020002d0,0x60000050 # to the range 0x0f0-0x730
51− .long 0x02000320,0x60000050 # in memory. At the end of
52− .long 0x02000370,0x60000050 # the channel program the PSW
53− .long 0x020003c0,0x60000050 # at location 0 is loaded.
54− .long 0x02000410,0x60000050 # Initial processing starts
55− .long 0x02000460,0x60000050 # at 0x200 = iplstart.
56− .long 0x020004b0,0x60000050
57− .long 0x02000500,0x60000050
58− .long 0x02000550,0x60000050
59− .long 0x020005a0,0x60000050
60− .long 0x020005f0,0x60000050
61− .long 0x02000640,0x60000050
62− .long 0x02000690,0x60000050
63− .long 0x020006e0,0x20000050
64−
65− .org __LC_RST_NEW_PSW # 0x1a0
66− .quad 0,iplstart
67− .org __LC_EXT_NEW_PSW # 0x1b0
68− .quad 0x0002000180000000,0x1b0 # disabled wait
69− .org __LC_PGM_NEW_PSW # 0x1d0
70− .quad 0x0000000180000000,startup_pgm_check_handler
71− .org __LC_IO_NEW_PSW # 0x1f0
72− .quad 0x0002000180000000,0x1f0 # disabled wait
73−
74− .org 0x200
75−
37+ipl_start:
38+ mvi __LC_AR_MODE_ID,1 # set esame flag
39+ slr %r0,%r0 # set cpuid to zero
40+ lhi %r1,2 # mode 2 = esame (dump)
41+ sigp %r1,%r0,0x12 # switch to esame mode
42+ sam64 # switch to 64 bit addressing mode
43+ lgh %r1,__LC_SUBCHANNEL_ID # test if subchannel number
44+ brctg %r1,.Lnoload # is valid
45+ llgf %r1,__LC_SUBCHANNEL_ID # load ipl subchannel number
46+ lghi %r2,IPL_BS # load start address
47+ bras %r14,.Lloader # load rest of ipl image
48+ larl %r12,parmarea # pointer to parameter area
49+ stg %r1,IPL_DEVICE-PARMAREA(%r12) # save ipl device number
50+#
51+# load parameter file from ipl device
52+#
53+.Lagain1:
54+ larl %r2,_end # ramdisk loc. is temp
55+ bras %r14,.Lloader # load parameter file
56+ ltgr %r2,%r2 # got anything ?
57+ jz .Lnopf
58+ lg %r3,MAX_COMMAND_LINE_SIZE-PARMAREA(%r12)
59+ aghi %r3,-1
60+ clgr %r2,%r3
61+ jl .Lnotrunc
62+ lgr %r2,%r3
63+.Lnotrunc:
64+ larl %r4,_end
65+ larl %r13,.L_hdr
66+ clc 0(3,%r4),0(%r13) # if it is HDRx
67+ jz .Lagain1 # skip dataset header
68+ larl %r13,.L_eof
69+ clc 0(3,%r4),0(%r13) # if it is EOFx
70+ jz .Lagain1 # skip dateset trailer
71+ lgr %r5,%r2
72+ la %r6,COMMAND_LINE-PARMAREA(%r12)
73+ lgr %r7,%r2
74+ aghi %r7,1
75+ mvcl %r6,%r4
76+.Lnopf:
77+#
78+# load ramdisk from ipl device
79+#
80+.Lagain2:
81+ larl %r2,_end # addr of ramdisk
82+ stg %r2,INITRD_START-PARMAREA(%r12)
83+ bras %r14,.Lloader # load ramdisk
84+ stg %r2,INITRD_SIZE-PARMAREA(%r12) # store size of rd
85+ ltgr %r2,%r2
86+ jnz .Lrdcont
87+ stg %r2,INITRD_START-PARMAREA(%r12) # no ramdisk found
88+.Lrdcont:
89+ larl %r2,_end
90+ larl %r13,.L_hdr # skip HDRx and EOFx
91+ clc 0(3,%r2),0(%r13)
92+ jz .Lagain2
93+ larl %r13,.L_eof
94+ clc 0(3,%r2),0(%r13)
95+ jz .Lagain2
96+#
97+# reset files in VM reader
98+#
99+ larl %r13,.Lcpuid
100+ stidp 0(%r13) # store cpuid
101+ tm 0(%r13),0xff # running VM ?
102+ jno .Lnoreset
103+ larl %r2,.Lreset
104+ lghi %r3,26
105+ diag %r2,%r3,8
106+ larl %r5,.Lirb
107+ stsch 0(%r5) # check if irq is pending
108+ tm 30(%r5),0x0f # by verifying if any of the
109+ jnz .Lwaitforirq # activity or status control
110+ tm 31(%r5),0xff # bits is set in the schib
111+ jz .Lnoreset
112+.Lwaitforirq:
113+ bras %r14,.Lirqwait # wait for IO interrupt
114+ c %r1,__LC_SUBCHANNEL_ID # compare subchannel number
115+ jne .Lwaitforirq
116+ larl %r5,.Lirb
117+ tsch 0(%r5)
118+.Lnoreset:
119+ j .Lnoload
120+#
121+# everything loaded, go for it
122+#
123+.Lnoload:
124+ jg startup
76125 #
77126 # subroutine to wait for end I/O
78127 #
79128 .Lirqwait:
80− mvc __LC_IO_NEW_PSW(16),.Lnewpsw # set up IO interrupt psw
81− lpsw .Lwaitpsw
129+ larl %r13,.Lnewpswmask # set up IO interrupt psw
130+ mvc __LC_IO_NEW_PSW(8),0(%r13)
131+ stg %r14,__LC_IO_NEW_PSW+8
132+ larl %r13,.Lwaitpsw
133+ lpswe 0(%r13)
82134 .Lioint:
83− br %r14
84− .align 8
85−.Lnewpsw:
86− .quad 0x0000000080000000,.Lioint
87−.Lwaitpsw:
88− .long 0x020a0000,0x80000000+.Lioint
89−
90135 #
91136 # subroutine for loading cards from the reader
92137 #
93138 .Lloader:
94− la %r4,0(%r14)
95− la %r3,.Lorb # r2 = address of orb into r2
96− la %r5,.Lirb # r4 = address of irb
97− la %r6,.Lccws
98− la %r7,20
139+ lgr %r4,%r14
140+ larl %r3,.Lorb # r2 = address of orb into r2
141+ larl %r5,.Lirb # r4 = address of irb
142+ larl %r6,.Lccws
143+ lghi %r7,20
99144 .Linit:
100145 st %r2,4(%r6) # initialize CCW data addresses
101146 la %r2,0x50(%r2)
102147 la %r6,8(%r6)
103− bct 7,.Linit
104−
105− lctl %c6,%c6,.Lcr6 # set IO subclass mask
106− slr %r2,%r2
148+ brctg %r7,.Linit
149+ larl %r13,.Lcr6
150+ lctlg %c6,%c6,0(%r13)
151+ xgr %r2,%r2
107152 .Lldlp:
108153 ssch 0(%r3) # load chunk of 1600 bytes
109− bnz .Llderr
154+ jnz .Llderr
110155 .Lwait4irq:
111− bas %r14,.Lirqwait
156+ bras %r14,.Lirqwait
112157 c %r1,__LC_SUBCHANNEL_ID # compare subchannel number
113− bne .Lwait4irq
158+ jne .Lwait4irq
114159 tsch 0(%r5)
115−
116− slr %r0,%r0
160+ xgr %r0,%r0
117161 ic %r0,8(%r5) # get device status
118− chi %r0,8 # channel end ?
119− be .Lcont
120− chi %r0,12 # channel end + device end ?
121− be .Lcont
122−
123− l %r0,4(%r5)
124− s %r0,8(%r3) # r0/8 = number of ccws executed
125− mhi %r0,10 # *10 = number of bytes in ccws
126− lh %r3,10(%r5) # get residual count
127− sr %r0,%r3 # #ccws*80-residual=#bytes read
128− ar %r2,%r0
129−
162+ cghi %r0,8 # channel end ?
163+ je .Lcont
164+ cghi %r0,12 # channel end + device end ?
165+ je .Lcont
166+ llgf %r0,4(%r5)
167+ sgf %r0,8(%r3) # r0/8 = number of ccws executed
168+ mghi %r0,10 # *10 = number of bytes in ccws
169+ llgh %r3,10(%r5) # get residual count
170+ sgr %r0,%r3 # #ccws*80-residual=#bytes read
171+ agr %r2,%r0
130172 br %r4 # r2 contains the total size
131−
132173 .Lcont:
133− ahi %r2,0x640 # add 0x640 to total size
134− la %r6,.Lccws
135− la %r7,20
174+ aghi %r2,0x640 # add 0x640 to total size
175+ larl %r6,.Lccws
176+ lghi %r7,20
136177 .Lincr:
137178 l %r0,4(%r6) # update CCW data addresses
138− ahi %r0,0x640
179+ aghi %r0,0x640
139180 st %r0,4(%r6)
140− ahi %r6,8
141− bct 7,.Lincr
142−
143− b .Lldlp
181+ aghi %r6,8
182+ brctg %r7,.Lincr
183+ j .Lldlp
144184 .Llderr:
145− lpsw .Lcrash
185+ larl %r13,.Lcrash
186+ lpsw 0(%r13)
146187
188+ .align 8
189+.Lwaitpsw:
190+ .quad 0x0202000180000000,.Lioint
191+.Lnewpswmask:
192+ .quad 0x0000000180000000
147193 .align 8
148194 .Lorb: .long 0x00000000,0x0080ff00,.Lccws
149195 .Lirb: .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
150−.Lcr6: .long 0xff000000
151−.Lloadp:.long 0,0
196+ .align 8
197+.Lcr6: .quad 0x00000000ff000000
152198 .align 8
153199 .Lcrash:.long 0x000a0000,0x00000000
154−
155200 .align 8
156201 .Lccws: .rept 19
157202 .long 0x02600050,0x00000000
158203 .endr
159204 .long 0x02200050,0x00000000
160−
161−iplstart:
162− mvi __LC_AR_MODE_ID,1 # set esame flag
163− slr %r0,%r0 # set cpuid to zero
164− lhi %r1,2 # mode 2 = esame (dump)
165− sigp %r1,%r0,0x12 # switch to esame mode
166− bras %r13,0f
167− .fill 16,4,0x0
168−0: lmh %r0,%r15,0(%r13) # clear high-order half of gprs
169− sam31 # switch to 31 bit addressing mode
170− lh %r1,__LC_SUBCHANNEL_ID # test if subchannel number
171− bct %r1,.Lnoload # is valid
172− l %r1,__LC_SUBCHANNEL_ID # load ipl subchannel number
173− la %r2,IPL_BS # load start address
174− bas %r14,.Lloader # load rest of ipl image
175− l %r12,.Lparm # pointer to parameter area
176− st %r1,IPL_DEVICE+ARCH_OFFSET-PARMAREA(%r12) # save ipl device number
177−
178−#
179−# load parameter file from ipl device
180−#
181−.Lagain1:
182− l %r2,.Linitrd # ramdisk loc. is temp
183− bas %r14,.Lloader # load parameter file
184− ltr %r2,%r2 # got anything ?
185− bz .Lnopf
186− l %r3,MAX_COMMAND_LINE_SIZE+ARCH_OFFSET-PARMAREA(%r12)
187− ahi %r3,-1
188− clr %r2,%r3
189− bl .Lnotrunc
190− lr %r2,%r3
191−.Lnotrunc:
192− l %r4,.Linitrd
193− clc 0(3,%r4),.L_hdr # if it is HDRx
194− bz .Lagain1 # skip dataset header
195− clc 0(3,%r4),.L_eof # if it is EOFx
196− bz .Lagain1 # skip dateset trailer
197−
198− lr %r5,%r2
199− la %r6,COMMAND_LINE-PARMAREA(%r12)
200− lr %r7,%r2
201− ahi %r7,1
202− mvcl %r6,%r4
203−.Lnopf:
204−
205−#
206−# load ramdisk from ipl device
207−#
208−.Lagain2:
209− l %r2,.Linitrd # addr of ramdisk
210− st %r2,INITRD_START+ARCH_OFFSET-PARMAREA(%r12)
211− bas %r14,.Lloader # load ramdisk
212− st %r2,INITRD_SIZE+ARCH_OFFSET-PARMAREA(%r12) # store size of rd
213− ltr %r2,%r2
214− bnz .Lrdcont
215− st %r2,INITRD_START+ARCH_OFFSET-PARMAREA(%r12) # no ramdisk found
216−.Lrdcont:
217− l %r2,.Linitrd
218−
219− clc 0(3,%r2),.L_hdr # skip HDRx and EOFx
220− bz .Lagain2
221− clc 0(3,%r2),.L_eof
222− bz .Lagain2
223−
224−#
225−# reset files in VM reader
226−#
227− stidp .Lcpuid # store cpuid
228− tm .Lcpuid,0xff # running VM ?
229− bno .Lnoreset
230− la %r2,.Lreset
231− lhi %r3,26
232− diag %r2,%r3,8
233− la %r5,.Lirb
234− stsch 0(%r5) # check if irq is pending
235− tm 30(%r5),0x0f # by verifying if any of the
236− bnz .Lwaitforirq # activity or status control
237− tm 31(%r5),0xff # bits is set in the schib
238− bz .Lnoreset
239−.Lwaitforirq:
240− bas %r14,.Lirqwait # wait for IO interrupt
241− c %r1,__LC_SUBCHANNEL_ID # compare subchannel number
242− bne .Lwaitforirq
243− la %r5,.Lirb
244− tsch 0(%r5)
245−.Lnoreset:
246− b .Lnoload
247−
248−#
249−# everything loaded, go for it
250−#
251−.Lnoload:
252− l %r1,.Lstartup
253− br %r1
254−
255−.Linitrd:.long _end # default address of initrd
256−.Lparm: .long PARMAREA
257−.Lstartup: .long startup
258205 .Lreset:.byte 0xc3,0xc8,0xc1,0xd5,0xc7,0xc5,0x40,0xd9,0xc4,0xd9,0x40
259206 .byte 0xc1,0xd3,0xd3,0x40,0xd2,0xc5,0xc5,0xd7,0x40,0xd5,0xd6
260207 .byte 0xc8,0xd6,0xd3,0xc4 # "change rdr all keep nohold"
@@ -268,10 +215,10 @@ iplstart: · 7 unmodified lines
268215 # this is called either by the ipl loader or directly by PSW restart
269216 # or linload or SALIPL
270217 #
271− .org STARTUP_NORMAL_OFFSET
218+ .org STARTUP_NORMAL_OFFSET - IPL_START
272219 SYM_CODE_START(startup)
273220 j startup_normal
274− .org EP_OFFSET
221+ .org EP_OFFSET - IPL_START
275222 #
276223 # This is a list of s390 kernel entry points. At address 0x1000f the number of
277224 # valid entry points is stored.
@@ -283,7 +230,7 @@ SYM_CODE_START(startup) · 5 unmodified lines
283230 #
284231 # kdump startup-code, running in 64 bit absolute addressing mode
285232 #
286− .org STARTUP_KDUMP_OFFSET
233+ .org STARTUP_KDUMP_OFFSET - IPL_START
287234 j startup_kdump
288235 SYM_CODE_END(startup)
289236 SYM_CODE_START_LOCAL(startup_normal)
@@ -295,20 +242,23 @@ SYM_CODE_START_LOCAL(startup_normal) · 5 unmodified lines
295242 .fill 16,4,0x0
296243 0: lmh %r0,%r15,0(%r13) # clear high-order half of gprs
297244 sam64 # switch to 64 bit addressing mode
298− basr %r13,0 # get base
299−.LPG0:
300− mvc __LC_EXT_NEW_PSW(16),.Lext_new_psw-.LPG0(%r13)
301− mvc __LC_PGM_NEW_PSW(16),.Lpgm_new_psw-.LPG0(%r13)
302− mvc __LC_IO_NEW_PSW(16),.Lio_new_psw-.LPG0(%r13)
245+ larl %r13,.Lext_new_psw
246+ mvc __LC_EXT_NEW_PSW(16),0(%r13)
247+ larl %r13,.Lpgm_new_psw
248+ mvc __LC_PGM_NEW_PSW(16),0(%r13)
249+ larl %r13,.Lio_new_psw
250+ mvc __LC_IO_NEW_PSW(16),0(%r13)
303251 xc 0x200(256),0x200 # partially clear lowcore
304252 xc 0x300(256),0x300
305253 xc 0xe00(256),0xe00
306254 xc 0xf00(256),0xf00
307− lctlg %c0,%c15,.Lctl-.LPG0(%r13) # load control registers
255+ larl %r13,.Lctl
256+ lctlg %c0,%c15,0(%r13) # load control registers
308257 stcke __LC_BOOT_CLOCK
309258 mvc __LC_LAST_UPDATE_CLOCK(8),__LC_BOOT_CLOCK+1
310− spt 6f-.LPG0(%r13)
311− mvc __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13)
259+ larl %r13,6f
260+ spt 0(%r13)
261+ mvc __LC_LAST_UPDATE_TIMER(8),0(%r13)
312262 larl %r15,_stack_end-STACK_FRAME_OVERHEAD
313263 brasl %r14,sclp_early_setup_buffer
314264 brasl %r14,verify_facilities
@@ -368,23 +318,3 @@ SYM_CODE_START_LOCAL(startup_pgm_check_handler) · 53 unmodified lines
368318 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r8)
369319 lpswe __LC_RETURN_PSW # disabled wait
370320 SYM_CODE_END(startup_pgm_check_handler)
371−
372−#
373−# params at 10400 (setup.h)
374−# Must be keept in sync with struct parmarea in setup.h
375−#
376− .org PARMAREA
377−SYM_DATA_START(parmarea)
378− .quad 0 # IPL_DEVICE
379− .quad 0 # INITRD_START
380− .quad 0 # INITRD_SIZE
381− .quad 0 # OLDMEM_BASE
382− .quad 0 # OLDMEM_SIZE
383− .quad kernel_version # points to kernel version string
384− .quad COMMAND_LINE_SIZE
385−
386− .org COMMAND_LINE
387− .byte "root=/dev/ram0 ro"
388− .byte 0
389− .org PARMAREA+__PARMAREA_SIZE
390−SYM_DATA_END(parmarea)
arch/s390/boot/ipl_data.c+84−0
@@ -0,0 +1,84 @@
1+// SPDX-License-Identifier: GPL-2.0
2+
3+#include <linux/compat.h>
4+#include <linux/ptrace.h>
5+#include <asm/cio.h>
6+#include <asm/asm-offsets.h>
7+#include "boot.h"
8+
9+#define CCW0(cmd, addr, cnt, flg) \
10+ { .cmd_code = cmd, .cda = addr, .count = cnt, .flags = flg, }
11+
12+#define PSW_MASK_DISABLED (PSW_MASK_WAIT | PSW_MASK_EA | PSW_MASK_BA)
13+
14+struct ipl_lowcore {
15+ psw_t32 ipl_psw; /* 0x0000 */
16+ struct ccw0 ccwpgm[2]; /* 0x0008 */
17+ u8 fill[56]; /* 0x0018 */
18+ struct ccw0 ccwpgmcc[20]; /* 0x0050 */
19+ u8 pad_0xf0[0x01a0-0x00f0]; /* 0x00f0 */
20+ psw_t restart_psw; /* 0x01a0 */
21+ psw_t external_new_psw; /* 0x01b0 */
22+ psw_t svc_new_psw; /* 0x01c0 */
23+ psw_t program_new_psw; /* 0x01d0 */
24+ psw_t mcck_new_psw; /* 0x01e0 */
25+ psw_t io_new_psw; /* 0x01f0 */
26+};
27+
28+/*
29+ * Initial lowcore for IPL: the first 24 bytes are loaded by IPL to
30+ * addresses 0-23 (a PSW and two CCWs). Bytes 24-79 are discarded.
31+ * The next 160 bytes are loaded to addresses 0x18-0xb7. They form
32+ * the continuation of the CCW program started by IPL and load the
33+ * range 0x0f0-0x730 from the image to the range 0x0f0-0x730 in
34+ * memory. At the end of the channel program the PSW at location 0 is
35+ * loaded.
36+ * Initial processing starts at 0x200 = iplstart.
37+ *
38+ * The restart psw points to iplstart which allows to load a kernel
39+ * image into memory and starting it by a psw restart on any cpu. All
40+ * other default psw new locations contain a disabled wait psw where
41+ * the address indicates which psw was loaded.
42+ *
43+ * Note that the 'file' utility can detect s390 kernel images. For
44+ * that to succeed the two initial CCWs, and the 0x40 fill bytes must
45+ * be present.
46+ */
47+static struct ipl_lowcore ipl_lowcore __used __section(".ipldata") = {
48+ .ipl_psw = { .mask = PSW32_MASK_BASE, .addr = PSW32_ADDR_AMODE | IPL_START },
49+ .ccwpgm = {
50+ [ 0] = CCW0(CCW_CMD_READ_IPL, 0x018, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
51+ [ 1] = CCW0(CCW_CMD_READ_IPL, 0x068, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
52+ },
53+ .fill = {
54+ [ 0 ... 55] = 0x40,
55+ },
56+ .ccwpgmcc = {
57+ [ 0] = CCW0(CCW_CMD_READ_IPL, 0x0f0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
58+ [ 1] = CCW0(CCW_CMD_READ_IPL, 0x140, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
59+ [ 2] = CCW0(CCW_CMD_READ_IPL, 0x190, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
60+ [ 3] = CCW0(CCW_CMD_READ_IPL, 0x1e0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
61+ [ 4] = CCW0(CCW_CMD_READ_IPL, 0x230, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
62+ [ 5] = CCW0(CCW_CMD_READ_IPL, 0x280, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
63+ [ 6] = CCW0(CCW_CMD_READ_IPL, 0x2d0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
64+ [ 7] = CCW0(CCW_CMD_READ_IPL, 0x320, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
65+ [ 8] = CCW0(CCW_CMD_READ_IPL, 0x370, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
66+ [ 9] = CCW0(CCW_CMD_READ_IPL, 0x3c0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
67+ [10] = CCW0(CCW_CMD_READ_IPL, 0x410, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
68+ [11] = CCW0(CCW_CMD_READ_IPL, 0x460, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
69+ [12] = CCW0(CCW_CMD_READ_IPL, 0x4b0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
70+ [13] = CCW0(CCW_CMD_READ_IPL, 0x500, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
71+ [14] = CCW0(CCW_CMD_READ_IPL, 0x550, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
72+ [15] = CCW0(CCW_CMD_READ_IPL, 0x5a0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
73+ [16] = CCW0(CCW_CMD_READ_IPL, 0x5f0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
74+ [17] = CCW0(CCW_CMD_READ_IPL, 0x640, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
75+ [18] = CCW0(CCW_CMD_READ_IPL, 0x690, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
76+ [19] = CCW0(CCW_CMD_READ_IPL, 0x6e0, 0x50, CCW_FLAG_SLI),
77+ },
78+ .restart_psw = { .mask = 0, .addr = IPL_START, },
79+ .external_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_EXT_NEW_PSW, },
80+ .svc_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_SVC_NEW_PSW, },
81+ .program_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_PGM_NEW_PSW, },
82+ .mcck_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_MCK_NEW_PSW, },
83+ .io_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_IO_NEW_PSW, },
84+};
arch/s390/boot/ipl_parm.c+7−0
@@ -8,9 +8,16 @@ · 7 unmodified lines
88 #include <asm/sections.h>
99 #include <asm/boot_data.h>
1010 #include <asm/facility.h>
11+#include <asm/setup.h>
1112 #include <asm/uv.h>
1213 #include "boot.h"
1314
15+struct parmarea parmarea __section(".parmarea") = {
16+ .kernel_version = (unsigned long)kernel_version,
17+ .max_command_line_size = COMMAND_LINE_SIZE,
18+ .command_line = "root=/dev/ram0 ro",
19+};
20+
1421 char __bootdata(early_command_line)[COMMAND_LINE_SIZE];
1522 int __bootdata(noexec_disabled);
1623
arch/s390/boot/kaslr.c+1−1
@@ -8,7 +8,7 @@ · 7 unmodified lines
88 #include <asm/timex.h>
99 #include <asm/sclp.h>
1010 #include <asm/kasan.h>
11−#include "compressed/decompressor.h"
11+#include "decompressor.h"
1212 #include "boot.h"
1313
1414 #define PRNG_MODE_TDES 1
arch/s390/boot/mem_detect.c+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 #include <asm/sections.h>
88 #include <asm/mem_detect.h>
99 #include <asm/sparsemem.h>
10−#include "compressed/decompressor.h"
10+#include "decompressor.h"
1111 #include "boot.h"
1212
1313 struct mem_detect_info __bootdata(mem_detect);
arch/s390/boot/startup.c+1−1
@@ -10,7 +10,7 @@ · 9 unmodified lines
1010 #include <asm/sclp.h>
1111 #include <asm/diag.h>
1212 #include <asm/uv.h>
13−#include "compressed/decompressor.h"
13+#include "decompressor.h"
1414 #include "boot.h"
1515 #include "uv.h"
1616
arch/s390/boot/vmlinux.lds.Srenamed from arch/s390/boot/compressed/vmlinux.lds.S+9−0
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 #include <asm/thread_info.h>
55 #include <asm/page.h>
66 #include <asm/sclp.h>
7+#include "boot.h"
78
89 OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
910 OUTPUT_ARCH(s390:64-bit)
@@ -13,11 +14,19 @@ ENTRY(startup) · 3 unmodified lines
1314 SECTIONS
1415 {
1516 . = 0;
17+ .ipldata : {
18+ *(.ipldata)
19+ }
20+ . = IPL_START;
1621 .head.text : {
1722 _head = . ;
1823 HEAD_TEXT
1924 _ehead = . ;
2025 }
26+ . = PARMAREA;
27+ .parmarea : {
28+ *(.parmarea)
29+ }
2130 .text : {
2231 _text = .; /* Text */
2332 *(.text)
arch/s390/crypto/des_s390.c+1−1
@@ -194,7 +194,7 @@ static struct skcipher_alg cbc_des_alg = { · 193 unmodified lines
194194 * same as DES. Implementers MUST reject keys that exhibit this
195195 * property.
196196 *
197− * In fips mode additinally check for all 3 keys are unique.
197+ * In fips mode additionally check for all 3 keys are unique.
198198 *
199199 */
200200 static int des3_setkey(struct crypto_tfm *tfm, const u8 *key,
arch/s390/crypto/prng.c+1−1
@@ -528,7 +528,7 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf, · 527 unmodified lines
528528 /* give mutex free before calling schedule() */
529529 mutex_unlock(&prng_data->mutex);
530530 schedule();
531− /* occopy mutex again */
531+ /* occupy mutex again */
532532 if (mutex_lock_interruptible(&prng_data->mutex)) {
533533 if (ret == 0)
534534 ret = -ERESTARTSYS;
arch/s390/hypfs/hypfs_vm.c+1−1
@@ -190,7 +190,7 @@ int hypfs_vm_create_files(struct dentry *root) · 189 unmodified lines
190190 if (IS_ERR(data))
191191 return PTR_ERR(data);
192192
193− /* Hpervisor Info */
193+ /* Hypervisor Info */
194194 dir = hypfs_mkdir(root, "hyp");
195195 if (IS_ERR(dir)) {
196196 rc = PTR_ERR(dir);
arch/s390/include/asm/alternative-asm.h+9−67
@@ -4,19 +4,6 @@ · 3 unmodified lines
44
55 #ifdef __ASSEMBLY__
66
7−/*
8− * Check the length of an instruction sequence. The length may not be larger
9− * than 254 bytes and it has to be divisible by 2.
10− */
11−.macro alt_len_check start,end
12− .if ( \end - \start ) > 254
13− .error "cpu alternatives does not support instructions blocks > 254 bytes\n"
14− .endif
15− .if ( \end - \start ) % 2
16− .error "cpu alternatives instructions length is odd\n"
17− .endif
18−.endm
19−
207 /*
218 * Issue one struct alt_instr descriptor entry (need to put it into
229 * the section .altinstructions, see below). This entry contains
@@ -28,66 +15,29 @@ · 5 unmodified lines
2815 .long \alt_start - .
2916 .word \feature
3017 .byte \orig_end - \orig_start
31− .byte \alt_end - \alt_start
32−.endm
33−
34−/*
35− * Fill up @bytes with nops. The macro emits 6-byte nop instructions
36− * for the bulk of the area, possibly followed by a 4-byte and/or
37− * a 2-byte nop if the size of the area is not divisible by 6.
38− */
39−.macro alt_pad_fill bytes
40− .rept ( \bytes ) / 6
41− brcl 0,0
42− .endr
43− .rept ( \bytes ) % 6 / 4
44− nop
45− .endr
46− .rept ( \bytes ) % 6 % 4 / 2
47− nopr
48− .endr
49−.endm
50−
51−/*
52− * Fill up @bytes with nops. If the number of bytes is larger
53− * than 6, emit a jg instruction to branch over all nops, then
54− * fill an area of size (@bytes - 6) with nop instructions.
55− */
56−.macro alt_pad bytes
57− .if ( \bytes > 0 )
58− .if ( \bytes > 6 )
59− jg . + \bytes
60− alt_pad_fill \bytes - 6
61− .else
62− alt_pad_fill \bytes
63− .endif
64− .endif
18+ .org . - ( \orig_end - \orig_start ) + ( \alt_end - \alt_start )
19+ .org . - ( \alt_end - \alt_start ) + ( \orig_end - \orig_start )
6520 .endm
6621
6722 /*
6823 * Define an alternative between two instructions. If @feature is
6924 * present, early code in apply_alternatives() replaces @oldinstr with
70− * @newinstr. ".skip" directive takes care of proper instruction padding
71− * in case @newinstr is longer than @oldinstr.
25+ * @newinstr.
7226 */
7327 .macro ALTERNATIVE oldinstr, newinstr, feature
7428 .pushsection .altinstr_replacement,"ax"
7529 770: \newinstr
7630 771: .popsection
7731 772: \oldinstr
78−773: alt_len_check 770b, 771b
79− alt_len_check 772b, 773b
80− alt_pad ( ( 771b - 770b ) - ( 773b - 772b ) )
81−774: .pushsection .altinstructions,"a"
82− alt_entry 772b, 774b, 770b, 771b, \feature
32+773: .pushsection .altinstructions,"a"
33+ alt_entry 772b, 773b, 770b, 771b, \feature
8334 .popsection
8435 .endm
8536
8637 /*
8738 * Define an alternative between two instructions. If @feature is
8839 * present, early code in apply_alternatives() replaces @oldinstr with
89− * @newinstr. ".skip" directive takes care of proper instruction padding
90− * in case @newinstr is longer than @oldinstr.
40+ * @newinstr.
9141 */
9242 .macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2
9343 .pushsection .altinstr_replacement,"ax"
@@ -95,17 +45,9 @@ · 1 unmodified line
9545 771: \newinstr2
9646 772: .popsection
9747 773: \oldinstr
98−774: alt_len_check 770b, 771b
99− alt_len_check 771b, 772b
100− alt_len_check 773b, 774b
101− .if ( 771b - 770b > 772b - 771b )
102− alt_pad ( ( 771b - 770b ) - ( 774b - 773b ) )
103− .else
104− alt_pad ( ( 772b - 771b ) - ( 774b - 773b ) )
105− .endif
106−775: .pushsection .altinstructions,"a"
107− alt_entry 773b, 775b, 770b, 771b,\feature1
108− alt_entry 773b, 775b, 771b, 772b,\feature2
48+774: .pushsection .altinstructions,"a"
49+ alt_entry 773b, 774b, 770b, 771b,\feature1
50+ alt_entry 773b, 774b, 771b, 772b,\feature2
10951 .popsection
11052 .endm
11153
arch/s390/include/asm/alternative.h+20−73
@@ -13,32 +13,25 @@ struct alt_instr { · 12 unmodified lines
1313 s32 repl_offset; /* offset to replacement instruction */
1414 u16 facility; /* facility bit set for replacement */
1515 u8 instrlen; /* length of original instruction */
16− u8 replacementlen; /* length of new instruction */
1716 } __packed;
1817
1918 void apply_alternative_instructions(void);
2019 void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
2120
2221 /*
23− * |661: |662: |6620 |663:
24− * +-----------+---------------------+
25− * | oldinstr | oldinstr_padding |
26− * | +----------+----------+
27− * | | | |
28− * | | >6 bytes |6/4/2 nops|
29− * | |6 bytes jg----------->
30− * +-----------+---------------------+
31− * ^^ static padding ^^
22+ * +---------------------------------+
23+ * |661: |662:
24+ * | oldinstr |
25+ * +---------------------------------+
3226 *
3327 * .altinstr_replacement section
34− * +---------------------+-----------+
28+ * +---------------------------------+
3529 * |6641: |6651:
3630 * | alternative instr 1 |
37− * +-----------+---------+- - - - - -+
38− * |6642: |6652: |
39− * | alternative instr 2 | padding
40− * +---------------------+- - - - - -+
41− * ^ runtime ^
31+ * +---------------------------------+
32+ * |6642: |6652:
33+ * | alternative instr 2 |
34+ * +---------------------------------+
4235 *
4336 * .altinstructions section
4437 * +---------------------------------+
@@ -47,77 +40,31 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end); · 2 unmodified lines
4740 * +---------------------------------+
4841 */
4942
50−#define b_altinstr(num) "664"#num
51−#define e_altinstr(num) "665"#num
52−
53−#define e_oldinstr_pad_end "663"
43+#define b_altinstr(num) "664"#num
44+#define e_altinstr(num) "665"#num
5445 #define oldinstr_len "662b-661b"
55−#define oldinstr_total_len e_oldinstr_pad_end"b-661b"
5646 #define altinstr_len(num) e_altinstr(num)"b-"b_altinstr(num)"b"
57−#define oldinstr_pad_len(num) \
58− "-(((" altinstr_len(num) ")-(" oldinstr_len ")) > 0) * " \
59− "((" altinstr_len(num) ")-(" oldinstr_len "))"
60−
61−#define INSTR_LEN_SANITY_CHECK(len) \
62− ".if " len " > 254\n" \
63− "\t.error \"cpu alternatives does not support instructions " \
64− "blocks > 254 bytes\"\n" \
65− ".endif\n" \
66− ".if (" len ") %% 2\n" \
67− "\t.error \"cpu alternatives instructions length is odd\"\n" \
68− ".endif\n"
69−
70−#define OLDINSTR_PADDING(oldinstr, num) \
71− ".if " oldinstr_pad_len(num) " > 6\n" \
72− "\tjg " e_oldinstr_pad_end "f\n" \
73− "6620:\n" \
74− "\t.rept (" oldinstr_pad_len(num) " - (6620b-662b)) / 2\n" \
75− "\tnopr\n" \
76− ".else\n" \
77− "\t.rept " oldinstr_pad_len(num) " / 6\n" \
78− "\t.brcl 0,0\n" \
79− "\t.endr\n" \
80− "\t.rept " oldinstr_pad_len(num) " %% 6 / 4\n" \
81− "\tnop\n" \
82− "\t.endr\n" \
83− "\t.rept " oldinstr_pad_len(num) " %% 6 %% 4 / 2\n" \
84− "\tnopr\n" \
85− ".endr\n" \
86− ".endif\n"
87−
88−#define OLDINSTR(oldinstr, num) \
89− "661:\n\t" oldinstr "\n662:\n" \
90− OLDINSTR_PADDING(oldinstr, num) \
91− e_oldinstr_pad_end ":\n" \
92− INSTR_LEN_SANITY_CHECK(oldinstr_len)
93−
94−#define OLDINSTR_2(oldinstr, num1, num2) \
95− "661:\n\t" oldinstr "\n662:\n" \
96− ".if " altinstr_len(num1) " < " altinstr_len(num2) "\n" \
97− OLDINSTR_PADDING(oldinstr, num2) \
98− ".else\n" \
99− OLDINSTR_PADDING(oldinstr, num1) \
100− ".endif\n" \
101− e_oldinstr_pad_end ":\n" \
102− INSTR_LEN_SANITY_CHECK(oldinstr_len)
47+
48+#define OLDINSTR(oldinstr) \
49+ "661:\n\t" oldinstr "\n662:\n"
10350
10451 #define ALTINSTR_ENTRY(facility, num) \
10552 "\t.long 661b - .\n" /* old instruction */ \
10653 "\t.long " b_altinstr(num)"b - .\n" /* alt instruction */ \
10754 "\t.word " __stringify(facility) "\n" /* facility bit */ \
108− "\t.byte " oldinstr_total_len "\n" /* source len */ \
109− "\t.byte " altinstr_len(num) "\n" /* alt instruction len */
55+ "\t.byte " oldinstr_len "\n" /* instruction len */ \
56+ "\t.org . - (" oldinstr_len ") + (" altinstr_len(num) ")\n" \
57+ "\t.org . - (" altinstr_len(num) ") + (" oldinstr_len ")\n"
11058
11159 #define ALTINSTR_REPLACEMENT(altinstr, num) /* replacement */ \
112− b_altinstr(num)":\n\t" altinstr "\n" e_altinstr(num) ":\n" \
113− INSTR_LEN_SANITY_CHECK(altinstr_len(num))
60+ b_altinstr(num)":\n\t" altinstr "\n" e_altinstr(num) ":\n"
11461
11562 /* alternative assembly primitive: */
11663 #define ALTERNATIVE(oldinstr, altinstr, facility) \
11764 ".pushsection .altinstr_replacement, \"ax\"\n" \
11865 ALTINSTR_REPLACEMENT(altinstr, 1) \
11966 ".popsection\n" \
120− OLDINSTR(oldinstr, 1) \
67+ OLDINSTR(oldinstr) \
12168 ".pushsection .altinstructions,\"a\"\n" \
12269 ALTINSTR_ENTRY(facility, 1) \
12370 ".popsection\n"
@@ -127,7 +74,7 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end); · 3 unmodified lines
12774 ALTINSTR_REPLACEMENT(altinstr1, 1) \
12875 ALTINSTR_REPLACEMENT(altinstr2, 2) \
12976 ".popsection\n" \
130− OLDINSTR_2(oldinstr, 1, 2) \
77+ OLDINSTR(oldinstr) \
13178 ".pushsection .altinstructions,\"a\"\n" \
13279 ALTINSTR_ENTRY(facility1, 1) \
13380 ALTINSTR_ENTRY(facility2, 2) \
arch/s390/include/asm/asm-extable.h+6−6
@@ -26,16 +26,16 @@ · 25 unmodified lines
2626 stringify_in_c(.long (_target) - .;) \
2727 stringify_in_c(.short (_type);) \
2828 stringify_in_c(.macro extable_reg reg;) \
29− stringify_in_c(.set found, 0;) \
30− stringify_in_c(.set regnr, 0;) \
29+ stringify_in_c(.set .Lfound, 0;) \
30+ stringify_in_c(.set .Lregnr, 0;) \
3131 stringify_in_c(.irp rs,r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15;) \
3232 stringify_in_c(.ifc "\reg", "%%\rs";) \
33− stringify_in_c(.set found, 1;) \
34− stringify_in_c(.short regnr;) \
33+ stringify_in_c(.set .Lfound, 1;) \
34+ stringify_in_c(.short .Lregnr;) \
3535 stringify_in_c(.endif;) \
36− stringify_in_c(.set regnr, regnr+1;) \
36+ stringify_in_c(.set .Lregnr, .Lregnr+1;) \
3737 stringify_in_c(.endr;) \
38− stringify_in_c(.ifne (found != 1);) \
38+ stringify_in_c(.ifne (.Lfound != 1);) \
3939 stringify_in_c(.error "extable_reg: bad register argument";) \
4040 stringify_in_c(.endif;) \
4141 stringify_in_c(.endm;) \
arch/s390/include/asm/barrier.h+8−8
@@ -26,14 +26,14 @@ static __always_inline void bcr_serialize(void) · 25 unmodified lines
2626 asm volatile(__ASM_BCR_SERIALIZE : : : "memory");
2727 }
2828
29−#define mb() bcr_serialize()
30−#define rmb() barrier()
31−#define wmb() barrier()
32−#define dma_rmb() mb()
33−#define dma_wmb() mb()
34−#define __smp_mb() mb()
35−#define __smp_rmb() rmb()
36−#define __smp_wmb() wmb()
29+#define __mb() bcr_serialize()
30+#define __rmb() barrier()
31+#define __wmb() barrier()
32+#define __dma_rmb() __mb()
33+#define __dma_wmb() __mb()
34+#define __smp_mb() __mb()
35+#define __smp_rmb() __rmb()
36+#define __smp_wmb() __wmb()
3737
3838 #define __smp_store_release(p, v) \
3939 do { \
arch/s390/include/asm/cio.h+1−1
@@ -369,7 +369,7 @@ void cio_gp_dma_destroy(struct gen_pool *gp_dma, struct device *dma_dev); · 368 unmodified lines
369369 struct gen_pool *cio_gp_dma_create(struct device *dma_dev, int nr_pages);
370370
371371 /* Function from drivers/s390/cio/chsc.c */
372−int chsc_sstpc(void *page, unsigned int op, u16 ctrl, u64 *clock_delta);
372+int chsc_sstpc(void *page, unsigned int op, u16 ctrl, long *clock_delta);
373373 int chsc_sstpi(void *page, void *result, size_t size);
374374 int chsc_stzi(void *page, void *result, size_t size);
375375 int chsc_sgib(u32 origin);
arch/s390/include/asm/compat.h+1−24
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include <linux/sched.h>
99 #include <linux/sched/task_stack.h>
1010 #include <linux/thread_info.h>
11+#include <asm/ptrace.h>
1112
1213 #define compat_mode_t compat_mode_t
1314 typedef u16 compat_mode_t;
@@ -22,32 +23,8 @@ typedef u16 compat_mode_t; · 8 unmodified lines
2223 (__force t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \
2324 })
2425
25−#define PSW32_MASK_PER 0x40000000UL
26−#define PSW32_MASK_DAT 0x04000000UL
27−#define PSW32_MASK_IO 0x02000000UL
28−#define PSW32_MASK_EXT 0x01000000UL
29−#define PSW32_MASK_KEY 0x00F00000UL
30−#define PSW32_MASK_BASE 0x00080000UL /* Always one */
31−#define PSW32_MASK_MCHECK 0x00040000UL
32−#define PSW32_MASK_WAIT 0x00020000UL
33−#define PSW32_MASK_PSTATE 0x00010000UL
34−#define PSW32_MASK_ASC 0x0000C000UL
35−#define PSW32_MASK_CC 0x00003000UL
36−#define PSW32_MASK_PM 0x00000f00UL
37−#define PSW32_MASK_RI 0x00000080UL
38−
3926 #define PSW32_MASK_USER 0x0000FF00UL
4027
41−#define PSW32_ADDR_AMODE 0x80000000UL
42−#define PSW32_ADDR_INSN 0x7FFFFFFFUL
43−
44−#define PSW32_DEFAULT_KEY (((u32) PAGE_DEFAULT_ACC) << 20)
45−
46−#define PSW32_ASC_PRIMARY 0x00000000UL
47−#define PSW32_ASC_ACCREG 0x00004000UL
48−#define PSW32_ASC_SECONDARY 0x00008000UL
49−#define PSW32_ASC_HOME 0x0000C000UL
50−
5128 #define PSW32_USER_BITS (PSW32_MASK_DAT | PSW32_MASK_IO | PSW32_MASK_EXT | \
5229 PSW32_DEFAULT_KEY | PSW32_MASK_BASE | \
5330 PSW32_MASK_MCHECK | PSW32_MASK_PSTATE | \
arch/s390/include/asm/ctl_reg.h+3−1
@@ -93,7 +93,9 @@ union ctlreg0 { · 92 unmodified lines
9393 unsigned long tcx : 1; /* Transactional-Execution control */
9494 unsigned long pifo : 1; /* Transactional-Execution Program-
9595 Interruption-Filtering Override */
96− unsigned long : 22;
96+ unsigned long : 3;
97+ unsigned long ccc : 1; /* Cryptography counter control */
98+ unsigned long : 18;
9799 unsigned long : 3;
98100 unsigned long lap : 1; /* Low-address-protection control */
99101 unsigned long : 4;
arch/s390/include/asm/entry-common.h+9−5
@@ -9,19 +9,21 @@ · 8 unmodified lines
99 #include <linux/uaccess.h>
1010 #include <asm/timex.h>
1111 #include <asm/fpu/api.h>
12+#include <asm/pai.h>
1213
1314 #define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP)
1415
1516 void do_per_trap(struct pt_regs *regs);
1617
17−#ifdef CONFIG_DEBUG_ENTRY
18−static __always_inline void arch_check_user_regs(struct pt_regs *regs)
18+static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
1919 {
20− debug_user_asce(0);
20+ if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
21+ debug_user_asce(0);
22+
23+ pai_kernel_enter(regs);
2124 }
2225
23−#define arch_check_user_regs arch_check_user_regs
24−#endif /* CONFIG_DEBUG_ENTRY */
26+#define arch_enter_from_user_mode arch_enter_from_user_mode
2527
2628 static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs,
2729 unsigned long ti_work)
@@ -44,6 +46,8 @@ static __always_inline void arch_exit_to_user_mode(void) · 16 unmodified lines
4446
4547 if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
4648 debug_user_asce(1);
49+
50+ pai_kernel_exit(current_pt_regs());
4751 }
4852
4953 #define arch_exit_to_user_mode arch_exit_to_user_mode
arch/s390/include/asm/ipl.h+6−0
@@ -133,6 +133,8 @@ int ipl_report_add_certificate(struct ipl_report *report, void *key, · 132 unmodified lines
133133 * DIAG 308 support
134134 */
135135 enum diag308_subcode {
136+ DIAG308_CLEAR_RESET = 0,
137+ DIAG308_LOAD_NORMAL_RESET = 1,
136138 DIAG308_REL_HSA = 2,
137139 DIAG308_LOAD_CLEAR = 3,
138140 DIAG308_LOAD_NORMAL_DUMP = 4,
@@ -141,6 +143,10 @@ enum diag308_subcode { · 2 unmodified lines
141143 DIAG308_LOAD_NORMAL = 7,
142144 };
143145
146+enum diag308_subcode_flags {
147+ DIAG308_FLAG_EI = 1UL << 16,
148+};
149+
144150 enum diag308_rc {
145151 DIAG308_RC_OK = 0x0001,
146152 DIAG308_RC_NOCONFIG = 0x0102,
arch/s390/include/asm/lowcore.h+4−1
@@ -200,7 +200,10 @@ struct lowcore { · 199 unmodified lines
200200 __u64 last_break_save_area; /* 0x1338 */
201201 __u32 access_regs_save_area[16]; /* 0x1340 */
202202 __u64 cregs_save_area[16]; /* 0x1380 */
203− __u8 pad_0x1400[0x1800-0x1400]; /* 0x1400 */
203+ __u8 pad_0x1400[0x1500-0x1400]; /* 0x1400 */
204+ /* Cryptography-counter designation */
205+ __u64 ccd; /* 0x1500 */
206+ __u8 pad_0x1508[0x1800-0x1508]; /* 0x1508 */
204207
205208 /* Transaction abort diagnostic block */
206209 struct pgm_tdb pgm_tdb; /* 0x1800 */
arch/s390/include/asm/nmi.h+1−1
@@ -101,7 +101,7 @@ void nmi_alloc_mcesa_early(u64 *mcesad); · 100 unmodified lines
101101 int nmi_alloc_mcesa(u64 *mcesad);
102102 void nmi_free_mcesa(u64 *mcesad);
103103
104−void s390_handle_mcck(void);
104+void s390_handle_mcck(struct pt_regs *regs);
105105 void __s390_handle_mcck(void);
106106 int s390_do_machine_check(struct pt_regs *regs);
107107
arch/s390/include/asm/nospec-insn.h+6−6
@@ -54,31 +54,31 @@ · 53 unmodified lines
5454 .endm
5555
5656 .macro __DECODE_R expand,reg
57− .set __decode_fail,1
57+ .set .L__decode_fail,1
5858 .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
5959 .ifc \reg,%r\r1
6060 \expand \r1
61− .set __decode_fail,0
61+ .set .L__decode_fail,0
6262 .endif
6363 .endr
64− .if __decode_fail == 1
64+ .if .L__decode_fail == 1
6565 .error "__DECODE_R failed"
6666 .endif
6767 .endm
6868
6969 .macro __DECODE_RR expand,rsave,rtarget
70− .set __decode_fail,1
70+ .set .L__decode_fail,1
7171 .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
7272 .ifc \rsave,%r\r1
7373 .irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
7474 .ifc \rtarget,%r\r2
7575 \expand \r1,\r2
76− .set __decode_fail,0
76+ .set .L__decode_fail,0
7777 .endif
7878 .endr
7979 .endif
8080 .endr
81− .if __decode_fail == 1
81+ .if .L__decode_fail == 1
8282 .error "__DECODE_RR failed"
8383 .endif
8484 .endm
arch/s390/include/asm/pai.h+74−0
@@ -0,0 +1,74 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+/*
3+ * Processor Activity Instrumentation support for cryptography counters
4+ *
5+ * Copyright IBM Corp. 2022
6+ * Author(s): Thomas Richter <tmricht@linux.ibm.com>
7+ */
8+#ifndef _ASM_S390_PAI_H
9+#define _ASM_S390_PAI_H
10+
11+#include <linux/jump_label.h>
12+#include <asm/lowcore.h>
13+#include <asm/ptrace.h>
14+
15+struct qpaci_info_block {
16+ u64 header;
17+ struct {
18+ u64 : 8;
19+ u64 num_cc : 8; /* # of supported crypto counters */
20+ u64 : 48;
21+ };
22+};
23+
24+static inline int qpaci(struct qpaci_info_block *info)
25+{
26+ /* Size of info (in double words minus one) */
27+ size_t size = sizeof(*info) / sizeof(u64) - 1;
28+ int cc;
29+
30+ asm volatile(
31+ " lgr 0,%[size]\n"
32+ " .insn s,0xb28f0000,%[info]\n"
33+ " lgr %[size],0\n"
34+ " ipm %[cc]\n"
35+ " srl %[cc],28\n"
36+ : [cc] "=d" (cc), [info] "=Q" (*info), [size] "+&d" (size)
37+ :
38+ : "0", "cc", "memory");
39+ return cc ? (size + 1) * sizeof(u64) : 0;
40+}
41+
42+#define PAI_CRYPTO_BASE 0x1000 /* First event number */
43+#define PAI_CRYPTO_MAXCTR 256 /* Max # of event counters */
44+#define PAI_CRYPTO_KERNEL_OFFSET 2048
45+
46+DECLARE_STATIC_KEY_FALSE(pai_key);
47+
48+static __always_inline void pai_kernel_enter(struct pt_regs *regs)
49+{
50+ if (!IS_ENABLED(CONFIG_PERF_EVENTS))
51+ return;
52+ if (!static_branch_unlikely(&pai_key))
53+ return;
54+ if (!S390_lowcore.ccd)
55+ return;
56+ if (!user_mode(regs))
57+ return;
58+ WRITE_ONCE(S390_lowcore.ccd, S390_lowcore.ccd | PAI_CRYPTO_KERNEL_OFFSET);
59+}
60+
61+static __always_inline void pai_kernel_exit(struct pt_regs *regs)
62+{
63+ if (!IS_ENABLED(CONFIG_PERF_EVENTS))
64+ return;
65+ if (!static_branch_unlikely(&pai_key))
66+ return;
67+ if (!S390_lowcore.ccd)
68+ return;
69+ if (!user_mode(regs))
70+ return;
71+ WRITE_ONCE(S390_lowcore.ccd, S390_lowcore.ccd & ~PAI_CRYPTO_KERNEL_OFFSET);
72+}
73+
74+#endif
arch/s390/include/asm/pci_debug.h+6−1
@@ -17,9 +17,14 @@ extern debug_info_t *pci_debug_err_id; · 16 unmodified lines
1717 debug_text_event(pci_debug_err_id, 0, debug_buffer); \
1818 } while (0)
1919
20+static inline void zpci_err_hex_level(int level, void *addr, int len)
21+{
22+ debug_event(pci_debug_err_id, level, addr, len);
23+}
24+
2025 static inline void zpci_err_hex(void *addr, int len)
2126 {
22− debug_event(pci_debug_err_id, 0, addr, len);
27+ zpci_err_hex_level(0, addr, len);
2328 }
2429
2530 #endif
arch/s390/include/asm/preempt.h+11−4
@@ -46,10 +46,17 @@ static inline bool test_preempt_need_resched(void) · 45 unmodified lines
4646
4747 static inline void __preempt_count_add(int val)
4848 {
49− if (__builtin_constant_p(val) && (val >= -128) && (val <= 127))
50− __atomic_add_const(val, &S390_lowcore.preempt_count);
51− else
52− __atomic_add(val, &S390_lowcore.preempt_count);
49+ /*
50+ * With some obscure config options and CONFIG_PROFILE_ALL_BRANCHES
51+ * enabled, gcc 12 fails to handle __builtin_constant_p().
52+ */
53+ if (!IS_ENABLED(CONFIG_PROFILE_ALL_BRANCHES)) {
54+ if (__builtin_constant_p(val) && (val >= -128) && (val <= 127)) {
55+ __atomic_add_const(val, &S390_lowcore.preempt_count);
56+ return;
57+ }
58+ }
59+ __atomic_add(val, &S390_lowcore.preempt_count);
5360 }
5461
5562 static inline void __preempt_count_sub(int val)
arch/s390/include/asm/processor.h+5−3
@@ -83,6 +83,7 @@ void cpu_detect_mhz_feature(void); · 82 unmodified lines
8383 extern const struct seq_operations cpuinfo_op;
8484 extern void execve_tail(void);
8585 extern void __bpon(void);
86+unsigned long vdso_size(void);
8687
8788 /*
8889 * User space process size: 2GB for 31 bit, 4TB or 8PT for 64 bit.
@@ -94,9 +95,10 @@ extern void __bpon(void); · 5 unmodified lines
9495 (_REGION3_SIZE >> 1) : (_REGION2_SIZE >> 1))
9596 #define TASK_SIZE_MAX (-PAGE_SIZE)
9697
97−#define STACK_TOP (test_thread_flag(TIF_31BIT) ? \
98− _REGION3_SIZE : _REGION2_SIZE)
99−#define STACK_TOP_MAX _REGION2_SIZE
98+#define VDSO_BASE (STACK_TOP + PAGE_SIZE)
99+#define VDSO_LIMIT (test_thread_flag(TIF_31BIT) ? _REGION3_SIZE : _REGION2_SIZE)
100+#define STACK_TOP (VDSO_LIMIT - vdso_size() - PAGE_SIZE)
101+#define STACK_TOP_MAX (_REGION2_SIZE - vdso_size() - PAGE_SIZE)
100102
101103 #define HAVE_ARCH_PICK_MMAP_LAYOUT
102104
arch/s390/include/asm/ptrace.h+29−0
@@ -71,6 +71,35 @@ enum { · 70 unmodified lines
7171 &(*(struct psw_bits *)(&(__psw))); \
7272 }))
7373
74+#define PSW32_MASK_PER 0x40000000UL
75+#define PSW32_MASK_DAT 0x04000000UL
76+#define PSW32_MASK_IO 0x02000000UL
77+#define PSW32_MASK_EXT 0x01000000UL
78+#define PSW32_MASK_KEY 0x00F00000UL
79+#define PSW32_MASK_BASE 0x00080000UL /* Always one */
80+#define PSW32_MASK_MCHECK 0x00040000UL
81+#define PSW32_MASK_WAIT 0x00020000UL
82+#define PSW32_MASK_PSTATE 0x00010000UL
83+#define PSW32_MASK_ASC 0x0000C000UL
84+#define PSW32_MASK_CC 0x00003000UL
85+#define PSW32_MASK_PM 0x00000f00UL
86+#define PSW32_MASK_RI 0x00000080UL
87+
88+#define PSW32_ADDR_AMODE 0x80000000UL
89+#define PSW32_ADDR_INSN 0x7FFFFFFFUL
90+
91+#define PSW32_DEFAULT_KEY (((u32)PAGE_DEFAULT_ACC) << 20)
92+
93+#define PSW32_ASC_PRIMARY 0x00000000UL
94+#define PSW32_ASC_ACCREG 0x00004000UL
95+#define PSW32_ASC_SECONDARY 0x00008000UL
96+#define PSW32_ASC_HOME 0x0000C000UL
97+
98+typedef struct {
99+ unsigned int mask;
100+ unsigned int addr;
101+} psw_t32 __aligned(8);
102+
74103 #define PGM_INT_CODE_MASK 0x7f
75104 #define PGM_INT_CODE_PER 0x80
76105
arch/s390/include/asm/sclp.h+1−0
@@ -87,6 +87,7 @@ struct sclp_info { · 86 unmodified lines
8787 unsigned char has_diag318 : 1;
8888 unsigned char has_sipl : 1;
8989 unsigned char has_dirq : 1;
90+ unsigned char has_iplcc : 1;
9091 unsigned int ibc;
9192 unsigned int mtid;
9293 unsigned int mtid_cp;
arch/s390/include/asm/scsw.h+68−15
@@ -508,9 +508,21 @@ static inline int scsw_cmd_is_valid_zcc(union scsw *scsw) · 507 unmodified lines
508508 */
509509 static inline int scsw_cmd_is_valid_ectl(union scsw *scsw)
510510 {
511− return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
512− !(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) &&
513− (scsw->cmd.stctl & SCSW_STCTL_ALERT_STATUS);
511+ /* Must be status pending. */
512+ if (!(scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND))
513+ return 0;
514+
515+ /* Must have alert status. */
516+ if (!(scsw->cmd.stctl & SCSW_STCTL_ALERT_STATUS))
517+ return 0;
518+
519+ /* Must be alone or together with primary, secondary or both,
520+ * => no intermediate status.
521+ */
522+ if (scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS)
523+ return 0;
524+
525+ return 1;
514526 }
515527
516528 /**
@@ -522,10 +534,25 @@ static inline int scsw_cmd_is_valid_ectl(union scsw *scsw) · 5 unmodified lines
522534 */
523535 static inline int scsw_cmd_is_valid_pno(union scsw *scsw)
524536 {
525− return (scsw->cmd.fctl != 0) &&
526− (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
527− (!(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) ||
528− (scsw->cmd.actl & SCSW_ACTL_SUSPENDED));
537+ /* Must indicate at least one I/O function. */
538+ if (!scsw->cmd.fctl)
539+ return 0;
540+
541+ /* Must be status pending. */
542+ if (!(scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND))
543+ return 0;
544+
545+ /* Can be status pending alone, or with any combination of primary,
546+ * secondary and alert => no intermediate status.
547+ */
548+ if (!(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS))
549+ return 1;
550+
551+ /* If intermediate, must be suspended. */
552+ if (scsw->cmd.actl & SCSW_ACTL_SUSPENDED)
553+ return 1;
554+
555+ return 0;
529556 }
530557
531558 /**
@@ -675,9 +702,21 @@ static inline int scsw_tm_is_valid_q(union scsw *scsw) · 143 unmodified lines
675702 */
676703 static inline int scsw_tm_is_valid_ectl(union scsw *scsw)
677704 {
678− return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
679− !(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) &&
680− (scsw->tm.stctl & SCSW_STCTL_ALERT_STATUS);
705+ /* Must be status pending. */
706+ if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
707+ return 0;
708+
709+ /* Must have alert status. */
710+ if (!(scsw->tm.stctl & SCSW_STCTL_ALERT_STATUS))
711+ return 0;
712+
713+ /* Must be alone or together with primary, secondary or both,
714+ * => no intermediate status.
715+ */
716+ if (scsw->tm.stctl & SCSW_STCTL_INTER_STATUS)
717+ return 0;
718+
719+ return 1;
681720 }
682721
683722 /**
@@ -689,11 +728,25 @@ static inline int scsw_tm_is_valid_ectl(union scsw *scsw) · 5 unmodified lines
689728 */
690729 static inline int scsw_tm_is_valid_pno(union scsw *scsw)
691730 {
692− return (scsw->tm.fctl != 0) &&
693− (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
694− (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) ||
695− ((scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) &&
696− (scsw->tm.actl & SCSW_ACTL_SUSPENDED)));
731+ /* Must indicate at least one I/O function. */
732+ if (!scsw->tm.fctl)
733+ return 0;
734+
735+ /* Must be status pending. */
736+ if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
737+ return 0;
738+
739+ /* Can be status pending alone, or with any combination of primary,
740+ * secondary and alert => no intermediate status.
741+ */
742+ if (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS))
743+ return 1;
744+
745+ /* If intermediate, must be suspended. */
746+ if (scsw->tm.actl & SCSW_ACTL_SUSPENDED)
747+ return 1;
748+
749+ return 0;
697750 }
698751
699752 /**
arch/s390/include/asm/spinlock.h+2−1
@@ -77,8 +77,9 @@ static inline int arch_spin_trylock(arch_spinlock_t *lp) · 76 unmodified lines
7777 static inline void arch_spin_unlock(arch_spinlock_t *lp)
7878 {
7979 typecheck(int, lp->lock);
80+ kcsan_release();
8081 asm_inline volatile(
81− ALTERNATIVE("", ".insn rre,0xb2fa0000,7,0", 49) /* NIAI 7 */
82+ ALTERNATIVE("nop", ".insn rre,0xb2fa0000,7,0", 49) /* NIAI 7 */
8283 " sth %1,%0\n"
8384 : "=R" (((unsigned short *) &lp->lock)[1])
8485 : "d" (0) : "cc", "memory");
arch/s390/include/asm/stp.h+2−2
@@ -44,8 +44,8 @@ struct stp_sstpi { · 43 unmodified lines
4444 u32 : 32;
4545 u32 ctnid[3];
4646 u32 : 32;
47− u32 todoff[4];
48− u32 rsvd[48];
47+ u64 todoff;
48+ u32 rsvd[50];
4949 } __packed;
5050
5151 struct stp_tzib {
arch/s390/include/asm/vx-insn.h+3−3
@@ -366,7 +366,7 @@ · 365 unmodified lines
366366 .macro VLM vfrom, vto, disp, base, hint=3
367367 VX_NUM v1, \vfrom
368368 VX_NUM v3, \vto
369− GR_NUM b2, \base /* Base register */
369+ GR_NUM b2, \base
370370 .word 0xE700 | ((v1&15) << 4) | (v3&15)
371371 .word (b2 << 12) | (\disp)
372372 MRXBOPC \hint, 0x36, v1, v3
@@ -376,7 +376,7 @@ · 3 unmodified lines
376376 .macro VST vr1, disp, index="%r0", base
377377 VX_NUM v1, \vr1
378378 GR_NUM x2, \index
379− GR_NUM b2, \base /* Base register */
379+ GR_NUM b2, \base
380380 .word 0xE700 | ((v1&15) << 4) | (x2&15)
381381 .word (b2 << 12) | (\disp)
382382 MRXBOPC 0, 0x0E, v1
@@ -386,7 +386,7 @@ · 3 unmodified lines
386386 .macro VSTM vfrom, vto, disp, base, hint=3
387387 VX_NUM v1, \vfrom
388388 VX_NUM v3, \vto
389− GR_NUM b2, \base /* Base register */
389+ GR_NUM b2, \base
390390 .word 0xE700 | ((v1&15) << 4) | (v3&15)
391391 .word (b2 << 12) | (\disp)
392392 MRXBOPC \hint, 0x3E, v1, v3
arch/s390/include/uapi/asm/pkey.h+1−1
@@ -171,7 +171,7 @@ struct pkey_skey2pkey { · 170 unmodified lines
171171 #define PKEY_SKEY2PKEY _IOWR(PKEY_IOCTL_MAGIC, 0x06, struct pkey_skey2pkey)
172172
173173 /*
174− * Verify the given CCA AES secure key for being able to be useable with
174+ * Verify the given CCA AES secure key for being able to be usable with
175175 * the pkey module. Check for correct key type and check for having at
176176 * least one crypto card being able to handle this key (master key
177177 * or old master key verification pattern matches).
arch/s390/include/uapi/asm/zcrypt.h+20−22
@@ -4,7 +4,7 @@ · 3 unmodified lines
44 *
55 * zcrypt 2.2.1 (user-visible header)
66 *
7− * Copyright IBM Corp. 2001, 2019
7+ * Copyright IBM Corp. 2001, 2022
88 * Author(s): Robert Burroughs
99 * Eric Rossman (edrossma@us.ibm.com)
1010 *
@@ -85,7 +85,7 @@ struct ica_rsa_modexpo_crt { · 74 unmodified lines
8585 struct CPRBX {
8686 __u16 cprb_len; /* CPRB length 220 */
8787 __u8 cprb_ver_id; /* CPRB version id. 0x02 */
88− __u8 pad_000[3]; /* Alignment pad bytes */
88+ __u8 _pad_000[3]; /* Alignment pad bytes */
8989 __u8 func_id[2]; /* function id 0x5432 */
9090 __u8 cprb_flags[4]; /* Flags */
9191 __u32 req_parml; /* request parameter buffer len */
@@ -95,19 +95,19 @@ struct CPRBX { · 3 unmodified lines
9595 __u32 rpl_datal; /* reply data block len */
9696 __u32 rpld_datal; /* replied data block len */
9797 __u32 req_extbl; /* request extension block len */
98− __u8 pad_001[4]; /* reserved */
98+ __u8 _pad_001[4]; /* reserved */
9999 __u32 rpld_extbl; /* replied extension block len */
100− __u8 padx000[16 - sizeof(__u8 *)];
100+ __u8 _pad_002[16 - sizeof(__u8 *)];
101101 __u8 __user *req_parmb; /* request parm block 'address' */
102− __u8 padx001[16 - sizeof(__u8 *)];
102+ __u8 _pad_003[16 - sizeof(__u8 *)];
103103 __u8 __user *req_datab; /* request data block 'address' */
104− __u8 padx002[16 - sizeof(__u8 *)];
104+ __u8 _pad_004[16 - sizeof(__u8 *)];
105105 __u8 __user *rpl_parmb; /* reply parm block 'address' */
106− __u8 padx003[16 - sizeof(__u8 *)];
106+ __u8 _pad_005[16 - sizeof(__u8 *)];
107107 __u8 __user *rpl_datab; /* reply data block 'address' */
108− __u8 padx004[16 - sizeof(__u8 *)];
108+ __u8 _pad_006[16 - sizeof(__u8 *)];
109109 __u8 __user *req_extb; /* request extension block 'addr'*/
110− __u8 padx005[16 - sizeof(__u8 *)];
110+ __u8 _pad_007[16 - sizeof(__u8 *)];
111111 __u8 __user *rpl_extb; /* reply extension block 'address'*/
112112 __u16 ccp_rtcode; /* server return code */
113113 __u16 ccp_rscode; /* server reason code */
@@ -115,12 +115,10 @@ struct CPRBX { · 1 unmodified line
115115 __u8 logon_id[8]; /* Logon Identifier */
116116 __u8 mac_value[8]; /* Mac Value */
117117 __u8 mac_content_flgs; /* Mac content flag byte */
118− __u8 pad_002; /* Alignment */
118+ __u8 _pad_008; /* Alignment */
119119 __u16 domain; /* Domain */
120− __u8 usage_domain[4]; /* Usage domain */
121− __u8 cntrl_domain[4]; /* Control domain */
122− __u8 S390enf_mask[4]; /* S/390 enforcement mask */
123− __u8 pad_004[36]; /* reserved */
120+ __u8 _pad_009[12]; /* reserved, checked for zeros */
121+ __u8 _pad_010[36]; /* reserved */
124122 } __attribute__((packed));
125123
126124 /**
@@ -238,8 +236,8 @@ struct zcrypt_device_matrix_ext { · 111 unmodified lines
238236 };
239237
240238 #define AUTOSELECT 0xFFFFFFFF
241−#define AUTOSEL_AP ((__u16) 0xFFFF)
242−#define AUTOSEL_DOM ((__u16) 0xFFFF)
239+#define AUTOSEL_AP ((__u16)0xFFFF)
240+#define AUTOSEL_DOM ((__u16)0xFFFF)
243241
244242 #define ZCRYPT_IOCTL_MAGIC 'z'
245243
@@ -305,12 +303,12 @@ struct zcrypt_device_matrix_ext { · 59 unmodified lines
305303 /**
306304 * Supported ioctl calls
307305 */
308−#define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x05, 0)
309−#define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0)
310−#define ZSECSENDCPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0)
311−#define ZSENDEP11CPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0)
306+#define ICARSAMODEXPO _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x05, 0)
307+#define ICARSACRT _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0)
308+#define ZSECSENDCPRB _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0)
309+#define ZSENDEP11CPRB _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0)
312310
313−#define ZCRYPT_DEVICE_STATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x5f, 0)
311+#define ZCRYPT_DEVICE_STATUS _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x5f, 0)
314312 #define ZCRYPT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x58, char[MAX_ZDEV_CARDIDS_EXT])
315313 #define ZCRYPT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x59, char[MAX_ZDEV_CARDIDS_EXT])
316314 #define ZCRYPT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x5a, int[MAX_ZDEV_CARDIDS_EXT])
@@ -352,7 +350,7 @@ struct zcrypt_device_matrix { · 35 unmodified lines
352350 };
353351
354352 /* Deprecated: use ZCRYPT_DEVICE_STATUS */
355−#define ZDEVICESTATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0)
353+#define ZDEVICESTATUS _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0)
356354 /* Deprecated: use ZCRYPT_STATUS_MASK */
357355 #define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64])
358356 /* Deprecated: use ZCRYPT_QDEPTH_MASK */
arch/s390/kernel/Makefile+1−0
@@ -72,6 +72,7 @@ obj-$(CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT) += ima_arch.o · 71 unmodified lines
7272 obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf_common.o
7373 obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf.o perf_cpum_sf.o
7474 obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf_events.o perf_regs.o
75+obj-$(CONFIG_PERF_EVENTS) += perf_pai_crypto.o
7576
7677 obj-$(CONFIG_TRACEPOINTS) += trace.o
7778 obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o
arch/s390/kernel/alternative.c+2−59
@@ -7,8 +7,6 @@ · 6 unmodified lines
77 #include <asm/facility.h>
88 #include <asm/nospec-branch.h>
99
10−#define MAX_PATCH_LEN (255 - 1)
11−
1210 static int __initdata_or_module alt_instr_disabled;
1311
1412 static int __init disable_alternative_instructions(char *str)
@@ -19,85 +17,30 @@ static int __init disable_alternative_instructions(char *str) · 4 unmodified lines
1917
2018 early_param("noaltinstr", disable_alternative_instructions);
2119
22−struct brcl_insn {
23− u16 opc;
24− s32 disp;
25−} __packed;
26−
27−static u16 __initdata_or_module nop16 = 0x0700;
28−static u32 __initdata_or_module nop32 = 0x47000000;
29−static struct brcl_insn __initdata_or_module nop48 = {
30− 0xc004, 0
31−};
32−
33−static const void *nops[] __initdata_or_module = {
34− &nop16,
35− &nop32,
36− &nop48
37−};
38−
39−static void __init_or_module add_jump_padding(void *insns, unsigned int len)
40−{
41− struct brcl_insn brcl = {
42− 0xc0f4,
43− len / 2
44− };
45−
46− memcpy(insns, &brcl, sizeof(brcl));
47− insns += sizeof(brcl);
48− len -= sizeof(brcl);
49−
50− while (len > 0) {
51− memcpy(insns, &nop16, 2);
52− insns += 2;
53− len -= 2;
54− }
55−}
56−
57−static void __init_or_module add_padding(void *insns, unsigned int len)
58−{
59− if (len > 6)
60− add_jump_padding(insns, len);
61− else if (len >= 2)
62− memcpy(insns, nops[len / 2 - 1], len);
63−}
64−
6520 static void __init_or_module __apply_alternatives(struct alt_instr *start,
6621 struct alt_instr *end)
6722 {
6823 struct alt_instr *a;
6924 u8 *instr, *replacement;
70− u8 insnbuf[MAX_PATCH_LEN];
7125
7226 /*
7327 * The scan order should be from start to end. A later scanned
7428 * alternative code can overwrite previously scanned alternative code.
7529 */
7630 for (a = start; a < end; a++) {
77− int insnbuf_sz = 0;
78−
7931 instr = (u8 *)&a->instr_offset + a->instr_offset;
8032 replacement = (u8 *)&a->repl_offset + a->repl_offset;
8133
8234 if (!__test_facility(a->facility, alt_stfle_fac_list))
8335 continue;
8436
85− if (unlikely(a->instrlen % 2 || a->replacementlen % 2)) {
37+ if (unlikely(a->instrlen % 2)) {
8638 WARN_ONCE(1, "cpu alternatives instructions length is "
8739 "odd, skipping patching\n");
8840 continue;
8941 }
9042
91− memcpy(insnbuf, replacement, a->replacementlen);
92− insnbuf_sz = a->replacementlen;
93−
94− if (a->instrlen > a->replacementlen) {
95− add_padding(insnbuf + a->replacementlen,
96− a->instrlen - a->replacementlen);
97− insnbuf_sz += a->instrlen - a->replacementlen;
98− }
99−
100− s390_kernel_write(instr, insnbuf, insnbuf_sz);
43+ s390_kernel_write(instr, replacement, a->instrlen);
10144 }
10245 }
10346
arch/s390/kernel/compat_linux.h+30−59
@@ -5,69 +5,59 @@ · 4 unmodified lines
55 #include <linux/compat.h>
66 #include <linux/socket.h>
77 #include <linux/syscalls.h>
8+#include <asm/ptrace.h>
89
9−/* Macro that masks the high order bit of an 32 bit pointer and converts it*/
10−/* to a 64 bit pointer */
11−#define A(__x) ((unsigned long)((__x) & 0x7FFFFFFFUL))
12−#define AA(__x) \
13− ((unsigned long)(__x))
10+/*
11+ * Macro that masks the high order bit of a 32 bit pointer and
12+ * converts it to a 64 bit pointer.
13+ */
14+#define A(__x) ((unsigned long)((__x) & 0x7FFFFFFFUL))
15+#define AA(__x) ((unsigned long)(__x))
1416
1517 /* Now 32bit compatibility types */
1618 struct ipc_kludge_32 {
17− __u32 msgp; /* pointer */
18− __s32 msgtyp;
19+ __u32 msgp; /* pointer */
20+ __s32 msgtyp;
1921 };
2022
2123 /* asm/sigcontext.h */
22−typedef union
23−{
24− __u64 d;
25− __u32 f;
24+typedef union {
25+ __u64 d;
26+ __u32 f;
2627 } freg_t32;
2728
28−typedef struct
29−{
29+typedef struct {
3030 unsigned int fpc;
3131 unsigned int pad;
32− freg_t32 fprs[__NUM_FPRS];
32+ freg_t32 fprs[__NUM_FPRS];
3333 } _s390_fp_regs32;
3434
35−typedef struct
36−{
37− __u32 mask;
38− __u32 addr;
39−} _psw_t32 __attribute__ ((aligned(8)));
40−
41−typedef struct
42−{
43− _psw_t32 psw;
35+typedef struct {
36+ psw_t32 psw;
4437 __u32 gprs[__NUM_GPRS];
4538 __u32 acrs[__NUM_ACRS];
4639 } _s390_regs_common32;
4740
48−typedef struct
49−{
41+typedef struct {
5042 _s390_regs_common32 regs;
51− _s390_fp_regs32 fpregs;
43+ _s390_fp_regs32 fpregs;
5244 } _sigregs32;
5345
54−typedef struct
55−{
56− __u32 gprs_high[__NUM_GPRS];
57− __u64 vxrs_low[__NUM_VXRS_LOW];
58− __vector128 vxrs_high[__NUM_VXRS_HIGH];
59− __u8 __reserved[128];
46+typedef struct {
47+ __u32 gprs_high[__NUM_GPRS];
48+ __u64 vxrs_low[__NUM_VXRS_LOW];
49+ __vector128 vxrs_high[__NUM_VXRS_HIGH];
50+ __u8 __reserved[128];
6051 } _sigregs_ext32;
6152
6253 #define _SIGCONTEXT_NSIG32 64
6354 #define _SIGCONTEXT_NSIG_BPW32 32
6455 #define __SIGNAL_FRAMESIZE32 96
65−#define _SIGMASK_COPY_SIZE32 (sizeof(u32)*2)
56+#define _SIGMASK_COPY_SIZE32 (sizeof(u32) * 2)
6657
67−struct sigcontext32
68−{
58+struct sigcontext32 {
6959 __u32 oldmask[_COMPAT_NSIG_WORDS];
70− __u32 sregs; /* pointer */
60+ __u32 sregs; /* pointer */
7161 };
7262
7363 /* asm/signal.h */
@@ -75,11 +65,11 @@ struct sigcontext32 · 1 unmodified line
7565 /* asm/ucontext.h */
7666 struct ucontext32 {
7767 __u32 uc_flags;
78− __u32 uc_link; /* pointer */
68+ __u32 uc_link; /* pointer */
7969 compat_stack_t uc_stack;
8070 _sigregs32 uc_mcontext;
8171 compat_sigset_t uc_sigmask;
82− /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
72+ /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
8373 unsigned char __unused[128 - sizeof(compat_sigset_t)];
8474 _sigregs_ext32 uc_mcontext_ext;
8575 };
@@ -88,25 +78,6 @@ struct stat64_emu31; · 2 unmodified lines
8878 struct mmap_arg_struct_emu31;
8979 struct fadvise64_64_args;
9080
91−long compat_sys_s390_chown16(const char __user *filename, u16 user, u16 group);
92−long compat_sys_s390_lchown16(const char __user *filename, u16 user, u16 group);
93−long compat_sys_s390_fchown16(unsigned int fd, u16 user, u16 group);
94−long compat_sys_s390_setregid16(u16 rgid, u16 egid);
95−long compat_sys_s390_setgid16(u16 gid);
96−long compat_sys_s390_setreuid16(u16 ruid, u16 euid);
97−long compat_sys_s390_setuid16(u16 uid);
98−long compat_sys_s390_setresuid16(u16 ruid, u16 euid, u16 suid);
99−long compat_sys_s390_getresuid16(u16 __user *ruid, u16 __user *euid, u16 __user *suid);
100−long compat_sys_s390_setresgid16(u16 rgid, u16 egid, u16 sgid);
101−long compat_sys_s390_getresgid16(u16 __user *rgid, u16 __user *egid, u16 __user *sgid);
102−long compat_sys_s390_setfsuid16(u16 uid);
103−long compat_sys_s390_setfsgid16(u16 gid);
104−long compat_sys_s390_getgroups16(int gidsetsize, u16 __user *grouplist);
105−long compat_sys_s390_setgroups16(int gidsetsize, u16 __user *grouplist);
106−long compat_sys_s390_getuid16(void);
107−long compat_sys_s390_geteuid16(void);
108−long compat_sys_s390_getgid16(void);
109−long compat_sys_s390_getegid16(void);
11081 long compat_sys_s390_truncate64(const char __user *path, u32 high, u32 low);
11182 long compat_sys_s390_ftruncate64(unsigned int fd, u32 high, u32 low);
11283 long compat_sys_s390_pread64(unsigned int fd, char __user *ubuf, compat_size_t count, u32 high, u32 low);
@@ -118,8 +89,8 @@ long compat_sys_s390_fstat64(unsigned int fd, struct stat64_emu31 __user *statbu · 5 unmodified lines
11889 long compat_sys_s390_fstatat64(unsigned int dfd, const char __user *filename, struct stat64_emu31 __user *statbuf, int flag);
11990 long compat_sys_s390_old_mmap(struct mmap_arg_struct_emu31 __user *arg);
12091 long compat_sys_s390_mmap2(struct mmap_arg_struct_emu31 __user *arg);
121−long compat_sys_s390_read(unsigned int fd, char __user * buf, compat_size_t count);
122−long compat_sys_s390_write(unsigned int fd, const char __user * buf, compat_size_t count);
92+long compat_sys_s390_read(unsigned int fd, char __user *buf, compat_size_t count);
93+long compat_sys_s390_write(unsigned int fd, const char __user *buf, compat_size_t count);
12394 long compat_sys_s390_fadvise64(int fd, u32 high, u32 low, compat_size_t len, int advise);
12495 long compat_sys_s390_fadvise64_64(struct fadvise64_64_args __user *args);
12596 long compat_sys_s390_sync_file_range(int fd, u32 offhigh, u32 offlow, u32 nhigh, u32 nlow, unsigned int flags);
arch/s390/kernel/entry.S+24−16
@@ -53,19 +53,19 @@ STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE · 52 unmodified lines
5353 _LPP_OFFSET = __LC_LPP
5454
5555 .macro STBEAR address
56− ALTERNATIVE "", ".insn s,0xb2010000,\address", 193
56+ ALTERNATIVE "nop", ".insn s,0xb2010000,\address", 193
5757 .endm
5858
5959 .macro LBEAR address
60− ALTERNATIVE "", ".insn s,0xb2000000,\address", 193
60+ ALTERNATIVE "nop", ".insn s,0xb2000000,\address", 193
6161 .endm
6262
6363 .macro LPSWEY address,lpswe
64− ALTERNATIVE "b \lpswe", ".insn siy,0xeb0000000071,\address,0", 193
64+ ALTERNATIVE "b \lpswe; nopr", ".insn siy,0xeb0000000071,\address,0", 193
6565 .endm
6666
6767 .macro MBEAR reg
68− ALTERNATIVE "", __stringify(mvc __PT_LAST_BREAK(8,\reg),__LC_LAST_BREAK), 193
68+ ALTERNATIVE "brcl 0,0", __stringify(mvc __PT_LAST_BREAK(8,\reg),__LC_LAST_BREAK), 193
6969 .endm
7070
7171 .macro CHECK_STACK savearea
@@ -121,16 +121,16 @@ _LPP_OFFSET = __LC_LPP · 49 unmodified lines
121121 .endm
122122
123123 .macro BPOFF
124− ALTERNATIVE "", ".insn rrf,0xb2e80000,0,0,12,0", 82
124+ ALTERNATIVE "nop", ".insn rrf,0xb2e80000,0,0,12,0", 82
125125 .endm
126126
127127 .macro BPON
128− ALTERNATIVE "", ".insn rrf,0xb2e80000,0,0,13,0", 82
128+ ALTERNATIVE "nop", ".insn rrf,0xb2e80000,0,0,13,0", 82
129129 .endm
130130
131131 .macro BPENTER tif_ptr,tif_mask
132132 ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .insn rrf,0xb2e80000,0,0,13,0", \
133− "", 82
133+ "j .+12; nop; nop", 82
134134 .endm
135135
136136 .macro BPEXIT tif_ptr,tif_mask
@@ -172,9 +172,19 @@ _LPP_OFFSET = __LC_LPP · 35 unmodified lines
172172 lgr %r14,\reg
173173 larl %r13,\start
174174 slgr %r14,%r13
175− lghi %r13,\end - \start
176− clgr %r14,%r13
175+#ifdef CONFIG_AS_IS_LLVM
176+ clgfrl %r14,.Lrange_size\@
177+#else
178+ clgfi %r14,\end - \start
179+#endif
177180 jhe \outside_label
181+#ifdef CONFIG_AS_IS_LLVM
182+ .section .rodata, "a"
183+ .align 4
184+.Lrange_size\@:
185+ .long \end - \start
186+ .previous
187+#endif
178188 .endm
179189
180190 .macro SIEEXIT
@@ -226,7 +236,7 @@ ENTRY(__switch_to) · 45 unmodified lines
226236 aghi %r3,__TASK_pid
227237 mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next
228238 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
229− ALTERNATIVE "", "lpp _LPP_OFFSET", 40
239+ ALTERNATIVE "nop", "lpp _LPP_OFFSET", 40
230240 BR_EX %r14
231241 ENDPROC(__switch_to)
232242
@@ -473,10 +483,7 @@ ENTRY(\name) · 240 unmodified lines
473483 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
474484 MBEAR %r11
475485 stmg %r8,%r9,__PT_PSW(%r11)
476− tm %r8,0x0001 # coming from user space?
477− jno 1f
478− lctlg %c1,%c1,__LC_KERNEL_ASCE
479−1: lgr %r2,%r11 # pass pointer to pt_regs
486+ lgr %r2,%r11 # pass pointer to pt_regs
480487 brasl %r14,\handler
481488 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
482489 tmhh %r8,0x0001 # returning to user ?
@@ -602,6 +609,7 @@ ENTRY(mcck_int_handler) · 119 unmodified lines
602609 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
603610 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
604611 la %r11,STACK_FRAME_OVERHEAD(%r1)
612+ lgr %r2,%r11
605613 lgr %r15,%r1
606614 brasl %r14,s390_handle_mcck
607615 .Lmcck_return:
@@ -612,7 +620,7 @@ ENTRY(mcck_int_handler) · 4 unmodified lines
612620 jno 0f
613621 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
614622 stpt __LC_EXIT_TIMER
615−0: ALTERNATIVE "", __stringify(lghi %r12,__LC_LAST_BREAK_SAVE_AREA),193
623+0: ALTERNATIVE "nop", __stringify(lghi %r12,__LC_LAST_BREAK_SAVE_AREA),193
616624 LBEAR 0(%r12)
617625 lmg %r11,%r15,__PT_R11(%r11)
618626 LPSWEY __LC_RETURN_MCCK_PSW,__LC_RETURN_MCCK_LPSWE
@@ -648,7 +656,7 @@ ENTRY(mcck_int_handler) · 29 unmodified lines
648656 ENDPROC(mcck_int_handler)
649657
650658 ENTRY(restart_int_handler)
651− ALTERNATIVE "", "lpp _LPP_OFFSET", 40
659+ ALTERNATIVE "nop", "lpp _LPP_OFFSET", 40
652660 stg %r15,__LC_SAVE_AREA_RESTART
653661 TSTMSK __LC_RESTART_FLAGS,RESTART_FLAG_CTLREGS,4
654662 jz 0f
arch/s390/kernel/irq.c+2−2
@@ -205,7 +205,7 @@ static void show_msi_interrupt(struct seq_file *p, int irq) · 204 unmodified lines
205205 unsigned long flags;
206206 int cpu;
207207
208− irq_lock_sparse();
208+ rcu_read_lock();
209209 desc = irq_to_desc(irq);
210210 if (!desc)
211211 goto out;
@@ -224,7 +224,7 @@ static void show_msi_interrupt(struct seq_file *p, int irq) · 12 unmodified lines
224224 seq_putc(p, '\n');
225225 raw_spin_unlock_irqrestore(&desc->lock, flags);
226226 out:
227− irq_unlock_sparse();
227+ rcu_read_unlock();
228228 }
229229
230230 /*
arch/s390/kernel/machine_kexec.c+8−2
@@ -26,8 +26,10 @@ · 25 unmodified lines
2626 #include <asm/stacktrace.h>
2727 #include <asm/switch_to.h>
2828 #include <asm/nmi.h>
29+#include <asm/sclp.h>
2930
30−typedef void (*relocate_kernel_t)(kimage_entry_t *, unsigned long);
31+typedef void (*relocate_kernel_t)(kimage_entry_t *, unsigned long,
32+ unsigned long);
3133
3234 extern const unsigned char relocate_kernel[];
3335 extern const unsigned long long relocate_kernel_len;
@@ -243,6 +245,7 @@ void machine_crash_shutdown(struct pt_regs *regs) · 209 unmodified lines
243245 */
244246 static void __do_machine_kexec(void *data)
245247 {
248+ unsigned long diag308_subcode;
246249 relocate_kernel_t data_mover;
247250 struct kimage *image = data;
248251
@@ -251,7 +254,10 @@ static void __do_machine_kexec(void *data) · 2 unmodified lines
251254
252255 __arch_local_irq_stnsm(0xfb); /* disable DAT - avoid no-execute */
253256 /* Call the moving routine */
254− (*data_mover)(&image->head, image->start);
257+ diag308_subcode = DIAG308_CLEAR_RESET;
258+ if (sclp.has_iplcc)
259+ diag308_subcode |= DIAG308_FLAG_EI;
260+ (*data_mover)(&image->head, image->start, diag308_subcode);
255261
256262 /* Die if kexec returns */
257263 disabled_wait();
arch/s390/kernel/nmi.c+5−1
@@ -29,6 +29,8 @@ · 28 unmodified lines
2929 #include <asm/switch_to.h>
3030 #include <asm/ctl_reg.h>
3131 #include <asm/asm-offsets.h>
32+#include <asm/pai.h>
33+
3234 #include <linux/kvm_host.h>
3335
3436 struct mcck_struct {
@@ -169,10 +171,12 @@ void __s390_handle_mcck(void) · 134 unmodified lines
169171 }
170172 }
171173
172−void noinstr s390_handle_mcck(void)
174+void noinstr s390_handle_mcck(struct pt_regs *regs)
173175 {
174176 trace_hardirqs_off();
177+ pai_kernel_enter(regs);
175178 __s390_handle_mcck();
179+ pai_kernel_exit(regs);
176180 trace_hardirqs_on();
177181 }
178182 /*
arch/s390/kernel/perf_cpum_cf_events.c+148−0
@@ -295,6 +295,76 @@ CPUMF_EVENT_ATTR(cf_z15, DFLT_CC, 0x00108); · 294 unmodified lines
295295 CPUMF_EVENT_ATTR(cf_z15, DFLT_CCFINISH, 0x00109);
296296 CPUMF_EVENT_ATTR(cf_z15, MT_DIAG_CYCLES_ONE_THR_ACTIVE, 0x01c0);
297297 CPUMF_EVENT_ATTR(cf_z15, MT_DIAG_CYCLES_TWO_THR_ACTIVE, 0x01c1);
298+CPUMF_EVENT_ATTR(cf_z16, L1D_RO_EXCL_WRITES, 0x0080);
299+CPUMF_EVENT_ATTR(cf_z16, DTLB2_WRITES, 0x0081);
300+CPUMF_EVENT_ATTR(cf_z16, DTLB2_MISSES, 0x0082);
301+CPUMF_EVENT_ATTR(cf_z16, CRSTE_1MB_WRITES, 0x0083);
302+CPUMF_EVENT_ATTR(cf_z16, DTLB2_GPAGE_WRITES, 0x0084);
303+CPUMF_EVENT_ATTR(cf_z16, ITLB2_WRITES, 0x0086);
304+CPUMF_EVENT_ATTR(cf_z16, ITLB2_MISSES, 0x0087);
305+CPUMF_EVENT_ATTR(cf_z16, TLB2_PTE_WRITES, 0x0089);
306+CPUMF_EVENT_ATTR(cf_z16, TLB2_CRSTE_WRITES, 0x008a);
307+CPUMF_EVENT_ATTR(cf_z16, TLB2_ENGINES_BUSY, 0x008b);
308+CPUMF_EVENT_ATTR(cf_z16, TX_C_TEND, 0x008c);
309+CPUMF_EVENT_ATTR(cf_z16, TX_NC_TEND, 0x008d);
310+CPUMF_EVENT_ATTR(cf_z16, L1C_TLB2_MISSES, 0x008f);
311+CPUMF_EVENT_ATTR(cf_z16, DCW_REQ, 0x0091);
312+CPUMF_EVENT_ATTR(cf_z16, DCW_REQ_IV, 0x0092);
313+CPUMF_EVENT_ATTR(cf_z16, DCW_REQ_CHIP_HIT, 0x0093);
314+CPUMF_EVENT_ATTR(cf_z16, DCW_REQ_DRAWER_HIT, 0x0094);
315+CPUMF_EVENT_ATTR(cf_z16, DCW_ON_CHIP, 0x0095);
316+CPUMF_EVENT_ATTR(cf_z16, DCW_ON_CHIP_IV, 0x0096);
317+CPUMF_EVENT_ATTR(cf_z16, DCW_ON_CHIP_CHIP_HIT, 0x0097);
318+CPUMF_EVENT_ATTR(cf_z16, DCW_ON_CHIP_DRAWER_HIT, 0x0098);
319+CPUMF_EVENT_ATTR(cf_z16, DCW_ON_MODULE, 0x0099);
320+CPUMF_EVENT_ATTR(cf_z16, DCW_ON_DRAWER, 0x009a);
321+CPUMF_EVENT_ATTR(cf_z16, DCW_OFF_DRAWER, 0x009b);
322+CPUMF_EVENT_ATTR(cf_z16, DCW_ON_CHIP_MEMORY, 0x009c);
323+CPUMF_EVENT_ATTR(cf_z16, DCW_ON_MODULE_MEMORY, 0x009d);
324+CPUMF_EVENT_ATTR(cf_z16, DCW_ON_DRAWER_MEMORY, 0x009e);
325+CPUMF_EVENT_ATTR(cf_z16, DCW_OFF_DRAWER_MEMORY, 0x009f);
326+CPUMF_EVENT_ATTR(cf_z16, IDCW_ON_MODULE_IV, 0x00a0);
327+CPUMF_EVENT_ATTR(cf_z16, IDCW_ON_MODULE_CHIP_HIT, 0x00a1);
328+CPUMF_EVENT_ATTR(cf_z16, IDCW_ON_MODULE_DRAWER_HIT, 0x00a2);
329+CPUMF_EVENT_ATTR(cf_z16, IDCW_ON_DRAWER_IV, 0x00a3);
330+CPUMF_EVENT_ATTR(cf_z16, IDCW_ON_DRAWER_CHIP_HIT, 0x00a4);
331+CPUMF_EVENT_ATTR(cf_z16, IDCW_ON_DRAWER_DRAWER_HIT, 0x00a5);
332+CPUMF_EVENT_ATTR(cf_z16, IDCW_OFF_DRAWER_IV, 0x00a6);
333+CPUMF_EVENT_ATTR(cf_z16, IDCW_OFF_DRAWER_CHIP_HIT, 0x00a7);
334+CPUMF_EVENT_ATTR(cf_z16, IDCW_OFF_DRAWER_DRAWER_HIT, 0x00a8);
335+CPUMF_EVENT_ATTR(cf_z16, ICW_REQ, 0x00a9);
336+CPUMF_EVENT_ATTR(cf_z16, ICW_REQ_IV, 0x00aa);
337+CPUMF_EVENT_ATTR(cf_z16, ICW_REQ_CHIP_HIT, 0x00ab);
338+CPUMF_EVENT_ATTR(cf_z16, ICW_REQ_DRAWER_HIT, 0x00ac);
339+CPUMF_EVENT_ATTR(cf_z16, ICW_ON_CHIP, 0x00ad);
340+CPUMF_EVENT_ATTR(cf_z16, ICW_ON_CHIP_IV, 0x00ae);
341+CPUMF_EVENT_ATTR(cf_z16, ICW_ON_CHIP_CHIP_HIT, 0x00af);
342+CPUMF_EVENT_ATTR(cf_z16, ICW_ON_CHIP_DRAWER_HIT, 0x00b0);
343+CPUMF_EVENT_ATTR(cf_z16, ICW_ON_MODULE, 0x00b1);
344+CPUMF_EVENT_ATTR(cf_z16, ICW_ON_DRAWER, 0x00b2);
345+CPUMF_EVENT_ATTR(cf_z16, ICW_OFF_DRAWER, 0x00b3);
346+CPUMF_EVENT_ATTR(cf_z16, ICW_ON_CHIP_MEMORY, 0x00b4);
347+CPUMF_EVENT_ATTR(cf_z16, ICW_ON_MODULE_MEMORY, 0x00b5);
348+CPUMF_EVENT_ATTR(cf_z16, ICW_ON_DRAWER_MEMORY, 0x00b6);
349+CPUMF_EVENT_ATTR(cf_z16, ICW_OFF_DRAWER_MEMORY, 0x00b7);
350+CPUMF_EVENT_ATTR(cf_z16, BCD_DFP_EXECUTION_SLOTS, 0x00e0);
351+CPUMF_EVENT_ATTR(cf_z16, VX_BCD_EXECUTION_SLOTS, 0x00e1);
352+CPUMF_EVENT_ATTR(cf_z16, DECIMAL_INSTRUCTIONS, 0x00e2);
353+CPUMF_EVENT_ATTR(cf_z16, LAST_HOST_TRANSLATIONS, 0x00e8);
354+CPUMF_EVENT_ATTR(cf_z16, TX_NC_TABORT, 0x00f4);
355+CPUMF_EVENT_ATTR(cf_z16, TX_C_TABORT_NO_SPECIAL, 0x00f5);
356+CPUMF_EVENT_ATTR(cf_z16, TX_C_TABORT_SPECIAL, 0x00f6);
357+CPUMF_EVENT_ATTR(cf_z16, DFLT_ACCESS, 0x00f8);
358+CPUMF_EVENT_ATTR(cf_z16, DFLT_CYCLES, 0x00fd);
359+CPUMF_EVENT_ATTR(cf_z16, SORTL, 0x0100);
360+CPUMF_EVENT_ATTR(cf_z16, DFLT_CC, 0x0109);
361+CPUMF_EVENT_ATTR(cf_z16, DFLT_CCFINISH, 0x010a);
362+CPUMF_EVENT_ATTR(cf_z16, NNPA_INVOCATIONS, 0x010b);
363+CPUMF_EVENT_ATTR(cf_z16, NNPA_COMPLETIONS, 0x010c);
364+CPUMF_EVENT_ATTR(cf_z16, NNPA_WAIT_LOCK, 0x010d);
365+CPUMF_EVENT_ATTR(cf_z16, NNPA_HOLD_LOCK, 0x010e);
366+CPUMF_EVENT_ATTR(cf_z16, MT_DIAG_CYCLES_ONE_THR_ACTIVE, 0x01c0);
367+CPUMF_EVENT_ATTR(cf_z16, MT_DIAG_CYCLES_TWO_THR_ACTIVE, 0x01c1);
298368
299369 static struct attribute *cpumcf_fvn1_pmu_event_attr[] __initdata = {
300370 CPUMF_EVENT_PTR(cf_fvn1, CPU_CYCLES),
@@ -635,6 +705,80 @@ static struct attribute *cpumcf_z15_pmu_event_attr[] __initdata = { · 334 unmodified lines
635705 NULL,
636706 };
637707
708+static struct attribute *cpumcf_z16_pmu_event_attr[] __initdata = {
709+ CPUMF_EVENT_PTR(cf_z16, L1D_RO_EXCL_WRITES),
710+ CPUMF_EVENT_PTR(cf_z16, DTLB2_WRITES),
711+ CPUMF_EVENT_PTR(cf_z16, DTLB2_MISSES),
712+ CPUMF_EVENT_PTR(cf_z16, CRSTE_1MB_WRITES),
713+ CPUMF_EVENT_PTR(cf_z16, DTLB2_GPAGE_WRITES),
714+ CPUMF_EVENT_PTR(cf_z16, ITLB2_WRITES),
715+ CPUMF_EVENT_PTR(cf_z16, ITLB2_MISSES),
716+ CPUMF_EVENT_PTR(cf_z16, TLB2_PTE_WRITES),
717+ CPUMF_EVENT_PTR(cf_z16, TLB2_CRSTE_WRITES),
718+ CPUMF_EVENT_PTR(cf_z16, TLB2_ENGINES_BUSY),
719+ CPUMF_EVENT_PTR(cf_z16, TX_C_TEND),
720+ CPUMF_EVENT_PTR(cf_z16, TX_NC_TEND),
721+ CPUMF_EVENT_PTR(cf_z16, L1C_TLB2_MISSES),
722+ CPUMF_EVENT_PTR(cf_z16, DCW_REQ),
723+ CPUMF_EVENT_PTR(cf_z16, DCW_REQ_IV),
724+ CPUMF_EVENT_PTR(cf_z16, DCW_REQ_CHIP_HIT),
725+ CPUMF_EVENT_PTR(cf_z16, DCW_REQ_DRAWER_HIT),
726+ CPUMF_EVENT_PTR(cf_z16, DCW_ON_CHIP),
727+ CPUMF_EVENT_PTR(cf_z16, DCW_ON_CHIP_IV),
728+ CPUMF_EVENT_PTR(cf_z16, DCW_ON_CHIP_CHIP_HIT),
729+ CPUMF_EVENT_PTR(cf_z16, DCW_ON_CHIP_DRAWER_HIT),
730+ CPUMF_EVENT_PTR(cf_z16, DCW_ON_MODULE),
731+ CPUMF_EVENT_PTR(cf_z16, DCW_ON_DRAWER),
732+ CPUMF_EVENT_PTR(cf_z16, DCW_OFF_DRAWER),
733+ CPUMF_EVENT_PTR(cf_z16, DCW_ON_CHIP_MEMORY),
734+ CPUMF_EVENT_PTR(cf_z16, DCW_ON_MODULE_MEMORY),
735+ CPUMF_EVENT_PTR(cf_z16, DCW_ON_DRAWER_MEMORY),
736+ CPUMF_EVENT_PTR(cf_z16, DCW_OFF_DRAWER_MEMORY),
737+ CPUMF_EVENT_PTR(cf_z16, IDCW_ON_MODULE_IV),
738+ CPUMF_EVENT_PTR(cf_z16, IDCW_ON_MODULE_CHIP_HIT),
739+ CPUMF_EVENT_PTR(cf_z16, IDCW_ON_MODULE_DRAWER_HIT),
740+ CPUMF_EVENT_PTR(cf_z16, IDCW_ON_DRAWER_IV),
741+ CPUMF_EVENT_PTR(cf_z16, IDCW_ON_DRAWER_CHIP_HIT),
742+ CPUMF_EVENT_PTR(cf_z16, IDCW_ON_DRAWER_DRAWER_HIT),
743+ CPUMF_EVENT_PTR(cf_z16, IDCW_OFF_DRAWER_IV),
744+ CPUMF_EVENT_PTR(cf_z16, IDCW_OFF_DRAWER_CHIP_HIT),
745+ CPUMF_EVENT_PTR(cf_z16, IDCW_OFF_DRAWER_DRAWER_HIT),
746+ CPUMF_EVENT_PTR(cf_z16, ICW_REQ),
747+ CPUMF_EVENT_PTR(cf_z16, ICW_REQ_IV),
748+ CPUMF_EVENT_PTR(cf_z16, ICW_REQ_CHIP_HIT),
749+ CPUMF_EVENT_PTR(cf_z16, ICW_REQ_DRAWER_HIT),
750+ CPUMF_EVENT_PTR(cf_z16, ICW_ON_CHIP),
751+ CPUMF_EVENT_PTR(cf_z16, ICW_ON_CHIP_IV),
752+ CPUMF_EVENT_PTR(cf_z16, ICW_ON_CHIP_CHIP_HIT),
753+ CPUMF_EVENT_PTR(cf_z16, ICW_ON_CHIP_DRAWER_HIT),
754+ CPUMF_EVENT_PTR(cf_z16, ICW_ON_MODULE),
755+ CPUMF_EVENT_PTR(cf_z16, ICW_ON_DRAWER),
756+ CPUMF_EVENT_PTR(cf_z16, ICW_OFF_DRAWER),
757+ CPUMF_EVENT_PTR(cf_z16, ICW_ON_CHIP_MEMORY),
758+ CPUMF_EVENT_PTR(cf_z16, ICW_ON_MODULE_MEMORY),
759+ CPUMF_EVENT_PTR(cf_z16, ICW_ON_DRAWER_MEMORY),
760+ CPUMF_EVENT_PTR(cf_z16, ICW_OFF_DRAWER_MEMORY),
761+ CPUMF_EVENT_PTR(cf_z16, BCD_DFP_EXECUTION_SLOTS),
762+ CPUMF_EVENT_PTR(cf_z16, VX_BCD_EXECUTION_SLOTS),
763+ CPUMF_EVENT_PTR(cf_z16, DECIMAL_INSTRUCTIONS),
764+ CPUMF_EVENT_PTR(cf_z16, LAST_HOST_TRANSLATIONS),
765+ CPUMF_EVENT_PTR(cf_z16, TX_NC_TABORT),
766+ CPUMF_EVENT_PTR(cf_z16, TX_C_TABORT_NO_SPECIAL),
767+ CPUMF_EVENT_PTR(cf_z16, TX_C_TABORT_SPECIAL),
768+ CPUMF_EVENT_PTR(cf_z16, DFLT_ACCESS),
769+ CPUMF_EVENT_PTR(cf_z16, DFLT_CYCLES),
770+ CPUMF_EVENT_PTR(cf_z16, SORTL),
771+ CPUMF_EVENT_PTR(cf_z16, DFLT_CC),
772+ CPUMF_EVENT_PTR(cf_z16, DFLT_CCFINISH),
773+ CPUMF_EVENT_PTR(cf_z16, NNPA_INVOCATIONS),
774+ CPUMF_EVENT_PTR(cf_z16, NNPA_COMPLETIONS),
775+ CPUMF_EVENT_PTR(cf_z16, NNPA_WAIT_LOCK),
776+ CPUMF_EVENT_PTR(cf_z16, NNPA_HOLD_LOCK),
777+ CPUMF_EVENT_PTR(cf_z16, MT_DIAG_CYCLES_ONE_THR_ACTIVE),
778+ CPUMF_EVENT_PTR(cf_z16, MT_DIAG_CYCLES_TWO_THR_ACTIVE),
779+ NULL,
780+};
781+
638782 /* END: CPUM_CF COUNTER DEFINITIONS ===================================== */
639783
640784 static struct attribute_group cpumcf_pmu_events_group = {
@@ -749,6 +893,10 @@ __init const struct attribute_group **cpumf_cf_event_group(void) · 108 unmodified lines
749893 case 0x8562:
750894 model = cpumcf_z15_pmu_event_attr;
751895 break;
896+ case 0x3931:
897+ case 0x3932:
898+ model = cpumcf_z16_pmu_event_attr;
899+ break;
752900 default:
753901 model = none;
754902 break;
arch/s390/kernel/perf_pai_crypto.c+688−0
@@ -0,0 +1,688 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Performance event support - Processor Activity Instrumentation Facility
4+ *
5+ * Copyright IBM Corp. 2022
6+ * Author(s): Thomas Richter <tmricht@linux.ibm.com>
7+ */
8+#define KMSG_COMPONENT "pai_crypto"
9+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
10+
11+#include <linux/kernel.h>
12+#include <linux/kernel_stat.h>
13+#include <linux/percpu.h>
14+#include <linux/notifier.h>
15+#include <linux/init.h>
16+#include <linux/export.h>
17+#include <linux/io.h>
18+#include <linux/perf_event.h>
19+
20+#include <asm/ctl_reg.h>
21+#include <asm/pai.h>
22+#include <asm/debug.h>
23+
24+static debug_info_t *cfm_dbg;
25+static unsigned int paicrypt_cnt; /* Size of the mapped counter sets */
26+ /* extracted with QPACI instruction */
27+
28+DEFINE_STATIC_KEY_FALSE(pai_key);
29+
30+struct pai_userdata {
31+ u16 num;
32+ u64 value;
33+} __packed;
34+
35+struct paicrypt_map {
36+ unsigned long *page; /* Page for CPU to store counters */
37+ struct pai_userdata *save; /* Page to store no-zero counters */
38+ unsigned int users; /* # of PAI crypto users */
39+ unsigned int sampler; /* # of PAI crypto samplers */
40+ unsigned int counter; /* # of PAI crypto counters */
41+ struct perf_event *event; /* Perf event for sampling */
42+};
43+
44+static DEFINE_PER_CPU(struct paicrypt_map, paicrypt_map);
45+
46+/* Release the PMU if event is the last perf event */
47+static DEFINE_MUTEX(pai_reserve_mutex);
48+
49+/* Adjust usage counters and remove allocated memory when all users are
50+ * gone.
51+ */
52+static void paicrypt_event_destroy(struct perf_event *event)
53+{
54+ struct paicrypt_map *cpump = per_cpu_ptr(&paicrypt_map, event->cpu);
55+
56+ cpump->event = NULL;
57+ static_branch_dec(&pai_key);
58+ mutex_lock(&pai_reserve_mutex);
59+ if (event->attr.sample_period)
60+ cpump->sampler -= 1;
61+ else
62+ cpump->counter -= 1;
63+ debug_sprintf_event(cfm_dbg, 5, "%s event %#llx cpu %d"
64+ " sampler %d counter %d\n", __func__,
65+ event->attr.config, event->cpu, cpump->sampler,
66+ cpump->counter);
67+ if (!cpump->counter && !cpump->sampler) {
68+ debug_sprintf_event(cfm_dbg, 4, "%s page %#lx save %p\n",
69+ __func__, (unsigned long)cpump->page,
70+ cpump->save);
71+ free_page((unsigned long)cpump->page);
72+ cpump->page = NULL;
73+ kvfree(cpump->save);
74+ cpump->save = NULL;
75+ }
76+ mutex_unlock(&pai_reserve_mutex);
77+}
78+
79+static u64 paicrypt_getctr(struct paicrypt_map *cpump, int nr, bool kernel)
80+{
81+ if (kernel)
82+ nr += PAI_CRYPTO_MAXCTR;
83+ return cpump->page[nr];
84+}
85+
86+/* Read the counter values. Return value from location in CMP. For event
87+ * CRYPTO_ALL sum up all events.
88+ */
89+static u64 paicrypt_getdata(struct perf_event *event, bool kernel)
90+{
91+ struct paicrypt_map *cpump = this_cpu_ptr(&paicrypt_map);
92+ u64 sum = 0;
93+ int i;
94+
95+ if (event->attr.config != PAI_CRYPTO_BASE) {
96+ return paicrypt_getctr(cpump,
97+ event->attr.config - PAI_CRYPTO_BASE,
98+ kernel);
99+ }
100+
101+ for (i = 1; i <= paicrypt_cnt; i++) {
102+ u64 val = paicrypt_getctr(cpump, i, kernel);
103+
104+ if (!val)
105+ continue;
106+ sum += val;
107+ }
108+ return sum;
109+}
110+
111+static u64 paicrypt_getall(struct perf_event *event)
112+{
113+ u64 sum = 0;
114+
115+ if (!event->attr.exclude_kernel)
116+ sum += paicrypt_getdata(event, true);
117+ if (!event->attr.exclude_user)
118+ sum += paicrypt_getdata(event, false);
119+
120+ return sum;
121+}
122+
123+/* Used to avoid races in checking concurrent access of counting and
124+ * sampling for crypto events
125+ *
126+ * Only one instance of event pai_crypto/CRYPTO_ALL/ for sampling is
127+ * allowed and when this event is running, no counting event is allowed.
128+ * Several counting events are allowed in parallel, but no sampling event
129+ * is allowed while one (or more) counting events are running.
130+ *
131+ * This function is called in process context and it is save to block.
132+ * When the event initialization functions fails, no other call back will
133+ * be invoked.
134+ *
135+ * Allocate the memory for the event.
136+ */
137+static int paicrypt_busy(struct perf_event_attr *a, struct paicrypt_map *cpump)
138+{
139+ unsigned int *use_ptr;
140+ int rc = 0;
141+
142+ mutex_lock(&pai_reserve_mutex);
143+ if (a->sample_period) { /* Sampling requested */
144+ use_ptr = &cpump->sampler;
145+ if (cpump->counter || cpump->sampler)
146+ rc = -EBUSY; /* ... sampling/counting active */
147+ } else { /* Counting requested */
148+ use_ptr = &cpump->counter;
149+ if (cpump->sampler)
150+ rc = -EBUSY; /* ... and sampling active */
151+ }
152+ if (rc)
153+ goto unlock;
154+
155+ /* Allocate memory for counter page and counter extraction.
156+ * Only the first counting event has to allocate a page.
157+ */
158+ if (cpump->page)
159+ goto unlock;
160+
161+ rc = -ENOMEM;
162+ cpump->page = (unsigned long *)get_zeroed_page(GFP_KERNEL);
163+ if (!cpump->page)
164+ goto unlock;
165+ cpump->save = kvmalloc_array(paicrypt_cnt + 1,
166+ sizeof(struct pai_userdata), GFP_KERNEL);
167+ if (!cpump->save) {
168+ free_page((unsigned long)cpump->page);
169+ cpump->page = NULL;
170+ goto unlock;
171+ }
172+ rc = 0;
173+
174+unlock:
175+ /* If rc is non-zero, do not increment counter/sampler. */
176+ if (!rc)
177+ *use_ptr += 1;
178+ debug_sprintf_event(cfm_dbg, 5, "%s sample_period %#llx sampler %d"
179+ " counter %d page %#lx save %p rc %d\n", __func__,
180+ a->sample_period, cpump->sampler, cpump->counter,
181+ (unsigned long)cpump->page, cpump->save, rc);
182+ mutex_unlock(&pai_reserve_mutex);
183+ return rc;
184+}
185+
186+/* Might be called on different CPU than the one the event is intended for. */
187+static int paicrypt_event_init(struct perf_event *event)
188+{
189+ struct perf_event_attr *a = &event->attr;
190+ struct paicrypt_map *cpump;
191+ int rc;
192+
193+ /* PAI crypto PMU registered as PERF_TYPE_RAW, check event type */
194+ if (a->type != PERF_TYPE_RAW && event->pmu->type != a->type)
195+ return -ENOENT;
196+ /* PAI crypto event must be valid */
197+ if (a->config > PAI_CRYPTO_BASE + paicrypt_cnt)
198+ return -EINVAL;
199+ /* Allow only CPU wide operation, no process context for now. */
200+ if (event->hw.target || event->cpu == -1)
201+ return -ENOENT;
202+ /* Allow only CRYPTO_ALL for sampling. */
203+ if (a->sample_period && a->config != PAI_CRYPTO_BASE)
204+ return -EINVAL;
205+
206+ cpump = per_cpu_ptr(&paicrypt_map, event->cpu);
207+ rc = paicrypt_busy(a, cpump);
208+ if (rc)
209+ return rc;
210+
211+ cpump->event = event;
212+ event->destroy = paicrypt_event_destroy;
213+
214+ if (a->sample_period) {
215+ a->sample_period = 1;
216+ a->freq = 0;
217+ /* Register for paicrypt_sched_task() to be called */
218+ event->attach_state |= PERF_ATTACH_SCHED_CB;
219+ /* Add raw data which contain the memory mapped counters */
220+ a->sample_type |= PERF_SAMPLE_RAW;
221+ /* Turn off inheritance */
222+ a->inherit = 0;
223+ }
224+
225+ static_branch_inc(&pai_key);
226+ return 0;
227+}
228+
229+static void paicrypt_read(struct perf_event *event)
230+{
231+ u64 prev, new, delta;
232+
233+ prev = local64_read(&event->hw.prev_count);
234+ new = paicrypt_getall(event);
235+ local64_set(&event->hw.prev_count, new);
236+ delta = (prev <= new) ? new - prev
237+ : (-1ULL - prev) + new + 1; /* overflow */
238+ local64_add(delta, &event->count);
239+}
240+
241+static void paicrypt_start(struct perf_event *event, int flags)
242+{
243+ u64 sum;
244+
245+ sum = paicrypt_getall(event); /* Get current value */
246+ local64_set(&event->hw.prev_count, sum);
247+ local64_set(&event->count, 0);
248+}
249+
250+static int paicrypt_add(struct perf_event *event, int flags)
251+{
252+ struct paicrypt_map *cpump = this_cpu_ptr(&paicrypt_map);
253+ unsigned long ccd;
254+
255+ if (cpump->users++ == 0) {
256+ ccd = virt_to_phys(cpump->page) | PAI_CRYPTO_KERNEL_OFFSET;
257+ WRITE_ONCE(S390_lowcore.ccd, ccd);
258+ __ctl_set_bit(0, 50);
259+ }
260+ cpump->event = event;
261+ if (flags & PERF_EF_START && !event->attr.sample_period) {
262+ /* Only counting needs initial counter value */
263+ paicrypt_start(event, PERF_EF_RELOAD);
264+ }
265+ event->hw.state = 0;
266+ if (event->attr.sample_period)
267+ perf_sched_cb_inc(event->pmu);
268+ return 0;
269+}
270+
271+static void paicrypt_stop(struct perf_event *event, int flags)
272+{
273+ paicrypt_read(event);
274+ event->hw.state = PERF_HES_STOPPED;
275+}
276+
277+static void paicrypt_del(struct perf_event *event, int flags)
278+{
279+ struct paicrypt_map *cpump = this_cpu_ptr(&paicrypt_map);
280+
281+ if (event->attr.sample_period)
282+ perf_sched_cb_dec(event->pmu);
283+ if (!event->attr.sample_period)
284+ /* Only counting needs to read counter */
285+ paicrypt_stop(event, PERF_EF_UPDATE);
286+ if (cpump->users-- == 1) {
287+ __ctl_clear_bit(0, 50);
288+ WRITE_ONCE(S390_lowcore.ccd, 0);
289+ }
290+}
291+
292+/* Create raw data and save it in buffer. Returns number of bytes copied.
293+ * Saves only positive counter entries of the form
294+ * 2 bytes: Number of counter
295+ * 8 bytes: Value of counter
296+ */
297+static size_t paicrypt_copy(struct pai_userdata *userdata,
298+ struct paicrypt_map *cpump,
299+ bool exclude_user, bool exclude_kernel)
300+{
301+ int i, outidx = 0;
302+
303+ for (i = 1; i <= paicrypt_cnt; i++) {
304+ u64 val = 0;
305+
306+ if (!exclude_kernel)
307+ val += paicrypt_getctr(cpump, i, true);
308+ if (!exclude_user)
309+ val += paicrypt_getctr(cpump, i, false);
310+ if (val) {
311+ userdata[outidx].num = i;
312+ userdata[outidx].value = val;
313+ outidx++;
314+ }
315+ }
316+ return outidx * sizeof(struct pai_userdata);
317+}
318+
319+static int paicrypt_push_sample(void)
320+{
321+ struct paicrypt_map *cpump = this_cpu_ptr(&paicrypt_map);
322+ struct perf_event *event = cpump->event;
323+ struct perf_sample_data data;
324+ struct perf_raw_record raw;
325+ struct pt_regs regs;
326+ size_t rawsize;
327+ int overflow;
328+
329+ if (!cpump->event) /* No event active */
330+ return 0;
331+ rawsize = paicrypt_copy(cpump->save, cpump,
332+ cpump->event->attr.exclude_user,
333+ cpump->event->attr.exclude_kernel);
334+ if (!rawsize) /* No incremented counters */
335+ return 0;
336+
337+ /* Setup perf sample */
338+ memset(&regs, 0, sizeof(regs));
339+ memset(&raw, 0, sizeof(raw));
340+ memset(&data, 0, sizeof(data));
341+ perf_sample_data_init(&data, 0, event->hw.last_period);
342+ if (event->attr.sample_type & PERF_SAMPLE_TID) {
343+ data.tid_entry.pid = task_tgid_nr(current);
344+ data.tid_entry.tid = task_pid_nr(current);
345+ }
346+ if (event->attr.sample_type & PERF_SAMPLE_TIME)
347+ data.time = event->clock();
348+ if (event->attr.sample_type & (PERF_SAMPLE_ID | PERF_SAMPLE_IDENTIFIER))
349+ data.id = event->id;
350+ if (event->attr.sample_type & PERF_SAMPLE_CPU) {
351+ data.cpu_entry.cpu = smp_processor_id();
352+ data.cpu_entry.reserved = 0;
353+ }
354+ if (event->attr.sample_type & PERF_SAMPLE_RAW) {
355+ raw.frag.size = rawsize;
356+ raw.frag.data = cpump->save;
357+ raw.size = raw.frag.size;
358+ data.raw = &raw;
359+ }
360+
361+ overflow = perf_event_overflow(event, &data, &regs);
362+ perf_event_update_userpage(event);
363+ /* Clear lowcore page after read */
364+ memset(cpump->page, 0, PAGE_SIZE);
365+ return overflow;
366+}
367+
368+/* Called on schedule-in and schedule-out. No access to event structure,
369+ * but for sampling only event CRYPTO_ALL is allowed.
370+ */
371+static void paicrypt_sched_task(struct perf_event_context *ctx, bool sched_in)
372+{
373+ /* We started with a clean page on event installation. So read out
374+ * results on schedule_out and if page was dirty, clear values.
375+ */
376+ if (!sched_in)
377+ paicrypt_push_sample();
378+}
379+
380+/* Attribute definitions for paicrypt interface. As with other CPU
381+ * Measurement Facilities, there is one attribute per mapped counter.
382+ * The number of mapped counters may vary per machine generation. Use
383+ * the QUERY PROCESSOR ACTIVITY COUNTER INFORMATION (QPACI) instruction
384+ * to determine the number of mapped counters. The instructions returns
385+ * a positive number, which is the highest number of supported counters.
386+ * All counters less than this number are also supported, there are no
387+ * holes. A returned number of zero means no support for mapped counters.
388+ *
389+ * The identification of the counter is a unique number. The chosen range
390+ * is 0x1000 + offset in mapped kernel page.
391+ * All CPU Measurement Facility counters identifiers must be unique and
392+ * the numbers from 0 to 496 are already used for the CPU Measurement
393+ * Counter facility. Numbers 0xb0000, 0xbc000 and 0xbd000 are already
394+ * used for the CPU Measurement Sampling facility.
395+ */
396+PMU_FORMAT_ATTR(event, "config:0-63");
397+
398+static struct attribute *paicrypt_format_attr[] = {
399+ &format_attr_event.attr,
400+ NULL,
401+};
402+
403+static struct attribute_group paicrypt_events_group = {
404+ .name = "events",
405+ .attrs = NULL /* Filled in attr_event_init() */
406+};
407+
408+static struct attribute_group paicrypt_format_group = {
409+ .name = "format",
410+ .attrs = paicrypt_format_attr,
411+};
412+
413+static const struct attribute_group *paicrypt_attr_groups[] = {
414+ &paicrypt_events_group,
415+ &paicrypt_format_group,
416+ NULL,
417+};
418+
419+/* Performance monitoring unit for mapped counters */
420+static struct pmu paicrypt = {
421+ .task_ctx_nr = perf_invalid_context,
422+ .event_init = paicrypt_event_init,
423+ .add = paicrypt_add,
424+ .del = paicrypt_del,
425+ .start = paicrypt_start,
426+ .stop = paicrypt_stop,
427+ .read = paicrypt_read,
428+ .sched_task = paicrypt_sched_task,
429+ .attr_groups = paicrypt_attr_groups
430+};
431+
432+/* List of symbolic PAI counter names. */
433+static const char * const paicrypt_ctrnames[] = {
434+ [0] = "CRYPTO_ALL",
435+ [1] = "KM_DEA",
436+ [2] = "KM_TDEA_128",
437+ [3] = "KM_TDEA_192",
438+ [4] = "KM_ENCRYPTED_DEA",
439+ [5] = "KM_ENCRYPTED_TDEA_128",
440+ [6] = "KM_ENCRYPTED_TDEA_192",
441+ [7] = "KM_AES_128",
442+ [8] = "KM_AES_192",
443+ [9] = "KM_AES_256",
444+ [10] = "KM_ENCRYPTED_AES_128",
445+ [11] = "KM_ENCRYPTED_AES_192",
446+ [12] = "KM_ENCRYPTED_AES_256",
447+ [13] = "KM_XTS_AES_128",
448+ [14] = "KM_XTS_AES_256",
449+ [15] = "KM_XTS_ENCRYPTED_AES_128",
450+ [16] = "KM_XTS_ENCRYPTED_AES_256",
451+ [17] = "KMC_DEA",
452+ [18] = "KMC_TDEA_128",
453+ [19] = "KMC_TDEA_192",
454+ [20] = "KMC_ENCRYPTED_DEA",
455+ [21] = "KMC_ENCRYPTED_TDEA_128",
456+ [22] = "KMC_ENCRYPTED_TDEA_192",
457+ [23] = "KMC_AES_128",
458+ [24] = "KMC_AES_192",
459+ [25] = "KMC_AES_256",
460+ [26] = "KMC_ENCRYPTED_AES_128",
461+ [27] = "KMC_ENCRYPTED_AES_192",
462+ [28] = "KMC_ENCRYPTED_AES_256",
463+ [29] = "KMC_PRNG",
464+ [30] = "KMA_GCM_AES_128",
465+ [31] = "KMA_GCM_AES_192",
466+ [32] = "KMA_GCM_AES_256",
467+ [33] = "KMA_GCM_ENCRYPTED_AES_128",
468+ [34] = "KMA_GCM_ENCRYPTED_AES_192",
469+ [35] = "KMA_GCM_ENCRYPTED_AES_256",
470+ [36] = "KMF_DEA",
471+ [37] = "KMF_TDEA_128",
472+ [38] = "KMF_TDEA_192",
473+ [39] = "KMF_ENCRYPTED_DEA",
474+ [40] = "KMF_ENCRYPTED_TDEA_128",
475+ [41] = "KMF_ENCRYPTED_TDEA_192",
476+ [42] = "KMF_AES_128",
477+ [43] = "KMF_AES_192",
478+ [44] = "KMF_AES_256",
479+ [45] = "KMF_ENCRYPTED_AES_128",
480+ [46] = "KMF_ENCRYPTED_AES_192",
481+ [47] = "KMF_ENCRYPTED_AES_256",
482+ [48] = "KMCTR_DEA",
483+ [49] = "KMCTR_TDEA_128",
484+ [50] = "KMCTR_TDEA_192",
485+ [51] = "KMCTR_ENCRYPTED_DEA",
486+ [52] = "KMCTR_ENCRYPTED_TDEA_128",
487+ [53] = "KMCTR_ENCRYPTED_TDEA_192",
488+ [54] = "KMCTR_AES_128",
489+ [55] = "KMCTR_AES_192",
490+ [56] = "KMCTR_AES_256",
491+ [57] = "KMCTR_ENCRYPTED_AES_128",
492+ [58] = "KMCTR_ENCRYPTED_AES_192",
493+ [59] = "KMCTR_ENCRYPTED_AES_256",
494+ [60] = "KMO_DEA",
495+ [61] = "KMO_TDEA_128",
496+ [62] = "KMO_TDEA_192",
497+ [63] = "KMO_ENCRYPTED_DEA",
498+ [64] = "KMO_ENCRYPTED_TDEA_128",
499+ [65] = "KMO_ENCRYPTED_TDEA_192",
500+ [66] = "KMO_AES_128",
501+ [67] = "KMO_AES_192",
502+ [68] = "KMO_AES_256",
503+ [69] = "KMO_ENCRYPTED_AES_128",
504+ [70] = "KMO_ENCRYPTED_AES_192",
505+ [71] = "KMO_ENCRYPTED_AES_256",
506+ [72] = "KIMD_SHA_1",
507+ [73] = "KIMD_SHA_256",
508+ [74] = "KIMD_SHA_512",
509+ [75] = "KIMD_SHA3_224",
510+ [76] = "KIMD_SHA3_256",
511+ [77] = "KIMD_SHA3_384",
512+ [78] = "KIMD_SHA3_512",
513+ [79] = "KIMD_SHAKE_128",
514+ [80] = "KIMD_SHAKE_256",
515+ [81] = "KIMD_GHASH",
516+ [82] = "KLMD_SHA_1",
517+ [83] = "KLMD_SHA_256",
518+ [84] = "KLMD_SHA_512",
519+ [85] = "KLMD_SHA3_224",
520+ [86] = "KLMD_SHA3_256",
521+ [87] = "KLMD_SHA3_384",
522+ [88] = "KLMD_SHA3_512",
523+ [89] = "KLMD_SHAKE_128",
524+ [90] = "KLMD_SHAKE_256",
525+ [91] = "KMAC_DEA",
526+ [92] = "KMAC_TDEA_128",
527+ [93] = "KMAC_TDEA_192",
528+ [94] = "KMAC_ENCRYPTED_DEA",
529+ [95] = "KMAC_ENCRYPTED_TDEA_128",
530+ [96] = "KMAC_ENCRYPTED_TDEA_192",
531+ [97] = "KMAC_AES_128",
532+ [98] = "KMAC_AES_192",
533+ [99] = "KMAC_AES_256",
534+ [100] = "KMAC_ENCRYPTED_AES_128",
535+ [101] = "KMAC_ENCRYPTED_AES_192",
536+ [102] = "KMAC_ENCRYPTED_AES_256",
537+ [103] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_DEA",
538+ [104] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_TDEA_128",
539+ [105] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_TDEA_192",
540+ [106] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_ENCRYPTED_DEA",
541+ [107] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_ENCRYPTED_TDEA_128",
542+ [108] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_ENCRYPTED_TDEA_192",
543+ [109] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_AES_128",
544+ [110] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_AES_192",
545+ [111] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_AES_256",
546+ [112] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_ENCRYPTED_AES_128",
547+ [113] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_ENCRYPTED_AES_192",
548+ [114] = "PCC_COMPUTE_LAST_BLOCK_CMAC_USING_ENCRYPTED_AES_256A",
549+ [115] = "PCC_COMPUTE_XTS_PARAMETER_USING_AES_128",
550+ [116] = "PCC_COMPUTE_XTS_PARAMETER_USING_AES_256",
551+ [117] = "PCC_COMPUTE_XTS_PARAMETER_USING_ENCRYPTED_AES_128",
552+ [118] = "PCC_COMPUTE_XTS_PARAMETER_USING_ENCRYPTED_AES_256",
553+ [119] = "PCC_SCALAR_MULTIPLY_P256",
554+ [120] = "PCC_SCALAR_MULTIPLY_P384",
555+ [121] = "PCC_SCALAR_MULTIPLY_P521",
556+ [122] = "PCC_SCALAR_MULTIPLY_ED25519",
557+ [123] = "PCC_SCALAR_MULTIPLY_ED448",
558+ [124] = "PCC_SCALAR_MULTIPLY_X25519",
559+ [125] = "PCC_SCALAR_MULTIPLY_X448",
560+ [126] = "PRNO_SHA_512_DRNG",
561+ [127] = "PRNO_TRNG_QUERY_RAW_TO_CONDITIONED_RATIO",
562+ [128] = "PRNO_TRNG",
563+ [129] = "KDSA_ECDSA_VERIFY_P256",
564+ [130] = "KDSA_ECDSA_VERIFY_P384",
565+ [131] = "KDSA_ECDSA_VERIFY_P521",
566+ [132] = "KDSA_ECDSA_SIGN_P256",
567+ [133] = "KDSA_ECDSA_SIGN_P384",
568+ [134] = "KDSA_ECDSA_SIGN_P521",
569+ [135] = "KDSA_ENCRYPTED_ECDSA_SIGN_P256",
570+ [136] = "KDSA_ENCRYPTED_ECDSA_SIGN_P384",
571+ [137] = "KDSA_ENCRYPTED_ECDSA_SIGN_P521",
572+ [138] = "KDSA_EDDSA_VERIFY_ED25519",
573+ [139] = "KDSA_EDDSA_VERIFY_ED448",
574+ [140] = "KDSA_EDDSA_SIGN_ED25519",
575+ [141] = "KDSA_EDDSA_SIGN_ED448",
576+ [142] = "KDSA_ENCRYPTED_EDDSA_SIGN_ED25519",
577+ [143] = "KDSA_ENCRYPTED_EDDSA_SIGN_ED448",
578+ [144] = "PCKMO_ENCRYPT_DEA_KEY",
579+ [145] = "PCKMO_ENCRYPT_TDEA_128_KEY",
580+ [146] = "PCKMO_ENCRYPT_TDEA_192_KEY",
581+ [147] = "PCKMO_ENCRYPT_AES_128_KEY",
582+ [148] = "PCKMO_ENCRYPT_AES_192_KEY",
583+ [149] = "PCKMO_ENCRYPT_AES_256_KEY",
584+ [150] = "PCKMO_ENCRYPT_ECC_P256_KEY",
585+ [151] = "PCKMO_ENCRYPT_ECC_P384_KEY",
586+ [152] = "PCKMO_ENCRYPT_ECC_P521_KEY",
587+ [153] = "PCKMO_ENCRYPT_ECC_ED25519_KEY",
588+ [154] = "PCKMO_ENCRYPT_ECC_ED448_KEY",
589+ [155] = "IBM_RESERVED_155",
590+ [156] = "IBM_RESERVED_156",
591+};
592+
593+static void __init attr_event_free(struct attribute **attrs, int num)
594+{
595+ struct perf_pmu_events_attr *pa;
596+ int i;
597+
598+ for (i = 0; i < num; i++) {
599+ struct device_attribute *dap;
600+
601+ dap = container_of(attrs[i], struct device_attribute, attr);
602+ pa = container_of(dap, struct perf_pmu_events_attr, attr);
603+ kfree(pa);
604+ }
605+ kfree(attrs);
606+}
607+
608+static int __init attr_event_init_one(struct attribute **attrs, int num)
609+{
610+ struct perf_pmu_events_attr *pa;
611+
612+ pa = kzalloc(sizeof(*pa), GFP_KERNEL);
613+ if (!pa)
614+ return -ENOMEM;
615+
616+ sysfs_attr_init(&pa->attr.attr);
617+ pa->id = PAI_CRYPTO_BASE + num;
618+ pa->attr.attr.name = paicrypt_ctrnames[num];
619+ pa->attr.attr.mode = 0444;
620+ pa->attr.show = cpumf_events_sysfs_show;
621+ pa->attr.store = NULL;
622+ attrs[num] = &pa->attr.attr;
623+ return 0;
624+}
625+
626+/* Create PMU sysfs event attributes on the fly. */
627+static int __init attr_event_init(void)
628+{
629+ struct attribute **attrs;
630+ int ret, i;
631+
632+ attrs = kmalloc_array(ARRAY_SIZE(paicrypt_ctrnames) + 1, sizeof(*attrs),
633+ GFP_KERNEL);
634+ if (!attrs)
635+ return -ENOMEM;
636+ for (i = 0; i < ARRAY_SIZE(paicrypt_ctrnames); i++) {
637+ ret = attr_event_init_one(attrs, i);
638+ if (ret) {
639+ attr_event_free(attrs, i - 1);
640+ return ret;
641+ }
642+ }
643+ attrs[i] = NULL;
644+ paicrypt_events_group.attrs = attrs;
645+ return 0;
646+}
647+
648+static int __init paicrypt_init(void)
649+{
650+ struct qpaci_info_block ib;
651+ int rc;
652+
653+ if (!test_facility(196))
654+ return 0;
655+
656+ qpaci(&ib);
657+ paicrypt_cnt = ib.num_cc;
658+ if (paicrypt_cnt == 0)
659+ return 0;
660+ if (paicrypt_cnt >= PAI_CRYPTO_MAXCTR)
661+ paicrypt_cnt = PAI_CRYPTO_MAXCTR - 1;
662+
663+ rc = attr_event_init(); /* Export known PAI crypto events */
664+ if (rc) {
665+ pr_err("Creation of PMU pai_crypto /sysfs failed\n");
666+ return rc;
667+ }
668+
669+ /* Setup s390dbf facility */
670+ cfm_dbg = debug_register(KMSG_COMPONENT, 2, 256, 128);
671+ if (!cfm_dbg) {
672+ pr_err("Registration of s390dbf pai_crypto failed\n");
673+ return -ENOMEM;
674+ }
675+ debug_register_view(cfm_dbg, &debug_sprintf_view);
676+
677+ rc = perf_pmu_register(&paicrypt, "pai_crypto", -1);
678+ if (rc) {
679+ pr_err("Registering the pai_crypto PMU failed with rc=%i\n",
680+ rc);
681+ debug_unregister_view(cfm_dbg, &debug_sprintf_view);
682+ debug_unregister(cfm_dbg);
683+ return rc;
684+ }
685+ return 0;
686+}
687+
688+device_initcall(paicrypt_init);
arch/s390/kernel/relocate_kernel.S+2−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 * moves the new kernel to its destination...
1515 * %r2 = pointer to first kimage_entry_t
1616 * %r3 = start address - where to jump to after the job is done...
17+ * %r4 = subcode
1718 *
1819 * %r5 will be used as temp. storage
1920 * %r6 holds the destination address
@@ -56,7 +57,7 @@ ENTRY(relocate_kernel) · 36 unmodified lines
5657 jo 0b
5758 j .base
5859 .done:
59− sgr %r0,%r0 # clear register r0
60+ lgr %r0,%r4 # subcode
6061 cghi %r3,0
6162 je .diag
6263 la %r4,load_psw-.base(%r13) # load psw-address into the register
arch/s390/kernel/setup.c+1−1
@@ -494,7 +494,7 @@ static void __init setup_lowcore_dat_off(void) · 493 unmodified lines
494494 lc->return_mcck_lpswe = gen_lpswe(__LC_RETURN_MCCK_PSW);
495495 lc->preempt_count = PREEMPT_DISABLED;
496496
497− set_prefix((u32)(unsigned long) lc);
497+ set_prefix(__pa(lc));
498498 lowcore_ptr[0] = lc;
499499 }
500500
arch/s390/kernel/time.c+5−7
@@ -364,7 +364,7 @@ static inline int check_sync_clock(void) · 363 unmodified lines
364364 * Apply clock delta to the global data structures.
365365 * This is called once on the CPU that performed the clock sync.
366366 */
367−static void clock_sync_global(unsigned long delta)
367+static void clock_sync_global(long delta)
368368 {
369369 unsigned long now, adj;
370370 struct ptff_qto qto;
@@ -400,7 +400,7 @@ static void clock_sync_global(unsigned long delta) · 29 unmodified lines
400400 * Apply clock delta to the per-CPU data structures of this CPU.
401401 * This is called for each online CPU after the call to clock_sync_global.
402402 */
403−static void clock_sync_local(unsigned long delta)
403+static void clock_sync_local(long delta)
404404 {
405405 /* Add the delta to the clock comparator. */
406406 if (S390_lowcore.clock_comparator != clock_comparator_max) {
@@ -424,7 +424,7 @@ static void __init time_init_wq(void) · 17 unmodified lines
424424 struct clock_sync_data {
425425 atomic_t cpus;
426426 int in_sync;
427− unsigned long clock_delta;
427+ long clock_delta;
428428 };
429429
430430 /*
@@ -544,7 +544,7 @@ static int stpinfo_valid(void) · 113 unmodified lines
544544 static int stp_sync_clock(void *data)
545545 {
546546 struct clock_sync_data *sync = data;
547− u64 clock_delta, flags;
547+ long clock_delta, flags;
548548 static int first;
549549 int rc;
550550
@@ -554,9 +554,7 @@ static int stp_sync_clock(void *data) · 3 unmodified lines
554554 while (atomic_read(&sync->cpus) != 0)
555555 cpu_relax();
556556 rc = 0;
557− if (stp_info.todoff[0] || stp_info.todoff[1] ||
558− stp_info.todoff[2] || stp_info.todoff[3] ||
559− stp_info.tmd != 2) {
557+ if (stp_info.todoff || stp_info.tmd != 2) {
560558 flags = vdso_update_begin();
561559 rc = chsc_sstpc(stp_page, STP_OP_SYNC, 0,
562560 &clock_delta);
arch/s390/kernel/vdso.c+50−5
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <linux/slab.h>
1717 #include <linux/smp.h>
1818 #include <linux/time_namespace.h>
19+#include <linux/random.h>
1920 #include <vdso/datapage.h>
2021 #include <asm/vdso.h>
2122
@@ -160,10 +161,9 @@ int vdso_getcpu_init(void) · 138 unmodified lines
160161 }
161162 early_initcall(vdso_getcpu_init); /* Must be called before SMP init */
162163
163−int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
164+static int map_vdso(unsigned long addr, unsigned long vdso_mapping_len)
164165 {
165− unsigned long vdso_text_len, vdso_mapping_len;
166− unsigned long vvar_start, vdso_text_start;
166+ unsigned long vvar_start, vdso_text_start, vdso_text_len;
167167 struct vm_special_mapping *vdso_mapping;
168168 struct mm_struct *mm = current->mm;
169169 struct vm_area_struct *vma;
@@ -180,8 +180,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) · 10 unmodified lines
180180 vdso_text_len = vdso64_end - vdso64_start;
181181 vdso_mapping = &vdso64_mapping;
182182 }
183− vdso_mapping_len = vdso_text_len + VVAR_NR_PAGES * PAGE_SIZE;
184− vvar_start = get_unmapped_area(NULL, 0, vdso_mapping_len, 0, 0);
183+ vvar_start = get_unmapped_area(NULL, addr, vdso_mapping_len, 0, 0);
185184 rc = vvar_start;
186185 if (IS_ERR_VALUE(vvar_start))
187186 goto out;
@@ -210,6 +209,52 @@ out: · 22 unmodified lines
210209 return rc;
211210 }
212211
212+static unsigned long vdso_addr(unsigned long start, unsigned long len)
213+{
214+ unsigned long addr, end, offset;
215+
216+ /*
217+ * Round up the start address. It can start out unaligned as a result
218+ * of stack start randomization.
219+ */
220+ start = PAGE_ALIGN(start);
221+
222+ /* Round the lowest possible end address up to a PMD boundary. */
223+ end = (start + len + PMD_SIZE - 1) & PMD_MASK;
224+ if (end >= VDSO_BASE)
225+ end = VDSO_BASE;
226+ end -= len;
227+
228+ if (end > start) {
229+ offset = get_random_int() % (((end - start) >> PAGE_SHIFT) + 1);
230+ addr = start + (offset << PAGE_SHIFT);
231+ } else {
232+ addr = start;
233+ }
234+ return addr;
235+}
236+
237+unsigned long vdso_size(void)
238+{
239+ unsigned long size = VVAR_NR_PAGES * PAGE_SIZE;
240+
241+ if (is_compat_task())
242+ size += vdso32_end - vdso32_start;
243+ else
244+ size += vdso64_end - vdso64_start;
245+ return PAGE_ALIGN(size);
246+}
247+
248+int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
249+{
250+ unsigned long addr = VDSO_BASE;
251+ unsigned long size = vdso_size();
252+
253+ if (current->flags & PF_RANDOMIZE)
254+ addr = vdso_addr(current->mm->start_stack + PAGE_SIZE, size);
255+ return map_vdso(addr, size);
256+}
257+
213258 static struct page ** __init vdso_setup_pages(void *start, void *end)
214259 {
215260 int pages = (end - start) >> PAGE_SHIFT;
arch/s390/kvm/priv.c+0−1
@@ -11,7 +11,6 @@ · 10 unmodified lines
1111 #include <linux/kvm.h>
1212 #include <linux/gfp.h>
1313 #include <linux/errno.h>
14−#include <linux/compat.h>
1514 #include <linux/mm_types.h>
1615 #include <linux/pgtable.h>
1716
arch/s390/lib/spinlock.c+2−2
@@ -75,7 +75,7 @@ static inline int arch_load_niai4(int *lock) · 74 unmodified lines
7575 int owner;
7676
7777 asm_inline volatile(
78− ALTERNATIVE("", ".insn rre,0xb2fa0000,4,0", 49) /* NIAI 4 */
78+ ALTERNATIVE("nop", ".insn rre,0xb2fa0000,4,0", 49) /* NIAI 4 */
7979 " l %0,%1\n"
8080 : "=d" (owner) : "Q" (*lock) : "memory");
8181 return owner;
@@ -86,7 +86,7 @@ static inline int arch_cmpxchg_niai8(int *lock, int old, int new) · 4 unmodified lines
8686 int expected = old;
8787
8888 asm_inline volatile(
89− ALTERNATIVE("", ".insn rre,0xb2fa0000,8,0", 49) /* NIAI 8 */
89+ ALTERNATIVE("nop", ".insn rre,0xb2fa0000,8,0", 49) /* NIAI 8 */
9090 " cs %0,%3,%1\n"
9191 : "=d" (old), "=Q" (*lock)
9292 : "0" (old), "d" (new), "Q" (*lock)
arch/s390/mm/mmap.c+2−2
@@ -58,9 +58,9 @@ static inline unsigned long mmap_base(unsigned long rnd, · 57 unmodified lines
5858
5959 /*
6060 * Top of mmap area (just below the process stack).
61− * Leave at least a ~32 MB hole.
61+ * Leave at least a ~128 MB hole.
6262 */
63− gap_min = 32 * 1024 * 1024UL;
63+ gap_min = SZ_128M;
6464 gap_max = (STACK_TOP / 6) * 5;
6565
6666 if (gap < gap_min)
arch/s390/pci/pci.c+1−1
@@ -799,7 +799,7 @@ struct zpci_dev *zpci_create_device(u32 fid, u32 fh, enum zpci_state state) · 798 unmodified lines
799799 struct zpci_dev *zdev;
800800 int rc;
801801
802− zpci_dbg(3, "add fid:%x, fh:%x, c:%d\n", fid, fh, state);
802+ zpci_dbg(1, "add fid:%x, fh:%x, c:%d\n", fid, fh, state);
803803 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL);
804804 if (!zdev)
805805 return ERR_PTR(-ENOMEM);
arch/s390/pci/pci_clp.c+1−1
@@ -30,7 +30,7 @@ bool zpci_unique_uid; · 29 unmodified lines
3030 void update_uid_checking(bool new)
3131 {
3232 if (zpci_unique_uid != new)
33− zpci_dbg(1, "uid checking:%d\n", new);
33+ zpci_dbg(3, "uid checking:%d\n", new);
3434
3535 zpci_unique_uid = new;
3636 }
arch/s390/pci/pci_debug.c+1−1
@@ -196,7 +196,7 @@ int __init zpci_debug_init(void) · 195 unmodified lines
196196 if (!pci_debug_err_id)
197197 return -EINVAL;
198198 debug_register_view(pci_debug_err_id, &debug_hex_ascii_view);
199− debug_set_level(pci_debug_err_id, 6);
199+ debug_set_level(pci_debug_err_id, 3);
200200
201201 debugfs_root = debugfs_create_dir("pci", NULL);
202202 return 0;
arch/s390/pci/pci_event.c+0−3
@@ -321,9 +321,6 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf) · 320 unmodified lines
321321
322322 zpci_dbg(3, "avl fid:%x, fh:%x, pec:%x\n",
323323 ccdf->fid, ccdf->fh, ccdf->pec);
324− zpci_err("avail CCDF:\n");
325− zpci_err_hex(ccdf, sizeof(*ccdf));
326−
327324 switch (ccdf->pec) {
328325 case 0x0301: /* Reserved|Standby -> Configured */
329326 if (!zdev) {
arch/s390/pci/pci_insn.c+86−22
@@ -18,16 +18,40 @@ · 17 unmodified lines
1818
1919 #define ZPCI_INSN_BUSY_DELAY 1 /* 1 microsecond */
2020
21−static inline void zpci_err_insn(u8 cc, u8 status, u64 req, u64 offset)
21+struct zpci_err_insn_data {
22+ u8 insn;
23+ u8 cc;
24+ u8 status;
25+ union {
26+ struct {
27+ u64 req;
28+ u64 offset;
29+ };
30+ struct {
31+ u64 addr;
32+ u64 len;
33+ };
34+ };
35+} __packed;
36+
37+static inline void zpci_err_insn_req(int lvl, u8 insn, u8 cc, u8 status,
38+ u64 req, u64 offset)
2239 {
23− struct {
24− u64 req;
25− u64 offset;
26− u8 cc;
27− u8 status;
28− } __packed data = {req, offset, cc, status};
29−
30− zpci_err_hex(&data, sizeof(data));
40+ struct zpci_err_insn_data data = {
41+ .insn = insn, .cc = cc, .status = status,
42+ .req = req, .offset = offset};
43+
44+ zpci_err_hex_level(lvl, &data, sizeof(data));
45+}
46+
47+static inline void zpci_err_insn_addr(int lvl, u8 insn, u8 cc, u8 status,
48+ u64 addr, u64 len)
49+{
50+ struct zpci_err_insn_data data = {
51+ .insn = insn, .cc = cc, .status = status,
52+ .addr = addr, .len = len};
53+
54+ zpci_err_hex_level(lvl, &data, sizeof(data));
3155 }
3256
3357 /* Modify PCI Function Controls */
@@ -47,16 +71,24 @@ static inline u8 __mpcifc(u64 req, struct zpci_fib *fib, u8 *status) · 13 unmodified lines
4771
4872 u8 zpci_mod_fc(u64 req, struct zpci_fib *fib, u8 *status)
4973 {
74+ bool retried = false;
5075 u8 cc;
5176
5277 do {
5378 cc = __mpcifc(req, fib, status);
54− if (cc == 2)
79+ if (cc == 2) {
5580 msleep(ZPCI_INSN_BUSY_DELAY);
81+ if (!retried) {
82+ zpci_err_insn_req(1, 'M', cc, *status, req, 0);
83+ retried = true;
84+ }
85+ }
5686 } while (cc == 2);
5787
5888 if (cc)
59− zpci_err_insn(cc, *status, req, 0);
89+ zpci_err_insn_req(0, 'M', cc, *status, req, 0);
90+ else if (retried)
91+ zpci_err_insn_req(1, 'M', cc, *status, req, 0);
6092
6193 return cc;
6294 }
@@ -80,16 +112,24 @@ static inline u8 __rpcit(u64 fn, u64 addr, u64 range, u8 *status) · 17 unmodified lines
80112
81113 int zpci_refresh_trans(u64 fn, u64 addr, u64 range)
82114 {
115+ bool retried = false;
83116 u8 cc, status;
84117
85118 do {
86119 cc = __rpcit(fn, addr, range, &status);
87− if (cc == 2)
120+ if (cc == 2) {
88121 udelay(ZPCI_INSN_BUSY_DELAY);
122+ if (!retried) {
123+ zpci_err_insn_addr(1, 'R', cc, status, addr, range);
124+ retried = true;
125+ }
126+ }
89127 } while (cc == 2);
90128
91129 if (cc)
92− zpci_err_insn(cc, status, addr, range);
130+ zpci_err_insn_addr(0, 'R', cc, status, addr, range);
131+ else if (retried)
132+ zpci_err_insn_addr(1, 'R', cc, status, addr, range);
93133
94134 if (cc == 1 && (status == 4 || status == 16))
95135 return -ENOMEM;
@@ -144,17 +184,25 @@ static inline int __pcilg(u64 *data, u64 req, u64 offset, u8 *status) · 48 unmodified lines
144184
145185 int __zpci_load(u64 *data, u64 req, u64 offset)
146186 {
187+ bool retried = false;
147188 u8 status;
148189 int cc;
149190
150191 do {
151192 cc = __pcilg(data, req, offset, &status);
152− if (cc == 2)
193+ if (cc == 2) {
153194 udelay(ZPCI_INSN_BUSY_DELAY);
195+ if (!retried) {
196+ zpci_err_insn_req(1, 'l', cc, status, req, offset);
197+ retried = true;
198+ }
199+ }
154200 } while (cc == 2);
155201
156202 if (cc)
157− zpci_err_insn(cc, status, req, offset);
203+ zpci_err_insn_req(0, 'l', cc, status, req, offset);
204+ else if (retried)
205+ zpci_err_insn_req(1, 'l', cc, status, req, offset);
158206
159207 return (cc > 0) ? -EIO : cc;
160208 }
@@ -198,7 +246,7 @@ int zpci_load(u64 *data, const volatile void __iomem *addr, unsigned long len) · 37 unmodified lines
198246
199247 cc = __pcilg_mio(data, (__force u64) addr, len, &status);
200248 if (cc)
201− zpci_err_insn(cc, status, 0, (__force u64) addr);
249+ zpci_err_insn_addr(0, 'L', cc, status, (__force u64) addr, len);
202250
203251 return (cc > 0) ? -EIO : cc;
204252 }
@@ -225,17 +273,25 @@ static inline int __pcistg(u64 data, u64 req, u64 offset, u8 *status) · 20 unmodified lines
225273
226274 int __zpci_store(u64 data, u64 req, u64 offset)
227275 {
276+ bool retried = false;
228277 u8 status;
229278 int cc;
230279
231280 do {
232281 cc = __pcistg(data, req, offset, &status);
233− if (cc == 2)
282+ if (cc == 2) {
234283 udelay(ZPCI_INSN_BUSY_DELAY);
284+ if (!retried) {
285+ zpci_err_insn_req(1, 's', cc, status, req, offset);
286+ retried = true;
287+ }
288+ }
235289 } while (cc == 2);
236290
237291 if (cc)
238− zpci_err_insn(cc, status, req, offset);
292+ zpci_err_insn_req(0, 's', cc, status, req, offset);
293+ else if (retried)
294+ zpci_err_insn_req(1, 's', cc, status, req, offset);
239295
240296 return (cc > 0) ? -EIO : cc;
241297 }
@@ -278,7 +334,7 @@ int zpci_store(const volatile void __iomem *addr, u64 data, unsigned long len) · 36 unmodified lines
278334
279335 cc = __pcistg_mio(data, (__force u64) addr, len, &status);
280336 if (cc)
281− zpci_err_insn(cc, status, 0, (__force u64) addr);
337+ zpci_err_insn_addr(0, 'S', cc, status, (__force u64) addr, len);
282338
283339 return (cc > 0) ? -EIO : cc;
284340 }
@@ -304,17 +360,25 @@ static inline int __pcistb(const u64 *data, u64 req, u64 offset, u8 *status) · 19 unmodified lines
304360
305361 int __zpci_store_block(const u64 *data, u64 req, u64 offset)
306362 {
363+ bool retried = false;
307364 u8 status;
308365 int cc;
309366
310367 do {
311368 cc = __pcistb(data, req, offset, &status);
312− if (cc == 2)
369+ if (cc == 2) {
313370 udelay(ZPCI_INSN_BUSY_DELAY);
371+ if (!retried) {
372+ zpci_err_insn_req(0, 'b', cc, status, req, offset);
373+ retried = true;
374+ }
375+ }
314376 } while (cc == 2);
315377
316378 if (cc)
317− zpci_err_insn(cc, status, req, offset);
379+ zpci_err_insn_req(0, 'b', cc, status, req, offset);
380+ else if (retried)
381+ zpci_err_insn_req(1, 'b', cc, status, req, offset);
318382
319383 return (cc > 0) ? -EIO : cc;
320384 }
@@ -358,7 +422,7 @@ int zpci_write_block(volatile void __iomem *dst, · 37 unmodified lines
358422
359423 cc = __pcistb_mio(src, (__force u64) dst, len, &status);
360424 if (cc)
361− zpci_err_insn(cc, status, 0, (__force u64) dst);
425+ zpci_err_insn_addr(0, 'B', cc, status, (__force u64) dst, len);
362426
363427 return (cc > 0) ? -EIO : cc;
364428 }
arch/s390/purgatory/head.S+23−7
@@ -44,11 +44,14 @@ · 43 unmodified lines
4444 .endm
4545
4646 .macro MEMSWAP dst,src,buf,len
47−10: cghi \len,bufsz
47+10: larl %r0,purgatory_end
48+ larl %r1,stack
49+ slgr %r0,%r1
50+ cgr \len,%r0
4851 jh 11f
4952 lgr %r4,\len
5053 j 12f
51−11: lghi %r4,bufsz
54+11: lgr %r4,%r0
5255
5356 12: MEMCPY \buf,\dst,%r4
5457 MEMCPY \dst,\src,%r4
@@ -135,12 +138,18 @@ ENTRY(purgatory_start) · 80 unmodified lines
135138
136139 .start_crash_kernel:
137140 /* Location of purgatory_start in crash memory */
141+ larl %r0,.base_crash
142+ larl %r1,purgatory_start
143+ slgr %r0,%r1
138144 lgr %r8,%r13
139− aghi %r8,-(.base_crash-purgatory_start)
145+ sgr %r8,%r0
140146
141147 /* Destination for this code i.e. end of memory to be swapped. */
148+ larl %r0,purgatory_end
149+ larl %r1,purgatory_start
150+ slgr %r0,%r1
142151 lg %r9,crash_size-.base_crash(%r13)
143− aghi %r9,-(purgatory_end-purgatory_start)
152+ sgr %r9,%r0
144153
145154 /* Destination in crash memory, i.e. same as r9 but in crash memory. */
146155 lg %r10,crash_start-.base_crash(%r13)
@@ -149,15 +158,19 @@ ENTRY(purgatory_start) · 2 unmodified lines
149158 /* Buffer location (in crash memory) and size. As the purgatory is
150159 * behind the point of no return it can re-use the stack as buffer.
151160 */
152− lghi %r11,bufsz
161+ larl %r11,purgatory_end
153162 larl %r12,stack
163+ slgr %r11,%r12
154164
155165 MEMCPY %r12,%r9,%r11 /* dst -> (crash) buf */
156166 MEMCPY %r9,%r8,%r11 /* self -> dst */
157167
158168 /* Jump to new location. */
159169 lgr %r7,%r9
160− aghi %r7,.jump_to_dst-purgatory_start
170+ larl %r0,.jump_to_dst
171+ larl %r1,purgatory_start
172+ slgr %r0,%r1
173+ agr %r7,%r0
161174 br %r7
162175
163176 .jump_to_dst:
@@ -169,7 +182,10 @@ ENTRY(purgatory_start) · 5 unmodified lines
169182
170183 /* Load new buffer location after jump */
171184 larl %r7,stack
172− aghi %r10,stack-purgatory_start
185+ lgr %r0,%r7
186+ larl %r1,purgatory_start
187+ slgr %r0,%r1
188+ agr %r10,%r0
173189 MEMCPY %r10,%r7,%r11 /* (new) buf -> (crash) buf */
174190
175191 /* Now the code is set up to run from its designated location. Start
arch/x86/include/asm/entry-common.h+2−2
@@ -10,7 +10,7 @@ · 9 unmodified lines
1010 #include <asm/fpu/api.h>
1111
1212 /* Check that the stack and regs on entry from user mode are sane. */
13−static __always_inline void arch_check_user_regs(struct pt_regs *regs)
13+static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
1414 {
1515 if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) {
1616 /*
@@ -42,7 +42,7 @@ static __always_inline void arch_check_user_regs(struct pt_regs *regs) · 25 unmodified lines
4242 WARN_ON_ONCE(regs != task_pt_regs(current));
4343 }
4444 }
45−#define arch_check_user_regs arch_check_user_regs
45+#define arch_enter_from_user_mode arch_enter_from_user_mode
4646
4747 static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
4848 unsigned long ti_work)
drivers/s390/char/con3215.c+13−12
@@ -771,35 +771,36 @@ static struct tty_driver *con3215_device(struct console *c, int *index) · 770 unmodified lines
771771 }
772772
773773 /*
774− * panic() calls con3215_flush through a panic_notifier
775− * before the system enters a disabled, endless loop.
774+ * The below function is called as a panic/reboot notifier before the
775+ * system enters a disabled, endless loop.
776+ *
777+ * Notice we must use the spin_trylock() alternative, to prevent lockups
778+ * in atomic context (panic routine runs with secondary CPUs, local IRQs
779+ * and preemption disabled).
776780 */
777−static void con3215_flush(void)
781+static int con3215_notify(struct notifier_block *self,
782+ unsigned long event, void *data)
778783 {
779784 struct raw3215_info *raw;
780785 unsigned long flags;
781786
782787 raw = raw3215[0]; /* console 3215 is the first one */
783− spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
788+ if (!spin_trylock_irqsave(get_ccwdev_lock(raw->cdev), flags))
789+ return NOTIFY_DONE;
784790 raw3215_make_room(raw, RAW3215_BUFFER_SIZE);
785791 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
786−}
787792
788−static int con3215_notify(struct notifier_block *self,
789− unsigned long event, void *data)
790−{
791− con3215_flush();
792− return NOTIFY_OK;
793+ return NOTIFY_DONE;
793794 }
794795
795796 static struct notifier_block on_panic_nb = {
796797 .notifier_call = con3215_notify,
797− .priority = 0,
798+ .priority = INT_MIN + 1, /* run the callback late */
798799 };
799800
800801 static struct notifier_block on_reboot_nb = {
801802 .notifier_call = con3215_notify,
802− .priority = 0,
803+ .priority = INT_MIN + 1, /* run the callback late */
803804 };
804805
805806 /*
drivers/s390/char/con3270.c+16−15
@@ -535,20 +535,26 @@ con3270_wait_write(struct con3270 *cp) · 534 unmodified lines
535535 }
536536
537537 /*
538− * panic() calls con3270_flush through a panic_notifier
539− * before the system enters a disabled, endless loop.
538+ * The below function is called as a panic/reboot notifier before the
539+ * system enters a disabled, endless loop.
540+ *
541+ * Notice we must use the spin_trylock() alternative, to prevent lockups
542+ * in atomic context (panic routine runs with secondary CPUs, local IRQs
543+ * and preemption disabled).
540544 */
541−static void
542−con3270_flush(void)
545+static int con3270_notify(struct notifier_block *self,
546+ unsigned long event, void *data)
543547 {
544548 struct con3270 *cp;
545549 unsigned long flags;
546550
547551 cp = condev;
548552 if (!cp->view.dev)
549− return;
550− raw3270_activate_view(&cp->view);
551− spin_lock_irqsave(&cp->view.lock, flags);
553+ return NOTIFY_DONE;
554+ if (!raw3270_view_lock_unavailable(&cp->view))
555+ raw3270_activate_view(&cp->view);
556+ if (!spin_trylock_irqsave(&cp->view.lock, flags))
557+ return NOTIFY_DONE;
552558 con3270_wait_write(cp);
553559 cp->nr_up = 0;
554560 con3270_rebuild_update(cp);
@@ -560,23 +566,18 @@ con3270_flush(void) · 5 unmodified lines
560566 con3270_wait_write(cp);
561567 }
562568 spin_unlock_irqrestore(&cp->view.lock, flags);
563−}
564569
565−static int con3270_notify(struct notifier_block *self,
566− unsigned long event, void *data)
567−{
568− con3270_flush();
569− return NOTIFY_OK;
570+ return NOTIFY_DONE;
570571 }
571572
572573 static struct notifier_block on_panic_nb = {
573574 .notifier_call = con3270_notify,
574− .priority = 0,
575+ .priority = INT_MIN + 1, /* run the callback late */
575576 };
576577
577578 static struct notifier_block on_reboot_nb = {
578579 .notifier_call = con3270_notify,
579− .priority = 0,
580+ .priority = INT_MIN + 1, /* run the callback late */
580581 };
581582
582583 /*
drivers/s390/char/raw3270.c+15−0
@@ -830,6 +830,21 @@ raw3270_create_device(struct ccw_device *cdev) · 829 unmodified lines
830830 return rp;
831831 }
832832
833+/*
834+ * This helper just validates that it is safe to activate a
835+ * view in the panic() context, due to locking restrictions.
836+ */
837+int raw3270_view_lock_unavailable(struct raw3270_view *view)
838+{
839+ struct raw3270 *rp = view->dev;
840+
841+ if (!rp)
842+ return -ENODEV;
843+ if (spin_is_locked(get_ccwdev_lock(rp->cdev)))
844+ return -EBUSY;
845+ return 0;
846+}
847+
833848 /*
834849 * Activate a view.
835850 */
drivers/s390/char/raw3270.h+1−0
@@ -160,6 +160,7 @@ struct raw3270_view { · 159 unmodified lines
160160 };
161161
162162 int raw3270_add_view(struct raw3270_view *, struct raw3270_fn *, int, int);
163+int raw3270_view_lock_unavailable(struct raw3270_view *view);
163164 int raw3270_activate_view(struct raw3270_view *);
164165 void raw3270_del_view(struct raw3270_view *);
165166 void raw3270_deactivate_view(struct raw3270_view *);
drivers/s390/char/sclp_con.c+15−11
@@ -220,30 +220,34 @@ sclp_console_device(struct console *c, int *index) · 219 unmodified lines
220220 }
221221
222222 /*
223− * Make sure that all buffers will be flushed to the SCLP.
223+ * This panic/reboot notifier makes sure that all buffers
224+ * will be flushed to the SCLP.
224225 */
225−static void
226−sclp_console_flush(void)
226+static int sclp_console_notify(struct notifier_block *self,
227+ unsigned long event, void *data)
227228 {
229+ /*
230+ * Perform the lock check before effectively getting the
231+ * lock on sclp_conbuf_emit() / sclp_console_sync_queue()
232+ * to prevent potential lockups in atomic context.
233+ */
234+ if (spin_is_locked(&sclp_con_lock))
235+ return NOTIFY_DONE;
236+
228237 sclp_conbuf_emit();
229238 sclp_console_sync_queue();
230−}
231239
232−static int sclp_console_notify(struct notifier_block *self,
233− unsigned long event, void *data)
234−{
235− sclp_console_flush();
236− return NOTIFY_OK;
240+ return NOTIFY_DONE;
237241 }
238242
239243 static struct notifier_block on_panic_nb = {
240244 .notifier_call = sclp_console_notify,
241− .priority = 1,
245+ .priority = INT_MIN + 1, /* run the callback late */
242246 };
243247
244248 static struct notifier_block on_reboot_nb = {
245249 .notifier_call = sclp_console_notify,
246− .priority = 1,
250+ .priority = INT_MIN + 1, /* run the callback late */
247251 };
248252
249253 /*
drivers/s390/char/sclp_early.c+3−1
@@ -49,8 +49,10 @@ static void __init sclp_early_facilities_detect(void) · 48 unmodified lines
4949 S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP;
5050 if (sccb->fac91 & 0x40)
5151 S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_GUEST;
52− if (sccb->cpuoff > 134)
52+ if (sccb->cpuoff > 134) {
5353 sclp.has_diag318 = !!(sccb->byte_134 & 0x80);
54+ sclp.has_iplcc = !!(sccb->byte_134 & 0x02);
55+ }
5456 if (sccb->cpuoff > 137)
5557 sclp.has_sipl = !!(sccb->cbl & 0x4000);
5658 sclp.rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2;
drivers/s390/char/sclp_vt220.c+23−19
@@ -769,21 +769,6 @@ __initcall(sclp_vt220_tty_init); · 768 unmodified lines
769769
770770 #ifdef CONFIG_SCLP_VT220_CONSOLE
771771
772−static void __sclp_vt220_flush_buffer(void)
773−{
774− unsigned long flags;
775−
776− sclp_vt220_emit_current();
777− spin_lock_irqsave(&sclp_vt220_lock, flags);
778− del_timer(&sclp_vt220_timer);
779− while (sclp_vt220_queue_running) {
780− spin_unlock_irqrestore(&sclp_vt220_lock, flags);
781− sclp_sync_wait();
782− spin_lock_irqsave(&sclp_vt220_lock, flags);
783− }
784− spin_unlock_irqrestore(&sclp_vt220_lock, flags);
785−}
786−
787772 static void
788773 sclp_vt220_con_write(struct console *con, const char *buf, unsigned int count)
789774 {
@@ -797,22 +782,41 @@ sclp_vt220_con_device(struct console *c, int *index) · 7 unmodified lines
797782 return sclp_vt220_driver;
798783 }
799784
785+/*
786+ * This panic/reboot notifier runs in atomic context, so
787+ * locking restrictions apply to prevent potential lockups.
788+ */
800789 static int
801790 sclp_vt220_notify(struct notifier_block *self,
802791 unsigned long event, void *data)
803792 {
804− __sclp_vt220_flush_buffer();
805− return NOTIFY_OK;
793+ unsigned long flags;
794+
795+ if (spin_is_locked(&sclp_vt220_lock))
796+ return NOTIFY_DONE;
797+
798+ sclp_vt220_emit_current();
799+
800+ spin_lock_irqsave(&sclp_vt220_lock, flags);
801+ del_timer(&sclp_vt220_timer);
802+ while (sclp_vt220_queue_running) {
803+ spin_unlock_irqrestore(&sclp_vt220_lock, flags);
804+ sclp_sync_wait();
805+ spin_lock_irqsave(&sclp_vt220_lock, flags);
806+ }
807+ spin_unlock_irqrestore(&sclp_vt220_lock, flags);
808+
809+ return NOTIFY_DONE;
806810 }
807811
808812 static struct notifier_block on_panic_nb = {
809813 .notifier_call = sclp_vt220_notify,
810− .priority = 1,
814+ .priority = INT_MIN + 1, /* run the callback late */
811815 };
812816
813817 static struct notifier_block on_reboot_nb = {
814818 .notifier_call = sclp_vt220_notify,
815− .priority = 1,
819+ .priority = INT_MIN + 1, /* run the callback late */
816820 };
817821
818822 /* Structure needed to register with printk */
drivers/s390/cio/chsc.c+2−2
@@ -1255,7 +1255,7 @@ exit: · 1254 unmodified lines
12551255 EXPORT_SYMBOL_GPL(css_general_characteristics);
12561256 EXPORT_SYMBOL_GPL(css_chsc_characteristics);
12571257
1258−int chsc_sstpc(void *page, unsigned int op, u16 ctrl, u64 *clock_delta)
1258+int chsc_sstpc(void *page, unsigned int op, u16 ctrl, long *clock_delta)
12591259 {
12601260 struct {
12611261 struct chsc_header request;
@@ -1266,7 +1266,7 @@ int chsc_sstpc(void *page, unsigned int op, u16 ctrl, u64 *clock_delta) · 4 unmodified lines
12661266 unsigned int rsvd2[5];
12671267 struct chsc_header response;
12681268 unsigned int rsvd3[3];
1269− u64 clock_delta;
1269+ s64 clock_delta;
12701270 unsigned int rsvd4[2];
12711271 } *rr;
12721272 int rc;
drivers/s390/crypto/ap_bus.c+63−33
@@ -179,7 +179,7 @@ static int ap_qci_available(void) · 178 unmodified lines
179179 * ap_apft_available(): Test if AP facilities test (APFT)
180180 * facility is available.
181181 *
182− * Returns 1 if APFT is is available.
182+ * Returns 1 if APFT is available.
183183 */
184184 static int ap_apft_available(void)
185185 {
@@ -693,6 +693,24 @@ void ap_send_online_uevent(struct ap_device *ap_dev, int online) · 507 unmodified lines
693693 }
694694 EXPORT_SYMBOL(ap_send_online_uevent);
695695
696+static void ap_send_mask_changed_uevent(unsigned long *newapm,
697+ unsigned long *newaqm)
698+{
699+ char buf[100];
700+ char *envp[] = { buf, NULL };
701+
702+ if (newapm)
703+ snprintf(buf, sizeof(buf),
704+ "APMASK=0x%016lx%016lx%016lx%016lx\n",
705+ newapm[0], newapm[1], newapm[2], newapm[3]);
706+ else
707+ snprintf(buf, sizeof(buf),
708+ "AQMASK=0x%016lx%016lx%016lx%016lx\n",
709+ newaqm[0], newaqm[1], newaqm[2], newaqm[3]);
710+
711+ kobject_uevent_env(&ap_root_device->kobj, KOBJ_CHANGE, envp);
712+}
713+
696714 /*
697715 * calc # of bound APQNs
698716 */
@@ -704,7 +722,7 @@ struct __ap_calc_ctrs { · 5 unmodified lines
704722
705723 static int __ap_calc_helper(struct device *dev, void *arg)
706724 {
707− struct __ap_calc_ctrs *pctrs = (struct __ap_calc_ctrs *) arg;
725+ struct __ap_calc_ctrs *pctrs = (struct __ap_calc_ctrs *)arg;
708726
709727 if (is_queue_dev(dev)) {
710728 pctrs->apqns++;
@@ -720,7 +738,7 @@ static void ap_calc_bound_apqns(unsigned int *apqns, unsigned int *bound) · 9 unmodified lines
720738 struct __ap_calc_ctrs ctrs;
721739
722740 memset(&ctrs, 0, sizeof(ctrs));
723− bus_for_each_dev(&ap_bus_type, NULL, (void *) &ctrs, __ap_calc_helper);
741+ bus_for_each_dev(&ap_bus_type, NULL, (void *)&ctrs, __ap_calc_helper);
724742
725743 *apqns = ctrs.apqns;
726744 *bound = ctrs.bound;
@@ -781,7 +799,7 @@ EXPORT_SYMBOL(ap_wait_init_apqn_bindings_complete); · 54 unmodified lines
781799 static int __ap_queue_devices_with_id_unregister(struct device *dev, void *data)
782800 {
783801 if (is_queue_dev(dev) &&
784− AP_QID_CARD(to_ap_queue(dev)->qid) == (int)(long) data)
802+ AP_QID_CARD(to_ap_queue(dev)->qid) == (int)(long)data)
785803 device_unregister(dev);
786804 return 0;
787805 }
@@ -794,8 +812,8 @@ static int __ap_revise_reserved(struct device *dev, void *dummy) · 6 unmodified lines
794812 card = AP_QID_CARD(to_ap_queue(dev)->qid);
795813 queue = AP_QID_QUEUE(to_ap_queue(dev)->qid);
796814 mutex_lock(&ap_perms_mutex);
797− devres = test_bit_inv(card, ap_perms.apm)
798− && test_bit_inv(queue, ap_perms.aqm);
815+ devres = test_bit_inv(card, ap_perms.apm) &&
816+ test_bit_inv(queue, ap_perms.aqm);
799817 mutex_unlock(&ap_perms_mutex);
800818 drvres = to_ap_drv(dev->driver)->flags
801819 & AP_DRIVER_FLAG_DEFAULT;
@@ -826,8 +844,8 @@ int ap_owned_by_def_drv(int card, int queue) · 24 unmodified lines
826844
827845 mutex_lock(&ap_perms_mutex);
828846
829− if (test_bit_inv(card, ap_perms.apm)
830− && test_bit_inv(queue, ap_perms.aqm))
847+ if (test_bit_inv(card, ap_perms.apm) &&
848+ test_bit_inv(queue, ap_perms.aqm))
831849 rc = 1;
832850
833851 mutex_unlock(&ap_perms_mutex);
@@ -876,8 +894,8 @@ static int ap_device_probe(struct device *dev) · 42 unmodified lines
876894 card = AP_QID_CARD(to_ap_queue(dev)->qid);
877895 queue = AP_QID_QUEUE(to_ap_queue(dev)->qid);
878896 mutex_lock(&ap_perms_mutex);
879− devres = test_bit_inv(card, ap_perms.apm)
880− && test_bit_inv(queue, ap_perms.aqm);
897+ devres = test_bit_inv(card, ap_perms.apm) &&
898+ test_bit_inv(queue, ap_perms.aqm);
881899 mutex_unlock(&ap_perms_mutex);
882900 drvres = ap_drv->flags & AP_DRIVER_FLAG_DEFAULT;
883901 if (!!devres != !!drvres)
@@ -898,8 +916,9 @@ static int ap_device_probe(struct device *dev) · 14 unmodified lines
898916 if (is_queue_dev(dev))
899917 hash_del(&to_ap_queue(dev)->hnode);
900918 spin_unlock_bh(&ap_queues_lock);
901− } else
919+ } else {
902920 ap_check_bindings_complete();
921+ }
903922
904923 out:
905924 if (rc)
@@ -980,8 +999,8 @@ void ap_bus_force_rescan(void) · 74 unmodified lines
980999 EXPORT_SYMBOL(ap_bus_force_rescan);
9811000
9821001 /*
983−* A config change has happened, force an ap bus rescan.
984−*/
1002+ * A config change has happened, force an ap bus rescan.
1003+ */
9851004 void ap_bus_cfg_chg(void)
9861005 {
9871006 AP_DBF_DBG("%s config change, forcing bus rescan\n", __func__);
@@ -1105,7 +1124,7 @@ int ap_parse_mask_str(const char *str, · 117 unmodified lines
11051124 if (bits & 0x07)
11061125 return -EINVAL;
11071126
1108− size = BITS_TO_LONGS(bits)*sizeof(unsigned long);
1127+ size = BITS_TO_LONGS(bits) * sizeof(unsigned long);
11091128 newmap = kmalloc(size, GFP_KERNEL);
11101129 if (!newmap)
11111130 return -ENOMEM;
@@ -1241,8 +1260,9 @@ static ssize_t poll_thread_store(struct bus_type *bus, · 129 unmodified lines
12411260 rc = ap_poll_thread_start();
12421261 if (rc)
12431262 count = rc;
1244− } else
1263+ } else {
12451264 ap_poll_thread_stop();
1265+ }
12461266 return count;
12471267 }
12481268
@@ -1355,7 +1375,7 @@ static int apmask_commit(unsigned long *newapm) · 106 unmodified lines
13551375 static ssize_t apmask_store(struct bus_type *bus, const char *buf,
13561376 size_t count)
13571377 {
1358− int rc;
1378+ int rc, changes = 0;
13591379 DECLARE_BITMAP(newapm, AP_DEVICES);
13601380
13611381 if (mutex_lock_interruptible(&ap_perms_mutex))
@@ -1365,14 +1385,19 @@ static ssize_t apmask_store(struct bus_type *bus, const char *buf, · 3 unmodified lines
13651385 if (rc)
13661386 goto done;
13671387
1368− rc = apmask_commit(newapm);
1388+ changes = memcmp(ap_perms.apm, newapm, APMASKSIZE);
1389+ if (changes)
1390+ rc = apmask_commit(newapm);
13691391
13701392 done:
13711393 mutex_unlock(&ap_perms_mutex);
13721394 if (rc)
13731395 return rc;
13741396
1375− ap_bus_revise_bindings();
1397+ if (changes) {
1398+ ap_bus_revise_bindings();
1399+ ap_send_mask_changed_uevent(newapm, NULL);
1400+ }
13761401
13771402 return count;
13781403 }
@@ -1443,7 +1468,7 @@ static int aqmask_commit(unsigned long *newaqm) · 64 unmodified lines
14431468 static ssize_t aqmask_store(struct bus_type *bus, const char *buf,
14441469 size_t count)
14451470 {
1446− int rc;
1471+ int rc, changes = 0;
14471472 DECLARE_BITMAP(newaqm, AP_DOMAINS);
14481473
14491474 if (mutex_lock_interruptible(&ap_perms_mutex))
@@ -1453,14 +1478,19 @@ static ssize_t aqmask_store(struct bus_type *bus, const char *buf, · 3 unmodified lines
14531478 if (rc)
14541479 goto done;
14551480
1456− rc = aqmask_commit(newaqm);
1481+ changes = memcmp(ap_perms.aqm, newaqm, APMASKSIZE);
1482+ if (changes)
1483+ rc = aqmask_commit(newaqm);
14571484
14581485 done:
14591486 mutex_unlock(&ap_perms_mutex);
14601487 if (rc)
14611488 return rc;
14621489
1463− ap_bus_revise_bindings();
1490+ if (changes) {
1491+ ap_bus_revise_bindings();
1492+ ap_send_mask_changed_uevent(NULL, newaqm);
1493+ }
14641494
14651495 return count;
14661496 }
@@ -1605,9 +1635,9 @@ static int ap_get_compatible_type(ap_qid_t qid, int rawtype, unsigned int func) · 138 unmodified lines
16051635 apinfo.mode = (func >> 26) & 0x07;
16061636 apinfo.cat = AP_DEVICE_TYPE_CEX8;
16071637 status = ap_qact(qid, 0, &apinfo);
1608− if (status.response_code == AP_RESPONSE_NORMAL
1609− && apinfo.cat >= AP_DEVICE_TYPE_CEX2A
1610− && apinfo.cat <= AP_DEVICE_TYPE_CEX8)
1638+ if (status.response_code == AP_RESPONSE_NORMAL &&
1639+ apinfo.cat >= AP_DEVICE_TYPE_CEX2A &&
1640+ apinfo.cat <= AP_DEVICE_TYPE_CEX8)
16111641 comp_type = apinfo.cat;
16121642 }
16131643 if (!comp_type)
@@ -1627,7 +1657,7 @@ static int ap_get_compatible_type(ap_qid_t qid, int rawtype, unsigned int func) · 13 unmodified lines
16271657 */
16281658 static int __match_card_device_with_id(struct device *dev, const void *data)
16291659 {
1630− return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long)(void *) data;
1660+ return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long)(void *)data;
16311661 }
16321662
16331663 /*
@@ -1636,7 +1666,7 @@ static int __match_card_device_with_id(struct device *dev, const void *data) · 2 unmodified lines
16361666 */
16371667 static int __match_queue_device_with_qid(struct device *dev, const void *data)
16381668 {
1639− return is_queue_dev(dev) && to_ap_queue(dev)->qid == (int)(long) data;
1669+ return is_queue_dev(dev) && to_ap_queue(dev)->qid == (int)(long)data;
16401670 }
16411671
16421672 /*
@@ -1645,8 +1675,8 @@ static int __match_queue_device_with_qid(struct device *dev, const void *data) · 2 unmodified lines
16451675 */
16461676 static int __match_queue_device_with_queue_id(struct device *dev, const void *data)
16471677 {
1648− return is_queue_dev(dev)
1649− && AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long) data;
1678+ return is_queue_dev(dev) &&
1679+ AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long)data;
16501680 }
16511681
16521682 /* Helper function for notify_config_changed */
@@ -1699,7 +1729,7 @@ static inline void notify_scan_complete(void) · 46 unmodified lines
16991729 static inline void ap_scan_rm_card_dev_and_queue_devs(struct ap_card *ac)
17001730 {
17011731 bus_for_each_dev(&ap_bus_type, NULL,
1702− (void *)(long) ac->id,
1732+ (void *)(long)ac->id,
17031733 __ap_queue_devices_with_id_unregister);
17041734 device_unregister(&ac->ap_dev.device);
17051735 }
@@ -1727,7 +1757,7 @@ static inline void ap_scan_domains(struct ap_card *ac) · 21 unmodified lines
17271757 for (dom = 0; dom <= ap_max_domain_id; dom++) {
17281758 qid = AP_MKQID(ac->id, dom);
17291759 dev = bus_find_device(&ap_bus_type, NULL,
1730− (void *)(long) qid,
1760+ (void *)(long)qid,
17311761 __match_queue_device_with_qid);
17321762 aq = dev ? to_ap_queue(dev) : NULL;
17331763 if (!ap_test_config_usage_domain(dom)) {
@@ -1873,7 +1903,7 @@ static inline void ap_scan_adapter(int ap) · 139 unmodified lines
18731903
18741904 /* Is there currently a card device for this adapter ? */
18751905 dev = bus_find_device(&ap_bus_type, NULL,
1876− (void *)(long) ap,
1906+ (void *)(long)ap,
18771907 __match_card_device_with_id);
18781908 ac = dev ? to_ap_card(dev) : NULL;
18791909
@@ -2074,7 +2104,7 @@ static void ap_scan_bus(struct work_struct *unused) · 194 unmodified lines
20742104 if (ap_domain_index >= 0) {
20752105 struct device *dev =
20762106 bus_find_device(&ap_bus_type, NULL,
2077− (void *)(long) ap_domain_index,
2107+ (void *)(long)ap_domain_index,
20782108 __match_queue_device_with_queue_id);
20792109 if (dev)
20802110 put_device(dev);
@@ -2109,7 +2139,7 @@ static int __init ap_debug_init(void) · 28 unmodified lines
21092139
21102140 static void __init ap_perms_init(void)
21112141 {
2112− /* all resources useable if no kernel parameter string given */
2142+ /* all resources usable if no kernel parameter string given */
21132143 memset(&ap_perms.ioctlm, 0xFF, sizeof(ap_perms.ioctlm));
21142144 memset(&ap_perms.apm, 0xFF, sizeof(ap_perms.apm));
21152145 memset(&ap_perms.aqm, 0xFF, sizeof(ap_perms.aqm));
drivers/s390/crypto/ap_bus.h+1−0
@@ -317,6 +317,7 @@ struct ap_perms { · 316 unmodified lines
317317 unsigned long aqm[BITS_TO_LONGS(AP_DOMAINS)];
318318 unsigned long adm[BITS_TO_LONGS(AP_DOMAINS)];
319319 };
320+
320321 extern struct ap_perms ap_perms;
321322 extern struct mutex ap_perms_mutex;
322323
drivers/s390/crypto/ap_queue.c+4−3
@@ -99,7 +99,7 @@ int ap_recv(ap_qid_t qid, unsigned long long *psmid, void *msg, size_t length) · 98 unmodified lines
9999 {
100100 struct ap_queue_status status;
101101
102− if (msg == NULL)
102+ if (!msg)
103103 return -EINVAL;
104104 status = ap_dqap(qid, psmid, msg, length, NULL, NULL);
105105 switch (status.response_code) {
@@ -603,7 +603,7 @@ static ssize_t interrupt_show(struct device *dev, · 497 unmodified lines
603603 static DEVICE_ATTR_RO(interrupt);
604604
605605 static ssize_t config_show(struct device *dev,
606− struct device_attribute *attr, char *buf)
606+ struct device_attribute *attr, char *buf)
607607 {
608608 struct ap_queue *aq = to_ap_queue(dev);
609609 int rc;
@@ -827,8 +827,9 @@ int ap_queue_message(struct ap_queue *aq, struct ap_message *ap_msg) · 217 unmodified lines
827827 aq->requestq_count++;
828828 aq->total_request_count++;
829829 atomic64_inc(&aq->card->total_request_count);
830− } else
830+ } else {
831831 rc = -ENODEV;
832+ }
832833
833834 /* Send/receive as many request from the queue as possible. */
834835 ap_wait(ap_sm_event_loop(aq, AP_SM_EVENT_POLL));
drivers/s390/crypto/pkey_api.c+78−71
@@ -232,7 +232,7 @@ static int pkey_ep11key2pkey(const u8 *key, struct pkey_protkey *pkey) · 231 unmodified lines
232232 int i, rc;
233233 u16 card, dom;
234234 u32 nr_apqns, *apqns = NULL;
235− struct ep11keyblob *kb = (struct ep11keyblob *) key;
235+ struct ep11keyblob *kb = (struct ep11keyblob *)key;
236236
237237 zcrypt_wait_api_operational();
238238
@@ -267,12 +267,12 @@ static int pkey_verifykey(const struct pkey_seckey *seckey, · 28 unmodified lines
267267 u16 *pcardnr, u16 *pdomain,
268268 u16 *pkeysize, u32 *pattributes)
269269 {
270− struct secaeskeytoken *t = (struct secaeskeytoken *) seckey;
270+ struct secaeskeytoken *t = (struct secaeskeytoken *)seckey;
271271 u16 cardnr, domain;
272272 int rc;
273273
274274 /* check the secure key for valid AES secure key */
275− rc = cca_check_secaeskeytoken(debug_info, 3, (u8 *) seckey, 0);
275+ rc = cca_check_secaeskeytoken(debug_info, 3, (u8 *)seckey, 0);
276276 if (rc)
277277 goto out;
278278 if (pattributes)
@@ -425,9 +425,9 @@ static int pkey_nonccatok2pkey(const u8 *key, u32 keylen, · 146 unmodified lines
425425 t = (struct clearaeskeytoken *)key;
426426 if (keylen != sizeof(*t) + t->len)
427427 goto out;
428− if ((t->keytype == PKEY_KEYTYPE_AES_128 && t->len == 16)
429− || (t->keytype == PKEY_KEYTYPE_AES_192 && t->len == 24)
430− || (t->keytype == PKEY_KEYTYPE_AES_256 && t->len == 32))
428+ if ((t->keytype == PKEY_KEYTYPE_AES_128 && t->len == 16) ||
429+ (t->keytype == PKEY_KEYTYPE_AES_192 && t->len == 24) ||
430+ (t->keytype == PKEY_KEYTYPE_AES_256 && t->len == 32))
431431 memcpy(ckey.clrkey, t->clearkey, t->len);
432432 else
433433 goto out;
@@ -541,7 +541,6 @@ int pkey_keyblob2pkey(const u8 *key, u32 keylen, · 107 unmodified lines
541541
542542 DEBUG_DBG("%s rc=%d\n", __func__, rc);
543543 return rc;
544−
545544 }
546545 EXPORT_SYMBOL(pkey_keyblob2pkey);
547546
@@ -588,9 +587,11 @@ static int pkey_genseckey2(const struct pkey_apqn *apqns, size_t nr_apqns, · 40 unmodified lines
588587 } else if (ktype == PKEY_TYPE_CCA_DATA) {
589588 rc = cca_genseckey(card, dom, ksize, keybuf);
590589 *keybufsize = (rc ? 0 : SECKEYBLOBSIZE);
591− } else /* TOKVER_CCA_VLSC */
590+ } else {
591+ /* TOKVER_CCA_VLSC */
592592 rc = cca_gencipherkey(card, dom, ksize, kflags,
593593 keybuf, keybufsize);
594+ }
594595 if (rc == 0)
595596 break;
596597 }
@@ -645,9 +646,11 @@ static int pkey_clr2seckey2(const struct pkey_apqn *apqns, size_t nr_apqns, · 48 unmodified lines
645646 rc = cca_clr2seckey(card, dom, ksize,
646647 clrkey, keybuf);
647648 *keybufsize = (rc ? 0 : SECKEYBLOBSIZE);
648− } else /* TOKVER_CCA_VLSC */
649+ } else {
650+ /* TOKVER_CCA_VLSC */
649651 rc = cca_clr2cipherkey(card, dom, ksize, kflags,
650652 clrkey, keybuf, keybufsize);
653+ }
651654 if (rc == 0)
652655 break;
653656 }
@@ -667,8 +670,8 @@ static int pkey_verifykey2(const u8 *key, size_t keylen, · 13 unmodified lines
667670 if (keylen < sizeof(struct keytoken_header))
668671 return -EINVAL;
669672
670− if (hdr->type == TOKTYPE_CCA_INTERNAL
671− && hdr->version == TOKVER_CCA_AES) {
673+ if (hdr->type == TOKTYPE_CCA_INTERNAL &&
674+ hdr->version == TOKVER_CCA_AES) {
672675 struct secaeskeytoken *t = (struct secaeskeytoken *)key;
673676
674677 rc = cca_check_secaeskeytoken(debug_info, 3, key, 0);
@@ -677,7 +680,7 @@ static int pkey_verifykey2(const u8 *key, size_t keylen, · 2 unmodified lines
677680 if (ktype)
678681 *ktype = PKEY_TYPE_CCA_DATA;
679682 if (ksize)
680− *ksize = (enum pkey_key_size) t->bitsize;
683+ *ksize = (enum pkey_key_size)t->bitsize;
681684
682685 rc = cca_findcard2(&_apqns, &_nr_apqns, *cardnr, *domain,
683686 ZCRYPT_CEX3C, AES_MK_SET, t->mkvp, 0, 1);
@@ -697,8 +700,8 @@ static int pkey_verifykey2(const u8 *key, size_t keylen, · 13 unmodified lines
697700 *cardnr = ((struct pkey_apqn *)_apqns)->card;
698701 *domain = ((struct pkey_apqn *)_apqns)->domain;
699702
700− } else if (hdr->type == TOKTYPE_CCA_INTERNAL
701− && hdr->version == TOKVER_CCA_VLSC) {
703+ } else if (hdr->type == TOKTYPE_CCA_INTERNAL &&
704+ hdr->version == TOKVER_CCA_VLSC) {
702705 struct cipherkeytoken *t = (struct cipherkeytoken *)key;
703706
704707 rc = cca_check_secaescipherkey(debug_info, 3, key, 0, 1);
@@ -734,8 +737,8 @@ static int pkey_verifykey2(const u8 *key, size_t keylen, · 29 unmodified lines
734737 *cardnr = ((struct pkey_apqn *)_apqns)->card;
735738 *domain = ((struct pkey_apqn *)_apqns)->domain;
736739
737− } else if (hdr->type == TOKTYPE_NON_CCA
738− && hdr->version == TOKVER_EP11_AES) {
740+ } else if (hdr->type == TOKTYPE_NON_CCA &&
741+ hdr->version == TOKVER_EP11_AES) {
739742 struct ep11keyblob *kb = (struct ep11keyblob *)key;
740743
741744 rc = ep11_check_aes_key(debug_info, 3, key, keylen, 1);
@@ -757,8 +760,9 @@ static int pkey_verifykey2(const u8 *key, size_t keylen, · 15 unmodified lines
757760 *cardnr = ((struct pkey_apqn *)_apqns)->card;
758761 *domain = ((struct pkey_apqn *)_apqns)->domain;
759762
760− } else
763+ } else {
761764 rc = -EINVAL;
765+ }
762766
763767 out:
764768 kfree(_apqns);
@@ -816,16 +820,17 @@ static int pkey_keyblob2pkey2(const struct pkey_apqn *apqns, size_t nr_apqns, · 51 unmodified lines
816820 for (i = 0, rc = -ENODEV; i < nr_apqns; i++) {
817821 card = apqns[i].card;
818822 dom = apqns[i].domain;
819− if (hdr->type == TOKTYPE_CCA_INTERNAL
820− && hdr->version == TOKVER_CCA_AES)
823+ if (hdr->type == TOKTYPE_CCA_INTERNAL &&
824+ hdr->version == TOKVER_CCA_AES) {
821825 rc = cca_sec2protkey(card, dom, key, pkey->protkey,
822826 &pkey->len, &pkey->type);
823− else if (hdr->type == TOKTYPE_CCA_INTERNAL
824− && hdr->version == TOKVER_CCA_VLSC)
827+ } else if (hdr->type == TOKTYPE_CCA_INTERNAL &&
828+ hdr->version == TOKVER_CCA_VLSC) {
825829 rc = cca_cipher2protkey(card, dom, key, pkey->protkey,
826830 &pkey->len, &pkey->type);
827− else { /* EP11 AES secure key blob */
828− struct ep11keyblob *kb = (struct ep11keyblob *) key;
831+ } else {
832+ /* EP11 AES secure key blob */
833+ struct ep11keyblob *kb = (struct ep11keyblob *)key;
829834
830835 pkey->len = sizeof(pkey->protkey);
831836 rc = ep11_kblob2protkey(card, dom, key, kb->head.len,
@@ -851,10 +856,10 @@ static int pkey_apqns4key(const u8 *key, size_t keylen, u32 flags, · 19 unmodified lines
851856
852857 zcrypt_wait_api_operational();
853858
854− if (hdr->type == TOKTYPE_NON_CCA
855− && (hdr->version == TOKVER_EP11_AES_WITH_HEADER
856− || hdr->version == TOKVER_EP11_ECC_WITH_HEADER)
857− && is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) {
859+ if (hdr->type == TOKTYPE_NON_CCA &&
860+ (hdr->version == TOKVER_EP11_AES_WITH_HEADER ||
861+ hdr->version == TOKVER_EP11_ECC_WITH_HEADER) &&
862+ is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) {
858863 int minhwtype = 0, api = 0;
859864 struct ep11keyblob *kb = (struct ep11keyblob *)
860865 (key + sizeof(struct ep11kblob_header));
@@ -869,11 +874,11 @@ static int pkey_apqns4key(const u8 *key, size_t keylen, u32 flags, · 8 unmodified lines
869874 minhwtype, api, kb->wkvp);
870875 if (rc)
871876 goto out;
872− } else if (hdr->type == TOKTYPE_NON_CCA
873− && hdr->version == TOKVER_EP11_AES
874− && is_ep11_keyblob(key)) {
877+ } else if (hdr->type == TOKTYPE_NON_CCA &&
878+ hdr->version == TOKVER_EP11_AES &&
879+ is_ep11_keyblob(key)) {
875880 int minhwtype = 0, api = 0;
876− struct ep11keyblob *kb = (struct ep11keyblob *) key;
881+ struct ep11keyblob *kb = (struct ep11keyblob *)key;
877882
878883 if (flags != PKEY_FLAGS_MATCH_CUR_MKVP)
879884 return -EINVAL;
@@ -931,8 +936,9 @@ static int pkey_apqns4key(const u8 *key, size_t keylen, u32 flags, · 51 unmodified lines
931936 cur_mkvp, old_mkvp, 1);
932937 if (rc)
933938 goto out;
934− } else
939+ } else {
935940 return -EINVAL;
941+ }
936942
937943 if (apqns) {
938944 if (*nr_apqns < _nr_apqns)
@@ -961,9 +967,9 @@ static int pkey_apqns4keytype(enum pkey_key_type ktype, · 22 unmodified lines
961967 int minhwtype = ZCRYPT_CEX3C;
962968
963969 if (flags & PKEY_FLAGS_MATCH_CUR_MKVP)
964− cur_mkvp = *((u64 *) cur_mkvp);
970+ cur_mkvp = *((u64 *)cur_mkvp);
965971 if (flags & PKEY_FLAGS_MATCH_ALT_MKVP)
966− old_mkvp = *((u64 *) alt_mkvp);
972+ old_mkvp = *((u64 *)alt_mkvp);
967973 if (ktype == PKEY_TYPE_CCA_CIPHER)
968974 minhwtype = ZCRYPT_CEX6;
969975 rc = cca_findcard2(&_apqns, &_nr_apqns, 0xFFFF, 0xFFFF,
@@ -975,9 +981,9 @@ static int pkey_apqns4keytype(enum pkey_key_type ktype, · 5 unmodified lines
975981 u64 cur_mkvp = 0, old_mkvp = 0;
976982
977983 if (flags & PKEY_FLAGS_MATCH_CUR_MKVP)
978− cur_mkvp = *((u64 *) cur_mkvp);
984+ cur_mkvp = *((u64 *)cur_mkvp);
979985 if (flags & PKEY_FLAGS_MATCH_ALT_MKVP)
980− old_mkvp = *((u64 *) alt_mkvp);
986+ old_mkvp = *((u64 *)alt_mkvp);
981987 rc = cca_findcard2(&_apqns, &_nr_apqns, 0xFFFF, 0xFFFF,
982988 ZCRYPT_CEX7, APKA_MK_SET,
983989 cur_mkvp, old_mkvp, 1);
@@ -996,8 +1002,9 @@ static int pkey_apqns4keytype(enum pkey_key_type ktype, · 12 unmodified lines
9961002 if (rc)
9971003 goto out;
9981004
999− } else
1005+ } else {
10001006 return -EINVAL;
1007+ }
10011008
10021009 if (apqns) {
10031010 if (*nr_apqns < _nr_apqns)
@@ -1026,21 +1033,21 @@ static int pkey_keyblob2pkey3(const struct pkey_apqn *apqns, size_t nr_apqns, · 22 unmodified lines
10261033 if (keylen < sizeof(struct keytoken_header))
10271034 return -EINVAL;
10281035
1029− if (hdr->type == TOKTYPE_NON_CCA
1030− && hdr->version == TOKVER_EP11_AES_WITH_HEADER
1031− && is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) {
1036+ if (hdr->type == TOKTYPE_NON_CCA &&
1037+ hdr->version == TOKVER_EP11_AES_WITH_HEADER &&
1038+ is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) {
10321039 /* EP11 AES key blob with header */
10331040 if (ep11_check_aes_key_with_hdr(debug_info, 3, key, keylen, 1))
10341041 return -EINVAL;
1035− } else if (hdr->type == TOKTYPE_NON_CCA
1036− && hdr->version == TOKVER_EP11_ECC_WITH_HEADER
1037− && is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) {
1042+ } else if (hdr->type == TOKTYPE_NON_CCA &&
1043+ hdr->version == TOKVER_EP11_ECC_WITH_HEADER &&
1044+ is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) {
10381045 /* EP11 ECC key blob with header */
10391046 if (ep11_check_ecc_key_with_hdr(debug_info, 3, key, keylen, 1))
10401047 return -EINVAL;
1041− } else if (hdr->type == TOKTYPE_NON_CCA
1042− && hdr->version == TOKVER_EP11_AES
1043− && is_ep11_keyblob(key)) {
1048+ } else if (hdr->type == TOKTYPE_NON_CCA &&
1049+ hdr->version == TOKVER_EP11_AES &&
1050+ is_ep11_keyblob(key)) {
10441051 /* EP11 AES key blob with header in session field */
10451052 if (ep11_check_aes_key(debug_info, 3, key, keylen, 1))
10461053 return -EINVAL;
@@ -1088,15 +1095,15 @@ static int pkey_keyblob2pkey3(const struct pkey_apqn *apqns, size_t nr_apqns, · 41 unmodified lines
10881095 for (rc = -ENODEV, i = 0; rc && i < nr_apqns; i++) {
10891096 card = apqns[i].card;
10901097 dom = apqns[i].domain;
1091− if (hdr->type == TOKTYPE_NON_CCA
1092− && (hdr->version == TOKVER_EP11_AES_WITH_HEADER
1093− || hdr->version == TOKVER_EP11_ECC_WITH_HEADER)
1094− && is_ep11_keyblob(key + sizeof(struct ep11kblob_header)))
1098+ if (hdr->type == TOKTYPE_NON_CCA &&
1099+ (hdr->version == TOKVER_EP11_AES_WITH_HEADER ||
1100+ hdr->version == TOKVER_EP11_ECC_WITH_HEADER) &&
1101+ is_ep11_keyblob(key + sizeof(struct ep11kblob_header)))
10951102 rc = ep11_kblob2protkey(card, dom, key, hdr->len,
10961103 protkey, protkeylen, protkeytype);
1097− else if (hdr->type == TOKTYPE_NON_CCA
1098− && hdr->version == TOKVER_EP11_AES
1099− && is_ep11_keyblob(key))
1104+ else if (hdr->type == TOKTYPE_NON_CCA &&
1105+ hdr->version == TOKVER_EP11_AES &&
1106+ is_ep11_keyblob(key))
11001107 rc = ep11_kblob2protkey(card, dom, key, hdr->len,
11011108 protkey, protkeylen, protkeytype);
11021109 else if (hdr->type == TOKTYPE_CCA_INTERNAL &&
@@ -1144,7 +1151,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 41 unmodified lines
11441151
11451152 switch (cmd) {
11461153 case PKEY_GENSECK: {
1147− struct pkey_genseck __user *ugs = (void __user *) arg;
1154+ struct pkey_genseck __user *ugs = (void __user *)arg;
11481155 struct pkey_genseck kgs;
11491156
11501157 if (copy_from_user(&kgs, ugs, sizeof(kgs)))
@@ -1159,7 +1166,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 8 unmodified lines
11591166 break;
11601167 }
11611168 case PKEY_CLR2SECK: {
1162− struct pkey_clr2seck __user *ucs = (void __user *) arg;
1169+ struct pkey_clr2seck __user *ucs = (void __user *)arg;
11631170 struct pkey_clr2seck kcs;
11641171
11651172 if (copy_from_user(&kcs, ucs, sizeof(kcs)))
@@ -1175,7 +1182,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 9 unmodified lines
11751182 break;
11761183 }
11771184 case PKEY_SEC2PROTK: {
1178− struct pkey_sec2protk __user *usp = (void __user *) arg;
1185+ struct pkey_sec2protk __user *usp = (void __user *)arg;
11791186 struct pkey_sec2protk ksp;
11801187
11811188 if (copy_from_user(&ksp, usp, sizeof(ksp)))
@@ -1191,7 +1198,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 9 unmodified lines
11911198 break;
11921199 }
11931200 case PKEY_CLR2PROTK: {
1194− struct pkey_clr2protk __user *ucp = (void __user *) arg;
1201+ struct pkey_clr2protk __user *ucp = (void __user *)arg;
11951202 struct pkey_clr2protk kcp;
11961203
11971204 if (copy_from_user(&kcp, ucp, sizeof(kcp)))
@@ -1207,7 +1214,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 9 unmodified lines
12071214 break;
12081215 }
12091216 case PKEY_FINDCARD: {
1210− struct pkey_findcard __user *ufc = (void __user *) arg;
1217+ struct pkey_findcard __user *ufc = (void __user *)arg;
12111218 struct pkey_findcard kfc;
12121219
12131220 if (copy_from_user(&kfc, ufc, sizeof(kfc)))
@@ -1222,7 +1229,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 8 unmodified lines
12221229 break;
12231230 }
12241231 case PKEY_SKEY2PKEY: {
1225− struct pkey_skey2pkey __user *usp = (void __user *) arg;
1232+ struct pkey_skey2pkey __user *usp = (void __user *)arg;
12261233 struct pkey_skey2pkey ksp;
12271234
12281235 if (copy_from_user(&ksp, usp, sizeof(ksp)))
@@ -1236,7 +1243,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 7 unmodified lines
12361243 break;
12371244 }
12381245 case PKEY_VERIFYKEY: {
1239− struct pkey_verifykey __user *uvk = (void __user *) arg;
1246+ struct pkey_verifykey __user *uvk = (void __user *)arg;
12401247 struct pkey_verifykey kvk;
12411248
12421249 if (copy_from_user(&kvk, uvk, sizeof(kvk)))
@@ -1251,7 +1258,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 8 unmodified lines
12511258 break;
12521259 }
12531260 case PKEY_GENPROTK: {
1254− struct pkey_genprotk __user *ugp = (void __user *) arg;
1261+ struct pkey_genprotk __user *ugp = (void __user *)arg;
12551262 struct pkey_genprotk kgp;
12561263
12571264 if (copy_from_user(&kgp, ugp, sizeof(kgp)))
@@ -1265,7 +1272,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 7 unmodified lines
12651272 break;
12661273 }
12671274 case PKEY_VERIFYPROTK: {
1268− struct pkey_verifyprotk __user *uvp = (void __user *) arg;
1275+ struct pkey_verifyprotk __user *uvp = (void __user *)arg;
12691276 struct pkey_verifyprotk kvp;
12701277
12711278 if (copy_from_user(&kvp, uvp, sizeof(kvp)))
@@ -1275,7 +1282,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 3 unmodified lines
12751282 break;
12761283 }
12771284 case PKEY_KBLOB2PROTK: {
1278− struct pkey_kblob2pkey __user *utp = (void __user *) arg;
1285+ struct pkey_kblob2pkey __user *utp = (void __user *)arg;
12791286 struct pkey_kblob2pkey ktp;
12801287 u8 *kkey;
12811288
@@ -1294,7 +1301,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 12 unmodified lines
12941301 break;
12951302 }
12961303 case PKEY_GENSECK2: {
1297− struct pkey_genseck2 __user *ugs = (void __user *) arg;
1304+ struct pkey_genseck2 __user *ugs = (void __user *)arg;
12981305 struct pkey_genseck2 kgs;
12991306 struct pkey_apqn *apqns;
13001307 size_t klen = KEYBLOBBUFSIZE;
@@ -1336,7 +1343,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 35 unmodified lines
13361343 break;
13371344 }
13381345 case PKEY_CLR2SECK2: {
1339− struct pkey_clr2seck2 __user *ucs = (void __user *) arg;
1346+ struct pkey_clr2seck2 __user *ucs = (void __user *)arg;
13401347 struct pkey_clr2seck2 kcs;
13411348 struct pkey_apqn *apqns;
13421349 size_t klen = KEYBLOBBUFSIZE;
@@ -1379,7 +1386,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 36 unmodified lines
13791386 break;
13801387 }
13811388 case PKEY_VERIFYKEY2: {
1382− struct pkey_verifykey2 __user *uvk = (void __user *) arg;
1389+ struct pkey_verifykey2 __user *uvk = (void __user *)arg;
13831390 struct pkey_verifykey2 kvk;
13841391 u8 *kkey;
13851392
@@ -1400,7 +1407,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 14 unmodified lines
14001407 break;
14011408 }
14021409 case PKEY_KBLOB2PROTK2: {
1403− struct pkey_kblob2pkey2 __user *utp = (void __user *) arg;
1410+ struct pkey_kblob2pkey2 __user *utp = (void __user *)arg;
14041411 struct pkey_kblob2pkey2 ktp;
14051412 struct pkey_apqn *apqns = NULL;
14061413 u8 *kkey;
@@ -1427,7 +1434,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 20 unmodified lines
14271434 break;
14281435 }
14291436 case PKEY_APQNS4K: {
1430− struct pkey_apqns4key __user *uak = (void __user *) arg;
1437+ struct pkey_apqns4key __user *uak = (void __user *)arg;
14311438 struct pkey_apqns4key kak;
14321439 struct pkey_apqn *apqns = NULL;
14331440 size_t nr_apqns, len;
@@ -1476,7 +1483,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 42 unmodified lines
14761483 break;
14771484 }
14781485 case PKEY_APQNS4KT: {
1479− struct pkey_apqns4keytype __user *uat = (void __user *) arg;
1486+ struct pkey_apqns4keytype __user *uat = (void __user *)arg;
14801487 struct pkey_apqns4keytype kat;
14811488 struct pkey_apqn *apqns = NULL;
14821489 size_t nr_apqns, len;
@@ -1518,7 +1525,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 35 unmodified lines
15181525 break;
15191526 }
15201527 case PKEY_KBLOB2PROTK3: {
1521− struct pkey_kblob2pkey3 __user *utp = (void __user *) arg;
1528+ struct pkey_kblob2pkey3 __user *utp = (void __user *)arg;
15221529 struct pkey_kblob2pkey3 ktp;
15231530 struct pkey_apqn *apqns = NULL;
15241531 u32 protkeylen = PROTKEYBLOBBUFSIZE;
@@ -1708,7 +1715,7 @@ static ssize_t pkey_ccadata_aes_attr_read(u32 keytype, bool is_xts, char *buf, · 183 unmodified lines
17081715 loff_t off, size_t count)
17091716 {
17101717 int rc;
1711− struct pkey_seckey *seckey = (struct pkey_seckey *) buf;
1718+ struct pkey_seckey *seckey = (struct pkey_seckey *)buf;
17121719
17131720 if (off != 0 || count < sizeof(struct secaeskeytoken))
17141721 return -EINVAL;
drivers/s390/crypto/vfio_ap_drv.c+0−2
@@ -46,8 +46,6 @@ static struct ap_device_id ap_queue_ids[] = { · 45 unmodified lines
4646 { /* end of sibling */ },
4747 };
4848
49−MODULE_DEVICE_TABLE(vfio_ap, ap_queue_ids);
50−
5149 static struct ap_matrix_mdev *vfio_ap_mdev_for_queue(struct vfio_ap_queue *q)
5250 {
5351 struct ap_matrix_mdev *matrix_mdev;
drivers/s390/crypto/zcrypt_api.c+108−107
@@ -104,7 +104,7 @@ struct zcrypt_ops *zcrypt_msgtype(unsigned char *name, int variant) · 103 unmodified lines
104104 struct zcrypt_ops *zops;
105105
106106 list_for_each_entry(zops, &zcrypt_ops_list, list)
107− if ((zops->variant == variant) &&
107+ if (zops->variant == variant &&
108108 (!strncmp(zops->name, name, sizeof(zops->name))))
109109 return zops;
110110 return NULL;
@@ -438,8 +438,8 @@ static int zcdn_create(const char *name) · 327 unmodified lines
438438 strncpy(nodename, name, sizeof(nodename));
439439 else
440440 snprintf(nodename, sizeof(nodename),
441− ZCRYPT_NAME "_%d", (int) MINOR(devt));
442− nodename[sizeof(nodename)-1] = '\0';
441+ ZCRYPT_NAME "_%d", (int)MINOR(devt));
442+ nodename[sizeof(nodename) - 1] = '\0';
443443 if (dev_set_name(&zcdndev->device, nodename)) {
444444 rc = -EINVAL;
445445 goto unlockout;
@@ -519,7 +519,7 @@ static ssize_t zcrypt_read(struct file *filp, char __user *buf, · 73 unmodified lines
519519 /*
520520 * zcrypt_write(): Not allowed.
521521 *
522− * Write is is not allowed
522+ * Write is not allowed
523523 */
524524 static ssize_t zcrypt_write(struct file *filp, const char __user *buf,
525525 size_t count, loff_t *f_pos)
@@ -549,7 +549,7 @@ static int zcrypt_open(struct inode *inode, struct file *filp) · 23 unmodified lines
549549 perms = &zcdndev->perms;
550550 }
551551 #endif
552− filp->private_data = (void *) perms;
552+ filp->private_data = (void *)perms;
553553
554554 atomic_inc(&zcrypt_open_count);
555555 return stream_open(inode, filp);
@@ -713,7 +713,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms, · 157 unmodified lines
713713 pref_zq = NULL;
714714 spin_lock(&zcrypt_list_lock);
715715 for_each_zcrypt_card(zc) {
716− /* Check for useable accelarator or CCA card */
716+ /* Check for usable accelarator or CCA card */
717717 if (!zc->online || !zc->card->config || zc->card->chkstop ||
718718 !(zc->card->functions & 0x18000000))
719719 continue;
@@ -733,7 +733,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms, · 13 unmodified lines
733733 if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt))
734734 continue;
735735 for_each_zcrypt_queue(zq, zc) {
736− /* check if device is useable and eligible */
736+ /* check if device is usable and eligible */
737737 if (!zq->online || !zq->ops->rsa_modexpo ||
738738 !zq->queue->config || zq->queue->chkstop)
739739 continue;
@@ -823,7 +823,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms, · 83 unmodified lines
823823 pref_zq = NULL;
824824 spin_lock(&zcrypt_list_lock);
825825 for_each_zcrypt_card(zc) {
826− /* Check for useable accelarator or CCA card */
826+ /* Check for usable accelarator or CCA card */
827827 if (!zc->online || !zc->card->config || zc->card->chkstop ||
828828 !(zc->card->functions & 0x18000000))
829829 continue;
@@ -843,7 +843,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms, · 13 unmodified lines
843843 if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt))
844844 continue;
845845 for_each_zcrypt_queue(zq, zc) {
846− /* check if device is useable and eligible */
846+ /* check if device is usable and eligible */
847847 if (!zq->online || !zq->ops->rsa_modexpo_crt ||
848848 !zq->queue->config || zq->queue->chkstop)
849849 continue;
@@ -893,7 +893,7 @@ out: · 43 unmodified lines
893893
894894 static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms,
895895 struct zcrypt_track *tr,
896− struct ica_xcRB *xcRB)
896+ struct ica_xcRB *xcrb)
897897 {
898898 struct zcrypt_card *zc, *pref_zc;
899899 struct zcrypt_queue *zq, *pref_zq;
@@ -904,9 +904,9 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 4 unmodified lines
904904 int cpen, qpen, qid = 0, rc = -ENODEV;
905905 struct module *mod;
906906
907− trace_s390_zcrypt_req(xcRB, TB_ZSECSENDCPRB);
907+ trace_s390_zcrypt_req(xcrb, TB_ZSECSENDCPRB);
908908
909− xcRB->status = 0;
909+ xcrb->status = 0;
910910 ap_init_message(&ap_msg);
911911
912912 #ifdef CONFIG_ZCRYPT_DEBUG
@@ -915,11 +915,11 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 2 unmodified lines
915915 if (tr && tr->fi.action == AP_FI_ACTION_CCA_AGENT_FF) {
916916 ZCRYPT_DBF_WARN("%s fi cmd 0x%04x: forcing invalid agent_ID 'FF'\n",
917917 __func__, tr->fi.cmd);
918− xcRB->agent_ID = 0x4646;
918+ xcrb->agent_ID = 0x4646;
919919 }
920920 #endif
921921
922− rc = prep_cca_ap_msg(userspace, xcRB, &ap_msg, &func_code, &domain);
922+ rc = prep_cca_ap_msg(userspace, xcrb, &ap_msg, &func_code, &domain);
923923 if (rc)
924924 goto out;
925925
@@ -948,13 +948,13 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 22 unmodified lines
948948 pref_zq = NULL;
949949 spin_lock(&zcrypt_list_lock);
950950 for_each_zcrypt_card(zc) {
951− /* Check for useable CCA card */
951+ /* Check for usable CCA card */
952952 if (!zc->online || !zc->card->config || zc->card->chkstop ||
953953 !(zc->card->functions & 0x10000000))
954954 continue;
955955 /* Check for user selected CCA card */
956− if (xcRB->user_defined != AUTOSELECT &&
957− xcRB->user_defined != zc->card->id)
956+ if (xcrb->user_defined != AUTOSELECT &&
957+ xcrb->user_defined != zc->card->id)
958958 continue;
959959 /* check if request size exceeds card max msg size */
960960 if (ap_msg.len > zc->card->maxmsgsize)
@@ -971,7 +971,7 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 10 unmodified lines
971971 if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt))
972972 continue;
973973 for_each_zcrypt_queue(zq, zc) {
974− /* check for device useable and eligible */
974+ /* check for device usable and eligible */
975975 if (!zq->online || !zq->ops->send_cprb ||
976976 !zq->queue->config || zq->queue->chkstop ||
977977 (tdom != AUTOSEL_DOM &&
@@ -998,7 +998,7 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 20 unmodified lines
998998
999999 if (!pref_zq) {
10001000 ZCRYPT_DBF_DBG("%s no match for address %02x.%04x => ENODEV\n",
1001− __func__, xcRB->user_defined, *domain);
1001+ __func__, xcrb->user_defined, *domain);
10021002 rc = -ENODEV;
10031003 goto out;
10041004 }
@@ -1016,7 +1016,7 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 11 unmodified lines
10161016 }
10171017 #endif
10181018
1019− rc = pref_zq->ops->send_cprb(userspace, pref_zq, xcRB, &ap_msg);
1019+ rc = pref_zq->ops->send_cprb(userspace, pref_zq, xcrb, &ap_msg);
10201020
10211021 spin_lock(&zcrypt_list_lock);
10221022 zcrypt_drop_queue(pref_zc, pref_zq, mod, wgt);
@@ -1028,14 +1028,14 @@ out: · 5 unmodified lines
10281028 tr->last_rc = rc;
10291029 tr->last_qid = qid;
10301030 }
1031− trace_s390_zcrypt_rep(xcRB, func_code, rc,
1031+ trace_s390_zcrypt_rep(xcrb, func_code, rc,
10321032 AP_QID_CARD(qid), AP_QID_QUEUE(qid));
10331033 return rc;
10341034 }
10351035
1036−long zcrypt_send_cprb(struct ica_xcRB *xcRB)
1036+long zcrypt_send_cprb(struct ica_xcRB *xcrb)
10371037 {
1038− return _zcrypt_send_cprb(false, &ap_perms, NULL, xcRB);
1038+ return _zcrypt_send_cprb(false, &ap_perms, NULL, xcrb);
10391039 }
10401040 EXPORT_SYMBOL(zcrypt_send_cprb);
10411041
@@ -1089,7 +1089,7 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 47 unmodified lines
10891089 ap_msg.fi.cmd = tr->fi.cmd;
10901090 #endif
10911091
1092− target_num = (unsigned short) xcrb->targets_num;
1092+ target_num = (unsigned short)xcrb->targets_num;
10931093
10941094 /* empty list indicates autoselect (all available targets) */
10951095 targets = NULL;
@@ -1103,9 +1103,9 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 7 unmodified lines
11031103 goto out;
11041104 }
11051105
1106− uptr = (struct ep11_target_dev __force __user *) xcrb->targets;
1106+ uptr = (struct ep11_target_dev __force __user *)xcrb->targets;
11071107 if (z_copy_from_user(userspace, targets, uptr,
1108− target_num * sizeof(*targets))) {
1108+ target_num * sizeof(*targets))) {
11091109 func_code = 0;
11101110 rc = -EFAULT;
11111111 goto out_free;
@@ -1132,7 +1132,7 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 20 unmodified lines
11321132 pref_zq = NULL;
11331133 spin_lock(&zcrypt_list_lock);
11341134 for_each_zcrypt_card(zc) {
1135− /* Check for useable EP11 card */
1135+ /* Check for usable EP11 card */
11361136 if (!zc->online || !zc->card->config || zc->card->chkstop ||
11371137 !(zc->card->functions & 0x04000000))
11381138 continue;
@@ -1155,7 +1155,7 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 16 unmodified lines
11551155 if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt))
11561156 continue;
11571157 for_each_zcrypt_queue(zq, zc) {
1158− /* check if device is useable and eligible */
1158+ /* check if device is usable and eligible */
11591159 if (!zq->online || !zq->ops->send_ep11_cprb ||
11601160 !zq->queue->config || zq->queue->chkstop ||
11611161 (targets &&
@@ -1184,11 +1184,11 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 22 unmodified lines
11841184 if (!pref_zq) {
11851185 if (targets && target_num == 1) {
11861186 ZCRYPT_DBF_DBG("%s no match for address %02x.%04x => ENODEV\n",
1187− __func__, (int) targets->ap_id,
1188− (int) targets->dom_id);
1187+ __func__, (int)targets->ap_id,
1188+ (int)targets->dom_id);
11891189 } else if (targets) {
11901190 ZCRYPT_DBF_DBG("%s no match for %d target addrs => ENODEV\n",
1191− __func__, (int) target_num);
1191+ __func__, (int)target_num);
11921192 } else {
11931193 ZCRYPT_DBF_DBG("%s no match for address ff.ffff => ENODEV\n",
11941194 __func__);
@@ -1245,7 +1245,7 @@ static long zcrypt_rng(char *buffer) · 50 unmodified lines
12451245 pref_zq = NULL;
12461246 spin_lock(&zcrypt_list_lock);
12471247 for_each_zcrypt_card(zc) {
1248− /* Check for useable CCA card */
1248+ /* Check for usable CCA card */
12491249 if (!zc->online || !zc->card->config || zc->card->chkstop ||
12501250 !(zc->card->functions & 0x10000000))
12511251 continue;
@@ -1254,7 +1254,7 @@ static long zcrypt_rng(char *buffer) · 2 unmodified lines
12541254 if (!zcrypt_card_compare(zc, pref_zc, wgt, pref_wgt))
12551255 continue;
12561256 for_each_zcrypt_queue(zq, zc) {
1257− /* check if device is useable and eligible */
1257+ /* check if device is usable and eligible */
12581258 if (!zq->online || !zq->ops->rng ||
12591259 !zq->queue->config || zq->queue->chkstop)
12601260 continue;
@@ -1270,7 +1270,7 @@ static long zcrypt_rng(char *buffer) · 9 unmodified lines
12701270
12711271 if (!pref_zq) {
12721272 ZCRYPT_DBF_DBG("%s no matching queue found => ENODEV\n",
1273− __func__);
1273+ __func__);
12741274 rc = -ENODEV;
12751275 goto out;
12761276 }
@@ -1381,8 +1381,8 @@ static void zcrypt_status_mask(char status[], size_t max_adapters) · 104 unmodified lines
13811381 for_each_zcrypt_card(zc) {
13821382 for_each_zcrypt_queue(zq, zc) {
13831383 card = AP_QID_CARD(zq->queue->qid);
1384− if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index
1385− || card >= max_adapters)
1384+ if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index ||
1385+ card >= max_adapters)
13861386 continue;
13871387 status[card] = zc->online ? zc->user_space_type : 0x0d;
13881388 }
@@ -1402,8 +1402,8 @@ static void zcrypt_qdepth_mask(char qdepth[], size_t max_adapters) · 13 unmodified lines
14021402 for_each_zcrypt_card(zc) {
14031403 for_each_zcrypt_queue(zq, zc) {
14041404 card = AP_QID_CARD(zq->queue->qid);
1405− if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index
1406− || card >= max_adapters)
1405+ if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index ||
1406+ card >= max_adapters)
14071407 continue;
14081408 spin_lock(&zq->queue->lock);
14091409 qdepth[card] =
@@ -1429,13 +1429,13 @@ static void zcrypt_perdev_reqcnt(u32 reqcnt[], size_t max_adapters) · 19 unmodified lines
14291429 for_each_zcrypt_card(zc) {
14301430 for_each_zcrypt_queue(zq, zc) {
14311431 card = AP_QID_CARD(zq->queue->qid);
1432− if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index
1433− || card >= max_adapters)
1432+ if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index ||
1433+ card >= max_adapters)
14341434 continue;
14351435 spin_lock(&zq->queue->lock);
14361436 cnt = zq->queue->total_request_count;
14371437 spin_unlock(&zq->queue->lock);
1438− reqcnt[card] = (cnt < UINT_MAX) ? (u32) cnt : UINT_MAX;
1438+ reqcnt[card] = (cnt < UINT_MAX) ? (u32)cnt : UINT_MAX;
14391439 }
14401440 }
14411441 local_bh_enable();
@@ -1493,7 +1493,7 @@ static int icarsamodexpo_ioctl(struct ap_perms *perms, unsigned long arg) · 51 unmodified lines
14931493 int rc;
14941494 struct zcrypt_track tr;
14951495 struct ica_rsa_modexpo mex;
1496− struct ica_rsa_modexpo __user *umex = (void __user *) arg;
1496+ struct ica_rsa_modexpo __user *umex = (void __user *)arg;
14971497
14981498 memset(&tr, 0, sizeof(tr));
14991499 if (copy_from_user(&mex, umex, sizeof(mex)))
@@ -1538,7 +1538,7 @@ static int icarsacrt_ioctl(struct ap_perms *perms, unsigned long arg) · 38 unmodified lines
15381538 int rc;
15391539 struct zcrypt_track tr;
15401540 struct ica_rsa_modexpo_crt crt;
1541− struct ica_rsa_modexpo_crt __user *ucrt = (void __user *) arg;
1541+ struct ica_rsa_modexpo_crt __user *ucrt = (void __user *)arg;
15421542
15431543 memset(&tr, 0, sizeof(tr));
15441544 if (copy_from_user(&crt, ucrt, sizeof(crt)))
@@ -1581,25 +1581,25 @@ static int icarsacrt_ioctl(struct ap_perms *perms, unsigned long arg) · 36 unmodified lines
15811581 static int zsecsendcprb_ioctl(struct ap_perms *perms, unsigned long arg)
15821582 {
15831583 int rc;
1584− struct ica_xcRB xcRB;
1584+ struct ica_xcRB xcrb;
15851585 struct zcrypt_track tr;
1586− struct ica_xcRB __user *uxcRB = (void __user *) arg;
1586+ struct ica_xcRB __user *uxcrb = (void __user *)arg;
15871587
15881588 memset(&tr, 0, sizeof(tr));
1589− if (copy_from_user(&xcRB, uxcRB, sizeof(xcRB)))
1589+ if (copy_from_user(&xcrb, uxcrb, sizeof(xcrb)))
15901590 return -EFAULT;
15911591
15921592 #ifdef CONFIG_ZCRYPT_DEBUG
1593− if ((xcRB.status & 0x8000FFFF) == 0x80004649 /* 'FI' */) {
1593+ if ((xcrb.status & 0x8000FFFF) == 0x80004649 /* 'FI' */) {
15941594 if (!capable(CAP_SYS_ADMIN))
15951595 return -EPERM;
1596− tr.fi.cmd = (u16)(xcRB.status >> 16);
1596+ tr.fi.cmd = (u16)(xcrb.status >> 16);
15971597 }
1598− xcRB.status = 0;
1598+ xcrb.status = 0;
15991599 #endif
16001600
16011601 do {
1602− rc = _zcrypt_send_cprb(true, perms, &tr, &xcRB);
1602+ rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb);
16031603 if (rc == -EAGAIN)
16041604 tr.again_counter++;
16051605 #ifdef CONFIG_ZCRYPT_DEBUG
@@ -1610,7 +1610,7 @@ static int zsecsendcprb_ioctl(struct ap_perms *perms, unsigned long arg) · 4 unmodified lines
16101610 /* on failure: retry once again after a requested rescan */
16111611 if ((rc == -ENODEV) && (zcrypt_process_rescan()))
16121612 do {
1613− rc = _zcrypt_send_cprb(true, perms, &tr, &xcRB);
1613+ rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb);
16141614 if (rc == -EAGAIN)
16151615 tr.again_counter++;
16161616 } while (rc == -EAGAIN && tr.again_counter < TRACK_AGAIN_MAX);
@@ -1618,8 +1618,8 @@ static int zsecsendcprb_ioctl(struct ap_perms *perms, unsigned long arg) · 1 unmodified line
16181618 rc = -EIO;
16191619 if (rc)
16201620 ZCRYPT_DBF_DBG("ioctl ZSENDCPRB rc=%d status=0x%x\n",
1621− rc, xcRB.status);
1622− if (copy_to_user(uxcRB, &xcRB, sizeof(xcRB)))
1621+ rc, xcrb.status);
1622+ if (copy_to_user(uxcrb, &xcrb, sizeof(xcrb)))
16231623 return -EFAULT;
16241624 return rc;
16251625 }
@@ -1674,7 +1674,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 48 unmodified lines
16741674 {
16751675 int rc;
16761676 struct ap_perms *perms =
1677− (struct ap_perms *) filp->private_data;
1677+ (struct ap_perms *)filp->private_data;
16781678
16791679 rc = zcrypt_check_ioctl(perms, cmd);
16801680 if (rc)
@@ -1698,7 +1698,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 17 unmodified lines
16981698 if (!device_status)
16991699 return -ENOMEM;
17001700 zcrypt_device_status_mask_ext(device_status);
1701− if (copy_to_user((char __user *) arg, device_status,
1701+ if (copy_to_user((char __user *)arg, device_status,
17021702 total_size))
17031703 rc = -EFAULT;
17041704 kfree(device_status);
@@ -1708,7 +1708,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 3 unmodified lines
17081708 char status[AP_DEVICES];
17091709
17101710 zcrypt_status_mask(status, AP_DEVICES);
1711− if (copy_to_user((char __user *) arg, status, sizeof(status)))
1711+ if (copy_to_user((char __user *)arg, status, sizeof(status)))
17121712 return -EFAULT;
17131713 return 0;
17141714 }
@@ -1716,7 +1716,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 1 unmodified line
17161716 char qdepth[AP_DEVICES];
17171717
17181718 zcrypt_qdepth_mask(qdepth, AP_DEVICES);
1719− if (copy_to_user((char __user *) arg, qdepth, sizeof(qdepth)))
1719+ if (copy_to_user((char __user *)arg, qdepth, sizeof(qdepth)))
17201720 return -EFAULT;
17211721 return 0;
17221722 }
@@ -1727,21 +1727,21 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 4 unmodified lines
17271727 if (!reqcnt)
17281728 return -ENOMEM;
17291729 zcrypt_perdev_reqcnt(reqcnt, AP_DEVICES);
1730− if (copy_to_user((int __user *) arg, reqcnt,
1730+ if (copy_to_user((int __user *)arg, reqcnt,
17311731 sizeof(u32) * AP_DEVICES))
17321732 rc = -EFAULT;
17331733 kfree(reqcnt);
17341734 return rc;
17351735 }
17361736 case Z90STAT_REQUESTQ_COUNT:
1737− return put_user(zcrypt_requestq_count(), (int __user *) arg);
1737+ return put_user(zcrypt_requestq_count(), (int __user *)arg);
17381738 case Z90STAT_PENDINGQ_COUNT:
1739− return put_user(zcrypt_pendingq_count(), (int __user *) arg);
1739+ return put_user(zcrypt_pendingq_count(), (int __user *)arg);
17401740 case Z90STAT_TOTALOPEN_COUNT:
17411741 return put_user(atomic_read(&zcrypt_open_count),
1742− (int __user *) arg);
1742+ (int __user *)arg);
17431743 case Z90STAT_DOMAIN_INDEX:
1744− return put_user(ap_domain_index, (int __user *) arg);
1744+ return put_user(ap_domain_index, (int __user *)arg);
17451745 /*
17461746 * Deprecated ioctls
17471747 */
@@ -1755,7 +1755,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 7 unmodified lines
17551755 if (!device_status)
17561756 return -ENOMEM;
17571757 zcrypt_device_status_mask(device_status);
1758− if (copy_to_user((char __user *) arg, device_status,
1758+ if (copy_to_user((char __user *)arg, device_status,
17591759 total_size))
17601760 rc = -EFAULT;
17611761 kfree(device_status);
@@ -1766,7 +1766,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 4 unmodified lines
17661766 char status[MAX_ZDEV_CARDIDS];
17671767
17681768 zcrypt_status_mask(status, MAX_ZDEV_CARDIDS);
1769− if (copy_to_user((char __user *) arg, status, sizeof(status)))
1769+ if (copy_to_user((char __user *)arg, status, sizeof(status)))
17701770 return -EFAULT;
17711771 return 0;
17721772 }
@@ -1775,7 +1775,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 2 unmodified lines
17751775 char qdepth[MAX_ZDEV_CARDIDS];
17761776
17771777 zcrypt_qdepth_mask(qdepth, MAX_ZDEV_CARDIDS);
1778− if (copy_to_user((char __user *) arg, qdepth, sizeof(qdepth)))
1778+ if (copy_to_user((char __user *)arg, qdepth, sizeof(qdepth)))
17791779 return -EFAULT;
17801780 return 0;
17811781 }
@@ -1784,7 +1784,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 2 unmodified lines
17841784 u32 reqcnt[MAX_ZDEV_CARDIDS];
17851785
17861786 zcrypt_perdev_reqcnt(reqcnt, MAX_ZDEV_CARDIDS);
1787− if (copy_to_user((int __user *) arg, reqcnt, sizeof(reqcnt)))
1787+ if (copy_to_user((int __user *)arg, reqcnt, sizeof(reqcnt)))
17881788 return -EFAULT;
17891789 return 0;
17901790 }
@@ -1899,7 +1899,7 @@ static long trans_modexpo_crt32(struct ap_perms *perms, struct file *filp, · 108 unmodified lines
18991899 &ucrt32->outputdatalength);
19001900 }
19011901
1902−struct compat_ica_xcRB {
1902+struct compat_ica_xcrb {
19031903 unsigned short agent_ID;
19041904 unsigned int user_defined;
19051905 unsigned short request_ID;
@@ -1919,66 +1919,66 @@ struct compat_ica_xcRB { · 13 unmodified lines
19191919 unsigned int status;
19201920 } __packed;
19211921
1922−static long trans_xcRB32(struct ap_perms *perms, struct file *filp,
1922+static long trans_xcrb32(struct ap_perms *perms, struct file *filp,
19231923 unsigned int cmd, unsigned long arg)
19241924 {
1925− struct compat_ica_xcRB __user *uxcRB32 = compat_ptr(arg);
1926− struct compat_ica_xcRB xcRB32;
1925+ struct compat_ica_xcrb __user *uxcrb32 = compat_ptr(arg);
1926+ struct compat_ica_xcrb xcrb32;
19271927 struct zcrypt_track tr;
1928− struct ica_xcRB xcRB64;
1928+ struct ica_xcRB xcrb64;
19291929 long rc;
19301930
19311931 memset(&tr, 0, sizeof(tr));
1932− if (copy_from_user(&xcRB32, uxcRB32, sizeof(xcRB32)))
1932+ if (copy_from_user(&xcrb32, uxcrb32, sizeof(xcrb32)))
19331933 return -EFAULT;
1934− xcRB64.agent_ID = xcRB32.agent_ID;
1935− xcRB64.user_defined = xcRB32.user_defined;
1936− xcRB64.request_ID = xcRB32.request_ID;
1937− xcRB64.request_control_blk_length =
1938− xcRB32.request_control_blk_length;
1939− xcRB64.request_control_blk_addr =
1940− compat_ptr(xcRB32.request_control_blk_addr);
1941− xcRB64.request_data_length =
1942− xcRB32.request_data_length;
1943− xcRB64.request_data_address =
1944− compat_ptr(xcRB32.request_data_address);
1945− xcRB64.reply_control_blk_length =
1946− xcRB32.reply_control_blk_length;
1947− xcRB64.reply_control_blk_addr =
1948− compat_ptr(xcRB32.reply_control_blk_addr);
1949− xcRB64.reply_data_length = xcRB32.reply_data_length;
1950− xcRB64.reply_data_addr =
1951− compat_ptr(xcRB32.reply_data_addr);
1952− xcRB64.priority_window = xcRB32.priority_window;
1953− xcRB64.status = xcRB32.status;
1934+ xcrb64.agent_ID = xcrb32.agent_ID;
1935+ xcrb64.user_defined = xcrb32.user_defined;
1936+ xcrb64.request_ID = xcrb32.request_ID;
1937+ xcrb64.request_control_blk_length =
1938+ xcrb32.request_control_blk_length;
1939+ xcrb64.request_control_blk_addr =
1940+ compat_ptr(xcrb32.request_control_blk_addr);
1941+ xcrb64.request_data_length =
1942+ xcrb32.request_data_length;
1943+ xcrb64.request_data_address =
1944+ compat_ptr(xcrb32.request_data_address);
1945+ xcrb64.reply_control_blk_length =
1946+ xcrb32.reply_control_blk_length;
1947+ xcrb64.reply_control_blk_addr =
1948+ compat_ptr(xcrb32.reply_control_blk_addr);
1949+ xcrb64.reply_data_length = xcrb32.reply_data_length;
1950+ xcrb64.reply_data_addr =
1951+ compat_ptr(xcrb32.reply_data_addr);
1952+ xcrb64.priority_window = xcrb32.priority_window;
1953+ xcrb64.status = xcrb32.status;
19541954 do {
1955− rc = _zcrypt_send_cprb(true, perms, &tr, &xcRB64);
1955+ rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb64);
19561956 if (rc == -EAGAIN)
19571957 tr.again_counter++;
19581958 } while (rc == -EAGAIN && tr.again_counter < TRACK_AGAIN_MAX);
19591959 /* on failure: retry once again after a requested rescan */
19601960 if ((rc == -ENODEV) && (zcrypt_process_rescan()))
19611961 do {
1962− rc = _zcrypt_send_cprb(true, perms, &tr, &xcRB64);
1962+ rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb64);
19631963 if (rc == -EAGAIN)
19641964 tr.again_counter++;
19651965 } while (rc == -EAGAIN && tr.again_counter < TRACK_AGAIN_MAX);
19661966 if (rc == -EAGAIN && tr.again_counter >= TRACK_AGAIN_MAX)
19671967 rc = -EIO;
1968− xcRB32.reply_control_blk_length = xcRB64.reply_control_blk_length;
1969− xcRB32.reply_data_length = xcRB64.reply_data_length;
1970− xcRB32.status = xcRB64.status;
1971− if (copy_to_user(uxcRB32, &xcRB32, sizeof(xcRB32)))
1968+ xcrb32.reply_control_blk_length = xcrb64.reply_control_blk_length;
1969+ xcrb32.reply_data_length = xcrb64.reply_data_length;
1970+ xcrb32.status = xcrb64.status;
1971+ if (copy_to_user(uxcrb32, &xcrb32, sizeof(xcrb32)))
19721972 return -EFAULT;
19731973 return rc;
19741974 }
19751975
19761976 static long zcrypt_compat_ioctl(struct file *filp, unsigned int cmd,
1977− unsigned long arg)
1977+ unsigned long arg)
19781978 {
19791979 int rc;
19801980 struct ap_perms *perms =
1981− (struct ap_perms *) filp->private_data;
1981+ (struct ap_perms *)filp->private_data;
19821982
19831983 rc = zcrypt_check_ioctl(perms, cmd);
19841984 if (rc)
@@ -1989,7 +1989,7 @@ static long zcrypt_compat_ioctl(struct file *filp, unsigned int cmd, · 4 unmodified lines
19891989 if (cmd == ICARSACRT)
19901990 return trans_modexpo_crt32(perms, filp, cmd, arg);
19911991 if (cmd == ZSECSENDCPRB)
1992− return trans_xcRB32(perms, filp, cmd, arg);
1992+ return trans_xcrb32(perms, filp, cmd, arg);
19931993 return zcrypt_unlocked_ioctl(filp, cmd, arg);
19941994 }
19951995 #endif
@@ -2033,10 +2033,10 @@ static int zcrypt_rng_data_read(struct hwrng *rng, u32 *data) · 37 unmodified lines
20332033 * read method calls.
20342034 */
20352035 if (zcrypt_rng_buffer_index == 0) {
2036− rc = zcrypt_rng((char *) zcrypt_rng_buffer);
2036+ rc = zcrypt_rng((char *)zcrypt_rng_buffer);
20372037 /* on failure: retry once again after a requested rescan */
20382038 if ((rc == -ENODEV) && (zcrypt_process_rescan()))
2039− rc = zcrypt_rng((char *) zcrypt_rng_buffer);
2039+ rc = zcrypt_rng((char *)zcrypt_rng_buffer);
20402040 if (rc < 0)
20412041 return -EIO;
20422042 zcrypt_rng_buffer_index = rc / sizeof(*data);
@@ -2057,7 +2057,7 @@ int zcrypt_rng_device_add(void) · 14 unmodified lines
20572057
20582058 mutex_lock(&zcrypt_rng_mutex);
20592059 if (zcrypt_rng_device_count == 0) {
2060− zcrypt_rng_buffer = (u32 *) get_zeroed_page(GFP_KERNEL);
2060+ zcrypt_rng_buffer = (u32 *)get_zeroed_page(GFP_KERNEL);
20612061 if (!zcrypt_rng_buffer) {
20622062 rc = -ENOMEM;
20632063 goto out;
@@ -2069,13 +2069,14 @@ int zcrypt_rng_device_add(void) · 5 unmodified lines
20692069 if (rc)
20702070 goto out_free;
20712071 zcrypt_rng_device_count = 1;
2072− } else
2072+ } else {
20732073 zcrypt_rng_device_count++;
2074+ }
20742075 mutex_unlock(&zcrypt_rng_mutex);
20752076 return 0;
20762077
20772078 out_free:
2078− free_page((unsigned long) zcrypt_rng_buffer);
2079+ free_page((unsigned long)zcrypt_rng_buffer);
20792080 out:
20802081 mutex_unlock(&zcrypt_rng_mutex);
20812082 return rc;
@@ -2087,7 +2088,7 @@ void zcrypt_rng_device_remove(void) · 5 unmodified lines
20872088 zcrypt_rng_device_count--;
20882089 if (zcrypt_rng_device_count == 0) {
20892090 hwrng_unregister(&zcrypt_rng_dev);
2090− free_page((unsigned long) zcrypt_rng_buffer);
2091+ free_page((unsigned long)zcrypt_rng_buffer);
20912092 }
20922093 mutex_unlock(&zcrypt_rng_mutex);
20932094 }
drivers/s390/crypto/zcrypt_api.h+2−2
@@ -170,7 +170,7 @@ static inline unsigned long z_copy_from_user(bool userspace, · 169 unmodified lines
170170 {
171171 if (likely(userspace))
172172 return copy_from_user(to, from, n);
173− memcpy(to, (void __force *) from, n);
173+ memcpy(to, (void __force *)from, n);
174174 return 0;
175175 }
176176
@@ -181,7 +181,7 @@ static inline unsigned long z_copy_to_user(bool userspace, · 4 unmodified lines
181181 {
182182 if (likely(userspace))
183183 return copy_to_user(to, from, n);
184− memcpy((void __force *) to, from, n);
184+ memcpy((void __force *)to, from, n);
185185 return 0;
186186 }
187187
drivers/s390/crypto/zcrypt_card.c+1−1
@@ -138,7 +138,7 @@ struct zcrypt_card *zcrypt_card_alloc(void) · 137 unmodified lines
138138 {
139139 struct zcrypt_card *zc;
140140
141− zc = kzalloc(sizeof(struct zcrypt_card), GFP_KERNEL);
141+ zc = kzalloc(sizeof(*zc), GFP_KERNEL);
142142 if (!zc)
143143 return NULL;
144144 INIT_LIST_HEAD(&zc->list);
drivers/s390/crypto/zcrypt_cca_key.h+29−29
@@ -11,7 +11,7 @@ · 10 unmodified lines
1111 #ifndef _ZCRYPT_CCA_KEY_H_
1212 #define _ZCRYPT_CCA_KEY_H_
1313
14−struct T6_keyBlock_hdr {
14+struct t6_keyblock_hdr {
1515 unsigned short blen;
1616 unsigned short ulen;
1717 unsigned short flags;
@@ -63,7 +63,7 @@ struct cca_public_sec { · 45 unmodified lines
6363 * complement of the residue modulo 8 of the sum of
6464 * (p_len + q_len + dp_len + dq_len + u_len).
6565 */
66−struct cca_pvt_ext_CRT_sec {
66+struct cca_pvt_ext_crt_sec {
6767 unsigned char section_identifier;
6868 unsigned char version;
6969 unsigned short section_length;
@@ -108,9 +108,9 @@ static inline int zcrypt_type6_mex_key_en(struct ica_rsa_modexpo *mex, void *p) · 38 unmodified lines
108108 .section_identifier = 0x04,
109109 };
110110 struct {
111− struct T6_keyBlock_hdr t6_hdr;
112− struct cca_token_hdr pubHdr;
113− struct cca_public_sec pubSec;
111+ struct t6_keyblock_hdr t6_hdr;
112+ struct cca_token_hdr pubhdr;
113+ struct cca_public_sec pubsec;
114114 char exponent[0];
115115 } __packed *key = p;
116116 unsigned char *temp;
@@ -127,8 +127,8 @@ static inline int zcrypt_type6_mex_key_en(struct ica_rsa_modexpo *mex, void *p) · 10 unmodified lines
127127
128128 memset(key, 0, sizeof(*key));
129129
130− key->pubHdr = static_pub_hdr;
131− key->pubSec = static_pub_sec;
130+ key->pubhdr = static_pub_hdr;
131+ key->pubsec = static_pub_sec;
132132
133133 /* key parameter block */
134134 temp = key->exponent;
@@ -146,16 +146,16 @@ static inline int zcrypt_type6_mex_key_en(struct ica_rsa_modexpo *mex, void *p) · 11 unmodified lines
146146 if (copy_from_user(temp, mex->n_modulus, mex->inputdatalength))
147147 return -EFAULT;
148148
149− key->pubSec.modulus_bit_len = 8 * mex->inputdatalength;
150− key->pubSec.modulus_byte_len = mex->inputdatalength;
151− key->pubSec.exponent_len = mex->inputdatalength - i;
152− key->pubSec.section_length = sizeof(key->pubSec) +
153− 2*mex->inputdatalength - i;
154− key->pubHdr.token_length =
155− key->pubSec.section_length + sizeof(key->pubHdr);
156− key->t6_hdr.ulen = key->pubHdr.token_length + 4;
157− key->t6_hdr.blen = key->pubHdr.token_length + 6;
158− return sizeof(*key) + 2*mex->inputdatalength - i;
149+ key->pubsec.modulus_bit_len = 8 * mex->inputdatalength;
150+ key->pubsec.modulus_byte_len = mex->inputdatalength;
151+ key->pubsec.exponent_len = mex->inputdatalength - i;
152+ key->pubsec.section_length = sizeof(key->pubsec) +
153+ 2 * mex->inputdatalength - i;
154+ key->pubhdr.token_length =
155+ key->pubsec.section_length + sizeof(key->pubhdr);
156+ key->t6_hdr.ulen = key->pubhdr.token_length + 4;
157+ key->t6_hdr.blen = key->pubhdr.token_length + 6;
158+ return sizeof(*key) + 2 * mex->inputdatalength - i;
159159 }
160160
161161 /**
@@ -177,9 +177,9 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p) · 15 unmodified lines
177177 };
178178 static char pk_exponent[3] = { 0x01, 0x00, 0x01 };
179179 struct {
180− struct T6_keyBlock_hdr t6_hdr;
180+ struct t6_keyblock_hdr t6_hdr;
181181 struct cca_token_hdr token;
182− struct cca_pvt_ext_CRT_sec pvt;
182+ struct cca_pvt_ext_crt_sec pvt;
183183 char key_parts[0];
184184 } __packed *key = p;
185185 struct cca_public_sec *pub;
@@ -198,8 +198,8 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p) · 12 unmodified lines
198198
199199 short_len = (crt->inputdatalength + 1) / 2;
200200 long_len = short_len + 8;
201− pad_len = -(3*long_len + 2*short_len) & 7;
202− key_len = 3*long_len + 2*short_len + pad_len + crt->inputdatalength;
201+ pad_len = -(3 * long_len + 2 * short_len) & 7;
202+ key_len = 3 * long_len + 2 * short_len + pad_len + crt->inputdatalength;
203203 size = sizeof(*key) + key_len + sizeof(*pub) + 3;
204204
205205 /* parameter block.key block */
@@ -223,15 +223,15 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p) · 17 unmodified lines
223223 /* key parts */
224224 if (copy_from_user(key->key_parts, crt->np_prime, long_len) ||
225225 copy_from_user(key->key_parts + long_len,
226− crt->nq_prime, short_len) ||
226+ crt->nq_prime, short_len) ||
227227 copy_from_user(key->key_parts + long_len + short_len,
228− crt->bp_key, long_len) ||
229− copy_from_user(key->key_parts + 2*long_len + short_len,
230− crt->bq_key, short_len) ||
231− copy_from_user(key->key_parts + 2*long_len + 2*short_len,
232− crt->u_mult_inv, long_len))
228+ crt->bp_key, long_len) ||
229+ copy_from_user(key->key_parts + 2 * long_len + short_len,
230+ crt->bq_key, short_len) ||
231+ copy_from_user(key->key_parts + 2 * long_len + 2 * short_len,
232+ crt->u_mult_inv, long_len))
233233 return -EFAULT;
234− memset(key->key_parts + 3*long_len + 2*short_len + pad_len,
234+ memset(key->key_parts + 3 * long_len + 2 * short_len + pad_len,
235235 0xff, crt->inputdatalength);
236236 pub = (struct cca_public_sec *)(key->key_parts + key_len);
237237 *pub = static_cca_pub_sec;
@@ -241,7 +241,7 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p) · 3 unmodified lines
241241 * section. So, an arbitrary public exponent of 0x010001 will be
242242 * used.
243243 */
244− memcpy((char *) (pub + 1), pk_exponent, 3);
244+ memcpy((char *)(pub + 1), pk_exponent, 3);
245245 return size;
246246 }
247247
drivers/s390/crypto/zcrypt_ccamisc.c+141−131
@@ -53,26 +53,26 @@ static DEFINE_SPINLOCK(cca_info_list_lock); · 52 unmodified lines
5353 int cca_check_secaeskeytoken(debug_info_t *dbg, int dbflvl,
5454 const u8 *token, int keybitsize)
5555 {
56− struct secaeskeytoken *t = (struct secaeskeytoken *) token;
56+ struct secaeskeytoken *t = (struct secaeskeytoken *)token;
5757
5858 #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__)
5959
6060 if (t->type != TOKTYPE_CCA_INTERNAL) {
6161 if (dbg)
6262 DBF("%s token check failed, type 0x%02x != 0x%02x\n",
63− __func__, (int) t->type, TOKTYPE_CCA_INTERNAL);
63+ __func__, (int)t->type, TOKTYPE_CCA_INTERNAL);
6464 return -EINVAL;
6565 }
6666 if (t->version != TOKVER_CCA_AES) {
6767 if (dbg)
6868 DBF("%s token check failed, version 0x%02x != 0x%02x\n",
69− __func__, (int) t->version, TOKVER_CCA_AES);
69+ __func__, (int)t->version, TOKVER_CCA_AES);
7070 return -EINVAL;
7171 }
7272 if (keybitsize > 0 && t->bitsize != keybitsize) {
7373 if (dbg)
7474 DBF("%s token check failed, bitsize %d != %d\n",
75− __func__, (int) t->bitsize, keybitsize);
75+ __func__, (int)t->bitsize, keybitsize);
7676 return -EINVAL;
7777 }
7878
@@ -93,7 +93,7 @@ int cca_check_secaescipherkey(debug_info_t *dbg, int dbflvl, · 14 unmodified lines
9393 const u8 *token, int keybitsize,
9494 int checkcpacfexport)
9595 {
96− struct cipherkeytoken *t = (struct cipherkeytoken *) token;
96+ struct cipherkeytoken *t = (struct cipherkeytoken *)token;
9797 bool keybitsizeok = true;
9898
9999 #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__)
@@ -101,37 +101,37 @@ int cca_check_secaescipherkey(debug_info_t *dbg, int dbflvl, · 1 unmodified line
101101 if (t->type != TOKTYPE_CCA_INTERNAL) {
102102 if (dbg)
103103 DBF("%s token check failed, type 0x%02x != 0x%02x\n",
104− __func__, (int) t->type, TOKTYPE_CCA_INTERNAL);
104+ __func__, (int)t->type, TOKTYPE_CCA_INTERNAL);
105105 return -EINVAL;
106106 }
107107 if (t->version != TOKVER_CCA_VLSC) {
108108 if (dbg)
109109 DBF("%s token check failed, version 0x%02x != 0x%02x\n",
110− __func__, (int) t->version, TOKVER_CCA_VLSC);
110+ __func__, (int)t->version, TOKVER_CCA_VLSC);
111111 return -EINVAL;
112112 }
113113 if (t->algtype != 0x02) {
114114 if (dbg)
115115 DBF("%s token check failed, algtype 0x%02x != 0x02\n",
116− __func__, (int) t->algtype);
116+ __func__, (int)t->algtype);
117117 return -EINVAL;
118118 }
119119 if (t->keytype != 0x0001) {
120120 if (dbg)
121121 DBF("%s token check failed, keytype 0x%04x != 0x0001\n",
122− __func__, (int) t->keytype);
122+ __func__, (int)t->keytype);
123123 return -EINVAL;
124124 }
125125 if (t->plfver != 0x00 && t->plfver != 0x01) {
126126 if (dbg)
127127 DBF("%s token check failed, unknown plfver 0x%02x\n",
128− __func__, (int) t->plfver);
128+ __func__, (int)t->plfver);
129129 return -EINVAL;
130130 }
131131 if (t->wpllen != 512 && t->wpllen != 576 && t->wpllen != 640) {
132132 if (dbg)
133133 DBF("%s token check failed, unknown wpllen %d\n",
134− __func__, (int) t->wpllen);
134+ __func__, (int)t->wpllen);
135135 return -EINVAL;
136136 }
137137 if (keybitsize > 0) {
@@ -180,26 +180,26 @@ int cca_check_sececckeytoken(debug_info_t *dbg, int dbflvl, · 42 unmodified lines
180180 const u8 *token, size_t keysize,
181181 int checkcpacfexport)
182182 {
183− struct eccprivkeytoken *t = (struct eccprivkeytoken *) token;
183+ struct eccprivkeytoken *t = (struct eccprivkeytoken *)token;
184184
185185 #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__)
186186
187187 if (t->type != TOKTYPE_CCA_INTERNAL_PKA) {
188188 if (dbg)
189189 DBF("%s token check failed, type 0x%02x != 0x%02x\n",
190− __func__, (int) t->type, TOKTYPE_CCA_INTERNAL_PKA);
190+ __func__, (int)t->type, TOKTYPE_CCA_INTERNAL_PKA);
191191 return -EINVAL;
192192 }
193193 if (t->len > keysize) {
194194 if (dbg)
195195 DBF("%s token check failed, len %d > keysize %zu\n",
196− __func__, (int) t->len, keysize);
196+ __func__, (int)t->len, keysize);
197197 return -EINVAL;
198198 }
199199 if (t->secid != 0x20) {
200200 if (dbg)
201201 DBF("%s token check failed, secid 0x%02x != 0x20\n",
202− __func__, (int) t->secid);
202+ __func__, (int)t->secid);
203203 return -EINVAL;
204204 }
205205 if (checkcpacfexport && !(t->kutc & 0x01)) {
@@ -222,9 +222,9 @@ EXPORT_SYMBOL(cca_check_sececckeytoken); · 16 unmodified lines
222222 * on failure.
223223 */
224224 static int alloc_and_prep_cprbmem(size_t paramblen,
225− u8 **pcprbmem,
226− struct CPRBX **preqCPRB,
227− struct CPRBX **prepCPRB)
225+ u8 **p_cprb_mem,
226+ struct CPRBX **p_req_cprb,
227+ struct CPRBX **p_rep_cprb)
228228 {
229229 u8 *cprbmem;
230230 size_t cprbplusparamblen = sizeof(struct CPRBX) + paramblen;
@@ -238,8 +238,8 @@ static int alloc_and_prep_cprbmem(size_t paramblen, · 7 unmodified lines
238238 if (!cprbmem)
239239 return -ENOMEM;
240240
241− preqcblk = (struct CPRBX *) cprbmem;
242− prepcblk = (struct CPRBX *) (cprbmem + cprbplusparamblen);
241+ preqcblk = (struct CPRBX *)cprbmem;
242+ prepcblk = (struct CPRBX *)(cprbmem + cprbplusparamblen);
243243
244244 /* fill request cprb struct */
245245 preqcblk->cprb_len = sizeof(struct CPRBX);
@@ -248,14 +248,14 @@ static int alloc_and_prep_cprbmem(size_t paramblen, · 2 unmodified lines
248248 preqcblk->rpl_msgbl = cprbplusparamblen;
249249 if (paramblen) {
250250 preqcblk->req_parmb =
251− ((u8 __user *) preqcblk) + sizeof(struct CPRBX);
251+ ((u8 __user *)preqcblk) + sizeof(struct CPRBX);
252252 preqcblk->rpl_parmb =
253− ((u8 __user *) prepcblk) + sizeof(struct CPRBX);
253+ ((u8 __user *)prepcblk) + sizeof(struct CPRBX);
254254 }
255255
256− *pcprbmem = cprbmem;
257− *preqCPRB = preqcblk;
258− *prepCPRB = prepcblk;
256+ *p_cprb_mem = cprbmem;
257+ *p_req_cprb = preqcblk;
258+ *p_rep_cprb = prepcblk;
259259
260260 return 0;
261261 }
@@ -286,9 +286,9 @@ static inline void prep_xcrb(struct ica_xcRB *pxcrb, · 24 unmodified lines
286286 pxcrb->user_defined = (cardnr == 0xFFFF ? AUTOSELECT : cardnr);
287287 pxcrb->request_control_blk_length =
288288 preqcblk->cprb_len + preqcblk->req_parml;
289− pxcrb->request_control_blk_addr = (void __user *) preqcblk;
289+ pxcrb->request_control_blk_addr = (void __user *)preqcblk;
290290 pxcrb->reply_control_blk_length = preqcblk->rpl_msgbl;
291− pxcrb->reply_control_blk_addr = (void __user *) prepcblk;
291+ pxcrb->reply_control_blk_addr = (void __user *)prepcblk;
292292 }
293293
294294 /*
@@ -345,7 +345,7 @@ int cca_genseckey(u16 cardnr, u16 domain, · 50 unmodified lines
345345 preqcblk->domain = domain;
346346
347347 /* fill request cprb param block with KG request */
348− preqparm = (struct kgreqparm __force *) preqcblk->req_parmb;
348+ preqparm = (struct kgreqparm __force *)preqcblk->req_parmb;
349349 memcpy(preqparm->subfunc_code, "KG", 2);
350350 preqparm->rule_array_len = sizeof(preqparm->rule_array_len);
351351 preqparm->lv1.len = sizeof(struct lv1);
@@ -387,7 +387,7 @@ int cca_genseckey(u16 cardnr, u16 domain, · 35 unmodified lines
387387 rc = zcrypt_send_cprb(&xcrb);
388388 if (rc) {
389389 DEBUG_ERR("%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, errno %d\n",
390− __func__, (int) cardnr, (int) domain, rc);
390+ __func__, (int)cardnr, (int)domain, rc);
391391 goto out;
392392 }
393393
@@ -395,16 +395,16 @@ int cca_genseckey(u16 cardnr, u16 domain, · 1 unmodified line
395395 if (prepcblk->ccp_rtcode != 0) {
396396 DEBUG_ERR("%s secure key generate failure, card response %d/%d\n",
397397 __func__,
398− (int) prepcblk->ccp_rtcode,
399− (int) prepcblk->ccp_rscode);
398+ (int)prepcblk->ccp_rtcode,
399+ (int)prepcblk->ccp_rscode);
400400 rc = -EIO;
401401 goto out;
402402 }
403403
404404 /* process response cprb param block */
405− ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
406− prepcblk->rpl_parmb = (u8 __user *) ptr;
407− prepparm = (struct kgrepparm *) ptr;
405+ ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX);
406+ prepcblk->rpl_parmb = (u8 __user *)ptr;
407+ prepparm = (struct kgrepparm *)ptr;
408408
409409 /* check length of the returned secure key token */
410410 seckeysize = prepparm->lv3.keyblock.toklen
@@ -419,7 +419,7 @@ int cca_genseckey(u16 cardnr, u16 domain, · 8 unmodified lines
419419
420420 /* check secure key token */
421421 rc = cca_check_secaeskeytoken(zcrypt_dbf_info, DBF_ERR,
422− prepparm->lv3.keyblock.tok, 8*keysize);
422+ prepparm->lv3.keyblock.tok, 8 * keysize);
423423 if (rc) {
424424 rc = -EIO;
425425 goto out;
@@ -486,7 +486,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 60 unmodified lines
486486 preqcblk->domain = domain;
487487
488488 /* fill request cprb param block with CM request */
489− preqparm = (struct cmreqparm __force *) preqcblk->req_parmb;
489+ preqparm = (struct cmreqparm __force *)preqcblk->req_parmb;
490490 memcpy(preqparm->subfunc_code, "CM", 2);
491491 memcpy(preqparm->rule_array, "AES ", 8);
492492 preqparm->rule_array_len =
@@ -512,7 +512,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 19 unmodified lines
512512 }
513513 preqparm->lv1.len = sizeof(struct lv1) + keysize;
514514 memcpy(preqparm->lv1.clrkey, clrkey, keysize);
515− plv2 = (struct lv2 *) (((u8 *) &preqparm->lv2) + keysize);
515+ plv2 = (struct lv2 *)(((u8 *)&preqparm->lv2) + keysize);
516516 plv2->len = sizeof(struct lv2);
517517 plv2->keyid.len = sizeof(struct keyid);
518518 plv2->keyid.attr = 0x30;
@@ -525,7 +525,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 6 unmodified lines
525525 rc = zcrypt_send_cprb(&xcrb);
526526 if (rc) {
527527 DEBUG_ERR("%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n",
528− __func__, (int) cardnr, (int) domain, rc);
528+ __func__, (int)cardnr, (int)domain, rc);
529529 goto out;
530530 }
531531
@@ -533,16 +533,16 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 1 unmodified line
533533 if (prepcblk->ccp_rtcode != 0) {
534534 DEBUG_ERR("%s clear key import failure, card response %d/%d\n",
535535 __func__,
536− (int) prepcblk->ccp_rtcode,
537− (int) prepcblk->ccp_rscode);
536+ (int)prepcblk->ccp_rtcode,
537+ (int)prepcblk->ccp_rscode);
538538 rc = -EIO;
539539 goto out;
540540 }
541541
542542 /* process response cprb param block */
543− ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
544− prepcblk->rpl_parmb = (u8 __user *) ptr;
545− prepparm = (struct cmrepparm *) ptr;
543+ ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX);
544+ prepcblk->rpl_parmb = (u8 __user *)ptr;
545+ prepparm = (struct cmrepparm *)ptr;
546546
547547 /* check length of the returned secure key token */
548548 seckeysize = prepparm->lv3.keyblock.toklen
@@ -557,7 +557,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 8 unmodified lines
557557
558558 /* check secure key token */
559559 rc = cca_check_secaeskeytoken(zcrypt_dbf_info, DBF_ERR,
560− prepparm->lv3.keyblock.tok, 8*keysize);
560+ prepparm->lv3.keyblock.tok, 8 * keysize);
561561 if (rc) {
562562 rc = -EIO;
563563 goto out;
@@ -632,7 +632,7 @@ int cca_sec2protkey(u16 cardnr, u16 domain, · 68 unmodified lines
632632 preqcblk->domain = domain;
633633
634634 /* fill request cprb param block with USK request */
635− preqparm = (struct uskreqparm __force *) preqcblk->req_parmb;
635+ preqparm = (struct uskreqparm __force *)preqcblk->req_parmb;
636636 memcpy(preqparm->subfunc_code, "US", 2);
637637 preqparm->rule_array_len = sizeof(preqparm->rule_array_len);
638638 preqparm->lv1.len = sizeof(struct lv1);
@@ -652,7 +652,7 @@ int cca_sec2protkey(u16 cardnr, u16 domain, · 13 unmodified lines
652652 rc = zcrypt_send_cprb(&xcrb);
653653 if (rc) {
654654 DEBUG_ERR("%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n",
655− __func__, (int) cardnr, (int) domain, rc);
655+ __func__, (int)cardnr, (int)domain, rc);
656656 goto out;
657657 }
658658
@@ -660,8 +660,8 @@ int cca_sec2protkey(u16 cardnr, u16 domain, · 1 unmodified line
660660 if (prepcblk->ccp_rtcode != 0) {
661661 DEBUG_ERR("%s unwrap secure key failure, card response %d/%d\n",
662662 __func__,
663− (int) prepcblk->ccp_rtcode,
664− (int) prepcblk->ccp_rscode);
663+ (int)prepcblk->ccp_rtcode,
664+ (int)prepcblk->ccp_rscode);
665665 if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290)
666666 rc = -EAGAIN;
667667 else
@@ -671,37 +671,37 @@ int cca_sec2protkey(u16 cardnr, u16 domain, · 3 unmodified lines
671671 if (prepcblk->ccp_rscode != 0) {
672672 DEBUG_WARN("%s unwrap secure key warning, card response %d/%d\n",
673673 __func__,
674− (int) prepcblk->ccp_rtcode,
675− (int) prepcblk->ccp_rscode);
674+ (int)prepcblk->ccp_rtcode,
675+ (int)prepcblk->ccp_rscode);
676676 }
677677
678678 /* process response cprb param block */
679− ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
680− prepcblk->rpl_parmb = (u8 __user *) ptr;
681− prepparm = (struct uskrepparm *) ptr;
679+ ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX);
680+ prepcblk->rpl_parmb = (u8 __user *)ptr;
681+ prepparm = (struct uskrepparm *)ptr;
682682
683683 /* check the returned keyblock */
684684 if (prepparm->lv3.ckb.version != 0x01 &&
685685 prepparm->lv3.ckb.version != 0x02) {
686686 DEBUG_ERR("%s reply param keyblock version mismatch 0x%02x\n",
687− __func__, (int) prepparm->lv3.ckb.version);
687+ __func__, (int)prepparm->lv3.ckb.version);
688688 rc = -EIO;
689689 goto out;
690690 }
691691
692692 /* copy the tanslated protected key */
693693 switch (prepparm->lv3.ckb.len) {
694− case 16+32:
694+ case 16 + 32:
695695 /* AES 128 protected key */
696696 if (protkeytype)
697697 *protkeytype = PKEY_KEYTYPE_AES_128;
698698 break;
699− case 24+32:
699+ case 24 + 32:
700700 /* AES 192 protected key */
701701 if (protkeytype)
702702 *protkeytype = PKEY_KEYTYPE_AES_192;
703703 break;
704− case 32+32:
704+ case 32 + 32:
705705 /* AES 256 protected key */
706706 if (protkeytype)
707707 *protkeytype = PKEY_KEYTYPE_AES_256;
@@ -751,7 +751,7 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 43 unmodified lines
751751 struct gkreqparm {
752752 u8 subfunc_code[2];
753753 u16 rule_array_len;
754− char rule_array[2*8];
754+ char rule_array[2 * 8];
755755 struct {
756756 u16 len;
757757 u8 key_type_1[8];
@@ -827,10 +827,10 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 69 unmodified lines
827827 preqcblk->req_parml = sizeof(struct gkreqparm);
828828
829829 /* prepare request param block with GK request */
830− preqparm = (struct gkreqparm __force *) preqcblk->req_parmb;
830+ preqparm = (struct gkreqparm __force *)preqcblk->req_parmb;
831831 memcpy(preqparm->subfunc_code, "GK", 2);
832832 preqparm->rule_array_len = sizeof(uint16_t) + 2 * 8;
833− memcpy(preqparm->rule_array, "AES OP ", 2*8);
833+ memcpy(preqparm->rule_array, "AES OP ", 2 * 8);
834834
835835 /* prepare vud block */
836836 preqparm->vud.len = sizeof(preqparm->vud);
@@ -869,9 +869,9 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 32 unmodified lines
869869
870870 /* patch the skeleton key token export flags inside the kb block */
871871 if (keygenflags) {
872− t = (struct cipherkeytoken *) preqparm->kb.tlv3.gen_key_id_1;
873− t->kmf1 |= (u16) (keygenflags & 0x0000FF00);
874− t->kmf1 &= (u16) ~(keygenflags & 0x000000FF);
872+ t = (struct cipherkeytoken *)preqparm->kb.tlv3.gen_key_id_1;
873+ t->kmf1 |= (u16)(keygenflags & 0x0000FF00);
874+ t->kmf1 &= (u16)~(keygenflags & 0x000000FF);
875875 }
876876
877877 /* prepare xcrb struct */
@@ -882,7 +882,7 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 4 unmodified lines
882882 if (rc) {
883883 DEBUG_ERR(
884884 "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n",
885− __func__, (int) cardnr, (int) domain, rc);
885+ __func__, (int)cardnr, (int)domain, rc);
886886 goto out;
887887 }
888888
@@ -891,16 +891,16 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 2 unmodified lines
891891 DEBUG_ERR(
892892 "%s cipher key generate failure, card response %d/%d\n",
893893 __func__,
894− (int) prepcblk->ccp_rtcode,
895− (int) prepcblk->ccp_rscode);
894+ (int)prepcblk->ccp_rtcode,
895+ (int)prepcblk->ccp_rscode);
896896 rc = -EIO;
897897 goto out;
898898 }
899899
900900 /* process response cprb param block */
901− ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
902− prepcblk->rpl_parmb = (u8 __user *) ptr;
903− prepparm = (struct gkrepparm *) ptr;
901+ ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX);
902+ prepcblk->rpl_parmb = (u8 __user *)ptr;
903+ prepparm = (struct gkrepparm *)ptr;
904904
905905 /* do some plausibility checks on the key block */
906906 if (prepparm->kb.len < 120 + 5 * sizeof(uint16_t) ||
@@ -921,7 +921,7 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 14 unmodified lines
921921 }
922922
923923 /* copy the generated vlsc key token */
924− t = (struct cipherkeytoken *) prepparm->kb.tlv1.gen_key;
924+ t = (struct cipherkeytoken *)prepparm->kb.tlv1.gen_key;
925925 if (keybuf) {
926926 if (*keybufsize >= t->len)
927927 memcpy(keybuf, t, t->len);
@@ -1006,7 +1006,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, · 78 unmodified lines
10061006 preqcblk->req_parml = 0;
10071007
10081008 /* prepare request param block with IP request */
1009− preq_ra_block = (struct rule_array_block __force *) preqcblk->req_parmb;
1009+ preq_ra_block = (struct rule_array_block __force *)preqcblk->req_parmb;
10101010 memcpy(preq_ra_block->subfunc_code, "IP", 2);
10111011 preq_ra_block->rule_array_len = sizeof(uint16_t) + 2 * 8;
10121012 memcpy(preq_ra_block->rule_array, rule_array_1, 8);
@@ -1050,7 +1050,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, · 37 unmodified lines
10501050 if (rc) {
10511051 DEBUG_ERR(
10521052 "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n",
1053− __func__, (int) cardnr, (int) domain, rc);
1053+ __func__, (int)cardnr, (int)domain, rc);
10541054 goto out;
10551055 }
10561056
@@ -1059,16 +1059,16 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, · 2 unmodified lines
10591059 DEBUG_ERR(
10601060 "%s CSNBKPI2 failure, card response %d/%d\n",
10611061 __func__,
1062− (int) prepcblk->ccp_rtcode,
1063− (int) prepcblk->ccp_rscode);
1062+ (int)prepcblk->ccp_rtcode,
1063+ (int)prepcblk->ccp_rscode);
10641064 rc = -EIO;
10651065 goto out;
10661066 }
10671067
10681068 /* process response cprb param block */
1069− ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
1070− prepcblk->rpl_parmb = (u8 __user *) ptr;
1071− prepparm = (struct iprepparm *) ptr;
1069+ ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX);
1070+ prepcblk->rpl_parmb = (u8 __user *)ptr;
1071+ prepparm = (struct iprepparm *)ptr;
10721072
10731073 /* do some plausibility checks on the key block */
10741074 if (prepparm->kb.len < 120 + 3 * sizeof(uint16_t) ||
@@ -1082,7 +1082,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, · 7 unmodified lines
10821082 /* do not check the key here, it may be incomplete */
10831083
10841084 /* copy the vlsc key token back */
1085− t = (struct cipherkeytoken *) prepparm->kb.tlv1.key_token;
1085+ t = (struct cipherkeytoken *)prepparm->kb.tlv1.key_token;
10861086 memcpy(key_token, t, t->len);
10871087 *key_token_size = t->len;
10881088
@@ -1117,9 +1117,9 @@ int cca_clr2cipherkey(u16 card, u16 dom, u32 keybitsize, u32 keygenflags, · 28 unmodified lines
11171117
11181118 /* patch the skeleton key token export flags */
11191119 if (keygenflags) {
1120− t = (struct cipherkeytoken *) token;
1121− t->kmf1 |= (u16) (keygenflags & 0x0000FF00);
1122− t->kmf1 &= (u16) ~(keygenflags & 0x000000FF);
1120+ t = (struct cipherkeytoken *)token;
1121+ t->kmf1 |= (u16)(keygenflags & 0x0000FF00);
1122+ t->kmf1 &= (u16)~(keygenflags & 0x000000FF);
11231123 }
11241124
11251125 /*
@@ -1241,7 +1241,7 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, · 115 unmodified lines
12411241 preqcblk->domain = domain;
12421242
12431243 /* fill request cprb param block with AU request */
1244− preqparm = (struct aureqparm __force *) preqcblk->req_parmb;
1244+ preqparm = (struct aureqparm __force *)preqcblk->req_parmb;
12451245 memcpy(preqparm->subfunc_code, "AU", 2);
12461246 preqparm->rule_array_len =
12471247 sizeof(preqparm->rule_array_len)
@@ -1267,7 +1267,7 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, · 19 unmodified lines
12671267 if (rc) {
12681268 DEBUG_ERR(
12691269 "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n",
1270− __func__, (int) cardnr, (int) domain, rc);
1270+ __func__, (int)cardnr, (int)domain, rc);
12711271 goto out;
12721272 }
12731273
@@ -1276,8 +1276,8 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, · 2 unmodified lines
12761276 DEBUG_ERR(
12771277 "%s unwrap secure key failure, card response %d/%d\n",
12781278 __func__,
1279− (int) prepcblk->ccp_rtcode,
1280− (int) prepcblk->ccp_rscode);
1279+ (int)prepcblk->ccp_rtcode,
1280+ (int)prepcblk->ccp_rscode);
12811281 if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290)
12821282 rc = -EAGAIN;
12831283 else
@@ -1288,44 +1288,44 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, · 4 unmodified lines
12881288 DEBUG_WARN(
12891289 "%s unwrap secure key warning, card response %d/%d\n",
12901290 __func__,
1291− (int) prepcblk->ccp_rtcode,
1292− (int) prepcblk->ccp_rscode);
1291+ (int)prepcblk->ccp_rtcode,
1292+ (int)prepcblk->ccp_rscode);
12931293 }
12941294
12951295 /* process response cprb param block */
1296− ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
1297− prepcblk->rpl_parmb = (u8 __user *) ptr;
1298− prepparm = (struct aurepparm *) ptr;
1296+ ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX);
1297+ prepcblk->rpl_parmb = (u8 __user *)ptr;
1298+ prepparm = (struct aurepparm *)ptr;
12991299
13001300 /* check the returned keyblock */
13011301 if (prepparm->vud.ckb.version != 0x01 &&
13021302 prepparm->vud.ckb.version != 0x02) {
13031303 DEBUG_ERR("%s reply param keyblock version mismatch 0x%02x\n",
1304− __func__, (int) prepparm->vud.ckb.version);
1304+ __func__, (int)prepparm->vud.ckb.version);
13051305 rc = -EIO;
13061306 goto out;
13071307 }
13081308 if (prepparm->vud.ckb.algo != 0x02) {
13091309 DEBUG_ERR(
13101310 "%s reply param keyblock algo mismatch 0x%02x != 0x02\n",
1311− __func__, (int) prepparm->vud.ckb.algo);
1311+ __func__, (int)prepparm->vud.ckb.algo);
13121312 rc = -EIO;
13131313 goto out;
13141314 }
13151315
13161316 /* copy the translated protected key */
13171317 switch (prepparm->vud.ckb.keylen) {
1318− case 16+32:
1318+ case 16 + 32:
13191319 /* AES 128 protected key */
13201320 if (protkeytype)
13211321 *protkeytype = PKEY_KEYTYPE_AES_128;
13221322 break;
1323− case 24+32:
1323+ case 24 + 32:
13241324 /* AES 192 protected key */
13251325 if (protkeytype)
13261326 *protkeytype = PKEY_KEYTYPE_AES_192;
13271327 break;
1328− case 32+32:
1328+ case 32 + 32:
13291329 /* AES 256 protected key */
13301330 if (protkeytype)
13311331 *protkeytype = PKEY_KEYTYPE_AES_256;
@@ -1410,7 +1410,7 @@ int cca_ecc2protkey(u16 cardnr, u16 domain, const u8 *key, · 78 unmodified lines
14101410 preqcblk->domain = domain;
14111411
14121412 /* fill request cprb param block with AU request */
1413− preqparm = (struct aureqparm __force *) preqcblk->req_parmb;
1413+ preqparm = (struct aureqparm __force *)preqcblk->req_parmb;
14141414 memcpy(preqparm->subfunc_code, "AU", 2);
14151415 preqparm->rule_array_len =
14161416 sizeof(preqparm->rule_array_len)
@@ -1436,7 +1436,7 @@ int cca_ecc2protkey(u16 cardnr, u16 domain, const u8 *key, · 19 unmodified lines
14361436 if (rc) {
14371437 DEBUG_ERR(
14381438 "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n",
1439− __func__, (int) cardnr, (int) domain, rc);
1439+ __func__, (int)cardnr, (int)domain, rc);
14401440 goto out;
14411441 }
14421442
@@ -1445,8 +1445,8 @@ int cca_ecc2protkey(u16 cardnr, u16 domain, const u8 *key, · 2 unmodified lines
14451445 DEBUG_ERR(
14461446 "%s unwrap secure key failure, card response %d/%d\n",
14471447 __func__,
1448− (int) prepcblk->ccp_rtcode,
1449− (int) prepcblk->ccp_rscode);
1448+ (int)prepcblk->ccp_rtcode,
1449+ (int)prepcblk->ccp_rscode);
14501450 if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290)
14511451 rc = -EAGAIN;
14521452 else
@@ -1457,26 +1457,26 @@ int cca_ecc2protkey(u16 cardnr, u16 domain, const u8 *key, · 4 unmodified lines
14571457 DEBUG_WARN(
14581458 "%s unwrap secure key warning, card response %d/%d\n",
14591459 __func__,
1460− (int) prepcblk->ccp_rtcode,
1461− (int) prepcblk->ccp_rscode);
1460+ (int)prepcblk->ccp_rtcode,
1461+ (int)prepcblk->ccp_rscode);
14621462 }
14631463
14641464 /* process response cprb param block */
1465− ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
1466− prepcblk->rpl_parmb = (u8 __user *) ptr;
1467− prepparm = (struct aurepparm *) ptr;
1465+ ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX);
1466+ prepcblk->rpl_parmb = (u8 __user *)ptr;
1467+ prepparm = (struct aurepparm *)ptr;
14681468
14691469 /* check the returned keyblock */
14701470 if (prepparm->vud.ckb.version != 0x02) {
14711471 DEBUG_ERR("%s reply param keyblock version mismatch 0x%02x != 0x02\n",
1472− __func__, (int) prepparm->vud.ckb.version);
1472+ __func__, (int)prepparm->vud.ckb.version);
14731473 rc = -EIO;
14741474 goto out;
14751475 }
14761476 if (prepparm->vud.ckb.algo != 0x81) {
14771477 DEBUG_ERR(
14781478 "%s reply param keyblock algo mismatch 0x%02x != 0x81\n",
1479− __func__, (int) prepparm->vud.ckb.algo);
1479+ __func__, (int)prepparm->vud.ckb.algo);
14801480 rc = -EIO;
14811481 goto out;
14821482 }
@@ -1537,7 +1537,7 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, · 54 unmodified lines
15371537 preqcblk->domain = domain;
15381538
15391539 /* fill request cprb param block with FQ request */
1540− preqparm = (struct fqreqparm __force *) preqcblk->req_parmb;
1540+ preqparm = (struct fqreqparm __force *)preqcblk->req_parmb;
15411541 memcpy(preqparm->subfunc_code, "FQ", 2);
15421542 memcpy(preqparm->rule_array, keyword, sizeof(preqparm->rule_array));
15431543 preqparm->rule_array_len =
@@ -1553,7 +1553,7 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, · 9 unmodified lines
15531553 rc = zcrypt_send_cprb(&xcrb);
15541554 if (rc) {
15551555 DEBUG_ERR("%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n",
1556− __func__, (int) cardnr, (int) domain, rc);
1556+ __func__, (int)cardnr, (int)domain, rc);
15571557 goto out;
15581558 }
15591559
@@ -1561,20 +1561,20 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, · 1 unmodified line
15611561 if (prepcblk->ccp_rtcode != 0) {
15621562 DEBUG_ERR("%s unwrap secure key failure, card response %d/%d\n",
15631563 __func__,
1564− (int) prepcblk->ccp_rtcode,
1565− (int) prepcblk->ccp_rscode);
1564+ (int)prepcblk->ccp_rtcode,
1565+ (int)prepcblk->ccp_rscode);
15661566 rc = -EIO;
15671567 goto out;
15681568 }
15691569
15701570 /* process response cprb param block */
1571− ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
1572− prepcblk->rpl_parmb = (u8 __user *) ptr;
1573− prepparm = (struct fqrepparm *) ptr;
1571+ ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX);
1572+ prepcblk->rpl_parmb = (u8 __user *)ptr;
1573+ prepparm = (struct fqrepparm *)ptr;
15741574 ptr = prepparm->lvdata;
15751575
15761576 /* check and possibly copy reply rule array */
1577− len = *((u16 *) ptr);
1577+ len = *((u16 *)ptr);
15781578 if (len > sizeof(u16)) {
15791579 ptr += sizeof(u16);
15801580 len -= sizeof(u16);
@@ -1585,7 +1585,7 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, · 4 unmodified lines
15851585 ptr += len;
15861586 }
15871587 /* check and possible copy reply var array */
1588− len = *((u16 *) ptr);
1588+ len = *((u16 *)ptr);
15891589 if (len > sizeof(u16)) {
15901590 ptr += sizeof(u16);
15911591 len -= sizeof(u16);
@@ -1696,21 +1696,30 @@ static int fetch_cca_info(u16 cardnr, u16 domain, struct cca_info *ci) · 104 unmodified lines
16961696 ci->hwtype = devstat.hwtype;
16971697
16981698 /* prep page for rule array and var array use */
1699− pg = (u8 *) __get_free_page(GFP_KERNEL);
1699+ pg = (u8 *)__get_free_page(GFP_KERNEL);
17001700 if (!pg)
17011701 return -ENOMEM;
17021702 rarray = pg;
1703− varray = pg + PAGE_SIZE/2;
1704− rlen = vlen = PAGE_SIZE/2;
1703+ varray = pg + PAGE_SIZE / 2;
1704+ rlen = vlen = PAGE_SIZE / 2;
17051705
17061706 /* QF for this card/domain */
17071707 rc = cca_query_crypto_facility(cardnr, domain, "STATICSA",
17081708 rarray, &rlen, varray, &vlen);
1709− if (rc == 0 && rlen >= 10*8 && vlen >= 204) {
1709+ if (rc == 0 && rlen >= 10 * 8 && vlen >= 204) {
17101710 memcpy(ci->serial, rarray, 8);
1711− ci->new_aes_mk_state = (char) rarray[7*8];
1712− ci->cur_aes_mk_state = (char) rarray[8*8];
1713− ci->old_aes_mk_state = (char) rarray[9*8];
1711+ ci->new_asym_mk_state = (char)rarray[4 * 8];
1712+ ci->cur_asym_mk_state = (char)rarray[5 * 8];
1713+ ci->old_asym_mk_state = (char)rarray[6 * 8];
1714+ if (ci->old_asym_mk_state == '2')
1715+ memcpy(ci->old_asym_mkvp, varray + 64, 16);
1716+ if (ci->cur_asym_mk_state == '2')
1717+ memcpy(ci->cur_asym_mkvp, varray + 84, 16);
1718+ if (ci->new_asym_mk_state == '3')
1719+ memcpy(ci->new_asym_mkvp, varray + 104, 16);
1720+ ci->new_aes_mk_state = (char)rarray[7 * 8];
1721+ ci->cur_aes_mk_state = (char)rarray[8 * 8];
1722+ ci->old_aes_mk_state = (char)rarray[9 * 8];
17141723 if (ci->old_aes_mk_state == '2')
17151724 memcpy(&ci->old_aes_mkvp, varray + 172, 8);
17161725 if (ci->cur_aes_mk_state == '2')
@@ -1721,13 +1730,13 @@ static int fetch_cca_info(u16 cardnr, u16 domain, struct cca_info *ci) · 4 unmodified lines
17211730 }
17221731 if (!found)
17231732 goto out;
1724− rlen = vlen = PAGE_SIZE/2;
1733+ rlen = vlen = PAGE_SIZE / 2;
17251734 rc = cca_query_crypto_facility(cardnr, domain, "STATICSB",
17261735 rarray, &rlen, varray, &vlen);
1727− if (rc == 0 && rlen >= 13*8 && vlen >= 240) {
1728− ci->new_apka_mk_state = (char) rarray[10*8];
1729− ci->cur_apka_mk_state = (char) rarray[11*8];
1730− ci->old_apka_mk_state = (char) rarray[12*8];
1736+ if (rc == 0 && rlen >= 13 * 8 && vlen >= 240) {
1737+ ci->new_apka_mk_state = (char)rarray[10 * 8];
1738+ ci->cur_apka_mk_state = (char)rarray[11 * 8];
1739+ ci->old_apka_mk_state = (char)rarray[12 * 8];
17311740 if (ci->old_apka_mk_state == '2')
17321741 memcpy(&ci->old_apka_mkvp, varray + 208, 8);
17331742 if (ci->cur_apka_mk_state == '2')
@@ -1738,7 +1747,7 @@ static int fetch_cca_info(u16 cardnr, u16 domain, struct cca_info *ci) · 4 unmodified lines
17381747 }
17391748
17401749 out:
1741− free_page((unsigned long) pg);
1750+ free_page((unsigned long)pg);
17421751 return found == 2 ? 0 : -ENOENT;
17431752 }
17441753
@@ -1846,8 +1855,9 @@ static int findcard(u64 mkvp, u16 *pcardnr, u16 *pdomain, · 101 unmodified lines
18461855 if (pdomain)
18471856 *pdomain = dom;
18481857 rc = (i < MAX_ZDEV_ENTRIES_EXT ? 0 : 1);
1849− } else
1858+ } else {
18501859 rc = -ENODEV;
1860+ }
18511861
18521862 kvfree(device_status);
18531863 return rc;
@@ -1861,7 +1871,7 @@ int cca_findcard(const u8 *key, u16 *pcardnr, u16 *pdomain, int verify) · 7 unmodified lines
18611871 {
18621872 u64 mkvp;
18631873 int minhwtype = 0;
1864− const struct keytoken_header *hdr = (struct keytoken_header *) key;
1874+ const struct keytoken_header *hdr = (struct keytoken_header *)key;
18651875
18661876 if (hdr->type != TOKTYPE_CCA_INTERNAL)
18671877 return -EINVAL;
@@ -1954,7 +1964,7 @@ int cca_findcard2(u32 **apqns, u32 *nr_apqns, u16 cardnr, u16 domain, · 86 unmodified lines
19541964 }
19551965 /* apqn passed all filtering criterons, add to the array */
19561966 if (_nr_apqns < 256)
1957− _apqns[_nr_apqns++] = (((u16)card) << 16) | ((u16) dom);
1967+ _apqns[_nr_apqns++] = (((u16)card) << 16) | ((u16)dom);
19581968 }
19591969
19601970 /* nothing found ? */
drivers/s390/crypto/zcrypt_ccamisc.h+6−0
@@ -251,12 +251,18 @@ struct cca_info { · 250 unmodified lines
251251 char new_apka_mk_state; /* '1' empty, '2' partially full, '3' full */
252252 char cur_apka_mk_state; /* '1' invalid, '2' valid */
253253 char old_apka_mk_state; /* '1' invalid, '2' valid */
254+ char new_asym_mk_state; /* '1' empty, '2' partially full, '3' full */
255+ char cur_asym_mk_state; /* '1' invalid, '2' valid */
256+ char old_asym_mk_state; /* '1' invalid, '2' valid */
254257 u64 new_aes_mkvp; /* truncated sha256 of new aes master key */
255258 u64 cur_aes_mkvp; /* truncated sha256 of current aes master key */
256259 u64 old_aes_mkvp; /* truncated sha256 of old aes master key */
257260 u64 new_apka_mkvp; /* truncated sha256 of new apka master key */
258261 u64 cur_apka_mkvp; /* truncated sha256 of current apka mk */
259262 u64 old_apka_mkvp; /* truncated sha256 of old apka mk */
263+ u8 new_asym_mkvp[16]; /* verify pattern of new asym master key */
264+ u8 cur_asym_mkvp[16]; /* verify pattern of current asym master key */
265+ u8 old_asym_mkvp[16]; /* verify pattern of old asym master key */
260266 char serial[9]; /* serial number (8 ascii numbers + 0x00) */
261267 };
262268
drivers/s390/crypto/zcrypt_cex2a.c+5−6
@@ -34,10 +34,11 @@ · 33 unmodified lines
3434
3535 #define CEX3A_MAX_RESPONSE_SIZE 0x210 /* 512 bit modulus
3636 * (max outputdatalength) +
37− * type80_hdr*/
37+ * type80_hdr
38+ */
3839 #define CEX3A_MAX_MESSAGE_SIZE sizeof(struct type50_crb3_msg)
3940
40−#define CEX2A_CLEANUP_TIME (15*HZ)
41+#define CEX2A_CLEANUP_TIME (15 * HZ)
4142 #define CEX3A_CLEANUP_TIME CEX2A_CLEANUP_TIME
4243
4344 MODULE_AUTHOR("IBM Corporation");
@@ -117,9 +118,8 @@ static int zcrypt_cex2a_card_probe(struct ap_device *ap_dev) · 73 unmodified lines
117118 zc->online = 1;
118119
119120 rc = zcrypt_card_register(zc);
120− if (rc) {
121+ if (rc)
121122 zcrypt_card_free(zc);
122− }
123123
124124 return rc;
125125 }
@@ -176,9 +176,8 @@ static int zcrypt_cex2a_queue_probe(struct ap_device *ap_dev) · 50 unmodified lines
176176 aq->request_timeout = CEX2A_CLEANUP_TIME;
177177 dev_set_drvdata(&ap_dev->device, zq);
178178 rc = zcrypt_queue_register(zq);
179− if (rc) {
179+ if (rc)
180180 zcrypt_queue_free(zq);
181− }
182181
183182 return rc;
184183 }
drivers/s390/crypto/zcrypt_cex2c.c+5−5
@@ -31,8 +31,8 @@ · 30 unmodified lines
3131 #define CEX2C_MAX_MOD_SIZE 256 /* 2048 bits */
3232 #define CEX3C_MIN_MOD_SIZE 16 /* 128 bits */
3333 #define CEX3C_MAX_MOD_SIZE 512 /* 4096 bits */
34−#define CEX2C_MAX_XCRB_MESSAGE_SIZE (12*1024)
35−#define CEX2C_CLEANUP_TIME (15*HZ)
34+#define CEX2C_MAX_XCRB_MESSAGE_SIZE (12 * 1024)
35+#define CEX2C_CLEANUP_TIME (15 * HZ)
3636
3737 MODULE_AUTHOR("IBM Corporation");
3838 MODULE_DESCRIPTION("CEX2C/CEX3C Cryptographic Coprocessor device driver, " \
@@ -200,11 +200,11 @@ static int zcrypt_cex2c_rng_supported(struct ap_queue *aq) · 161 unmodified lines
200200 int rc, i;
201201
202202 ap_init_message(&ap_msg);
203− ap_msg.msg = (void *) get_zeroed_page(GFP_KERNEL);
203+ ap_msg.msg = (void *)get_zeroed_page(GFP_KERNEL);
204204 if (!ap_msg.msg)
205205 return -ENOMEM;
206206
207− rng_type6CPRB_msgX(&ap_msg, 4, &domain);
207+ rng_type6cprb_msgx(&ap_msg, 4, &domain);
208208
209209 msg = ap_msg.msg;
210210 msg->cprbx.domain = AP_QID_QUEUE(aq->qid);
@@ -233,7 +233,7 @@ static int zcrypt_cex2c_rng_supported(struct ap_queue *aq) · 22 unmodified lines
233233 else
234234 rc = 0;
235235 out_free:
236− free_page((unsigned long) ap_msg.msg);
236+ free_page((unsigned long)ap_msg.msg);
237237 return rc;
238238 }
239239
drivers/s390/crypto/zcrypt_cex4.c+37−7
@@ -33,7 +33,7 @@ · 32 unmodified lines
3333 * But the maximum time limit managed by the stomper code is set to 60sec.
3434 * Hence we have to wait at least that time period.
3535 */
36−#define CEX4_CLEANUP_TIME (900*HZ)
36+#define CEX4_CLEANUP_TIME (900 * HZ)
3737
3838 MODULE_AUTHOR("IBM Corporation");
3939 MODULE_DESCRIPTION("CEX[45678] Cryptographic Card device driver, " \
@@ -123,11 +123,12 @@ static ssize_t cca_mkvps_show(struct device *dev, · 83 unmodified lines
123123 &ci, zq->online);
124124
125125 if (ci.new_aes_mk_state >= '1' && ci.new_aes_mk_state <= '3')
126− n = scnprintf(buf, PAGE_SIZE, "AES NEW: %s 0x%016llx\n",
127− new_state[ci.new_aes_mk_state - '1'],
128− ci.new_aes_mkvp);
126+ n += scnprintf(buf + n, PAGE_SIZE,
127+ "AES NEW: %s 0x%016llx\n",
128+ new_state[ci.new_aes_mk_state - '1'],
129+ ci.new_aes_mkvp);
129130 else
130− n = scnprintf(buf, PAGE_SIZE, "AES NEW: - -\n");
131+ n += scnprintf(buf + n, PAGE_SIZE, "AES NEW: - -\n");
131132
132133 if (ci.cur_aes_mk_state >= '1' && ci.cur_aes_mk_state <= '2')
133134 n += scnprintf(buf + n, PAGE_SIZE - n,
@@ -169,6 +170,33 @@ static ssize_t cca_mkvps_show(struct device *dev, · 35 unmodified lines
169170 else
170171 n += scnprintf(buf + n, PAGE_SIZE - n, "APKA OLD: - -\n");
171172
173+ if (ci.new_asym_mk_state >= '1' && ci.new_asym_mk_state <= '3')
174+ n += scnprintf(buf + n, PAGE_SIZE,
175+ "ASYM NEW: %s 0x%016llx%016llx\n",
176+ new_state[ci.new_asym_mk_state - '1'],
177+ *((u64 *)(ci.new_asym_mkvp)),
178+ *((u64 *)(ci.new_asym_mkvp + sizeof(u64))));
179+ else
180+ n += scnprintf(buf + n, PAGE_SIZE, "ASYM NEW: - -\n");
181+
182+ if (ci.cur_asym_mk_state >= '1' && ci.cur_asym_mk_state <= '2')
183+ n += scnprintf(buf + n, PAGE_SIZE - n,
184+ "ASYM CUR: %s 0x%016llx%016llx\n",
185+ cao_state[ci.cur_asym_mk_state - '1'],
186+ *((u64 *)(ci.cur_asym_mkvp)),
187+ *((u64 *)(ci.cur_asym_mkvp + sizeof(u64))));
188+ else
189+ n += scnprintf(buf + n, PAGE_SIZE - n, "ASYM CUR: - -\n");
190+
191+ if (ci.old_asym_mk_state >= '1' && ci.old_asym_mk_state <= '2')
192+ n += scnprintf(buf + n, PAGE_SIZE - n,
193+ "ASYM OLD: %s 0x%016llx%016llx\n",
194+ cao_state[ci.old_asym_mk_state - '1'],
195+ *((u64 *)(ci.old_asym_mkvp)),
196+ *((u64 *)(ci.old_asym_mkvp + sizeof(u64))));
197+ else
198+ n += scnprintf(buf + n, PAGE_SIZE - n, "ASYM OLD: - -\n");
199+
172200 return n;
173201 }
174202
@@ -336,8 +364,9 @@ static ssize_t ep11_mkvps_show(struct device *dev, · 161 unmodified lines
336364 bin2hex(buf + n, di.cur_wkvp, sizeof(di.cur_wkvp));
337365 n += 2 * sizeof(di.cur_wkvp);
338366 n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
339− } else
367+ } else {
340368 n = scnprintf(buf, PAGE_SIZE, "WK CUR: - -\n");
369+ }
341370
342371 if (di.new_wk_state == '0') {
343372 n += scnprintf(buf + n, PAGE_SIZE - n, "WK NEW: %s -\n",
@@ -348,8 +377,9 @@ static ssize_t ep11_mkvps_show(struct device *dev, · 4 unmodified lines
348377 bin2hex(buf + n, di.new_wkvp, sizeof(di.new_wkvp));
349378 n += 2 * sizeof(di.new_wkvp);
350379 n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
351− } else
380+ } else {
352381 n += scnprintf(buf + n, PAGE_SIZE - n, "WK NEW: - -\n");
382+ }
353383
354384 return n;
355385 }
drivers/s390/crypto/zcrypt_ep11misc.c+84−84
@@ -119,8 +119,8 @@ static void __exit card_cache_free(void) · 118 unmodified lines
119119 int ep11_check_aes_key_with_hdr(debug_info_t *dbg, int dbflvl,
120120 const u8 *key, size_t keylen, int checkcpacfexp)
121121 {
122− struct ep11kblob_header *hdr = (struct ep11kblob_header *) key;
123− struct ep11keyblob *kb = (struct ep11keyblob *) (key + sizeof(*hdr));
122+ struct ep11kblob_header *hdr = (struct ep11kblob_header *)key;
123+ struct ep11keyblob *kb = (struct ep11keyblob *)(key + sizeof(*hdr));
124124
125125 #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__)
126126
@@ -133,38 +133,38 @@ int ep11_check_aes_key_with_hdr(debug_info_t *dbg, int dbflvl, · 6 unmodified lines
133133 if (hdr->type != TOKTYPE_NON_CCA) {
134134 if (dbg)
135135 DBF("%s key check failed, type 0x%02x != 0x%02x\n",
136− __func__, (int) hdr->type, TOKTYPE_NON_CCA);
136+ __func__, (int)hdr->type, TOKTYPE_NON_CCA);
137137 return -EINVAL;
138138 }
139139 if (hdr->hver != 0x00) {
140140 if (dbg)
141141 DBF("%s key check failed, header version 0x%02x != 0x00\n",
142− __func__, (int) hdr->hver);
142+ __func__, (int)hdr->hver);
143143 return -EINVAL;
144144 }
145145 if (hdr->version != TOKVER_EP11_AES_WITH_HEADER) {
146146 if (dbg)
147147 DBF("%s key check failed, version 0x%02x != 0x%02x\n",
148− __func__, (int) hdr->version, TOKVER_EP11_AES_WITH_HEADER);
148+ __func__, (int)hdr->version, TOKVER_EP11_AES_WITH_HEADER);
149149 return -EINVAL;
150150 }
151151 if (hdr->len > keylen) {
152152 if (dbg)
153153 DBF("%s key check failed, header len %d keylen %zu mismatch\n",
154− __func__, (int) hdr->len, keylen);
154+ __func__, (int)hdr->len, keylen);
155155 return -EINVAL;
156156 }
157157 if (hdr->len < sizeof(*hdr) + sizeof(*kb)) {
158158 if (dbg)
159159 DBF("%s key check failed, header len %d < %zu\n",
160− __func__, (int) hdr->len, sizeof(*hdr) + sizeof(*kb));
160+ __func__, (int)hdr->len, sizeof(*hdr) + sizeof(*kb));
161161 return -EINVAL;
162162 }
163163
164164 if (kb->version != EP11_STRUCT_MAGIC) {
165165 if (dbg)
166166 DBF("%s key check failed, blob magic 0x%04x != 0x%04x\n",
167− __func__, (int) kb->version, EP11_STRUCT_MAGIC);
167+ __func__, (int)kb->version, EP11_STRUCT_MAGIC);
168168 return -EINVAL;
169169 }
170170 if (checkcpacfexp && !(kb->attr & EP11_BLOB_PKEY_EXTRACTABLE)) {
@@ -186,8 +186,8 @@ EXPORT_SYMBOL(ep11_check_aes_key_with_hdr); · 15 unmodified lines
186186 int ep11_check_ecc_key_with_hdr(debug_info_t *dbg, int dbflvl,
187187 const u8 *key, size_t keylen, int checkcpacfexp)
188188 {
189− struct ep11kblob_header *hdr = (struct ep11kblob_header *) key;
190− struct ep11keyblob *kb = (struct ep11keyblob *) (key + sizeof(*hdr));
189+ struct ep11kblob_header *hdr = (struct ep11kblob_header *)key;
190+ struct ep11keyblob *kb = (struct ep11keyblob *)(key + sizeof(*hdr));
191191
192192 #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__)
193193
@@ -200,38 +200,38 @@ int ep11_check_ecc_key_with_hdr(debug_info_t *dbg, int dbflvl, · 6 unmodified lines
200200 if (hdr->type != TOKTYPE_NON_CCA) {
201201 if (dbg)
202202 DBF("%s key check failed, type 0x%02x != 0x%02x\n",
203− __func__, (int) hdr->type, TOKTYPE_NON_CCA);
203+ __func__, (int)hdr->type, TOKTYPE_NON_CCA);
204204 return -EINVAL;
205205 }
206206 if (hdr->hver != 0x00) {
207207 if (dbg)
208208 DBF("%s key check failed, header version 0x%02x != 0x00\n",
209− __func__, (int) hdr->hver);
209+ __func__, (int)hdr->hver);
210210 return -EINVAL;
211211 }
212212 if (hdr->version != TOKVER_EP11_ECC_WITH_HEADER) {
213213 if (dbg)
214214 DBF("%s key check failed, version 0x%02x != 0x%02x\n",
215− __func__, (int) hdr->version, TOKVER_EP11_ECC_WITH_HEADER);
215+ __func__, (int)hdr->version, TOKVER_EP11_ECC_WITH_HEADER);
216216 return -EINVAL;
217217 }
218218 if (hdr->len > keylen) {
219219 if (dbg)
220220 DBF("%s key check failed, header len %d keylen %zu mismatch\n",
221− __func__, (int) hdr->len, keylen);
221+ __func__, (int)hdr->len, keylen);
222222 return -EINVAL;
223223 }
224224 if (hdr->len < sizeof(*hdr) + sizeof(*kb)) {
225225 if (dbg)
226226 DBF("%s key check failed, header len %d < %zu\n",
227− __func__, (int) hdr->len, sizeof(*hdr) + sizeof(*kb));
227+ __func__, (int)hdr->len, sizeof(*hdr) + sizeof(*kb));
228228 return -EINVAL;
229229 }
230230
231231 if (kb->version != EP11_STRUCT_MAGIC) {
232232 if (dbg)
233233 DBF("%s key check failed, blob magic 0x%04x != 0x%04x\n",
234− __func__, (int) kb->version, EP11_STRUCT_MAGIC);
234+ __func__, (int)kb->version, EP11_STRUCT_MAGIC);
235235 return -EINVAL;
236236 }
237237 if (checkcpacfexp && !(kb->attr & EP11_BLOB_PKEY_EXTRACTABLE)) {
@@ -254,7 +254,7 @@ EXPORT_SYMBOL(ep11_check_ecc_key_with_hdr); · 16 unmodified lines
254254 int ep11_check_aes_key(debug_info_t *dbg, int dbflvl,
255255 const u8 *key, size_t keylen, int checkcpacfexp)
256256 {
257− struct ep11keyblob *kb = (struct ep11keyblob *) key;
257+ struct ep11keyblob *kb = (struct ep11keyblob *)key;
258258
259259 #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__)
260260
@@ -267,32 +267,32 @@ int ep11_check_aes_key(debug_info_t *dbg, int dbflvl, · 6 unmodified lines
267267 if (kb->head.type != TOKTYPE_NON_CCA) {
268268 if (dbg)
269269 DBF("%s key check failed, type 0x%02x != 0x%02x\n",
270− __func__, (int) kb->head.type, TOKTYPE_NON_CCA);
270+ __func__, (int)kb->head.type, TOKTYPE_NON_CCA);
271271 return -EINVAL;
272272 }
273273 if (kb->head.version != TOKVER_EP11_AES) {
274274 if (dbg)
275275 DBF("%s key check failed, version 0x%02x != 0x%02x\n",
276− __func__, (int) kb->head.version, TOKVER_EP11_AES);
276+ __func__, (int)kb->head.version, TOKVER_EP11_AES);
277277 return -EINVAL;
278278 }
279279 if (kb->head.len > keylen) {
280280 if (dbg)
281281 DBF("%s key check failed, header len %d keylen %zu mismatch\n",
282− __func__, (int) kb->head.len, keylen);
282+ __func__, (int)kb->head.len, keylen);
283283 return -EINVAL;
284284 }
285285 if (kb->head.len < sizeof(*kb)) {
286286 if (dbg)
287287 DBF("%s key check failed, header len %d < %zu\n",
288− __func__, (int) kb->head.len, sizeof(*kb));
288+ __func__, (int)kb->head.len, sizeof(*kb));
289289 return -EINVAL;
290290 }
291291
292292 if (kb->version != EP11_STRUCT_MAGIC) {
293293 if (dbg)
294294 DBF("%s key check failed, blob magic 0x%04x != 0x%04x\n",
295− __func__, (int) kb->version, EP11_STRUCT_MAGIC);
295+ __func__, (int)kb->version, EP11_STRUCT_MAGIC);
296296 return -EINVAL;
297297 }
298298 if (checkcpacfexp && !(kb->attr & EP11_BLOB_PKEY_EXTRACTABLE)) {
@@ -347,11 +347,11 @@ static int asn1tag_write(u8 *ptr, u8 tag, const u8 *pvalue, u16 valuelen) · 48 unmodified lines
347347 }
348348 if (valuelen > 127) {
349349 ptr[1] = 0x81;
350− ptr[2] = (u8) valuelen;
350+ ptr[2] = (u8)valuelen;
351351 memcpy(ptr + 3, pvalue, valuelen);
352352 return 3 + valuelen;
353353 }
354− ptr[1] = (u8) valuelen;
354+ ptr[1] = (u8)valuelen;
355355 memcpy(ptr + 2, pvalue, valuelen);
356356 return 2 + valuelen;
357357 }
@@ -389,11 +389,11 @@ static inline void prep_urb(struct ep11_urb *u, · 31 unmodified lines
389389 struct ep11_cprb *req, size_t req_len,
390390 struct ep11_cprb *rep, size_t rep_len)
391391 {
392− u->targets = (u8 __user *) t;
392+ u->targets = (u8 __user *)t;
393393 u->targets_num = nt;
394− u->req = (u8 __user *) req;
394+ u->req = (u8 __user *)req;
395395 u->req_len = req_len;
396− u->resp = (u8 __user *) rep;
396+ u->resp = (u8 __user *)rep;
397397 u->resp_len = rep_len;
398398 }
399399
@@ -462,7 +462,6 @@ static int check_reply_pl(const u8 *pl, const char *func) · 62 unmodified lines
462462 return 0;
463463 }
464464
465−
466465 /*
467466 * Helper function which does an ep11 query with given query type.
468467 */
@@ -496,7 +495,7 @@ static int ep11_query_info(u16 cardnr, u16 domain, u32 query_type, · 27 unmodified lines
496495 req = alloc_cprb(sizeof(struct ep11_info_req_pl));
497496 if (!req)
498497 goto out;
499− req_pl = (struct ep11_info_req_pl *) (((u8 *) req) + sizeof(*req));
498+ req_pl = (struct ep11_info_req_pl *)(((u8 *)req) + sizeof(*req));
500499 prep_head(&req_pl->head, sizeof(*req_pl), api, 38); /* get xcp info */
501500 req_pl->query_type_tag = 0x04;
502501 req_pl->query_type_len = sizeof(u32);
@@ -508,10 +507,10 @@ static int ep11_query_info(u16 cardnr, u16 domain, u32 query_type, · 5 unmodified lines
508507 rep = alloc_cprb(sizeof(struct ep11_info_rep_pl) + buflen);
509508 if (!rep)
510509 goto out;
511− rep_pl = (struct ep11_info_rep_pl *) (((u8 *) rep) + sizeof(*rep));
510+ rep_pl = (struct ep11_info_rep_pl *)(((u8 *)rep) + sizeof(*rep));
512511
513512 /* urb and target */
514− urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL);
513+ urb = kmalloc(sizeof(*urb), GFP_KERNEL);
515514 if (!urb)
516515 goto out;
517516 target.ap_id = cardnr;
@@ -524,7 +523,7 @@ static int ep11_query_info(u16 cardnr, u16 domain, u32 query_type, · 6 unmodified lines
524523 if (rc) {
525524 DEBUG_ERR(
526525 "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n",
527− __func__, (int) cardnr, (int) domain, rc);
526+ __func__, (int)cardnr, (int)domain, rc);
528527 goto out;
529528 }
530529
@@ -543,7 +542,7 @@ static int ep11_query_info(u16 cardnr, u16 domain, u32 query_type, · 12 unmodified lines
543542 goto out;
544543 }
545544
546− memcpy(buf, ((u8 *) rep_pl) + sizeof(*rep_pl), rep_pl->data_len);
545+ memcpy(buf, ((u8 *)rep_pl) + sizeof(*rep_pl), rep_pl->data_len);
547546
548547 out:
549548 kfree(req);
@@ -592,7 +591,7 @@ int ep11_get_card_info(u16 card, struct ep11_card_info *info, int verify) · 42 unmodified lines
592591 return -ENOMEM;
593592 rc = ep11_query_info(card, AUTOSEL_DOM,
594593 0x01 /* module info query */,
595− sizeof(*pmqi), (u8 *) pmqi);
594+ sizeof(*pmqi), (u8 *)pmqi);
596595 if (rc) {
597596 if (rc == -ENODEV)
598597 card_cache_scrub(card);
@@ -632,7 +631,7 @@ int ep11_get_domain_info(u16 card, u16 domain, struct ep11_domain_info *info) · 33 unmodified lines
632631 return -ENOMEM;
633632
634633 rc = ep11_query_info(card, domain, 0x03 /* domain info query */,
635− sizeof(*p_dom_info), (u8 *) p_dom_info);
634+ sizeof(*p_dom_info), (u8 *)p_dom_info);
636635 if (rc)
637636 goto out;
638637
@@ -644,8 +643,8 @@ int ep11_get_domain_info(u16 card, u16 domain, struct ep11_domain_info *info) · 5 unmodified lines
644643 info->cur_wk_state = '1';
645644 memcpy(info->cur_wkvp, p_dom_info->cur_WK_VP, 32);
646645 }
647− if (p_dom_info->dom_flags & 0x04 /* new wk present */
648− || p_dom_info->dom_flags & 0x08 /* new wk committed */) {
646+ if (p_dom_info->dom_flags & 0x04 || /* new wk present */
647+ p_dom_info->dom_flags & 0x08 /* new wk committed */) {
649648 info->new_wk_state =
650649 p_dom_info->dom_flags & 0x08 ? '2' : '1';
651650 memcpy(info->new_wkvp, p_dom_info->new_WK_VP, 32);
@@ -722,7 +721,7 @@ int ep11_genaeskey(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 70 unmodified lines
722721 req = alloc_cprb(sizeof(struct keygen_req_pl));
723722 if (!req)
724723 goto out;
725− req_pl = (struct keygen_req_pl *) (((u8 *) req) + sizeof(*req));
724+ req_pl = (struct keygen_req_pl *)(((u8 *)req) + sizeof(*req));
726725 api = (!keygenflags || keygenflags & 0x00200000) ? 4 : 1;
727726 prep_head(&req_pl->head, sizeof(*req_pl), api, 21); /* GenerateKey */
728727 req_pl->var_tag = 0x04;
@@ -746,10 +745,10 @@ int ep11_genaeskey(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 17 unmodified lines
746745 rep = alloc_cprb(sizeof(struct keygen_rep_pl));
747746 if (!rep)
748747 goto out;
749− rep_pl = (struct keygen_rep_pl *) (((u8 *) rep) + sizeof(*rep));
748+ rep_pl = (struct keygen_rep_pl *)(((u8 *)rep) + sizeof(*rep));
750749
751750 /* urb and target */
752− urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL);
751+ urb = kmalloc(sizeof(*urb), GFP_KERNEL);
753752 if (!urb)
754753 goto out;
755754 target.ap_id = card;
@@ -762,7 +761,7 @@ int ep11_genaeskey(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 6 unmodified lines
762761 if (rc) {
763762 DEBUG_ERR(
764763 "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n",
765− __func__, (int) card, (int) domain, rc);
764+ __func__, (int)card, (int)domain, rc);
766765 goto out;
767766 }
768767
@@ -784,7 +783,7 @@ int ep11_genaeskey(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 15 unmodified lines
784783 /* copy key blob and set header values */
785784 memcpy(keybuf, rep_pl->data, rep_pl->data_len);
786785 *keybufsize = rep_pl->data_len;
787− kb = (struct ep11keyblob *) keybuf;
786+ kb = (struct ep11keyblob *)keybuf;
788787 kb->head.type = TOKTYPE_NON_CCA;
789788 kb->head.len = rep_pl->data_len;
790789 kb->head.version = TOKVER_EP11_AES;
@@ -844,7 +843,7 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 53 unmodified lines
844843 req = alloc_cprb(req_pl_size);
845844 if (!req)
846845 goto out;
847− req_pl = (struct crypt_req_pl *) (((u8 *) req) + sizeof(*req));
846+ req_pl = (struct crypt_req_pl *)(((u8 *)req) + sizeof(*req));
848847 prep_head(&req_pl->head, req_pl_size, api, (mode ? 20 : 19));
849848 req_pl->var_tag = 0x04;
850849 req_pl->var_len = sizeof(u32);
@@ -852,7 +851,7 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 1 unmodified line
852851 req_pl->mech_tag = 0x04;
853852 req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0);
854853 req_pl->mech = (mech ? mech : 0x00001085); /* CKM_AES_CBC_PAD */
855− p = ((u8 *) req_pl) + sizeof(*req_pl);
854+ p = ((u8 *)req_pl) + sizeof(*req_pl);
856855 if (iv) {
857856 memcpy(p, iv, 16);
858857 p += 16;
@@ -866,10 +865,10 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 7 unmodified lines
866865 rep = alloc_cprb(rep_pl_size);
867866 if (!rep)
868867 goto out;
869− rep_pl = (struct crypt_rep_pl *) (((u8 *) rep) + sizeof(*rep));
868+ rep_pl = (struct crypt_rep_pl *)(((u8 *)rep) + sizeof(*rep));
870869
871870 /* urb and target */
872− urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL);
871+ urb = kmalloc(sizeof(*urb), GFP_KERNEL);
873872 if (!urb)
874873 goto out;
875874 target.ap_id = card;
@@ -882,7 +881,7 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 6 unmodified lines
882881 if (rc) {
883882 DEBUG_ERR(
884883 "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n",
885− __func__, (int) card, (int) domain, rc);
884+ __func__, (int)card, (int)domain, rc);
886885 goto out;
887886 }
888887
@@ -894,13 +893,13 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 5 unmodified lines
894893 rc = -EIO;
895894 goto out;
896895 }
897− p = ((u8 *) rep_pl) + sizeof(*rep_pl);
898− if (rep_pl->data_lenfmt <= 127)
896+ p = ((u8 *)rep_pl) + sizeof(*rep_pl);
897+ if (rep_pl->data_lenfmt <= 127) {
899898 n = rep_pl->data_lenfmt;
900− else if (rep_pl->data_lenfmt == 0x81)
899+ } else if (rep_pl->data_lenfmt == 0x81) {
901900 n = *p++;
902− else if (rep_pl->data_lenfmt == 0x82) {
903− n = *((u16 *) p);
901+ } else if (rep_pl->data_lenfmt == 0x82) {
902+ n = *((u16 *)p);
904903 p += 2;
905904 } else {
906905 DEBUG_ERR("%s unknown reply data length format 0x%02hhx\n",
@@ -978,7 +977,7 @@ static int ep11_unwrapkey(u16 card, u16 domain, · 71 unmodified lines
978977 req = alloc_cprb(req_pl_size);
979978 if (!req)
980979 goto out;
981− req_pl = (struct uw_req_pl *) (((u8 *) req) + sizeof(*req));
980+ req_pl = (struct uw_req_pl *)(((u8 *)req) + sizeof(*req));
982981 api = (!keygenflags || keygenflags & 0x00200000) ? 4 : 1;
983982 prep_head(&req_pl->head, req_pl_size, api, 34); /* UnwrapKey */
984983 req_pl->attr_tag = 0x04;
@@ -994,7 +993,7 @@ static int ep11_unwrapkey(u16 card, u16 domain, · 9 unmodified lines
994993 req_pl->mech_tag = 0x04;
995994 req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0);
996995 req_pl->mech = (mech ? mech : 0x00001085); /* CKM_AES_CBC_PAD */
997− p = ((u8 *) req_pl) + sizeof(*req_pl);
996+ p = ((u8 *)req_pl) + sizeof(*req_pl);
998997 if (iv) {
999998 memcpy(p, iv, 16);
1000999 p += 16;
@@ -1014,10 +1013,10 @@ static int ep11_unwrapkey(u16 card, u16 domain, · 13 unmodified lines
10141013 rep = alloc_cprb(sizeof(struct uw_rep_pl));
10151014 if (!rep)
10161015 goto out;
1017− rep_pl = (struct uw_rep_pl *) (((u8 *) rep) + sizeof(*rep));
1016+ rep_pl = (struct uw_rep_pl *)(((u8 *)rep) + sizeof(*rep));
10181017
10191018 /* urb and target */
1020− urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL);
1019+ urb = kmalloc(sizeof(*urb), GFP_KERNEL);
10211020 if (!urb)
10221021 goto out;
10231022 target.ap_id = card;
@@ -1030,7 +1029,7 @@ static int ep11_unwrapkey(u16 card, u16 domain, · 6 unmodified lines
10301029 if (rc) {
10311030 DEBUG_ERR(
10321031 "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n",
1033− __func__, (int) card, (int) domain, rc);
1032+ __func__, (int)card, (int)domain, rc);
10341033 goto out;
10351034 }
10361035
@@ -1052,7 +1051,7 @@ static int ep11_unwrapkey(u16 card, u16 domain, · 15 unmodified lines
10521051 /* copy key blob and set header values */
10531052 memcpy(keybuf, rep_pl->data, rep_pl->data_len);
10541053 *keybufsize = rep_pl->data_len;
1055− kb = (struct ep11keyblob *) keybuf;
1054+ kb = (struct ep11keyblob *)keybuf;
10561055 kb->head.type = TOKTYPE_NON_CCA;
10571056 kb->head.len = rep_pl->data_len;
10581057 kb->head.version = TOKVER_EP11_AES;
@@ -1105,7 +1104,7 @@ static int ep11_wrapkey(u16 card, u16 domain, · 46 unmodified lines
11051104 u8 *p;
11061105
11071106 /* maybe the session field holds a header with key info */
1108− kb = (struct ep11keyblob *) key;
1107+ kb = (struct ep11keyblob *)key;
11091108 if (kb->head.type == TOKTYPE_NON_CCA &&
11101109 kb->head.version == TOKVER_EP11_AES) {
11111110 has_header = true;
@@ -1120,7 +1119,7 @@ static int ep11_wrapkey(u16 card, u16 domain, · 8 unmodified lines
11201119 goto out;
11211120 if (!mech || mech == 0x80060001)
11221121 req->flags |= 0x20; /* CPACF_WRAP needs special bit */
1123− req_pl = (struct wk_req_pl *) (((u8 *) req) + sizeof(*req));
1122+ req_pl = (struct wk_req_pl *)(((u8 *)req) + sizeof(*req));
11241123 api = (!mech || mech == 0x80060001) ? 4 : 1; /* CKM_IBM_CPACF_WRAP */
11251124 prep_head(&req_pl->head, req_pl_size, api, 33); /* WrapKey */
11261125 req_pl->var_tag = 0x04;
@@ -1129,7 +1128,7 @@ static int ep11_wrapkey(u16 card, u16 domain, · 2 unmodified lines
11291128 req_pl->mech_tag = 0x04;
11301129 req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0);
11311130 req_pl->mech = (mech ? mech : 0x80060001); /* CKM_IBM_CPACF_WRAP */
1132− p = ((u8 *) req_pl) + sizeof(*req_pl);
1131+ p = ((u8 *)req_pl) + sizeof(*req_pl);
11331132 if (iv) {
11341133 memcpy(p, iv, 16);
11351134 p += 16;
@@ -1152,10 +1151,10 @@ static int ep11_wrapkey(u16 card, u16 domain, · 16 unmodified lines
11521151 rep = alloc_cprb(sizeof(struct wk_rep_pl));
11531152 if (!rep)
11541153 goto out;
1155− rep_pl = (struct wk_rep_pl *) (((u8 *) rep) + sizeof(*rep));
1154+ rep_pl = (struct wk_rep_pl *)(((u8 *)rep) + sizeof(*rep));
11561155
11571156 /* urb and target */
1158− urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL);
1157+ urb = kmalloc(sizeof(*urb), GFP_KERNEL);
11591158 if (!urb)
11601159 goto out;
11611160 target.ap_id = card;
@@ -1168,7 +1167,7 @@ static int ep11_wrapkey(u16 card, u16 domain, · 6 unmodified lines
11681167 if (rc) {
11691168 DEBUG_ERR(
11701169 "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n",
1171− __func__, (int) card, (int) domain, rc);
1170+ __func__, (int)card, (int)domain, rc);
11721171 goto out;
11731172 }
11741173
@@ -1206,9 +1205,9 @@ int ep11_clr2keyblob(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 31 unmodified lines
12061205 u8 encbuf[64], *kek = NULL;
12071206 size_t clrkeylen, keklen, encbuflen = sizeof(encbuf);
12081207
1209− if (keybitsize == 128 || keybitsize == 192 || keybitsize == 256)
1208+ if (keybitsize == 128 || keybitsize == 192 || keybitsize == 256) {
12101209 clrkeylen = keybitsize / 8;
1211− else {
1210+ } else {
12121211 DEBUG_ERR(
12131212 "%s unknown/unsupported keybitsize %d\n",
12141213 __func__, keybitsize);
@@ -1233,7 +1232,7 @@ int ep11_clr2keyblob(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 18 unmodified lines
12331232 __func__, rc);
12341233 goto out;
12351234 }
1236− kb = (struct ep11keyblob *) kek;
1235+ kb = (struct ep11keyblob *)kek;
12371236 memset(&kb->head, 0, sizeof(kb->head));
12381237
12391238 /* Step 2: encrypt clear key value with the kek key */
@@ -1282,17 +1281,17 @@ int ep11_kblob2protkey(u16 card, u16 dom, const u8 *keyblob, size_t keybloblen, · 42 unmodified lines
12821281 struct ep11kblob_header *hdr;
12831282
12841283 /* key with or without header ? */
1285− hdr = (struct ep11kblob_header *) keyblob;
1286− if (hdr->type == TOKTYPE_NON_CCA
1287− && (hdr->version == TOKVER_EP11_AES_WITH_HEADER
1288− || hdr->version == TOKVER_EP11_ECC_WITH_HEADER)
1289− && is_ep11_keyblob(keyblob + sizeof(struct ep11kblob_header))) {
1284+ hdr = (struct ep11kblob_header *)keyblob;
1285+ if (hdr->type == TOKTYPE_NON_CCA &&
1286+ (hdr->version == TOKVER_EP11_AES_WITH_HEADER ||
1287+ hdr->version == TOKVER_EP11_ECC_WITH_HEADER) &&
1288+ is_ep11_keyblob(keyblob + sizeof(struct ep11kblob_header))) {
12901289 /* EP11 AES or ECC key with header */
12911290 key = keyblob + sizeof(struct ep11kblob_header);
12921291 keylen = hdr->len - sizeof(struct ep11kblob_header);
1293− } else if (hdr->type == TOKTYPE_NON_CCA
1294− && hdr->version == TOKVER_EP11_AES
1295− && is_ep11_keyblob(keyblob)) {
1292+ } else if (hdr->type == TOKTYPE_NON_CCA &&
1293+ hdr->version == TOKVER_EP11_AES &&
1294+ is_ep11_keyblob(keyblob)) {
12961295 /* EP11 AES key (old style) */
12971296 key = keyblob;
12981297 keylen = hdr->len;
@@ -1300,8 +1299,9 @@ int ep11_kblob2protkey(u16 card, u16 dom, const u8 *keyblob, size_t keybloblen, · 1 unmodified line
13001299 /* raw EP11 key blob */
13011300 key = keyblob;
13021301 keylen = keybloblen;
1303− } else
1302+ } else {
13041303 return -EINVAL;
1304+ }
13051305
13061306 /* alloc temp working buffer */
13071307 wkbuflen = (keylen + AES_BLOCK_SIZE) & (~(AES_BLOCK_SIZE - 1));
@@ -1318,12 +1318,12 @@ int ep11_kblob2protkey(u16 card, u16 dom, const u8 *keyblob, size_t keybloblen, · 10 unmodified lines
13181318 __func__, rc);
13191319 goto out;
13201320 }
1321− wki = (struct wk_info *) wkbuf;
1321+ wki = (struct wk_info *)wkbuf;
13221322
13231323 /* check struct version and pkey type */
13241324 if (wki->version != 1 || wki->pkeytype < 1 || wki->pkeytype > 5) {
13251325 DEBUG_ERR("%s wk info version %d or pkeytype %d mismatch.\n",
1326− __func__, (int) wki->version, (int) wki->pkeytype);
1326+ __func__, (int)wki->version, (int)wki->pkeytype);
13271327 rc = -EIO;
13281328 goto out;
13291329 }
@@ -1332,24 +1332,24 @@ int ep11_kblob2protkey(u16 card, u16 dom, const u8 *keyblob, size_t keybloblen, · 2 unmodified lines
13321332 switch (wki->pkeytype) {
13331333 case 1: /* AES */
13341334 switch (wki->pkeysize) {
1335− case 16+32:
1335+ case 16 + 32:
13361336 /* AES 128 protected key */
13371337 if (protkeytype)
13381338 *protkeytype = PKEY_KEYTYPE_AES_128;
13391339 break;
1340− case 24+32:
1340+ case 24 + 32:
13411341 /* AES 192 protected key */
13421342 if (protkeytype)
13431343 *protkeytype = PKEY_KEYTYPE_AES_192;
13441344 break;
1345− case 32+32:
1345+ case 32 + 32:
13461346 /* AES 256 protected key */
13471347 if (protkeytype)
13481348 *protkeytype = PKEY_KEYTYPE_AES_256;
13491349 break;
13501350 default:
13511351 DEBUG_ERR("%s unknown/unsupported AES pkeysize %d\n",
1352− __func__, (int) wki->pkeysize);
1352+ __func__, (int)wki->pkeysize);
13531353 rc = -EIO;
13541354 goto out;
13551355 }
@@ -1363,7 +1363,7 @@ int ep11_kblob2protkey(u16 card, u16 dom, const u8 *keyblob, size_t keybloblen, · 7 unmodified lines
13631363 case 2: /* TDES */
13641364 default:
13651365 DEBUG_ERR("%s unknown/unsupported key type %d\n",
1366− __func__, (int) wki->pkeytype);
1366+ __func__, (int)wki->pkeytype);
13671367 rc = -EIO;
13681368 goto out;
13691369 }
@@ -1445,7 +1445,7 @@ int ep11_findcard2(u32 **apqns, u32 *nr_apqns, u16 cardnr, u16 domain, · 75 unmodified lines
14451445 }
14461446 /* apqn passed all filtering criterons, add to the array */
14471447 if (_nr_apqns < 256)
1448− _apqns[_nr_apqns++] = (((u16)card) << 16) | ((u16) dom);
1448+ _apqns[_nr_apqns++] = (((u16)card) << 16) | ((u16)dom);
14491449 }
14501450
14511451 /* nothing found ? */
drivers/s390/crypto/zcrypt_ep11misc.h+1−1
@@ -50,7 +50,7 @@ struct ep11keyblob { · 49 unmodified lines
5050 /* check ep11 key magic to find out if this is an ep11 key blob */
5151 static inline bool is_ep11_keyblob(const u8 *key)
5252 {
53− struct ep11keyblob *kb = (struct ep11keyblob *) key;
53+ struct ep11keyblob *kb = (struct ep11keyblob *)key;
5454
5555 return (kb->version == EP11_STRUCT_MAGIC);
5656 }
drivers/s390/crypto/zcrypt_error.h+2−1
@@ -121,10 +121,11 @@ static inline int convert_error(struct zcrypt_queue *zq, · 120 unmodified lines
121121 ZCRYPT_DBF_WARN(
122122 "%s dev=%02x.%04x RY=0x%02x apfs=0x%x => bus rescan, rc=EAGAIN\n",
123123 __func__, card, queue, ehdr->reply_code, apfs);
124− } else
124+ } else {
125125 ZCRYPT_DBF_WARN("%s dev=%02x.%04x RY=0x%02x => bus rescan, rc=EAGAIN\n",
126126 __func__, card, queue,
127127 ehdr->reply_code);
128+ }
128129 return -EAGAIN;
129130 default:
130131 /* Assume request is valid and a retry will be worth it */
drivers/s390/crypto/zcrypt_msgtype50.c+18−13
@@ -158,7 +158,6 @@ struct type80_hdr { · 157 unmodified lines
158158
159159 int get_rsa_modex_fc(struct ica_rsa_modexpo *mex, int *fcode)
160160 {
161−
162161 if (!mex->inputdatalength)
163162 return -EINVAL;
164163
@@ -174,7 +173,6 @@ int get_rsa_modex_fc(struct ica_rsa_modexpo *mex, int *fcode) · 9 unmodified lines
174173
175174 int get_rsa_crt_fc(struct ica_rsa_modexpo_crt *crt, int *fcode)
176175 {
177−
178176 if (!crt->inputdatalength)
179177 return -EINVAL;
180178
@@ -239,8 +237,9 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq, · 58 unmodified lines
239237 mod = meb3->modulus + sizeof(meb3->modulus) - mod_len;
240238 exp = meb3->exponent + sizeof(meb3->exponent) - mod_len;
241239 inp = meb3->message + sizeof(meb3->message) - mod_len;
242− } else
240+ } else {
243241 return -EINVAL;
242+ }
244243
245244 if (copy_from_user(mod, mex->n_modulus, mod_len) ||
246245 copy_from_user(exp, mex->b_key, mod_len) ||
@@ -323,8 +322,9 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq, · 76 unmodified lines
323322 dq = crb3->dq + sizeof(crb3->dq) - short_len;
324323 u = crb3->u + sizeof(crb3->u) - short_len;
325324 inp = crb3->message + sizeof(crb3->message) - mod_len;
326− } else
325+ } else {
327326 return -EINVAL;
327+ }
328328
329329 /*
330330 * correct the offset of p, bp and mult_inv according zcrypt.h
@@ -392,7 +392,7 @@ static int convert_response_cex2a(struct zcrypt_queue *zq, · 61 unmodified lines
392392 unsigned int outputdatalength)
393393 {
394394 /* Response type byte is the second byte in the response. */
395− unsigned char rtype = ((unsigned char *) reply->msg)[1];
395+ unsigned char rtype = ((unsigned char *)reply->msg)[1];
396396
397397 switch (rtype) {
398398 case TYPE82_RSP_CODE:
@@ -406,11 +406,11 @@ static int convert_response_cex2a(struct zcrypt_queue *zq, · 7 unmodified lines
406406 pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
407407 AP_QID_CARD(zq->queue->qid),
408408 AP_QID_QUEUE(zq->queue->qid),
409− (int) rtype);
409+ (int)rtype);
410410 ZCRYPT_DBF_ERR(
411411 "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
412412 __func__, AP_QID_CARD(zq->queue->qid),
413− AP_QID_QUEUE(zq->queue->qid), (int) rtype);
413+ AP_QID_QUEUE(zq->queue->qid), (int)rtype);
414414 ap_send_online_uevent(&zq->queue->ap_dev, zq->online);
415415 return -EAGAIN;
416416 }
@@ -447,10 +447,11 @@ static void zcrypt_cex2a_receive(struct ap_queue *aq, · 30 unmodified lines
447447 memcpy(msg->msg, reply->msg, len);
448448 msg->len = len;
449449 }
450− } else
450+ } else {
451451 memcpy(msg->msg, reply->msg, sizeof(error_reply));
452+ }
452453 out:
453− complete((struct completion *) msg->private);
454+ complete((struct completion *)msg->private);
454455 }
455456
456457 static atomic_t zcrypt_step = ATOMIC_INIT(0);
@@ -475,7 +476,7 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq, · 18 unmodified lines
475476 if (!ap_msg->msg)
476477 return -ENOMEM;
477478 ap_msg->receive = zcrypt_cex2a_receive;
478− ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
479+ ap_msg->psmid = (((unsigned long long)current->pid) << 32) +
479480 atomic_inc_return(&zcrypt_step);
480481 ap_msg->private = &work;
481482 rc = ICAMEX_msg_to_type50MEX_msg(zq, ap_msg, mex);
@@ -492,9 +493,11 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq, · 10 unmodified lines
492493 rc = convert_response_cex2a(zq, ap_msg,
493494 mex->outputdata,
494495 mex->outputdatalength);
495− } else
496+ } else {
496497 /* Signal pending. */
497498 ap_cancel_message(zq->queue, ap_msg);
499+ }
500+
498501 out:
499502 ap_msg->private = NULL;
500503 if (rc)
@@ -524,7 +527,7 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq, · 23 unmodified lines
524527 if (!ap_msg->msg)
525528 return -ENOMEM;
526529 ap_msg->receive = zcrypt_cex2a_receive;
527− ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
530+ ap_msg->psmid = (((unsigned long long)current->pid) << 32) +
528531 atomic_inc_return(&zcrypt_step);
529532 ap_msg->private = &work;
530533 rc = ICACRT_msg_to_type50CRT_msg(zq, ap_msg, crt);
@@ -541,9 +544,11 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq, · 10 unmodified lines
541544 rc = convert_response_cex2a(zq, ap_msg,
542545 crt->outputdata,
543546 crt->outputdatalength);
544− } else
547+ } else {
545548 /* Signal pending. */
546549 ap_cancel_message(zq->queue, ap_msg);
550+ }
551+
547552 out:
548553 ap_msg->private = NULL;
549554 if (rc)
drivers/s390/crypto/zcrypt_msgtype6.c+147−193
@@ -1,6 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0+
22 /*
3− * Copyright IBM Corp. 2001, 2012
3+ * Copyright IBM Corp. 2001, 2022
44 * Author(s): Robert Burroughs
55 * Eric Rossman (edrossma@us.ibm.com)
66 *
@@ -29,12 +29,13 @@ · 22 unmodified lines
2929
3030 #define CEXXC_MAX_ICA_RESPONSE_SIZE 0x77c /* max size type86 v2 reply */
3131
32−#define CEIL4(x) ((((x)+3)/4)*4)
32+#define CEIL4(x) ((((x) + 3) / 4) * 4)
3333
3434 struct response_type {
3535 struct completion work;
3636 int type;
3737 };
38+
3839 #define CEXXC_RESPONSE_TYPE_ICA 0
3940 #define CEXXC_RESPONSE_TYPE_XCRB 1
4041 #define CEXXC_RESPONSE_TYPE_EP11 2
@@ -44,63 +45,6 @@ MODULE_DESCRIPTION("Cryptographic Coprocessor (message type 6), " \ · 3 unmodified lines
4445 "Copyright IBM Corp. 2001, 2012");
4546 MODULE_LICENSE("GPL");
4647
47−/*
48− * CPRB
49− * Note that all shorts, ints and longs are little-endian.
50− * All pointer fields are 32-bits long, and mean nothing
51− *
52− * A request CPRB is followed by a request_parameter_block.
53− *
54− * The request (or reply) parameter block is organized thus:
55− * function code
56− * VUD block
57− * key block
58− */
59−struct CPRB {
60− unsigned short cprb_len; /* CPRB length */
61− unsigned char cprb_ver_id; /* CPRB version id. */
62− unsigned char pad_000; /* Alignment pad byte. */
63− unsigned char srpi_rtcode[4]; /* SRPI return code LELONG */
64− unsigned char srpi_verb; /* SRPI verb type */
65− unsigned char flags; /* flags */
66− unsigned char func_id[2]; /* function id */
67− unsigned char checkpoint_flag; /* */
68− unsigned char resv2; /* reserved */
69− unsigned short req_parml; /* request parameter buffer */
70− /* length 16-bit little endian */
71− unsigned char req_parmp[4]; /* request parameter buffer *
72− * pointer (means nothing: the *
73− * parameter buffer follows *
74− * the CPRB). */
75− unsigned char req_datal[4]; /* request data buffer */
76− /* length ULELONG */
77− unsigned char req_datap[4]; /* request data buffer */
78− /* pointer */
79− unsigned short rpl_parml; /* reply parameter buffer */
80− /* length 16-bit little endian */
81− unsigned char pad_001[2]; /* Alignment pad bytes. ULESHORT */
82− unsigned char rpl_parmp[4]; /* reply parameter buffer *
83− * pointer (means nothing: the *
84− * parameter buffer follows *
85− * the CPRB). */
86− unsigned char rpl_datal[4]; /* reply data buffer len ULELONG */
87− unsigned char rpl_datap[4]; /* reply data buffer */
88− /* pointer */
89− unsigned short ccp_rscode; /* server reason code ULESHORT */
90− unsigned short ccp_rtcode; /* server return code ULESHORT */
91− unsigned char repd_parml[2]; /* replied parameter len ULESHORT*/
92− unsigned char mac_data_len[2]; /* Mac Data Length ULESHORT */
93− unsigned char repd_datal[4]; /* replied data length ULELONG */
94− unsigned char req_pc[2]; /* PC identifier */
95− unsigned char res_origin[8]; /* resource origin */
96− unsigned char mac_value[8]; /* Mac Value */
97− unsigned char logon_id[8]; /* Logon Identifier */
98− unsigned char usage_domain[2]; /* cdx */
99− unsigned char resv3[18]; /* reserved for requestor */
100− unsigned short svr_namel; /* server name length ULESHORT */
101− unsigned char svr_name[8]; /* server name */
102−} __packed;
103−
10448 struct function_and_rules_block {
10549 unsigned char function_code[2];
10650 unsigned short ulen;
@@ -235,7 +179,6 @@ int speed_idx_ep11(int req_type) · 128 unmodified lines
235179 }
236180 }
237181
238−
239182 /*
240183 * Convert a ICAMEX message to a type6 MEX message.
241184 *
@@ -245,7 +188,7 @@ int speed_idx_ep11(int req_type) · 3 unmodified lines
245188 *
246189 * Returns 0 on success or negative errno value.
247190 */
248−static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq,
191+static int icamex_msg_to_type6mex_msgx(struct zcrypt_queue *zq,
249192 struct ap_message *ap_msg,
250193 struct ica_rsa_modexpo *mex)
251194 {
@@ -283,19 +226,19 @@ static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq, · 31 unmodified lines
283226 return -EFAULT;
284227
285228 /* Set up key which is located after the variable length text. */
286− size = zcrypt_type6_mex_key_en(mex, msg->text+mex->inputdatalength);
229+ size = zcrypt_type6_mex_key_en(mex, msg->text + mex->inputdatalength);
287230 if (size < 0)
288231 return size;
289232 size += sizeof(*msg) + mex->inputdatalength;
290233
291234 /* message header, cprbx and f&r */
292235 msg->hdr = static_type6_hdrX;
293− msg->hdr.ToCardLen1 = size - sizeof(msg->hdr);
294− msg->hdr.FromCardLen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr);
236+ msg->hdr.tocardlen1 = size - sizeof(msg->hdr);
237+ msg->hdr.fromcardlen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr);
295238
296239 msg->cprbx = static_cprbx;
297240 msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid);
298− msg->cprbx.rpl_msgbl = msg->hdr.FromCardLen1;
241+ msg->cprbx.rpl_msgbl = msg->hdr.fromcardlen1;
299242
300243 msg->fr = static_pke_fnr;
301244
@@ -314,7 +257,7 @@ static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq, · 12 unmodified lines
314257 *
315258 * Returns 0 on success or negative errno value.
316259 */
317−static int ICACRT_msg_to_type6CRT_msgX(struct zcrypt_queue *zq,
260+static int icacrt_msg_to_type6crt_msgx(struct zcrypt_queue *zq,
318261 struct ap_message *ap_msg,
319262 struct ica_rsa_modexpo_crt *crt)
320263 {
@@ -360,8 +303,8 @@ static int ICACRT_msg_to_type6CRT_msgX(struct zcrypt_queue *zq, · 39 unmodified lines
360303
361304 /* message header, cprbx and f&r */
362305 msg->hdr = static_type6_hdrX;
363− msg->hdr.ToCardLen1 = size - sizeof(msg->hdr);
364− msg->hdr.FromCardLen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr);
306+ msg->hdr.tocardlen1 = size - sizeof(msg->hdr);
307+ msg->hdr.fromcardlen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr);
365308
366309 msg->cprbx = static_cprbx;
367310 msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid);
@@ -388,8 +331,8 @@ struct type86_fmt2_msg { · 20 unmodified lines
388331 struct type86_fmt2_ext fmt2;
389332 } __packed;
390333
391−static int XCRB_msg_to_type6CPRB_msgX(bool userspace, struct ap_message *ap_msg,
392− struct ica_xcRB *xcRB,
334+static int xcrb_msg_to_type6cprb_msgx(bool userspace, struct ap_message *ap_msg,
335+ struct ica_xcRB *xcrb,
393336 unsigned int *fcode,
394337 unsigned short **dom)
395338 {
@@ -402,19 +345,19 @@ static int XCRB_msg_to_type6CPRB_msgX(bool userspace, struct ap_message *ap_msg, · 6 unmodified lines
402345 struct CPRBX cprbx;
403346 } __packed * msg = ap_msg->msg;
404347
405− int rcblen = CEIL4(xcRB->request_control_blk_length);
348+ int rcblen = CEIL4(xcrb->request_control_blk_length);
406349 int req_sumlen, resp_sumlen;
407350 char *req_data = ap_msg->msg + sizeof(struct type6_hdr) + rcblen;
408351 char *function_code;
409352
410− if (CEIL4(xcRB->request_control_blk_length) <
411− xcRB->request_control_blk_length)
353+ if (CEIL4(xcrb->request_control_blk_length) <
354+ xcrb->request_control_blk_length)
412355 return -EINVAL; /* overflow after alignment*/
413356
414357 /* length checks */
415358 ap_msg->len = sizeof(struct type6_hdr) +
416− CEIL4(xcRB->request_control_blk_length) +
417− xcRB->request_data_length;
359+ CEIL4(xcrb->request_control_blk_length) +
360+ xcrb->request_data_length;
418361 if (ap_msg->len > ap_msg->bufsize)
419362 return -EINVAL;
420363
@@ -422,48 +365,49 @@ static int XCRB_msg_to_type6CPRB_msgX(bool userspace, struct ap_message *ap_msg, · 1 unmodified line
422365 * Overflow check
423366 * sum must be greater (or equal) than the largest operand
424367 */
425− req_sumlen = CEIL4(xcRB->request_control_blk_length) +
426− xcRB->request_data_length;
427− if ((CEIL4(xcRB->request_control_blk_length) <=
428− xcRB->request_data_length) ?
429− (req_sumlen < xcRB->request_data_length) :
430− (req_sumlen < CEIL4(xcRB->request_control_blk_length))) {
368+ req_sumlen = CEIL4(xcrb->request_control_blk_length) +
369+ xcrb->request_data_length;
370+ if ((CEIL4(xcrb->request_control_blk_length) <=
371+ xcrb->request_data_length) ?
372+ req_sumlen < xcrb->request_data_length :
373+ req_sumlen < CEIL4(xcrb->request_control_blk_length)) {
431374 return -EINVAL;
432375 }
433376
434− if (CEIL4(xcRB->reply_control_blk_length) <
435− xcRB->reply_control_blk_length)
377+ if (CEIL4(xcrb->reply_control_blk_length) <
378+ xcrb->reply_control_blk_length)
436379 return -EINVAL; /* overflow after alignment*/
437380
438381 /*
439382 * Overflow check
440383 * sum must be greater (or equal) than the largest operand
441384 */
442− resp_sumlen = CEIL4(xcRB->reply_control_blk_length) +
443− xcRB->reply_data_length;
444− if ((CEIL4(xcRB->reply_control_blk_length) <= xcRB->reply_data_length) ?
445− (resp_sumlen < xcRB->reply_data_length) :
446− (resp_sumlen < CEIL4(xcRB->reply_control_blk_length))) {
385+ resp_sumlen = CEIL4(xcrb->reply_control_blk_length) +
386+ xcrb->reply_data_length;
387+ if ((CEIL4(xcrb->reply_control_blk_length) <=
388+ xcrb->reply_data_length) ?
389+ resp_sumlen < xcrb->reply_data_length :
390+ resp_sumlen < CEIL4(xcrb->reply_control_blk_length)) {
447391 return -EINVAL;
448392 }
449393
450394 /* prepare type6 header */
451395 msg->hdr = static_type6_hdrX;
452− memcpy(msg->hdr.agent_id, &(xcRB->agent_ID), sizeof(xcRB->agent_ID));
453− msg->hdr.ToCardLen1 = xcRB->request_control_blk_length;
454− if (xcRB->request_data_length) {
396+ memcpy(msg->hdr.agent_id, &xcrb->agent_ID, sizeof(xcrb->agent_ID));
397+ msg->hdr.tocardlen1 = xcrb->request_control_blk_length;
398+ if (xcrb->request_data_length) {
455399 msg->hdr.offset2 = msg->hdr.offset1 + rcblen;
456− msg->hdr.ToCardLen2 = xcRB->request_data_length;
400+ msg->hdr.tocardlen2 = xcrb->request_data_length;
457401 }
458− msg->hdr.FromCardLen1 = xcRB->reply_control_blk_length;
459− msg->hdr.FromCardLen2 = xcRB->reply_data_length;
402+ msg->hdr.fromcardlen1 = xcrb->reply_control_blk_length;
403+ msg->hdr.fromcardlen2 = xcrb->reply_data_length;
460404
461405 /* prepare CPRB */
462− if (z_copy_from_user(userspace, &(msg->cprbx), xcRB->request_control_blk_addr,
463− xcRB->request_control_blk_length))
406+ if (z_copy_from_user(userspace, &msg->cprbx, xcrb->request_control_blk_addr,
407+ xcrb->request_control_blk_length))
464408 return -EFAULT;
465409 if (msg->cprbx.cprb_len + sizeof(msg->hdr.function_code) >
466− xcRB->request_control_blk_length)
410+ xcrb->request_control_blk_length)
467411 return -EINVAL;
468412 function_code = ((unsigned char *)&msg->cprbx) + msg->cprbx.cprb_len;
469413 memcpy(msg->hdr.function_code, function_code,
@@ -473,8 +417,8 @@ static int XCRB_msg_to_type6CPRB_msgX(bool userspace, struct ap_message *ap_msg, · 3 unmodified lines
473417 *dom = (unsigned short *)&msg->cprbx.domain;
474418
475419 /* check subfunction, US and AU need special flag with NQAP */
476− if (memcmp(function_code, "US", 2) == 0
477− || memcmp(function_code, "AU", 2) == 0)
420+ if (memcmp(function_code, "US", 2) == 0 ||
421+ memcmp(function_code, "AU", 2) == 0)
478422 ap_msg->flags |= AP_MSG_FLAG_SPECIAL;
479423
480424 #ifdef CONFIG_ZCRYPT_DEBUG
@@ -500,16 +444,16 @@ static int XCRB_msg_to_type6CPRB_msgX(bool userspace, struct ap_message *ap_msg, · 19 unmodified lines
500444 }
501445
502446 /* copy data block */
503− if (xcRB->request_data_length &&
504− z_copy_from_user(userspace, req_data, xcRB->request_data_address,
505− xcRB->request_data_length))
447+ if (xcrb->request_data_length &&
448+ z_copy_from_user(userspace, req_data, xcrb->request_data_address,
449+ xcrb->request_data_length))
506450 return -EFAULT;
507451
508452 return 0;
509453 }
510454
511455 static int xcrb_msg_to_type6_ep11cprb_msgx(bool userspace, struct ap_message *ap_msg,
512− struct ep11_urb *xcRB,
456+ struct ep11_urb *xcrb,
513457 unsigned int *fcode,
514458 unsigned int *domain)
515459 {
@@ -539,25 +483,25 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(bool userspace, struct ap_message *ap · 23 unmodified lines
539483 unsigned int dom_val; /* domain id */
540484 } __packed * payload_hdr = NULL;
541485
542− if (CEIL4(xcRB->req_len) < xcRB->req_len)
486+ if (CEIL4(xcrb->req_len) < xcrb->req_len)
543487 return -EINVAL; /* overflow after alignment*/
544488
545489 /* length checks */
546− ap_msg->len = sizeof(struct type6_hdr) + CEIL4(xcRB->req_len);
490+ ap_msg->len = sizeof(struct type6_hdr) + CEIL4(xcrb->req_len);
547491 if (ap_msg->len > ap_msg->bufsize)
548492 return -EINVAL;
549493
550− if (CEIL4(xcRB->resp_len) < xcRB->resp_len)
494+ if (CEIL4(xcrb->resp_len) < xcrb->resp_len)
551495 return -EINVAL; /* overflow after alignment*/
552496
553497 /* prepare type6 header */
554498 msg->hdr = static_type6_ep11_hdr;
555− msg->hdr.ToCardLen1 = xcRB->req_len;
556− msg->hdr.FromCardLen1 = xcRB->resp_len;
499+ msg->hdr.tocardlen1 = xcrb->req_len;
500+ msg->hdr.fromcardlen1 = xcrb->resp_len;
557501
558502 /* Import CPRB data from the ioctl input parameter */
559− if (z_copy_from_user(userspace, &(msg->cprbx.cprb_len),
560− (char __force __user *)xcRB->req, xcRB->req_len)) {
503+ if (z_copy_from_user(userspace, &msg->cprbx.cprb_len,
504+ (char __force __user *)xcrb->req, xcrb->req_len)) {
561505 return -EFAULT;
562506 }
563507
@@ -575,7 +519,7 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(bool userspace, struct ap_message *ap · 11 unmodified lines
575519 } else {
576520 lfmt = 1; /* length format #1 */
577521 }
578− payload_hdr = (struct pld_hdr *)((&(msg->pld_lenfmt))+lfmt);
522+ payload_hdr = (struct pld_hdr *)((&msg->pld_lenfmt) + lfmt);
579523 *fcode = payload_hdr->func_val & 0xFFFF;
580524
581525 /* enable special processing based on the cprbs flags special bit */
@@ -624,9 +568,9 @@ struct type86_ep11_reply { · 42 unmodified lines
624568 } __packed;
625569
626570 static int convert_type86_ica(struct zcrypt_queue *zq,
627− struct ap_message *reply,
628− char __user *outputdata,
629− unsigned int outputdatalength)
571+ struct ap_message *reply,
572+ char __user *outputdata,
573+ unsigned int outputdatalength)
630574 {
631575 static unsigned char static_pad[] = {
632576 0x00, 0x02,
@@ -679,18 +623,18 @@ static int convert_type86_ica(struct zcrypt_queue *zq, · 46 unmodified lines
679623 ZCRYPT_DBF_WARN("%s dev=%02x.%04x rc/rs=%d/%d => rc=EINVAL\n",
680624 __func__, AP_QID_CARD(zq->queue->qid),
681625 AP_QID_QUEUE(zq->queue->qid),
682− (int) service_rc, (int) service_rs);
626+ (int)service_rc, (int)service_rs);
683627 return -EINVAL;
684628 }
685629 zq->online = 0;
686630 pr_err("Crypto dev=%02x.%04x rc/rs=%d/%d online=0 rc=EAGAIN\n",
687631 AP_QID_CARD(zq->queue->qid),
688632 AP_QID_QUEUE(zq->queue->qid),
689− (int) service_rc, (int) service_rs);
633+ (int)service_rc, (int)service_rs);
690634 ZCRYPT_DBF_ERR("%s dev=%02x.%04x rc/rs=%d/%d => online=0 rc=EAGAIN\n",
691635 __func__, AP_QID_CARD(zq->queue->qid),
692636 AP_QID_QUEUE(zq->queue->qid),
693− (int) service_rc, (int) service_rs);
637+ (int)service_rc, (int)service_rs);
694638 ap_send_online_uevent(&zq->queue->ap_dev, zq->online);
695639 return -EAGAIN;
696640 }
@@ -729,42 +673,42 @@ static int convert_type86_ica(struct zcrypt_queue *zq, · 32 unmodified lines
729673 *
730674 * @zq: crypto device pointer
731675 * @reply: reply AP message.
732− * @xcRB: pointer to XCRB
676+ * @xcrb: pointer to XCRB
733677 *
734678 * Returns 0 on success or -EINVAL, -EFAULT, -EAGAIN in case of an error.
735679 */
736680 static int convert_type86_xcrb(bool userspace, struct zcrypt_queue *zq,
737681 struct ap_message *reply,
738− struct ica_xcRB *xcRB)
682+ struct ica_xcRB *xcrb)
739683 {
740684 struct type86_fmt2_msg *msg = reply->msg;
741685 char *data = reply->msg;
742686
743687 /* Copy CPRB to user */
744− if (xcRB->reply_control_blk_length < msg->fmt2.count1) {
688+ if (xcrb->reply_control_blk_length < msg->fmt2.count1) {
745689 ZCRYPT_DBF_DBG("%s reply_control_blk_length %u < required %u => EMSGSIZE\n",
746− __func__, xcRB->reply_control_blk_length,
690+ __func__, xcrb->reply_control_blk_length,
747691 msg->fmt2.count1);
748692 return -EMSGSIZE;
749693 }
750− if (z_copy_to_user(userspace, xcRB->reply_control_blk_addr,
694+ if (z_copy_to_user(userspace, xcrb->reply_control_blk_addr,
751695 data + msg->fmt2.offset1, msg->fmt2.count1))
752696 return -EFAULT;
753− xcRB->reply_control_blk_length = msg->fmt2.count1;
697+ xcrb->reply_control_blk_length = msg->fmt2.count1;
754698
755699 /* Copy data buffer to user */
756700 if (msg->fmt2.count2) {
757− if (xcRB->reply_data_length < msg->fmt2.count2) {
701+ if (xcrb->reply_data_length < msg->fmt2.count2) {
758702 ZCRYPT_DBF_DBG("%s reply_data_length %u < required %u => EMSGSIZE\n",
759− __func__, xcRB->reply_data_length,
703+ __func__, xcrb->reply_data_length,
760704 msg->fmt2.count2);
761705 return -EMSGSIZE;
762706 }
763− if (z_copy_to_user(userspace, xcRB->reply_data_addr,
707+ if (z_copy_to_user(userspace, xcrb->reply_data_addr,
764708 data + msg->fmt2.offset2, msg->fmt2.count2))
765709 return -EFAULT;
766710 }
767− xcRB->reply_data_length = msg->fmt2.count2;
711+ xcrb->reply_data_length = msg->fmt2.count2;
768712
769713 return 0;
770714 }
@@ -774,35 +718,35 @@ static int convert_type86_xcrb(bool userspace, struct zcrypt_queue *zq, · 3 unmodified lines
774718 *
775719 * @zq: crypto device pointer
776720 * @reply: reply AP message.
777− * @xcRB: pointer to EP11 user request block
721+ * @xcrb: pointer to EP11 user request block
778722 *
779723 * Returns 0 on success or -EINVAL, -EFAULT, -EAGAIN in case of an error.
780724 */
781725 static int convert_type86_ep11_xcrb(bool userspace, struct zcrypt_queue *zq,
782726 struct ap_message *reply,
783− struct ep11_urb *xcRB)
727+ struct ep11_urb *xcrb)
784728 {
785729 struct type86_fmt2_msg *msg = reply->msg;
786730 char *data = reply->msg;
787731
788− if (xcRB->resp_len < msg->fmt2.count1) {
732+ if (xcrb->resp_len < msg->fmt2.count1) {
789733 ZCRYPT_DBF_DBG("%s resp_len %u < required %u => EMSGSIZE\n",
790− __func__, (unsigned int)xcRB->resp_len,
734+ __func__, (unsigned int)xcrb->resp_len,
791735 msg->fmt2.count1);
792736 return -EMSGSIZE;
793737 }
794738
795739 /* Copy response CPRB to user */
796− if (z_copy_to_user(userspace, (char __force __user *)xcRB->resp,
740+ if (z_copy_to_user(userspace, (char __force __user *)xcrb->resp,
797741 data + msg->fmt2.offset1, msg->fmt2.count1))
798742 return -EFAULT;
799− xcRB->resp_len = msg->fmt2.count1;
743+ xcrb->resp_len = msg->fmt2.count1;
800744 return 0;
801745 }
802746
803747 static int convert_type86_rng(struct zcrypt_queue *zq,
804− struct ap_message *reply,
805− char *buffer)
748+ struct ap_message *reply,
749+ char *buffer)
806750 {
807751 struct {
808752 struct type86_hdr hdr;
@@ -818,9 +762,9 @@ static int convert_type86_rng(struct zcrypt_queue *zq, · 9 unmodified lines
818762 }
819763
820764 static int convert_response_ica(struct zcrypt_queue *zq,
821− struct ap_message *reply,
822− char __user *outputdata,
823− unsigned int outputdatalength)
765+ struct ap_message *reply,
766+ char __user *outputdata,
767+ unsigned int outputdatalength)
824768 {
825769 struct type86x_reply *msg = reply->msg;
826770
@@ -830,13 +774,14 @@ static int convert_response_ica(struct zcrypt_queue *zq, · 3 unmodified lines
830774 return convert_error(zq, reply);
831775 case TYPE86_RSP_CODE:
832776 if (msg->cprbx.ccp_rtcode &&
833− (msg->cprbx.ccp_rscode == 0x14f) &&
834− (outputdatalength > 256)) {
777+ msg->cprbx.ccp_rscode == 0x14f &&
778+ outputdatalength > 256) {
835779 if (zq->zcard->max_exp_bit_length <= 17) {
836780 zq->zcard->max_exp_bit_length = 17;
837781 return -EAGAIN;
838− } else
782+ } else {
839783 return -EINVAL;
784+ }
840785 }
841786 if (msg->hdr.reply_code)
842787 return convert_error(zq, reply);
@@ -850,11 +795,11 @@ static int convert_response_ica(struct zcrypt_queue *zq, · 7 unmodified lines
850795 pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
851796 AP_QID_CARD(zq->queue->qid),
852797 AP_QID_QUEUE(zq->queue->qid),
853− (int) msg->hdr.type);
798+ (int)msg->hdr.type);
854799 ZCRYPT_DBF_ERR(
855800 "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
856801 __func__, AP_QID_CARD(zq->queue->qid),
857− AP_QID_QUEUE(zq->queue->qid), (int) msg->hdr.type);
802+ AP_QID_QUEUE(zq->queue->qid), (int)msg->hdr.type);
858803 ap_send_online_uevent(&zq->queue->ap_dev, zq->online);
859804 return -EAGAIN;
860805 }
@@ -862,41 +807,41 @@ static int convert_response_ica(struct zcrypt_queue *zq, · 1 unmodified line
862807
863808 static int convert_response_xcrb(bool userspace, struct zcrypt_queue *zq,
864809 struct ap_message *reply,
865− struct ica_xcRB *xcRB)
810+ struct ica_xcRB *xcrb)
866811 {
867812 struct type86x_reply *msg = reply->msg;
868813
869814 switch (msg->hdr.type) {
870815 case TYPE82_RSP_CODE:
871816 case TYPE88_RSP_CODE:
872− xcRB->status = 0x0008044DL; /* HDD_InvalidParm */
817+ xcrb->status = 0x0008044DL; /* HDD_InvalidParm */
873818 return convert_error(zq, reply);
874819 case TYPE86_RSP_CODE:
875820 if (msg->hdr.reply_code) {
876− memcpy(&(xcRB->status), msg->fmt2.apfs, sizeof(u32));
821+ memcpy(&xcrb->status, msg->fmt2.apfs, sizeof(u32));
877822 return convert_error(zq, reply);
878823 }
879824 if (msg->cprbx.cprb_ver_id == 0x02)
880− return convert_type86_xcrb(userspace, zq, reply, xcRB);
825+ return convert_type86_xcrb(userspace, zq, reply, xcrb);
881826 fallthrough; /* wrong cprb version is an unknown response */
882827 default: /* Unknown response type, this should NEVER EVER happen */
883− xcRB->status = 0x0008044DL; /* HDD_InvalidParm */
828+ xcrb->status = 0x0008044DL; /* HDD_InvalidParm */
884829 zq->online = 0;
885830 pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
886831 AP_QID_CARD(zq->queue->qid),
887832 AP_QID_QUEUE(zq->queue->qid),
888− (int) msg->hdr.type);
833+ (int)msg->hdr.type);
889834 ZCRYPT_DBF_ERR(
890835 "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
891836 __func__, AP_QID_CARD(zq->queue->qid),
892− AP_QID_QUEUE(zq->queue->qid), (int) msg->hdr.type);
837+ AP_QID_QUEUE(zq->queue->qid), (int)msg->hdr.type);
893838 ap_send_online_uevent(&zq->queue->ap_dev, zq->online);
894839 return -EAGAIN;
895840 }
896841 }
897842
898843 static int convert_response_ep11_xcrb(bool userspace, struct zcrypt_queue *zq,
899− struct ap_message *reply, struct ep11_urb *xcRB)
844+ struct ap_message *reply, struct ep11_urb *xcrb)
900845 {
901846 struct type86_ep11_reply *msg = reply->msg;
902847
@@ -908,26 +853,26 @@ static int convert_response_ep11_xcrb(bool userspace, struct zcrypt_queue *zq, · 5 unmodified lines
908853 if (msg->hdr.reply_code)
909854 return convert_error(zq, reply);
910855 if (msg->cprbx.cprb_ver_id == 0x04)
911− return convert_type86_ep11_xcrb(userspace, zq, reply, xcRB);
856+ return convert_type86_ep11_xcrb(userspace, zq, reply, xcrb);
912857 fallthrough; /* wrong cprb version is an unknown resp */
913858 default: /* Unknown response type, this should NEVER EVER happen */
914859 zq->online = 0;
915860 pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
916861 AP_QID_CARD(zq->queue->qid),
917862 AP_QID_QUEUE(zq->queue->qid),
918− (int) msg->hdr.type);
863+ (int)msg->hdr.type);
919864 ZCRYPT_DBF_ERR(
920865 "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
921866 __func__, AP_QID_CARD(zq->queue->qid),
922− AP_QID_QUEUE(zq->queue->qid), (int) msg->hdr.type);
867+ AP_QID_QUEUE(zq->queue->qid), (int)msg->hdr.type);
923868 ap_send_online_uevent(&zq->queue->ap_dev, zq->online);
924869 return -EAGAIN;
925870 }
926871 }
927872
928873 static int convert_response_rng(struct zcrypt_queue *zq,
929− struct ap_message *reply,
930− char *data)
874+ struct ap_message *reply,
875+ char *data)
931876 {
932877 struct type86x_reply *msg = reply->msg;
933878
@@ -946,11 +891,11 @@ static int convert_response_rng(struct zcrypt_queue *zq, · 12 unmodified lines
946891 pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
947892 AP_QID_CARD(zq->queue->qid),
948893 AP_QID_QUEUE(zq->queue->qid),
949− (int) msg->hdr.type);
894+ (int)msg->hdr.type);
950895 ZCRYPT_DBF_ERR(
951896 "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n",
952897 __func__, AP_QID_CARD(zq->queue->qid),
953− AP_QID_QUEUE(zq->queue->qid), (int) msg->hdr.type);
898+ AP_QID_QUEUE(zq->queue->qid), (int)msg->hdr.type);
954899 ap_send_online_uevent(&zq->queue->ap_dev, zq->online);
955900 return -EAGAIN;
956901 }
@@ -965,15 +910,15 @@ static int convert_response_rng(struct zcrypt_queue *zq, · 8 unmodified lines
965910 * @reply: pointer to the AP reply message
966911 */
967912 static void zcrypt_msgtype6_receive(struct ap_queue *aq,
968− struct ap_message *msg,
969− struct ap_message *reply)
913+ struct ap_message *msg,
914+ struct ap_message *reply)
970915 {
971916 static struct error_hdr error_reply = {
972917 .type = TYPE82_RSP_CODE,
973918 .reply_code = REP82_ERROR_MACHINE_FAILURE,
974919 };
975920 struct response_type *resp_type =
976− (struct response_type *) msg->private;
921+ (struct response_type *)msg->private;
977922 struct type86x_reply *t86r;
978923 int len;
979924
@@ -982,7 +927,7 @@ static void zcrypt_msgtype6_receive(struct ap_queue *aq, · 2 unmodified lines
982927 goto out; /* ap_msg->rc indicates the error */
983928 t86r = reply->msg;
984929 if (t86r->hdr.type == TYPE86_RSP_CODE &&
985− t86r->cprbx.cprb_ver_id == 0x02) {
930+ t86r->cprbx.cprb_ver_id == 0x02) {
986931 switch (resp_type->type) {
987932 case CEXXC_RESPONSE_TYPE_ICA:
988933 len = sizeof(struct type86x_reply) + t86r->length - 2;
@@ -1005,10 +950,11 @@ static void zcrypt_msgtype6_receive(struct ap_queue *aq, · 16 unmodified lines
1005950 default:
1006951 memcpy(msg->msg, &error_reply, sizeof(error_reply));
1007952 }
1008− } else
953+ } else {
1009954 memcpy(msg->msg, reply->msg, sizeof(error_reply));
955+ }
1010956 out:
1011− complete(&(resp_type->work));
957+ complete(&resp_type->work);
1012958 }
1013959
1014960 /*
@@ -1055,7 +1001,7 @@ static void zcrypt_msgtype6_receive_ep11(struct ap_queue *aq, · 40 unmodified lines
10551001 memcpy(msg->msg, reply->msg, sizeof(error_reply));
10561002 }
10571003 out:
1058− complete(&(resp_type->work));
1004+ complete(&resp_type->work);
10591005 }
10601006
10611007 static atomic_t zcrypt_step = ATOMIC_INIT(0);
@@ -1076,15 +1022,15 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq, · 14 unmodified lines
10761022 };
10771023 int rc;
10781024
1079− ap_msg->msg = (void *) get_zeroed_page(GFP_KERNEL);
1025+ ap_msg->msg = (void *)get_zeroed_page(GFP_KERNEL);
10801026 if (!ap_msg->msg)
10811027 return -ENOMEM;
10821028 ap_msg->bufsize = PAGE_SIZE;
10831029 ap_msg->receive = zcrypt_msgtype6_receive;
1084− ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
1030+ ap_msg->psmid = (((unsigned long long)current->pid) << 32) +
10851031 atomic_inc_return(&zcrypt_step);
10861032 ap_msg->private = &resp_type;
1087− rc = ICAMEX_msg_to_type6MEX_msgX(zq, ap_msg, mex);
1033+ rc = icamex_msg_to_type6mex_msgx(zq, ap_msg, mex);
10881034 if (rc)
10891035 goto out_free;
10901036 init_completion(&resp_type.work);
@@ -1098,11 +1044,13 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq, · 7 unmodified lines
10981044 rc = convert_response_ica(zq, ap_msg,
10991045 mex->outputdata,
11001046 mex->outputdatalength);
1101− } else
1047+ } else {
11021048 /* Signal pending. */
11031049 ap_cancel_message(zq->queue, ap_msg);
1050+ }
1051+
11041052 out_free:
1105− free_page((unsigned long) ap_msg->msg);
1053+ free_page((unsigned long)ap_msg->msg);
11061054 ap_msg->private = NULL;
11071055 ap_msg->msg = NULL;
11081056 return rc;
@@ -1124,15 +1072,15 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq, · 15 unmodified lines
11241072 };
11251073 int rc;
11261074
1127− ap_msg->msg = (void *) get_zeroed_page(GFP_KERNEL);
1075+ ap_msg->msg = (void *)get_zeroed_page(GFP_KERNEL);
11281076 if (!ap_msg->msg)
11291077 return -ENOMEM;
11301078 ap_msg->bufsize = PAGE_SIZE;
11311079 ap_msg->receive = zcrypt_msgtype6_receive;
1132− ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
1080+ ap_msg->psmid = (((unsigned long long)current->pid) << 32) +
11331081 atomic_inc_return(&zcrypt_step);
11341082 ap_msg->private = &resp_type;
1135− rc = ICACRT_msg_to_type6CRT_msgX(zq, ap_msg, crt);
1083+ rc = icacrt_msg_to_type6crt_msgx(zq, ap_msg, crt);
11361084 if (rc)
11371085 goto out_free;
11381086 init_completion(&resp_type.work);
@@ -1150,8 +1098,9 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq, · 11 unmodified lines
11501098 /* Signal pending. */
11511099 ap_cancel_message(zq->queue, ap_msg);
11521100 }
1101+
11531102 out_free:
1154− free_page((unsigned long) ap_msg->msg);
1103+ free_page((unsigned long)ap_msg->msg);
11551104 ap_msg->private = NULL;
11561105 ap_msg->msg = NULL;
11571106 return rc;
@@ -1166,7 +1115,7 @@ out_free: · 8 unmodified lines
11661115 * by the caller with ap_init_message(). Also the caller has to
11671116 * make sure ap_release_message() is always called even on failure.
11681117 */
1169−int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcRB,
1118+int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcrb,
11701119 struct ap_message *ap_msg,
11711120 unsigned int *func_code, unsigned short **dom)
11721121 {
@@ -1179,12 +1128,12 @@ int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcRB, · 6 unmodified lines
11791128 if (!ap_msg->msg)
11801129 return -ENOMEM;
11811130 ap_msg->receive = zcrypt_msgtype6_receive;
1182− ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
1131+ ap_msg->psmid = (((unsigned long long)current->pid) << 32) +
11831132 atomic_inc_return(&zcrypt_step);
11841133 ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL);
11851134 if (!ap_msg->private)
11861135 return -ENOMEM;
1187− return XCRB_msg_to_type6CPRB_msgX(userspace, ap_msg, xcRB, func_code, dom);
1136+ return xcrb_msg_to_type6cprb_msgx(userspace, ap_msg, xcrb, func_code, dom);
11881137 }
11891138
11901139 /*
@@ -1192,10 +1141,10 @@ int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcRB, · 1 unmodified line
11921141 * device to handle a send_cprb request.
11931142 * @zq: pointer to zcrypt_queue structure that identifies the
11941143 * CEXxC device to the request distributor
1195− * @xcRB: pointer to the send_cprb request buffer
1144+ * @xcrb: pointer to the send_cprb request buffer
11961145 */
11971146 static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq,
1198− struct ica_xcRB *xcRB,
1147+ struct ica_xcRB *xcrb,
11991148 struct ap_message *ap_msg)
12001149 {
12011150 int rc;
@@ -1210,11 +1159,11 @@ static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq, · 8 unmodified lines
12101159 * Set the queue's reply buffer length minus 128 byte padding
12111160 * as reply limit for the card firmware.
12121161 */
1213− msg->hdr.FromCardLen1 = min_t(unsigned int, msg->hdr.FromCardLen1,
1162+ msg->hdr.fromcardlen1 = min_t(unsigned int, msg->hdr.fromcardlen1,
12141163 zq->reply.bufsize - 128);
1215− if (msg->hdr.FromCardLen2)
1216− msg->hdr.FromCardLen2 =
1217− zq->reply.bufsize - msg->hdr.FromCardLen1 - 128;
1164+ if (msg->hdr.fromcardlen2)
1165+ msg->hdr.fromcardlen2 =
1166+ zq->reply.bufsize - msg->hdr.fromcardlen1 - 128;
12181167
12191168 init_completion(&rtype->work);
12201169 rc = ap_queue_message(zq->queue, ap_msg);
@@ -1224,10 +1173,12 @@ static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq, · 3 unmodified lines
12241173 if (rc == 0) {
12251174 rc = ap_msg->rc;
12261175 if (rc == 0)
1227− rc = convert_response_xcrb(userspace, zq, ap_msg, xcRB);
1228− } else
1176+ rc = convert_response_xcrb(userspace, zq, ap_msg, xcrb);
1177+ } else {
12291178 /* Signal pending. */
12301179 ap_cancel_message(zq->queue, ap_msg);
1180+ }
1181+
12311182 out:
12321183 if (rc)
12331184 ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n",
@@ -1258,7 +1209,7 @@ int prep_ep11_ap_msg(bool userspace, struct ep11_urb *xcrb, · 24 unmodified lines
12581209 if (!ap_msg->msg)
12591210 return -ENOMEM;
12601211 ap_msg->receive = zcrypt_msgtype6_receive_ep11;
1261− ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
1212+ ap_msg->psmid = (((unsigned long long)current->pid) << 32) +
12621213 atomic_inc_return(&zcrypt_step);
12631214 ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL);
12641215 if (!ap_msg->private)
@@ -1272,7 +1223,7 @@ int prep_ep11_ap_msg(bool userspace, struct ep11_urb *xcrb, · 7 unmodified lines
12721223 * device to handle a send_ep11_cprb request.
12731224 * @zq: pointer to zcrypt_queue structure that identifies the
12741225 * CEX4P device to the request distributor
1275− * @xcRB: pointer to the ep11 user request block
1226+ * @xcrb: pointer to the ep11 user request block
12761227 */
12771228 static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue *zq,
12781229 struct ep11_urb *xcrb,
@@ -1322,7 +1273,7 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue * · 43 unmodified lines
13221273 } else {
13231274 lfmt = 1; /* length format #1 */
13241275 }
1325− payload_hdr = (struct pld_hdr *)((&(msg->pld_lenfmt))+lfmt);
1276+ payload_hdr = (struct pld_hdr *)((&msg->pld_lenfmt) + lfmt);
13261277 payload_hdr->dom_val = (unsigned int)
13271278 AP_QID_QUEUE(zq->queue->qid);
13281279 }
@@ -1331,7 +1282,7 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue * · 2 unmodified lines
13311282 * Set the queue's reply buffer length minus the two prepend headers
13321283 * as reply limit for the card firmware.
13331284 */
1334− msg->hdr.FromCardLen1 = zq->reply.bufsize -
1285+ msg->hdr.fromcardlen1 = zq->reply.bufsize -
13351286 sizeof(struct type86_hdr) - sizeof(struct type86_fmt2_ext);
13361287
13371288 init_completion(&rtype->work);
@@ -1343,9 +1294,11 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue * · 5 unmodified lines
13431294 rc = ap_msg->rc;
13441295 if (rc == 0)
13451296 rc = convert_response_ep11_xcrb(userspace, zq, ap_msg, xcrb);
1346− } else
1297+ } else {
13471298 /* Signal pending. */
13481299 ap_cancel_message(zq->queue, ap_msg);
1300+ }
1301+
13491302 out:
13501303 if (rc)
13511304 ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n",
@@ -1366,13 +1319,13 @@ int prep_rng_ap_msg(struct ap_message *ap_msg, int *func_code, · 14 unmodified lines
13661319 if (!ap_msg->msg)
13671320 return -ENOMEM;
13681321 ap_msg->receive = zcrypt_msgtype6_receive;
1369− ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
1322+ ap_msg->psmid = (((unsigned long long)current->pid) << 32) +
13701323 atomic_inc_return(&zcrypt_step);
13711324 ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL);
13721325 if (!ap_msg->private)
13731326 return -ENOMEM;
13741327
1375− rng_type6CPRB_msgX(ap_msg, ZCRYPT_RNG_BUFFER_SIZE, domain);
1328+ rng_type6cprb_msgx(ap_msg, ZCRYPT_RNG_BUFFER_SIZE, domain);
13761329
13771330 *func_code = HWRNG;
13781331 return 0;
@@ -1411,9 +1364,10 @@ static long zcrypt_msgtype6_rng(struct zcrypt_queue *zq, · 32 unmodified lines
14111364 rc = ap_msg->rc;
14121365 if (rc == 0)
14131366 rc = convert_response_rng(zq, ap_msg, buffer);
1414− } else
1367+ } else {
14151368 /* Signal pending. */
14161369 ap_cancel_message(zq->queue, ap_msg);
1370+ }
14171371 out:
14181372 return rc;
14191373 }
drivers/s390/crypto/zcrypt_msgtype6.h+13−13
@@ -45,14 +45,14 @@ struct type6_hdr { · 44 unmodified lines
4545 unsigned char reserved5[2]; /* 0x0000 */
4646 unsigned char function_code[2]; /* for PKD, 0x5044 (ascii 'PD') */
4747 unsigned char reserved6[2]; /* 0x0000 */
48− unsigned int ToCardLen1; /* (request CPRB len + 3) & -4 */
49− unsigned int ToCardLen2; /* db len 0x00000000 for PKD */
50− unsigned int ToCardLen3; /* 0x00000000 */
51− unsigned int ToCardLen4; /* 0x00000000 */
52− unsigned int FromCardLen1; /* response buffer length */
53− unsigned int FromCardLen2; /* db len 0x00000000 for PKD */
54− unsigned int FromCardLen3; /* 0x00000000 */
55− unsigned int FromCardLen4; /* 0x00000000 */
48+ unsigned int tocardlen1; /* (request CPRB len + 3) & -4 */
49+ unsigned int tocardlen2; /* db len 0x00000000 for PKD */
50+ unsigned int tocardlen3; /* 0x00000000 */
51+ unsigned int tocardlen4; /* 0x00000000 */
52+ unsigned int fromcardlen1; /* response buffer length */
53+ unsigned int fromcardlen2; /* db len 0x00000000 for PKD */
54+ unsigned int fromcardlen3; /* 0x00000000 */
55+ unsigned int fromcardlen4; /* 0x00000000 */
5656 } __packed;
5757
5858 /**
@@ -116,7 +116,7 @@ int speed_idx_ep11(int); · 57 unmodified lines
116116 * @ap_dev: AP device pointer
117117 * @ap_msg: pointer to AP message
118118 */
119−static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg,
119+static inline void rng_type6cprb_msgx(struct ap_message *ap_msg,
120120 unsigned int random_number_length,
121121 unsigned int *domain)
122122 {
@@ -134,8 +134,8 @@ static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg, · 11 unmodified lines
134134 .offset1 = 0x00000058,
135135 .agent_id = {'C', 'A'},
136136 .function_code = {'R', 'L'},
137− .ToCardLen1 = sizeof(*msg) - sizeof(msg->hdr),
138− .FromCardLen1 = sizeof(*msg) - sizeof(msg->hdr),
137+ .tocardlen1 = sizeof(*msg) - sizeof(msg->hdr),
138+ .fromcardlen1 = sizeof(*msg) - sizeof(msg->hdr),
139139 };
140140 static struct CPRBX local_cprbx = {
141141 .cprb_len = 0x00dc,
@@ -147,9 +147,9 @@ static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg, · 5 unmodified lines
147147 };
148148
149149 msg->hdr = static_type6_hdrX;
150− msg->hdr.FromCardLen2 = random_number_length,
150+ msg->hdr.fromcardlen2 = random_number_length;
151151 msg->cprbx = local_cprbx;
152− msg->cprbx.rpl_datal = random_number_length,
152+ msg->cprbx.rpl_datal = random_number_length;
153153 memcpy(msg->function_code, msg->hdr.function_code, 0x02);
154154 msg->rule_length = 0x0a;
155155 memcpy(msg->rule, "RANDOM ", 8);
drivers/s390/crypto/zcrypt_queue.c+1−1
@@ -114,7 +114,7 @@ struct zcrypt_queue *zcrypt_queue_alloc(size_t reply_buf_size) · 113 unmodified lines
114114 {
115115 struct zcrypt_queue *zq;
116116
117− zq = kzalloc(sizeof(struct zcrypt_queue), GFP_KERNEL);
117+ zq = kzalloc(sizeof(*zq), GFP_KERNEL);
118118 if (!zq)
119119 return NULL;
120120 zq->reply.msg = kmalloc(reply_buf_size, GFP_KERNEL);
include/linux/entry-common.h+4−4
@@ -63,7 +63,7 @@ · 62 unmodified lines
6363 ARCH_EXIT_TO_USER_MODE_WORK)
6464
6565 /**
66− * arch_check_user_regs - Architecture specific sanity check for user mode regs
66+ * arch_enter_from_user_mode - Architecture specific sanity check for user mode regs
6767 * @regs: Pointer to currents pt_regs
6868 *
6969 * Defaults to an empty implementation. Can be replaced by architecture
@@ -73,10 +73,10 @@ · 3 unmodified lines
7373 * section. Use __always_inline so the compiler cannot push it out of line
7474 * and make it instrumentable.
7575 */
76−static __always_inline void arch_check_user_regs(struct pt_regs *regs);
76+static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs);
7777
78−#ifndef arch_check_user_regs
79−static __always_inline void arch_check_user_regs(struct pt_regs *regs) {}
78+#ifndef arch_enter_from_user_mode
79+static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs) {}
8080 #endif
8181
8282 /**
kernel/entry/common.c+1−1
@@ -17,7 +17,7 @@ · 16 unmodified lines
1717 /* See comment for enter_from_user_mode() in entry-common.h */
1818 static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
1919 {
20− arch_check_user_regs(regs);
20+ arch_enter_from_user_mode(regs);
2121 lockdep_hardirqs_off(CALLER_ADDR0);
2222
2323 CT_WARN_ON(ct_state() != CONTEXT_USER);
scripts/min-tool-version.sh+1−2
@@ -24,9 +24,8 @@ icc) · 23 unmodified lines
2424 echo 16.0.3
2525 ;;
2626 llvm)
27− # https://lore.kernel.org/r/YMtib5hKVyNknZt3@osiris/
2827 if [ "$SRCARCH" = s390 ]; then
29− echo 13.0.0
28+ echo 14.0.0
3029 else
3130 echo 11.0.0
3231 fi

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t