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 ...
Unified · Split
| @@ -20,7 +20,9 @@ LDFLAGS_vmlinux := -pie · 19 unmodified lines | |||
| 20 | endif | 20 | endif |
| 21 | aflags_dwarf := -Wa,-gdwarf-2 | 21 | aflags_dwarf := -Wa,-gdwarf-2 |
| 22 | KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__ | 22 | KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__ |
| 23 | ifndef CONFIG_AS_IS_LLVM | ||
| 23 | KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf)) | 24 | KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf)) |
| 25 | endif | ||
| 24 | KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack | 26 | KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack |
| 25 | KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY | 27 | KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY |
| 26 | KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain | 28 | KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain |
| @@ -2,3 +2,6 @@ · 1 unmodified line | |||
| 2 | image | 2 | image |
| 3 | bzImage | 3 | bzImage |
| 4 | section_cmp.* | 4 | section_cmp.* |
| 5 | vmlinux | ||
| 6 | vmlinux.lds | ||
| 7 | vmlinux.syms | ||
| @@ -37,14 +37,21 @@ CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char · 36 unmodified lines | |||
| 37 | 37 | ||
| 38 | obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o | 38 | obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o |
| 39 | obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o | 39 | 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 |
| 41 | obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o | 41 | obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o |
| 42 | obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o | 42 | obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o |
| 43 | obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o | 43 | obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o |
| 44 | targets := bzImage startup.a section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y) | 44 | obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o |
| 45 | subdir- := compressed | 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) | ||
| 46 | 52 | ||
| 47 | OBJECTS := $(addprefix $(obj)/,$(obj-y)) | 53 | OBJECTS := $(addprefix $(obj)/,$(obj-y)) |
| 54 | OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all)) | ||
| 48 | 55 | ||
| 49 | quiet_cmd_section_cmp = SECTCMP $* | 56 | quiet_cmd_section_cmp = SECTCMP $* |
| 50 | define cmd_section_cmp | 57 | define cmd_section_cmp |
| @@ -59,14 +66,67 @@ define cmd_section_cmp · 8 unmodified lines | |||
| 59 | touch $@ | 66 | touch $@ |
| 60 | endef | 67 | endef |
| 61 | 68 | ||
| 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 |
| 63 | $(call if_changed,objcopy) | 70 | $(call if_changed,objcopy) |
| 64 | 71 | ||
| 65 | $(obj)/section_cmp%: vmlinux $(obj)/compressed/vmlinux FORCE | 72 | $(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE |
| 66 | $(call if_changed,section_cmp) | 73 | $(call if_changed,section_cmp) |
| 67 | 74 | ||
| 68 | $(obj)/compressed/vmlinux: $(obj)/startup.a FORCE | 75 | LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T |
| 69 | $(Q)$(MAKE) $(build)=$(obj)/compressed $@ | 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 | ||
| 70 | 114 | ||
| 71 | $(obj)/startup.a: $(OBJECTS) FORCE | 115 | $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE |
| 72 | $(call if_changed,ar) | 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) | ||
| @@ -2,9 +2,12 @@ · 1 unmodified line | |||
| 2 | #ifndef BOOT_BOOT_H | 2 | #ifndef BOOT_BOOT_H |
| 3 | #define BOOT_BOOT_H | 3 | #define BOOT_BOOT_H |
| 4 | 4 | ||
| 5 | #include <asm/extable.h> | ||
| 6 | #include <linux/types.h> | 5 | #include <linux/types.h> |
| 7 | 6 | ||
| 7 | #define IPL_START 0x200 | ||
| 8 | |||
| 9 | #ifndef __ASSEMBLY__ | ||
| 10 | |||
| 8 | void startup_kernel(void); | 11 | void startup_kernel(void); |
| 9 | unsigned long detect_memory(void); | 12 | unsigned long detect_memory(void); |
| 10 | bool is_ipl_block_dump(void); | 13 | bool is_ipl_block_dump(void); |
| @@ -31,4 +34,5 @@ extern char _stack_start[], _stack_end[]; · 20 unmodified lines | |||
| 31 | 34 | ||
| 32 | unsigned long read_ipl_report(unsigned long safe_offset); | 35 | unsigned long read_ipl_report(unsigned long safe_offset); |
| 33 | 36 | ||
| 37 | #endif /* __ASSEMBLY__ */ | ||
| 34 | #endif /* BOOT_BOOT_H */ | 38 | #endif /* BOOT_BOOT_H */ |
File renamed without changes.
| @@ -1,4 +0,0 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 2 | vmlinux | ||
| 3 | vmlinux.lds | ||
| 4 | vmlinux.syms | ||
| @@ -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) | ||
File renamed without changes.
File renamed without changes.
| @@ -27,234 +27,181 @@ · 26 unmodified lines | |||
| 27 | #include <asm/page.h> | 27 | #include <asm/page.h> |
| 28 | #include <asm/ptrace.h> | 28 | #include <asm/ptrace.h> |
| 29 | #include <asm/sclp.h> | 29 | #include <asm/sclp.h> |
| 30 | 30 | #include "boot.h" | |
| 31 | #define ARCH_OFFSET 4 | ||
| 32 | 31 | ||
| 33 | #define EP_OFFSET 0x10008 | 32 | #define EP_OFFSET 0x10008 |
| 34 | #define EP_STRING "S390EP" | 33 | #define EP_STRING "S390EP" |
| 34 | #define IPL_BS 0x730 | ||
| 35 | 35 | ||
| 36 | __HEAD | 36 | __HEAD |
| 37 | 37 | ipl_start: | |
| 38 | #define IPL_BS 0x730 | 38 | mvi __LC_AR_MODE_ID,1 # set esame flag |
| 39 | .org 0 | 39 | slr %r0,%r0 # set cpuid to zero |
| 40 | .long 0x00080000,0x80000000+iplstart # The first 24 bytes are loaded | 40 | lhi %r1,2 # mode 2 = esame (dump) |
| 41 | .long 0x02000018,0x60000050 # by ipl to addresses 0-23. | 41 | sigp %r1,%r0,0x12 # switch to esame mode |
| 42 | .long 0x02000068,0x60000050 # (a PSW and two CCWs). | 42 | sam64 # switch to 64 bit addressing mode |
| 43 | .fill 80-24,1,0x40 # bytes 24-79 are discarded !! | 43 | lgh %r1,__LC_SUBCHANNEL_ID # test if subchannel number |
| 44 | .long 0x020000f0,0x60000050 # The next 160 byte are loaded | 44 | brctg %r1,.Lnoload # is valid |
| 45 | .long 0x02000140,0x60000050 # to addresses 0x18-0xb7 | 45 | llgf %r1,__LC_SUBCHANNEL_ID # load ipl subchannel number |
| 46 | .long 0x02000190,0x60000050 # They form the continuation | 46 | lghi %r2,IPL_BS # load start address |
| 47 | .long 0x020001e0,0x60000050 # of the CCW program started | 47 | bras %r14,.Lloader # load rest of ipl image |
| 48 | .long 0x02000230,0x60000050 # by ipl and load the range | 48 | larl %r12,parmarea # pointer to parameter area |
| 49 | .long 0x02000280,0x60000050 # 0x0f0-0x730 from the image | 49 | stg %r1,IPL_DEVICE-PARMAREA(%r12) # save ipl device number |
| 50 | .long 0x020002d0,0x60000050 # to the range 0x0f0-0x730 | 50 | # |
| 51 | .long 0x02000320,0x60000050 # in memory. At the end of | 51 | # load parameter file from ipl device |
| 52 | .long 0x02000370,0x60000050 # the channel program the PSW | 52 | # |
| 53 | .long 0x020003c0,0x60000050 # at location 0 is loaded. | 53 | .Lagain1: |
| 54 | .long 0x02000410,0x60000050 # Initial processing starts | 54 | larl %r2,_end # ramdisk loc. is temp |
| 55 | .long 0x02000460,0x60000050 # at 0x200 = iplstart. | 55 | bras %r14,.Lloader # load parameter file |
| 56 | .long 0x020004b0,0x60000050 | 56 | ltgr %r2,%r2 # got anything ? |
| 57 | .long 0x02000500,0x60000050 | 57 | jz .Lnopf |
| 58 | .long 0x02000550,0x60000050 | 58 | lg %r3,MAX_COMMAND_LINE_SIZE-PARMAREA(%r12) |
| 59 | .long 0x020005a0,0x60000050 | 59 | aghi %r3,-1 |
| 60 | .long 0x020005f0,0x60000050 | 60 | clgr %r2,%r3 |
| 61 | .long 0x02000640,0x60000050 | 61 | jl .Lnotrunc |
| 62 | .long 0x02000690,0x60000050 | 62 | lgr %r2,%r3 |
| 63 | .long 0x020006e0,0x20000050 | 63 | .Lnotrunc: |
| 64 | 64 | larl %r4,_end | |
| 65 | .org __LC_RST_NEW_PSW # 0x1a0 | 65 | larl %r13,.L_hdr |
| 66 | .quad 0,iplstart | 66 | clc 0(3,%r4),0(%r13) # if it is HDRx |
| 67 | .org __LC_EXT_NEW_PSW # 0x1b0 | 67 | jz .Lagain1 # skip dataset header |
| 68 | .quad 0x0002000180000000,0x1b0 # disabled wait | 68 | larl %r13,.L_eof |
| 69 | .org __LC_PGM_NEW_PSW # 0x1d0 | 69 | clc 0(3,%r4),0(%r13) # if it is EOFx |
| 70 | .quad 0x0000000180000000,startup_pgm_check_handler | 70 | jz .Lagain1 # skip dateset trailer |
| 71 | .org __LC_IO_NEW_PSW # 0x1f0 | 71 | lgr %r5,%r2 |
| 72 | .quad 0x0002000180000000,0x1f0 # disabled wait | 72 | la %r6,COMMAND_LINE-PARMAREA(%r12) |
| 73 | 73 | lgr %r7,%r2 | |
| 74 | .org 0x200 | 74 | aghi %r7,1 |
| 75 | 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 | ||
| 76 | # | 125 | # |
| 77 | # subroutine to wait for end I/O | 126 | # subroutine to wait for end I/O |
| 78 | # | 127 | # |
| 79 | .Lirqwait: | 128 | .Lirqwait: |
| 80 | mvc __LC_IO_NEW_PSW(16),.Lnewpsw # set up IO interrupt psw | 129 | larl %r13,.Lnewpswmask # set up IO interrupt psw |
| 81 | lpsw .Lwaitpsw | 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) | ||
| 82 | .Lioint: | 134 | .Lioint: |
| 83 | br %r14 | ||
| 84 | .align 8 | ||
| 85 | .Lnewpsw: | ||
| 86 | .quad 0x0000000080000000,.Lioint | ||
| 87 | .Lwaitpsw: | ||
| 88 | .long 0x020a0000,0x80000000+.Lioint | ||
| 89 | |||
| 90 | # | 135 | # |
| 91 | # subroutine for loading cards from the reader | 136 | # subroutine for loading cards from the reader |
| 92 | # | 137 | # |
| 93 | .Lloader: | 138 | .Lloader: |
| 94 | la %r4,0(%r14) | 139 | lgr %r4,%r14 |
| 95 | la %r3,.Lorb # r2 = address of orb into r2 | 140 | larl %r3,.Lorb # r2 = address of orb into r2 |
| 96 | la %r5,.Lirb # r4 = address of irb | 141 | larl %r5,.Lirb # r4 = address of irb |
| 97 | la %r6,.Lccws | 142 | larl %r6,.Lccws |
| 98 | la %r7,20 | 143 | lghi %r7,20 |
| 99 | .Linit: | 144 | .Linit: |
| 100 | st %r2,4(%r6) # initialize CCW data addresses | 145 | st %r2,4(%r6) # initialize CCW data addresses |
| 101 | la %r2,0x50(%r2) | 146 | la %r2,0x50(%r2) |
| 102 | la %r6,8(%r6) | 147 | la %r6,8(%r6) |
| 103 | bct 7,.Linit | 148 | brctg %r7,.Linit |
| 104 | 149 | larl %r13,.Lcr6 | |
| 105 | lctl %c6,%c6,.Lcr6 # set IO subclass mask | 150 | lctlg %c6,%c6,0(%r13) |
| 106 | slr %r2,%r2 | 151 | xgr %r2,%r2 |
| 107 | .Lldlp: | 152 | .Lldlp: |
| 108 | ssch 0(%r3) # load chunk of 1600 bytes | 153 | ssch 0(%r3) # load chunk of 1600 bytes |
| 109 | bnz .Llderr | 154 | jnz .Llderr |
| 110 | .Lwait4irq: | 155 | .Lwait4irq: |
| 111 | bas %r14,.Lirqwait | 156 | bras %r14,.Lirqwait |
| 112 | c %r1,__LC_SUBCHANNEL_ID # compare subchannel number | 157 | c %r1,__LC_SUBCHANNEL_ID # compare subchannel number |
| 113 | bne .Lwait4irq | 158 | jne .Lwait4irq |
| 114 | tsch 0(%r5) | 159 | tsch 0(%r5) |
| 115 | 160 | xgr %r0,%r0 | |
| 116 | slr %r0,%r0 | ||
| 117 | ic %r0,8(%r5) # get device status | 161 | ic %r0,8(%r5) # get device status |
| 118 | chi %r0,8 # channel end ? | 162 | cghi %r0,8 # channel end ? |
| 119 | be .Lcont | 163 | je .Lcont |
| 120 | chi %r0,12 # channel end + device end ? | 164 | cghi %r0,12 # channel end + device end ? |
| 121 | be .Lcont | 165 | je .Lcont |
| 122 | 166 | llgf %r0,4(%r5) | |
| 123 | l %r0,4(%r5) | 167 | sgf %r0,8(%r3) # r0/8 = number of ccws executed |
| 124 | s %r0,8(%r3) # r0/8 = number of ccws executed | 168 | mghi %r0,10 # *10 = number of bytes in ccws |
| 125 | mhi %r0,10 # *10 = number of bytes in ccws | 169 | llgh %r3,10(%r5) # get residual count |
| 126 | lh %r3,10(%r5) # get residual count | 170 | sgr %r0,%r3 # #ccws*80-residual=#bytes read |
| 127 | sr %r0,%r3 # #ccws*80-residual=#bytes read | 171 | agr %r2,%r0 |
| 128 | ar %r2,%r0 | ||
| 129 | |||
| 130 | br %r4 # r2 contains the total size | 172 | br %r4 # r2 contains the total size |
| 131 | |||
| 132 | .Lcont: | 173 | .Lcont: |
| 133 | ahi %r2,0x640 # add 0x640 to total size | 174 | aghi %r2,0x640 # add 0x640 to total size |
| 134 | la %r6,.Lccws | 175 | larl %r6,.Lccws |
| 135 | la %r7,20 | 176 | lghi %r7,20 |
| 136 | .Lincr: | 177 | .Lincr: |
| 137 | l %r0,4(%r6) # update CCW data addresses | 178 | l %r0,4(%r6) # update CCW data addresses |
| 138 | ahi %r0,0x640 | 179 | aghi %r0,0x640 |
| 139 | st %r0,4(%r6) | 180 | st %r0,4(%r6) |
| 140 | ahi %r6,8 | 181 | aghi %r6,8 |
| 141 | bct 7,.Lincr | 182 | brctg %r7,.Lincr |
| 142 | 183 | j .Lldlp | |
| 143 | b .Lldlp | ||
| 144 | .Llderr: | 184 | .Llderr: |
| 145 | lpsw .Lcrash | 185 | larl %r13,.Lcrash |
| 186 | lpsw 0(%r13) | ||
| 146 | 187 | ||
| 188 | .align 8 | ||
| 189 | .Lwaitpsw: | ||
| 190 | .quad 0x0202000180000000,.Lioint | ||
| 191 | .Lnewpswmask: | ||
| 192 | .quad 0x0000000180000000 | ||
| 147 | .align 8 | 193 | .align 8 |
| 148 | .Lorb: .long 0x00000000,0x0080ff00,.Lccws | 194 | .Lorb: .long 0x00000000,0x0080ff00,.Lccws |
| 149 | .Lirb: .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | 195 | .Lirb: .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
| 150 | .Lcr6: .long 0xff000000 | 196 | .align 8 |
| 151 | .Lloadp:.long 0,0 | 197 | .Lcr6: .quad 0x00000000ff000000 |
| 152 | .align 8 | 198 | .align 8 |
| 153 | .Lcrash:.long 0x000a0000,0x00000000 | 199 | .Lcrash:.long 0x000a0000,0x00000000 |
| 154 | |||
| 155 | .align 8 | 200 | .align 8 |
| 156 | .Lccws: .rept 19 | 201 | .Lccws: .rept 19 |
| 157 | .long 0x02600050,0x00000000 | 202 | .long 0x02600050,0x00000000 |
| 158 | .endr | 203 | .endr |
| 159 | .long 0x02200050,0x00000000 | 204 | .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 | ||
| 258 | .Lreset:.byte 0xc3,0xc8,0xc1,0xd5,0xc7,0xc5,0x40,0xd9,0xc4,0xd9,0x40 | 205 | .Lreset:.byte 0xc3,0xc8,0xc1,0xd5,0xc7,0xc5,0x40,0xd9,0xc4,0xd9,0x40 |
| 259 | .byte 0xc1,0xd3,0xd3,0x40,0xd2,0xc5,0xc5,0xd7,0x40,0xd5,0xd6 | 206 | .byte 0xc1,0xd3,0xd3,0x40,0xd2,0xc5,0xc5,0xd7,0x40,0xd5,0xd6 |
| 260 | .byte 0xc8,0xd6,0xd3,0xc4 # "change rdr all keep nohold" | 207 | .byte 0xc8,0xd6,0xd3,0xc4 # "change rdr all keep nohold" |
| @@ -268,10 +215,10 @@ iplstart: · 7 unmodified lines | |||
| 268 | # this is called either by the ipl loader or directly by PSW restart | 215 | # this is called either by the ipl loader or directly by PSW restart |
| 269 | # or linload or SALIPL | 216 | # or linload or SALIPL |
| 270 | # | 217 | # |
| 271 | .org STARTUP_NORMAL_OFFSET | 218 | .org STARTUP_NORMAL_OFFSET - IPL_START |
| 272 | SYM_CODE_START(startup) | 219 | SYM_CODE_START(startup) |
| 273 | j startup_normal | 220 | j startup_normal |
| 274 | .org EP_OFFSET | 221 | .org EP_OFFSET - IPL_START |
| 275 | # | 222 | # |
| 276 | # This is a list of s390 kernel entry points. At address 0x1000f the number of | 223 | # This is a list of s390 kernel entry points. At address 0x1000f the number of |
| 277 | # valid entry points is stored. | 224 | # valid entry points is stored. |
| @@ -283,7 +230,7 @@ SYM_CODE_START(startup) · 5 unmodified lines | |||
| 283 | # | 230 | # |
| 284 | # kdump startup-code, running in 64 bit absolute addressing mode | 231 | # kdump startup-code, running in 64 bit absolute addressing mode |
| 285 | # | 232 | # |
| 286 | .org STARTUP_KDUMP_OFFSET | 233 | .org STARTUP_KDUMP_OFFSET - IPL_START |
| 287 | j startup_kdump | 234 | j startup_kdump |
| 288 | SYM_CODE_END(startup) | 235 | SYM_CODE_END(startup) |
| 289 | SYM_CODE_START_LOCAL(startup_normal) | 236 | SYM_CODE_START_LOCAL(startup_normal) |
| @@ -295,20 +242,23 @@ SYM_CODE_START_LOCAL(startup_normal) · 5 unmodified lines | |||
| 295 | .fill 16,4,0x0 | 242 | .fill 16,4,0x0 |
| 296 | 0: lmh %r0,%r15,0(%r13) # clear high-order half of gprs | 243 | 0: lmh %r0,%r15,0(%r13) # clear high-order half of gprs |
| 297 | sam64 # switch to 64 bit addressing mode | 244 | sam64 # switch to 64 bit addressing mode |
| 298 | basr %r13,0 # get base | 245 | larl %r13,.Lext_new_psw |
| 299 | .LPG0: | 246 | mvc __LC_EXT_NEW_PSW(16),0(%r13) |
| 300 | mvc __LC_EXT_NEW_PSW(16),.Lext_new_psw-.LPG0(%r13) | 247 | larl %r13,.Lpgm_new_psw |
| 301 | mvc __LC_PGM_NEW_PSW(16),.Lpgm_new_psw-.LPG0(%r13) | 248 | mvc __LC_PGM_NEW_PSW(16),0(%r13) |
| 302 | mvc __LC_IO_NEW_PSW(16),.Lio_new_psw-.LPG0(%r13) | 249 | larl %r13,.Lio_new_psw |
| 250 | mvc __LC_IO_NEW_PSW(16),0(%r13) | ||
| 303 | xc 0x200(256),0x200 # partially clear lowcore | 251 | xc 0x200(256),0x200 # partially clear lowcore |
| 304 | xc 0x300(256),0x300 | 252 | xc 0x300(256),0x300 |
| 305 | xc 0xe00(256),0xe00 | 253 | xc 0xe00(256),0xe00 |
| 306 | xc 0xf00(256),0xf00 | 254 | 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 | ||
| 308 | stcke __LC_BOOT_CLOCK | 257 | stcke __LC_BOOT_CLOCK |
| 309 | mvc __LC_LAST_UPDATE_CLOCK(8),__LC_BOOT_CLOCK+1 | 258 | mvc __LC_LAST_UPDATE_CLOCK(8),__LC_BOOT_CLOCK+1 |
| 310 | spt 6f-.LPG0(%r13) | 259 | larl %r13,6f |
| 311 | mvc __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13) | 260 | spt 0(%r13) |
| 261 | mvc __LC_LAST_UPDATE_TIMER(8),0(%r13) | ||
| 312 | larl %r15,_stack_end-STACK_FRAME_OVERHEAD | 262 | larl %r15,_stack_end-STACK_FRAME_OVERHEAD |
| 313 | brasl %r14,sclp_early_setup_buffer | 263 | brasl %r14,sclp_early_setup_buffer |
| 314 | brasl %r14,verify_facilities | 264 | brasl %r14,verify_facilities |
| @@ -368,23 +318,3 @@ SYM_CODE_START_LOCAL(startup_pgm_check_handler) · 53 unmodified lines | |||
| 368 | lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r8) | 318 | lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r8) |
| 369 | lpswe __LC_RETURN_PSW # disabled wait | 319 | lpswe __LC_RETURN_PSW # disabled wait |
| 370 | SYM_CODE_END(startup_pgm_check_handler) | 320 | 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) | ||
| @@ -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 | }; | ||
| @@ -8,9 +8,16 @@ · 7 unmodified lines | |||
| 8 | #include <asm/sections.h> | 8 | #include <asm/sections.h> |
| 9 | #include <asm/boot_data.h> | 9 | #include <asm/boot_data.h> |
| 10 | #include <asm/facility.h> | 10 | #include <asm/facility.h> |
| 11 | #include <asm/setup.h> | ||
| 11 | #include <asm/uv.h> | 12 | #include <asm/uv.h> |
| 12 | #include "boot.h" | 13 | #include "boot.h" |
| 13 | 14 | ||
| 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 | |||
| 14 | char __bootdata(early_command_line)[COMMAND_LINE_SIZE]; | 21 | char __bootdata(early_command_line)[COMMAND_LINE_SIZE]; |
| 15 | int __bootdata(noexec_disabled); | 22 | int __bootdata(noexec_disabled); |
| 16 | 23 | ||
| @@ -8,7 +8,7 @@ · 7 unmodified lines | |||
| 8 | #include <asm/timex.h> | 8 | #include <asm/timex.h> |
| 9 | #include <asm/sclp.h> | 9 | #include <asm/sclp.h> |
| 10 | #include <asm/kasan.h> | 10 | #include <asm/kasan.h> |
| 11 | #include "compressed/decompressor.h" | 11 | #include "decompressor.h" |
| 12 | #include "boot.h" | 12 | #include "boot.h" |
| 13 | 13 | ||
| 14 | #define PRNG_MODE_TDES 1 | 14 | #define PRNG_MODE_TDES 1 |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | #include <asm/sections.h> | 7 | #include <asm/sections.h> |
| 8 | #include <asm/mem_detect.h> | 8 | #include <asm/mem_detect.h> |
| 9 | #include <asm/sparsemem.h> | 9 | #include <asm/sparsemem.h> |
| 10 | #include "compressed/decompressor.h" | 10 | #include "decompressor.h" |
| 11 | #include "boot.h" | 11 | #include "boot.h" |
| 12 | 12 | ||
| 13 | struct mem_detect_info __bootdata(mem_detect); | 13 | struct mem_detect_info __bootdata(mem_detect); |
| @@ -10,7 +10,7 @@ · 9 unmodified lines | |||
| 10 | #include <asm/sclp.h> | 10 | #include <asm/sclp.h> |
| 11 | #include <asm/diag.h> | 11 | #include <asm/diag.h> |
| 12 | #include <asm/uv.h> | 12 | #include <asm/uv.h> |
| 13 | #include "compressed/decompressor.h" | 13 | #include "decompressor.h" |
| 14 | #include "boot.h" | 14 | #include "boot.h" |
| 15 | #include "uv.h" | 15 | #include "uv.h" |
| 16 | 16 | ||
| @@ -4,6 +4,7 @@ · 3 unmodified lines | |||
| 4 | #include <asm/thread_info.h> | 4 | #include <asm/thread_info.h> |
| 5 | #include <asm/page.h> | 5 | #include <asm/page.h> |
| 6 | #include <asm/sclp.h> | 6 | #include <asm/sclp.h> |
| 7 | #include "boot.h" | ||
| 7 | 8 | ||
| 8 | OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390") | 9 | OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390") |
| 9 | OUTPUT_ARCH(s390:64-bit) | 10 | OUTPUT_ARCH(s390:64-bit) |
| @@ -13,11 +14,19 @@ ENTRY(startup) · 3 unmodified lines | |||
| 13 | SECTIONS | 14 | SECTIONS |
| 14 | { | 15 | { |
| 15 | . = 0; | 16 | . = 0; |
| 17 | .ipldata : { | ||
| 18 | *(.ipldata) | ||
| 19 | } | ||
| 20 | . = IPL_START; | ||
| 16 | .head.text : { | 21 | .head.text : { |
| 17 | _head = . ; | 22 | _head = . ; |
| 18 | HEAD_TEXT | 23 | HEAD_TEXT |
| 19 | _ehead = . ; | 24 | _ehead = . ; |
| 20 | } | 25 | } |
| 26 | . = PARMAREA; | ||
| 27 | .parmarea : { | ||
| 28 | *(.parmarea) | ||
| 29 | } | ||
| 21 | .text : { | 30 | .text : { |
| 22 | _text = .; /* Text */ | 31 | _text = .; /* Text */ |
| 23 | *(.text) | 32 | *(.text) |
| @@ -194,7 +194,7 @@ static struct skcipher_alg cbc_des_alg = { · 193 unmodified lines | |||
| 194 | * same as DES. Implementers MUST reject keys that exhibit this | 194 | * same as DES. Implementers MUST reject keys that exhibit this |
| 195 | * property. | 195 | * property. |
| 196 | * | 196 | * |
| 197 | * In fips mode additinally check for all 3 keys are unique. | 197 | * In fips mode additionally check for all 3 keys are unique. |
| 198 | * | 198 | * |
| 199 | */ | 199 | */ |
| 200 | static int des3_setkey(struct crypto_tfm *tfm, const u8 *key, | 200 | static int des3_setkey(struct crypto_tfm *tfm, const u8 *key, |
| @@ -528,7 +528,7 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf, · 527 unmodified lines | |||
| 528 | /* give mutex free before calling schedule() */ | 528 | /* give mutex free before calling schedule() */ |
| 529 | mutex_unlock(&prng_data->mutex); | 529 | mutex_unlock(&prng_data->mutex); |
| 530 | schedule(); | 530 | schedule(); |
| 531 | /* occopy mutex again */ | 531 | /* occupy mutex again */ |
| 532 | if (mutex_lock_interruptible(&prng_data->mutex)) { | 532 | if (mutex_lock_interruptible(&prng_data->mutex)) { |
| 533 | if (ret == 0) | 533 | if (ret == 0) |
| 534 | ret = -ERESTARTSYS; | 534 | ret = -ERESTARTSYS; |
| @@ -190,7 +190,7 @@ int hypfs_vm_create_files(struct dentry *root) · 189 unmodified lines | |||
| 190 | if (IS_ERR(data)) | 190 | if (IS_ERR(data)) |
| 191 | return PTR_ERR(data); | 191 | return PTR_ERR(data); |
| 192 | 192 | ||
| 193 | /* Hpervisor Info */ | 193 | /* Hypervisor Info */ |
| 194 | dir = hypfs_mkdir(root, "hyp"); | 194 | dir = hypfs_mkdir(root, "hyp"); |
| 195 | if (IS_ERR(dir)) { | 195 | if (IS_ERR(dir)) { |
| 196 | rc = PTR_ERR(dir); | 196 | rc = PTR_ERR(dir); |
| @@ -4,19 +4,6 @@ · 3 unmodified lines | |||
| 4 | 4 | ||
| 5 | #ifdef __ASSEMBLY__ | 5 | #ifdef __ASSEMBLY__ |
| 6 | 6 | ||
| 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 | |||
| 20 | /* | 7 | /* |
| 21 | * Issue one struct alt_instr descriptor entry (need to put it into | 8 | * Issue one struct alt_instr descriptor entry (need to put it into |
| 22 | * the section .altinstructions, see below). This entry contains | 9 | * the section .altinstructions, see below). This entry contains |
| @@ -28,66 +15,29 @@ · 5 unmodified lines | |||
| 28 | .long \alt_start - . | 15 | .long \alt_start - . |
| 29 | .word \feature | 16 | .word \feature |
| 30 | .byte \orig_end - \orig_start | 17 | .byte \orig_end - \orig_start |
| 31 | .byte \alt_end - \alt_start | 18 | .org . - ( \orig_end - \orig_start ) + ( \alt_end - \alt_start ) |
| 32 | .endm | 19 | .org . - ( \alt_end - \alt_start ) + ( \orig_end - \orig_start ) |
| 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 | ||
| 65 | .endm | 20 | .endm |
| 66 | 21 | ||
| 67 | /* | 22 | /* |
| 68 | * Define an alternative between two instructions. If @feature is | 23 | * Define an alternative between two instructions. If @feature is |
| 69 | * present, early code in apply_alternatives() replaces @oldinstr with | 24 | * present, early code in apply_alternatives() replaces @oldinstr with |
| 70 | * @newinstr. ".skip" directive takes care of proper instruction padding | 25 | * @newinstr. |
| 71 | * in case @newinstr is longer than @oldinstr. | ||
| 72 | */ | 26 | */ |
| 73 | .macro ALTERNATIVE oldinstr, newinstr, feature | 27 | .macro ALTERNATIVE oldinstr, newinstr, feature |
| 74 | .pushsection .altinstr_replacement,"ax" | 28 | .pushsection .altinstr_replacement,"ax" |
| 75 | 770: \newinstr | 29 | 770: \newinstr |
| 76 | 771: .popsection | 30 | 771: .popsection |
| 77 | 772: \oldinstr | 31 | 772: \oldinstr |
| 78 | 773: alt_len_check 770b, 771b | 32 | 773: .pushsection .altinstructions,"a" |
| 79 | alt_len_check 772b, 773b | 33 | alt_entry 772b, 773b, 770b, 771b, \feature |
| 80 | alt_pad ( ( 771b - 770b ) - ( 773b - 772b ) ) | ||
| 81 | 774: .pushsection .altinstructions,"a" | ||
| 82 | alt_entry 772b, 774b, 770b, 771b, \feature | ||
| 83 | .popsection | 34 | .popsection |
| 84 | .endm | 35 | .endm |
| 85 | 36 | ||
| 86 | /* | 37 | /* |
| 87 | * Define an alternative between two instructions. If @feature is | 38 | * Define an alternative between two instructions. If @feature is |
| 88 | * present, early code in apply_alternatives() replaces @oldinstr with | 39 | * present, early code in apply_alternatives() replaces @oldinstr with |
| 89 | * @newinstr. ".skip" directive takes care of proper instruction padding | 40 | * @newinstr. |
| 90 | * in case @newinstr is longer than @oldinstr. | ||
| 91 | */ | 41 | */ |
| 92 | .macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2 | 42 | .macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2 |
| 93 | .pushsection .altinstr_replacement,"ax" | 43 | .pushsection .altinstr_replacement,"ax" |
| @@ -95,17 +45,9 @@ · 1 unmodified line | |||
| 95 | 771: \newinstr2 | 45 | 771: \newinstr2 |
| 96 | 772: .popsection | 46 | 772: .popsection |
| 97 | 773: \oldinstr | 47 | 773: \oldinstr |
| 98 | 774: alt_len_check 770b, 771b | 48 | 774: .pushsection .altinstructions,"a" |
| 99 | alt_len_check 771b, 772b | 49 | alt_entry 773b, 774b, 770b, 771b,\feature1 |
| 100 | alt_len_check 773b, 774b | 50 | alt_entry 773b, 774b, 771b, 772b,\feature2 |
| 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 | ||
| 109 | .popsection | 51 | .popsection |
| 110 | .endm | 52 | .endm |
| 111 | 53 | ||
| @@ -13,32 +13,25 @@ struct alt_instr { · 12 unmodified lines | |||
| 13 | s32 repl_offset; /* offset to replacement instruction */ | 13 | s32 repl_offset; /* offset to replacement instruction */ |
| 14 | u16 facility; /* facility bit set for replacement */ | 14 | u16 facility; /* facility bit set for replacement */ |
| 15 | u8 instrlen; /* length of original instruction */ | 15 | u8 instrlen; /* length of original instruction */ |
| 16 | u8 replacementlen; /* length of new instruction */ | ||
| 17 | } __packed; | 16 | } __packed; |
| 18 | 17 | ||
| 19 | void apply_alternative_instructions(void); | 18 | void apply_alternative_instructions(void); |
| 20 | void apply_alternatives(struct alt_instr *start, struct alt_instr *end); | 19 | void apply_alternatives(struct alt_instr *start, struct alt_instr *end); |
| 21 | 20 | ||
| 22 | /* | 21 | /* |
| 23 | * |661: |662: |6620 |663: | 22 | * +---------------------------------+ |
| 24 | * +-----------+---------------------+ | 23 | * |661: |662: |
| 25 | * | oldinstr | oldinstr_padding | | 24 | * | oldinstr | |
| 26 | * | +----------+----------+ | 25 | * +---------------------------------+ |
| 27 | * | | | | | ||
| 28 | * | | >6 bytes |6/4/2 nops| | ||
| 29 | * | |6 bytes jg-----------> | ||
| 30 | * +-----------+---------------------+ | ||
| 31 | * ^^ static padding ^^ | ||
| 32 | * | 26 | * |
| 33 | * .altinstr_replacement section | 27 | * .altinstr_replacement section |
| 34 | * +---------------------+-----------+ | 28 | * +---------------------------------+ |
| 35 | * |6641: |6651: | 29 | * |6641: |6651: |
| 36 | * | alternative instr 1 | | 30 | * | alternative instr 1 | |
| 37 | * +-----------+---------+- - - - - -+ | 31 | * +---------------------------------+ |
| 38 | * |6642: |6652: | | 32 | * |6642: |6652: |
| 39 | * | alternative instr 2 | padding | 33 | * | alternative instr 2 | |
| 40 | * +---------------------+- - - - - -+ | 34 | * +---------------------------------+ |
| 41 | * ^ runtime ^ | ||
| 42 | * | 35 | * |
| 43 | * .altinstructions section | 36 | * .altinstructions section |
| 44 | * +---------------------------------+ | 37 | * +---------------------------------+ |
| @@ -47,77 +40,31 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end); · 2 unmodified lines | |||
| 47 | * +---------------------------------+ | 40 | * +---------------------------------+ |
| 48 | */ | 41 | */ |
| 49 | 42 | ||
| 50 | #define b_altinstr(num) "664"#num | 43 | #define b_altinstr(num) "664"#num |
| 51 | #define e_altinstr(num) "665"#num | 44 | #define e_altinstr(num) "665"#num |
| 52 | |||
| 53 | #define e_oldinstr_pad_end "663" | ||
| 54 | #define oldinstr_len "662b-661b" | 45 | #define oldinstr_len "662b-661b" |
| 55 | #define oldinstr_total_len e_oldinstr_pad_end"b-661b" | ||
| 56 | #define altinstr_len(num) e_altinstr(num)"b-"b_altinstr(num)"b" | 46 | #define altinstr_len(num) e_altinstr(num)"b-"b_altinstr(num)"b" |
| 57 | #define oldinstr_pad_len(num) \ | 47 | |
| 58 | "-(((" altinstr_len(num) ")-(" oldinstr_len ")) > 0) * " \ | 48 | #define OLDINSTR(oldinstr) \ |
| 59 | "((" altinstr_len(num) ")-(" oldinstr_len "))" | 49 | "661:\n\t" oldinstr "\n662:\n" |
| 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) | ||
| 103 | 50 | ||
| 104 | #define ALTINSTR_ENTRY(facility, num) \ | 51 | #define ALTINSTR_ENTRY(facility, num) \ |
| 105 | "\t.long 661b - .\n" /* old instruction */ \ | 52 | "\t.long 661b - .\n" /* old instruction */ \ |
| 106 | "\t.long " b_altinstr(num)"b - .\n" /* alt instruction */ \ | 53 | "\t.long " b_altinstr(num)"b - .\n" /* alt instruction */ \ |
| 107 | "\t.word " __stringify(facility) "\n" /* facility bit */ \ | 54 | "\t.word " __stringify(facility) "\n" /* facility bit */ \ |
| 108 | "\t.byte " oldinstr_total_len "\n" /* source len */ \ | 55 | "\t.byte " oldinstr_len "\n" /* instruction len */ \ |
| 109 | "\t.byte " altinstr_len(num) "\n" /* alt instruction len */ | 56 | "\t.org . - (" oldinstr_len ") + (" altinstr_len(num) ")\n" \ |
| 57 | "\t.org . - (" altinstr_len(num) ") + (" oldinstr_len ")\n" | ||
| 110 | 58 | ||
| 111 | #define ALTINSTR_REPLACEMENT(altinstr, num) /* replacement */ \ | 59 | #define ALTINSTR_REPLACEMENT(altinstr, num) /* replacement */ \ |
| 112 | b_altinstr(num)":\n\t" altinstr "\n" e_altinstr(num) ":\n" \ | 60 | b_altinstr(num)":\n\t" altinstr "\n" e_altinstr(num) ":\n" |
| 113 | INSTR_LEN_SANITY_CHECK(altinstr_len(num)) | ||
| 114 | 61 | ||
| 115 | /* alternative assembly primitive: */ | 62 | /* alternative assembly primitive: */ |
| 116 | #define ALTERNATIVE(oldinstr, altinstr, facility) \ | 63 | #define ALTERNATIVE(oldinstr, altinstr, facility) \ |
| 117 | ".pushsection .altinstr_replacement, \"ax\"\n" \ | 64 | ".pushsection .altinstr_replacement, \"ax\"\n" \ |
| 118 | ALTINSTR_REPLACEMENT(altinstr, 1) \ | 65 | ALTINSTR_REPLACEMENT(altinstr, 1) \ |
| 119 | ".popsection\n" \ | 66 | ".popsection\n" \ |
| 120 | OLDINSTR(oldinstr, 1) \ | 67 | OLDINSTR(oldinstr) \ |
| 121 | ".pushsection .altinstructions,\"a\"\n" \ | 68 | ".pushsection .altinstructions,\"a\"\n" \ |
| 122 | ALTINSTR_ENTRY(facility, 1) \ | 69 | ALTINSTR_ENTRY(facility, 1) \ |
| 123 | ".popsection\n" | 70 | ".popsection\n" |
| @@ -127,7 +74,7 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end); · 3 unmodified lines | |||
| 127 | ALTINSTR_REPLACEMENT(altinstr1, 1) \ | 74 | ALTINSTR_REPLACEMENT(altinstr1, 1) \ |
| 128 | ALTINSTR_REPLACEMENT(altinstr2, 2) \ | 75 | ALTINSTR_REPLACEMENT(altinstr2, 2) \ |
| 129 | ".popsection\n" \ | 76 | ".popsection\n" \ |
| 130 | OLDINSTR_2(oldinstr, 1, 2) \ | 77 | OLDINSTR(oldinstr) \ |
| 131 | ".pushsection .altinstructions,\"a\"\n" \ | 78 | ".pushsection .altinstructions,\"a\"\n" \ |
| 132 | ALTINSTR_ENTRY(facility1, 1) \ | 79 | ALTINSTR_ENTRY(facility1, 1) \ |
| 133 | ALTINSTR_ENTRY(facility2, 2) \ | 80 | ALTINSTR_ENTRY(facility2, 2) \ |
| @@ -26,16 +26,16 @@ · 25 unmodified lines | |||
| 26 | stringify_in_c(.long (_target) - .;) \ | 26 | stringify_in_c(.long (_target) - .;) \ |
| 27 | stringify_in_c(.short (_type);) \ | 27 | stringify_in_c(.short (_type);) \ |
| 28 | stringify_in_c(.macro extable_reg reg;) \ | 28 | stringify_in_c(.macro extable_reg reg;) \ |
| 29 | stringify_in_c(.set found, 0;) \ | 29 | stringify_in_c(.set .Lfound, 0;) \ |
| 30 | stringify_in_c(.set regnr, 0;) \ | 30 | stringify_in_c(.set .Lregnr, 0;) \ |
| 31 | stringify_in_c(.irp rs,r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15;) \ | 31 | stringify_in_c(.irp rs,r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15;) \ |
| 32 | stringify_in_c(.ifc "\reg", "%%\rs";) \ | 32 | stringify_in_c(.ifc "\reg", "%%\rs";) \ |
| 33 | stringify_in_c(.set found, 1;) \ | 33 | stringify_in_c(.set .Lfound, 1;) \ |
| 34 | stringify_in_c(.short regnr;) \ | 34 | stringify_in_c(.short .Lregnr;) \ |
| 35 | stringify_in_c(.endif;) \ | 35 | stringify_in_c(.endif;) \ |
| 36 | stringify_in_c(.set regnr, regnr+1;) \ | 36 | stringify_in_c(.set .Lregnr, .Lregnr+1;) \ |
| 37 | stringify_in_c(.endr;) \ | 37 | stringify_in_c(.endr;) \ |
| 38 | stringify_in_c(.ifne (found != 1);) \ | 38 | stringify_in_c(.ifne (.Lfound != 1);) \ |
| 39 | stringify_in_c(.error "extable_reg: bad register argument";) \ | 39 | stringify_in_c(.error "extable_reg: bad register argument";) \ |
| 40 | stringify_in_c(.endif;) \ | 40 | stringify_in_c(.endif;) \ |
| 41 | stringify_in_c(.endm;) \ | 41 | stringify_in_c(.endm;) \ |
| @@ -26,14 +26,14 @@ static __always_inline void bcr_serialize(void) · 25 unmodified lines | |||
| 26 | asm volatile(__ASM_BCR_SERIALIZE : : : "memory"); | 26 | asm volatile(__ASM_BCR_SERIALIZE : : : "memory"); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | #define mb() bcr_serialize() | 29 | #define __mb() bcr_serialize() |
| 30 | #define rmb() barrier() | 30 | #define __rmb() barrier() |
| 31 | #define wmb() barrier() | 31 | #define __wmb() barrier() |
| 32 | #define dma_rmb() mb() | 32 | #define __dma_rmb() __mb() |
| 33 | #define dma_wmb() mb() | 33 | #define __dma_wmb() __mb() |
| 34 | #define __smp_mb() mb() | 34 | #define __smp_mb() __mb() |
| 35 | #define __smp_rmb() rmb() | 35 | #define __smp_rmb() __rmb() |
| 36 | #define __smp_wmb() wmb() | 36 | #define __smp_wmb() __wmb() |
| 37 | 37 | ||
| 38 | #define __smp_store_release(p, v) \ | 38 | #define __smp_store_release(p, v) \ |
| 39 | do { \ | 39 | do { \ |
| @@ -369,7 +369,7 @@ void cio_gp_dma_destroy(struct gen_pool *gp_dma, struct device *dma_dev); · 368 unmodified lines | |||
| 369 | struct gen_pool *cio_gp_dma_create(struct device *dma_dev, int nr_pages); | 369 | struct gen_pool *cio_gp_dma_create(struct device *dma_dev, int nr_pages); |
| 370 | 370 | ||
| 371 | /* Function from drivers/s390/cio/chsc.c */ | 371 | /* 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); |
| 373 | int chsc_sstpi(void *page, void *result, size_t size); | 373 | int chsc_sstpi(void *page, void *result, size_t size); |
| 374 | int chsc_stzi(void *page, void *result, size_t size); | 374 | int chsc_stzi(void *page, void *result, size_t size); |
| 375 | int chsc_sgib(u32 origin); | 375 | int chsc_sgib(u32 origin); |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | #include <linux/sched.h> | 8 | #include <linux/sched.h> |
| 9 | #include <linux/sched/task_stack.h> | 9 | #include <linux/sched/task_stack.h> |
| 10 | #include <linux/thread_info.h> | 10 | #include <linux/thread_info.h> |
| 11 | #include <asm/ptrace.h> | ||
| 11 | 12 | ||
| 12 | #define compat_mode_t compat_mode_t | 13 | #define compat_mode_t compat_mode_t |
| 13 | typedef u16 compat_mode_t; | 14 | typedef u16 compat_mode_t; |
| @@ -22,32 +23,8 @@ typedef u16 compat_mode_t; · 8 unmodified lines | |||
| 22 | (__force t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \ | 23 | (__force t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \ |
| 23 | }) | 24 | }) |
| 24 | 25 | ||
| 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 | |||
| 39 | #define PSW32_MASK_USER 0x0000FF00UL | 26 | #define PSW32_MASK_USER 0x0000FF00UL |
| 40 | 27 | ||
| 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 | |||
| 51 | #define PSW32_USER_BITS (PSW32_MASK_DAT | PSW32_MASK_IO | PSW32_MASK_EXT | \ | 28 | #define PSW32_USER_BITS (PSW32_MASK_DAT | PSW32_MASK_IO | PSW32_MASK_EXT | \ |
| 52 | PSW32_DEFAULT_KEY | PSW32_MASK_BASE | \ | 29 | PSW32_DEFAULT_KEY | PSW32_MASK_BASE | \ |
| 53 | PSW32_MASK_MCHECK | PSW32_MASK_PSTATE | \ | 30 | PSW32_MASK_MCHECK | PSW32_MASK_PSTATE | \ |
| @@ -93,7 +93,9 @@ union ctlreg0 { · 92 unmodified lines | |||
| 93 | unsigned long tcx : 1; /* Transactional-Execution control */ | 93 | unsigned long tcx : 1; /* Transactional-Execution control */ |
| 94 | unsigned long pifo : 1; /* Transactional-Execution Program- | 94 | unsigned long pifo : 1; /* Transactional-Execution Program- |
| 95 | Interruption-Filtering Override */ | 95 | Interruption-Filtering Override */ |
| 96 | unsigned long : 22; | 96 | unsigned long : 3; |
| 97 | unsigned long ccc : 1; /* Cryptography counter control */ | ||
| 98 | unsigned long : 18; | ||
| 97 | unsigned long : 3; | 99 | unsigned long : 3; |
| 98 | unsigned long lap : 1; /* Low-address-protection control */ | 100 | unsigned long lap : 1; /* Low-address-protection control */ |
| 99 | unsigned long : 4; | 101 | unsigned long : 4; |
| @@ -9,19 +9,21 @@ · 8 unmodified lines | |||
| 9 | #include <linux/uaccess.h> | 9 | #include <linux/uaccess.h> |
| 10 | #include <asm/timex.h> | 10 | #include <asm/timex.h> |
| 11 | #include <asm/fpu/api.h> | 11 | #include <asm/fpu/api.h> |
| 12 | #include <asm/pai.h> | ||
| 12 | 13 | ||
| 13 | #define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP) | 14 | #define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP) |
| 14 | 15 | ||
| 15 | void do_per_trap(struct pt_regs *regs); | 16 | void do_per_trap(struct pt_regs *regs); |
| 16 | 17 | ||
| 17 | #ifdef CONFIG_DEBUG_ENTRY | 18 | static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs) |
| 18 | static __always_inline void arch_check_user_regs(struct pt_regs *regs) | ||
| 19 | { | 19 | { |
| 20 | debug_user_asce(0); | 20 | if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) |
| 21 | debug_user_asce(0); | ||
| 22 | |||
| 23 | pai_kernel_enter(regs); | ||
| 21 | } | 24 | } |
| 22 | 25 | ||
| 23 | #define arch_check_user_regs arch_check_user_regs | 26 | #define arch_enter_from_user_mode arch_enter_from_user_mode |
| 24 | #endif /* CONFIG_DEBUG_ENTRY */ | ||
| 25 | 27 | ||
| 26 | static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs, | 28 | static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs, |
| 27 | unsigned long ti_work) | 29 | unsigned long ti_work) |
| @@ -44,6 +46,8 @@ static __always_inline void arch_exit_to_user_mode(void) · 16 unmodified lines | |||
| 44 | 46 | ||
| 45 | if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) | 47 | if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) |
| 46 | debug_user_asce(1); | 48 | debug_user_asce(1); |
| 49 | |||
| 50 | pai_kernel_exit(current_pt_regs()); | ||
| 47 | } | 51 | } |
| 48 | 52 | ||
| 49 | #define arch_exit_to_user_mode arch_exit_to_user_mode | 53 | #define arch_exit_to_user_mode arch_exit_to_user_mode |
| @@ -133,6 +133,8 @@ int ipl_report_add_certificate(struct ipl_report *report, void *key, · 132 unmodified lines | |||
| 133 | * DIAG 308 support | 133 | * DIAG 308 support |
| 134 | */ | 134 | */ |
| 135 | enum diag308_subcode { | 135 | enum diag308_subcode { |
| 136 | DIAG308_CLEAR_RESET = 0, | ||
| 137 | DIAG308_LOAD_NORMAL_RESET = 1, | ||
| 136 | DIAG308_REL_HSA = 2, | 138 | DIAG308_REL_HSA = 2, |
| 137 | DIAG308_LOAD_CLEAR = 3, | 139 | DIAG308_LOAD_CLEAR = 3, |
| 138 | DIAG308_LOAD_NORMAL_DUMP = 4, | 140 | DIAG308_LOAD_NORMAL_DUMP = 4, |
| @@ -141,6 +143,10 @@ enum diag308_subcode { · 2 unmodified lines | |||
| 141 | DIAG308_LOAD_NORMAL = 7, | 143 | DIAG308_LOAD_NORMAL = 7, |
| 142 | }; | 144 | }; |
| 143 | 145 | ||
| 146 | enum diag308_subcode_flags { | ||
| 147 | DIAG308_FLAG_EI = 1UL << 16, | ||
| 148 | }; | ||
| 149 | |||
| 144 | enum diag308_rc { | 150 | enum diag308_rc { |
| 145 | DIAG308_RC_OK = 0x0001, | 151 | DIAG308_RC_OK = 0x0001, |
| 146 | DIAG308_RC_NOCONFIG = 0x0102, | 152 | DIAG308_RC_NOCONFIG = 0x0102, |
| @@ -200,7 +200,10 @@ struct lowcore { · 199 unmodified lines | |||
| 200 | __u64 last_break_save_area; /* 0x1338 */ | 200 | __u64 last_break_save_area; /* 0x1338 */ |
| 201 | __u32 access_regs_save_area[16]; /* 0x1340 */ | 201 | __u32 access_regs_save_area[16]; /* 0x1340 */ |
| 202 | __u64 cregs_save_area[16]; /* 0x1380 */ | 202 | __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 */ | ||
| 204 | 207 | ||
| 205 | /* Transaction abort diagnostic block */ | 208 | /* Transaction abort diagnostic block */ |
| 206 | struct pgm_tdb pgm_tdb; /* 0x1800 */ | 209 | struct pgm_tdb pgm_tdb; /* 0x1800 */ |
| @@ -101,7 +101,7 @@ void nmi_alloc_mcesa_early(u64 *mcesad); · 100 unmodified lines | |||
| 101 | int nmi_alloc_mcesa(u64 *mcesad); | 101 | int nmi_alloc_mcesa(u64 *mcesad); |
| 102 | void nmi_free_mcesa(u64 *mcesad); | 102 | void nmi_free_mcesa(u64 *mcesad); |
| 103 | 103 | ||
| 104 | void s390_handle_mcck(void); | 104 | void s390_handle_mcck(struct pt_regs *regs); |
| 105 | void __s390_handle_mcck(void); | 105 | void __s390_handle_mcck(void); |
| 106 | int s390_do_machine_check(struct pt_regs *regs); | 106 | int s390_do_machine_check(struct pt_regs *regs); |
| 107 | 107 | ||
| @@ -54,31 +54,31 @@ · 53 unmodified lines | |||
| 54 | .endm | 54 | .endm |
| 55 | 55 | ||
| 56 | .macro __DECODE_R expand,reg | 56 | .macro __DECODE_R expand,reg |
| 57 | .set __decode_fail,1 | 57 | .set .L__decode_fail,1 |
| 58 | .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 | 58 | .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
| 59 | .ifc \reg,%r\r1 | 59 | .ifc \reg,%r\r1 |
| 60 | \expand \r1 | 60 | \expand \r1 |
| 61 | .set __decode_fail,0 | 61 | .set .L__decode_fail,0 |
| 62 | .endif | 62 | .endif |
| 63 | .endr | 63 | .endr |
| 64 | .if __decode_fail == 1 | 64 | .if .L__decode_fail == 1 |
| 65 | .error "__DECODE_R failed" | 65 | .error "__DECODE_R failed" |
| 66 | .endif | 66 | .endif |
| 67 | .endm | 67 | .endm |
| 68 | 68 | ||
| 69 | .macro __DECODE_RR expand,rsave,rtarget | 69 | .macro __DECODE_RR expand,rsave,rtarget |
| 70 | .set __decode_fail,1 | 70 | .set .L__decode_fail,1 |
| 71 | .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 | 71 | .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
| 72 | .ifc \rsave,%r\r1 | 72 | .ifc \rsave,%r\r1 |
| 73 | .irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 | 73 | .irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 |
| 74 | .ifc \rtarget,%r\r2 | 74 | .ifc \rtarget,%r\r2 |
| 75 | \expand \r1,\r2 | 75 | \expand \r1,\r2 |
| 76 | .set __decode_fail,0 | 76 | .set .L__decode_fail,0 |
| 77 | .endif | 77 | .endif |
| 78 | .endr | 78 | .endr |
| 79 | .endif | 79 | .endif |
| 80 | .endr | 80 | .endr |
| 81 | .if __decode_fail == 1 | 81 | .if .L__decode_fail == 1 |
| 82 | .error "__DECODE_RR failed" | 82 | .error "__DECODE_RR failed" |
| 83 | .endif | 83 | .endif |
| 84 | .endm | 84 | .endm |
| @@ -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 | ||
| @@ -17,9 +17,14 @@ extern debug_info_t *pci_debug_err_id; · 16 unmodified lines | |||
| 17 | debug_text_event(pci_debug_err_id, 0, debug_buffer); \ | 17 | debug_text_event(pci_debug_err_id, 0, debug_buffer); \ |
| 18 | } while (0) | 18 | } while (0) |
| 19 | 19 | ||
| 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 | |||
| 20 | static inline void zpci_err_hex(void *addr, int len) | 25 | static inline void zpci_err_hex(void *addr, int len) |
| 21 | { | 26 | { |
| 22 | debug_event(pci_debug_err_id, 0, addr, len); | 27 | zpci_err_hex_level(0, addr, len); |
| 23 | } | 28 | } |
| 24 | 29 | ||
| 25 | #endif | 30 | #endif |
| @@ -46,10 +46,17 @@ static inline bool test_preempt_need_resched(void) · 45 unmodified lines | |||
| 46 | 46 | ||
| 47 | static inline void __preempt_count_add(int val) | 47 | static inline void __preempt_count_add(int val) |
| 48 | { | 48 | { |
| 49 | if (__builtin_constant_p(val) && (val >= -128) && (val <= 127)) | 49 | /* |
| 50 | __atomic_add_const(val, &S390_lowcore.preempt_count); | 50 | * With some obscure config options and CONFIG_PROFILE_ALL_BRANCHES |
| 51 | else | 51 | * enabled, gcc 12 fails to handle __builtin_constant_p(). |
| 52 | __atomic_add(val, &S390_lowcore.preempt_count); | 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); | ||
| 53 | } | 60 | } |
| 54 | 61 | ||
| 55 | static inline void __preempt_count_sub(int val) | 62 | static inline void __preempt_count_sub(int val) |
| @@ -83,6 +83,7 @@ void cpu_detect_mhz_feature(void); · 82 unmodified lines | |||
| 83 | extern const struct seq_operations cpuinfo_op; | 83 | extern const struct seq_operations cpuinfo_op; |
| 84 | extern void execve_tail(void); | 84 | extern void execve_tail(void); |
| 85 | extern void __bpon(void); | 85 | extern void __bpon(void); |
| 86 | unsigned long vdso_size(void); | ||
| 86 | 87 | ||
| 87 | /* | 88 | /* |
| 88 | * User space process size: 2GB for 31 bit, 4TB or 8PT for 64 bit. | 89 | * 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 | |||
| 94 | (_REGION3_SIZE >> 1) : (_REGION2_SIZE >> 1)) | 95 | (_REGION3_SIZE >> 1) : (_REGION2_SIZE >> 1)) |
| 95 | #define TASK_SIZE_MAX (-PAGE_SIZE) | 96 | #define TASK_SIZE_MAX (-PAGE_SIZE) |
| 96 | 97 | ||
| 97 | #define STACK_TOP (test_thread_flag(TIF_31BIT) ? \ | 98 | #define VDSO_BASE (STACK_TOP + PAGE_SIZE) |
| 98 | _REGION3_SIZE : _REGION2_SIZE) | 99 | #define VDSO_LIMIT (test_thread_flag(TIF_31BIT) ? _REGION3_SIZE : _REGION2_SIZE) |
| 99 | #define STACK_TOP_MAX _REGION2_SIZE | 100 | #define STACK_TOP (VDSO_LIMIT - vdso_size() - PAGE_SIZE) |
| 101 | #define STACK_TOP_MAX (_REGION2_SIZE - vdso_size() - PAGE_SIZE) | ||
| 100 | 102 | ||
| 101 | #define HAVE_ARCH_PICK_MMAP_LAYOUT | 103 | #define HAVE_ARCH_PICK_MMAP_LAYOUT |
| 102 | 104 | ||
| @@ -71,6 +71,35 @@ enum { · 70 unmodified lines | |||
| 71 | &(*(struct psw_bits *)(&(__psw))); \ | 71 | &(*(struct psw_bits *)(&(__psw))); \ |
| 72 | })) | 72 | })) |
| 73 | 73 | ||
| 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 | |||
| 74 | #define PGM_INT_CODE_MASK 0x7f | 103 | #define PGM_INT_CODE_MASK 0x7f |
| 75 | #define PGM_INT_CODE_PER 0x80 | 104 | #define PGM_INT_CODE_PER 0x80 |
| 76 | 105 | ||
| @@ -87,6 +87,7 @@ struct sclp_info { · 86 unmodified lines | |||
| 87 | unsigned char has_diag318 : 1; | 87 | unsigned char has_diag318 : 1; |
| 88 | unsigned char has_sipl : 1; | 88 | unsigned char has_sipl : 1; |
| 89 | unsigned char has_dirq : 1; | 89 | unsigned char has_dirq : 1; |
| 90 | unsigned char has_iplcc : 1; | ||
| 90 | unsigned int ibc; | 91 | unsigned int ibc; |
| 91 | unsigned int mtid; | 92 | unsigned int mtid; |
| 92 | unsigned int mtid_cp; | 93 | unsigned int mtid_cp; |
| @@ -508,9 +508,21 @@ static inline int scsw_cmd_is_valid_zcc(union scsw *scsw) · 507 unmodified lines | |||
| 508 | */ | 508 | */ |
| 509 | static inline int scsw_cmd_is_valid_ectl(union scsw *scsw) | 509 | static inline int scsw_cmd_is_valid_ectl(union scsw *scsw) |
| 510 | { | 510 | { |
| 511 | return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) && | 511 | /* Must be status pending. */ |
| 512 | !(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) && | 512 | if (!(scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND)) |
| 513 | (scsw->cmd.stctl & SCSW_STCTL_ALERT_STATUS); | 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; | ||
| 514 | } | 526 | } |
| 515 | 527 | ||
| 516 | /** | 528 | /** |
| @@ -522,10 +534,25 @@ static inline int scsw_cmd_is_valid_ectl(union scsw *scsw) · 5 unmodified lines | |||
| 522 | */ | 534 | */ |
| 523 | static inline int scsw_cmd_is_valid_pno(union scsw *scsw) | 535 | static inline int scsw_cmd_is_valid_pno(union scsw *scsw) |
| 524 | { | 536 | { |
| 525 | return (scsw->cmd.fctl != 0) && | 537 | /* Must indicate at least one I/O function. */ |
| 526 | (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) && | 538 | if (!scsw->cmd.fctl) |
| 527 | (!(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) || | 539 | return 0; |
| 528 | (scsw->cmd.actl & SCSW_ACTL_SUSPENDED)); | 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; | ||
| 529 | } | 556 | } |
| 530 | 557 | ||
| 531 | /** | 558 | /** |
| @@ -675,9 +702,21 @@ static inline int scsw_tm_is_valid_q(union scsw *scsw) · 143 unmodified lines | |||
| 675 | */ | 702 | */ |
| 676 | static inline int scsw_tm_is_valid_ectl(union scsw *scsw) | 703 | static inline int scsw_tm_is_valid_ectl(union scsw *scsw) |
| 677 | { | 704 | { |
| 678 | return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) && | 705 | /* Must be status pending. */ |
| 679 | !(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) && | 706 | if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND)) |
| 680 | (scsw->tm.stctl & SCSW_STCTL_ALERT_STATUS); | 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; | ||
| 681 | } | 720 | } |
| 682 | 721 | ||
| 683 | /** | 722 | /** |
| @@ -689,11 +728,25 @@ static inline int scsw_tm_is_valid_ectl(union scsw *scsw) · 5 unmodified lines | |||
| 689 | */ | 728 | */ |
| 690 | static inline int scsw_tm_is_valid_pno(union scsw *scsw) | 729 | static inline int scsw_tm_is_valid_pno(union scsw *scsw) |
| 691 | { | 730 | { |
| 692 | return (scsw->tm.fctl != 0) && | 731 | /* Must indicate at least one I/O function. */ |
| 693 | (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) && | 732 | if (!scsw->tm.fctl) |
| 694 | (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) || | 733 | return 0; |
| 695 | ((scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) && | 734 | |
| 696 | (scsw->tm.actl & SCSW_ACTL_SUSPENDED))); | 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; | ||
| 697 | } | 750 | } |
| 698 | 751 | ||
| 699 | /** | 752 | /** |
| @@ -77,8 +77,9 @@ static inline int arch_spin_trylock(arch_spinlock_t *lp) · 76 unmodified lines | |||
| 77 | static inline void arch_spin_unlock(arch_spinlock_t *lp) | 77 | static inline void arch_spin_unlock(arch_spinlock_t *lp) |
| 78 | { | 78 | { |
| 79 | typecheck(int, lp->lock); | 79 | typecheck(int, lp->lock); |
| 80 | kcsan_release(); | ||
| 80 | asm_inline volatile( | 81 | asm_inline volatile( |
| 81 | ALTERNATIVE("", ".insn rre,0xb2fa0000,7,0", 49) /* NIAI 7 */ | 82 | ALTERNATIVE("nop", ".insn rre,0xb2fa0000,7,0", 49) /* NIAI 7 */ |
| 82 | " sth %1,%0\n" | 83 | " sth %1,%0\n" |
| 83 | : "=R" (((unsigned short *) &lp->lock)[1]) | 84 | : "=R" (((unsigned short *) &lp->lock)[1]) |
| 84 | : "d" (0) : "cc", "memory"); | 85 | : "d" (0) : "cc", "memory"); |
| @@ -44,8 +44,8 @@ struct stp_sstpi { · 43 unmodified lines | |||
| 44 | u32 : 32; | 44 | u32 : 32; |
| 45 | u32 ctnid[3]; | 45 | u32 ctnid[3]; |
| 46 | u32 : 32; | 46 | u32 : 32; |
| 47 | u32 todoff[4]; | 47 | u64 todoff; |
| 48 | u32 rsvd[48]; | 48 | u32 rsvd[50]; |
| 49 | } __packed; | 49 | } __packed; |
| 50 | 50 | ||
| 51 | struct stp_tzib { | 51 | struct stp_tzib { |
| @@ -366,7 +366,7 @@ · 365 unmodified lines | |||
| 366 | .macro VLM vfrom, vto, disp, base, hint=3 | 366 | .macro VLM vfrom, vto, disp, base, hint=3 |
| 367 | VX_NUM v1, \vfrom | 367 | VX_NUM v1, \vfrom |
| 368 | VX_NUM v3, \vto | 368 | VX_NUM v3, \vto |
| 369 | GR_NUM b2, \base /* Base register */ | 369 | GR_NUM b2, \base |
| 370 | .word 0xE700 | ((v1&15) << 4) | (v3&15) | 370 | .word 0xE700 | ((v1&15) << 4) | (v3&15) |
| 371 | .word (b2 << 12) | (\disp) | 371 | .word (b2 << 12) | (\disp) |
| 372 | MRXBOPC \hint, 0x36, v1, v3 | 372 | MRXBOPC \hint, 0x36, v1, v3 |
| @@ -376,7 +376,7 @@ · 3 unmodified lines | |||
| 376 | .macro VST vr1, disp, index="%r0", base | 376 | .macro VST vr1, disp, index="%r0", base |
| 377 | VX_NUM v1, \vr1 | 377 | VX_NUM v1, \vr1 |
| 378 | GR_NUM x2, \index | 378 | GR_NUM x2, \index |
| 379 | GR_NUM b2, \base /* Base register */ | 379 | GR_NUM b2, \base |
| 380 | .word 0xE700 | ((v1&15) << 4) | (x2&15) | 380 | .word 0xE700 | ((v1&15) << 4) | (x2&15) |
| 381 | .word (b2 << 12) | (\disp) | 381 | .word (b2 << 12) | (\disp) |
| 382 | MRXBOPC 0, 0x0E, v1 | 382 | MRXBOPC 0, 0x0E, v1 |
| @@ -386,7 +386,7 @@ · 3 unmodified lines | |||
| 386 | .macro VSTM vfrom, vto, disp, base, hint=3 | 386 | .macro VSTM vfrom, vto, disp, base, hint=3 |
| 387 | VX_NUM v1, \vfrom | 387 | VX_NUM v1, \vfrom |
| 388 | VX_NUM v3, \vto | 388 | VX_NUM v3, \vto |
| 389 | GR_NUM b2, \base /* Base register */ | 389 | GR_NUM b2, \base |
| 390 | .word 0xE700 | ((v1&15) << 4) | (v3&15) | 390 | .word 0xE700 | ((v1&15) << 4) | (v3&15) |
| 391 | .word (b2 << 12) | (\disp) | 391 | .word (b2 << 12) | (\disp) |
| 392 | MRXBOPC \hint, 0x3E, v1, v3 | 392 | MRXBOPC \hint, 0x3E, v1, v3 |
| @@ -171,7 +171,7 @@ struct pkey_skey2pkey { · 170 unmodified lines | |||
| 171 | #define PKEY_SKEY2PKEY _IOWR(PKEY_IOCTL_MAGIC, 0x06, struct pkey_skey2pkey) | 171 | #define PKEY_SKEY2PKEY _IOWR(PKEY_IOCTL_MAGIC, 0x06, struct pkey_skey2pkey) |
| 172 | 172 | ||
| 173 | /* | 173 | /* |
| 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 |
| 175 | * the pkey module. Check for correct key type and check for having at | 175 | * the pkey module. Check for correct key type and check for having at |
| 176 | * least one crypto card being able to handle this key (master key | 176 | * least one crypto card being able to handle this key (master key |
| 177 | * or old master key verification pattern matches). | 177 | * or old master key verification pattern matches). |
| @@ -4,7 +4,7 @@ · 3 unmodified lines | |||
| 4 | * | 4 | * |
| 5 | * zcrypt 2.2.1 (user-visible header) | 5 | * zcrypt 2.2.1 (user-visible header) |
| 6 | * | 6 | * |
| 7 | * Copyright IBM Corp. 2001, 2019 | 7 | * Copyright IBM Corp. 2001, 2022 |
| 8 | * Author(s): Robert Burroughs | 8 | * Author(s): Robert Burroughs |
| 9 | * Eric Rossman (edrossma@us.ibm.com) | 9 | * Eric Rossman (edrossma@us.ibm.com) |
| 10 | * | 10 | * |
| @@ -85,7 +85,7 @@ struct ica_rsa_modexpo_crt { · 74 unmodified lines | |||
| 85 | struct CPRBX { | 85 | struct CPRBX { |
| 86 | __u16 cprb_len; /* CPRB length 220 */ | 86 | __u16 cprb_len; /* CPRB length 220 */ |
| 87 | __u8 cprb_ver_id; /* CPRB version id. 0x02 */ | 87 | __u8 cprb_ver_id; /* CPRB version id. 0x02 */ |
| 88 | __u8 pad_000[3]; /* Alignment pad bytes */ | 88 | __u8 _pad_000[3]; /* Alignment pad bytes */ |
| 89 | __u8 func_id[2]; /* function id 0x5432 */ | 89 | __u8 func_id[2]; /* function id 0x5432 */ |
| 90 | __u8 cprb_flags[4]; /* Flags */ | 90 | __u8 cprb_flags[4]; /* Flags */ |
| 91 | __u32 req_parml; /* request parameter buffer len */ | 91 | __u32 req_parml; /* request parameter buffer len */ |
| @@ -95,19 +95,19 @@ struct CPRBX { · 3 unmodified lines | |||
| 95 | __u32 rpl_datal; /* reply data block len */ | 95 | __u32 rpl_datal; /* reply data block len */ |
| 96 | __u32 rpld_datal; /* replied data block len */ | 96 | __u32 rpld_datal; /* replied data block len */ |
| 97 | __u32 req_extbl; /* request extension block len */ | 97 | __u32 req_extbl; /* request extension block len */ |
| 98 | __u8 pad_001[4]; /* reserved */ | 98 | __u8 _pad_001[4]; /* reserved */ |
| 99 | __u32 rpld_extbl; /* replied extension block len */ | 99 | __u32 rpld_extbl; /* replied extension block len */ |
| 100 | __u8 padx000[16 - sizeof(__u8 *)]; | 100 | __u8 _pad_002[16 - sizeof(__u8 *)]; |
| 101 | __u8 __user *req_parmb; /* request parm block 'address' */ | 101 | __u8 __user *req_parmb; /* request parm block 'address' */ |
| 102 | __u8 padx001[16 - sizeof(__u8 *)]; | 102 | __u8 _pad_003[16 - sizeof(__u8 *)]; |
| 103 | __u8 __user *req_datab; /* request data block 'address' */ | 103 | __u8 __user *req_datab; /* request data block 'address' */ |
| 104 | __u8 padx002[16 - sizeof(__u8 *)]; | 104 | __u8 _pad_004[16 - sizeof(__u8 *)]; |
| 105 | __u8 __user *rpl_parmb; /* reply parm block 'address' */ | 105 | __u8 __user *rpl_parmb; /* reply parm block 'address' */ |
| 106 | __u8 padx003[16 - sizeof(__u8 *)]; | 106 | __u8 _pad_005[16 - sizeof(__u8 *)]; |
| 107 | __u8 __user *rpl_datab; /* reply data block 'address' */ | 107 | __u8 __user *rpl_datab; /* reply data block 'address' */ |
| 108 | __u8 padx004[16 - sizeof(__u8 *)]; | 108 | __u8 _pad_006[16 - sizeof(__u8 *)]; |
| 109 | __u8 __user *req_extb; /* request extension block 'addr'*/ | 109 | __u8 __user *req_extb; /* request extension block 'addr'*/ |
| 110 | __u8 padx005[16 - sizeof(__u8 *)]; | 110 | __u8 _pad_007[16 - sizeof(__u8 *)]; |
| 111 | __u8 __user *rpl_extb; /* reply extension block 'address'*/ | 111 | __u8 __user *rpl_extb; /* reply extension block 'address'*/ |
| 112 | __u16 ccp_rtcode; /* server return code */ | 112 | __u16 ccp_rtcode; /* server return code */ |
| 113 | __u16 ccp_rscode; /* server reason code */ | 113 | __u16 ccp_rscode; /* server reason code */ |
| @@ -115,12 +115,10 @@ struct CPRBX { · 1 unmodified line | |||
| 115 | __u8 logon_id[8]; /* Logon Identifier */ | 115 | __u8 logon_id[8]; /* Logon Identifier */ |
| 116 | __u8 mac_value[8]; /* Mac Value */ | 116 | __u8 mac_value[8]; /* Mac Value */ |
| 117 | __u8 mac_content_flgs; /* Mac content flag byte */ | 117 | __u8 mac_content_flgs; /* Mac content flag byte */ |
| 118 | __u8 pad_002; /* Alignment */ | 118 | __u8 _pad_008; /* Alignment */ |
| 119 | __u16 domain; /* Domain */ | 119 | __u16 domain; /* Domain */ |
| 120 | __u8 usage_domain[4]; /* Usage domain */ | 120 | __u8 _pad_009[12]; /* reserved, checked for zeros */ |
| 121 | __u8 cntrl_domain[4]; /* Control domain */ | 121 | __u8 _pad_010[36]; /* reserved */ |
| 122 | __u8 S390enf_mask[4]; /* S/390 enforcement mask */ | ||
| 123 | __u8 pad_004[36]; /* reserved */ | ||
| 124 | } __attribute__((packed)); | 122 | } __attribute__((packed)); |
| 125 | 123 | ||
| 126 | /** | 124 | /** |
| @@ -238,8 +236,8 @@ struct zcrypt_device_matrix_ext { · 111 unmodified lines | |||
| 238 | }; | 236 | }; |
| 239 | 237 | ||
| 240 | #define AUTOSELECT 0xFFFFFFFF | 238 | #define AUTOSELECT 0xFFFFFFFF |
| 241 | #define AUTOSEL_AP ((__u16) 0xFFFF) | 239 | #define AUTOSEL_AP ((__u16)0xFFFF) |
| 242 | #define AUTOSEL_DOM ((__u16) 0xFFFF) | 240 | #define AUTOSEL_DOM ((__u16)0xFFFF) |
| 243 | 241 | ||
| 244 | #define ZCRYPT_IOCTL_MAGIC 'z' | 242 | #define ZCRYPT_IOCTL_MAGIC 'z' |
| 245 | 243 | ||
| @@ -305,12 +303,12 @@ struct zcrypt_device_matrix_ext { · 59 unmodified lines | |||
| 305 | /** | 303 | /** |
| 306 | * Supported ioctl calls | 304 | * Supported ioctl calls |
| 307 | */ | 305 | */ |
| 308 | #define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x05, 0) | 306 | #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) | 307 | #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) | 308 | #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) | 309 | #define ZSENDEP11CPRB _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0) |
| 312 | 310 | ||
| 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) |
| 314 | #define ZCRYPT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x58, char[MAX_ZDEV_CARDIDS_EXT]) | 312 | #define ZCRYPT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x58, char[MAX_ZDEV_CARDIDS_EXT]) |
| 315 | #define ZCRYPT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x59, char[MAX_ZDEV_CARDIDS_EXT]) | 313 | #define ZCRYPT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x59, char[MAX_ZDEV_CARDIDS_EXT]) |
| 316 | #define ZCRYPT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x5a, int[MAX_ZDEV_CARDIDS_EXT]) | 314 | #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 | |||
| 352 | }; | 350 | }; |
| 353 | 351 | ||
| 354 | /* Deprecated: use ZCRYPT_DEVICE_STATUS */ | 352 | /* 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) |
| 356 | /* Deprecated: use ZCRYPT_STATUS_MASK */ | 354 | /* Deprecated: use ZCRYPT_STATUS_MASK */ |
| 357 | #define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64]) | 355 | #define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64]) |
| 358 | /* Deprecated: use ZCRYPT_QDEPTH_MASK */ | 356 | /* Deprecated: use ZCRYPT_QDEPTH_MASK */ |
| @@ -72,6 +72,7 @@ obj-$(CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT) += ima_arch.o · 71 unmodified lines | |||
| 72 | obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf_common.o | 72 | obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf_common.o |
| 73 | obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf.o perf_cpum_sf.o | 73 | obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf.o perf_cpum_sf.o |
| 74 | obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf_events.o perf_regs.o | 74 | obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf_events.o perf_regs.o |
| 75 | obj-$(CONFIG_PERF_EVENTS) += perf_pai_crypto.o | ||
| 75 | 76 | ||
| 76 | obj-$(CONFIG_TRACEPOINTS) += trace.o | 77 | obj-$(CONFIG_TRACEPOINTS) += trace.o |
| 77 | obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o | 78 | obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o |
| @@ -7,8 +7,6 @@ · 6 unmodified lines | |||
| 7 | #include <asm/facility.h> | 7 | #include <asm/facility.h> |
| 8 | #include <asm/nospec-branch.h> | 8 | #include <asm/nospec-branch.h> |
| 9 | 9 | ||
| 10 | #define MAX_PATCH_LEN (255 - 1) | ||
| 11 | |||
| 12 | static int __initdata_or_module alt_instr_disabled; | 10 | static int __initdata_or_module alt_instr_disabled; |
| 13 | 11 | ||
| 14 | static int __init disable_alternative_instructions(char *str) | 12 | static int __init disable_alternative_instructions(char *str) |
| @@ -19,85 +17,30 @@ static int __init disable_alternative_instructions(char *str) · 4 unmodified lines | |||
| 19 | 17 | ||
| 20 | early_param("noaltinstr", disable_alternative_instructions); | 18 | early_param("noaltinstr", disable_alternative_instructions); |
| 21 | 19 | ||
| 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 | |||
| 65 | static void __init_or_module __apply_alternatives(struct alt_instr *start, | 20 | static void __init_or_module __apply_alternatives(struct alt_instr *start, |
| 66 | struct alt_instr *end) | 21 | struct alt_instr *end) |
| 67 | { | 22 | { |
| 68 | struct alt_instr *a; | 23 | struct alt_instr *a; |
| 69 | u8 *instr, *replacement; | 24 | u8 *instr, *replacement; |
| 70 | u8 insnbuf[MAX_PATCH_LEN]; | ||
| 71 | 25 | ||
| 72 | /* | 26 | /* |
| 73 | * The scan order should be from start to end. A later scanned | 27 | * The scan order should be from start to end. A later scanned |
| 74 | * alternative code can overwrite previously scanned alternative code. | 28 | * alternative code can overwrite previously scanned alternative code. |
| 75 | */ | 29 | */ |
| 76 | for (a = start; a < end; a++) { | 30 | for (a = start; a < end; a++) { |
| 77 | int insnbuf_sz = 0; | ||
| 78 | |||
| 79 | instr = (u8 *)&a->instr_offset + a->instr_offset; | 31 | instr = (u8 *)&a->instr_offset + a->instr_offset; |
| 80 | replacement = (u8 *)&a->repl_offset + a->repl_offset; | 32 | replacement = (u8 *)&a->repl_offset + a->repl_offset; |
| 81 | 33 | ||
| 82 | if (!__test_facility(a->facility, alt_stfle_fac_list)) | 34 | if (!__test_facility(a->facility, alt_stfle_fac_list)) |
| 83 | continue; | 35 | continue; |
| 84 | 36 | ||
| 85 | if (unlikely(a->instrlen % 2 || a->replacementlen % 2)) { | 37 | if (unlikely(a->instrlen % 2)) { |
| 86 | WARN_ONCE(1, "cpu alternatives instructions length is " | 38 | WARN_ONCE(1, "cpu alternatives instructions length is " |
| 87 | "odd, skipping patching\n"); | 39 | "odd, skipping patching\n"); |
| 88 | continue; | 40 | continue; |
| 89 | } | 41 | } |
| 90 | 42 | ||
| 91 | memcpy(insnbuf, replacement, a->replacementlen); | 43 | s390_kernel_write(instr, replacement, a->instrlen); |
| 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); | ||
| 101 | } | 44 | } |
| 102 | } | 45 | } |
| 103 | 46 | ||
| @@ -5,69 +5,59 @@ · 4 unmodified lines | |||
| 5 | #include <linux/compat.h> | 5 | #include <linux/compat.h> |
| 6 | #include <linux/socket.h> | 6 | #include <linux/socket.h> |
| 7 | #include <linux/syscalls.h> | 7 | #include <linux/syscalls.h> |
| 8 | #include <asm/ptrace.h> | ||
| 8 | 9 | ||
| 9 | /* Macro that masks the high order bit of an 32 bit pointer and converts it*/ | 10 | /* |
| 10 | /* to a 64 bit pointer */ | 11 | * Macro that masks the high order bit of a 32 bit pointer and |
| 11 | #define A(__x) ((unsigned long)((__x) & 0x7FFFFFFFUL)) | 12 | * converts it to a 64 bit pointer. |
| 12 | #define AA(__x) \ | 13 | */ |
| 13 | ((unsigned long)(__x)) | 14 | #define A(__x) ((unsigned long)((__x) & 0x7FFFFFFFUL)) |
| 15 | #define AA(__x) ((unsigned long)(__x)) | ||
| 14 | 16 | ||
| 15 | /* Now 32bit compatibility types */ | 17 | /* Now 32bit compatibility types */ |
| 16 | struct ipc_kludge_32 { | 18 | struct ipc_kludge_32 { |
| 17 | __u32 msgp; /* pointer */ | 19 | __u32 msgp; /* pointer */ |
| 18 | __s32 msgtyp; | 20 | __s32 msgtyp; |
| 19 | }; | 21 | }; |
| 20 | 22 | ||
| 21 | /* asm/sigcontext.h */ | 23 | /* asm/sigcontext.h */ |
| 22 | typedef union | 24 | typedef union { |
| 23 | { | 25 | __u64 d; |
| 24 | __u64 d; | 26 | __u32 f; |
| 25 | __u32 f; | ||
| 26 | } freg_t32; | 27 | } freg_t32; |
| 27 | 28 | ||
| 28 | typedef struct | 29 | typedef struct { |
| 29 | { | ||
| 30 | unsigned int fpc; | 30 | unsigned int fpc; |
| 31 | unsigned int pad; | 31 | unsigned int pad; |
| 32 | freg_t32 fprs[__NUM_FPRS]; | 32 | freg_t32 fprs[__NUM_FPRS]; |
| 33 | } _s390_fp_regs32; | 33 | } _s390_fp_regs32; |
| 34 | 34 | ||
| 35 | typedef struct | 35 | typedef struct { |
| 36 | { | 36 | psw_t32 psw; |
| 37 | __u32 mask; | ||
| 38 | __u32 addr; | ||
| 39 | } _psw_t32 __attribute__ ((aligned(8))); | ||
| 40 | |||
| 41 | typedef struct | ||
| 42 | { | ||
| 43 | _psw_t32 psw; | ||
| 44 | __u32 gprs[__NUM_GPRS]; | 37 | __u32 gprs[__NUM_GPRS]; |
| 45 | __u32 acrs[__NUM_ACRS]; | 38 | __u32 acrs[__NUM_ACRS]; |
| 46 | } _s390_regs_common32; | 39 | } _s390_regs_common32; |
| 47 | 40 | ||
| 48 | typedef struct | 41 | typedef struct { |
| 49 | { | ||
| 50 | _s390_regs_common32 regs; | 42 | _s390_regs_common32 regs; |
| 51 | _s390_fp_regs32 fpregs; | 43 | _s390_fp_regs32 fpregs; |
| 52 | } _sigregs32; | 44 | } _sigregs32; |
| 53 | 45 | ||
| 54 | typedef struct | 46 | typedef struct { |
| 55 | { | 47 | __u32 gprs_high[__NUM_GPRS]; |
| 56 | __u32 gprs_high[__NUM_GPRS]; | 48 | __u64 vxrs_low[__NUM_VXRS_LOW]; |
| 57 | __u64 vxrs_low[__NUM_VXRS_LOW]; | 49 | __vector128 vxrs_high[__NUM_VXRS_HIGH]; |
| 58 | __vector128 vxrs_high[__NUM_VXRS_HIGH]; | 50 | __u8 __reserved[128]; |
| 59 | __u8 __reserved[128]; | ||
| 60 | } _sigregs_ext32; | 51 | } _sigregs_ext32; |
| 61 | 52 | ||
| 62 | #define _SIGCONTEXT_NSIG32 64 | 53 | #define _SIGCONTEXT_NSIG32 64 |
| 63 | #define _SIGCONTEXT_NSIG_BPW32 32 | 54 | #define _SIGCONTEXT_NSIG_BPW32 32 |
| 64 | #define __SIGNAL_FRAMESIZE32 96 | 55 | #define __SIGNAL_FRAMESIZE32 96 |
| 65 | #define _SIGMASK_COPY_SIZE32 (sizeof(u32)*2) | 56 | #define _SIGMASK_COPY_SIZE32 (sizeof(u32) * 2) |
| 66 | 57 | ||
| 67 | struct sigcontext32 | 58 | struct sigcontext32 { |
| 68 | { | ||
| 69 | __u32 oldmask[_COMPAT_NSIG_WORDS]; | 59 | __u32 oldmask[_COMPAT_NSIG_WORDS]; |
| 70 | __u32 sregs; /* pointer */ | 60 | __u32 sregs; /* pointer */ |
| 71 | }; | 61 | }; |
| 72 | 62 | ||
| 73 | /* asm/signal.h */ | 63 | /* asm/signal.h */ |
| @@ -75,11 +65,11 @@ struct sigcontext32 · 1 unmodified line | |||
| 75 | /* asm/ucontext.h */ | 65 | /* asm/ucontext.h */ |
| 76 | struct ucontext32 { | 66 | struct ucontext32 { |
| 77 | __u32 uc_flags; | 67 | __u32 uc_flags; |
| 78 | __u32 uc_link; /* pointer */ | 68 | __u32 uc_link; /* pointer */ |
| 79 | compat_stack_t uc_stack; | 69 | compat_stack_t uc_stack; |
| 80 | _sigregs32 uc_mcontext; | 70 | _sigregs32 uc_mcontext; |
| 81 | compat_sigset_t uc_sigmask; | 71 | 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. */ |
| 83 | unsigned char __unused[128 - sizeof(compat_sigset_t)]; | 73 | unsigned char __unused[128 - sizeof(compat_sigset_t)]; |
| 84 | _sigregs_ext32 uc_mcontext_ext; | 74 | _sigregs_ext32 uc_mcontext_ext; |
| 85 | }; | 75 | }; |
| @@ -88,25 +78,6 @@ struct stat64_emu31; · 2 unmodified lines | |||
| 88 | struct mmap_arg_struct_emu31; | 78 | struct mmap_arg_struct_emu31; |
| 89 | struct fadvise64_64_args; | 79 | struct fadvise64_64_args; |
| 90 | 80 | ||
| 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); | ||
| 110 | long compat_sys_s390_truncate64(const char __user *path, u32 high, u32 low); | 81 | long compat_sys_s390_truncate64(const char __user *path, u32 high, u32 low); |
| 111 | long compat_sys_s390_ftruncate64(unsigned int fd, u32 high, u32 low); | 82 | long compat_sys_s390_ftruncate64(unsigned int fd, u32 high, u32 low); |
| 112 | long compat_sys_s390_pread64(unsigned int fd, char __user *ubuf, compat_size_t count, u32 high, u32 low); | 83 | 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 | |||
| 118 | long compat_sys_s390_fstatat64(unsigned int dfd, const char __user *filename, struct stat64_emu31 __user *statbuf, int flag); | 89 | long compat_sys_s390_fstatat64(unsigned int dfd, const char __user *filename, struct stat64_emu31 __user *statbuf, int flag); |
| 119 | long compat_sys_s390_old_mmap(struct mmap_arg_struct_emu31 __user *arg); | 90 | long compat_sys_s390_old_mmap(struct mmap_arg_struct_emu31 __user *arg); |
| 120 | long compat_sys_s390_mmap2(struct mmap_arg_struct_emu31 __user *arg); | 91 | 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); | 92 | 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); | 93 | long compat_sys_s390_write(unsigned int fd, const char __user *buf, compat_size_t count); |
| 123 | long compat_sys_s390_fadvise64(int fd, u32 high, u32 low, compat_size_t len, int advise); | 94 | long compat_sys_s390_fadvise64(int fd, u32 high, u32 low, compat_size_t len, int advise); |
| 124 | long compat_sys_s390_fadvise64_64(struct fadvise64_64_args __user *args); | 95 | long compat_sys_s390_fadvise64_64(struct fadvise64_64_args __user *args); |
| 125 | long compat_sys_s390_sync_file_range(int fd, u32 offhigh, u32 offlow, u32 nhigh, u32 nlow, unsigned int flags); | 96 | long compat_sys_s390_sync_file_range(int fd, u32 offhigh, u32 offlow, u32 nhigh, u32 nlow, unsigned int flags); |
| @@ -53,19 +53,19 @@ STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE · 52 unmodified lines | |||
| 53 | _LPP_OFFSET = __LC_LPP | 53 | _LPP_OFFSET = __LC_LPP |
| 54 | 54 | ||
| 55 | .macro STBEAR address | 55 | .macro STBEAR address |
| 56 | ALTERNATIVE "", ".insn s,0xb2010000,\address", 193 | 56 | ALTERNATIVE "nop", ".insn s,0xb2010000,\address", 193 |
| 57 | .endm | 57 | .endm |
| 58 | 58 | ||
| 59 | .macro LBEAR address | 59 | .macro LBEAR address |
| 60 | ALTERNATIVE "", ".insn s,0xb2000000,\address", 193 | 60 | ALTERNATIVE "nop", ".insn s,0xb2000000,\address", 193 |
| 61 | .endm | 61 | .endm |
| 62 | 62 | ||
| 63 | .macro LPSWEY address,lpswe | 63 | .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 |
| 65 | .endm | 65 | .endm |
| 66 | 66 | ||
| 67 | .macro MBEAR reg | 67 | .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 |
| 69 | .endm | 69 | .endm |
| 70 | 70 | ||
| 71 | .macro CHECK_STACK savearea | 71 | .macro CHECK_STACK savearea |
| @@ -121,16 +121,16 @@ _LPP_OFFSET = __LC_LPP · 49 unmodified lines | |||
| 121 | .endm | 121 | .endm |
| 122 | 122 | ||
| 123 | .macro BPOFF | 123 | .macro BPOFF |
| 124 | ALTERNATIVE "", ".insn rrf,0xb2e80000,0,0,12,0", 82 | 124 | ALTERNATIVE "nop", ".insn rrf,0xb2e80000,0,0,12,0", 82 |
| 125 | .endm | 125 | .endm |
| 126 | 126 | ||
| 127 | .macro BPON | 127 | .macro BPON |
| 128 | ALTERNATIVE "", ".insn rrf,0xb2e80000,0,0,13,0", 82 | 128 | ALTERNATIVE "nop", ".insn rrf,0xb2e80000,0,0,13,0", 82 |
| 129 | .endm | 129 | .endm |
| 130 | 130 | ||
| 131 | .macro BPENTER tif_ptr,tif_mask | 131 | .macro BPENTER tif_ptr,tif_mask |
| 132 | ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .insn rrf,0xb2e80000,0,0,13,0", \ | 132 | ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .insn rrf,0xb2e80000,0,0,13,0", \ |
| 133 | "", 82 | 133 | "j .+12; nop; nop", 82 |
| 134 | .endm | 134 | .endm |
| 135 | 135 | ||
| 136 | .macro BPEXIT tif_ptr,tif_mask | 136 | .macro BPEXIT tif_ptr,tif_mask |
| @@ -172,9 +172,19 @@ _LPP_OFFSET = __LC_LPP · 35 unmodified lines | |||
| 172 | lgr %r14,\reg | 172 | lgr %r14,\reg |
| 173 | larl %r13,\start | 173 | larl %r13,\start |
| 174 | slgr %r14,%r13 | 174 | slgr %r14,%r13 |
| 175 | lghi %r13,\end - \start | 175 | #ifdef CONFIG_AS_IS_LLVM |
| 176 | clgr %r14,%r13 | 176 | clgfrl %r14,.Lrange_size\@ |
| 177 | #else | ||
| 178 | clgfi %r14,\end - \start | ||
| 179 | #endif | ||
| 177 | jhe \outside_label | 180 | 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 | ||
| 178 | .endm | 188 | .endm |
| 179 | 189 | ||
| 180 | .macro SIEEXIT | 190 | .macro SIEEXIT |
| @@ -226,7 +236,7 @@ ENTRY(__switch_to) · 45 unmodified lines | |||
| 226 | aghi %r3,__TASK_pid | 236 | aghi %r3,__TASK_pid |
| 227 | mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next | 237 | mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next |
| 228 | lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task | 238 | lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task |
| 229 | ALTERNATIVE "", "lpp _LPP_OFFSET", 40 | 239 | ALTERNATIVE "nop", "lpp _LPP_OFFSET", 40 |
| 230 | BR_EX %r14 | 240 | BR_EX %r14 |
| 231 | ENDPROC(__switch_to) | 241 | ENDPROC(__switch_to) |
| 232 | 242 | ||
| @@ -473,10 +483,7 @@ ENTRY(\name) · 240 unmodified lines | |||
| 473 | mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC | 483 | mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC |
| 474 | MBEAR %r11 | 484 | MBEAR %r11 |
| 475 | stmg %r8,%r9,__PT_PSW(%r11) | 485 | stmg %r8,%r9,__PT_PSW(%r11) |
| 476 | tm %r8,0x0001 # coming from user space? | 486 | lgr %r2,%r11 # pass pointer to pt_regs |
| 477 | jno 1f | ||
| 478 | lctlg %c1,%c1,__LC_KERNEL_ASCE | ||
| 479 | 1: lgr %r2,%r11 # pass pointer to pt_regs | ||
| 480 | brasl %r14,\handler | 487 | brasl %r14,\handler |
| 481 | mvc __LC_RETURN_PSW(16),__PT_PSW(%r11) | 488 | mvc __LC_RETURN_PSW(16),__PT_PSW(%r11) |
| 482 | tmhh %r8,0x0001 # returning to user ? | 489 | tmhh %r8,0x0001 # returning to user ? |
| @@ -602,6 +609,7 @@ ENTRY(mcck_int_handler) · 119 unmodified lines | |||
| 602 | mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11) | 609 | mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11) |
| 603 | xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) | 610 | xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) |
| 604 | la %r11,STACK_FRAME_OVERHEAD(%r1) | 611 | la %r11,STACK_FRAME_OVERHEAD(%r1) |
| 612 | lgr %r2,%r11 | ||
| 605 | lgr %r15,%r1 | 613 | lgr %r15,%r1 |
| 606 | brasl %r14,s390_handle_mcck | 614 | brasl %r14,s390_handle_mcck |
| 607 | .Lmcck_return: | 615 | .Lmcck_return: |
| @@ -612,7 +620,7 @@ ENTRY(mcck_int_handler) · 4 unmodified lines | |||
| 612 | jno 0f | 620 | jno 0f |
| 613 | BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP | 621 | BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP |
| 614 | stpt __LC_EXIT_TIMER | 622 | 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 |
| 616 | LBEAR 0(%r12) | 624 | LBEAR 0(%r12) |
| 617 | lmg %r11,%r15,__PT_R11(%r11) | 625 | lmg %r11,%r15,__PT_R11(%r11) |
| 618 | LPSWEY __LC_RETURN_MCCK_PSW,__LC_RETURN_MCCK_LPSWE | 626 | LPSWEY __LC_RETURN_MCCK_PSW,__LC_RETURN_MCCK_LPSWE |
| @@ -648,7 +656,7 @@ ENTRY(mcck_int_handler) · 29 unmodified lines | |||
| 648 | ENDPROC(mcck_int_handler) | 656 | ENDPROC(mcck_int_handler) |
| 649 | 657 | ||
| 650 | ENTRY(restart_int_handler) | 658 | ENTRY(restart_int_handler) |
| 651 | ALTERNATIVE "", "lpp _LPP_OFFSET", 40 | 659 | ALTERNATIVE "nop", "lpp _LPP_OFFSET", 40 |
| 652 | stg %r15,__LC_SAVE_AREA_RESTART | 660 | stg %r15,__LC_SAVE_AREA_RESTART |
| 653 | TSTMSK __LC_RESTART_FLAGS,RESTART_FLAG_CTLREGS,4 | 661 | TSTMSK __LC_RESTART_FLAGS,RESTART_FLAG_CTLREGS,4 |
| 654 | jz 0f | 662 | jz 0f |
| @@ -205,7 +205,7 @@ static void show_msi_interrupt(struct seq_file *p, int irq) · 204 unmodified lines | |||
| 205 | unsigned long flags; | 205 | unsigned long flags; |
| 206 | int cpu; | 206 | int cpu; |
| 207 | 207 | ||
| 208 | irq_lock_sparse(); | 208 | rcu_read_lock(); |
| 209 | desc = irq_to_desc(irq); | 209 | desc = irq_to_desc(irq); |
| 210 | if (!desc) | 210 | if (!desc) |
| 211 | goto out; | 211 | goto out; |
| @@ -224,7 +224,7 @@ static void show_msi_interrupt(struct seq_file *p, int irq) · 12 unmodified lines | |||
| 224 | seq_putc(p, '\n'); | 224 | seq_putc(p, '\n'); |
| 225 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 225 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
| 226 | out: | 226 | out: |
| 227 | irq_unlock_sparse(); | 227 | rcu_read_unlock(); |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | /* | 230 | /* |
| @@ -26,8 +26,10 @@ · 25 unmodified lines | |||
| 26 | #include <asm/stacktrace.h> | 26 | #include <asm/stacktrace.h> |
| 27 | #include <asm/switch_to.h> | 27 | #include <asm/switch_to.h> |
| 28 | #include <asm/nmi.h> | 28 | #include <asm/nmi.h> |
| 29 | #include <asm/sclp.h> | ||
| 29 | 30 | ||
| 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); | ||
| 31 | 33 | ||
| 32 | extern const unsigned char relocate_kernel[]; | 34 | extern const unsigned char relocate_kernel[]; |
| 33 | extern const unsigned long long relocate_kernel_len; | 35 | extern const unsigned long long relocate_kernel_len; |
| @@ -243,6 +245,7 @@ void machine_crash_shutdown(struct pt_regs *regs) · 209 unmodified lines | |||
| 243 | */ | 245 | */ |
| 244 | static void __do_machine_kexec(void *data) | 246 | static void __do_machine_kexec(void *data) |
| 245 | { | 247 | { |
| 248 | unsigned long diag308_subcode; | ||
| 246 | relocate_kernel_t data_mover; | 249 | relocate_kernel_t data_mover; |
| 247 | struct kimage *image = data; | 250 | struct kimage *image = data; |
| 248 | 251 | ||
| @@ -251,7 +254,10 @@ static void __do_machine_kexec(void *data) · 2 unmodified lines | |||
| 251 | 254 | ||
| 252 | __arch_local_irq_stnsm(0xfb); /* disable DAT - avoid no-execute */ | 255 | __arch_local_irq_stnsm(0xfb); /* disable DAT - avoid no-execute */ |
| 253 | /* Call the moving routine */ | 256 | /* 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); | ||
| 255 | 261 | ||
| 256 | /* Die if kexec returns */ | 262 | /* Die if kexec returns */ |
| 257 | disabled_wait(); | 263 | disabled_wait(); |
| @@ -29,6 +29,8 @@ · 28 unmodified lines | |||
| 29 | #include <asm/switch_to.h> | 29 | #include <asm/switch_to.h> |
| 30 | #include <asm/ctl_reg.h> | 30 | #include <asm/ctl_reg.h> |
| 31 | #include <asm/asm-offsets.h> | 31 | #include <asm/asm-offsets.h> |
| 32 | #include <asm/pai.h> | ||
| 33 | |||
| 32 | #include <linux/kvm_host.h> | 34 | #include <linux/kvm_host.h> |
| 33 | 35 | ||
| 34 | struct mcck_struct { | 36 | struct mcck_struct { |
| @@ -169,10 +171,12 @@ void __s390_handle_mcck(void) · 134 unmodified lines | |||
| 169 | } | 171 | } |
| 170 | } | 172 | } |
| 171 | 173 | ||
| 172 | void noinstr s390_handle_mcck(void) | 174 | void noinstr s390_handle_mcck(struct pt_regs *regs) |
| 173 | { | 175 | { |
| 174 | trace_hardirqs_off(); | 176 | trace_hardirqs_off(); |
| 177 | pai_kernel_enter(regs); | ||
| 175 | __s390_handle_mcck(); | 178 | __s390_handle_mcck(); |
| 179 | pai_kernel_exit(regs); | ||
| 176 | trace_hardirqs_on(); | 180 | trace_hardirqs_on(); |
| 177 | } | 181 | } |
| 178 | /* | 182 | /* |
| @@ -295,6 +295,76 @@ CPUMF_EVENT_ATTR(cf_z15, DFLT_CC, 0x00108); · 294 unmodified lines | |||
| 295 | CPUMF_EVENT_ATTR(cf_z15, DFLT_CCFINISH, 0x00109); | 295 | CPUMF_EVENT_ATTR(cf_z15, DFLT_CCFINISH, 0x00109); |
| 296 | CPUMF_EVENT_ATTR(cf_z15, MT_DIAG_CYCLES_ONE_THR_ACTIVE, 0x01c0); | 296 | CPUMF_EVENT_ATTR(cf_z15, MT_DIAG_CYCLES_ONE_THR_ACTIVE, 0x01c0); |
| 297 | CPUMF_EVENT_ATTR(cf_z15, MT_DIAG_CYCLES_TWO_THR_ACTIVE, 0x01c1); | 297 | 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); | ||
| 298 | 368 | ||
| 299 | static struct attribute *cpumcf_fvn1_pmu_event_attr[] __initdata = { | 369 | static struct attribute *cpumcf_fvn1_pmu_event_attr[] __initdata = { |
| 300 | CPUMF_EVENT_PTR(cf_fvn1, CPU_CYCLES), | 370 | CPUMF_EVENT_PTR(cf_fvn1, CPU_CYCLES), |
| @@ -635,6 +705,80 @@ static struct attribute *cpumcf_z15_pmu_event_attr[] __initdata = { · 334 unmodified lines | |||
| 635 | NULL, | 705 | NULL, |
| 636 | }; | 706 | }; |
| 637 | 707 | ||
| 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 | |||
| 638 | /* END: CPUM_CF COUNTER DEFINITIONS ===================================== */ | 782 | /* END: CPUM_CF COUNTER DEFINITIONS ===================================== */ |
| 639 | 783 | ||
| 640 | static struct attribute_group cpumcf_pmu_events_group = { | 784 | 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 | |||
| 749 | case 0x8562: | 893 | case 0x8562: |
| 750 | model = cpumcf_z15_pmu_event_attr; | 894 | model = cpumcf_z15_pmu_event_attr; |
| 751 | break; | 895 | break; |
| 896 | case 0x3931: | ||
| 897 | case 0x3932: | ||
| 898 | model = cpumcf_z16_pmu_event_attr; | ||
| 899 | break; | ||
| 752 | default: | 900 | default: |
| 753 | model = none; | 901 | model = none; |
| 754 | break; | 902 | break; |
| @@ -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(®s, 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, ®s); | ||
| 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); | ||
| @@ -14,6 +14,7 @@ · 13 unmodified lines | |||
| 14 | * moves the new kernel to its destination... | 14 | * moves the new kernel to its destination... |
| 15 | * %r2 = pointer to first kimage_entry_t | 15 | * %r2 = pointer to first kimage_entry_t |
| 16 | * %r3 = start address - where to jump to after the job is done... | 16 | * %r3 = start address - where to jump to after the job is done... |
| 17 | * %r4 = subcode | ||
| 17 | * | 18 | * |
| 18 | * %r5 will be used as temp. storage | 19 | * %r5 will be used as temp. storage |
| 19 | * %r6 holds the destination address | 20 | * %r6 holds the destination address |
| @@ -56,7 +57,7 @@ ENTRY(relocate_kernel) · 36 unmodified lines | |||
| 56 | jo 0b | 57 | jo 0b |
| 57 | j .base | 58 | j .base |
| 58 | .done: | 59 | .done: |
| 59 | sgr %r0,%r0 # clear register r0 | 60 | lgr %r0,%r4 # subcode |
| 60 | cghi %r3,0 | 61 | cghi %r3,0 |
| 61 | je .diag | 62 | je .diag |
| 62 | la %r4,load_psw-.base(%r13) # load psw-address into the register | 63 | la %r4,load_psw-.base(%r13) # load psw-address into the register |
| @@ -494,7 +494,7 @@ static void __init setup_lowcore_dat_off(void) · 493 unmodified lines | |||
| 494 | lc->return_mcck_lpswe = gen_lpswe(__LC_RETURN_MCCK_PSW); | 494 | lc->return_mcck_lpswe = gen_lpswe(__LC_RETURN_MCCK_PSW); |
| 495 | lc->preempt_count = PREEMPT_DISABLED; | 495 | lc->preempt_count = PREEMPT_DISABLED; |
| 496 | 496 | ||
| 497 | set_prefix((u32)(unsigned long) lc); | 497 | set_prefix(__pa(lc)); |
| 498 | lowcore_ptr[0] = lc; | 498 | lowcore_ptr[0] = lc; |
| 499 | } | 499 | } |
| 500 | 500 | ||
| @@ -364,7 +364,7 @@ static inline int check_sync_clock(void) · 363 unmodified lines | |||
| 364 | * Apply clock delta to the global data structures. | 364 | * Apply clock delta to the global data structures. |
| 365 | * This is called once on the CPU that performed the clock sync. | 365 | * This is called once on the CPU that performed the clock sync. |
| 366 | */ | 366 | */ |
| 367 | static void clock_sync_global(unsigned long delta) | 367 | static void clock_sync_global(long delta) |
| 368 | { | 368 | { |
| 369 | unsigned long now, adj; | 369 | unsigned long now, adj; |
| 370 | struct ptff_qto qto; | 370 | struct ptff_qto qto; |
| @@ -400,7 +400,7 @@ static void clock_sync_global(unsigned long delta) · 29 unmodified lines | |||
| 400 | * Apply clock delta to the per-CPU data structures of this CPU. | 400 | * Apply clock delta to the per-CPU data structures of this CPU. |
| 401 | * This is called for each online CPU after the call to clock_sync_global. | 401 | * This is called for each online CPU after the call to clock_sync_global. |
| 402 | */ | 402 | */ |
| 403 | static void clock_sync_local(unsigned long delta) | 403 | static void clock_sync_local(long delta) |
| 404 | { | 404 | { |
| 405 | /* Add the delta to the clock comparator. */ | 405 | /* Add the delta to the clock comparator. */ |
| 406 | if (S390_lowcore.clock_comparator != clock_comparator_max) { | 406 | if (S390_lowcore.clock_comparator != clock_comparator_max) { |
| @@ -424,7 +424,7 @@ static void __init time_init_wq(void) · 17 unmodified lines | |||
| 424 | struct clock_sync_data { | 424 | struct clock_sync_data { |
| 425 | atomic_t cpus; | 425 | atomic_t cpus; |
| 426 | int in_sync; | 426 | int in_sync; |
| 427 | unsigned long clock_delta; | 427 | long clock_delta; |
| 428 | }; | 428 | }; |
| 429 | 429 | ||
| 430 | /* | 430 | /* |
| @@ -544,7 +544,7 @@ static int stpinfo_valid(void) · 113 unmodified lines | |||
| 544 | static int stp_sync_clock(void *data) | 544 | static int stp_sync_clock(void *data) |
| 545 | { | 545 | { |
| 546 | struct clock_sync_data *sync = data; | 546 | struct clock_sync_data *sync = data; |
| 547 | u64 clock_delta, flags; | 547 | long clock_delta, flags; |
| 548 | static int first; | 548 | static int first; |
| 549 | int rc; | 549 | int rc; |
| 550 | 550 | ||
| @@ -554,9 +554,7 @@ static int stp_sync_clock(void *data) · 3 unmodified lines | |||
| 554 | while (atomic_read(&sync->cpus) != 0) | 554 | while (atomic_read(&sync->cpus) != 0) |
| 555 | cpu_relax(); | 555 | cpu_relax(); |
| 556 | rc = 0; | 556 | rc = 0; |
| 557 | if (stp_info.todoff[0] || stp_info.todoff[1] || | 557 | if (stp_info.todoff || stp_info.tmd != 2) { |
| 558 | stp_info.todoff[2] || stp_info.todoff[3] || | ||
| 559 | stp_info.tmd != 2) { | ||
| 560 | flags = vdso_update_begin(); | 558 | flags = vdso_update_begin(); |
| 561 | rc = chsc_sstpc(stp_page, STP_OP_SYNC, 0, | 559 | rc = chsc_sstpc(stp_page, STP_OP_SYNC, 0, |
| 562 | &clock_delta); | 560 | &clock_delta); |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | |||
| 16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
| 17 | #include <linux/smp.h> | 17 | #include <linux/smp.h> |
| 18 | #include <linux/time_namespace.h> | 18 | #include <linux/time_namespace.h> |
| 19 | #include <linux/random.h> | ||
| 19 | #include <vdso/datapage.h> | 20 | #include <vdso/datapage.h> |
| 20 | #include <asm/vdso.h> | 21 | #include <asm/vdso.h> |
| 21 | 22 | ||
| @@ -160,10 +161,9 @@ int vdso_getcpu_init(void) · 138 unmodified lines | |||
| 160 | } | 161 | } |
| 161 | early_initcall(vdso_getcpu_init); /* Must be called before SMP init */ | 162 | early_initcall(vdso_getcpu_init); /* Must be called before SMP init */ |
| 162 | 163 | ||
| 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) |
| 164 | { | 165 | { |
| 165 | unsigned long vdso_text_len, vdso_mapping_len; | 166 | unsigned long vvar_start, vdso_text_start, vdso_text_len; |
| 166 | unsigned long vvar_start, vdso_text_start; | ||
| 167 | struct vm_special_mapping *vdso_mapping; | 167 | struct vm_special_mapping *vdso_mapping; |
| 168 | struct mm_struct *mm = current->mm; | 168 | struct mm_struct *mm = current->mm; |
| 169 | struct vm_area_struct *vma; | 169 | struct vm_area_struct *vma; |
| @@ -180,8 +180,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) · 10 unmodified lines | |||
| 180 | vdso_text_len = vdso64_end - vdso64_start; | 180 | vdso_text_len = vdso64_end - vdso64_start; |
| 181 | vdso_mapping = &vdso64_mapping; | 181 | vdso_mapping = &vdso64_mapping; |
| 182 | } | 182 | } |
| 183 | vdso_mapping_len = vdso_text_len + VVAR_NR_PAGES * PAGE_SIZE; | 183 | vvar_start = get_unmapped_area(NULL, addr, vdso_mapping_len, 0, 0); |
| 184 | vvar_start = get_unmapped_area(NULL, 0, vdso_mapping_len, 0, 0); | ||
| 185 | rc = vvar_start; | 184 | rc = vvar_start; |
| 186 | if (IS_ERR_VALUE(vvar_start)) | 185 | if (IS_ERR_VALUE(vvar_start)) |
| 187 | goto out; | 186 | goto out; |
| @@ -210,6 +209,52 @@ out: · 22 unmodified lines | |||
| 210 | return rc; | 209 | return rc; |
| 211 | } | 210 | } |
| 212 | 211 | ||
| 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 | |||
| 213 | static struct page ** __init vdso_setup_pages(void *start, void *end) | 258 | static struct page ** __init vdso_setup_pages(void *start, void *end) |
| 214 | { | 259 | { |
| 215 | int pages = (end - start) >> PAGE_SHIFT; | 260 | int pages = (end - start) >> PAGE_SHIFT; |
| @@ -11,7 +11,6 @@ · 10 unmodified lines | |||
| 11 | #include <linux/kvm.h> | 11 | #include <linux/kvm.h> |
| 12 | #include <linux/gfp.h> | 12 | #include <linux/gfp.h> |
| 13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
| 14 | #include <linux/compat.h> | ||
| 15 | #include <linux/mm_types.h> | 14 | #include <linux/mm_types.h> |
| 16 | #include <linux/pgtable.h> | 15 | #include <linux/pgtable.h> |
| 17 | 16 | ||
| @@ -75,7 +75,7 @@ static inline int arch_load_niai4(int *lock) · 74 unmodified lines | |||
| 75 | int owner; | 75 | int owner; |
| 76 | 76 | ||
| 77 | asm_inline volatile( | 77 | asm_inline volatile( |
| 78 | ALTERNATIVE("", ".insn rre,0xb2fa0000,4,0", 49) /* NIAI 4 */ | 78 | ALTERNATIVE("nop", ".insn rre,0xb2fa0000,4,0", 49) /* NIAI 4 */ |
| 79 | " l %0,%1\n" | 79 | " l %0,%1\n" |
| 80 | : "=d" (owner) : "Q" (*lock) : "memory"); | 80 | : "=d" (owner) : "Q" (*lock) : "memory"); |
| 81 | return owner; | 81 | return owner; |
| @@ -86,7 +86,7 @@ static inline int arch_cmpxchg_niai8(int *lock, int old, int new) · 4 unmodified lines | |||
| 86 | int expected = old; | 86 | int expected = old; |
| 87 | 87 | ||
| 88 | asm_inline volatile( | 88 | asm_inline volatile( |
| 89 | ALTERNATIVE("", ".insn rre,0xb2fa0000,8,0", 49) /* NIAI 8 */ | 89 | ALTERNATIVE("nop", ".insn rre,0xb2fa0000,8,0", 49) /* NIAI 8 */ |
| 90 | " cs %0,%3,%1\n" | 90 | " cs %0,%3,%1\n" |
| 91 | : "=d" (old), "=Q" (*lock) | 91 | : "=d" (old), "=Q" (*lock) |
| 92 | : "0" (old), "d" (new), "Q" (*lock) | 92 | : "0" (old), "d" (new), "Q" (*lock) |
| @@ -58,9 +58,9 @@ static inline unsigned long mmap_base(unsigned long rnd, · 57 unmodified lines | |||
| 58 | 58 | ||
| 59 | /* | 59 | /* |
| 60 | * Top of mmap area (just below the process stack). | 60 | * 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. |
| 62 | */ | 62 | */ |
| 63 | gap_min = 32 * 1024 * 1024UL; | 63 | gap_min = SZ_128M; |
| 64 | gap_max = (STACK_TOP / 6) * 5; | 64 | gap_max = (STACK_TOP / 6) * 5; |
| 65 | 65 | ||
| 66 | if (gap < gap_min) | 66 | if (gap < gap_min) |
| @@ -799,7 +799,7 @@ struct zpci_dev *zpci_create_device(u32 fid, u32 fh, enum zpci_state state) · 798 unmodified lines | |||
| 799 | struct zpci_dev *zdev; | 799 | struct zpci_dev *zdev; |
| 800 | int rc; | 800 | int rc; |
| 801 | 801 | ||
| 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); |
| 803 | zdev = kzalloc(sizeof(*zdev), GFP_KERNEL); | 803 | zdev = kzalloc(sizeof(*zdev), GFP_KERNEL); |
| 804 | if (!zdev) | 804 | if (!zdev) |
| 805 | return ERR_PTR(-ENOMEM); | 805 | return ERR_PTR(-ENOMEM); |
| @@ -30,7 +30,7 @@ bool zpci_unique_uid; · 29 unmodified lines | |||
| 30 | void update_uid_checking(bool new) | 30 | void update_uid_checking(bool new) |
| 31 | { | 31 | { |
| 32 | if (zpci_unique_uid != new) | 32 | if (zpci_unique_uid != new) |
| 33 | zpci_dbg(1, "uid checking:%d\n", new); | 33 | zpci_dbg(3, "uid checking:%d\n", new); |
| 34 | 34 | ||
| 35 | zpci_unique_uid = new; | 35 | zpci_unique_uid = new; |
| 36 | } | 36 | } |
| @@ -196,7 +196,7 @@ int __init zpci_debug_init(void) · 195 unmodified lines | |||
| 196 | if (!pci_debug_err_id) | 196 | if (!pci_debug_err_id) |
| 197 | return -EINVAL; | 197 | return -EINVAL; |
| 198 | debug_register_view(pci_debug_err_id, &debug_hex_ascii_view); | 198 | 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); |
| 200 | 200 | ||
| 201 | debugfs_root = debugfs_create_dir("pci", NULL); | 201 | debugfs_root = debugfs_create_dir("pci", NULL); |
| 202 | return 0; | 202 | return 0; |
| @@ -321,9 +321,6 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf) · 320 unmodified lines | |||
| 321 | 321 | ||
| 322 | zpci_dbg(3, "avl fid:%x, fh:%x, pec:%x\n", | 322 | zpci_dbg(3, "avl fid:%x, fh:%x, pec:%x\n", |
| 323 | ccdf->fid, ccdf->fh, ccdf->pec); | 323 | ccdf->fid, ccdf->fh, ccdf->pec); |
| 324 | zpci_err("avail CCDF:\n"); | ||
| 325 | zpci_err_hex(ccdf, sizeof(*ccdf)); | ||
| 326 | |||
| 327 | switch (ccdf->pec) { | 324 | switch (ccdf->pec) { |
| 328 | case 0x0301: /* Reserved|Standby -> Configured */ | 325 | case 0x0301: /* Reserved|Standby -> Configured */ |
| 329 | if (!zdev) { | 326 | if (!zdev) { |
| @@ -18,16 +18,40 @@ · 17 unmodified lines | |||
| 18 | 18 | ||
| 19 | #define ZPCI_INSN_BUSY_DELAY 1 /* 1 microsecond */ | 19 | #define ZPCI_INSN_BUSY_DELAY 1 /* 1 microsecond */ |
| 20 | 20 | ||
| 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) | ||
| 22 | { | 39 | { |
| 23 | struct { | 40 | struct zpci_err_insn_data data = { |
| 24 | u64 req; | 41 | .insn = insn, .cc = cc, .status = status, |
| 25 | u64 offset; | 42 | .req = req, .offset = offset}; |
| 26 | u8 cc; | 43 | |
| 27 | u8 status; | 44 | zpci_err_hex_level(lvl, &data, sizeof(data)); |
| 28 | } __packed data = {req, offset, cc, status}; | 45 | } |
| 29 | 46 | ||
| 30 | zpci_err_hex(&data, sizeof(data)); | 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)); | ||
| 31 | } | 55 | } |
| 32 | 56 | ||
| 33 | /* Modify PCI Function Controls */ | 57 | /* Modify PCI Function Controls */ |
| @@ -47,16 +71,24 @@ static inline u8 __mpcifc(u64 req, struct zpci_fib *fib, u8 *status) · 13 unmodified lines | |||
| 47 | 71 | ||
| 48 | u8 zpci_mod_fc(u64 req, struct zpci_fib *fib, u8 *status) | 72 | u8 zpci_mod_fc(u64 req, struct zpci_fib *fib, u8 *status) |
| 49 | { | 73 | { |
| 74 | bool retried = false; | ||
| 50 | u8 cc; | 75 | u8 cc; |
| 51 | 76 | ||
| 52 | do { | 77 | do { |
| 53 | cc = __mpcifc(req, fib, status); | 78 | cc = __mpcifc(req, fib, status); |
| 54 | if (cc == 2) | 79 | if (cc == 2) { |
| 55 | msleep(ZPCI_INSN_BUSY_DELAY); | 80 | msleep(ZPCI_INSN_BUSY_DELAY); |
| 81 | if (!retried) { | ||
| 82 | zpci_err_insn_req(1, 'M', cc, *status, req, 0); | ||
| 83 | retried = true; | ||
| 84 | } | ||
| 85 | } | ||
| 56 | } while (cc == 2); | 86 | } while (cc == 2); |
| 57 | 87 | ||
| 58 | if (cc) | 88 | 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); | ||
| 60 | 92 | ||
| 61 | return cc; | 93 | return cc; |
| 62 | } | 94 | } |
| @@ -80,16 +112,24 @@ static inline u8 __rpcit(u64 fn, u64 addr, u64 range, u8 *status) · 17 unmodified lines | |||
| 80 | 112 | ||
| 81 | int zpci_refresh_trans(u64 fn, u64 addr, u64 range) | 113 | int zpci_refresh_trans(u64 fn, u64 addr, u64 range) |
| 82 | { | 114 | { |
| 115 | bool retried = false; | ||
| 83 | u8 cc, status; | 116 | u8 cc, status; |
| 84 | 117 | ||
| 85 | do { | 118 | do { |
| 86 | cc = __rpcit(fn, addr, range, &status); | 119 | cc = __rpcit(fn, addr, range, &status); |
| 87 | if (cc == 2) | 120 | if (cc == 2) { |
| 88 | udelay(ZPCI_INSN_BUSY_DELAY); | 121 | udelay(ZPCI_INSN_BUSY_DELAY); |
| 122 | if (!retried) { | ||
| 123 | zpci_err_insn_addr(1, 'R', cc, status, addr, range); | ||
| 124 | retried = true; | ||
| 125 | } | ||
| 126 | } | ||
| 89 | } while (cc == 2); | 127 | } while (cc == 2); |
| 90 | 128 | ||
| 91 | if (cc) | 129 | 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); | ||
| 93 | 133 | ||
| 94 | if (cc == 1 && (status == 4 || status == 16)) | 134 | if (cc == 1 && (status == 4 || status == 16)) |
| 95 | return -ENOMEM; | 135 | return -ENOMEM; |
| @@ -144,17 +184,25 @@ static inline int __pcilg(u64 *data, u64 req, u64 offset, u8 *status) · 48 unmodified lines | |||
| 144 | 184 | ||
| 145 | int __zpci_load(u64 *data, u64 req, u64 offset) | 185 | int __zpci_load(u64 *data, u64 req, u64 offset) |
| 146 | { | 186 | { |
| 187 | bool retried = false; | ||
| 147 | u8 status; | 188 | u8 status; |
| 148 | int cc; | 189 | int cc; |
| 149 | 190 | ||
| 150 | do { | 191 | do { |
| 151 | cc = __pcilg(data, req, offset, &status); | 192 | cc = __pcilg(data, req, offset, &status); |
| 152 | if (cc == 2) | 193 | if (cc == 2) { |
| 153 | udelay(ZPCI_INSN_BUSY_DELAY); | 194 | udelay(ZPCI_INSN_BUSY_DELAY); |
| 195 | if (!retried) { | ||
| 196 | zpci_err_insn_req(1, 'l', cc, status, req, offset); | ||
| 197 | retried = true; | ||
| 198 | } | ||
| 199 | } | ||
| 154 | } while (cc == 2); | 200 | } while (cc == 2); |
| 155 | 201 | ||
| 156 | if (cc) | 202 | 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); | ||
| 158 | 206 | ||
| 159 | return (cc > 0) ? -EIO : cc; | 207 | return (cc > 0) ? -EIO : cc; |
| 160 | } | 208 | } |
| @@ -198,7 +246,7 @@ int zpci_load(u64 *data, const volatile void __iomem *addr, unsigned long len) · 37 unmodified lines | |||
| 198 | 246 | ||
| 199 | cc = __pcilg_mio(data, (__force u64) addr, len, &status); | 247 | cc = __pcilg_mio(data, (__force u64) addr, len, &status); |
| 200 | if (cc) | 248 | 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); |
| 202 | 250 | ||
| 203 | return (cc > 0) ? -EIO : cc; | 251 | return (cc > 0) ? -EIO : cc; |
| 204 | } | 252 | } |
| @@ -225,17 +273,25 @@ static inline int __pcistg(u64 data, u64 req, u64 offset, u8 *status) · 20 unmodified lines | |||
| 225 | 273 | ||
| 226 | int __zpci_store(u64 data, u64 req, u64 offset) | 274 | int __zpci_store(u64 data, u64 req, u64 offset) |
| 227 | { | 275 | { |
| 276 | bool retried = false; | ||
| 228 | u8 status; | 277 | u8 status; |
| 229 | int cc; | 278 | int cc; |
| 230 | 279 | ||
| 231 | do { | 280 | do { |
| 232 | cc = __pcistg(data, req, offset, &status); | 281 | cc = __pcistg(data, req, offset, &status); |
| 233 | if (cc == 2) | 282 | if (cc == 2) { |
| 234 | udelay(ZPCI_INSN_BUSY_DELAY); | 283 | udelay(ZPCI_INSN_BUSY_DELAY); |
| 284 | if (!retried) { | ||
| 285 | zpci_err_insn_req(1, 's', cc, status, req, offset); | ||
| 286 | retried = true; | ||
| 287 | } | ||
| 288 | } | ||
| 235 | } while (cc == 2); | 289 | } while (cc == 2); |
| 236 | 290 | ||
| 237 | if (cc) | 291 | 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); | ||
| 239 | 295 | ||
| 240 | return (cc > 0) ? -EIO : cc; | 296 | return (cc > 0) ? -EIO : cc; |
| 241 | } | 297 | } |
| @@ -278,7 +334,7 @@ int zpci_store(const volatile void __iomem *addr, u64 data, unsigned long len) · 36 unmodified lines | |||
| 278 | 334 | ||
| 279 | cc = __pcistg_mio(data, (__force u64) addr, len, &status); | 335 | cc = __pcistg_mio(data, (__force u64) addr, len, &status); |
| 280 | if (cc) | 336 | 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); |
| 282 | 338 | ||
| 283 | return (cc > 0) ? -EIO : cc; | 339 | return (cc > 0) ? -EIO : cc; |
| 284 | } | 340 | } |
| @@ -304,17 +360,25 @@ static inline int __pcistb(const u64 *data, u64 req, u64 offset, u8 *status) · 19 unmodified lines | |||
| 304 | 360 | ||
| 305 | int __zpci_store_block(const u64 *data, u64 req, u64 offset) | 361 | int __zpci_store_block(const u64 *data, u64 req, u64 offset) |
| 306 | { | 362 | { |
| 363 | bool retried = false; | ||
| 307 | u8 status; | 364 | u8 status; |
| 308 | int cc; | 365 | int cc; |
| 309 | 366 | ||
| 310 | do { | 367 | do { |
| 311 | cc = __pcistb(data, req, offset, &status); | 368 | cc = __pcistb(data, req, offset, &status); |
| 312 | if (cc == 2) | 369 | if (cc == 2) { |
| 313 | udelay(ZPCI_INSN_BUSY_DELAY); | 370 | udelay(ZPCI_INSN_BUSY_DELAY); |
| 371 | if (!retried) { | ||
| 372 | zpci_err_insn_req(0, 'b', cc, status, req, offset); | ||
| 373 | retried = true; | ||
| 374 | } | ||
| 375 | } | ||
| 314 | } while (cc == 2); | 376 | } while (cc == 2); |
| 315 | 377 | ||
| 316 | if (cc) | 378 | 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); | ||
| 318 | 382 | ||
| 319 | return (cc > 0) ? -EIO : cc; | 383 | return (cc > 0) ? -EIO : cc; |
| 320 | } | 384 | } |
| @@ -358,7 +422,7 @@ int zpci_write_block(volatile void __iomem *dst, · 37 unmodified lines | |||
| 358 | 422 | ||
| 359 | cc = __pcistb_mio(src, (__force u64) dst, len, &status); | 423 | cc = __pcistb_mio(src, (__force u64) dst, len, &status); |
| 360 | if (cc) | 424 | 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); |
| 362 | 426 | ||
| 363 | return (cc > 0) ? -EIO : cc; | 427 | return (cc > 0) ? -EIO : cc; |
| 364 | } | 428 | } |
| @@ -44,11 +44,14 @@ · 43 unmodified lines | |||
| 44 | .endm | 44 | .endm |
| 45 | 45 | ||
| 46 | .macro MEMSWAP dst,src,buf,len | 46 | .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 | ||
| 48 | jh 11f | 51 | jh 11f |
| 49 | lgr %r4,\len | 52 | lgr %r4,\len |
| 50 | j 12f | 53 | j 12f |
| 51 | 11: lghi %r4,bufsz | 54 | 11: lgr %r4,%r0 |
| 52 | 55 | ||
| 53 | 12: MEMCPY \buf,\dst,%r4 | 56 | 12: MEMCPY \buf,\dst,%r4 |
| 54 | MEMCPY \dst,\src,%r4 | 57 | MEMCPY \dst,\src,%r4 |
| @@ -135,12 +138,18 @@ ENTRY(purgatory_start) · 80 unmodified lines | |||
| 135 | 138 | ||
| 136 | .start_crash_kernel: | 139 | .start_crash_kernel: |
| 137 | /* Location of purgatory_start in crash memory */ | 140 | /* Location of purgatory_start in crash memory */ |
| 141 | larl %r0,.base_crash | ||
| 142 | larl %r1,purgatory_start | ||
| 143 | slgr %r0,%r1 | ||
| 138 | lgr %r8,%r13 | 144 | lgr %r8,%r13 |
| 139 | aghi %r8,-(.base_crash-purgatory_start) | 145 | sgr %r8,%r0 |
| 140 | 146 | ||
| 141 | /* Destination for this code i.e. end of memory to be swapped. */ | 147 | /* 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 | ||
| 142 | lg %r9,crash_size-.base_crash(%r13) | 151 | lg %r9,crash_size-.base_crash(%r13) |
| 143 | aghi %r9,-(purgatory_end-purgatory_start) | 152 | sgr %r9,%r0 |
| 144 | 153 | ||
| 145 | /* Destination in crash memory, i.e. same as r9 but in crash memory. */ | 154 | /* Destination in crash memory, i.e. same as r9 but in crash memory. */ |
| 146 | lg %r10,crash_start-.base_crash(%r13) | 155 | lg %r10,crash_start-.base_crash(%r13) |
| @@ -149,15 +158,19 @@ ENTRY(purgatory_start) · 2 unmodified lines | |||
| 149 | /* Buffer location (in crash memory) and size. As the purgatory is | 158 | /* Buffer location (in crash memory) and size. As the purgatory is |
| 150 | * behind the point of no return it can re-use the stack as buffer. | 159 | * behind the point of no return it can re-use the stack as buffer. |
| 151 | */ | 160 | */ |
| 152 | lghi %r11,bufsz | 161 | larl %r11,purgatory_end |
| 153 | larl %r12,stack | 162 | larl %r12,stack |
| 163 | slgr %r11,%r12 | ||
| 154 | 164 | ||
| 155 | MEMCPY %r12,%r9,%r11 /* dst -> (crash) buf */ | 165 | MEMCPY %r12,%r9,%r11 /* dst -> (crash) buf */ |
| 156 | MEMCPY %r9,%r8,%r11 /* self -> dst */ | 166 | MEMCPY %r9,%r8,%r11 /* self -> dst */ |
| 157 | 167 | ||
| 158 | /* Jump to new location. */ | 168 | /* Jump to new location. */ |
| 159 | lgr %r7,%r9 | 169 | 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 | ||
| 161 | br %r7 | 174 | br %r7 |
| 162 | 175 | ||
| 163 | .jump_to_dst: | 176 | .jump_to_dst: |
| @@ -169,7 +182,10 @@ ENTRY(purgatory_start) · 5 unmodified lines | |||
| 169 | 182 | ||
| 170 | /* Load new buffer location after jump */ | 183 | /* Load new buffer location after jump */ |
| 171 | larl %r7,stack | 184 | 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 | ||
| 173 | MEMCPY %r10,%r7,%r11 /* (new) buf -> (crash) buf */ | 189 | MEMCPY %r10,%r7,%r11 /* (new) buf -> (crash) buf */ |
| 174 | 190 | ||
| 175 | /* Now the code is set up to run from its designated location. Start | 191 | /* Now the code is set up to run from its designated location. Start |
| @@ -10,7 +10,7 @@ · 9 unmodified lines | |||
| 10 | #include <asm/fpu/api.h> | 10 | #include <asm/fpu/api.h> |
| 11 | 11 | ||
| 12 | /* Check that the stack and regs on entry from user mode are sane. */ | 12 | /* 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) |
| 14 | { | 14 | { |
| 15 | if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) { | 15 | if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) { |
| 16 | /* | 16 | /* |
| @@ -42,7 +42,7 @@ static __always_inline void arch_check_user_regs(struct pt_regs *regs) · 25 unmodified lines | |||
| 42 | WARN_ON_ONCE(regs != task_pt_regs(current)); | 42 | WARN_ON_ONCE(regs != task_pt_regs(current)); |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | #define arch_check_user_regs arch_check_user_regs | 45 | #define arch_enter_from_user_mode arch_enter_from_user_mode |
| 46 | 46 | ||
| 47 | static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, | 47 | static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, |
| 48 | unsigned long ti_work) | 48 | unsigned long ti_work) |
| @@ -771,35 +771,36 @@ static struct tty_driver *con3215_device(struct console *c, int *index) · 770 unmodified lines | |||
| 771 | } | 771 | } |
| 772 | 772 | ||
| 773 | /* | 773 | /* |
| 774 | * panic() calls con3215_flush through a panic_notifier | 774 | * The below function is called as a panic/reboot notifier before the |
| 775 | * before the system enters a disabled, endless loop. | 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). | ||
| 776 | */ | 780 | */ |
| 777 | static void con3215_flush(void) | 781 | static int con3215_notify(struct notifier_block *self, |
| 782 | unsigned long event, void *data) | ||
| 778 | { | 783 | { |
| 779 | struct raw3215_info *raw; | 784 | struct raw3215_info *raw; |
| 780 | unsigned long flags; | 785 | unsigned long flags; |
| 781 | 786 | ||
| 782 | raw = raw3215[0]; /* console 3215 is the first one */ | 787 | 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; | ||
| 784 | raw3215_make_room(raw, RAW3215_BUFFER_SIZE); | 790 | raw3215_make_room(raw, RAW3215_BUFFER_SIZE); |
| 785 | spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); | 791 | spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); |
| 786 | } | ||
| 787 | 792 | ||
| 788 | static int con3215_notify(struct notifier_block *self, | 793 | return NOTIFY_DONE; |
| 789 | unsigned long event, void *data) | ||
| 790 | { | ||
| 791 | con3215_flush(); | ||
| 792 | return NOTIFY_OK; | ||
| 793 | } | 794 | } |
| 794 | 795 | ||
| 795 | static struct notifier_block on_panic_nb = { | 796 | static struct notifier_block on_panic_nb = { |
| 796 | .notifier_call = con3215_notify, | 797 | .notifier_call = con3215_notify, |
| 797 | .priority = 0, | 798 | .priority = INT_MIN + 1, /* run the callback late */ |
| 798 | }; | 799 | }; |
| 799 | 800 | ||
| 800 | static struct notifier_block on_reboot_nb = { | 801 | static struct notifier_block on_reboot_nb = { |
| 801 | .notifier_call = con3215_notify, | 802 | .notifier_call = con3215_notify, |
| 802 | .priority = 0, | 803 | .priority = INT_MIN + 1, /* run the callback late */ |
| 803 | }; | 804 | }; |
| 804 | 805 | ||
| 805 | /* | 806 | /* |
| @@ -535,20 +535,26 @@ con3270_wait_write(struct con3270 *cp) · 534 unmodified lines | |||
| 535 | } | 535 | } |
| 536 | 536 | ||
| 537 | /* | 537 | /* |
| 538 | * panic() calls con3270_flush through a panic_notifier | 538 | * The below function is called as a panic/reboot notifier before the |
| 539 | * before the system enters a disabled, endless loop. | 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). | ||
| 540 | */ | 544 | */ |
| 541 | static void | 545 | static int con3270_notify(struct notifier_block *self, |
| 542 | con3270_flush(void) | 546 | unsigned long event, void *data) |
| 543 | { | 547 | { |
| 544 | struct con3270 *cp; | 548 | struct con3270 *cp; |
| 545 | unsigned long flags; | 549 | unsigned long flags; |
| 546 | 550 | ||
| 547 | cp = condev; | 551 | cp = condev; |
| 548 | if (!cp->view.dev) | 552 | if (!cp->view.dev) |
| 549 | return; | 553 | return NOTIFY_DONE; |
| 550 | raw3270_activate_view(&cp->view); | 554 | if (!raw3270_view_lock_unavailable(&cp->view)) |
| 551 | spin_lock_irqsave(&cp->view.lock, flags); | 555 | raw3270_activate_view(&cp->view); |
| 556 | if (!spin_trylock_irqsave(&cp->view.lock, flags)) | ||
| 557 | return NOTIFY_DONE; | ||
| 552 | con3270_wait_write(cp); | 558 | con3270_wait_write(cp); |
| 553 | cp->nr_up = 0; | 559 | cp->nr_up = 0; |
| 554 | con3270_rebuild_update(cp); | 560 | con3270_rebuild_update(cp); |
| @@ -560,23 +566,18 @@ con3270_flush(void) · 5 unmodified lines | |||
| 560 | con3270_wait_write(cp); | 566 | con3270_wait_write(cp); |
| 561 | } | 567 | } |
| 562 | spin_unlock_irqrestore(&cp->view.lock, flags); | 568 | spin_unlock_irqrestore(&cp->view.lock, flags); |
| 563 | } | ||
| 564 | 569 | ||
| 565 | static int con3270_notify(struct notifier_block *self, | 570 | return NOTIFY_DONE; |
| 566 | unsigned long event, void *data) | ||
| 567 | { | ||
| 568 | con3270_flush(); | ||
| 569 | return NOTIFY_OK; | ||
| 570 | } | 571 | } |
| 571 | 572 | ||
| 572 | static struct notifier_block on_panic_nb = { | 573 | static struct notifier_block on_panic_nb = { |
| 573 | .notifier_call = con3270_notify, | 574 | .notifier_call = con3270_notify, |
| 574 | .priority = 0, | 575 | .priority = INT_MIN + 1, /* run the callback late */ |
| 575 | }; | 576 | }; |
| 576 | 577 | ||
| 577 | static struct notifier_block on_reboot_nb = { | 578 | static struct notifier_block on_reboot_nb = { |
| 578 | .notifier_call = con3270_notify, | 579 | .notifier_call = con3270_notify, |
| 579 | .priority = 0, | 580 | .priority = INT_MIN + 1, /* run the callback late */ |
| 580 | }; | 581 | }; |
| 581 | 582 | ||
| 582 | /* | 583 | /* |
| @@ -830,6 +830,21 @@ raw3270_create_device(struct ccw_device *cdev) · 829 unmodified lines | |||
| 830 | return rp; | 830 | return rp; |
| 831 | } | 831 | } |
| 832 | 832 | ||
| 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 | |||
| 833 | /* | 848 | /* |
| 834 | * Activate a view. | 849 | * Activate a view. |
| 835 | */ | 850 | */ |
| @@ -160,6 +160,7 @@ struct raw3270_view { · 159 unmodified lines | |||
| 160 | }; | 160 | }; |
| 161 | 161 | ||
| 162 | int raw3270_add_view(struct raw3270_view *, struct raw3270_fn *, int, int); | 162 | int raw3270_add_view(struct raw3270_view *, struct raw3270_fn *, int, int); |
| 163 | int raw3270_view_lock_unavailable(struct raw3270_view *view); | ||
| 163 | int raw3270_activate_view(struct raw3270_view *); | 164 | int raw3270_activate_view(struct raw3270_view *); |
| 164 | void raw3270_del_view(struct raw3270_view *); | 165 | void raw3270_del_view(struct raw3270_view *); |
| 165 | void raw3270_deactivate_view(struct raw3270_view *); | 166 | void raw3270_deactivate_view(struct raw3270_view *); |
| @@ -220,30 +220,34 @@ sclp_console_device(struct console *c, int *index) · 219 unmodified lines | |||
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | /* | 222 | /* |
| 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. | ||
| 224 | */ | 225 | */ |
| 225 | static void | 226 | static int sclp_console_notify(struct notifier_block *self, |
| 226 | sclp_console_flush(void) | 227 | unsigned long event, void *data) |
| 227 | { | 228 | { |
| 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 | |||
| 228 | sclp_conbuf_emit(); | 237 | sclp_conbuf_emit(); |
| 229 | sclp_console_sync_queue(); | 238 | sclp_console_sync_queue(); |
| 230 | } | ||
| 231 | 239 | ||
| 232 | static int sclp_console_notify(struct notifier_block *self, | 240 | return NOTIFY_DONE; |
| 233 | unsigned long event, void *data) | ||
| 234 | { | ||
| 235 | sclp_console_flush(); | ||
| 236 | return NOTIFY_OK; | ||
| 237 | } | 241 | } |
| 238 | 242 | ||
| 239 | static struct notifier_block on_panic_nb = { | 243 | static struct notifier_block on_panic_nb = { |
| 240 | .notifier_call = sclp_console_notify, | 244 | .notifier_call = sclp_console_notify, |
| 241 | .priority = 1, | 245 | .priority = INT_MIN + 1, /* run the callback late */ |
| 242 | }; | 246 | }; |
| 243 | 247 | ||
| 244 | static struct notifier_block on_reboot_nb = { | 248 | static struct notifier_block on_reboot_nb = { |
| 245 | .notifier_call = sclp_console_notify, | 249 | .notifier_call = sclp_console_notify, |
| 246 | .priority = 1, | 250 | .priority = INT_MIN + 1, /* run the callback late */ |
| 247 | }; | 251 | }; |
| 248 | 252 | ||
| 249 | /* | 253 | /* |
| @@ -49,8 +49,10 @@ static void __init sclp_early_facilities_detect(void) · 48 unmodified lines | |||
| 49 | S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP; | 49 | S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP; |
| 50 | if (sccb->fac91 & 0x40) | 50 | if (sccb->fac91 & 0x40) |
| 51 | S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_GUEST; | 51 | S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_GUEST; |
| 52 | if (sccb->cpuoff > 134) | 52 | if (sccb->cpuoff > 134) { |
| 53 | sclp.has_diag318 = !!(sccb->byte_134 & 0x80); | 53 | sclp.has_diag318 = !!(sccb->byte_134 & 0x80); |
| 54 | sclp.has_iplcc = !!(sccb->byte_134 & 0x02); | ||
| 55 | } | ||
| 54 | if (sccb->cpuoff > 137) | 56 | if (sccb->cpuoff > 137) |
| 55 | sclp.has_sipl = !!(sccb->cbl & 0x4000); | 57 | sclp.has_sipl = !!(sccb->cbl & 0x4000); |
| 56 | sclp.rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2; | 58 | sclp.rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2; |
| @@ -769,21 +769,6 @@ __initcall(sclp_vt220_tty_init); · 768 unmodified lines | |||
| 769 | 769 | ||
| 770 | #ifdef CONFIG_SCLP_VT220_CONSOLE | 770 | #ifdef CONFIG_SCLP_VT220_CONSOLE |
| 771 | 771 | ||
| 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 | |||
| 787 | static void | 772 | static void |
| 788 | sclp_vt220_con_write(struct console *con, const char *buf, unsigned int count) | 773 | sclp_vt220_con_write(struct console *con, const char *buf, unsigned int count) |
| 789 | { | 774 | { |
| @@ -797,22 +782,41 @@ sclp_vt220_con_device(struct console *c, int *index) · 7 unmodified lines | |||
| 797 | return sclp_vt220_driver; | 782 | return sclp_vt220_driver; |
| 798 | } | 783 | } |
| 799 | 784 | ||
| 785 | /* | ||
| 786 | * This panic/reboot notifier runs in atomic context, so | ||
| 787 | * locking restrictions apply to prevent potential lockups. | ||
| 788 | */ | ||
| 800 | static int | 789 | static int |
| 801 | sclp_vt220_notify(struct notifier_block *self, | 790 | sclp_vt220_notify(struct notifier_block *self, |
| 802 | unsigned long event, void *data) | 791 | unsigned long event, void *data) |
| 803 | { | 792 | { |
| 804 | __sclp_vt220_flush_buffer(); | 793 | unsigned long flags; |
| 805 | return NOTIFY_OK; | 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; | ||
| 806 | } | 810 | } |
| 807 | 811 | ||
| 808 | static struct notifier_block on_panic_nb = { | 812 | static struct notifier_block on_panic_nb = { |
| 809 | .notifier_call = sclp_vt220_notify, | 813 | .notifier_call = sclp_vt220_notify, |
| 810 | .priority = 1, | 814 | .priority = INT_MIN + 1, /* run the callback late */ |
| 811 | }; | 815 | }; |
| 812 | 816 | ||
| 813 | static struct notifier_block on_reboot_nb = { | 817 | static struct notifier_block on_reboot_nb = { |
| 814 | .notifier_call = sclp_vt220_notify, | 818 | .notifier_call = sclp_vt220_notify, |
| 815 | .priority = 1, | 819 | .priority = INT_MIN + 1, /* run the callback late */ |
| 816 | }; | 820 | }; |
| 817 | 821 | ||
| 818 | /* Structure needed to register with printk */ | 822 | /* Structure needed to register with printk */ |
| @@ -1255,7 +1255,7 @@ exit: · 1254 unmodified lines | |||
| 1255 | EXPORT_SYMBOL_GPL(css_general_characteristics); | 1255 | EXPORT_SYMBOL_GPL(css_general_characteristics); |
| 1256 | EXPORT_SYMBOL_GPL(css_chsc_characteristics); | 1256 | EXPORT_SYMBOL_GPL(css_chsc_characteristics); |
| 1257 | 1257 | ||
| 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) |
| 1259 | { | 1259 | { |
| 1260 | struct { | 1260 | struct { |
| 1261 | struct chsc_header request; | 1261 | struct chsc_header request; |
| @@ -1266,7 +1266,7 @@ int chsc_sstpc(void *page, unsigned int op, u16 ctrl, u64 *clock_delta) · 4 unmodified lines | |||
| 1266 | unsigned int rsvd2[5]; | 1266 | unsigned int rsvd2[5]; |
| 1267 | struct chsc_header response; | 1267 | struct chsc_header response; |
| 1268 | unsigned int rsvd3[3]; | 1268 | unsigned int rsvd3[3]; |
| 1269 | u64 clock_delta; | 1269 | s64 clock_delta; |
| 1270 | unsigned int rsvd4[2]; | 1270 | unsigned int rsvd4[2]; |
| 1271 | } *rr; | 1271 | } *rr; |
| 1272 | int rc; | 1272 | int rc; |
| @@ -179,7 +179,7 @@ static int ap_qci_available(void) · 178 unmodified lines | |||
| 179 | * ap_apft_available(): Test if AP facilities test (APFT) | 179 | * ap_apft_available(): Test if AP facilities test (APFT) |
| 180 | * facility is available. | 180 | * facility is available. |
| 181 | * | 181 | * |
| 182 | * Returns 1 if APFT is is available. | 182 | * Returns 1 if APFT is available. |
| 183 | */ | 183 | */ |
| 184 | static int ap_apft_available(void) | 184 | static int ap_apft_available(void) |
| 185 | { | 185 | { |
| @@ -693,6 +693,24 @@ void ap_send_online_uevent(struct ap_device *ap_dev, int online) · 507 unmodified lines | |||
| 693 | } | 693 | } |
| 694 | EXPORT_SYMBOL(ap_send_online_uevent); | 694 | EXPORT_SYMBOL(ap_send_online_uevent); |
| 695 | 695 | ||
| 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 | |||
| 696 | /* | 714 | /* |
| 697 | * calc # of bound APQNs | 715 | * calc # of bound APQNs |
| 698 | */ | 716 | */ |
| @@ -704,7 +722,7 @@ struct __ap_calc_ctrs { · 5 unmodified lines | |||
| 704 | 722 | ||
| 705 | static int __ap_calc_helper(struct device *dev, void *arg) | 723 | static int __ap_calc_helper(struct device *dev, void *arg) |
| 706 | { | 724 | { |
| 707 | struct __ap_calc_ctrs *pctrs = (struct __ap_calc_ctrs *) arg; | 725 | struct __ap_calc_ctrs *pctrs = (struct __ap_calc_ctrs *)arg; |
| 708 | 726 | ||
| 709 | if (is_queue_dev(dev)) { | 727 | if (is_queue_dev(dev)) { |
| 710 | pctrs->apqns++; | 728 | pctrs->apqns++; |
| @@ -720,7 +738,7 @@ static void ap_calc_bound_apqns(unsigned int *apqns, unsigned int *bound) · 9 unmodified lines | |||
| 720 | struct __ap_calc_ctrs ctrs; | 738 | struct __ap_calc_ctrs ctrs; |
| 721 | 739 | ||
| 722 | memset(&ctrs, 0, sizeof(ctrs)); | 740 | 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); |
| 724 | 742 | ||
| 725 | *apqns = ctrs.apqns; | 743 | *apqns = ctrs.apqns; |
| 726 | *bound = ctrs.bound; | 744 | *bound = ctrs.bound; |
| @@ -781,7 +799,7 @@ EXPORT_SYMBOL(ap_wait_init_apqn_bindings_complete); · 54 unmodified lines | |||
| 781 | static int __ap_queue_devices_with_id_unregister(struct device *dev, void *data) | 799 | static int __ap_queue_devices_with_id_unregister(struct device *dev, void *data) |
| 782 | { | 800 | { |
| 783 | if (is_queue_dev(dev) && | 801 | 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) |
| 785 | device_unregister(dev); | 803 | device_unregister(dev); |
| 786 | return 0; | 804 | return 0; |
| 787 | } | 805 | } |
| @@ -794,8 +812,8 @@ static int __ap_revise_reserved(struct device *dev, void *dummy) · 6 unmodified lines | |||
| 794 | card = AP_QID_CARD(to_ap_queue(dev)->qid); | 812 | card = AP_QID_CARD(to_ap_queue(dev)->qid); |
| 795 | queue = AP_QID_QUEUE(to_ap_queue(dev)->qid); | 813 | queue = AP_QID_QUEUE(to_ap_queue(dev)->qid); |
| 796 | mutex_lock(&ap_perms_mutex); | 814 | mutex_lock(&ap_perms_mutex); |
| 797 | devres = test_bit_inv(card, ap_perms.apm) | 815 | devres = test_bit_inv(card, ap_perms.apm) && |
| 798 | && test_bit_inv(queue, ap_perms.aqm); | 816 | test_bit_inv(queue, ap_perms.aqm); |
| 799 | mutex_unlock(&ap_perms_mutex); | 817 | mutex_unlock(&ap_perms_mutex); |
| 800 | drvres = to_ap_drv(dev->driver)->flags | 818 | drvres = to_ap_drv(dev->driver)->flags |
| 801 | & AP_DRIVER_FLAG_DEFAULT; | 819 | & AP_DRIVER_FLAG_DEFAULT; |
| @@ -826,8 +844,8 @@ int ap_owned_by_def_drv(int card, int queue) · 24 unmodified lines | |||
| 826 | 844 | ||
| 827 | mutex_lock(&ap_perms_mutex); | 845 | mutex_lock(&ap_perms_mutex); |
| 828 | 846 | ||
| 829 | if (test_bit_inv(card, ap_perms.apm) | 847 | if (test_bit_inv(card, ap_perms.apm) && |
| 830 | && test_bit_inv(queue, ap_perms.aqm)) | 848 | test_bit_inv(queue, ap_perms.aqm)) |
| 831 | rc = 1; | 849 | rc = 1; |
| 832 | 850 | ||
| 833 | mutex_unlock(&ap_perms_mutex); | 851 | mutex_unlock(&ap_perms_mutex); |
| @@ -876,8 +894,8 @@ static int ap_device_probe(struct device *dev) · 42 unmodified lines | |||
| 876 | card = AP_QID_CARD(to_ap_queue(dev)->qid); | 894 | card = AP_QID_CARD(to_ap_queue(dev)->qid); |
| 877 | queue = AP_QID_QUEUE(to_ap_queue(dev)->qid); | 895 | queue = AP_QID_QUEUE(to_ap_queue(dev)->qid); |
| 878 | mutex_lock(&ap_perms_mutex); | 896 | mutex_lock(&ap_perms_mutex); |
| 879 | devres = test_bit_inv(card, ap_perms.apm) | 897 | devres = test_bit_inv(card, ap_perms.apm) && |
| 880 | && test_bit_inv(queue, ap_perms.aqm); | 898 | test_bit_inv(queue, ap_perms.aqm); |
| 881 | mutex_unlock(&ap_perms_mutex); | 899 | mutex_unlock(&ap_perms_mutex); |
| 882 | drvres = ap_drv->flags & AP_DRIVER_FLAG_DEFAULT; | 900 | drvres = ap_drv->flags & AP_DRIVER_FLAG_DEFAULT; |
| 883 | if (!!devres != !!drvres) | 901 | if (!!devres != !!drvres) |
| @@ -898,8 +916,9 @@ static int ap_device_probe(struct device *dev) · 14 unmodified lines | |||
| 898 | if (is_queue_dev(dev)) | 916 | if (is_queue_dev(dev)) |
| 899 | hash_del(&to_ap_queue(dev)->hnode); | 917 | hash_del(&to_ap_queue(dev)->hnode); |
| 900 | spin_unlock_bh(&ap_queues_lock); | 918 | spin_unlock_bh(&ap_queues_lock); |
| 901 | } else | 919 | } else { |
| 902 | ap_check_bindings_complete(); | 920 | ap_check_bindings_complete(); |
| 921 | } | ||
| 903 | 922 | ||
| 904 | out: | 923 | out: |
| 905 | if (rc) | 924 | if (rc) |
| @@ -980,8 +999,8 @@ void ap_bus_force_rescan(void) · 74 unmodified lines | |||
| 980 | EXPORT_SYMBOL(ap_bus_force_rescan); | 999 | EXPORT_SYMBOL(ap_bus_force_rescan); |
| 981 | 1000 | ||
| 982 | /* | 1001 | /* |
| 983 | * A config change has happened, force an ap bus rescan. | 1002 | * A config change has happened, force an ap bus rescan. |
| 984 | */ | 1003 | */ |
| 985 | void ap_bus_cfg_chg(void) | 1004 | void ap_bus_cfg_chg(void) |
| 986 | { | 1005 | { |
| 987 | AP_DBF_DBG("%s config change, forcing bus rescan\n", __func__); | 1006 | 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 | |||
| 1105 | if (bits & 0x07) | 1124 | if (bits & 0x07) |
| 1106 | return -EINVAL; | 1125 | return -EINVAL; |
| 1107 | 1126 | ||
| 1108 | size = BITS_TO_LONGS(bits)*sizeof(unsigned long); | 1127 | size = BITS_TO_LONGS(bits) * sizeof(unsigned long); |
| 1109 | newmap = kmalloc(size, GFP_KERNEL); | 1128 | newmap = kmalloc(size, GFP_KERNEL); |
| 1110 | if (!newmap) | 1129 | if (!newmap) |
| 1111 | return -ENOMEM; | 1130 | return -ENOMEM; |
| @@ -1241,8 +1260,9 @@ static ssize_t poll_thread_store(struct bus_type *bus, · 129 unmodified lines | |||
| 1241 | rc = ap_poll_thread_start(); | 1260 | rc = ap_poll_thread_start(); |
| 1242 | if (rc) | 1261 | if (rc) |
| 1243 | count = rc; | 1262 | count = rc; |
| 1244 | } else | 1263 | } else { |
| 1245 | ap_poll_thread_stop(); | 1264 | ap_poll_thread_stop(); |
| 1265 | } | ||
| 1246 | return count; | 1266 | return count; |
| 1247 | } | 1267 | } |
| 1248 | 1268 | ||
| @@ -1355,7 +1375,7 @@ static int apmask_commit(unsigned long *newapm) · 106 unmodified lines | |||
| 1355 | static ssize_t apmask_store(struct bus_type *bus, const char *buf, | 1375 | static ssize_t apmask_store(struct bus_type *bus, const char *buf, |
| 1356 | size_t count) | 1376 | size_t count) |
| 1357 | { | 1377 | { |
| 1358 | int rc; | 1378 | int rc, changes = 0; |
| 1359 | DECLARE_BITMAP(newapm, AP_DEVICES); | 1379 | DECLARE_BITMAP(newapm, AP_DEVICES); |
| 1360 | 1380 | ||
| 1361 | if (mutex_lock_interruptible(&ap_perms_mutex)) | 1381 | 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 | |||
| 1365 | if (rc) | 1385 | if (rc) |
| 1366 | goto done; | 1386 | goto done; |
| 1367 | 1387 | ||
| 1368 | rc = apmask_commit(newapm); | 1388 | changes = memcmp(ap_perms.apm, newapm, APMASKSIZE); |
| 1389 | if (changes) | ||
| 1390 | rc = apmask_commit(newapm); | ||
| 1369 | 1391 | ||
| 1370 | done: | 1392 | done: |
| 1371 | mutex_unlock(&ap_perms_mutex); | 1393 | mutex_unlock(&ap_perms_mutex); |
| 1372 | if (rc) | 1394 | if (rc) |
| 1373 | return rc; | 1395 | return rc; |
| 1374 | 1396 | ||
| 1375 | ap_bus_revise_bindings(); | 1397 | if (changes) { |
| 1398 | ap_bus_revise_bindings(); | ||
| 1399 | ap_send_mask_changed_uevent(newapm, NULL); | ||
| 1400 | } | ||
| 1376 | 1401 | ||
| 1377 | return count; | 1402 | return count; |
| 1378 | } | 1403 | } |
| @@ -1443,7 +1468,7 @@ static int aqmask_commit(unsigned long *newaqm) · 64 unmodified lines | |||
| 1443 | static ssize_t aqmask_store(struct bus_type *bus, const char *buf, | 1468 | static ssize_t aqmask_store(struct bus_type *bus, const char *buf, |
| 1444 | size_t count) | 1469 | size_t count) |
| 1445 | { | 1470 | { |
| 1446 | int rc; | 1471 | int rc, changes = 0; |
| 1447 | DECLARE_BITMAP(newaqm, AP_DOMAINS); | 1472 | DECLARE_BITMAP(newaqm, AP_DOMAINS); |
| 1448 | 1473 | ||
| 1449 | if (mutex_lock_interruptible(&ap_perms_mutex)) | 1474 | 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 | |||
| 1453 | if (rc) | 1478 | if (rc) |
| 1454 | goto done; | 1479 | goto done; |
| 1455 | 1480 | ||
| 1456 | rc = aqmask_commit(newaqm); | 1481 | changes = memcmp(ap_perms.aqm, newaqm, APMASKSIZE); |
| 1482 | if (changes) | ||
| 1483 | rc = aqmask_commit(newaqm); | ||
| 1457 | 1484 | ||
| 1458 | done: | 1485 | done: |
| 1459 | mutex_unlock(&ap_perms_mutex); | 1486 | mutex_unlock(&ap_perms_mutex); |
| 1460 | if (rc) | 1487 | if (rc) |
| 1461 | return rc; | 1488 | return rc; |
| 1462 | 1489 | ||
| 1463 | ap_bus_revise_bindings(); | 1490 | if (changes) { |
| 1491 | ap_bus_revise_bindings(); | ||
| 1492 | ap_send_mask_changed_uevent(NULL, newaqm); | ||
| 1493 | } | ||
| 1464 | 1494 | ||
| 1465 | return count; | 1495 | return count; |
| 1466 | } | 1496 | } |
| @@ -1605,9 +1635,9 @@ static int ap_get_compatible_type(ap_qid_t qid, int rawtype, unsigned int func) · 138 unmodified lines | |||
| 1605 | apinfo.mode = (func >> 26) & 0x07; | 1635 | apinfo.mode = (func >> 26) & 0x07; |
| 1606 | apinfo.cat = AP_DEVICE_TYPE_CEX8; | 1636 | apinfo.cat = AP_DEVICE_TYPE_CEX8; |
| 1607 | status = ap_qact(qid, 0, &apinfo); | 1637 | status = ap_qact(qid, 0, &apinfo); |
| 1608 | if (status.response_code == AP_RESPONSE_NORMAL | 1638 | if (status.response_code == AP_RESPONSE_NORMAL && |
| 1609 | && apinfo.cat >= AP_DEVICE_TYPE_CEX2A | 1639 | apinfo.cat >= AP_DEVICE_TYPE_CEX2A && |
| 1610 | && apinfo.cat <= AP_DEVICE_TYPE_CEX8) | 1640 | apinfo.cat <= AP_DEVICE_TYPE_CEX8) |
| 1611 | comp_type = apinfo.cat; | 1641 | comp_type = apinfo.cat; |
| 1612 | } | 1642 | } |
| 1613 | if (!comp_type) | 1643 | 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 | |||
| 1627 | */ | 1657 | */ |
| 1628 | static int __match_card_device_with_id(struct device *dev, const void *data) | 1658 | static int __match_card_device_with_id(struct device *dev, const void *data) |
| 1629 | { | 1659 | { |
| 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; |
| 1631 | } | 1661 | } |
| 1632 | 1662 | ||
| 1633 | /* | 1663 | /* |
| @@ -1636,7 +1666,7 @@ static int __match_card_device_with_id(struct device *dev, const void *data) · 2 unmodified lines | |||
| 1636 | */ | 1666 | */ |
| 1637 | static int __match_queue_device_with_qid(struct device *dev, const void *data) | 1667 | static int __match_queue_device_with_qid(struct device *dev, const void *data) |
| 1638 | { | 1668 | { |
| 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; |
| 1640 | } | 1670 | } |
| 1641 | 1671 | ||
| 1642 | /* | 1672 | /* |
| @@ -1645,8 +1675,8 @@ static int __match_queue_device_with_qid(struct device *dev, const void *data) · 2 unmodified lines | |||
| 1645 | */ | 1675 | */ |
| 1646 | static int __match_queue_device_with_queue_id(struct device *dev, const void *data) | 1676 | static int __match_queue_device_with_queue_id(struct device *dev, const void *data) |
| 1647 | { | 1677 | { |
| 1648 | return is_queue_dev(dev) | 1678 | return is_queue_dev(dev) && |
| 1649 | && AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long) data; | 1679 | AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long)data; |
| 1650 | } | 1680 | } |
| 1651 | 1681 | ||
| 1652 | /* Helper function for notify_config_changed */ | 1682 | /* Helper function for notify_config_changed */ |
| @@ -1699,7 +1729,7 @@ static inline void notify_scan_complete(void) · 46 unmodified lines | |||
| 1699 | static inline void ap_scan_rm_card_dev_and_queue_devs(struct ap_card *ac) | 1729 | static inline void ap_scan_rm_card_dev_and_queue_devs(struct ap_card *ac) |
| 1700 | { | 1730 | { |
| 1701 | bus_for_each_dev(&ap_bus_type, NULL, | 1731 | bus_for_each_dev(&ap_bus_type, NULL, |
| 1702 | (void *)(long) ac->id, | 1732 | (void *)(long)ac->id, |
| 1703 | __ap_queue_devices_with_id_unregister); | 1733 | __ap_queue_devices_with_id_unregister); |
| 1704 | device_unregister(&ac->ap_dev.device); | 1734 | device_unregister(&ac->ap_dev.device); |
| 1705 | } | 1735 | } |
| @@ -1727,7 +1757,7 @@ static inline void ap_scan_domains(struct ap_card *ac) · 21 unmodified lines | |||
| 1727 | for (dom = 0; dom <= ap_max_domain_id; dom++) { | 1757 | for (dom = 0; dom <= ap_max_domain_id; dom++) { |
| 1728 | qid = AP_MKQID(ac->id, dom); | 1758 | qid = AP_MKQID(ac->id, dom); |
| 1729 | dev = bus_find_device(&ap_bus_type, NULL, | 1759 | dev = bus_find_device(&ap_bus_type, NULL, |
| 1730 | (void *)(long) qid, | 1760 | (void *)(long)qid, |
| 1731 | __match_queue_device_with_qid); | 1761 | __match_queue_device_with_qid); |
| 1732 | aq = dev ? to_ap_queue(dev) : NULL; | 1762 | aq = dev ? to_ap_queue(dev) : NULL; |
| 1733 | if (!ap_test_config_usage_domain(dom)) { | 1763 | if (!ap_test_config_usage_domain(dom)) { |
| @@ -1873,7 +1903,7 @@ static inline void ap_scan_adapter(int ap) · 139 unmodified lines | |||
| 1873 | 1903 | ||
| 1874 | /* Is there currently a card device for this adapter ? */ | 1904 | /* Is there currently a card device for this adapter ? */ |
| 1875 | dev = bus_find_device(&ap_bus_type, NULL, | 1905 | dev = bus_find_device(&ap_bus_type, NULL, |
| 1876 | (void *)(long) ap, | 1906 | (void *)(long)ap, |
| 1877 | __match_card_device_with_id); | 1907 | __match_card_device_with_id); |
| 1878 | ac = dev ? to_ap_card(dev) : NULL; | 1908 | ac = dev ? to_ap_card(dev) : NULL; |
| 1879 | 1909 | ||
| @@ -2074,7 +2104,7 @@ static void ap_scan_bus(struct work_struct *unused) · 194 unmodified lines | |||
| 2074 | if (ap_domain_index >= 0) { | 2104 | if (ap_domain_index >= 0) { |
| 2075 | struct device *dev = | 2105 | struct device *dev = |
| 2076 | bus_find_device(&ap_bus_type, NULL, | 2106 | bus_find_device(&ap_bus_type, NULL, |
| 2077 | (void *)(long) ap_domain_index, | 2107 | (void *)(long)ap_domain_index, |
| 2078 | __match_queue_device_with_queue_id); | 2108 | __match_queue_device_with_queue_id); |
| 2079 | if (dev) | 2109 | if (dev) |
| 2080 | put_device(dev); | 2110 | put_device(dev); |
| @@ -2109,7 +2139,7 @@ static int __init ap_debug_init(void) · 28 unmodified lines | |||
| 2109 | 2139 | ||
| 2110 | static void __init ap_perms_init(void) | 2140 | static void __init ap_perms_init(void) |
| 2111 | { | 2141 | { |
| 2112 | /* all resources useable if no kernel parameter string given */ | 2142 | /* all resources usable if no kernel parameter string given */ |
| 2113 | memset(&ap_perms.ioctlm, 0xFF, sizeof(ap_perms.ioctlm)); | 2143 | memset(&ap_perms.ioctlm, 0xFF, sizeof(ap_perms.ioctlm)); |
| 2114 | memset(&ap_perms.apm, 0xFF, sizeof(ap_perms.apm)); | 2144 | memset(&ap_perms.apm, 0xFF, sizeof(ap_perms.apm)); |
| 2115 | memset(&ap_perms.aqm, 0xFF, sizeof(ap_perms.aqm)); | 2145 | memset(&ap_perms.aqm, 0xFF, sizeof(ap_perms.aqm)); |
| @@ -317,6 +317,7 @@ struct ap_perms { · 316 unmodified lines | |||
| 317 | unsigned long aqm[BITS_TO_LONGS(AP_DOMAINS)]; | 317 | unsigned long aqm[BITS_TO_LONGS(AP_DOMAINS)]; |
| 318 | unsigned long adm[BITS_TO_LONGS(AP_DOMAINS)]; | 318 | unsigned long adm[BITS_TO_LONGS(AP_DOMAINS)]; |
| 319 | }; | 319 | }; |
| 320 | |||
| 320 | extern struct ap_perms ap_perms; | 321 | extern struct ap_perms ap_perms; |
| 321 | extern struct mutex ap_perms_mutex; | 322 | extern struct mutex ap_perms_mutex; |
| 322 | 323 | ||
| @@ -99,7 +99,7 @@ int ap_recv(ap_qid_t qid, unsigned long long *psmid, void *msg, size_t length) · 98 unmodified lines | |||
| 99 | { | 99 | { |
| 100 | struct ap_queue_status status; | 100 | struct ap_queue_status status; |
| 101 | 101 | ||
| 102 | if (msg == NULL) | 102 | if (!msg) |
| 103 | return -EINVAL; | 103 | return -EINVAL; |
| 104 | status = ap_dqap(qid, psmid, msg, length, NULL, NULL); | 104 | status = ap_dqap(qid, psmid, msg, length, NULL, NULL); |
| 105 | switch (status.response_code) { | 105 | switch (status.response_code) { |
| @@ -603,7 +603,7 @@ static ssize_t interrupt_show(struct device *dev, · 497 unmodified lines | |||
| 603 | static DEVICE_ATTR_RO(interrupt); | 603 | static DEVICE_ATTR_RO(interrupt); |
| 604 | 604 | ||
| 605 | static ssize_t config_show(struct device *dev, | 605 | static ssize_t config_show(struct device *dev, |
| 606 | struct device_attribute *attr, char *buf) | 606 | struct device_attribute *attr, char *buf) |
| 607 | { | 607 | { |
| 608 | struct ap_queue *aq = to_ap_queue(dev); | 608 | struct ap_queue *aq = to_ap_queue(dev); |
| 609 | int rc; | 609 | int rc; |
| @@ -827,8 +827,9 @@ int ap_queue_message(struct ap_queue *aq, struct ap_message *ap_msg) · 217 unmodified lines | |||
| 827 | aq->requestq_count++; | 827 | aq->requestq_count++; |
| 828 | aq->total_request_count++; | 828 | aq->total_request_count++; |
| 829 | atomic64_inc(&aq->card->total_request_count); | 829 | atomic64_inc(&aq->card->total_request_count); |
| 830 | } else | 830 | } else { |
| 831 | rc = -ENODEV; | 831 | rc = -ENODEV; |
| 832 | } | ||
| 832 | 833 | ||
| 833 | /* Send/receive as many request from the queue as possible. */ | 834 | /* Send/receive as many request from the queue as possible. */ |
| 834 | ap_wait(ap_sm_event_loop(aq, AP_SM_EVENT_POLL)); | 835 | ap_wait(ap_sm_event_loop(aq, AP_SM_EVENT_POLL)); |
| @@ -232,7 +232,7 @@ static int pkey_ep11key2pkey(const u8 *key, struct pkey_protkey *pkey) · 231 unmodified lines | |||
| 232 | int i, rc; | 232 | int i, rc; |
| 233 | u16 card, dom; | 233 | u16 card, dom; |
| 234 | u32 nr_apqns, *apqns = NULL; | 234 | u32 nr_apqns, *apqns = NULL; |
| 235 | struct ep11keyblob *kb = (struct ep11keyblob *) key; | 235 | struct ep11keyblob *kb = (struct ep11keyblob *)key; |
| 236 | 236 | ||
| 237 | zcrypt_wait_api_operational(); | 237 | zcrypt_wait_api_operational(); |
| 238 | 238 | ||
| @@ -267,12 +267,12 @@ static int pkey_verifykey(const struct pkey_seckey *seckey, · 28 unmodified lines | |||
| 267 | u16 *pcardnr, u16 *pdomain, | 267 | u16 *pcardnr, u16 *pdomain, |
| 268 | u16 *pkeysize, u32 *pattributes) | 268 | u16 *pkeysize, u32 *pattributes) |
| 269 | { | 269 | { |
| 270 | struct secaeskeytoken *t = (struct secaeskeytoken *) seckey; | 270 | struct secaeskeytoken *t = (struct secaeskeytoken *)seckey; |
| 271 | u16 cardnr, domain; | 271 | u16 cardnr, domain; |
| 272 | int rc; | 272 | int rc; |
| 273 | 273 | ||
| 274 | /* check the secure key for valid AES secure key */ | 274 | /* 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); |
| 276 | if (rc) | 276 | if (rc) |
| 277 | goto out; | 277 | goto out; |
| 278 | if (pattributes) | 278 | if (pattributes) |
| @@ -425,9 +425,9 @@ static int pkey_nonccatok2pkey(const u8 *key, u32 keylen, · 146 unmodified lines | |||
| 425 | t = (struct clearaeskeytoken *)key; | 425 | t = (struct clearaeskeytoken *)key; |
| 426 | if (keylen != sizeof(*t) + t->len) | 426 | if (keylen != sizeof(*t) + t->len) |
| 427 | goto out; | 427 | goto out; |
| 428 | if ((t->keytype == PKEY_KEYTYPE_AES_128 && t->len == 16) | 428 | if ((t->keytype == PKEY_KEYTYPE_AES_128 && t->len == 16) || |
| 429 | || (t->keytype == PKEY_KEYTYPE_AES_192 && t->len == 24) | 429 | (t->keytype == PKEY_KEYTYPE_AES_192 && t->len == 24) || |
| 430 | || (t->keytype == PKEY_KEYTYPE_AES_256 && t->len == 32)) | 430 | (t->keytype == PKEY_KEYTYPE_AES_256 && t->len == 32)) |
| 431 | memcpy(ckey.clrkey, t->clearkey, t->len); | 431 | memcpy(ckey.clrkey, t->clearkey, t->len); |
| 432 | else | 432 | else |
| 433 | goto out; | 433 | goto out; |
| @@ -541,7 +541,6 @@ int pkey_keyblob2pkey(const u8 *key, u32 keylen, · 107 unmodified lines | |||
| 541 | 541 | ||
| 542 | DEBUG_DBG("%s rc=%d\n", __func__, rc); | 542 | DEBUG_DBG("%s rc=%d\n", __func__, rc); |
| 543 | return rc; | 543 | return rc; |
| 544 | |||
| 545 | } | 544 | } |
| 546 | EXPORT_SYMBOL(pkey_keyblob2pkey); | 545 | EXPORT_SYMBOL(pkey_keyblob2pkey); |
| 547 | 546 | ||
| @@ -588,9 +587,11 @@ static int pkey_genseckey2(const struct pkey_apqn *apqns, size_t nr_apqns, · 40 unmodified lines | |||
| 588 | } else if (ktype == PKEY_TYPE_CCA_DATA) { | 587 | } else if (ktype == PKEY_TYPE_CCA_DATA) { |
| 589 | rc = cca_genseckey(card, dom, ksize, keybuf); | 588 | rc = cca_genseckey(card, dom, ksize, keybuf); |
| 590 | *keybufsize = (rc ? 0 : SECKEYBLOBSIZE); | 589 | *keybufsize = (rc ? 0 : SECKEYBLOBSIZE); |
| 591 | } else /* TOKVER_CCA_VLSC */ | 590 | } else { |
| 591 | /* TOKVER_CCA_VLSC */ | ||
| 592 | rc = cca_gencipherkey(card, dom, ksize, kflags, | 592 | rc = cca_gencipherkey(card, dom, ksize, kflags, |
| 593 | keybuf, keybufsize); | 593 | keybuf, keybufsize); |
| 594 | } | ||
| 594 | if (rc == 0) | 595 | if (rc == 0) |
| 595 | break; | 596 | break; |
| 596 | } | 597 | } |
| @@ -645,9 +646,11 @@ static int pkey_clr2seckey2(const struct pkey_apqn *apqns, size_t nr_apqns, · 48 unmodified lines | |||
| 645 | rc = cca_clr2seckey(card, dom, ksize, | 646 | rc = cca_clr2seckey(card, dom, ksize, |
| 646 | clrkey, keybuf); | 647 | clrkey, keybuf); |
| 647 | *keybufsize = (rc ? 0 : SECKEYBLOBSIZE); | 648 | *keybufsize = (rc ? 0 : SECKEYBLOBSIZE); |
| 648 | } else /* TOKVER_CCA_VLSC */ | 649 | } else { |
| 650 | /* TOKVER_CCA_VLSC */ | ||
| 649 | rc = cca_clr2cipherkey(card, dom, ksize, kflags, | 651 | rc = cca_clr2cipherkey(card, dom, ksize, kflags, |
| 650 | clrkey, keybuf, keybufsize); | 652 | clrkey, keybuf, keybufsize); |
| 653 | } | ||
| 651 | if (rc == 0) | 654 | if (rc == 0) |
| 652 | break; | 655 | break; |
| 653 | } | 656 | } |
| @@ -667,8 +670,8 @@ static int pkey_verifykey2(const u8 *key, size_t keylen, · 13 unmodified lines | |||
| 667 | if (keylen < sizeof(struct keytoken_header)) | 670 | if (keylen < sizeof(struct keytoken_header)) |
| 668 | return -EINVAL; | 671 | return -EINVAL; |
| 669 | 672 | ||
| 670 | if (hdr->type == TOKTYPE_CCA_INTERNAL | 673 | if (hdr->type == TOKTYPE_CCA_INTERNAL && |
| 671 | && hdr->version == TOKVER_CCA_AES) { | 674 | hdr->version == TOKVER_CCA_AES) { |
| 672 | struct secaeskeytoken *t = (struct secaeskeytoken *)key; | 675 | struct secaeskeytoken *t = (struct secaeskeytoken *)key; |
| 673 | 676 | ||
| 674 | rc = cca_check_secaeskeytoken(debug_info, 3, key, 0); | 677 | 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 | |||
| 677 | if (ktype) | 680 | if (ktype) |
| 678 | *ktype = PKEY_TYPE_CCA_DATA; | 681 | *ktype = PKEY_TYPE_CCA_DATA; |
| 679 | if (ksize) | 682 | if (ksize) |
| 680 | *ksize = (enum pkey_key_size) t->bitsize; | 683 | *ksize = (enum pkey_key_size)t->bitsize; |
| 681 | 684 | ||
| 682 | rc = cca_findcard2(&_apqns, &_nr_apqns, *cardnr, *domain, | 685 | rc = cca_findcard2(&_apqns, &_nr_apqns, *cardnr, *domain, |
| 683 | ZCRYPT_CEX3C, AES_MK_SET, t->mkvp, 0, 1); | 686 | 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 | |||
| 697 | *cardnr = ((struct pkey_apqn *)_apqns)->card; | 700 | *cardnr = ((struct pkey_apqn *)_apqns)->card; |
| 698 | *domain = ((struct pkey_apqn *)_apqns)->domain; | 701 | *domain = ((struct pkey_apqn *)_apqns)->domain; |
| 699 | 702 | ||
| 700 | } else if (hdr->type == TOKTYPE_CCA_INTERNAL | 703 | } else if (hdr->type == TOKTYPE_CCA_INTERNAL && |
| 701 | && hdr->version == TOKVER_CCA_VLSC) { | 704 | hdr->version == TOKVER_CCA_VLSC) { |
| 702 | struct cipherkeytoken *t = (struct cipherkeytoken *)key; | 705 | struct cipherkeytoken *t = (struct cipherkeytoken *)key; |
| 703 | 706 | ||
| 704 | rc = cca_check_secaescipherkey(debug_info, 3, key, 0, 1); | 707 | 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 | |||
| 734 | *cardnr = ((struct pkey_apqn *)_apqns)->card; | 737 | *cardnr = ((struct pkey_apqn *)_apqns)->card; |
| 735 | *domain = ((struct pkey_apqn *)_apqns)->domain; | 738 | *domain = ((struct pkey_apqn *)_apqns)->domain; |
| 736 | 739 | ||
| 737 | } else if (hdr->type == TOKTYPE_NON_CCA | 740 | } else if (hdr->type == TOKTYPE_NON_CCA && |
| 738 | && hdr->version == TOKVER_EP11_AES) { | 741 | hdr->version == TOKVER_EP11_AES) { |
| 739 | struct ep11keyblob *kb = (struct ep11keyblob *)key; | 742 | struct ep11keyblob *kb = (struct ep11keyblob *)key; |
| 740 | 743 | ||
| 741 | rc = ep11_check_aes_key(debug_info, 3, key, keylen, 1); | 744 | 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 | |||
| 757 | *cardnr = ((struct pkey_apqn *)_apqns)->card; | 760 | *cardnr = ((struct pkey_apqn *)_apqns)->card; |
| 758 | *domain = ((struct pkey_apqn *)_apqns)->domain; | 761 | *domain = ((struct pkey_apqn *)_apqns)->domain; |
| 759 | 762 | ||
| 760 | } else | 763 | } else { |
| 761 | rc = -EINVAL; | 764 | rc = -EINVAL; |
| 765 | } | ||
| 762 | 766 | ||
| 763 | out: | 767 | out: |
| 764 | kfree(_apqns); | 768 | kfree(_apqns); |
| @@ -816,16 +820,17 @@ static int pkey_keyblob2pkey2(const struct pkey_apqn *apqns, size_t nr_apqns, · 51 unmodified lines | |||
| 816 | for (i = 0, rc = -ENODEV; i < nr_apqns; i++) { | 820 | for (i = 0, rc = -ENODEV; i < nr_apqns; i++) { |
| 817 | card = apqns[i].card; | 821 | card = apqns[i].card; |
| 818 | dom = apqns[i].domain; | 822 | dom = apqns[i].domain; |
| 819 | if (hdr->type == TOKTYPE_CCA_INTERNAL | 823 | if (hdr->type == TOKTYPE_CCA_INTERNAL && |
| 820 | && hdr->version == TOKVER_CCA_AES) | 824 | hdr->version == TOKVER_CCA_AES) { |
| 821 | rc = cca_sec2protkey(card, dom, key, pkey->protkey, | 825 | rc = cca_sec2protkey(card, dom, key, pkey->protkey, |
| 822 | &pkey->len, &pkey->type); | 826 | &pkey->len, &pkey->type); |
| 823 | else if (hdr->type == TOKTYPE_CCA_INTERNAL | 827 | } else if (hdr->type == TOKTYPE_CCA_INTERNAL && |
| 824 | && hdr->version == TOKVER_CCA_VLSC) | 828 | hdr->version == TOKVER_CCA_VLSC) { |
| 825 | rc = cca_cipher2protkey(card, dom, key, pkey->protkey, | 829 | rc = cca_cipher2protkey(card, dom, key, pkey->protkey, |
| 826 | &pkey->len, &pkey->type); | 830 | &pkey->len, &pkey->type); |
| 827 | else { /* EP11 AES secure key blob */ | 831 | } else { |
| 828 | struct ep11keyblob *kb = (struct ep11keyblob *) key; | 832 | /* EP11 AES secure key blob */ |
| 833 | struct ep11keyblob *kb = (struct ep11keyblob *)key; | ||
| 829 | 834 | ||
| 830 | pkey->len = sizeof(pkey->protkey); | 835 | pkey->len = sizeof(pkey->protkey); |
| 831 | rc = ep11_kblob2protkey(card, dom, key, kb->head.len, | 836 | 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 | |||
| 851 | 856 | ||
| 852 | zcrypt_wait_api_operational(); | 857 | zcrypt_wait_api_operational(); |
| 853 | 858 | ||
| 854 | if (hdr->type == TOKTYPE_NON_CCA | 859 | if (hdr->type == TOKTYPE_NON_CCA && |
| 855 | && (hdr->version == TOKVER_EP11_AES_WITH_HEADER | 860 | (hdr->version == TOKVER_EP11_AES_WITH_HEADER || |
| 856 | || hdr->version == TOKVER_EP11_ECC_WITH_HEADER) | 861 | hdr->version == TOKVER_EP11_ECC_WITH_HEADER) && |
| 857 | && is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) { | 862 | is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) { |
| 858 | int minhwtype = 0, api = 0; | 863 | int minhwtype = 0, api = 0; |
| 859 | struct ep11keyblob *kb = (struct ep11keyblob *) | 864 | struct ep11keyblob *kb = (struct ep11keyblob *) |
| 860 | (key + sizeof(struct ep11kblob_header)); | 865 | (key + sizeof(struct ep11kblob_header)); |
| @@ -869,11 +874,11 @@ static int pkey_apqns4key(const u8 *key, size_t keylen, u32 flags, · 8 unmodified lines | |||
| 869 | minhwtype, api, kb->wkvp); | 874 | minhwtype, api, kb->wkvp); |
| 870 | if (rc) | 875 | if (rc) |
| 871 | goto out; | 876 | goto out; |
| 872 | } else if (hdr->type == TOKTYPE_NON_CCA | 877 | } else if (hdr->type == TOKTYPE_NON_CCA && |
| 873 | && hdr->version == TOKVER_EP11_AES | 878 | hdr->version == TOKVER_EP11_AES && |
| 874 | && is_ep11_keyblob(key)) { | 879 | is_ep11_keyblob(key)) { |
| 875 | int minhwtype = 0, api = 0; | 880 | int minhwtype = 0, api = 0; |
| 876 | struct ep11keyblob *kb = (struct ep11keyblob *) key; | 881 | struct ep11keyblob *kb = (struct ep11keyblob *)key; |
| 877 | 882 | ||
| 878 | if (flags != PKEY_FLAGS_MATCH_CUR_MKVP) | 883 | if (flags != PKEY_FLAGS_MATCH_CUR_MKVP) |
| 879 | return -EINVAL; | 884 | return -EINVAL; |
| @@ -931,8 +936,9 @@ static int pkey_apqns4key(const u8 *key, size_t keylen, u32 flags, · 51 unmodified lines | |||
| 931 | cur_mkvp, old_mkvp, 1); | 936 | cur_mkvp, old_mkvp, 1); |
| 932 | if (rc) | 937 | if (rc) |
| 933 | goto out; | 938 | goto out; |
| 934 | } else | 939 | } else { |
| 935 | return -EINVAL; | 940 | return -EINVAL; |
| 941 | } | ||
| 936 | 942 | ||
| 937 | if (apqns) { | 943 | if (apqns) { |
| 938 | if (*nr_apqns < _nr_apqns) | 944 | if (*nr_apqns < _nr_apqns) |
| @@ -961,9 +967,9 @@ static int pkey_apqns4keytype(enum pkey_key_type ktype, · 22 unmodified lines | |||
| 961 | int minhwtype = ZCRYPT_CEX3C; | 967 | int minhwtype = ZCRYPT_CEX3C; |
| 962 | 968 | ||
| 963 | if (flags & PKEY_FLAGS_MATCH_CUR_MKVP) | 969 | if (flags & PKEY_FLAGS_MATCH_CUR_MKVP) |
| 964 | cur_mkvp = *((u64 *) cur_mkvp); | 970 | cur_mkvp = *((u64 *)cur_mkvp); |
| 965 | if (flags & PKEY_FLAGS_MATCH_ALT_MKVP) | 971 | if (flags & PKEY_FLAGS_MATCH_ALT_MKVP) |
| 966 | old_mkvp = *((u64 *) alt_mkvp); | 972 | old_mkvp = *((u64 *)alt_mkvp); |
| 967 | if (ktype == PKEY_TYPE_CCA_CIPHER) | 973 | if (ktype == PKEY_TYPE_CCA_CIPHER) |
| 968 | minhwtype = ZCRYPT_CEX6; | 974 | minhwtype = ZCRYPT_CEX6; |
| 969 | rc = cca_findcard2(&_apqns, &_nr_apqns, 0xFFFF, 0xFFFF, | 975 | rc = cca_findcard2(&_apqns, &_nr_apqns, 0xFFFF, 0xFFFF, |
| @@ -975,9 +981,9 @@ static int pkey_apqns4keytype(enum pkey_key_type ktype, · 5 unmodified lines | |||
| 975 | u64 cur_mkvp = 0, old_mkvp = 0; | 981 | u64 cur_mkvp = 0, old_mkvp = 0; |
| 976 | 982 | ||
| 977 | if (flags & PKEY_FLAGS_MATCH_CUR_MKVP) | 983 | if (flags & PKEY_FLAGS_MATCH_CUR_MKVP) |
| 978 | cur_mkvp = *((u64 *) cur_mkvp); | 984 | cur_mkvp = *((u64 *)cur_mkvp); |
| 979 | if (flags & PKEY_FLAGS_MATCH_ALT_MKVP) | 985 | if (flags & PKEY_FLAGS_MATCH_ALT_MKVP) |
| 980 | old_mkvp = *((u64 *) alt_mkvp); | 986 | old_mkvp = *((u64 *)alt_mkvp); |
| 981 | rc = cca_findcard2(&_apqns, &_nr_apqns, 0xFFFF, 0xFFFF, | 987 | rc = cca_findcard2(&_apqns, &_nr_apqns, 0xFFFF, 0xFFFF, |
| 982 | ZCRYPT_CEX7, APKA_MK_SET, | 988 | ZCRYPT_CEX7, APKA_MK_SET, |
| 983 | cur_mkvp, old_mkvp, 1); | 989 | cur_mkvp, old_mkvp, 1); |
| @@ -996,8 +1002,9 @@ static int pkey_apqns4keytype(enum pkey_key_type ktype, · 12 unmodified lines | |||
| 996 | if (rc) | 1002 | if (rc) |
| 997 | goto out; | 1003 | goto out; |
| 998 | 1004 | ||
| 999 | } else | 1005 | } else { |
| 1000 | return -EINVAL; | 1006 | return -EINVAL; |
| 1007 | } | ||
| 1001 | 1008 | ||
| 1002 | if (apqns) { | 1009 | if (apqns) { |
| 1003 | if (*nr_apqns < _nr_apqns) | 1010 | 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 | |||
| 1026 | if (keylen < sizeof(struct keytoken_header)) | 1033 | if (keylen < sizeof(struct keytoken_header)) |
| 1027 | return -EINVAL; | 1034 | return -EINVAL; |
| 1028 | 1035 | ||
| 1029 | if (hdr->type == TOKTYPE_NON_CCA | 1036 | if (hdr->type == TOKTYPE_NON_CCA && |
| 1030 | && hdr->version == TOKVER_EP11_AES_WITH_HEADER | 1037 | hdr->version == TOKVER_EP11_AES_WITH_HEADER && |
| 1031 | && is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) { | 1038 | is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) { |
| 1032 | /* EP11 AES key blob with header */ | 1039 | /* EP11 AES key blob with header */ |
| 1033 | if (ep11_check_aes_key_with_hdr(debug_info, 3, key, keylen, 1)) | 1040 | if (ep11_check_aes_key_with_hdr(debug_info, 3, key, keylen, 1)) |
| 1034 | return -EINVAL; | 1041 | return -EINVAL; |
| 1035 | } else if (hdr->type == TOKTYPE_NON_CCA | 1042 | } else if (hdr->type == TOKTYPE_NON_CCA && |
| 1036 | && hdr->version == TOKVER_EP11_ECC_WITH_HEADER | 1043 | hdr->version == TOKVER_EP11_ECC_WITH_HEADER && |
| 1037 | && is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) { | 1044 | is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) { |
| 1038 | /* EP11 ECC key blob with header */ | 1045 | /* EP11 ECC key blob with header */ |
| 1039 | if (ep11_check_ecc_key_with_hdr(debug_info, 3, key, keylen, 1)) | 1046 | if (ep11_check_ecc_key_with_hdr(debug_info, 3, key, keylen, 1)) |
| 1040 | return -EINVAL; | 1047 | return -EINVAL; |
| 1041 | } else if (hdr->type == TOKTYPE_NON_CCA | 1048 | } else if (hdr->type == TOKTYPE_NON_CCA && |
| 1042 | && hdr->version == TOKVER_EP11_AES | 1049 | hdr->version == TOKVER_EP11_AES && |
| 1043 | && is_ep11_keyblob(key)) { | 1050 | is_ep11_keyblob(key)) { |
| 1044 | /* EP11 AES key blob with header in session field */ | 1051 | /* EP11 AES key blob with header in session field */ |
| 1045 | if (ep11_check_aes_key(debug_info, 3, key, keylen, 1)) | 1052 | if (ep11_check_aes_key(debug_info, 3, key, keylen, 1)) |
| 1046 | return -EINVAL; | 1053 | return -EINVAL; |
| @@ -1088,15 +1095,15 @@ static int pkey_keyblob2pkey3(const struct pkey_apqn *apqns, size_t nr_apqns, · 41 unmodified lines | |||
| 1088 | for (rc = -ENODEV, i = 0; rc && i < nr_apqns; i++) { | 1095 | for (rc = -ENODEV, i = 0; rc && i < nr_apqns; i++) { |
| 1089 | card = apqns[i].card; | 1096 | card = apqns[i].card; |
| 1090 | dom = apqns[i].domain; | 1097 | dom = apqns[i].domain; |
| 1091 | if (hdr->type == TOKTYPE_NON_CCA | 1098 | if (hdr->type == TOKTYPE_NON_CCA && |
| 1092 | && (hdr->version == TOKVER_EP11_AES_WITH_HEADER | 1099 | (hdr->version == TOKVER_EP11_AES_WITH_HEADER || |
| 1093 | || hdr->version == TOKVER_EP11_ECC_WITH_HEADER) | 1100 | hdr->version == TOKVER_EP11_ECC_WITH_HEADER) && |
| 1094 | && is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) | 1101 | is_ep11_keyblob(key + sizeof(struct ep11kblob_header))) |
| 1095 | rc = ep11_kblob2protkey(card, dom, key, hdr->len, | 1102 | rc = ep11_kblob2protkey(card, dom, key, hdr->len, |
| 1096 | protkey, protkeylen, protkeytype); | 1103 | protkey, protkeylen, protkeytype); |
| 1097 | else if (hdr->type == TOKTYPE_NON_CCA | 1104 | else if (hdr->type == TOKTYPE_NON_CCA && |
| 1098 | && hdr->version == TOKVER_EP11_AES | 1105 | hdr->version == TOKVER_EP11_AES && |
| 1099 | && is_ep11_keyblob(key)) | 1106 | is_ep11_keyblob(key)) |
| 1100 | rc = ep11_kblob2protkey(card, dom, key, hdr->len, | 1107 | rc = ep11_kblob2protkey(card, dom, key, hdr->len, |
| 1101 | protkey, protkeylen, protkeytype); | 1108 | protkey, protkeylen, protkeytype); |
| 1102 | else if (hdr->type == TOKTYPE_CCA_INTERNAL && | 1109 | 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 | |||
| 1144 | 1151 | ||
| 1145 | switch (cmd) { | 1152 | switch (cmd) { |
| 1146 | case PKEY_GENSECK: { | 1153 | case PKEY_GENSECK: { |
| 1147 | struct pkey_genseck __user *ugs = (void __user *) arg; | 1154 | struct pkey_genseck __user *ugs = (void __user *)arg; |
| 1148 | struct pkey_genseck kgs; | 1155 | struct pkey_genseck kgs; |
| 1149 | 1156 | ||
| 1150 | if (copy_from_user(&kgs, ugs, sizeof(kgs))) | 1157 | 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 | |||
| 1159 | break; | 1166 | break; |
| 1160 | } | 1167 | } |
| 1161 | case PKEY_CLR2SECK: { | 1168 | case PKEY_CLR2SECK: { |
| 1162 | struct pkey_clr2seck __user *ucs = (void __user *) arg; | 1169 | struct pkey_clr2seck __user *ucs = (void __user *)arg; |
| 1163 | struct pkey_clr2seck kcs; | 1170 | struct pkey_clr2seck kcs; |
| 1164 | 1171 | ||
| 1165 | if (copy_from_user(&kcs, ucs, sizeof(kcs))) | 1172 | 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 | |||
| 1175 | break; | 1182 | break; |
| 1176 | } | 1183 | } |
| 1177 | case PKEY_SEC2PROTK: { | 1184 | case PKEY_SEC2PROTK: { |
| 1178 | struct pkey_sec2protk __user *usp = (void __user *) arg; | 1185 | struct pkey_sec2protk __user *usp = (void __user *)arg; |
| 1179 | struct pkey_sec2protk ksp; | 1186 | struct pkey_sec2protk ksp; |
| 1180 | 1187 | ||
| 1181 | if (copy_from_user(&ksp, usp, sizeof(ksp))) | 1188 | 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 | |||
| 1191 | break; | 1198 | break; |
| 1192 | } | 1199 | } |
| 1193 | case PKEY_CLR2PROTK: { | 1200 | case PKEY_CLR2PROTK: { |
| 1194 | struct pkey_clr2protk __user *ucp = (void __user *) arg; | 1201 | struct pkey_clr2protk __user *ucp = (void __user *)arg; |
| 1195 | struct pkey_clr2protk kcp; | 1202 | struct pkey_clr2protk kcp; |
| 1196 | 1203 | ||
| 1197 | if (copy_from_user(&kcp, ucp, sizeof(kcp))) | 1204 | 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 | |||
| 1207 | break; | 1214 | break; |
| 1208 | } | 1215 | } |
| 1209 | case PKEY_FINDCARD: { | 1216 | case PKEY_FINDCARD: { |
| 1210 | struct pkey_findcard __user *ufc = (void __user *) arg; | 1217 | struct pkey_findcard __user *ufc = (void __user *)arg; |
| 1211 | struct pkey_findcard kfc; | 1218 | struct pkey_findcard kfc; |
| 1212 | 1219 | ||
| 1213 | if (copy_from_user(&kfc, ufc, sizeof(kfc))) | 1220 | 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 | |||
| 1222 | break; | 1229 | break; |
| 1223 | } | 1230 | } |
| 1224 | case PKEY_SKEY2PKEY: { | 1231 | case PKEY_SKEY2PKEY: { |
| 1225 | struct pkey_skey2pkey __user *usp = (void __user *) arg; | 1232 | struct pkey_skey2pkey __user *usp = (void __user *)arg; |
| 1226 | struct pkey_skey2pkey ksp; | 1233 | struct pkey_skey2pkey ksp; |
| 1227 | 1234 | ||
| 1228 | if (copy_from_user(&ksp, usp, sizeof(ksp))) | 1235 | 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 | |||
| 1236 | break; | 1243 | break; |
| 1237 | } | 1244 | } |
| 1238 | case PKEY_VERIFYKEY: { | 1245 | case PKEY_VERIFYKEY: { |
| 1239 | struct pkey_verifykey __user *uvk = (void __user *) arg; | 1246 | struct pkey_verifykey __user *uvk = (void __user *)arg; |
| 1240 | struct pkey_verifykey kvk; | 1247 | struct pkey_verifykey kvk; |
| 1241 | 1248 | ||
| 1242 | if (copy_from_user(&kvk, uvk, sizeof(kvk))) | 1249 | 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 | |||
| 1251 | break; | 1258 | break; |
| 1252 | } | 1259 | } |
| 1253 | case PKEY_GENPROTK: { | 1260 | case PKEY_GENPROTK: { |
| 1254 | struct pkey_genprotk __user *ugp = (void __user *) arg; | 1261 | struct pkey_genprotk __user *ugp = (void __user *)arg; |
| 1255 | struct pkey_genprotk kgp; | 1262 | struct pkey_genprotk kgp; |
| 1256 | 1263 | ||
| 1257 | if (copy_from_user(&kgp, ugp, sizeof(kgp))) | 1264 | 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 | |||
| 1265 | break; | 1272 | break; |
| 1266 | } | 1273 | } |
| 1267 | case PKEY_VERIFYPROTK: { | 1274 | case PKEY_VERIFYPROTK: { |
| 1268 | struct pkey_verifyprotk __user *uvp = (void __user *) arg; | 1275 | struct pkey_verifyprotk __user *uvp = (void __user *)arg; |
| 1269 | struct pkey_verifyprotk kvp; | 1276 | struct pkey_verifyprotk kvp; |
| 1270 | 1277 | ||
| 1271 | if (copy_from_user(&kvp, uvp, sizeof(kvp))) | 1278 | 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 | |||
| 1275 | break; | 1282 | break; |
| 1276 | } | 1283 | } |
| 1277 | case PKEY_KBLOB2PROTK: { | 1284 | case PKEY_KBLOB2PROTK: { |
| 1278 | struct pkey_kblob2pkey __user *utp = (void __user *) arg; | 1285 | struct pkey_kblob2pkey __user *utp = (void __user *)arg; |
| 1279 | struct pkey_kblob2pkey ktp; | 1286 | struct pkey_kblob2pkey ktp; |
| 1280 | u8 *kkey; | 1287 | u8 *kkey; |
| 1281 | 1288 | ||
| @@ -1294,7 +1301,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 12 unmodified lines | |||
| 1294 | break; | 1301 | break; |
| 1295 | } | 1302 | } |
| 1296 | case PKEY_GENSECK2: { | 1303 | case PKEY_GENSECK2: { |
| 1297 | struct pkey_genseck2 __user *ugs = (void __user *) arg; | 1304 | struct pkey_genseck2 __user *ugs = (void __user *)arg; |
| 1298 | struct pkey_genseck2 kgs; | 1305 | struct pkey_genseck2 kgs; |
| 1299 | struct pkey_apqn *apqns; | 1306 | struct pkey_apqn *apqns; |
| 1300 | size_t klen = KEYBLOBBUFSIZE; | 1307 | size_t klen = KEYBLOBBUFSIZE; |
| @@ -1336,7 +1343,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 35 unmodified lines | |||
| 1336 | break; | 1343 | break; |
| 1337 | } | 1344 | } |
| 1338 | case PKEY_CLR2SECK2: { | 1345 | case PKEY_CLR2SECK2: { |
| 1339 | struct pkey_clr2seck2 __user *ucs = (void __user *) arg; | 1346 | struct pkey_clr2seck2 __user *ucs = (void __user *)arg; |
| 1340 | struct pkey_clr2seck2 kcs; | 1347 | struct pkey_clr2seck2 kcs; |
| 1341 | struct pkey_apqn *apqns; | 1348 | struct pkey_apqn *apqns; |
| 1342 | size_t klen = KEYBLOBBUFSIZE; | 1349 | size_t klen = KEYBLOBBUFSIZE; |
| @@ -1379,7 +1386,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 36 unmodified lines | |||
| 1379 | break; | 1386 | break; |
| 1380 | } | 1387 | } |
| 1381 | case PKEY_VERIFYKEY2: { | 1388 | case PKEY_VERIFYKEY2: { |
| 1382 | struct pkey_verifykey2 __user *uvk = (void __user *) arg; | 1389 | struct pkey_verifykey2 __user *uvk = (void __user *)arg; |
| 1383 | struct pkey_verifykey2 kvk; | 1390 | struct pkey_verifykey2 kvk; |
| 1384 | u8 *kkey; | 1391 | u8 *kkey; |
| 1385 | 1392 | ||
| @@ -1400,7 +1407,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 14 unmodified lines | |||
| 1400 | break; | 1407 | break; |
| 1401 | } | 1408 | } |
| 1402 | case PKEY_KBLOB2PROTK2: { | 1409 | case PKEY_KBLOB2PROTK2: { |
| 1403 | struct pkey_kblob2pkey2 __user *utp = (void __user *) arg; | 1410 | struct pkey_kblob2pkey2 __user *utp = (void __user *)arg; |
| 1404 | struct pkey_kblob2pkey2 ktp; | 1411 | struct pkey_kblob2pkey2 ktp; |
| 1405 | struct pkey_apqn *apqns = NULL; | 1412 | struct pkey_apqn *apqns = NULL; |
| 1406 | u8 *kkey; | 1413 | u8 *kkey; |
| @@ -1427,7 +1434,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 20 unmodified lines | |||
| 1427 | break; | 1434 | break; |
| 1428 | } | 1435 | } |
| 1429 | case PKEY_APQNS4K: { | 1436 | case PKEY_APQNS4K: { |
| 1430 | struct pkey_apqns4key __user *uak = (void __user *) arg; | 1437 | struct pkey_apqns4key __user *uak = (void __user *)arg; |
| 1431 | struct pkey_apqns4key kak; | 1438 | struct pkey_apqns4key kak; |
| 1432 | struct pkey_apqn *apqns = NULL; | 1439 | struct pkey_apqn *apqns = NULL; |
| 1433 | size_t nr_apqns, len; | 1440 | size_t nr_apqns, len; |
| @@ -1476,7 +1483,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 42 unmodified lines | |||
| 1476 | break; | 1483 | break; |
| 1477 | } | 1484 | } |
| 1478 | case PKEY_APQNS4KT: { | 1485 | case PKEY_APQNS4KT: { |
| 1479 | struct pkey_apqns4keytype __user *uat = (void __user *) arg; | 1486 | struct pkey_apqns4keytype __user *uat = (void __user *)arg; |
| 1480 | struct pkey_apqns4keytype kat; | 1487 | struct pkey_apqns4keytype kat; |
| 1481 | struct pkey_apqn *apqns = NULL; | 1488 | struct pkey_apqn *apqns = NULL; |
| 1482 | size_t nr_apqns, len; | 1489 | size_t nr_apqns, len; |
| @@ -1518,7 +1525,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, · 35 unmodified lines | |||
| 1518 | break; | 1525 | break; |
| 1519 | } | 1526 | } |
| 1520 | case PKEY_KBLOB2PROTK3: { | 1527 | case PKEY_KBLOB2PROTK3: { |
| 1521 | struct pkey_kblob2pkey3 __user *utp = (void __user *) arg; | 1528 | struct pkey_kblob2pkey3 __user *utp = (void __user *)arg; |
| 1522 | struct pkey_kblob2pkey3 ktp; | 1529 | struct pkey_kblob2pkey3 ktp; |
| 1523 | struct pkey_apqn *apqns = NULL; | 1530 | struct pkey_apqn *apqns = NULL; |
| 1524 | u32 protkeylen = PROTKEYBLOBBUFSIZE; | 1531 | 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 | |||
| 1708 | loff_t off, size_t count) | 1715 | loff_t off, size_t count) |
| 1709 | { | 1716 | { |
| 1710 | int rc; | 1717 | int rc; |
| 1711 | struct pkey_seckey *seckey = (struct pkey_seckey *) buf; | 1718 | struct pkey_seckey *seckey = (struct pkey_seckey *)buf; |
| 1712 | 1719 | ||
| 1713 | if (off != 0 || count < sizeof(struct secaeskeytoken)) | 1720 | if (off != 0 || count < sizeof(struct secaeskeytoken)) |
| 1714 | return -EINVAL; | 1721 | return -EINVAL; |
| @@ -46,8 +46,6 @@ static struct ap_device_id ap_queue_ids[] = { · 45 unmodified lines | |||
| 46 | { /* end of sibling */ }, | 46 | { /* end of sibling */ }, |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | MODULE_DEVICE_TABLE(vfio_ap, ap_queue_ids); | ||
| 50 | |||
| 51 | static struct ap_matrix_mdev *vfio_ap_mdev_for_queue(struct vfio_ap_queue *q) | 49 | static struct ap_matrix_mdev *vfio_ap_mdev_for_queue(struct vfio_ap_queue *q) |
| 52 | { | 50 | { |
| 53 | struct ap_matrix_mdev *matrix_mdev; | 51 | struct ap_matrix_mdev *matrix_mdev; |
| @@ -104,7 +104,7 @@ struct zcrypt_ops *zcrypt_msgtype(unsigned char *name, int variant) · 103 unmodified lines | |||
| 104 | struct zcrypt_ops *zops; | 104 | struct zcrypt_ops *zops; |
| 105 | 105 | ||
| 106 | list_for_each_entry(zops, &zcrypt_ops_list, list) | 106 | list_for_each_entry(zops, &zcrypt_ops_list, list) |
| 107 | if ((zops->variant == variant) && | 107 | if (zops->variant == variant && |
| 108 | (!strncmp(zops->name, name, sizeof(zops->name)))) | 108 | (!strncmp(zops->name, name, sizeof(zops->name)))) |
| 109 | return zops; | 109 | return zops; |
| 110 | return NULL; | 110 | return NULL; |
| @@ -438,8 +438,8 @@ static int zcdn_create(const char *name) · 327 unmodified lines | |||
| 438 | strncpy(nodename, name, sizeof(nodename)); | 438 | strncpy(nodename, name, sizeof(nodename)); |
| 439 | else | 439 | else |
| 440 | snprintf(nodename, sizeof(nodename), | 440 | snprintf(nodename, sizeof(nodename), |
| 441 | ZCRYPT_NAME "_%d", (int) MINOR(devt)); | 441 | ZCRYPT_NAME "_%d", (int)MINOR(devt)); |
| 442 | nodename[sizeof(nodename)-1] = '\0'; | 442 | nodename[sizeof(nodename) - 1] = '\0'; |
| 443 | if (dev_set_name(&zcdndev->device, nodename)) { | 443 | if (dev_set_name(&zcdndev->device, nodename)) { |
| 444 | rc = -EINVAL; | 444 | rc = -EINVAL; |
| 445 | goto unlockout; | 445 | goto unlockout; |
| @@ -519,7 +519,7 @@ static ssize_t zcrypt_read(struct file *filp, char __user *buf, · 73 unmodified lines | |||
| 519 | /* | 519 | /* |
| 520 | * zcrypt_write(): Not allowed. | 520 | * zcrypt_write(): Not allowed. |
| 521 | * | 521 | * |
| 522 | * Write is is not allowed | 522 | * Write is not allowed |
| 523 | */ | 523 | */ |
| 524 | static ssize_t zcrypt_write(struct file *filp, const char __user *buf, | 524 | static ssize_t zcrypt_write(struct file *filp, const char __user *buf, |
| 525 | size_t count, loff_t *f_pos) | 525 | size_t count, loff_t *f_pos) |
| @@ -549,7 +549,7 @@ static int zcrypt_open(struct inode *inode, struct file *filp) · 23 unmodified lines | |||
| 549 | perms = &zcdndev->perms; | 549 | perms = &zcdndev->perms; |
| 550 | } | 550 | } |
| 551 | #endif | 551 | #endif |
| 552 | filp->private_data = (void *) perms; | 552 | filp->private_data = (void *)perms; |
| 553 | 553 | ||
| 554 | atomic_inc(&zcrypt_open_count); | 554 | atomic_inc(&zcrypt_open_count); |
| 555 | return stream_open(inode, filp); | 555 | return stream_open(inode, filp); |
| @@ -713,7 +713,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms, · 157 unmodified lines | |||
| 713 | pref_zq = NULL; | 713 | pref_zq = NULL; |
| 714 | spin_lock(&zcrypt_list_lock); | 714 | spin_lock(&zcrypt_list_lock); |
| 715 | for_each_zcrypt_card(zc) { | 715 | for_each_zcrypt_card(zc) { |
| 716 | /* Check for useable accelarator or CCA card */ | 716 | /* Check for usable accelarator or CCA card */ |
| 717 | if (!zc->online || !zc->card->config || zc->card->chkstop || | 717 | if (!zc->online || !zc->card->config || zc->card->chkstop || |
| 718 | !(zc->card->functions & 0x18000000)) | 718 | !(zc->card->functions & 0x18000000)) |
| 719 | continue; | 719 | continue; |
| @@ -733,7 +733,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms, · 13 unmodified lines | |||
| 733 | if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt)) | 733 | if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt)) |
| 734 | continue; | 734 | continue; |
| 735 | for_each_zcrypt_queue(zq, zc) { | 735 | for_each_zcrypt_queue(zq, zc) { |
| 736 | /* check if device is useable and eligible */ | 736 | /* check if device is usable and eligible */ |
| 737 | if (!zq->online || !zq->ops->rsa_modexpo || | 737 | if (!zq->online || !zq->ops->rsa_modexpo || |
| 738 | !zq->queue->config || zq->queue->chkstop) | 738 | !zq->queue->config || zq->queue->chkstop) |
| 739 | continue; | 739 | continue; |
| @@ -823,7 +823,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms, · 83 unmodified lines | |||
| 823 | pref_zq = NULL; | 823 | pref_zq = NULL; |
| 824 | spin_lock(&zcrypt_list_lock); | 824 | spin_lock(&zcrypt_list_lock); |
| 825 | for_each_zcrypt_card(zc) { | 825 | for_each_zcrypt_card(zc) { |
| 826 | /* Check for useable accelarator or CCA card */ | 826 | /* Check for usable accelarator or CCA card */ |
| 827 | if (!zc->online || !zc->card->config || zc->card->chkstop || | 827 | if (!zc->online || !zc->card->config || zc->card->chkstop || |
| 828 | !(zc->card->functions & 0x18000000)) | 828 | !(zc->card->functions & 0x18000000)) |
| 829 | continue; | 829 | continue; |
| @@ -843,7 +843,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms, · 13 unmodified lines | |||
| 843 | if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt)) | 843 | if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt)) |
| 844 | continue; | 844 | continue; |
| 845 | for_each_zcrypt_queue(zq, zc) { | 845 | for_each_zcrypt_queue(zq, zc) { |
| 846 | /* check if device is useable and eligible */ | 846 | /* check if device is usable and eligible */ |
| 847 | if (!zq->online || !zq->ops->rsa_modexpo_crt || | 847 | if (!zq->online || !zq->ops->rsa_modexpo_crt || |
| 848 | !zq->queue->config || zq->queue->chkstop) | 848 | !zq->queue->config || zq->queue->chkstop) |
| 849 | continue; | 849 | continue; |
| @@ -893,7 +893,7 @@ out: · 43 unmodified lines | |||
| 893 | 893 | ||
| 894 | static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, | 894 | static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, |
| 895 | struct zcrypt_track *tr, | 895 | struct zcrypt_track *tr, |
| 896 | struct ica_xcRB *xcRB) | 896 | struct ica_xcRB *xcrb) |
| 897 | { | 897 | { |
| 898 | struct zcrypt_card *zc, *pref_zc; | 898 | struct zcrypt_card *zc, *pref_zc; |
| 899 | struct zcrypt_queue *zq, *pref_zq; | 899 | struct zcrypt_queue *zq, *pref_zq; |
| @@ -904,9 +904,9 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 4 unmodified lines | |||
| 904 | int cpen, qpen, qid = 0, rc = -ENODEV; | 904 | int cpen, qpen, qid = 0, rc = -ENODEV; |
| 905 | struct module *mod; | 905 | struct module *mod; |
| 906 | 906 | ||
| 907 | trace_s390_zcrypt_req(xcRB, TB_ZSECSENDCPRB); | 907 | trace_s390_zcrypt_req(xcrb, TB_ZSECSENDCPRB); |
| 908 | 908 | ||
| 909 | xcRB->status = 0; | 909 | xcrb->status = 0; |
| 910 | ap_init_message(&ap_msg); | 910 | ap_init_message(&ap_msg); |
| 911 | 911 | ||
| 912 | #ifdef CONFIG_ZCRYPT_DEBUG | 912 | #ifdef CONFIG_ZCRYPT_DEBUG |
| @@ -915,11 +915,11 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 2 unmodified lines | |||
| 915 | if (tr && tr->fi.action == AP_FI_ACTION_CCA_AGENT_FF) { | 915 | if (tr && tr->fi.action == AP_FI_ACTION_CCA_AGENT_FF) { |
| 916 | ZCRYPT_DBF_WARN("%s fi cmd 0x%04x: forcing invalid agent_ID 'FF'\n", | 916 | ZCRYPT_DBF_WARN("%s fi cmd 0x%04x: forcing invalid agent_ID 'FF'\n", |
| 917 | __func__, tr->fi.cmd); | 917 | __func__, tr->fi.cmd); |
| 918 | xcRB->agent_ID = 0x4646; | 918 | xcrb->agent_ID = 0x4646; |
| 919 | } | 919 | } |
| 920 | #endif | 920 | #endif |
| 921 | 921 | ||
| 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); |
| 923 | if (rc) | 923 | if (rc) |
| 924 | goto out; | 924 | goto out; |
| 925 | 925 | ||
| @@ -948,13 +948,13 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 22 unmodified lines | |||
| 948 | pref_zq = NULL; | 948 | pref_zq = NULL; |
| 949 | spin_lock(&zcrypt_list_lock); | 949 | spin_lock(&zcrypt_list_lock); |
| 950 | for_each_zcrypt_card(zc) { | 950 | for_each_zcrypt_card(zc) { |
| 951 | /* Check for useable CCA card */ | 951 | /* Check for usable CCA card */ |
| 952 | if (!zc->online || !zc->card->config || zc->card->chkstop || | 952 | if (!zc->online || !zc->card->config || zc->card->chkstop || |
| 953 | !(zc->card->functions & 0x10000000)) | 953 | !(zc->card->functions & 0x10000000)) |
| 954 | continue; | 954 | continue; |
| 955 | /* Check for user selected CCA card */ | 955 | /* Check for user selected CCA card */ |
| 956 | if (xcRB->user_defined != AUTOSELECT && | 956 | if (xcrb->user_defined != AUTOSELECT && |
| 957 | xcRB->user_defined != zc->card->id) | 957 | xcrb->user_defined != zc->card->id) |
| 958 | continue; | 958 | continue; |
| 959 | /* check if request size exceeds card max msg size */ | 959 | /* check if request size exceeds card max msg size */ |
| 960 | if (ap_msg.len > zc->card->maxmsgsize) | 960 | 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 | |||
| 971 | if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt)) | 971 | if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt)) |
| 972 | continue; | 972 | continue; |
| 973 | for_each_zcrypt_queue(zq, zc) { | 973 | for_each_zcrypt_queue(zq, zc) { |
| 974 | /* check for device useable and eligible */ | 974 | /* check for device usable and eligible */ |
| 975 | if (!zq->online || !zq->ops->send_cprb || | 975 | if (!zq->online || !zq->ops->send_cprb || |
| 976 | !zq->queue->config || zq->queue->chkstop || | 976 | !zq->queue->config || zq->queue->chkstop || |
| 977 | (tdom != AUTOSEL_DOM && | 977 | (tdom != AUTOSEL_DOM && |
| @@ -998,7 +998,7 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 20 unmodified lines | |||
| 998 | 998 | ||
| 999 | if (!pref_zq) { | 999 | if (!pref_zq) { |
| 1000 | ZCRYPT_DBF_DBG("%s no match for address %02x.%04x => ENODEV\n", | 1000 | ZCRYPT_DBF_DBG("%s no match for address %02x.%04x => ENODEV\n", |
| 1001 | __func__, xcRB->user_defined, *domain); | 1001 | __func__, xcrb->user_defined, *domain); |
| 1002 | rc = -ENODEV; | 1002 | rc = -ENODEV; |
| 1003 | goto out; | 1003 | goto out; |
| 1004 | } | 1004 | } |
| @@ -1016,7 +1016,7 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, · 11 unmodified lines | |||
| 1016 | } | 1016 | } |
| 1017 | #endif | 1017 | #endif |
| 1018 | 1018 | ||
| 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); |
| 1020 | 1020 | ||
| 1021 | spin_lock(&zcrypt_list_lock); | 1021 | spin_lock(&zcrypt_list_lock); |
| 1022 | zcrypt_drop_queue(pref_zc, pref_zq, mod, wgt); | 1022 | zcrypt_drop_queue(pref_zc, pref_zq, mod, wgt); |
| @@ -1028,14 +1028,14 @@ out: · 5 unmodified lines | |||
| 1028 | tr->last_rc = rc; | 1028 | tr->last_rc = rc; |
| 1029 | tr->last_qid = qid; | 1029 | tr->last_qid = qid; |
| 1030 | } | 1030 | } |
| 1031 | trace_s390_zcrypt_rep(xcRB, func_code, rc, | 1031 | trace_s390_zcrypt_rep(xcrb, func_code, rc, |
| 1032 | AP_QID_CARD(qid), AP_QID_QUEUE(qid)); | 1032 | AP_QID_CARD(qid), AP_QID_QUEUE(qid)); |
| 1033 | return rc; | 1033 | return rc; |
| 1034 | } | 1034 | } |
| 1035 | 1035 | ||
| 1036 | long zcrypt_send_cprb(struct ica_xcRB *xcRB) | 1036 | long zcrypt_send_cprb(struct ica_xcRB *xcrb) |
| 1037 | { | 1037 | { |
| 1038 | return _zcrypt_send_cprb(false, &ap_perms, NULL, xcRB); | 1038 | return _zcrypt_send_cprb(false, &ap_perms, NULL, xcrb); |
| 1039 | } | 1039 | } |
| 1040 | EXPORT_SYMBOL(zcrypt_send_cprb); | 1040 | EXPORT_SYMBOL(zcrypt_send_cprb); |
| 1041 | 1041 | ||
| @@ -1089,7 +1089,7 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 47 unmodified lines | |||
| 1089 | ap_msg.fi.cmd = tr->fi.cmd; | 1089 | ap_msg.fi.cmd = tr->fi.cmd; |
| 1090 | #endif | 1090 | #endif |
| 1091 | 1091 | ||
| 1092 | target_num = (unsigned short) xcrb->targets_num; | 1092 | target_num = (unsigned short)xcrb->targets_num; |
| 1093 | 1093 | ||
| 1094 | /* empty list indicates autoselect (all available targets) */ | 1094 | /* empty list indicates autoselect (all available targets) */ |
| 1095 | targets = NULL; | 1095 | targets = NULL; |
| @@ -1103,9 +1103,9 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 7 unmodified lines | |||
| 1103 | goto out; | 1103 | goto out; |
| 1104 | } | 1104 | } |
| 1105 | 1105 | ||
| 1106 | uptr = (struct ep11_target_dev __force __user *) xcrb->targets; | 1106 | uptr = (struct ep11_target_dev __force __user *)xcrb->targets; |
| 1107 | if (z_copy_from_user(userspace, targets, uptr, | 1107 | if (z_copy_from_user(userspace, targets, uptr, |
| 1108 | target_num * sizeof(*targets))) { | 1108 | target_num * sizeof(*targets))) { |
| 1109 | func_code = 0; | 1109 | func_code = 0; |
| 1110 | rc = -EFAULT; | 1110 | rc = -EFAULT; |
| 1111 | goto out_free; | 1111 | goto out_free; |
| @@ -1132,7 +1132,7 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 20 unmodified lines | |||
| 1132 | pref_zq = NULL; | 1132 | pref_zq = NULL; |
| 1133 | spin_lock(&zcrypt_list_lock); | 1133 | spin_lock(&zcrypt_list_lock); |
| 1134 | for_each_zcrypt_card(zc) { | 1134 | for_each_zcrypt_card(zc) { |
| 1135 | /* Check for useable EP11 card */ | 1135 | /* Check for usable EP11 card */ |
| 1136 | if (!zc->online || !zc->card->config || zc->card->chkstop || | 1136 | if (!zc->online || !zc->card->config || zc->card->chkstop || |
| 1137 | !(zc->card->functions & 0x04000000)) | 1137 | !(zc->card->functions & 0x04000000)) |
| 1138 | continue; | 1138 | continue; |
| @@ -1155,7 +1155,7 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 16 unmodified lines | |||
| 1155 | if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt)) | 1155 | if (!zcrypt_card_compare(zc, pref_zc, wgt + cpen, pref_wgt)) |
| 1156 | continue; | 1156 | continue; |
| 1157 | for_each_zcrypt_queue(zq, zc) { | 1157 | for_each_zcrypt_queue(zq, zc) { |
| 1158 | /* check if device is useable and eligible */ | 1158 | /* check if device is usable and eligible */ |
| 1159 | if (!zq->online || !zq->ops->send_ep11_cprb || | 1159 | if (!zq->online || !zq->ops->send_ep11_cprb || |
| 1160 | !zq->queue->config || zq->queue->chkstop || | 1160 | !zq->queue->config || zq->queue->chkstop || |
| 1161 | (targets && | 1161 | (targets && |
| @@ -1184,11 +1184,11 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, · 22 unmodified lines | |||
| 1184 | if (!pref_zq) { | 1184 | if (!pref_zq) { |
| 1185 | if (targets && target_num == 1) { | 1185 | if (targets && target_num == 1) { |
| 1186 | ZCRYPT_DBF_DBG("%s no match for address %02x.%04x => ENODEV\n", | 1186 | ZCRYPT_DBF_DBG("%s no match for address %02x.%04x => ENODEV\n", |
| 1187 | __func__, (int) targets->ap_id, | 1187 | __func__, (int)targets->ap_id, |
| 1188 | (int) targets->dom_id); | 1188 | (int)targets->dom_id); |
| 1189 | } else if (targets) { | 1189 | } else if (targets) { |
| 1190 | ZCRYPT_DBF_DBG("%s no match for %d target addrs => ENODEV\n", | 1190 | ZCRYPT_DBF_DBG("%s no match for %d target addrs => ENODEV\n", |
| 1191 | __func__, (int) target_num); | 1191 | __func__, (int)target_num); |
| 1192 | } else { | 1192 | } else { |
| 1193 | ZCRYPT_DBF_DBG("%s no match for address ff.ffff => ENODEV\n", | 1193 | ZCRYPT_DBF_DBG("%s no match for address ff.ffff => ENODEV\n", |
| 1194 | __func__); | 1194 | __func__); |
| @@ -1245,7 +1245,7 @@ static long zcrypt_rng(char *buffer) · 50 unmodified lines | |||
| 1245 | pref_zq = NULL; | 1245 | pref_zq = NULL; |
| 1246 | spin_lock(&zcrypt_list_lock); | 1246 | spin_lock(&zcrypt_list_lock); |
| 1247 | for_each_zcrypt_card(zc) { | 1247 | for_each_zcrypt_card(zc) { |
| 1248 | /* Check for useable CCA card */ | 1248 | /* Check for usable CCA card */ |
| 1249 | if (!zc->online || !zc->card->config || zc->card->chkstop || | 1249 | if (!zc->online || !zc->card->config || zc->card->chkstop || |
| 1250 | !(zc->card->functions & 0x10000000)) | 1250 | !(zc->card->functions & 0x10000000)) |
| 1251 | continue; | 1251 | continue; |
| @@ -1254,7 +1254,7 @@ static long zcrypt_rng(char *buffer) · 2 unmodified lines | |||
| 1254 | if (!zcrypt_card_compare(zc, pref_zc, wgt, pref_wgt)) | 1254 | if (!zcrypt_card_compare(zc, pref_zc, wgt, pref_wgt)) |
| 1255 | continue; | 1255 | continue; |
| 1256 | for_each_zcrypt_queue(zq, zc) { | 1256 | for_each_zcrypt_queue(zq, zc) { |
| 1257 | /* check if device is useable and eligible */ | 1257 | /* check if device is usable and eligible */ |
| 1258 | if (!zq->online || !zq->ops->rng || | 1258 | if (!zq->online || !zq->ops->rng || |
| 1259 | !zq->queue->config || zq->queue->chkstop) | 1259 | !zq->queue->config || zq->queue->chkstop) |
| 1260 | continue; | 1260 | continue; |
| @@ -1270,7 +1270,7 @@ static long zcrypt_rng(char *buffer) · 9 unmodified lines | |||
| 1270 | 1270 | ||
| 1271 | if (!pref_zq) { | 1271 | if (!pref_zq) { |
| 1272 | ZCRYPT_DBF_DBG("%s no matching queue found => ENODEV\n", | 1272 | ZCRYPT_DBF_DBG("%s no matching queue found => ENODEV\n", |
| 1273 | __func__); | 1273 | __func__); |
| 1274 | rc = -ENODEV; | 1274 | rc = -ENODEV; |
| 1275 | goto out; | 1275 | goto out; |
| 1276 | } | 1276 | } |
| @@ -1381,8 +1381,8 @@ static void zcrypt_status_mask(char status[], size_t max_adapters) · 104 unmodified lines | |||
| 1381 | for_each_zcrypt_card(zc) { | 1381 | for_each_zcrypt_card(zc) { |
| 1382 | for_each_zcrypt_queue(zq, zc) { | 1382 | for_each_zcrypt_queue(zq, zc) { |
| 1383 | card = AP_QID_CARD(zq->queue->qid); | 1383 | card = AP_QID_CARD(zq->queue->qid); |
| 1384 | if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index | 1384 | if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index || |
| 1385 | || card >= max_adapters) | 1385 | card >= max_adapters) |
| 1386 | continue; | 1386 | continue; |
| 1387 | status[card] = zc->online ? zc->user_space_type : 0x0d; | 1387 | status[card] = zc->online ? zc->user_space_type : 0x0d; |
| 1388 | } | 1388 | } |
| @@ -1402,8 +1402,8 @@ static void zcrypt_qdepth_mask(char qdepth[], size_t max_adapters) · 13 unmodified lines | |||
| 1402 | for_each_zcrypt_card(zc) { | 1402 | for_each_zcrypt_card(zc) { |
| 1403 | for_each_zcrypt_queue(zq, zc) { | 1403 | for_each_zcrypt_queue(zq, zc) { |
| 1404 | card = AP_QID_CARD(zq->queue->qid); | 1404 | card = AP_QID_CARD(zq->queue->qid); |
| 1405 | if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index | 1405 | if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index || |
| 1406 | || card >= max_adapters) | 1406 | card >= max_adapters) |
| 1407 | continue; | 1407 | continue; |
| 1408 | spin_lock(&zq->queue->lock); | 1408 | spin_lock(&zq->queue->lock); |
| 1409 | qdepth[card] = | 1409 | qdepth[card] = |
| @@ -1429,13 +1429,13 @@ static void zcrypt_perdev_reqcnt(u32 reqcnt[], size_t max_adapters) · 19 unmodified lines | |||
| 1429 | for_each_zcrypt_card(zc) { | 1429 | for_each_zcrypt_card(zc) { |
| 1430 | for_each_zcrypt_queue(zq, zc) { | 1430 | for_each_zcrypt_queue(zq, zc) { |
| 1431 | card = AP_QID_CARD(zq->queue->qid); | 1431 | card = AP_QID_CARD(zq->queue->qid); |
| 1432 | if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index | 1432 | if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index || |
| 1433 | || card >= max_adapters) | 1433 | card >= max_adapters) |
| 1434 | continue; | 1434 | continue; |
| 1435 | spin_lock(&zq->queue->lock); | 1435 | spin_lock(&zq->queue->lock); |
| 1436 | cnt = zq->queue->total_request_count; | 1436 | cnt = zq->queue->total_request_count; |
| 1437 | spin_unlock(&zq->queue->lock); | 1437 | 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; |
| 1439 | } | 1439 | } |
| 1440 | } | 1440 | } |
| 1441 | local_bh_enable(); | 1441 | local_bh_enable(); |
| @@ -1493,7 +1493,7 @@ static int icarsamodexpo_ioctl(struct ap_perms *perms, unsigned long arg) · 51 unmodified lines | |||
| 1493 | int rc; | 1493 | int rc; |
| 1494 | struct zcrypt_track tr; | 1494 | struct zcrypt_track tr; |
| 1495 | struct ica_rsa_modexpo mex; | 1495 | 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; |
| 1497 | 1497 | ||
| 1498 | memset(&tr, 0, sizeof(tr)); | 1498 | memset(&tr, 0, sizeof(tr)); |
| 1499 | if (copy_from_user(&mex, umex, sizeof(mex))) | 1499 | 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 | |||
| 1538 | int rc; | 1538 | int rc; |
| 1539 | struct zcrypt_track tr; | 1539 | struct zcrypt_track tr; |
| 1540 | struct ica_rsa_modexpo_crt crt; | 1540 | 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; |
| 1542 | 1542 | ||
| 1543 | memset(&tr, 0, sizeof(tr)); | 1543 | memset(&tr, 0, sizeof(tr)); |
| 1544 | if (copy_from_user(&crt, ucrt, sizeof(crt))) | 1544 | 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 | |||
| 1581 | static int zsecsendcprb_ioctl(struct ap_perms *perms, unsigned long arg) | 1581 | static int zsecsendcprb_ioctl(struct ap_perms *perms, unsigned long arg) |
| 1582 | { | 1582 | { |
| 1583 | int rc; | 1583 | int rc; |
| 1584 | struct ica_xcRB xcRB; | 1584 | struct ica_xcRB xcrb; |
| 1585 | struct zcrypt_track tr; | 1585 | struct zcrypt_track tr; |
| 1586 | struct ica_xcRB __user *uxcRB = (void __user *) arg; | 1586 | struct ica_xcRB __user *uxcrb = (void __user *)arg; |
| 1587 | 1587 | ||
| 1588 | memset(&tr, 0, sizeof(tr)); | 1588 | memset(&tr, 0, sizeof(tr)); |
| 1589 | if (copy_from_user(&xcRB, uxcRB, sizeof(xcRB))) | 1589 | if (copy_from_user(&xcrb, uxcrb, sizeof(xcrb))) |
| 1590 | return -EFAULT; | 1590 | return -EFAULT; |
| 1591 | 1591 | ||
| 1592 | #ifdef CONFIG_ZCRYPT_DEBUG | 1592 | #ifdef CONFIG_ZCRYPT_DEBUG |
| 1593 | if ((xcRB.status & 0x8000FFFF) == 0x80004649 /* 'FI' */) { | 1593 | if ((xcrb.status & 0x8000FFFF) == 0x80004649 /* 'FI' */) { |
| 1594 | if (!capable(CAP_SYS_ADMIN)) | 1594 | if (!capable(CAP_SYS_ADMIN)) |
| 1595 | return -EPERM; | 1595 | return -EPERM; |
| 1596 | tr.fi.cmd = (u16)(xcRB.status >> 16); | 1596 | tr.fi.cmd = (u16)(xcrb.status >> 16); |
| 1597 | } | 1597 | } |
| 1598 | xcRB.status = 0; | 1598 | xcrb.status = 0; |
| 1599 | #endif | 1599 | #endif |
| 1600 | 1600 | ||
| 1601 | do { | 1601 | do { |
| 1602 | rc = _zcrypt_send_cprb(true, perms, &tr, &xcRB); | 1602 | rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb); |
| 1603 | if (rc == -EAGAIN) | 1603 | if (rc == -EAGAIN) |
| 1604 | tr.again_counter++; | 1604 | tr.again_counter++; |
| 1605 | #ifdef CONFIG_ZCRYPT_DEBUG | 1605 | #ifdef CONFIG_ZCRYPT_DEBUG |
| @@ -1610,7 +1610,7 @@ static int zsecsendcprb_ioctl(struct ap_perms *perms, unsigned long arg) · 4 unmodified lines | |||
| 1610 | /* on failure: retry once again after a requested rescan */ | 1610 | /* on failure: retry once again after a requested rescan */ |
| 1611 | if ((rc == -ENODEV) && (zcrypt_process_rescan())) | 1611 | if ((rc == -ENODEV) && (zcrypt_process_rescan())) |
| 1612 | do { | 1612 | do { |
| 1613 | rc = _zcrypt_send_cprb(true, perms, &tr, &xcRB); | 1613 | rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb); |
| 1614 | if (rc == -EAGAIN) | 1614 | if (rc == -EAGAIN) |
| 1615 | tr.again_counter++; | 1615 | tr.again_counter++; |
| 1616 | } while (rc == -EAGAIN && tr.again_counter < TRACK_AGAIN_MAX); | 1616 | } 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 | |||
| 1618 | rc = -EIO; | 1618 | rc = -EIO; |
| 1619 | if (rc) | 1619 | if (rc) |
| 1620 | ZCRYPT_DBF_DBG("ioctl ZSENDCPRB rc=%d status=0x%x\n", | 1620 | ZCRYPT_DBF_DBG("ioctl ZSENDCPRB rc=%d status=0x%x\n", |
| 1621 | rc, xcRB.status); | 1621 | rc, xcrb.status); |
| 1622 | if (copy_to_user(uxcRB, &xcRB, sizeof(xcRB))) | 1622 | if (copy_to_user(uxcrb, &xcrb, sizeof(xcrb))) |
| 1623 | return -EFAULT; | 1623 | return -EFAULT; |
| 1624 | return rc; | 1624 | return rc; |
| 1625 | } | 1625 | } |
| @@ -1674,7 +1674,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 48 unmodified lines | |||
| 1674 | { | 1674 | { |
| 1675 | int rc; | 1675 | int rc; |
| 1676 | struct ap_perms *perms = | 1676 | struct ap_perms *perms = |
| 1677 | (struct ap_perms *) filp->private_data; | 1677 | (struct ap_perms *)filp->private_data; |
| 1678 | 1678 | ||
| 1679 | rc = zcrypt_check_ioctl(perms, cmd); | 1679 | rc = zcrypt_check_ioctl(perms, cmd); |
| 1680 | if (rc) | 1680 | if (rc) |
| @@ -1698,7 +1698,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 17 unmodified lines | |||
| 1698 | if (!device_status) | 1698 | if (!device_status) |
| 1699 | return -ENOMEM; | 1699 | return -ENOMEM; |
| 1700 | zcrypt_device_status_mask_ext(device_status); | 1700 | 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, |
| 1702 | total_size)) | 1702 | total_size)) |
| 1703 | rc = -EFAULT; | 1703 | rc = -EFAULT; |
| 1704 | kfree(device_status); | 1704 | kfree(device_status); |
| @@ -1708,7 +1708,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 3 unmodified lines | |||
| 1708 | char status[AP_DEVICES]; | 1708 | char status[AP_DEVICES]; |
| 1709 | 1709 | ||
| 1710 | zcrypt_status_mask(status, AP_DEVICES); | 1710 | 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))) |
| 1712 | return -EFAULT; | 1712 | return -EFAULT; |
| 1713 | return 0; | 1713 | return 0; |
| 1714 | } | 1714 | } |
| @@ -1716,7 +1716,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 1 unmodified line | |||
| 1716 | char qdepth[AP_DEVICES]; | 1716 | char qdepth[AP_DEVICES]; |
| 1717 | 1717 | ||
| 1718 | zcrypt_qdepth_mask(qdepth, AP_DEVICES); | 1718 | 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))) |
| 1720 | return -EFAULT; | 1720 | return -EFAULT; |
| 1721 | return 0; | 1721 | return 0; |
| 1722 | } | 1722 | } |
| @@ -1727,21 +1727,21 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 4 unmodified lines | |||
| 1727 | if (!reqcnt) | 1727 | if (!reqcnt) |
| 1728 | return -ENOMEM; | 1728 | return -ENOMEM; |
| 1729 | zcrypt_perdev_reqcnt(reqcnt, AP_DEVICES); | 1729 | zcrypt_perdev_reqcnt(reqcnt, AP_DEVICES); |
| 1730 | if (copy_to_user((int __user *) arg, reqcnt, | 1730 | if (copy_to_user((int __user *)arg, reqcnt, |
| 1731 | sizeof(u32) * AP_DEVICES)) | 1731 | sizeof(u32) * AP_DEVICES)) |
| 1732 | rc = -EFAULT; | 1732 | rc = -EFAULT; |
| 1733 | kfree(reqcnt); | 1733 | kfree(reqcnt); |
| 1734 | return rc; | 1734 | return rc; |
| 1735 | } | 1735 | } |
| 1736 | case Z90STAT_REQUESTQ_COUNT: | 1736 | case Z90STAT_REQUESTQ_COUNT: |
| 1737 | return put_user(zcrypt_requestq_count(), (int __user *) arg); | 1737 | return put_user(zcrypt_requestq_count(), (int __user *)arg); |
| 1738 | case Z90STAT_PENDINGQ_COUNT: | 1738 | case Z90STAT_PENDINGQ_COUNT: |
| 1739 | return put_user(zcrypt_pendingq_count(), (int __user *) arg); | 1739 | return put_user(zcrypt_pendingq_count(), (int __user *)arg); |
| 1740 | case Z90STAT_TOTALOPEN_COUNT: | 1740 | case Z90STAT_TOTALOPEN_COUNT: |
| 1741 | return put_user(atomic_read(&zcrypt_open_count), | 1741 | return put_user(atomic_read(&zcrypt_open_count), |
| 1742 | (int __user *) arg); | 1742 | (int __user *)arg); |
| 1743 | case Z90STAT_DOMAIN_INDEX: | 1743 | case Z90STAT_DOMAIN_INDEX: |
| 1744 | return put_user(ap_domain_index, (int __user *) arg); | 1744 | return put_user(ap_domain_index, (int __user *)arg); |
| 1745 | /* | 1745 | /* |
| 1746 | * Deprecated ioctls | 1746 | * Deprecated ioctls |
| 1747 | */ | 1747 | */ |
| @@ -1755,7 +1755,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 7 unmodified lines | |||
| 1755 | if (!device_status) | 1755 | if (!device_status) |
| 1756 | return -ENOMEM; | 1756 | return -ENOMEM; |
| 1757 | zcrypt_device_status_mask(device_status); | 1757 | 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, |
| 1759 | total_size)) | 1759 | total_size)) |
| 1760 | rc = -EFAULT; | 1760 | rc = -EFAULT; |
| 1761 | kfree(device_status); | 1761 | kfree(device_status); |
| @@ -1766,7 +1766,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 4 unmodified lines | |||
| 1766 | char status[MAX_ZDEV_CARDIDS]; | 1766 | char status[MAX_ZDEV_CARDIDS]; |
| 1767 | 1767 | ||
| 1768 | zcrypt_status_mask(status, MAX_ZDEV_CARDIDS); | 1768 | 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))) |
| 1770 | return -EFAULT; | 1770 | return -EFAULT; |
| 1771 | return 0; | 1771 | return 0; |
| 1772 | } | 1772 | } |
| @@ -1775,7 +1775,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 2 unmodified lines | |||
| 1775 | char qdepth[MAX_ZDEV_CARDIDS]; | 1775 | char qdepth[MAX_ZDEV_CARDIDS]; |
| 1776 | 1776 | ||
| 1777 | zcrypt_qdepth_mask(qdepth, MAX_ZDEV_CARDIDS); | 1777 | 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))) |
| 1779 | return -EFAULT; | 1779 | return -EFAULT; |
| 1780 | return 0; | 1780 | return 0; |
| 1781 | } | 1781 | } |
| @@ -1784,7 +1784,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, · 2 unmodified lines | |||
| 1784 | u32 reqcnt[MAX_ZDEV_CARDIDS]; | 1784 | u32 reqcnt[MAX_ZDEV_CARDIDS]; |
| 1785 | 1785 | ||
| 1786 | zcrypt_perdev_reqcnt(reqcnt, MAX_ZDEV_CARDIDS); | 1786 | 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))) |
| 1788 | return -EFAULT; | 1788 | return -EFAULT; |
| 1789 | return 0; | 1789 | return 0; |
| 1790 | } | 1790 | } |
| @@ -1899,7 +1899,7 @@ static long trans_modexpo_crt32(struct ap_perms *perms, struct file *filp, · 108 unmodified lines | |||
| 1899 | &ucrt32->outputdatalength); | 1899 | &ucrt32->outputdatalength); |
| 1900 | } | 1900 | } |
| 1901 | 1901 | ||
| 1902 | struct compat_ica_xcRB { | 1902 | struct compat_ica_xcrb { |
| 1903 | unsigned short agent_ID; | 1903 | unsigned short agent_ID; |
| 1904 | unsigned int user_defined; | 1904 | unsigned int user_defined; |
| 1905 | unsigned short request_ID; | 1905 | unsigned short request_ID; |
| @@ -1919,66 +1919,66 @@ struct compat_ica_xcRB { · 13 unmodified lines | |||
| 1919 | unsigned int status; | 1919 | unsigned int status; |
| 1920 | } __packed; | 1920 | } __packed; |
| 1921 | 1921 | ||
| 1922 | static long trans_xcRB32(struct ap_perms *perms, struct file *filp, | 1922 | static long trans_xcrb32(struct ap_perms *perms, struct file *filp, |
| 1923 | unsigned int cmd, unsigned long arg) | 1923 | unsigned int cmd, unsigned long arg) |
| 1924 | { | 1924 | { |
| 1925 | struct compat_ica_xcRB __user *uxcRB32 = compat_ptr(arg); | 1925 | struct compat_ica_xcrb __user *uxcrb32 = compat_ptr(arg); |
| 1926 | struct compat_ica_xcRB xcRB32; | 1926 | struct compat_ica_xcrb xcrb32; |
| 1927 | struct zcrypt_track tr; | 1927 | struct zcrypt_track tr; |
| 1928 | struct ica_xcRB xcRB64; | 1928 | struct ica_xcRB xcrb64; |
| 1929 | long rc; | 1929 | long rc; |
| 1930 | 1930 | ||
| 1931 | memset(&tr, 0, sizeof(tr)); | 1931 | memset(&tr, 0, sizeof(tr)); |
| 1932 | if (copy_from_user(&xcRB32, uxcRB32, sizeof(xcRB32))) | 1932 | if (copy_from_user(&xcrb32, uxcrb32, sizeof(xcrb32))) |
| 1933 | return -EFAULT; | 1933 | return -EFAULT; |
| 1934 | xcRB64.agent_ID = xcRB32.agent_ID; | 1934 | xcrb64.agent_ID = xcrb32.agent_ID; |
| 1935 | xcRB64.user_defined = xcRB32.user_defined; | 1935 | xcrb64.user_defined = xcrb32.user_defined; |
| 1936 | xcRB64.request_ID = xcRB32.request_ID; | 1936 | xcrb64.request_ID = xcrb32.request_ID; |
| 1937 | xcRB64.request_control_blk_length = | 1937 | xcrb64.request_control_blk_length = |
| 1938 | xcRB32.request_control_blk_length; | 1938 | xcrb32.request_control_blk_length; |
| 1939 | xcRB64.request_control_blk_addr = | 1939 | xcrb64.request_control_blk_addr = |
| 1940 | compat_ptr(xcRB32.request_control_blk_addr); | 1940 | compat_ptr(xcrb32.request_control_blk_addr); |
| 1941 | xcRB64.request_data_length = | 1941 | xcrb64.request_data_length = |
| 1942 | xcRB32.request_data_length; | 1942 | xcrb32.request_data_length; |
| 1943 | xcRB64.request_data_address = | 1943 | xcrb64.request_data_address = |
| 1944 | compat_ptr(xcRB32.request_data_address); | 1944 | compat_ptr(xcrb32.request_data_address); |
| 1945 | xcRB64.reply_control_blk_length = | 1945 | xcrb64.reply_control_blk_length = |
| 1946 | xcRB32.reply_control_blk_length; | 1946 | xcrb32.reply_control_blk_length; |
| 1947 | xcRB64.reply_control_blk_addr = | 1947 | xcrb64.reply_control_blk_addr = |
| 1948 | compat_ptr(xcRB32.reply_control_blk_addr); | 1948 | compat_ptr(xcrb32.reply_control_blk_addr); |
| 1949 | xcRB64.reply_data_length = xcRB32.reply_data_length; | 1949 | xcrb64.reply_data_length = xcrb32.reply_data_length; |
| 1950 | xcRB64.reply_data_addr = | 1950 | xcrb64.reply_data_addr = |
| 1951 | compat_ptr(xcRB32.reply_data_addr); | 1951 | compat_ptr(xcrb32.reply_data_addr); |
| 1952 | xcRB64.priority_window = xcRB32.priority_window; | 1952 | xcrb64.priority_window = xcrb32.priority_window; |
| 1953 | xcRB64.status = xcRB32.status; | 1953 | xcrb64.status = xcrb32.status; |
| 1954 | do { | 1954 | do { |
| 1955 | rc = _zcrypt_send_cprb(true, perms, &tr, &xcRB64); | 1955 | rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb64); |
| 1956 | if (rc == -EAGAIN) | 1956 | if (rc == -EAGAIN) |
| 1957 | tr.again_counter++; | 1957 | tr.again_counter++; |
| 1958 | } while (rc == -EAGAIN && tr.again_counter < TRACK_AGAIN_MAX); | 1958 | } while (rc == -EAGAIN && tr.again_counter < TRACK_AGAIN_MAX); |
| 1959 | /* on failure: retry once again after a requested rescan */ | 1959 | /* on failure: retry once again after a requested rescan */ |
| 1960 | if ((rc == -ENODEV) && (zcrypt_process_rescan())) | 1960 | if ((rc == -ENODEV) && (zcrypt_process_rescan())) |
| 1961 | do { | 1961 | do { |
| 1962 | rc = _zcrypt_send_cprb(true, perms, &tr, &xcRB64); | 1962 | rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb64); |
| 1963 | if (rc == -EAGAIN) | 1963 | if (rc == -EAGAIN) |
| 1964 | tr.again_counter++; | 1964 | tr.again_counter++; |
| 1965 | } while (rc == -EAGAIN && tr.again_counter < TRACK_AGAIN_MAX); | 1965 | } while (rc == -EAGAIN && tr.again_counter < TRACK_AGAIN_MAX); |
| 1966 | if (rc == -EAGAIN && tr.again_counter >= TRACK_AGAIN_MAX) | 1966 | if (rc == -EAGAIN && tr.again_counter >= TRACK_AGAIN_MAX) |
| 1967 | rc = -EIO; | 1967 | rc = -EIO; |
| 1968 | xcRB32.reply_control_blk_length = xcRB64.reply_control_blk_length; | 1968 | xcrb32.reply_control_blk_length = xcrb64.reply_control_blk_length; |
| 1969 | xcRB32.reply_data_length = xcRB64.reply_data_length; | 1969 | xcrb32.reply_data_length = xcrb64.reply_data_length; |
| 1970 | xcRB32.status = xcRB64.status; | 1970 | xcrb32.status = xcrb64.status; |
| 1971 | if (copy_to_user(uxcRB32, &xcRB32, sizeof(xcRB32))) | 1971 | if (copy_to_user(uxcrb32, &xcrb32, sizeof(xcrb32))) |
| 1972 | return -EFAULT; | 1972 | return -EFAULT; |
| 1973 | return rc; | 1973 | return rc; |
| 1974 | } | 1974 | } |
| 1975 | 1975 | ||
| 1976 | static long zcrypt_compat_ioctl(struct file *filp, unsigned int cmd, | 1976 | static long zcrypt_compat_ioctl(struct file *filp, unsigned int cmd, |
| 1977 | unsigned long arg) | 1977 | unsigned long arg) |
| 1978 | { | 1978 | { |
| 1979 | int rc; | 1979 | int rc; |
| 1980 | struct ap_perms *perms = | 1980 | struct ap_perms *perms = |
| 1981 | (struct ap_perms *) filp->private_data; | 1981 | (struct ap_perms *)filp->private_data; |
| 1982 | 1982 | ||
| 1983 | rc = zcrypt_check_ioctl(perms, cmd); | 1983 | rc = zcrypt_check_ioctl(perms, cmd); |
| 1984 | if (rc) | 1984 | if (rc) |
| @@ -1989,7 +1989,7 @@ static long zcrypt_compat_ioctl(struct file *filp, unsigned int cmd, · 4 unmodified lines | |||
| 1989 | if (cmd == ICARSACRT) | 1989 | if (cmd == ICARSACRT) |
| 1990 | return trans_modexpo_crt32(perms, filp, cmd, arg); | 1990 | return trans_modexpo_crt32(perms, filp, cmd, arg); |
| 1991 | if (cmd == ZSECSENDCPRB) | 1991 | if (cmd == ZSECSENDCPRB) |
| 1992 | return trans_xcRB32(perms, filp, cmd, arg); | 1992 | return trans_xcrb32(perms, filp, cmd, arg); |
| 1993 | return zcrypt_unlocked_ioctl(filp, cmd, arg); | 1993 | return zcrypt_unlocked_ioctl(filp, cmd, arg); |
| 1994 | } | 1994 | } |
| 1995 | #endif | 1995 | #endif |
| @@ -2033,10 +2033,10 @@ static int zcrypt_rng_data_read(struct hwrng *rng, u32 *data) · 37 unmodified lines | |||
| 2033 | * read method calls. | 2033 | * read method calls. |
| 2034 | */ | 2034 | */ |
| 2035 | if (zcrypt_rng_buffer_index == 0) { | 2035 | if (zcrypt_rng_buffer_index == 0) { |
| 2036 | rc = zcrypt_rng((char *) zcrypt_rng_buffer); | 2036 | rc = zcrypt_rng((char *)zcrypt_rng_buffer); |
| 2037 | /* on failure: retry once again after a requested rescan */ | 2037 | /* on failure: retry once again after a requested rescan */ |
| 2038 | if ((rc == -ENODEV) && (zcrypt_process_rescan())) | 2038 | if ((rc == -ENODEV) && (zcrypt_process_rescan())) |
| 2039 | rc = zcrypt_rng((char *) zcrypt_rng_buffer); | 2039 | rc = zcrypt_rng((char *)zcrypt_rng_buffer); |
| 2040 | if (rc < 0) | 2040 | if (rc < 0) |
| 2041 | return -EIO; | 2041 | return -EIO; |
| 2042 | zcrypt_rng_buffer_index = rc / sizeof(*data); | 2042 | zcrypt_rng_buffer_index = rc / sizeof(*data); |
| @@ -2057,7 +2057,7 @@ int zcrypt_rng_device_add(void) · 14 unmodified lines | |||
| 2057 | 2057 | ||
| 2058 | mutex_lock(&zcrypt_rng_mutex); | 2058 | mutex_lock(&zcrypt_rng_mutex); |
| 2059 | if (zcrypt_rng_device_count == 0) { | 2059 | 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); |
| 2061 | if (!zcrypt_rng_buffer) { | 2061 | if (!zcrypt_rng_buffer) { |
| 2062 | rc = -ENOMEM; | 2062 | rc = -ENOMEM; |
| 2063 | goto out; | 2063 | goto out; |
| @@ -2069,13 +2069,14 @@ int zcrypt_rng_device_add(void) · 5 unmodified lines | |||
| 2069 | if (rc) | 2069 | if (rc) |
| 2070 | goto out_free; | 2070 | goto out_free; |
| 2071 | zcrypt_rng_device_count = 1; | 2071 | zcrypt_rng_device_count = 1; |
| 2072 | } else | 2072 | } else { |
| 2073 | zcrypt_rng_device_count++; | 2073 | zcrypt_rng_device_count++; |
| 2074 | } | ||
| 2074 | mutex_unlock(&zcrypt_rng_mutex); | 2075 | mutex_unlock(&zcrypt_rng_mutex); |
| 2075 | return 0; | 2076 | return 0; |
| 2076 | 2077 | ||
| 2077 | out_free: | 2078 | out_free: |
| 2078 | free_page((unsigned long) zcrypt_rng_buffer); | 2079 | free_page((unsigned long)zcrypt_rng_buffer); |
| 2079 | out: | 2080 | out: |
| 2080 | mutex_unlock(&zcrypt_rng_mutex); | 2081 | mutex_unlock(&zcrypt_rng_mutex); |
| 2081 | return rc; | 2082 | return rc; |
| @@ -2087,7 +2088,7 @@ void zcrypt_rng_device_remove(void) · 5 unmodified lines | |||
| 2087 | zcrypt_rng_device_count--; | 2088 | zcrypt_rng_device_count--; |
| 2088 | if (zcrypt_rng_device_count == 0) { | 2089 | if (zcrypt_rng_device_count == 0) { |
| 2089 | hwrng_unregister(&zcrypt_rng_dev); | 2090 | hwrng_unregister(&zcrypt_rng_dev); |
| 2090 | free_page((unsigned long) zcrypt_rng_buffer); | 2091 | free_page((unsigned long)zcrypt_rng_buffer); |
| 2091 | } | 2092 | } |
| 2092 | mutex_unlock(&zcrypt_rng_mutex); | 2093 | mutex_unlock(&zcrypt_rng_mutex); |
| 2093 | } | 2094 | } |
| @@ -170,7 +170,7 @@ static inline unsigned long z_copy_from_user(bool userspace, · 169 unmodified lines | |||
| 170 | { | 170 | { |
| 171 | if (likely(userspace)) | 171 | if (likely(userspace)) |
| 172 | return copy_from_user(to, from, n); | 172 | return copy_from_user(to, from, n); |
| 173 | memcpy(to, (void __force *) from, n); | 173 | memcpy(to, (void __force *)from, n); |
| 174 | return 0; | 174 | return 0; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| @@ -181,7 +181,7 @@ static inline unsigned long z_copy_to_user(bool userspace, · 4 unmodified lines | |||
| 181 | { | 181 | { |
| 182 | if (likely(userspace)) | 182 | if (likely(userspace)) |
| 183 | return copy_to_user(to, from, n); | 183 | return copy_to_user(to, from, n); |
| 184 | memcpy((void __force *) to, from, n); | 184 | memcpy((void __force *)to, from, n); |
| 185 | return 0; | 185 | return 0; |
| 186 | } | 186 | } |
| 187 | 187 | ||
| @@ -138,7 +138,7 @@ struct zcrypt_card *zcrypt_card_alloc(void) · 137 unmodified lines | |||
| 138 | { | 138 | { |
| 139 | struct zcrypt_card *zc; | 139 | struct zcrypt_card *zc; |
| 140 | 140 | ||
| 141 | zc = kzalloc(sizeof(struct zcrypt_card), GFP_KERNEL); | 141 | zc = kzalloc(sizeof(*zc), GFP_KERNEL); |
| 142 | if (!zc) | 142 | if (!zc) |
| 143 | return NULL; | 143 | return NULL; |
| 144 | INIT_LIST_HEAD(&zc->list); | 144 | INIT_LIST_HEAD(&zc->list); |
| @@ -11,7 +11,7 @@ · 10 unmodified lines | |||
| 11 | #ifndef _ZCRYPT_CCA_KEY_H_ | 11 | #ifndef _ZCRYPT_CCA_KEY_H_ |
| 12 | #define _ZCRYPT_CCA_KEY_H_ | 12 | #define _ZCRYPT_CCA_KEY_H_ |
| 13 | 13 | ||
| 14 | struct T6_keyBlock_hdr { | 14 | struct t6_keyblock_hdr { |
| 15 | unsigned short blen; | 15 | unsigned short blen; |
| 16 | unsigned short ulen; | 16 | unsigned short ulen; |
| 17 | unsigned short flags; | 17 | unsigned short flags; |
| @@ -63,7 +63,7 @@ struct cca_public_sec { · 45 unmodified lines | |||
| 63 | * complement of the residue modulo 8 of the sum of | 63 | * complement of the residue modulo 8 of the sum of |
| 64 | * (p_len + q_len + dp_len + dq_len + u_len). | 64 | * (p_len + q_len + dp_len + dq_len + u_len). |
| 65 | */ | 65 | */ |
| 66 | struct cca_pvt_ext_CRT_sec { | 66 | struct cca_pvt_ext_crt_sec { |
| 67 | unsigned char section_identifier; | 67 | unsigned char section_identifier; |
| 68 | unsigned char version; | 68 | unsigned char version; |
| 69 | unsigned short section_length; | 69 | 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 | |||
| 108 | .section_identifier = 0x04, | 108 | .section_identifier = 0x04, |
| 109 | }; | 109 | }; |
| 110 | struct { | 110 | struct { |
| 111 | struct T6_keyBlock_hdr t6_hdr; | 111 | struct t6_keyblock_hdr t6_hdr; |
| 112 | struct cca_token_hdr pubHdr; | 112 | struct cca_token_hdr pubhdr; |
| 113 | struct cca_public_sec pubSec; | 113 | struct cca_public_sec pubsec; |
| 114 | char exponent[0]; | 114 | char exponent[0]; |
| 115 | } __packed *key = p; | 115 | } __packed *key = p; |
| 116 | unsigned char *temp; | 116 | 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 | |||
| 127 | 127 | ||
| 128 | memset(key, 0, sizeof(*key)); | 128 | memset(key, 0, sizeof(*key)); |
| 129 | 129 | ||
| 130 | key->pubHdr = static_pub_hdr; | 130 | key->pubhdr = static_pub_hdr; |
| 131 | key->pubSec = static_pub_sec; | 131 | key->pubsec = static_pub_sec; |
| 132 | 132 | ||
| 133 | /* key parameter block */ | 133 | /* key parameter block */ |
| 134 | temp = key->exponent; | 134 | 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 | |||
| 146 | if (copy_from_user(temp, mex->n_modulus, mex->inputdatalength)) | 146 | if (copy_from_user(temp, mex->n_modulus, mex->inputdatalength)) |
| 147 | return -EFAULT; | 147 | return -EFAULT; |
| 148 | 148 | ||
| 149 | key->pubSec.modulus_bit_len = 8 * mex->inputdatalength; | 149 | key->pubsec.modulus_bit_len = 8 * mex->inputdatalength; |
| 150 | key->pubSec.modulus_byte_len = mex->inputdatalength; | 150 | key->pubsec.modulus_byte_len = mex->inputdatalength; |
| 151 | key->pubSec.exponent_len = mex->inputdatalength - i; | 151 | key->pubsec.exponent_len = mex->inputdatalength - i; |
| 152 | key->pubSec.section_length = sizeof(key->pubSec) + | 152 | key->pubsec.section_length = sizeof(key->pubsec) + |
| 153 | 2*mex->inputdatalength - i; | 153 | 2 * mex->inputdatalength - i; |
| 154 | key->pubHdr.token_length = | 154 | key->pubhdr.token_length = |
| 155 | key->pubSec.section_length + sizeof(key->pubHdr); | 155 | key->pubsec.section_length + sizeof(key->pubhdr); |
| 156 | key->t6_hdr.ulen = key->pubHdr.token_length + 4; | 156 | key->t6_hdr.ulen = key->pubhdr.token_length + 4; |
| 157 | key->t6_hdr.blen = key->pubHdr.token_length + 6; | 157 | key->t6_hdr.blen = key->pubhdr.token_length + 6; |
| 158 | return sizeof(*key) + 2*mex->inputdatalength - i; | 158 | return sizeof(*key) + 2 * mex->inputdatalength - i; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | /** | 161 | /** |
| @@ -177,9 +177,9 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p) · 15 unmodified lines | |||
| 177 | }; | 177 | }; |
| 178 | static char pk_exponent[3] = { 0x01, 0x00, 0x01 }; | 178 | static char pk_exponent[3] = { 0x01, 0x00, 0x01 }; |
| 179 | struct { | 179 | struct { |
| 180 | struct T6_keyBlock_hdr t6_hdr; | 180 | struct t6_keyblock_hdr t6_hdr; |
| 181 | struct cca_token_hdr token; | 181 | struct cca_token_hdr token; |
| 182 | struct cca_pvt_ext_CRT_sec pvt; | 182 | struct cca_pvt_ext_crt_sec pvt; |
| 183 | char key_parts[0]; | 183 | char key_parts[0]; |
| 184 | } __packed *key = p; | 184 | } __packed *key = p; |
| 185 | struct cca_public_sec *pub; | 185 | 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 | |||
| 198 | 198 | ||
| 199 | short_len = (crt->inputdatalength + 1) / 2; | 199 | short_len = (crt->inputdatalength + 1) / 2; |
| 200 | long_len = short_len + 8; | 200 | long_len = short_len + 8; |
| 201 | pad_len = -(3*long_len + 2*short_len) & 7; | 201 | pad_len = -(3 * long_len + 2 * short_len) & 7; |
| 202 | key_len = 3*long_len + 2*short_len + pad_len + crt->inputdatalength; | 202 | key_len = 3 * long_len + 2 * short_len + pad_len + crt->inputdatalength; |
| 203 | size = sizeof(*key) + key_len + sizeof(*pub) + 3; | 203 | size = sizeof(*key) + key_len + sizeof(*pub) + 3; |
| 204 | 204 | ||
| 205 | /* parameter block.key block */ | 205 | /* 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 | |||
| 223 | /* key parts */ | 223 | /* key parts */ |
| 224 | if (copy_from_user(key->key_parts, crt->np_prime, long_len) || | 224 | if (copy_from_user(key->key_parts, crt->np_prime, long_len) || |
| 225 | copy_from_user(key->key_parts + long_len, | 225 | copy_from_user(key->key_parts + long_len, |
| 226 | crt->nq_prime, short_len) || | 226 | crt->nq_prime, short_len) || |
| 227 | copy_from_user(key->key_parts + long_len + short_len, | 227 | copy_from_user(key->key_parts + long_len + short_len, |
| 228 | crt->bp_key, long_len) || | 228 | crt->bp_key, long_len) || |
| 229 | copy_from_user(key->key_parts + 2*long_len + short_len, | 229 | copy_from_user(key->key_parts + 2 * long_len + short_len, |
| 230 | crt->bq_key, short_len) || | 230 | crt->bq_key, short_len) || |
| 231 | copy_from_user(key->key_parts + 2*long_len + 2*short_len, | 231 | copy_from_user(key->key_parts + 2 * long_len + 2 * short_len, |
| 232 | crt->u_mult_inv, long_len)) | 232 | crt->u_mult_inv, long_len)) |
| 233 | return -EFAULT; | 233 | 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, |
| 235 | 0xff, crt->inputdatalength); | 235 | 0xff, crt->inputdatalength); |
| 236 | pub = (struct cca_public_sec *)(key->key_parts + key_len); | 236 | pub = (struct cca_public_sec *)(key->key_parts + key_len); |
| 237 | *pub = static_cca_pub_sec; | 237 | *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 | |||
| 241 | * section. So, an arbitrary public exponent of 0x010001 will be | 241 | * section. So, an arbitrary public exponent of 0x010001 will be |
| 242 | * used. | 242 | * used. |
| 243 | */ | 243 | */ |
| 244 | memcpy((char *) (pub + 1), pk_exponent, 3); | 244 | memcpy((char *)(pub + 1), pk_exponent, 3); |
| 245 | return size; | 245 | return size; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| @@ -53,26 +53,26 @@ static DEFINE_SPINLOCK(cca_info_list_lock); · 52 unmodified lines | |||
| 53 | int cca_check_secaeskeytoken(debug_info_t *dbg, int dbflvl, | 53 | int cca_check_secaeskeytoken(debug_info_t *dbg, int dbflvl, |
| 54 | const u8 *token, int keybitsize) | 54 | const u8 *token, int keybitsize) |
| 55 | { | 55 | { |
| 56 | struct secaeskeytoken *t = (struct secaeskeytoken *) token; | 56 | struct secaeskeytoken *t = (struct secaeskeytoken *)token; |
| 57 | 57 | ||
| 58 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) | 58 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) |
| 59 | 59 | ||
| 60 | if (t->type != TOKTYPE_CCA_INTERNAL) { | 60 | if (t->type != TOKTYPE_CCA_INTERNAL) { |
| 61 | if (dbg) | 61 | if (dbg) |
| 62 | DBF("%s token check failed, type 0x%02x != 0x%02x\n", | 62 | 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); |
| 64 | return -EINVAL; | 64 | return -EINVAL; |
| 65 | } | 65 | } |
| 66 | if (t->version != TOKVER_CCA_AES) { | 66 | if (t->version != TOKVER_CCA_AES) { |
| 67 | if (dbg) | 67 | if (dbg) |
| 68 | DBF("%s token check failed, version 0x%02x != 0x%02x\n", | 68 | 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); |
| 70 | return -EINVAL; | 70 | return -EINVAL; |
| 71 | } | 71 | } |
| 72 | if (keybitsize > 0 && t->bitsize != keybitsize) { | 72 | if (keybitsize > 0 && t->bitsize != keybitsize) { |
| 73 | if (dbg) | 73 | if (dbg) |
| 74 | DBF("%s token check failed, bitsize %d != %d\n", | 74 | DBF("%s token check failed, bitsize %d != %d\n", |
| 75 | __func__, (int) t->bitsize, keybitsize); | 75 | __func__, (int)t->bitsize, keybitsize); |
| 76 | return -EINVAL; | 76 | return -EINVAL; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| @@ -93,7 +93,7 @@ int cca_check_secaescipherkey(debug_info_t *dbg, int dbflvl, · 14 unmodified lines | |||
| 93 | const u8 *token, int keybitsize, | 93 | const u8 *token, int keybitsize, |
| 94 | int checkcpacfexport) | 94 | int checkcpacfexport) |
| 95 | { | 95 | { |
| 96 | struct cipherkeytoken *t = (struct cipherkeytoken *) token; | 96 | struct cipherkeytoken *t = (struct cipherkeytoken *)token; |
| 97 | bool keybitsizeok = true; | 97 | bool keybitsizeok = true; |
| 98 | 98 | ||
| 99 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) | 99 | #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 | |||
| 101 | if (t->type != TOKTYPE_CCA_INTERNAL) { | 101 | if (t->type != TOKTYPE_CCA_INTERNAL) { |
| 102 | if (dbg) | 102 | if (dbg) |
| 103 | DBF("%s token check failed, type 0x%02x != 0x%02x\n", | 103 | 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); |
| 105 | return -EINVAL; | 105 | return -EINVAL; |
| 106 | } | 106 | } |
| 107 | if (t->version != TOKVER_CCA_VLSC) { | 107 | if (t->version != TOKVER_CCA_VLSC) { |
| 108 | if (dbg) | 108 | if (dbg) |
| 109 | DBF("%s token check failed, version 0x%02x != 0x%02x\n", | 109 | 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); |
| 111 | return -EINVAL; | 111 | return -EINVAL; |
| 112 | } | 112 | } |
| 113 | if (t->algtype != 0x02) { | 113 | if (t->algtype != 0x02) { |
| 114 | if (dbg) | 114 | if (dbg) |
| 115 | DBF("%s token check failed, algtype 0x%02x != 0x02\n", | 115 | DBF("%s token check failed, algtype 0x%02x != 0x02\n", |
| 116 | __func__, (int) t->algtype); | 116 | __func__, (int)t->algtype); |
| 117 | return -EINVAL; | 117 | return -EINVAL; |
| 118 | } | 118 | } |
| 119 | if (t->keytype != 0x0001) { | 119 | if (t->keytype != 0x0001) { |
| 120 | if (dbg) | 120 | if (dbg) |
| 121 | DBF("%s token check failed, keytype 0x%04x != 0x0001\n", | 121 | DBF("%s token check failed, keytype 0x%04x != 0x0001\n", |
| 122 | __func__, (int) t->keytype); | 122 | __func__, (int)t->keytype); |
| 123 | return -EINVAL; | 123 | return -EINVAL; |
| 124 | } | 124 | } |
| 125 | if (t->plfver != 0x00 && t->plfver != 0x01) { | 125 | if (t->plfver != 0x00 && t->plfver != 0x01) { |
| 126 | if (dbg) | 126 | if (dbg) |
| 127 | DBF("%s token check failed, unknown plfver 0x%02x\n", | 127 | DBF("%s token check failed, unknown plfver 0x%02x\n", |
| 128 | __func__, (int) t->plfver); | 128 | __func__, (int)t->plfver); |
| 129 | return -EINVAL; | 129 | return -EINVAL; |
| 130 | } | 130 | } |
| 131 | if (t->wpllen != 512 && t->wpllen != 576 && t->wpllen != 640) { | 131 | if (t->wpllen != 512 && t->wpllen != 576 && t->wpllen != 640) { |
| 132 | if (dbg) | 132 | if (dbg) |
| 133 | DBF("%s token check failed, unknown wpllen %d\n", | 133 | DBF("%s token check failed, unknown wpllen %d\n", |
| 134 | __func__, (int) t->wpllen); | 134 | __func__, (int)t->wpllen); |
| 135 | return -EINVAL; | 135 | return -EINVAL; |
| 136 | } | 136 | } |
| 137 | if (keybitsize > 0) { | 137 | if (keybitsize > 0) { |
| @@ -180,26 +180,26 @@ int cca_check_sececckeytoken(debug_info_t *dbg, int dbflvl, · 42 unmodified lines | |||
| 180 | const u8 *token, size_t keysize, | 180 | const u8 *token, size_t keysize, |
| 181 | int checkcpacfexport) | 181 | int checkcpacfexport) |
| 182 | { | 182 | { |
| 183 | struct eccprivkeytoken *t = (struct eccprivkeytoken *) token; | 183 | struct eccprivkeytoken *t = (struct eccprivkeytoken *)token; |
| 184 | 184 | ||
| 185 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) | 185 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) |
| 186 | 186 | ||
| 187 | if (t->type != TOKTYPE_CCA_INTERNAL_PKA) { | 187 | if (t->type != TOKTYPE_CCA_INTERNAL_PKA) { |
| 188 | if (dbg) | 188 | if (dbg) |
| 189 | DBF("%s token check failed, type 0x%02x != 0x%02x\n", | 189 | 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); |
| 191 | return -EINVAL; | 191 | return -EINVAL; |
| 192 | } | 192 | } |
| 193 | if (t->len > keysize) { | 193 | if (t->len > keysize) { |
| 194 | if (dbg) | 194 | if (dbg) |
| 195 | DBF("%s token check failed, len %d > keysize %zu\n", | 195 | DBF("%s token check failed, len %d > keysize %zu\n", |
| 196 | __func__, (int) t->len, keysize); | 196 | __func__, (int)t->len, keysize); |
| 197 | return -EINVAL; | 197 | return -EINVAL; |
| 198 | } | 198 | } |
| 199 | if (t->secid != 0x20) { | 199 | if (t->secid != 0x20) { |
| 200 | if (dbg) | 200 | if (dbg) |
| 201 | DBF("%s token check failed, secid 0x%02x != 0x20\n", | 201 | DBF("%s token check failed, secid 0x%02x != 0x20\n", |
| 202 | __func__, (int) t->secid); | 202 | __func__, (int)t->secid); |
| 203 | return -EINVAL; | 203 | return -EINVAL; |
| 204 | } | 204 | } |
| 205 | if (checkcpacfexport && !(t->kutc & 0x01)) { | 205 | if (checkcpacfexport && !(t->kutc & 0x01)) { |
| @@ -222,9 +222,9 @@ EXPORT_SYMBOL(cca_check_sececckeytoken); · 16 unmodified lines | |||
| 222 | * on failure. | 222 | * on failure. |
| 223 | */ | 223 | */ |
| 224 | static int alloc_and_prep_cprbmem(size_t paramblen, | 224 | static int alloc_and_prep_cprbmem(size_t paramblen, |
| 225 | u8 **pcprbmem, | 225 | u8 **p_cprb_mem, |
| 226 | struct CPRBX **preqCPRB, | 226 | struct CPRBX **p_req_cprb, |
| 227 | struct CPRBX **prepCPRB) | 227 | struct CPRBX **p_rep_cprb) |
| 228 | { | 228 | { |
| 229 | u8 *cprbmem; | 229 | u8 *cprbmem; |
| 230 | size_t cprbplusparamblen = sizeof(struct CPRBX) + paramblen; | 230 | size_t cprbplusparamblen = sizeof(struct CPRBX) + paramblen; |
| @@ -238,8 +238,8 @@ static int alloc_and_prep_cprbmem(size_t paramblen, · 7 unmodified lines | |||
| 238 | if (!cprbmem) | 238 | if (!cprbmem) |
| 239 | return -ENOMEM; | 239 | return -ENOMEM; |
| 240 | 240 | ||
| 241 | preqcblk = (struct CPRBX *) cprbmem; | 241 | preqcblk = (struct CPRBX *)cprbmem; |
| 242 | prepcblk = (struct CPRBX *) (cprbmem + cprbplusparamblen); | 242 | prepcblk = (struct CPRBX *)(cprbmem + cprbplusparamblen); |
| 243 | 243 | ||
| 244 | /* fill request cprb struct */ | 244 | /* fill request cprb struct */ |
| 245 | preqcblk->cprb_len = sizeof(struct CPRBX); | 245 | preqcblk->cprb_len = sizeof(struct CPRBX); |
| @@ -248,14 +248,14 @@ static int alloc_and_prep_cprbmem(size_t paramblen, · 2 unmodified lines | |||
| 248 | preqcblk->rpl_msgbl = cprbplusparamblen; | 248 | preqcblk->rpl_msgbl = cprbplusparamblen; |
| 249 | if (paramblen) { | 249 | if (paramblen) { |
| 250 | preqcblk->req_parmb = | 250 | preqcblk->req_parmb = |
| 251 | ((u8 __user *) preqcblk) + sizeof(struct CPRBX); | 251 | ((u8 __user *)preqcblk) + sizeof(struct CPRBX); |
| 252 | preqcblk->rpl_parmb = | 252 | preqcblk->rpl_parmb = |
| 253 | ((u8 __user *) prepcblk) + sizeof(struct CPRBX); | 253 | ((u8 __user *)prepcblk) + sizeof(struct CPRBX); |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | *pcprbmem = cprbmem; | 256 | *p_cprb_mem = cprbmem; |
| 257 | *preqCPRB = preqcblk; | 257 | *p_req_cprb = preqcblk; |
| 258 | *prepCPRB = prepcblk; | 258 | *p_rep_cprb = prepcblk; |
| 259 | 259 | ||
| 260 | return 0; | 260 | return 0; |
| 261 | } | 261 | } |
| @@ -286,9 +286,9 @@ static inline void prep_xcrb(struct ica_xcRB *pxcrb, · 24 unmodified lines | |||
| 286 | pxcrb->user_defined = (cardnr == 0xFFFF ? AUTOSELECT : cardnr); | 286 | pxcrb->user_defined = (cardnr == 0xFFFF ? AUTOSELECT : cardnr); |
| 287 | pxcrb->request_control_blk_length = | 287 | pxcrb->request_control_blk_length = |
| 288 | preqcblk->cprb_len + preqcblk->req_parml; | 288 | preqcblk->cprb_len + preqcblk->req_parml; |
| 289 | pxcrb->request_control_blk_addr = (void __user *) preqcblk; | 289 | pxcrb->request_control_blk_addr = (void __user *)preqcblk; |
| 290 | pxcrb->reply_control_blk_length = preqcblk->rpl_msgbl; | 290 | 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; |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | /* | 294 | /* |
| @@ -345,7 +345,7 @@ int cca_genseckey(u16 cardnr, u16 domain, · 50 unmodified lines | |||
| 345 | preqcblk->domain = domain; | 345 | preqcblk->domain = domain; |
| 346 | 346 | ||
| 347 | /* fill request cprb param block with KG request */ | 347 | /* fill request cprb param block with KG request */ |
| 348 | preqparm = (struct kgreqparm __force *) preqcblk->req_parmb; | 348 | preqparm = (struct kgreqparm __force *)preqcblk->req_parmb; |
| 349 | memcpy(preqparm->subfunc_code, "KG", 2); | 349 | memcpy(preqparm->subfunc_code, "KG", 2); |
| 350 | preqparm->rule_array_len = sizeof(preqparm->rule_array_len); | 350 | preqparm->rule_array_len = sizeof(preqparm->rule_array_len); |
| 351 | preqparm->lv1.len = sizeof(struct lv1); | 351 | preqparm->lv1.len = sizeof(struct lv1); |
| @@ -387,7 +387,7 @@ int cca_genseckey(u16 cardnr, u16 domain, · 35 unmodified lines | |||
| 387 | rc = zcrypt_send_cprb(&xcrb); | 387 | rc = zcrypt_send_cprb(&xcrb); |
| 388 | if (rc) { | 388 | if (rc) { |
| 389 | DEBUG_ERR("%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, errno %d\n", | 389 | 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); |
| 391 | goto out; | 391 | goto out; |
| 392 | } | 392 | } |
| 393 | 393 | ||
| @@ -395,16 +395,16 @@ int cca_genseckey(u16 cardnr, u16 domain, · 1 unmodified line | |||
| 395 | if (prepcblk->ccp_rtcode != 0) { | 395 | if (prepcblk->ccp_rtcode != 0) { |
| 396 | DEBUG_ERR("%s secure key generate failure, card response %d/%d\n", | 396 | DEBUG_ERR("%s secure key generate failure, card response %d/%d\n", |
| 397 | __func__, | 397 | __func__, |
| 398 | (int) prepcblk->ccp_rtcode, | 398 | (int)prepcblk->ccp_rtcode, |
| 399 | (int) prepcblk->ccp_rscode); | 399 | (int)prepcblk->ccp_rscode); |
| 400 | rc = -EIO; | 400 | rc = -EIO; |
| 401 | goto out; | 401 | goto out; |
| 402 | } | 402 | } |
| 403 | 403 | ||
| 404 | /* process response cprb param block */ | 404 | /* process response cprb param block */ |
| 405 | ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX); | 405 | ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX); |
| 406 | prepcblk->rpl_parmb = (u8 __user *) ptr; | 406 | prepcblk->rpl_parmb = (u8 __user *)ptr; |
| 407 | prepparm = (struct kgrepparm *) ptr; | 407 | prepparm = (struct kgrepparm *)ptr; |
| 408 | 408 | ||
| 409 | /* check length of the returned secure key token */ | 409 | /* check length of the returned secure key token */ |
| 410 | seckeysize = prepparm->lv3.keyblock.toklen | 410 | seckeysize = prepparm->lv3.keyblock.toklen |
| @@ -419,7 +419,7 @@ int cca_genseckey(u16 cardnr, u16 domain, · 8 unmodified lines | |||
| 419 | 419 | ||
| 420 | /* check secure key token */ | 420 | /* check secure key token */ |
| 421 | rc = cca_check_secaeskeytoken(zcrypt_dbf_info, DBF_ERR, | 421 | rc = cca_check_secaeskeytoken(zcrypt_dbf_info, DBF_ERR, |
| 422 | prepparm->lv3.keyblock.tok, 8*keysize); | 422 | prepparm->lv3.keyblock.tok, 8 * keysize); |
| 423 | if (rc) { | 423 | if (rc) { |
| 424 | rc = -EIO; | 424 | rc = -EIO; |
| 425 | goto out; | 425 | goto out; |
| @@ -486,7 +486,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 60 unmodified lines | |||
| 486 | preqcblk->domain = domain; | 486 | preqcblk->domain = domain; |
| 487 | 487 | ||
| 488 | /* fill request cprb param block with CM request */ | 488 | /* fill request cprb param block with CM request */ |
| 489 | preqparm = (struct cmreqparm __force *) preqcblk->req_parmb; | 489 | preqparm = (struct cmreqparm __force *)preqcblk->req_parmb; |
| 490 | memcpy(preqparm->subfunc_code, "CM", 2); | 490 | memcpy(preqparm->subfunc_code, "CM", 2); |
| 491 | memcpy(preqparm->rule_array, "AES ", 8); | 491 | memcpy(preqparm->rule_array, "AES ", 8); |
| 492 | preqparm->rule_array_len = | 492 | preqparm->rule_array_len = |
| @@ -512,7 +512,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 19 unmodified lines | |||
| 512 | } | 512 | } |
| 513 | preqparm->lv1.len = sizeof(struct lv1) + keysize; | 513 | preqparm->lv1.len = sizeof(struct lv1) + keysize; |
| 514 | memcpy(preqparm->lv1.clrkey, clrkey, keysize); | 514 | memcpy(preqparm->lv1.clrkey, clrkey, keysize); |
| 515 | plv2 = (struct lv2 *) (((u8 *) &preqparm->lv2) + keysize); | 515 | plv2 = (struct lv2 *)(((u8 *)&preqparm->lv2) + keysize); |
| 516 | plv2->len = sizeof(struct lv2); | 516 | plv2->len = sizeof(struct lv2); |
| 517 | plv2->keyid.len = sizeof(struct keyid); | 517 | plv2->keyid.len = sizeof(struct keyid); |
| 518 | plv2->keyid.attr = 0x30; | 518 | plv2->keyid.attr = 0x30; |
| @@ -525,7 +525,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 6 unmodified lines | |||
| 525 | rc = zcrypt_send_cprb(&xcrb); | 525 | rc = zcrypt_send_cprb(&xcrb); |
| 526 | if (rc) { | 526 | if (rc) { |
| 527 | DEBUG_ERR("%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n", | 527 | 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); |
| 529 | goto out; | 529 | goto out; |
| 530 | } | 530 | } |
| 531 | 531 | ||
| @@ -533,16 +533,16 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 1 unmodified line | |||
| 533 | if (prepcblk->ccp_rtcode != 0) { | 533 | if (prepcblk->ccp_rtcode != 0) { |
| 534 | DEBUG_ERR("%s clear key import failure, card response %d/%d\n", | 534 | DEBUG_ERR("%s clear key import failure, card response %d/%d\n", |
| 535 | __func__, | 535 | __func__, |
| 536 | (int) prepcblk->ccp_rtcode, | 536 | (int)prepcblk->ccp_rtcode, |
| 537 | (int) prepcblk->ccp_rscode); | 537 | (int)prepcblk->ccp_rscode); |
| 538 | rc = -EIO; | 538 | rc = -EIO; |
| 539 | goto out; | 539 | goto out; |
| 540 | } | 540 | } |
| 541 | 541 | ||
| 542 | /* process response cprb param block */ | 542 | /* process response cprb param block */ |
| 543 | ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX); | 543 | ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX); |
| 544 | prepcblk->rpl_parmb = (u8 __user *) ptr; | 544 | prepcblk->rpl_parmb = (u8 __user *)ptr; |
| 545 | prepparm = (struct cmrepparm *) ptr; | 545 | prepparm = (struct cmrepparm *)ptr; |
| 546 | 546 | ||
| 547 | /* check length of the returned secure key token */ | 547 | /* check length of the returned secure key token */ |
| 548 | seckeysize = prepparm->lv3.keyblock.toklen | 548 | seckeysize = prepparm->lv3.keyblock.toklen |
| @@ -557,7 +557,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, · 8 unmodified lines | |||
| 557 | 557 | ||
| 558 | /* check secure key token */ | 558 | /* check secure key token */ |
| 559 | rc = cca_check_secaeskeytoken(zcrypt_dbf_info, DBF_ERR, | 559 | rc = cca_check_secaeskeytoken(zcrypt_dbf_info, DBF_ERR, |
| 560 | prepparm->lv3.keyblock.tok, 8*keysize); | 560 | prepparm->lv3.keyblock.tok, 8 * keysize); |
| 561 | if (rc) { | 561 | if (rc) { |
| 562 | rc = -EIO; | 562 | rc = -EIO; |
| 563 | goto out; | 563 | goto out; |
| @@ -632,7 +632,7 @@ int cca_sec2protkey(u16 cardnr, u16 domain, · 68 unmodified lines | |||
| 632 | preqcblk->domain = domain; | 632 | preqcblk->domain = domain; |
| 633 | 633 | ||
| 634 | /* fill request cprb param block with USK request */ | 634 | /* fill request cprb param block with USK request */ |
| 635 | preqparm = (struct uskreqparm __force *) preqcblk->req_parmb; | 635 | preqparm = (struct uskreqparm __force *)preqcblk->req_parmb; |
| 636 | memcpy(preqparm->subfunc_code, "US", 2); | 636 | memcpy(preqparm->subfunc_code, "US", 2); |
| 637 | preqparm->rule_array_len = sizeof(preqparm->rule_array_len); | 637 | preqparm->rule_array_len = sizeof(preqparm->rule_array_len); |
| 638 | preqparm->lv1.len = sizeof(struct lv1); | 638 | preqparm->lv1.len = sizeof(struct lv1); |
| @@ -652,7 +652,7 @@ int cca_sec2protkey(u16 cardnr, u16 domain, · 13 unmodified lines | |||
| 652 | rc = zcrypt_send_cprb(&xcrb); | 652 | rc = zcrypt_send_cprb(&xcrb); |
| 653 | if (rc) { | 653 | if (rc) { |
| 654 | DEBUG_ERR("%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n", | 654 | 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); |
| 656 | goto out; | 656 | goto out; |
| 657 | } | 657 | } |
| 658 | 658 | ||
| @@ -660,8 +660,8 @@ int cca_sec2protkey(u16 cardnr, u16 domain, · 1 unmodified line | |||
| 660 | if (prepcblk->ccp_rtcode != 0) { | 660 | if (prepcblk->ccp_rtcode != 0) { |
| 661 | DEBUG_ERR("%s unwrap secure key failure, card response %d/%d\n", | 661 | DEBUG_ERR("%s unwrap secure key failure, card response %d/%d\n", |
| 662 | __func__, | 662 | __func__, |
| 663 | (int) prepcblk->ccp_rtcode, | 663 | (int)prepcblk->ccp_rtcode, |
| 664 | (int) prepcblk->ccp_rscode); | 664 | (int)prepcblk->ccp_rscode); |
| 665 | if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290) | 665 | if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290) |
| 666 | rc = -EAGAIN; | 666 | rc = -EAGAIN; |
| 667 | else | 667 | else |
| @@ -671,37 +671,37 @@ int cca_sec2protkey(u16 cardnr, u16 domain, · 3 unmodified lines | |||
| 671 | if (prepcblk->ccp_rscode != 0) { | 671 | if (prepcblk->ccp_rscode != 0) { |
| 672 | DEBUG_WARN("%s unwrap secure key warning, card response %d/%d\n", | 672 | DEBUG_WARN("%s unwrap secure key warning, card response %d/%d\n", |
| 673 | __func__, | 673 | __func__, |
| 674 | (int) prepcblk->ccp_rtcode, | 674 | (int)prepcblk->ccp_rtcode, |
| 675 | (int) prepcblk->ccp_rscode); | 675 | (int)prepcblk->ccp_rscode); |
| 676 | } | 676 | } |
| 677 | 677 | ||
| 678 | /* process response cprb param block */ | 678 | /* process response cprb param block */ |
| 679 | ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX); | 679 | ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX); |
| 680 | prepcblk->rpl_parmb = (u8 __user *) ptr; | 680 | prepcblk->rpl_parmb = (u8 __user *)ptr; |
| 681 | prepparm = (struct uskrepparm *) ptr; | 681 | prepparm = (struct uskrepparm *)ptr; |
| 682 | 682 | ||
| 683 | /* check the returned keyblock */ | 683 | /* check the returned keyblock */ |
| 684 | if (prepparm->lv3.ckb.version != 0x01 && | 684 | if (prepparm->lv3.ckb.version != 0x01 && |
| 685 | prepparm->lv3.ckb.version != 0x02) { | 685 | prepparm->lv3.ckb.version != 0x02) { |
| 686 | DEBUG_ERR("%s reply param keyblock version mismatch 0x%02x\n", | 686 | 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); |
| 688 | rc = -EIO; | 688 | rc = -EIO; |
| 689 | goto out; | 689 | goto out; |
| 690 | } | 690 | } |
| 691 | 691 | ||
| 692 | /* copy the tanslated protected key */ | 692 | /* copy the tanslated protected key */ |
| 693 | switch (prepparm->lv3.ckb.len) { | 693 | switch (prepparm->lv3.ckb.len) { |
| 694 | case 16+32: | 694 | case 16 + 32: |
| 695 | /* AES 128 protected key */ | 695 | /* AES 128 protected key */ |
| 696 | if (protkeytype) | 696 | if (protkeytype) |
| 697 | *protkeytype = PKEY_KEYTYPE_AES_128; | 697 | *protkeytype = PKEY_KEYTYPE_AES_128; |
| 698 | break; | 698 | break; |
| 699 | case 24+32: | 699 | case 24 + 32: |
| 700 | /* AES 192 protected key */ | 700 | /* AES 192 protected key */ |
| 701 | if (protkeytype) | 701 | if (protkeytype) |
| 702 | *protkeytype = PKEY_KEYTYPE_AES_192; | 702 | *protkeytype = PKEY_KEYTYPE_AES_192; |
| 703 | break; | 703 | break; |
| 704 | case 32+32: | 704 | case 32 + 32: |
| 705 | /* AES 256 protected key */ | 705 | /* AES 256 protected key */ |
| 706 | if (protkeytype) | 706 | if (protkeytype) |
| 707 | *protkeytype = PKEY_KEYTYPE_AES_256; | 707 | *protkeytype = PKEY_KEYTYPE_AES_256; |
| @@ -751,7 +751,7 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 43 unmodified lines | |||
| 751 | struct gkreqparm { | 751 | struct gkreqparm { |
| 752 | u8 subfunc_code[2]; | 752 | u8 subfunc_code[2]; |
| 753 | u16 rule_array_len; | 753 | u16 rule_array_len; |
| 754 | char rule_array[2*8]; | 754 | char rule_array[2 * 8]; |
| 755 | struct { | 755 | struct { |
| 756 | u16 len; | 756 | u16 len; |
| 757 | u8 key_type_1[8]; | 757 | u8 key_type_1[8]; |
| @@ -827,10 +827,10 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 69 unmodified lines | |||
| 827 | preqcblk->req_parml = sizeof(struct gkreqparm); | 827 | preqcblk->req_parml = sizeof(struct gkreqparm); |
| 828 | 828 | ||
| 829 | /* prepare request param block with GK request */ | 829 | /* prepare request param block with GK request */ |
| 830 | preqparm = (struct gkreqparm __force *) preqcblk->req_parmb; | 830 | preqparm = (struct gkreqparm __force *)preqcblk->req_parmb; |
| 831 | memcpy(preqparm->subfunc_code, "GK", 2); | 831 | memcpy(preqparm->subfunc_code, "GK", 2); |
| 832 | preqparm->rule_array_len = sizeof(uint16_t) + 2 * 8; | 832 | 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); |
| 834 | 834 | ||
| 835 | /* prepare vud block */ | 835 | /* prepare vud block */ |
| 836 | preqparm->vud.len = sizeof(preqparm->vud); | 836 | preqparm->vud.len = sizeof(preqparm->vud); |
| @@ -869,9 +869,9 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 32 unmodified lines | |||
| 869 | 869 | ||
| 870 | /* patch the skeleton key token export flags inside the kb block */ | 870 | /* patch the skeleton key token export flags inside the kb block */ |
| 871 | if (keygenflags) { | 871 | if (keygenflags) { |
| 872 | t = (struct cipherkeytoken *) preqparm->kb.tlv3.gen_key_id_1; | 872 | t = (struct cipherkeytoken *)preqparm->kb.tlv3.gen_key_id_1; |
| 873 | t->kmf1 |= (u16) (keygenflags & 0x0000FF00); | 873 | t->kmf1 |= (u16)(keygenflags & 0x0000FF00); |
| 874 | t->kmf1 &= (u16) ~(keygenflags & 0x000000FF); | 874 | t->kmf1 &= (u16)~(keygenflags & 0x000000FF); |
| 875 | } | 875 | } |
| 876 | 876 | ||
| 877 | /* prepare xcrb struct */ | 877 | /* prepare xcrb struct */ |
| @@ -882,7 +882,7 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 4 unmodified lines | |||
| 882 | if (rc) { | 882 | if (rc) { |
| 883 | DEBUG_ERR( | 883 | DEBUG_ERR( |
| 884 | "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n", | 884 | "%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); |
| 886 | goto out; | 886 | goto out; |
| 887 | } | 887 | } |
| 888 | 888 | ||
| @@ -891,16 +891,16 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, · 2 unmodified lines | |||
| 891 | DEBUG_ERR( | 891 | DEBUG_ERR( |
| 892 | "%s cipher key generate failure, card response %d/%d\n", | 892 | "%s cipher key generate failure, card response %d/%d\n", |
| 893 | __func__, | 893 | __func__, |
| 894 | (int) prepcblk->ccp_rtcode, | 894 | (int)prepcblk->ccp_rtcode, |
| 895 | (int) prepcblk->ccp_rscode); | 895 | (int)prepcblk->ccp_rscode); |
| 896 | rc = -EIO; | 896 | rc = -EIO; |
| 897 | goto out; | 897 | goto out; |
| 898 | } | 898 | } |
| 899 | 899 | ||
| 900 | /* process response cprb param block */ | 900 | /* process response cprb param block */ |
| 901 | ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX); | 901 | ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX); |
| 902 | prepcblk->rpl_parmb = (u8 __user *) ptr; | 902 | prepcblk->rpl_parmb = (u8 __user *)ptr; |
| 903 | prepparm = (struct gkrepparm *) ptr; | 903 | prepparm = (struct gkrepparm *)ptr; |
| 904 | 904 | ||
| 905 | /* do some plausibility checks on the key block */ | 905 | /* do some plausibility checks on the key block */ |
| 906 | if (prepparm->kb.len < 120 + 5 * sizeof(uint16_t) || | 906 | 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 | |||
| 921 | } | 921 | } |
| 922 | 922 | ||
| 923 | /* copy the generated vlsc key token */ | 923 | /* copy the generated vlsc key token */ |
| 924 | t = (struct cipherkeytoken *) prepparm->kb.tlv1.gen_key; | 924 | t = (struct cipherkeytoken *)prepparm->kb.tlv1.gen_key; |
| 925 | if (keybuf) { | 925 | if (keybuf) { |
| 926 | if (*keybufsize >= t->len) | 926 | if (*keybufsize >= t->len) |
| 927 | memcpy(keybuf, t, t->len); | 927 | memcpy(keybuf, t, t->len); |
| @@ -1006,7 +1006,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, · 78 unmodified lines | |||
| 1006 | preqcblk->req_parml = 0; | 1006 | preqcblk->req_parml = 0; |
| 1007 | 1007 | ||
| 1008 | /* prepare request param block with IP request */ | 1008 | /* 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; |
| 1010 | memcpy(preq_ra_block->subfunc_code, "IP", 2); | 1010 | memcpy(preq_ra_block->subfunc_code, "IP", 2); |
| 1011 | preq_ra_block->rule_array_len = sizeof(uint16_t) + 2 * 8; | 1011 | preq_ra_block->rule_array_len = sizeof(uint16_t) + 2 * 8; |
| 1012 | memcpy(preq_ra_block->rule_array, rule_array_1, 8); | 1012 | 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 | |||
| 1050 | if (rc) { | 1050 | if (rc) { |
| 1051 | DEBUG_ERR( | 1051 | DEBUG_ERR( |
| 1052 | "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n", | 1052 | "%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); |
| 1054 | goto out; | 1054 | goto out; |
| 1055 | } | 1055 | } |
| 1056 | 1056 | ||
| @@ -1059,16 +1059,16 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, · 2 unmodified lines | |||
| 1059 | DEBUG_ERR( | 1059 | DEBUG_ERR( |
| 1060 | "%s CSNBKPI2 failure, card response %d/%d\n", | 1060 | "%s CSNBKPI2 failure, card response %d/%d\n", |
| 1061 | __func__, | 1061 | __func__, |
| 1062 | (int) prepcblk->ccp_rtcode, | 1062 | (int)prepcblk->ccp_rtcode, |
| 1063 | (int) prepcblk->ccp_rscode); | 1063 | (int)prepcblk->ccp_rscode); |
| 1064 | rc = -EIO; | 1064 | rc = -EIO; |
| 1065 | goto out; | 1065 | goto out; |
| 1066 | } | 1066 | } |
| 1067 | 1067 | ||
| 1068 | /* process response cprb param block */ | 1068 | /* process response cprb param block */ |
| 1069 | ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX); | 1069 | ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX); |
| 1070 | prepcblk->rpl_parmb = (u8 __user *) ptr; | 1070 | prepcblk->rpl_parmb = (u8 __user *)ptr; |
| 1071 | prepparm = (struct iprepparm *) ptr; | 1071 | prepparm = (struct iprepparm *)ptr; |
| 1072 | 1072 | ||
| 1073 | /* do some plausibility checks on the key block */ | 1073 | /* do some plausibility checks on the key block */ |
| 1074 | if (prepparm->kb.len < 120 + 3 * sizeof(uint16_t) || | 1074 | 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 | |||
| 1082 | /* do not check the key here, it may be incomplete */ | 1082 | /* do not check the key here, it may be incomplete */ |
| 1083 | 1083 | ||
| 1084 | /* copy the vlsc key token back */ | 1084 | /* copy the vlsc key token back */ |
| 1085 | t = (struct cipherkeytoken *) prepparm->kb.tlv1.key_token; | 1085 | t = (struct cipherkeytoken *)prepparm->kb.tlv1.key_token; |
| 1086 | memcpy(key_token, t, t->len); | 1086 | memcpy(key_token, t, t->len); |
| 1087 | *key_token_size = t->len; | 1087 | *key_token_size = t->len; |
| 1088 | 1088 | ||
| @@ -1117,9 +1117,9 @@ int cca_clr2cipherkey(u16 card, u16 dom, u32 keybitsize, u32 keygenflags, · 28 unmodified lines | |||
| 1117 | 1117 | ||
| 1118 | /* patch the skeleton key token export flags */ | 1118 | /* patch the skeleton key token export flags */ |
| 1119 | if (keygenflags) { | 1119 | if (keygenflags) { |
| 1120 | t = (struct cipherkeytoken *) token; | 1120 | t = (struct cipherkeytoken *)token; |
| 1121 | t->kmf1 |= (u16) (keygenflags & 0x0000FF00); | 1121 | t->kmf1 |= (u16)(keygenflags & 0x0000FF00); |
| 1122 | t->kmf1 &= (u16) ~(keygenflags & 0x000000FF); | 1122 | t->kmf1 &= (u16)~(keygenflags & 0x000000FF); |
| 1123 | } | 1123 | } |
| 1124 | 1124 | ||
| 1125 | /* | 1125 | /* |
| @@ -1241,7 +1241,7 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, · 115 unmodified lines | |||
| 1241 | preqcblk->domain = domain; | 1241 | preqcblk->domain = domain; |
| 1242 | 1242 | ||
| 1243 | /* fill request cprb param block with AU request */ | 1243 | /* fill request cprb param block with AU request */ |
| 1244 | preqparm = (struct aureqparm __force *) preqcblk->req_parmb; | 1244 | preqparm = (struct aureqparm __force *)preqcblk->req_parmb; |
| 1245 | memcpy(preqparm->subfunc_code, "AU", 2); | 1245 | memcpy(preqparm->subfunc_code, "AU", 2); |
| 1246 | preqparm->rule_array_len = | 1246 | preqparm->rule_array_len = |
| 1247 | sizeof(preqparm->rule_array_len) | 1247 | sizeof(preqparm->rule_array_len) |
| @@ -1267,7 +1267,7 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, · 19 unmodified lines | |||
| 1267 | if (rc) { | 1267 | if (rc) { |
| 1268 | DEBUG_ERR( | 1268 | DEBUG_ERR( |
| 1269 | "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n", | 1269 | "%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); |
| 1271 | goto out; | 1271 | goto out; |
| 1272 | } | 1272 | } |
| 1273 | 1273 | ||
| @@ -1276,8 +1276,8 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, · 2 unmodified lines | |||
| 1276 | DEBUG_ERR( | 1276 | DEBUG_ERR( |
| 1277 | "%s unwrap secure key failure, card response %d/%d\n", | 1277 | "%s unwrap secure key failure, card response %d/%d\n", |
| 1278 | __func__, | 1278 | __func__, |
| 1279 | (int) prepcblk->ccp_rtcode, | 1279 | (int)prepcblk->ccp_rtcode, |
| 1280 | (int) prepcblk->ccp_rscode); | 1280 | (int)prepcblk->ccp_rscode); |
| 1281 | if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290) | 1281 | if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290) |
| 1282 | rc = -EAGAIN; | 1282 | rc = -EAGAIN; |
| 1283 | else | 1283 | else |
| @@ -1288,44 +1288,44 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, · 4 unmodified lines | |||
| 1288 | DEBUG_WARN( | 1288 | DEBUG_WARN( |
| 1289 | "%s unwrap secure key warning, card response %d/%d\n", | 1289 | "%s unwrap secure key warning, card response %d/%d\n", |
| 1290 | __func__, | 1290 | __func__, |
| 1291 | (int) prepcblk->ccp_rtcode, | 1291 | (int)prepcblk->ccp_rtcode, |
| 1292 | (int) prepcblk->ccp_rscode); | 1292 | (int)prepcblk->ccp_rscode); |
| 1293 | } | 1293 | } |
| 1294 | 1294 | ||
| 1295 | /* process response cprb param block */ | 1295 | /* process response cprb param block */ |
| 1296 | ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX); | 1296 | ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX); |
| 1297 | prepcblk->rpl_parmb = (u8 __user *) ptr; | 1297 | prepcblk->rpl_parmb = (u8 __user *)ptr; |
| 1298 | prepparm = (struct aurepparm *) ptr; | 1298 | prepparm = (struct aurepparm *)ptr; |
| 1299 | 1299 | ||
| 1300 | /* check the returned keyblock */ | 1300 | /* check the returned keyblock */ |
| 1301 | if (prepparm->vud.ckb.version != 0x01 && | 1301 | if (prepparm->vud.ckb.version != 0x01 && |
| 1302 | prepparm->vud.ckb.version != 0x02) { | 1302 | prepparm->vud.ckb.version != 0x02) { |
| 1303 | DEBUG_ERR("%s reply param keyblock version mismatch 0x%02x\n", | 1303 | 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); |
| 1305 | rc = -EIO; | 1305 | rc = -EIO; |
| 1306 | goto out; | 1306 | goto out; |
| 1307 | } | 1307 | } |
| 1308 | if (prepparm->vud.ckb.algo != 0x02) { | 1308 | if (prepparm->vud.ckb.algo != 0x02) { |
| 1309 | DEBUG_ERR( | 1309 | DEBUG_ERR( |
| 1310 | "%s reply param keyblock algo mismatch 0x%02x != 0x02\n", | 1310 | "%s reply param keyblock algo mismatch 0x%02x != 0x02\n", |
| 1311 | __func__, (int) prepparm->vud.ckb.algo); | 1311 | __func__, (int)prepparm->vud.ckb.algo); |
| 1312 | rc = -EIO; | 1312 | rc = -EIO; |
| 1313 | goto out; | 1313 | goto out; |
| 1314 | } | 1314 | } |
| 1315 | 1315 | ||
| 1316 | /* copy the translated protected key */ | 1316 | /* copy the translated protected key */ |
| 1317 | switch (prepparm->vud.ckb.keylen) { | 1317 | switch (prepparm->vud.ckb.keylen) { |
| 1318 | case 16+32: | 1318 | case 16 + 32: |
| 1319 | /* AES 128 protected key */ | 1319 | /* AES 128 protected key */ |
| 1320 | if (protkeytype) | 1320 | if (protkeytype) |
| 1321 | *protkeytype = PKEY_KEYTYPE_AES_128; | 1321 | *protkeytype = PKEY_KEYTYPE_AES_128; |
| 1322 | break; | 1322 | break; |
| 1323 | case 24+32: | 1323 | case 24 + 32: |
| 1324 | /* AES 192 protected key */ | 1324 | /* AES 192 protected key */ |
| 1325 | if (protkeytype) | 1325 | if (protkeytype) |
| 1326 | *protkeytype = PKEY_KEYTYPE_AES_192; | 1326 | *protkeytype = PKEY_KEYTYPE_AES_192; |
| 1327 | break; | 1327 | break; |
| 1328 | case 32+32: | 1328 | case 32 + 32: |
| 1329 | /* AES 256 protected key */ | 1329 | /* AES 256 protected key */ |
| 1330 | if (protkeytype) | 1330 | if (protkeytype) |
| 1331 | *protkeytype = PKEY_KEYTYPE_AES_256; | 1331 | *protkeytype = PKEY_KEYTYPE_AES_256; |
| @@ -1410,7 +1410,7 @@ int cca_ecc2protkey(u16 cardnr, u16 domain, const u8 *key, · 78 unmodified lines | |||
| 1410 | preqcblk->domain = domain; | 1410 | preqcblk->domain = domain; |
| 1411 | 1411 | ||
| 1412 | /* fill request cprb param block with AU request */ | 1412 | /* fill request cprb param block with AU request */ |
| 1413 | preqparm = (struct aureqparm __force *) preqcblk->req_parmb; | 1413 | preqparm = (struct aureqparm __force *)preqcblk->req_parmb; |
| 1414 | memcpy(preqparm->subfunc_code, "AU", 2); | 1414 | memcpy(preqparm->subfunc_code, "AU", 2); |
| 1415 | preqparm->rule_array_len = | 1415 | preqparm->rule_array_len = |
| 1416 | sizeof(preqparm->rule_array_len) | 1416 | sizeof(preqparm->rule_array_len) |
| @@ -1436,7 +1436,7 @@ int cca_ecc2protkey(u16 cardnr, u16 domain, const u8 *key, · 19 unmodified lines | |||
| 1436 | if (rc) { | 1436 | if (rc) { |
| 1437 | DEBUG_ERR( | 1437 | DEBUG_ERR( |
| 1438 | "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n", | 1438 | "%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); |
| 1440 | goto out; | 1440 | goto out; |
| 1441 | } | 1441 | } |
| 1442 | 1442 | ||
| @@ -1445,8 +1445,8 @@ int cca_ecc2protkey(u16 cardnr, u16 domain, const u8 *key, · 2 unmodified lines | |||
| 1445 | DEBUG_ERR( | 1445 | DEBUG_ERR( |
| 1446 | "%s unwrap secure key failure, card response %d/%d\n", | 1446 | "%s unwrap secure key failure, card response %d/%d\n", |
| 1447 | __func__, | 1447 | __func__, |
| 1448 | (int) prepcblk->ccp_rtcode, | 1448 | (int)prepcblk->ccp_rtcode, |
| 1449 | (int) prepcblk->ccp_rscode); | 1449 | (int)prepcblk->ccp_rscode); |
| 1450 | if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290) | 1450 | if (prepcblk->ccp_rtcode == 8 && prepcblk->ccp_rscode == 2290) |
| 1451 | rc = -EAGAIN; | 1451 | rc = -EAGAIN; |
| 1452 | else | 1452 | else |
| @@ -1457,26 +1457,26 @@ int cca_ecc2protkey(u16 cardnr, u16 domain, const u8 *key, · 4 unmodified lines | |||
| 1457 | DEBUG_WARN( | 1457 | DEBUG_WARN( |
| 1458 | "%s unwrap secure key warning, card response %d/%d\n", | 1458 | "%s unwrap secure key warning, card response %d/%d\n", |
| 1459 | __func__, | 1459 | __func__, |
| 1460 | (int) prepcblk->ccp_rtcode, | 1460 | (int)prepcblk->ccp_rtcode, |
| 1461 | (int) prepcblk->ccp_rscode); | 1461 | (int)prepcblk->ccp_rscode); |
| 1462 | } | 1462 | } |
| 1463 | 1463 | ||
| 1464 | /* process response cprb param block */ | 1464 | /* process response cprb param block */ |
| 1465 | ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX); | 1465 | ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX); |
| 1466 | prepcblk->rpl_parmb = (u8 __user *) ptr; | 1466 | prepcblk->rpl_parmb = (u8 __user *)ptr; |
| 1467 | prepparm = (struct aurepparm *) ptr; | 1467 | prepparm = (struct aurepparm *)ptr; |
| 1468 | 1468 | ||
| 1469 | /* check the returned keyblock */ | 1469 | /* check the returned keyblock */ |
| 1470 | if (prepparm->vud.ckb.version != 0x02) { | 1470 | if (prepparm->vud.ckb.version != 0x02) { |
| 1471 | DEBUG_ERR("%s reply param keyblock version mismatch 0x%02x != 0x02\n", | 1471 | 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); |
| 1473 | rc = -EIO; | 1473 | rc = -EIO; |
| 1474 | goto out; | 1474 | goto out; |
| 1475 | } | 1475 | } |
| 1476 | if (prepparm->vud.ckb.algo != 0x81) { | 1476 | if (prepparm->vud.ckb.algo != 0x81) { |
| 1477 | DEBUG_ERR( | 1477 | DEBUG_ERR( |
| 1478 | "%s reply param keyblock algo mismatch 0x%02x != 0x81\n", | 1478 | "%s reply param keyblock algo mismatch 0x%02x != 0x81\n", |
| 1479 | __func__, (int) prepparm->vud.ckb.algo); | 1479 | __func__, (int)prepparm->vud.ckb.algo); |
| 1480 | rc = -EIO; | 1480 | rc = -EIO; |
| 1481 | goto out; | 1481 | goto out; |
| 1482 | } | 1482 | } |
| @@ -1537,7 +1537,7 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, · 54 unmodified lines | |||
| 1537 | preqcblk->domain = domain; | 1537 | preqcblk->domain = domain; |
| 1538 | 1538 | ||
| 1539 | /* fill request cprb param block with FQ request */ | 1539 | /* fill request cprb param block with FQ request */ |
| 1540 | preqparm = (struct fqreqparm __force *) preqcblk->req_parmb; | 1540 | preqparm = (struct fqreqparm __force *)preqcblk->req_parmb; |
| 1541 | memcpy(preqparm->subfunc_code, "FQ", 2); | 1541 | memcpy(preqparm->subfunc_code, "FQ", 2); |
| 1542 | memcpy(preqparm->rule_array, keyword, sizeof(preqparm->rule_array)); | 1542 | memcpy(preqparm->rule_array, keyword, sizeof(preqparm->rule_array)); |
| 1543 | preqparm->rule_array_len = | 1543 | preqparm->rule_array_len = |
| @@ -1553,7 +1553,7 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, · 9 unmodified lines | |||
| 1553 | rc = zcrypt_send_cprb(&xcrb); | 1553 | rc = zcrypt_send_cprb(&xcrb); |
| 1554 | if (rc) { | 1554 | if (rc) { |
| 1555 | DEBUG_ERR("%s zcrypt_send_cprb (cardnr=%d domain=%d) failed, rc=%d\n", | 1555 | 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); |
| 1557 | goto out; | 1557 | goto out; |
| 1558 | } | 1558 | } |
| 1559 | 1559 | ||
| @@ -1561,20 +1561,20 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, · 1 unmodified line | |||
| 1561 | if (prepcblk->ccp_rtcode != 0) { | 1561 | if (prepcblk->ccp_rtcode != 0) { |
| 1562 | DEBUG_ERR("%s unwrap secure key failure, card response %d/%d\n", | 1562 | DEBUG_ERR("%s unwrap secure key failure, card response %d/%d\n", |
| 1563 | __func__, | 1563 | __func__, |
| 1564 | (int) prepcblk->ccp_rtcode, | 1564 | (int)prepcblk->ccp_rtcode, |
| 1565 | (int) prepcblk->ccp_rscode); | 1565 | (int)prepcblk->ccp_rscode); |
| 1566 | rc = -EIO; | 1566 | rc = -EIO; |
| 1567 | goto out; | 1567 | goto out; |
| 1568 | } | 1568 | } |
| 1569 | 1569 | ||
| 1570 | /* process response cprb param block */ | 1570 | /* process response cprb param block */ |
| 1571 | ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX); | 1571 | ptr = ((u8 *)prepcblk) + sizeof(struct CPRBX); |
| 1572 | prepcblk->rpl_parmb = (u8 __user *) ptr; | 1572 | prepcblk->rpl_parmb = (u8 __user *)ptr; |
| 1573 | prepparm = (struct fqrepparm *) ptr; | 1573 | prepparm = (struct fqrepparm *)ptr; |
| 1574 | ptr = prepparm->lvdata; | 1574 | ptr = prepparm->lvdata; |
| 1575 | 1575 | ||
| 1576 | /* check and possibly copy reply rule array */ | 1576 | /* check and possibly copy reply rule array */ |
| 1577 | len = *((u16 *) ptr); | 1577 | len = *((u16 *)ptr); |
| 1578 | if (len > sizeof(u16)) { | 1578 | if (len > sizeof(u16)) { |
| 1579 | ptr += sizeof(u16); | 1579 | ptr += sizeof(u16); |
| 1580 | len -= sizeof(u16); | 1580 | len -= sizeof(u16); |
| @@ -1585,7 +1585,7 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, · 4 unmodified lines | |||
| 1585 | ptr += len; | 1585 | ptr += len; |
| 1586 | } | 1586 | } |
| 1587 | /* check and possible copy reply var array */ | 1587 | /* check and possible copy reply var array */ |
| 1588 | len = *((u16 *) ptr); | 1588 | len = *((u16 *)ptr); |
| 1589 | if (len > sizeof(u16)) { | 1589 | if (len > sizeof(u16)) { |
| 1590 | ptr += sizeof(u16); | 1590 | ptr += sizeof(u16); |
| 1591 | len -= sizeof(u16); | 1591 | len -= sizeof(u16); |
| @@ -1696,21 +1696,30 @@ static int fetch_cca_info(u16 cardnr, u16 domain, struct cca_info *ci) · 104 unmodified lines | |||
| 1696 | ci->hwtype = devstat.hwtype; | 1696 | ci->hwtype = devstat.hwtype; |
| 1697 | 1697 | ||
| 1698 | /* prep page for rule array and var array use */ | 1698 | /* 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); |
| 1700 | if (!pg) | 1700 | if (!pg) |
| 1701 | return -ENOMEM; | 1701 | return -ENOMEM; |
| 1702 | rarray = pg; | 1702 | rarray = pg; |
| 1703 | varray = pg + PAGE_SIZE/2; | 1703 | varray = pg + PAGE_SIZE / 2; |
| 1704 | rlen = vlen = PAGE_SIZE/2; | 1704 | rlen = vlen = PAGE_SIZE / 2; |
| 1705 | 1705 | ||
| 1706 | /* QF for this card/domain */ | 1706 | /* QF for this card/domain */ |
| 1707 | rc = cca_query_crypto_facility(cardnr, domain, "STATICSA", | 1707 | rc = cca_query_crypto_facility(cardnr, domain, "STATICSA", |
| 1708 | rarray, &rlen, varray, &vlen); | 1708 | rarray, &rlen, varray, &vlen); |
| 1709 | if (rc == 0 && rlen >= 10*8 && vlen >= 204) { | 1709 | if (rc == 0 && rlen >= 10 * 8 && vlen >= 204) { |
| 1710 | memcpy(ci->serial, rarray, 8); | 1710 | memcpy(ci->serial, rarray, 8); |
| 1711 | ci->new_aes_mk_state = (char) rarray[7*8]; | 1711 | ci->new_asym_mk_state = (char)rarray[4 * 8]; |
| 1712 | ci->cur_aes_mk_state = (char) rarray[8*8]; | 1712 | ci->cur_asym_mk_state = (char)rarray[5 * 8]; |
| 1713 | ci->old_aes_mk_state = (char) rarray[9*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]; | ||
| 1714 | if (ci->old_aes_mk_state == '2') | 1723 | if (ci->old_aes_mk_state == '2') |
| 1715 | memcpy(&ci->old_aes_mkvp, varray + 172, 8); | 1724 | memcpy(&ci->old_aes_mkvp, varray + 172, 8); |
| 1716 | if (ci->cur_aes_mk_state == '2') | 1725 | 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 | |||
| 1721 | } | 1730 | } |
| 1722 | if (!found) | 1731 | if (!found) |
| 1723 | goto out; | 1732 | goto out; |
| 1724 | rlen = vlen = PAGE_SIZE/2; | 1733 | rlen = vlen = PAGE_SIZE / 2; |
| 1725 | rc = cca_query_crypto_facility(cardnr, domain, "STATICSB", | 1734 | rc = cca_query_crypto_facility(cardnr, domain, "STATICSB", |
| 1726 | rarray, &rlen, varray, &vlen); | 1735 | rarray, &rlen, varray, &vlen); |
| 1727 | if (rc == 0 && rlen >= 13*8 && vlen >= 240) { | 1736 | if (rc == 0 && rlen >= 13 * 8 && vlen >= 240) { |
| 1728 | ci->new_apka_mk_state = (char) rarray[10*8]; | 1737 | ci->new_apka_mk_state = (char)rarray[10 * 8]; |
| 1729 | ci->cur_apka_mk_state = (char) rarray[11*8]; | 1738 | ci->cur_apka_mk_state = (char)rarray[11 * 8]; |
| 1730 | ci->old_apka_mk_state = (char) rarray[12*8]; | 1739 | ci->old_apka_mk_state = (char)rarray[12 * 8]; |
| 1731 | if (ci->old_apka_mk_state == '2') | 1740 | if (ci->old_apka_mk_state == '2') |
| 1732 | memcpy(&ci->old_apka_mkvp, varray + 208, 8); | 1741 | memcpy(&ci->old_apka_mkvp, varray + 208, 8); |
| 1733 | if (ci->cur_apka_mk_state == '2') | 1742 | 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 | |||
| 1738 | } | 1747 | } |
| 1739 | 1748 | ||
| 1740 | out: | 1749 | out: |
| 1741 | free_page((unsigned long) pg); | 1750 | free_page((unsigned long)pg); |
| 1742 | return found == 2 ? 0 : -ENOENT; | 1751 | return found == 2 ? 0 : -ENOENT; |
| 1743 | } | 1752 | } |
| 1744 | 1753 | ||
| @@ -1846,8 +1855,9 @@ static int findcard(u64 mkvp, u16 *pcardnr, u16 *pdomain, · 101 unmodified lines | |||
| 1846 | if (pdomain) | 1855 | if (pdomain) |
| 1847 | *pdomain = dom; | 1856 | *pdomain = dom; |
| 1848 | rc = (i < MAX_ZDEV_ENTRIES_EXT ? 0 : 1); | 1857 | rc = (i < MAX_ZDEV_ENTRIES_EXT ? 0 : 1); |
| 1849 | } else | 1858 | } else { |
| 1850 | rc = -ENODEV; | 1859 | rc = -ENODEV; |
| 1860 | } | ||
| 1851 | 1861 | ||
| 1852 | kvfree(device_status); | 1862 | kvfree(device_status); |
| 1853 | return rc; | 1863 | return rc; |
| @@ -1861,7 +1871,7 @@ int cca_findcard(const u8 *key, u16 *pcardnr, u16 *pdomain, int verify) · 7 unmodified lines | |||
| 1861 | { | 1871 | { |
| 1862 | u64 mkvp; | 1872 | u64 mkvp; |
| 1863 | int minhwtype = 0; | 1873 | int minhwtype = 0; |
| 1864 | const struct keytoken_header *hdr = (struct keytoken_header *) key; | 1874 | const struct keytoken_header *hdr = (struct keytoken_header *)key; |
| 1865 | 1875 | ||
| 1866 | if (hdr->type != TOKTYPE_CCA_INTERNAL) | 1876 | if (hdr->type != TOKTYPE_CCA_INTERNAL) |
| 1867 | return -EINVAL; | 1877 | return -EINVAL; |
| @@ -1954,7 +1964,7 @@ int cca_findcard2(u32 **apqns, u32 *nr_apqns, u16 cardnr, u16 domain, · 86 unmodified lines | |||
| 1954 | } | 1964 | } |
| 1955 | /* apqn passed all filtering criterons, add to the array */ | 1965 | /* apqn passed all filtering criterons, add to the array */ |
| 1956 | if (_nr_apqns < 256) | 1966 | if (_nr_apqns < 256) |
| 1957 | _apqns[_nr_apqns++] = (((u16)card) << 16) | ((u16) dom); | 1967 | _apqns[_nr_apqns++] = (((u16)card) << 16) | ((u16)dom); |
| 1958 | } | 1968 | } |
| 1959 | 1969 | ||
| 1960 | /* nothing found ? */ | 1970 | /* nothing found ? */ |
| @@ -251,12 +251,18 @@ struct cca_info { · 250 unmodified lines | |||
| 251 | char new_apka_mk_state; /* '1' empty, '2' partially full, '3' full */ | 251 | char new_apka_mk_state; /* '1' empty, '2' partially full, '3' full */ |
| 252 | char cur_apka_mk_state; /* '1' invalid, '2' valid */ | 252 | char cur_apka_mk_state; /* '1' invalid, '2' valid */ |
| 253 | char old_apka_mk_state; /* '1' invalid, '2' valid */ | 253 | 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 */ | ||
| 254 | u64 new_aes_mkvp; /* truncated sha256 of new aes master key */ | 257 | u64 new_aes_mkvp; /* truncated sha256 of new aes master key */ |
| 255 | u64 cur_aes_mkvp; /* truncated sha256 of current aes master key */ | 258 | u64 cur_aes_mkvp; /* truncated sha256 of current aes master key */ |
| 256 | u64 old_aes_mkvp; /* truncated sha256 of old aes master key */ | 259 | u64 old_aes_mkvp; /* truncated sha256 of old aes master key */ |
| 257 | u64 new_apka_mkvp; /* truncated sha256 of new apka master key */ | 260 | u64 new_apka_mkvp; /* truncated sha256 of new apka master key */ |
| 258 | u64 cur_apka_mkvp; /* truncated sha256 of current apka mk */ | 261 | u64 cur_apka_mkvp; /* truncated sha256 of current apka mk */ |
| 259 | u64 old_apka_mkvp; /* truncated sha256 of old apka mk */ | 262 | 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 */ | ||
| 260 | char serial[9]; /* serial number (8 ascii numbers + 0x00) */ | 266 | char serial[9]; /* serial number (8 ascii numbers + 0x00) */ |
| 261 | }; | 267 | }; |
| 262 | 268 | ||
| @@ -34,10 +34,11 @@ · 33 unmodified lines | |||
| 34 | 34 | ||
| 35 | #define CEX3A_MAX_RESPONSE_SIZE 0x210 /* 512 bit modulus | 35 | #define CEX3A_MAX_RESPONSE_SIZE 0x210 /* 512 bit modulus |
| 36 | * (max outputdatalength) + | 36 | * (max outputdatalength) + |
| 37 | * type80_hdr*/ | 37 | * type80_hdr |
| 38 | */ | ||
| 38 | #define CEX3A_MAX_MESSAGE_SIZE sizeof(struct type50_crb3_msg) | 39 | #define CEX3A_MAX_MESSAGE_SIZE sizeof(struct type50_crb3_msg) |
| 39 | 40 | ||
| 40 | #define CEX2A_CLEANUP_TIME (15*HZ) | 41 | #define CEX2A_CLEANUP_TIME (15 * HZ) |
| 41 | #define CEX3A_CLEANUP_TIME CEX2A_CLEANUP_TIME | 42 | #define CEX3A_CLEANUP_TIME CEX2A_CLEANUP_TIME |
| 42 | 43 | ||
| 43 | MODULE_AUTHOR("IBM Corporation"); | 44 | MODULE_AUTHOR("IBM Corporation"); |
| @@ -117,9 +118,8 @@ static int zcrypt_cex2a_card_probe(struct ap_device *ap_dev) · 73 unmodified lines | |||
| 117 | zc->online = 1; | 118 | zc->online = 1; |
| 118 | 119 | ||
| 119 | rc = zcrypt_card_register(zc); | 120 | rc = zcrypt_card_register(zc); |
| 120 | if (rc) { | 121 | if (rc) |
| 121 | zcrypt_card_free(zc); | 122 | zcrypt_card_free(zc); |
| 122 | } | ||
| 123 | 123 | ||
| 124 | return rc; | 124 | return rc; |
| 125 | } | 125 | } |
| @@ -176,9 +176,8 @@ static int zcrypt_cex2a_queue_probe(struct ap_device *ap_dev) · 50 unmodified lines | |||
| 176 | aq->request_timeout = CEX2A_CLEANUP_TIME; | 176 | aq->request_timeout = CEX2A_CLEANUP_TIME; |
| 177 | dev_set_drvdata(&ap_dev->device, zq); | 177 | dev_set_drvdata(&ap_dev->device, zq); |
| 178 | rc = zcrypt_queue_register(zq); | 178 | rc = zcrypt_queue_register(zq); |
| 179 | if (rc) { | 179 | if (rc) |
| 180 | zcrypt_queue_free(zq); | 180 | zcrypt_queue_free(zq); |
| 181 | } | ||
| 182 | 181 | ||
| 183 | return rc; | 182 | return rc; |
| 184 | } | 183 | } |
| @@ -31,8 +31,8 @@ · 30 unmodified lines | |||
| 31 | #define CEX2C_MAX_MOD_SIZE 256 /* 2048 bits */ | 31 | #define CEX2C_MAX_MOD_SIZE 256 /* 2048 bits */ |
| 32 | #define CEX3C_MIN_MOD_SIZE 16 /* 128 bits */ | 32 | #define CEX3C_MIN_MOD_SIZE 16 /* 128 bits */ |
| 33 | #define CEX3C_MAX_MOD_SIZE 512 /* 4096 bits */ | 33 | #define CEX3C_MAX_MOD_SIZE 512 /* 4096 bits */ |
| 34 | #define CEX2C_MAX_XCRB_MESSAGE_SIZE (12*1024) | 34 | #define CEX2C_MAX_XCRB_MESSAGE_SIZE (12 * 1024) |
| 35 | #define CEX2C_CLEANUP_TIME (15*HZ) | 35 | #define CEX2C_CLEANUP_TIME (15 * HZ) |
| 36 | 36 | ||
| 37 | MODULE_AUTHOR("IBM Corporation"); | 37 | MODULE_AUTHOR("IBM Corporation"); |
| 38 | MODULE_DESCRIPTION("CEX2C/CEX3C Cryptographic Coprocessor device driver, " \ | 38 | 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 | |||
| 200 | int rc, i; | 200 | int rc, i; |
| 201 | 201 | ||
| 202 | ap_init_message(&ap_msg); | 202 | 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); |
| 204 | if (!ap_msg.msg) | 204 | if (!ap_msg.msg) |
| 205 | return -ENOMEM; | 205 | return -ENOMEM; |
| 206 | 206 | ||
| 207 | rng_type6CPRB_msgX(&ap_msg, 4, &domain); | 207 | rng_type6cprb_msgx(&ap_msg, 4, &domain); |
| 208 | 208 | ||
| 209 | msg = ap_msg.msg; | 209 | msg = ap_msg.msg; |
| 210 | msg->cprbx.domain = AP_QID_QUEUE(aq->qid); | 210 | 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 | |||
| 233 | else | 233 | else |
| 234 | rc = 0; | 234 | rc = 0; |
| 235 | out_free: | 235 | out_free: |
| 236 | free_page((unsigned long) ap_msg.msg); | 236 | free_page((unsigned long)ap_msg.msg); |
| 237 | return rc; | 237 | return rc; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| @@ -33,7 +33,7 @@ · 32 unmodified lines | |||
| 33 | * But the maximum time limit managed by the stomper code is set to 60sec. | 33 | * But the maximum time limit managed by the stomper code is set to 60sec. |
| 34 | * Hence we have to wait at least that time period. | 34 | * Hence we have to wait at least that time period. |
| 35 | */ | 35 | */ |
| 36 | #define CEX4_CLEANUP_TIME (900*HZ) | 36 | #define CEX4_CLEANUP_TIME (900 * HZ) |
| 37 | 37 | ||
| 38 | MODULE_AUTHOR("IBM Corporation"); | 38 | MODULE_AUTHOR("IBM Corporation"); |
| 39 | MODULE_DESCRIPTION("CEX[45678] Cryptographic Card device driver, " \ | 39 | MODULE_DESCRIPTION("CEX[45678] Cryptographic Card device driver, " \ |
| @@ -123,11 +123,12 @@ static ssize_t cca_mkvps_show(struct device *dev, · 83 unmodified lines | |||
| 123 | &ci, zq->online); | 123 | &ci, zq->online); |
| 124 | 124 | ||
| 125 | if (ci.new_aes_mk_state >= '1' && ci.new_aes_mk_state <= '3') | 125 | 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", | 126 | n += scnprintf(buf + n, PAGE_SIZE, |
| 127 | new_state[ci.new_aes_mk_state - '1'], | 127 | "AES NEW: %s 0x%016llx\n", |
| 128 | ci.new_aes_mkvp); | 128 | new_state[ci.new_aes_mk_state - '1'], |
| 129 | ci.new_aes_mkvp); | ||
| 129 | else | 130 | else |
| 130 | n = scnprintf(buf, PAGE_SIZE, "AES NEW: - -\n"); | 131 | n += scnprintf(buf + n, PAGE_SIZE, "AES NEW: - -\n"); |
| 131 | 132 | ||
| 132 | if (ci.cur_aes_mk_state >= '1' && ci.cur_aes_mk_state <= '2') | 133 | if (ci.cur_aes_mk_state >= '1' && ci.cur_aes_mk_state <= '2') |
| 133 | n += scnprintf(buf + n, PAGE_SIZE - n, | 134 | n += scnprintf(buf + n, PAGE_SIZE - n, |
| @@ -169,6 +170,33 @@ static ssize_t cca_mkvps_show(struct device *dev, · 35 unmodified lines | |||
| 169 | else | 170 | else |
| 170 | n += scnprintf(buf + n, PAGE_SIZE - n, "APKA OLD: - -\n"); | 171 | n += scnprintf(buf + n, PAGE_SIZE - n, "APKA OLD: - -\n"); |
| 171 | 172 | ||
| 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 | |||
| 172 | return n; | 200 | return n; |
| 173 | } | 201 | } |
| 174 | 202 | ||
| @@ -336,8 +364,9 @@ static ssize_t ep11_mkvps_show(struct device *dev, · 161 unmodified lines | |||
| 336 | bin2hex(buf + n, di.cur_wkvp, sizeof(di.cur_wkvp)); | 364 | bin2hex(buf + n, di.cur_wkvp, sizeof(di.cur_wkvp)); |
| 337 | n += 2 * sizeof(di.cur_wkvp); | 365 | n += 2 * sizeof(di.cur_wkvp); |
| 338 | n += scnprintf(buf + n, PAGE_SIZE - n, "\n"); | 366 | n += scnprintf(buf + n, PAGE_SIZE - n, "\n"); |
| 339 | } else | 367 | } else { |
| 340 | n = scnprintf(buf, PAGE_SIZE, "WK CUR: - -\n"); | 368 | n = scnprintf(buf, PAGE_SIZE, "WK CUR: - -\n"); |
| 369 | } | ||
| 341 | 370 | ||
| 342 | if (di.new_wk_state == '0') { | 371 | if (di.new_wk_state == '0') { |
| 343 | n += scnprintf(buf + n, PAGE_SIZE - n, "WK NEW: %s -\n", | 372 | 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 | |||
| 348 | bin2hex(buf + n, di.new_wkvp, sizeof(di.new_wkvp)); | 377 | bin2hex(buf + n, di.new_wkvp, sizeof(di.new_wkvp)); |
| 349 | n += 2 * sizeof(di.new_wkvp); | 378 | n += 2 * sizeof(di.new_wkvp); |
| 350 | n += scnprintf(buf + n, PAGE_SIZE - n, "\n"); | 379 | n += scnprintf(buf + n, PAGE_SIZE - n, "\n"); |
| 351 | } else | 380 | } else { |
| 352 | n += scnprintf(buf + n, PAGE_SIZE - n, "WK NEW: - -\n"); | 381 | n += scnprintf(buf + n, PAGE_SIZE - n, "WK NEW: - -\n"); |
| 382 | } | ||
| 353 | 383 | ||
| 354 | return n; | 384 | return n; |
| 355 | } | 385 | } |
| @@ -119,8 +119,8 @@ static void __exit card_cache_free(void) · 118 unmodified lines | |||
| 119 | int ep11_check_aes_key_with_hdr(debug_info_t *dbg, int dbflvl, | 119 | int ep11_check_aes_key_with_hdr(debug_info_t *dbg, int dbflvl, |
| 120 | const u8 *key, size_t keylen, int checkcpacfexp) | 120 | const u8 *key, size_t keylen, int checkcpacfexp) |
| 121 | { | 121 | { |
| 122 | struct ep11kblob_header *hdr = (struct ep11kblob_header *) key; | 122 | struct ep11kblob_header *hdr = (struct ep11kblob_header *)key; |
| 123 | struct ep11keyblob *kb = (struct ep11keyblob *) (key + sizeof(*hdr)); | 123 | struct ep11keyblob *kb = (struct ep11keyblob *)(key + sizeof(*hdr)); |
| 124 | 124 | ||
| 125 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) | 125 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) |
| 126 | 126 | ||
| @@ -133,38 +133,38 @@ int ep11_check_aes_key_with_hdr(debug_info_t *dbg, int dbflvl, · 6 unmodified lines | |||
| 133 | if (hdr->type != TOKTYPE_NON_CCA) { | 133 | if (hdr->type != TOKTYPE_NON_CCA) { |
| 134 | if (dbg) | 134 | if (dbg) |
| 135 | DBF("%s key check failed, type 0x%02x != 0x%02x\n", | 135 | 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); |
| 137 | return -EINVAL; | 137 | return -EINVAL; |
| 138 | } | 138 | } |
| 139 | if (hdr->hver != 0x00) { | 139 | if (hdr->hver != 0x00) { |
| 140 | if (dbg) | 140 | if (dbg) |
| 141 | DBF("%s key check failed, header version 0x%02x != 0x00\n", | 141 | DBF("%s key check failed, header version 0x%02x != 0x00\n", |
| 142 | __func__, (int) hdr->hver); | 142 | __func__, (int)hdr->hver); |
| 143 | return -EINVAL; | 143 | return -EINVAL; |
| 144 | } | 144 | } |
| 145 | if (hdr->version != TOKVER_EP11_AES_WITH_HEADER) { | 145 | if (hdr->version != TOKVER_EP11_AES_WITH_HEADER) { |
| 146 | if (dbg) | 146 | if (dbg) |
| 147 | DBF("%s key check failed, version 0x%02x != 0x%02x\n", | 147 | 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); |
| 149 | return -EINVAL; | 149 | return -EINVAL; |
| 150 | } | 150 | } |
| 151 | if (hdr->len > keylen) { | 151 | if (hdr->len > keylen) { |
| 152 | if (dbg) | 152 | if (dbg) |
| 153 | DBF("%s key check failed, header len %d keylen %zu mismatch\n", | 153 | DBF("%s key check failed, header len %d keylen %zu mismatch\n", |
| 154 | __func__, (int) hdr->len, keylen); | 154 | __func__, (int)hdr->len, keylen); |
| 155 | return -EINVAL; | 155 | return -EINVAL; |
| 156 | } | 156 | } |
| 157 | if (hdr->len < sizeof(*hdr) + sizeof(*kb)) { | 157 | if (hdr->len < sizeof(*hdr) + sizeof(*kb)) { |
| 158 | if (dbg) | 158 | if (dbg) |
| 159 | DBF("%s key check failed, header len %d < %zu\n", | 159 | 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)); |
| 161 | return -EINVAL; | 161 | return -EINVAL; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | if (kb->version != EP11_STRUCT_MAGIC) { | 164 | if (kb->version != EP11_STRUCT_MAGIC) { |
| 165 | if (dbg) | 165 | if (dbg) |
| 166 | DBF("%s key check failed, blob magic 0x%04x != 0x%04x\n", | 166 | 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); |
| 168 | return -EINVAL; | 168 | return -EINVAL; |
| 169 | } | 169 | } |
| 170 | if (checkcpacfexp && !(kb->attr & EP11_BLOB_PKEY_EXTRACTABLE)) { | 170 | if (checkcpacfexp && !(kb->attr & EP11_BLOB_PKEY_EXTRACTABLE)) { |
| @@ -186,8 +186,8 @@ EXPORT_SYMBOL(ep11_check_aes_key_with_hdr); · 15 unmodified lines | |||
| 186 | int ep11_check_ecc_key_with_hdr(debug_info_t *dbg, int dbflvl, | 186 | int ep11_check_ecc_key_with_hdr(debug_info_t *dbg, int dbflvl, |
| 187 | const u8 *key, size_t keylen, int checkcpacfexp) | 187 | const u8 *key, size_t keylen, int checkcpacfexp) |
| 188 | { | 188 | { |
| 189 | struct ep11kblob_header *hdr = (struct ep11kblob_header *) key; | 189 | struct ep11kblob_header *hdr = (struct ep11kblob_header *)key; |
| 190 | struct ep11keyblob *kb = (struct ep11keyblob *) (key + sizeof(*hdr)); | 190 | struct ep11keyblob *kb = (struct ep11keyblob *)(key + sizeof(*hdr)); |
| 191 | 191 | ||
| 192 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) | 192 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) |
| 193 | 193 | ||
| @@ -200,38 +200,38 @@ int ep11_check_ecc_key_with_hdr(debug_info_t *dbg, int dbflvl, · 6 unmodified lines | |||
| 200 | if (hdr->type != TOKTYPE_NON_CCA) { | 200 | if (hdr->type != TOKTYPE_NON_CCA) { |
| 201 | if (dbg) | 201 | if (dbg) |
| 202 | DBF("%s key check failed, type 0x%02x != 0x%02x\n", | 202 | 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); |
| 204 | return -EINVAL; | 204 | return -EINVAL; |
| 205 | } | 205 | } |
| 206 | if (hdr->hver != 0x00) { | 206 | if (hdr->hver != 0x00) { |
| 207 | if (dbg) | 207 | if (dbg) |
| 208 | DBF("%s key check failed, header version 0x%02x != 0x00\n", | 208 | DBF("%s key check failed, header version 0x%02x != 0x00\n", |
| 209 | __func__, (int) hdr->hver); | 209 | __func__, (int)hdr->hver); |
| 210 | return -EINVAL; | 210 | return -EINVAL; |
| 211 | } | 211 | } |
| 212 | if (hdr->version != TOKVER_EP11_ECC_WITH_HEADER) { | 212 | if (hdr->version != TOKVER_EP11_ECC_WITH_HEADER) { |
| 213 | if (dbg) | 213 | if (dbg) |
| 214 | DBF("%s key check failed, version 0x%02x != 0x%02x\n", | 214 | 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); |
| 216 | return -EINVAL; | 216 | return -EINVAL; |
| 217 | } | 217 | } |
| 218 | if (hdr->len > keylen) { | 218 | if (hdr->len > keylen) { |
| 219 | if (dbg) | 219 | if (dbg) |
| 220 | DBF("%s key check failed, header len %d keylen %zu mismatch\n", | 220 | DBF("%s key check failed, header len %d keylen %zu mismatch\n", |
| 221 | __func__, (int) hdr->len, keylen); | 221 | __func__, (int)hdr->len, keylen); |
| 222 | return -EINVAL; | 222 | return -EINVAL; |
| 223 | } | 223 | } |
| 224 | if (hdr->len < sizeof(*hdr) + sizeof(*kb)) { | 224 | if (hdr->len < sizeof(*hdr) + sizeof(*kb)) { |
| 225 | if (dbg) | 225 | if (dbg) |
| 226 | DBF("%s key check failed, header len %d < %zu\n", | 226 | 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)); |
| 228 | return -EINVAL; | 228 | return -EINVAL; |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | if (kb->version != EP11_STRUCT_MAGIC) { | 231 | if (kb->version != EP11_STRUCT_MAGIC) { |
| 232 | if (dbg) | 232 | if (dbg) |
| 233 | DBF("%s key check failed, blob magic 0x%04x != 0x%04x\n", | 233 | 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); |
| 235 | return -EINVAL; | 235 | return -EINVAL; |
| 236 | } | 236 | } |
| 237 | if (checkcpacfexp && !(kb->attr & EP11_BLOB_PKEY_EXTRACTABLE)) { | 237 | if (checkcpacfexp && !(kb->attr & EP11_BLOB_PKEY_EXTRACTABLE)) { |
| @@ -254,7 +254,7 @@ EXPORT_SYMBOL(ep11_check_ecc_key_with_hdr); · 16 unmodified lines | |||
| 254 | int ep11_check_aes_key(debug_info_t *dbg, int dbflvl, | 254 | int ep11_check_aes_key(debug_info_t *dbg, int dbflvl, |
| 255 | const u8 *key, size_t keylen, int checkcpacfexp) | 255 | const u8 *key, size_t keylen, int checkcpacfexp) |
| 256 | { | 256 | { |
| 257 | struct ep11keyblob *kb = (struct ep11keyblob *) key; | 257 | struct ep11keyblob *kb = (struct ep11keyblob *)key; |
| 258 | 258 | ||
| 259 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) | 259 | #define DBF(...) debug_sprintf_event(dbg, dbflvl, ##__VA_ARGS__) |
| 260 | 260 | ||
| @@ -267,32 +267,32 @@ int ep11_check_aes_key(debug_info_t *dbg, int dbflvl, · 6 unmodified lines | |||
| 267 | if (kb->head.type != TOKTYPE_NON_CCA) { | 267 | if (kb->head.type != TOKTYPE_NON_CCA) { |
| 268 | if (dbg) | 268 | if (dbg) |
| 269 | DBF("%s key check failed, type 0x%02x != 0x%02x\n", | 269 | 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); |
| 271 | return -EINVAL; | 271 | return -EINVAL; |
| 272 | } | 272 | } |
| 273 | if (kb->head.version != TOKVER_EP11_AES) { | 273 | if (kb->head.version != TOKVER_EP11_AES) { |
| 274 | if (dbg) | 274 | if (dbg) |
| 275 | DBF("%s key check failed, version 0x%02x != 0x%02x\n", | 275 | 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); |
| 277 | return -EINVAL; | 277 | return -EINVAL; |
| 278 | } | 278 | } |
| 279 | if (kb->head.len > keylen) { | 279 | if (kb->head.len > keylen) { |
| 280 | if (dbg) | 280 | if (dbg) |
| 281 | DBF("%s key check failed, header len %d keylen %zu mismatch\n", | 281 | 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); |
| 283 | return -EINVAL; | 283 | return -EINVAL; |
| 284 | } | 284 | } |
| 285 | if (kb->head.len < sizeof(*kb)) { | 285 | if (kb->head.len < sizeof(*kb)) { |
| 286 | if (dbg) | 286 | if (dbg) |
| 287 | DBF("%s key check failed, header len %d < %zu\n", | 287 | 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)); |
| 289 | return -EINVAL; | 289 | return -EINVAL; |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | if (kb->version != EP11_STRUCT_MAGIC) { | 292 | if (kb->version != EP11_STRUCT_MAGIC) { |
| 293 | if (dbg) | 293 | if (dbg) |
| 294 | DBF("%s key check failed, blob magic 0x%04x != 0x%04x\n", | 294 | 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); |
| 296 | return -EINVAL; | 296 | return -EINVAL; |
| 297 | } | 297 | } |
| 298 | if (checkcpacfexp && !(kb->attr & EP11_BLOB_PKEY_EXTRACTABLE)) { | 298 | 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 | |||
| 347 | } | 347 | } |
| 348 | if (valuelen > 127) { | 348 | if (valuelen > 127) { |
| 349 | ptr[1] = 0x81; | 349 | ptr[1] = 0x81; |
| 350 | ptr[2] = (u8) valuelen; | 350 | ptr[2] = (u8)valuelen; |
| 351 | memcpy(ptr + 3, pvalue, valuelen); | 351 | memcpy(ptr + 3, pvalue, valuelen); |
| 352 | return 3 + valuelen; | 352 | return 3 + valuelen; |
| 353 | } | 353 | } |
| 354 | ptr[1] = (u8) valuelen; | 354 | ptr[1] = (u8)valuelen; |
| 355 | memcpy(ptr + 2, pvalue, valuelen); | 355 | memcpy(ptr + 2, pvalue, valuelen); |
| 356 | return 2 + valuelen; | 356 | return 2 + valuelen; |
| 357 | } | 357 | } |
| @@ -389,11 +389,11 @@ static inline void prep_urb(struct ep11_urb *u, · 31 unmodified lines | |||
| 389 | struct ep11_cprb *req, size_t req_len, | 389 | struct ep11_cprb *req, size_t req_len, |
| 390 | struct ep11_cprb *rep, size_t rep_len) | 390 | struct ep11_cprb *rep, size_t rep_len) |
| 391 | { | 391 | { |
| 392 | u->targets = (u8 __user *) t; | 392 | u->targets = (u8 __user *)t; |
| 393 | u->targets_num = nt; | 393 | u->targets_num = nt; |
| 394 | u->req = (u8 __user *) req; | 394 | u->req = (u8 __user *)req; |
| 395 | u->req_len = req_len; | 395 | u->req_len = req_len; |
| 396 | u->resp = (u8 __user *) rep; | 396 | u->resp = (u8 __user *)rep; |
| 397 | u->resp_len = rep_len; | 397 | u->resp_len = rep_len; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| @@ -462,7 +462,6 @@ static int check_reply_pl(const u8 *pl, const char *func) · 62 unmodified lines | |||
| 462 | return 0; | 462 | return 0; |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | |||
| 466 | /* | 465 | /* |
| 467 | * Helper function which does an ep11 query with given query type. | 466 | * Helper function which does an ep11 query with given query type. |
| 468 | */ | 467 | */ |
| @@ -496,7 +495,7 @@ static int ep11_query_info(u16 cardnr, u16 domain, u32 query_type, · 27 unmodified lines | |||
| 496 | req = alloc_cprb(sizeof(struct ep11_info_req_pl)); | 495 | req = alloc_cprb(sizeof(struct ep11_info_req_pl)); |
| 497 | if (!req) | 496 | if (!req) |
| 498 | goto out; | 497 | 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)); |
| 500 | prep_head(&req_pl->head, sizeof(*req_pl), api, 38); /* get xcp info */ | 499 | prep_head(&req_pl->head, sizeof(*req_pl), api, 38); /* get xcp info */ |
| 501 | req_pl->query_type_tag = 0x04; | 500 | req_pl->query_type_tag = 0x04; |
| 502 | req_pl->query_type_len = sizeof(u32); | 501 | 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 | |||
| 508 | rep = alloc_cprb(sizeof(struct ep11_info_rep_pl) + buflen); | 507 | rep = alloc_cprb(sizeof(struct ep11_info_rep_pl) + buflen); |
| 509 | if (!rep) | 508 | if (!rep) |
| 510 | goto out; | 509 | 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)); |
| 512 | 511 | ||
| 513 | /* urb and target */ | 512 | /* urb and target */ |
| 514 | urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL); | 513 | urb = kmalloc(sizeof(*urb), GFP_KERNEL); |
| 515 | if (!urb) | 514 | if (!urb) |
| 516 | goto out; | 515 | goto out; |
| 517 | target.ap_id = cardnr; | 516 | target.ap_id = cardnr; |
| @@ -524,7 +523,7 @@ static int ep11_query_info(u16 cardnr, u16 domain, u32 query_type, · 6 unmodified lines | |||
| 524 | if (rc) { | 523 | if (rc) { |
| 525 | DEBUG_ERR( | 524 | DEBUG_ERR( |
| 526 | "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n", | 525 | "%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); |
| 528 | goto out; | 527 | goto out; |
| 529 | } | 528 | } |
| 530 | 529 | ||
| @@ -543,7 +542,7 @@ static int ep11_query_info(u16 cardnr, u16 domain, u32 query_type, · 12 unmodified lines | |||
| 543 | goto out; | 542 | goto out; |
| 544 | } | 543 | } |
| 545 | 544 | ||
| 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); |
| 547 | 546 | ||
| 548 | out: | 547 | out: |
| 549 | kfree(req); | 548 | kfree(req); |
| @@ -592,7 +591,7 @@ int ep11_get_card_info(u16 card, struct ep11_card_info *info, int verify) · 42 unmodified lines | |||
| 592 | return -ENOMEM; | 591 | return -ENOMEM; |
| 593 | rc = ep11_query_info(card, AUTOSEL_DOM, | 592 | rc = ep11_query_info(card, AUTOSEL_DOM, |
| 594 | 0x01 /* module info query */, | 593 | 0x01 /* module info query */, |
| 595 | sizeof(*pmqi), (u8 *) pmqi); | 594 | sizeof(*pmqi), (u8 *)pmqi); |
| 596 | if (rc) { | 595 | if (rc) { |
| 597 | if (rc == -ENODEV) | 596 | if (rc == -ENODEV) |
| 598 | card_cache_scrub(card); | 597 | 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 | |||
| 632 | return -ENOMEM; | 631 | return -ENOMEM; |
| 633 | 632 | ||
| 634 | rc = ep11_query_info(card, domain, 0x03 /* domain info query */, | 633 | 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); |
| 636 | if (rc) | 635 | if (rc) |
| 637 | goto out; | 636 | goto out; |
| 638 | 637 | ||
| @@ -644,8 +643,8 @@ int ep11_get_domain_info(u16 card, u16 domain, struct ep11_domain_info *info) · 5 unmodified lines | |||
| 644 | info->cur_wk_state = '1'; | 643 | info->cur_wk_state = '1'; |
| 645 | memcpy(info->cur_wkvp, p_dom_info->cur_WK_VP, 32); | 644 | memcpy(info->cur_wkvp, p_dom_info->cur_WK_VP, 32); |
| 646 | } | 645 | } |
| 647 | if (p_dom_info->dom_flags & 0x04 /* new wk present */ | 646 | if (p_dom_info->dom_flags & 0x04 || /* new wk present */ |
| 648 | || p_dom_info->dom_flags & 0x08 /* new wk committed */) { | 647 | p_dom_info->dom_flags & 0x08 /* new wk committed */) { |
| 649 | info->new_wk_state = | 648 | info->new_wk_state = |
| 650 | p_dom_info->dom_flags & 0x08 ? '2' : '1'; | 649 | p_dom_info->dom_flags & 0x08 ? '2' : '1'; |
| 651 | memcpy(info->new_wkvp, p_dom_info->new_WK_VP, 32); | 650 | 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 | |||
| 722 | req = alloc_cprb(sizeof(struct keygen_req_pl)); | 721 | req = alloc_cprb(sizeof(struct keygen_req_pl)); |
| 723 | if (!req) | 722 | if (!req) |
| 724 | goto out; | 723 | goto out; |
| 725 | req_pl = (struct keygen_req_pl *) (((u8 *) req) + sizeof(*req)); | 724 | req_pl = (struct keygen_req_pl *)(((u8 *)req) + sizeof(*req)); |
| 726 | api = (!keygenflags || keygenflags & 0x00200000) ? 4 : 1; | 725 | api = (!keygenflags || keygenflags & 0x00200000) ? 4 : 1; |
| 727 | prep_head(&req_pl->head, sizeof(*req_pl), api, 21); /* GenerateKey */ | 726 | prep_head(&req_pl->head, sizeof(*req_pl), api, 21); /* GenerateKey */ |
| 728 | req_pl->var_tag = 0x04; | 727 | req_pl->var_tag = 0x04; |
| @@ -746,10 +745,10 @@ int ep11_genaeskey(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 17 unmodified lines | |||
| 746 | rep = alloc_cprb(sizeof(struct keygen_rep_pl)); | 745 | rep = alloc_cprb(sizeof(struct keygen_rep_pl)); |
| 747 | if (!rep) | 746 | if (!rep) |
| 748 | goto out; | 747 | goto out; |
| 749 | rep_pl = (struct keygen_rep_pl *) (((u8 *) rep) + sizeof(*rep)); | 748 | rep_pl = (struct keygen_rep_pl *)(((u8 *)rep) + sizeof(*rep)); |
| 750 | 749 | ||
| 751 | /* urb and target */ | 750 | /* urb and target */ |
| 752 | urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL); | 751 | urb = kmalloc(sizeof(*urb), GFP_KERNEL); |
| 753 | if (!urb) | 752 | if (!urb) |
| 754 | goto out; | 753 | goto out; |
| 755 | target.ap_id = card; | 754 | target.ap_id = card; |
| @@ -762,7 +761,7 @@ int ep11_genaeskey(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 6 unmodified lines | |||
| 762 | if (rc) { | 761 | if (rc) { |
| 763 | DEBUG_ERR( | 762 | DEBUG_ERR( |
| 764 | "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n", | 763 | "%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); |
| 766 | goto out; | 765 | goto out; |
| 767 | } | 766 | } |
| 768 | 767 | ||
| @@ -784,7 +783,7 @@ int ep11_genaeskey(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 15 unmodified lines | |||
| 784 | /* copy key blob and set header values */ | 783 | /* copy key blob and set header values */ |
| 785 | memcpy(keybuf, rep_pl->data, rep_pl->data_len); | 784 | memcpy(keybuf, rep_pl->data, rep_pl->data_len); |
| 786 | *keybufsize = rep_pl->data_len; | 785 | *keybufsize = rep_pl->data_len; |
| 787 | kb = (struct ep11keyblob *) keybuf; | 786 | kb = (struct ep11keyblob *)keybuf; |
| 788 | kb->head.type = TOKTYPE_NON_CCA; | 787 | kb->head.type = TOKTYPE_NON_CCA; |
| 789 | kb->head.len = rep_pl->data_len; | 788 | kb->head.len = rep_pl->data_len; |
| 790 | kb->head.version = TOKVER_EP11_AES; | 789 | kb->head.version = TOKVER_EP11_AES; |
| @@ -844,7 +843,7 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 53 unmodified lines | |||
| 844 | req = alloc_cprb(req_pl_size); | 843 | req = alloc_cprb(req_pl_size); |
| 845 | if (!req) | 844 | if (!req) |
| 846 | goto out; | 845 | goto out; |
| 847 | req_pl = (struct crypt_req_pl *) (((u8 *) req) + sizeof(*req)); | 846 | req_pl = (struct crypt_req_pl *)(((u8 *)req) + sizeof(*req)); |
| 848 | prep_head(&req_pl->head, req_pl_size, api, (mode ? 20 : 19)); | 847 | prep_head(&req_pl->head, req_pl_size, api, (mode ? 20 : 19)); |
| 849 | req_pl->var_tag = 0x04; | 848 | req_pl->var_tag = 0x04; |
| 850 | req_pl->var_len = sizeof(u32); | 849 | req_pl->var_len = sizeof(u32); |
| @@ -852,7 +851,7 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 1 unmodified line | |||
| 852 | req_pl->mech_tag = 0x04; | 851 | req_pl->mech_tag = 0x04; |
| 853 | req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0); | 852 | req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0); |
| 854 | req_pl->mech = (mech ? mech : 0x00001085); /* CKM_AES_CBC_PAD */ | 853 | 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); |
| 856 | if (iv) { | 855 | if (iv) { |
| 857 | memcpy(p, iv, 16); | 856 | memcpy(p, iv, 16); |
| 858 | p += 16; | 857 | p += 16; |
| @@ -866,10 +865,10 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 7 unmodified lines | |||
| 866 | rep = alloc_cprb(rep_pl_size); | 865 | rep = alloc_cprb(rep_pl_size); |
| 867 | if (!rep) | 866 | if (!rep) |
| 868 | goto out; | 867 | goto out; |
| 869 | rep_pl = (struct crypt_rep_pl *) (((u8 *) rep) + sizeof(*rep)); | 868 | rep_pl = (struct crypt_rep_pl *)(((u8 *)rep) + sizeof(*rep)); |
| 870 | 869 | ||
| 871 | /* urb and target */ | 870 | /* urb and target */ |
| 872 | urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL); | 871 | urb = kmalloc(sizeof(*urb), GFP_KERNEL); |
| 873 | if (!urb) | 872 | if (!urb) |
| 874 | goto out; | 873 | goto out; |
| 875 | target.ap_id = card; | 874 | target.ap_id = card; |
| @@ -882,7 +881,7 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 6 unmodified lines | |||
| 882 | if (rc) { | 881 | if (rc) { |
| 883 | DEBUG_ERR( | 882 | DEBUG_ERR( |
| 884 | "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n", | 883 | "%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); |
| 886 | goto out; | 885 | goto out; |
| 887 | } | 886 | } |
| 888 | 887 | ||
| @@ -894,13 +893,13 @@ static int ep11_cryptsingle(u16 card, u16 domain, · 5 unmodified lines | |||
| 894 | rc = -EIO; | 893 | rc = -EIO; |
| 895 | goto out; | 894 | goto out; |
| 896 | } | 895 | } |
| 897 | p = ((u8 *) rep_pl) + sizeof(*rep_pl); | 896 | p = ((u8 *)rep_pl) + sizeof(*rep_pl); |
| 898 | if (rep_pl->data_lenfmt <= 127) | 897 | if (rep_pl->data_lenfmt <= 127) { |
| 899 | n = rep_pl->data_lenfmt; | 898 | n = rep_pl->data_lenfmt; |
| 900 | else if (rep_pl->data_lenfmt == 0x81) | 899 | } else if (rep_pl->data_lenfmt == 0x81) { |
| 901 | n = *p++; | 900 | n = *p++; |
| 902 | else if (rep_pl->data_lenfmt == 0x82) { | 901 | } else if (rep_pl->data_lenfmt == 0x82) { |
| 903 | n = *((u16 *) p); | 902 | n = *((u16 *)p); |
| 904 | p += 2; | 903 | p += 2; |
| 905 | } else { | 904 | } else { |
| 906 | DEBUG_ERR("%s unknown reply data length format 0x%02hhx\n", | 905 | 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 | |||
| 978 | req = alloc_cprb(req_pl_size); | 977 | req = alloc_cprb(req_pl_size); |
| 979 | if (!req) | 978 | if (!req) |
| 980 | goto out; | 979 | goto out; |
| 981 | req_pl = (struct uw_req_pl *) (((u8 *) req) + sizeof(*req)); | 980 | req_pl = (struct uw_req_pl *)(((u8 *)req) + sizeof(*req)); |
| 982 | api = (!keygenflags || keygenflags & 0x00200000) ? 4 : 1; | 981 | api = (!keygenflags || keygenflags & 0x00200000) ? 4 : 1; |
| 983 | prep_head(&req_pl->head, req_pl_size, api, 34); /* UnwrapKey */ | 982 | prep_head(&req_pl->head, req_pl_size, api, 34); /* UnwrapKey */ |
| 984 | req_pl->attr_tag = 0x04; | 983 | req_pl->attr_tag = 0x04; |
| @@ -994,7 +993,7 @@ static int ep11_unwrapkey(u16 card, u16 domain, · 9 unmodified lines | |||
| 994 | req_pl->mech_tag = 0x04; | 993 | req_pl->mech_tag = 0x04; |
| 995 | req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0); | 994 | req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0); |
| 996 | req_pl->mech = (mech ? mech : 0x00001085); /* CKM_AES_CBC_PAD */ | 995 | 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); |
| 998 | if (iv) { | 997 | if (iv) { |
| 999 | memcpy(p, iv, 16); | 998 | memcpy(p, iv, 16); |
| 1000 | p += 16; | 999 | p += 16; |
| @@ -1014,10 +1013,10 @@ static int ep11_unwrapkey(u16 card, u16 domain, · 13 unmodified lines | |||
| 1014 | rep = alloc_cprb(sizeof(struct uw_rep_pl)); | 1013 | rep = alloc_cprb(sizeof(struct uw_rep_pl)); |
| 1015 | if (!rep) | 1014 | if (!rep) |
| 1016 | goto out; | 1015 | goto out; |
| 1017 | rep_pl = (struct uw_rep_pl *) (((u8 *) rep) + sizeof(*rep)); | 1016 | rep_pl = (struct uw_rep_pl *)(((u8 *)rep) + sizeof(*rep)); |
| 1018 | 1017 | ||
| 1019 | /* urb and target */ | 1018 | /* urb and target */ |
| 1020 | urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL); | 1019 | urb = kmalloc(sizeof(*urb), GFP_KERNEL); |
| 1021 | if (!urb) | 1020 | if (!urb) |
| 1022 | goto out; | 1021 | goto out; |
| 1023 | target.ap_id = card; | 1022 | target.ap_id = card; |
| @@ -1030,7 +1029,7 @@ static int ep11_unwrapkey(u16 card, u16 domain, · 6 unmodified lines | |||
| 1030 | if (rc) { | 1029 | if (rc) { |
| 1031 | DEBUG_ERR( | 1030 | DEBUG_ERR( |
| 1032 | "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n", | 1031 | "%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); |
| 1034 | goto out; | 1033 | goto out; |
| 1035 | } | 1034 | } |
| 1036 | 1035 | ||
| @@ -1052,7 +1051,7 @@ static int ep11_unwrapkey(u16 card, u16 domain, · 15 unmodified lines | |||
| 1052 | /* copy key blob and set header values */ | 1051 | /* copy key blob and set header values */ |
| 1053 | memcpy(keybuf, rep_pl->data, rep_pl->data_len); | 1052 | memcpy(keybuf, rep_pl->data, rep_pl->data_len); |
| 1054 | *keybufsize = rep_pl->data_len; | 1053 | *keybufsize = rep_pl->data_len; |
| 1055 | kb = (struct ep11keyblob *) keybuf; | 1054 | kb = (struct ep11keyblob *)keybuf; |
| 1056 | kb->head.type = TOKTYPE_NON_CCA; | 1055 | kb->head.type = TOKTYPE_NON_CCA; |
| 1057 | kb->head.len = rep_pl->data_len; | 1056 | kb->head.len = rep_pl->data_len; |
| 1058 | kb->head.version = TOKVER_EP11_AES; | 1057 | kb->head.version = TOKVER_EP11_AES; |
| @@ -1105,7 +1104,7 @@ static int ep11_wrapkey(u16 card, u16 domain, · 46 unmodified lines | |||
| 1105 | u8 *p; | 1104 | u8 *p; |
| 1106 | 1105 | ||
| 1107 | /* maybe the session field holds a header with key info */ | 1106 | /* maybe the session field holds a header with key info */ |
| 1108 | kb = (struct ep11keyblob *) key; | 1107 | kb = (struct ep11keyblob *)key; |
| 1109 | if (kb->head.type == TOKTYPE_NON_CCA && | 1108 | if (kb->head.type == TOKTYPE_NON_CCA && |
| 1110 | kb->head.version == TOKVER_EP11_AES) { | 1109 | kb->head.version == TOKVER_EP11_AES) { |
| 1111 | has_header = true; | 1110 | has_header = true; |
| @@ -1120,7 +1119,7 @@ static int ep11_wrapkey(u16 card, u16 domain, · 8 unmodified lines | |||
| 1120 | goto out; | 1119 | goto out; |
| 1121 | if (!mech || mech == 0x80060001) | 1120 | if (!mech || mech == 0x80060001) |
| 1122 | req->flags |= 0x20; /* CPACF_WRAP needs special bit */ | 1121 | 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)); |
| 1124 | api = (!mech || mech == 0x80060001) ? 4 : 1; /* CKM_IBM_CPACF_WRAP */ | 1123 | api = (!mech || mech == 0x80060001) ? 4 : 1; /* CKM_IBM_CPACF_WRAP */ |
| 1125 | prep_head(&req_pl->head, req_pl_size, api, 33); /* WrapKey */ | 1124 | prep_head(&req_pl->head, req_pl_size, api, 33); /* WrapKey */ |
| 1126 | req_pl->var_tag = 0x04; | 1125 | req_pl->var_tag = 0x04; |
| @@ -1129,7 +1128,7 @@ static int ep11_wrapkey(u16 card, u16 domain, · 2 unmodified lines | |||
| 1129 | req_pl->mech_tag = 0x04; | 1128 | req_pl->mech_tag = 0x04; |
| 1130 | req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0); | 1129 | req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0); |
| 1131 | req_pl->mech = (mech ? mech : 0x80060001); /* CKM_IBM_CPACF_WRAP */ | 1130 | 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); |
| 1133 | if (iv) { | 1132 | if (iv) { |
| 1134 | memcpy(p, iv, 16); | 1133 | memcpy(p, iv, 16); |
| 1135 | p += 16; | 1134 | p += 16; |
| @@ -1152,10 +1151,10 @@ static int ep11_wrapkey(u16 card, u16 domain, · 16 unmodified lines | |||
| 1152 | rep = alloc_cprb(sizeof(struct wk_rep_pl)); | 1151 | rep = alloc_cprb(sizeof(struct wk_rep_pl)); |
| 1153 | if (!rep) | 1152 | if (!rep) |
| 1154 | goto out; | 1153 | goto out; |
| 1155 | rep_pl = (struct wk_rep_pl *) (((u8 *) rep) + sizeof(*rep)); | 1154 | rep_pl = (struct wk_rep_pl *)(((u8 *)rep) + sizeof(*rep)); |
| 1156 | 1155 | ||
| 1157 | /* urb and target */ | 1156 | /* urb and target */ |
| 1158 | urb = kmalloc(sizeof(struct ep11_urb), GFP_KERNEL); | 1157 | urb = kmalloc(sizeof(*urb), GFP_KERNEL); |
| 1159 | if (!urb) | 1158 | if (!urb) |
| 1160 | goto out; | 1159 | goto out; |
| 1161 | target.ap_id = card; | 1160 | target.ap_id = card; |
| @@ -1168,7 +1167,7 @@ static int ep11_wrapkey(u16 card, u16 domain, · 6 unmodified lines | |||
| 1168 | if (rc) { | 1167 | if (rc) { |
| 1169 | DEBUG_ERR( | 1168 | DEBUG_ERR( |
| 1170 | "%s zcrypt_send_ep11_cprb(card=%d dom=%d) failed, rc=%d\n", | 1169 | "%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); |
| 1172 | goto out; | 1171 | goto out; |
| 1173 | } | 1172 | } |
| 1174 | 1173 | ||
| @@ -1206,9 +1205,9 @@ int ep11_clr2keyblob(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 31 unmodified lines | |||
| 1206 | u8 encbuf[64], *kek = NULL; | 1205 | u8 encbuf[64], *kek = NULL; |
| 1207 | size_t clrkeylen, keklen, encbuflen = sizeof(encbuf); | 1206 | size_t clrkeylen, keklen, encbuflen = sizeof(encbuf); |
| 1208 | 1207 | ||
| 1209 | if (keybitsize == 128 || keybitsize == 192 || keybitsize == 256) | 1208 | if (keybitsize == 128 || keybitsize == 192 || keybitsize == 256) { |
| 1210 | clrkeylen = keybitsize / 8; | 1209 | clrkeylen = keybitsize / 8; |
| 1211 | else { | 1210 | } else { |
| 1212 | DEBUG_ERR( | 1211 | DEBUG_ERR( |
| 1213 | "%s unknown/unsupported keybitsize %d\n", | 1212 | "%s unknown/unsupported keybitsize %d\n", |
| 1214 | __func__, keybitsize); | 1213 | __func__, keybitsize); |
| @@ -1233,7 +1232,7 @@ int ep11_clr2keyblob(u16 card, u16 domain, u32 keybitsize, u32 keygenflags, · 18 unmodified lines | |||
| 1233 | __func__, rc); | 1232 | __func__, rc); |
| 1234 | goto out; | 1233 | goto out; |
| 1235 | } | 1234 | } |
| 1236 | kb = (struct ep11keyblob *) kek; | 1235 | kb = (struct ep11keyblob *)kek; |
| 1237 | memset(&kb->head, 0, sizeof(kb->head)); | 1236 | memset(&kb->head, 0, sizeof(kb->head)); |
| 1238 | 1237 | ||
| 1239 | /* Step 2: encrypt clear key value with the kek key */ | 1238 | /* 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 | |||
| 1282 | struct ep11kblob_header *hdr; | 1281 | struct ep11kblob_header *hdr; |
| 1283 | 1282 | ||
| 1284 | /* key with or without header ? */ | 1283 | /* key with or without header ? */ |
| 1285 | hdr = (struct ep11kblob_header *) keyblob; | 1284 | hdr = (struct ep11kblob_header *)keyblob; |
| 1286 | if (hdr->type == TOKTYPE_NON_CCA | 1285 | if (hdr->type == TOKTYPE_NON_CCA && |
| 1287 | && (hdr->version == TOKVER_EP11_AES_WITH_HEADER | 1286 | (hdr->version == TOKVER_EP11_AES_WITH_HEADER || |
| 1288 | || hdr->version == TOKVER_EP11_ECC_WITH_HEADER) | 1287 | hdr->version == TOKVER_EP11_ECC_WITH_HEADER) && |
| 1289 | && is_ep11_keyblob(keyblob + sizeof(struct ep11kblob_header))) { | 1288 | is_ep11_keyblob(keyblob + sizeof(struct ep11kblob_header))) { |
| 1290 | /* EP11 AES or ECC key with header */ | 1289 | /* EP11 AES or ECC key with header */ |
| 1291 | key = keyblob + sizeof(struct ep11kblob_header); | 1290 | key = keyblob + sizeof(struct ep11kblob_header); |
| 1292 | keylen = hdr->len - sizeof(struct ep11kblob_header); | 1291 | keylen = hdr->len - sizeof(struct ep11kblob_header); |
| 1293 | } else if (hdr->type == TOKTYPE_NON_CCA | 1292 | } else if (hdr->type == TOKTYPE_NON_CCA && |
| 1294 | && hdr->version == TOKVER_EP11_AES | 1293 | hdr->version == TOKVER_EP11_AES && |
| 1295 | && is_ep11_keyblob(keyblob)) { | 1294 | is_ep11_keyblob(keyblob)) { |
| 1296 | /* EP11 AES key (old style) */ | 1295 | /* EP11 AES key (old style) */ |
| 1297 | key = keyblob; | 1296 | key = keyblob; |
| 1298 | keylen = hdr->len; | 1297 | keylen = hdr->len; |
| @@ -1300,8 +1299,9 @@ int ep11_kblob2protkey(u16 card, u16 dom, const u8 *keyblob, size_t keybloblen, · 1 unmodified line | |||
| 1300 | /* raw EP11 key blob */ | 1299 | /* raw EP11 key blob */ |
| 1301 | key = keyblob; | 1300 | key = keyblob; |
| 1302 | keylen = keybloblen; | 1301 | keylen = keybloblen; |
| 1303 | } else | 1302 | } else { |
| 1304 | return -EINVAL; | 1303 | return -EINVAL; |
| 1304 | } | ||
| 1305 | 1305 | ||
| 1306 | /* alloc temp working buffer */ | 1306 | /* alloc temp working buffer */ |
| 1307 | wkbuflen = (keylen + AES_BLOCK_SIZE) & (~(AES_BLOCK_SIZE - 1)); | 1307 | 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 | |||
| 1318 | __func__, rc); | 1318 | __func__, rc); |
| 1319 | goto out; | 1319 | goto out; |
| 1320 | } | 1320 | } |
| 1321 | wki = (struct wk_info *) wkbuf; | 1321 | wki = (struct wk_info *)wkbuf; |
| 1322 | 1322 | ||
| 1323 | /* check struct version and pkey type */ | 1323 | /* check struct version and pkey type */ |
| 1324 | if (wki->version != 1 || wki->pkeytype < 1 || wki->pkeytype > 5) { | 1324 | if (wki->version != 1 || wki->pkeytype < 1 || wki->pkeytype > 5) { |
| 1325 | DEBUG_ERR("%s wk info version %d or pkeytype %d mismatch.\n", | 1325 | 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); |
| 1327 | rc = -EIO; | 1327 | rc = -EIO; |
| 1328 | goto out; | 1328 | goto out; |
| 1329 | } | 1329 | } |
| @@ -1332,24 +1332,24 @@ int ep11_kblob2protkey(u16 card, u16 dom, const u8 *keyblob, size_t keybloblen, · 2 unmodified lines | |||
| 1332 | switch (wki->pkeytype) { | 1332 | switch (wki->pkeytype) { |
| 1333 | case 1: /* AES */ | 1333 | case 1: /* AES */ |
| 1334 | switch (wki->pkeysize) { | 1334 | switch (wki->pkeysize) { |
| 1335 | case 16+32: | 1335 | case 16 + 32: |
| 1336 | /* AES 128 protected key */ | 1336 | /* AES 128 protected key */ |
| 1337 | if (protkeytype) | 1337 | if (protkeytype) |
| 1338 | *protkeytype = PKEY_KEYTYPE_AES_128; | 1338 | *protkeytype = PKEY_KEYTYPE_AES_128; |
| 1339 | break; | 1339 | break; |
| 1340 | case 24+32: | 1340 | case 24 + 32: |
| 1341 | /* AES 192 protected key */ | 1341 | /* AES 192 protected key */ |
| 1342 | if (protkeytype) | 1342 | if (protkeytype) |
| 1343 | *protkeytype = PKEY_KEYTYPE_AES_192; | 1343 | *protkeytype = PKEY_KEYTYPE_AES_192; |
| 1344 | break; | 1344 | break; |
| 1345 | case 32+32: | 1345 | case 32 + 32: |
| 1346 | /* AES 256 protected key */ | 1346 | /* AES 256 protected key */ |
| 1347 | if (protkeytype) | 1347 | if (protkeytype) |
| 1348 | *protkeytype = PKEY_KEYTYPE_AES_256; | 1348 | *protkeytype = PKEY_KEYTYPE_AES_256; |
| 1349 | break; | 1349 | break; |
| 1350 | default: | 1350 | default: |
| 1351 | DEBUG_ERR("%s unknown/unsupported AES pkeysize %d\n", | 1351 | DEBUG_ERR("%s unknown/unsupported AES pkeysize %d\n", |
| 1352 | __func__, (int) wki->pkeysize); | 1352 | __func__, (int)wki->pkeysize); |
| 1353 | rc = -EIO; | 1353 | rc = -EIO; |
| 1354 | goto out; | 1354 | goto out; |
| 1355 | } | 1355 | } |
| @@ -1363,7 +1363,7 @@ int ep11_kblob2protkey(u16 card, u16 dom, const u8 *keyblob, size_t keybloblen, · 7 unmodified lines | |||
| 1363 | case 2: /* TDES */ | 1363 | case 2: /* TDES */ |
| 1364 | default: | 1364 | default: |
| 1365 | DEBUG_ERR("%s unknown/unsupported key type %d\n", | 1365 | DEBUG_ERR("%s unknown/unsupported key type %d\n", |
| 1366 | __func__, (int) wki->pkeytype); | 1366 | __func__, (int)wki->pkeytype); |
| 1367 | rc = -EIO; | 1367 | rc = -EIO; |
| 1368 | goto out; | 1368 | goto out; |
| 1369 | } | 1369 | } |
| @@ -1445,7 +1445,7 @@ int ep11_findcard2(u32 **apqns, u32 *nr_apqns, u16 cardnr, u16 domain, · 75 unmodified lines | |||
| 1445 | } | 1445 | } |
| 1446 | /* apqn passed all filtering criterons, add to the array */ | 1446 | /* apqn passed all filtering criterons, add to the array */ |
| 1447 | if (_nr_apqns < 256) | 1447 | if (_nr_apqns < 256) |
| 1448 | _apqns[_nr_apqns++] = (((u16)card) << 16) | ((u16) dom); | 1448 | _apqns[_nr_apqns++] = (((u16)card) << 16) | ((u16)dom); |
| 1449 | } | 1449 | } |
| 1450 | 1450 | ||
| 1451 | /* nothing found ? */ | 1451 | /* nothing found ? */ |
| @@ -50,7 +50,7 @@ struct ep11keyblob { · 49 unmodified lines | |||
| 50 | /* check ep11 key magic to find out if this is an ep11 key blob */ | 50 | /* check ep11 key magic to find out if this is an ep11 key blob */ |
| 51 | static inline bool is_ep11_keyblob(const u8 *key) | 51 | static inline bool is_ep11_keyblob(const u8 *key) |
| 52 | { | 52 | { |
| 53 | struct ep11keyblob *kb = (struct ep11keyblob *) key; | 53 | struct ep11keyblob *kb = (struct ep11keyblob *)key; |
| 54 | 54 | ||
| 55 | return (kb->version == EP11_STRUCT_MAGIC); | 55 | return (kb->version == EP11_STRUCT_MAGIC); |
| 56 | } | 56 | } |
| @@ -121,10 +121,11 @@ static inline int convert_error(struct zcrypt_queue *zq, · 120 unmodified lines | |||
| 121 | ZCRYPT_DBF_WARN( | 121 | ZCRYPT_DBF_WARN( |
| 122 | "%s dev=%02x.%04x RY=0x%02x apfs=0x%x => bus rescan, rc=EAGAIN\n", | 122 | "%s dev=%02x.%04x RY=0x%02x apfs=0x%x => bus rescan, rc=EAGAIN\n", |
| 123 | __func__, card, queue, ehdr->reply_code, apfs); | 123 | __func__, card, queue, ehdr->reply_code, apfs); |
| 124 | } else | 124 | } else { |
| 125 | ZCRYPT_DBF_WARN("%s dev=%02x.%04x RY=0x%02x => bus rescan, rc=EAGAIN\n", | 125 | ZCRYPT_DBF_WARN("%s dev=%02x.%04x RY=0x%02x => bus rescan, rc=EAGAIN\n", |
| 126 | __func__, card, queue, | 126 | __func__, card, queue, |
| 127 | ehdr->reply_code); | 127 | ehdr->reply_code); |
| 128 | } | ||
| 128 | return -EAGAIN; | 129 | return -EAGAIN; |
| 129 | default: | 130 | default: |
| 130 | /* Assume request is valid and a retry will be worth it */ | 131 | /* Assume request is valid and a retry will be worth it */ |
| @@ -158,7 +158,6 @@ struct type80_hdr { · 157 unmodified lines | |||
| 158 | 158 | ||
| 159 | int get_rsa_modex_fc(struct ica_rsa_modexpo *mex, int *fcode) | 159 | int get_rsa_modex_fc(struct ica_rsa_modexpo *mex, int *fcode) |
| 160 | { | 160 | { |
| 161 | |||
| 162 | if (!mex->inputdatalength) | 161 | if (!mex->inputdatalength) |
| 163 | return -EINVAL; | 162 | return -EINVAL; |
| 164 | 163 | ||
| @@ -174,7 +173,6 @@ int get_rsa_modex_fc(struct ica_rsa_modexpo *mex, int *fcode) · 9 unmodified lines | |||
| 174 | 173 | ||
| 175 | int get_rsa_crt_fc(struct ica_rsa_modexpo_crt *crt, int *fcode) | 174 | int get_rsa_crt_fc(struct ica_rsa_modexpo_crt *crt, int *fcode) |
| 176 | { | 175 | { |
| 177 | |||
| 178 | if (!crt->inputdatalength) | 176 | if (!crt->inputdatalength) |
| 179 | return -EINVAL; | 177 | return -EINVAL; |
| 180 | 178 | ||
| @@ -239,8 +237,9 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq, · 58 unmodified lines | |||
| 239 | mod = meb3->modulus + sizeof(meb3->modulus) - mod_len; | 237 | mod = meb3->modulus + sizeof(meb3->modulus) - mod_len; |
| 240 | exp = meb3->exponent + sizeof(meb3->exponent) - mod_len; | 238 | exp = meb3->exponent + sizeof(meb3->exponent) - mod_len; |
| 241 | inp = meb3->message + sizeof(meb3->message) - mod_len; | 239 | inp = meb3->message + sizeof(meb3->message) - mod_len; |
| 242 | } else | 240 | } else { |
| 243 | return -EINVAL; | 241 | return -EINVAL; |
| 242 | } | ||
| 244 | 243 | ||
| 245 | if (copy_from_user(mod, mex->n_modulus, mod_len) || | 244 | if (copy_from_user(mod, mex->n_modulus, mod_len) || |
| 246 | copy_from_user(exp, mex->b_key, mod_len) || | 245 | 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 | |||
| 323 | dq = crb3->dq + sizeof(crb3->dq) - short_len; | 322 | dq = crb3->dq + sizeof(crb3->dq) - short_len; |
| 324 | u = crb3->u + sizeof(crb3->u) - short_len; | 323 | u = crb3->u + sizeof(crb3->u) - short_len; |
| 325 | inp = crb3->message + sizeof(crb3->message) - mod_len; | 324 | inp = crb3->message + sizeof(crb3->message) - mod_len; |
| 326 | } else | 325 | } else { |
| 327 | return -EINVAL; | 326 | return -EINVAL; |
| 327 | } | ||
| 328 | 328 | ||
| 329 | /* | 329 | /* |
| 330 | * correct the offset of p, bp and mult_inv according zcrypt.h | 330 | * 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 | |||
| 392 | unsigned int outputdatalength) | 392 | unsigned int outputdatalength) |
| 393 | { | 393 | { |
| 394 | /* Response type byte is the second byte in the response. */ | 394 | /* 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]; |
| 396 | 396 | ||
| 397 | switch (rtype) { | 397 | switch (rtype) { |
| 398 | case TYPE82_RSP_CODE: | 398 | case TYPE82_RSP_CODE: |
| @@ -406,11 +406,11 @@ static int convert_response_cex2a(struct zcrypt_queue *zq, · 7 unmodified lines | |||
| 406 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 406 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 407 | AP_QID_CARD(zq->queue->qid), | 407 | AP_QID_CARD(zq->queue->qid), |
| 408 | AP_QID_QUEUE(zq->queue->qid), | 408 | AP_QID_QUEUE(zq->queue->qid), |
| 409 | (int) rtype); | 409 | (int)rtype); |
| 410 | ZCRYPT_DBF_ERR( | 410 | ZCRYPT_DBF_ERR( |
| 411 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 411 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 412 | __func__, AP_QID_CARD(zq->queue->qid), | 412 | __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); |
| 414 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); | 414 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); |
| 415 | return -EAGAIN; | 415 | return -EAGAIN; |
| 416 | } | 416 | } |
| @@ -447,10 +447,11 @@ static void zcrypt_cex2a_receive(struct ap_queue *aq, · 30 unmodified lines | |||
| 447 | memcpy(msg->msg, reply->msg, len); | 447 | memcpy(msg->msg, reply->msg, len); |
| 448 | msg->len = len; | 448 | msg->len = len; |
| 449 | } | 449 | } |
| 450 | } else | 450 | } else { |
| 451 | memcpy(msg->msg, reply->msg, sizeof(error_reply)); | 451 | memcpy(msg->msg, reply->msg, sizeof(error_reply)); |
| 452 | } | ||
| 452 | out: | 453 | out: |
| 453 | complete((struct completion *) msg->private); | 454 | complete((struct completion *)msg->private); |
| 454 | } | 455 | } |
| 455 | 456 | ||
| 456 | static atomic_t zcrypt_step = ATOMIC_INIT(0); | 457 | static atomic_t zcrypt_step = ATOMIC_INIT(0); |
| @@ -475,7 +476,7 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq, · 18 unmodified lines | |||
| 475 | if (!ap_msg->msg) | 476 | if (!ap_msg->msg) |
| 476 | return -ENOMEM; | 477 | return -ENOMEM; |
| 477 | ap_msg->receive = zcrypt_cex2a_receive; | 478 | 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) + |
| 479 | atomic_inc_return(&zcrypt_step); | 480 | atomic_inc_return(&zcrypt_step); |
| 480 | ap_msg->private = &work; | 481 | ap_msg->private = &work; |
| 481 | rc = ICAMEX_msg_to_type50MEX_msg(zq, ap_msg, mex); | 482 | 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 | |||
| 492 | rc = convert_response_cex2a(zq, ap_msg, | 493 | rc = convert_response_cex2a(zq, ap_msg, |
| 493 | mex->outputdata, | 494 | mex->outputdata, |
| 494 | mex->outputdatalength); | 495 | mex->outputdatalength); |
| 495 | } else | 496 | } else { |
| 496 | /* Signal pending. */ | 497 | /* Signal pending. */ |
| 497 | ap_cancel_message(zq->queue, ap_msg); | 498 | ap_cancel_message(zq->queue, ap_msg); |
| 499 | } | ||
| 500 | |||
| 498 | out: | 501 | out: |
| 499 | ap_msg->private = NULL; | 502 | ap_msg->private = NULL; |
| 500 | if (rc) | 503 | if (rc) |
| @@ -524,7 +527,7 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq, · 23 unmodified lines | |||
| 524 | if (!ap_msg->msg) | 527 | if (!ap_msg->msg) |
| 525 | return -ENOMEM; | 528 | return -ENOMEM; |
| 526 | ap_msg->receive = zcrypt_cex2a_receive; | 529 | 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) + |
| 528 | atomic_inc_return(&zcrypt_step); | 531 | atomic_inc_return(&zcrypt_step); |
| 529 | ap_msg->private = &work; | 532 | ap_msg->private = &work; |
| 530 | rc = ICACRT_msg_to_type50CRT_msg(zq, ap_msg, crt); | 533 | 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 | |||
| 541 | rc = convert_response_cex2a(zq, ap_msg, | 544 | rc = convert_response_cex2a(zq, ap_msg, |
| 542 | crt->outputdata, | 545 | crt->outputdata, |
| 543 | crt->outputdatalength); | 546 | crt->outputdatalength); |
| 544 | } else | 547 | } else { |
| 545 | /* Signal pending. */ | 548 | /* Signal pending. */ |
| 546 | ap_cancel_message(zq->queue, ap_msg); | 549 | ap_cancel_message(zq->queue, ap_msg); |
| 550 | } | ||
| 551 | |||
| 547 | out: | 552 | out: |
| 548 | ap_msg->private = NULL; | 553 | ap_msg->private = NULL; |
| 549 | if (rc) | 554 | if (rc) |
| @@ -1,6 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0+ | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* | 2 | /* |
| 3 | * Copyright IBM Corp. 2001, 2012 | 3 | * Copyright IBM Corp. 2001, 2022 |
| 4 | * Author(s): Robert Burroughs | 4 | * Author(s): Robert Burroughs |
| 5 | * Eric Rossman (edrossma@us.ibm.com) | 5 | * Eric Rossman (edrossma@us.ibm.com) |
| 6 | * | 6 | * |
| @@ -29,12 +29,13 @@ · 22 unmodified lines | |||
| 29 | 29 | ||
| 30 | #define CEXXC_MAX_ICA_RESPONSE_SIZE 0x77c /* max size type86 v2 reply */ | 30 | #define CEXXC_MAX_ICA_RESPONSE_SIZE 0x77c /* max size type86 v2 reply */ |
| 31 | 31 | ||
| 32 | #define CEIL4(x) ((((x)+3)/4)*4) | 32 | #define CEIL4(x) ((((x) + 3) / 4) * 4) |
| 33 | 33 | ||
| 34 | struct response_type { | 34 | struct response_type { |
| 35 | struct completion work; | 35 | struct completion work; |
| 36 | int type; | 36 | int type; |
| 37 | }; | 37 | }; |
| 38 | |||
| 38 | #define CEXXC_RESPONSE_TYPE_ICA 0 | 39 | #define CEXXC_RESPONSE_TYPE_ICA 0 |
| 39 | #define CEXXC_RESPONSE_TYPE_XCRB 1 | 40 | #define CEXXC_RESPONSE_TYPE_XCRB 1 |
| 40 | #define CEXXC_RESPONSE_TYPE_EP11 2 | 41 | #define CEXXC_RESPONSE_TYPE_EP11 2 |
| @@ -44,63 +45,6 @@ MODULE_DESCRIPTION("Cryptographic Coprocessor (message type 6), " \ · 3 unmodified lines | |||
| 44 | "Copyright IBM Corp. 2001, 2012"); | 45 | "Copyright IBM Corp. 2001, 2012"); |
| 45 | MODULE_LICENSE("GPL"); | 46 | MODULE_LICENSE("GPL"); |
| 46 | 47 | ||
| 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 | |||
| 104 | struct function_and_rules_block { | 48 | struct function_and_rules_block { |
| 105 | unsigned char function_code[2]; | 49 | unsigned char function_code[2]; |
| 106 | unsigned short ulen; | 50 | unsigned short ulen; |
| @@ -235,7 +179,6 @@ int speed_idx_ep11(int req_type) · 128 unmodified lines | |||
| 235 | } | 179 | } |
| 236 | } | 180 | } |
| 237 | 181 | ||
| 238 | |||
| 239 | /* | 182 | /* |
| 240 | * Convert a ICAMEX message to a type6 MEX message. | 183 | * Convert a ICAMEX message to a type6 MEX message. |
| 241 | * | 184 | * |
| @@ -245,7 +188,7 @@ int speed_idx_ep11(int req_type) · 3 unmodified lines | |||
| 245 | * | 188 | * |
| 246 | * Returns 0 on success or negative errno value. | 189 | * Returns 0 on success or negative errno value. |
| 247 | */ | 190 | */ |
| 248 | static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq, | 191 | static int icamex_msg_to_type6mex_msgx(struct zcrypt_queue *zq, |
| 249 | struct ap_message *ap_msg, | 192 | struct ap_message *ap_msg, |
| 250 | struct ica_rsa_modexpo *mex) | 193 | struct ica_rsa_modexpo *mex) |
| 251 | { | 194 | { |
| @@ -283,19 +226,19 @@ static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq, · 31 unmodified lines | |||
| 283 | return -EFAULT; | 226 | return -EFAULT; |
| 284 | 227 | ||
| 285 | /* Set up key which is located after the variable length text. */ | 228 | /* 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); |
| 287 | if (size < 0) | 230 | if (size < 0) |
| 288 | return size; | 231 | return size; |
| 289 | size += sizeof(*msg) + mex->inputdatalength; | 232 | size += sizeof(*msg) + mex->inputdatalength; |
| 290 | 233 | ||
| 291 | /* message header, cprbx and f&r */ | 234 | /* message header, cprbx and f&r */ |
| 292 | msg->hdr = static_type6_hdrX; | 235 | msg->hdr = static_type6_hdrX; |
| 293 | msg->hdr.ToCardLen1 = size - sizeof(msg->hdr); | 236 | msg->hdr.tocardlen1 = size - sizeof(msg->hdr); |
| 294 | msg->hdr.FromCardLen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr); | 237 | msg->hdr.fromcardlen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr); |
| 295 | 238 | ||
| 296 | msg->cprbx = static_cprbx; | 239 | msg->cprbx = static_cprbx; |
| 297 | msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid); | 240 | 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; |
| 299 | 242 | ||
| 300 | msg->fr = static_pke_fnr; | 243 | msg->fr = static_pke_fnr; |
| 301 | 244 | ||
| @@ -314,7 +257,7 @@ static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq, · 12 unmodified lines | |||
| 314 | * | 257 | * |
| 315 | * Returns 0 on success or negative errno value. | 258 | * Returns 0 on success or negative errno value. |
| 316 | */ | 259 | */ |
| 317 | static int ICACRT_msg_to_type6CRT_msgX(struct zcrypt_queue *zq, | 260 | static int icacrt_msg_to_type6crt_msgx(struct zcrypt_queue *zq, |
| 318 | struct ap_message *ap_msg, | 261 | struct ap_message *ap_msg, |
| 319 | struct ica_rsa_modexpo_crt *crt) | 262 | struct ica_rsa_modexpo_crt *crt) |
| 320 | { | 263 | { |
| @@ -360,8 +303,8 @@ static int ICACRT_msg_to_type6CRT_msgX(struct zcrypt_queue *zq, · 39 unmodified lines | |||
| 360 | 303 | ||
| 361 | /* message header, cprbx and f&r */ | 304 | /* message header, cprbx and f&r */ |
| 362 | msg->hdr = static_type6_hdrX; | 305 | msg->hdr = static_type6_hdrX; |
| 363 | msg->hdr.ToCardLen1 = size - sizeof(msg->hdr); | 306 | msg->hdr.tocardlen1 = size - sizeof(msg->hdr); |
| 364 | msg->hdr.FromCardLen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr); | 307 | msg->hdr.fromcardlen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr); |
| 365 | 308 | ||
| 366 | msg->cprbx = static_cprbx; | 309 | msg->cprbx = static_cprbx; |
| 367 | msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid); | 310 | msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid); |
| @@ -388,8 +331,8 @@ struct type86_fmt2_msg { · 20 unmodified lines | |||
| 388 | struct type86_fmt2_ext fmt2; | 331 | struct type86_fmt2_ext fmt2; |
| 389 | } __packed; | 332 | } __packed; |
| 390 | 333 | ||
| 391 | static int XCRB_msg_to_type6CPRB_msgX(bool userspace, struct ap_message *ap_msg, | 334 | static int xcrb_msg_to_type6cprb_msgx(bool userspace, struct ap_message *ap_msg, |
| 392 | struct ica_xcRB *xcRB, | 335 | struct ica_xcRB *xcrb, |
| 393 | unsigned int *fcode, | 336 | unsigned int *fcode, |
| 394 | unsigned short **dom) | 337 | unsigned short **dom) |
| 395 | { | 338 | { |
| @@ -402,19 +345,19 @@ static int XCRB_msg_to_type6CPRB_msgX(bool userspace, struct ap_message *ap_msg, · 6 unmodified lines | |||
| 402 | struct CPRBX cprbx; | 345 | struct CPRBX cprbx; |
| 403 | } __packed * msg = ap_msg->msg; | 346 | } __packed * msg = ap_msg->msg; |
| 404 | 347 | ||
| 405 | int rcblen = CEIL4(xcRB->request_control_blk_length); | 348 | int rcblen = CEIL4(xcrb->request_control_blk_length); |
| 406 | int req_sumlen, resp_sumlen; | 349 | int req_sumlen, resp_sumlen; |
| 407 | char *req_data = ap_msg->msg + sizeof(struct type6_hdr) + rcblen; | 350 | char *req_data = ap_msg->msg + sizeof(struct type6_hdr) + rcblen; |
| 408 | char *function_code; | 351 | char *function_code; |
| 409 | 352 | ||
| 410 | if (CEIL4(xcRB->request_control_blk_length) < | 353 | if (CEIL4(xcrb->request_control_blk_length) < |
| 411 | xcRB->request_control_blk_length) | 354 | xcrb->request_control_blk_length) |
| 412 | return -EINVAL; /* overflow after alignment*/ | 355 | return -EINVAL; /* overflow after alignment*/ |
| 413 | 356 | ||
| 414 | /* length checks */ | 357 | /* length checks */ |
| 415 | ap_msg->len = sizeof(struct type6_hdr) + | 358 | ap_msg->len = sizeof(struct type6_hdr) + |
| 416 | CEIL4(xcRB->request_control_blk_length) + | 359 | CEIL4(xcrb->request_control_blk_length) + |
| 417 | xcRB->request_data_length; | 360 | xcrb->request_data_length; |
| 418 | if (ap_msg->len > ap_msg->bufsize) | 361 | if (ap_msg->len > ap_msg->bufsize) |
| 419 | return -EINVAL; | 362 | return -EINVAL; |
| 420 | 363 | ||
| @@ -422,48 +365,49 @@ static int XCRB_msg_to_type6CPRB_msgX(bool userspace, struct ap_message *ap_msg, · 1 unmodified line | |||
| 422 | * Overflow check | 365 | * Overflow check |
| 423 | * sum must be greater (or equal) than the largest operand | 366 | * sum must be greater (or equal) than the largest operand |
| 424 | */ | 367 | */ |
| 425 | req_sumlen = CEIL4(xcRB->request_control_blk_length) + | 368 | req_sumlen = CEIL4(xcrb->request_control_blk_length) + |
| 426 | xcRB->request_data_length; | 369 | xcrb->request_data_length; |
| 427 | if ((CEIL4(xcRB->request_control_blk_length) <= | 370 | if ((CEIL4(xcrb->request_control_blk_length) <= |
| 428 | xcRB->request_data_length) ? | 371 | xcrb->request_data_length) ? |
| 429 | (req_sumlen < xcRB->request_data_length) : | 372 | req_sumlen < xcrb->request_data_length : |
| 430 | (req_sumlen < CEIL4(xcRB->request_control_blk_length))) { | 373 | req_sumlen < CEIL4(xcrb->request_control_blk_length)) { |
| 431 | return -EINVAL; | 374 | return -EINVAL; |
| 432 | } | 375 | } |
| 433 | 376 | ||
| 434 | if (CEIL4(xcRB->reply_control_blk_length) < | 377 | if (CEIL4(xcrb->reply_control_blk_length) < |
| 435 | xcRB->reply_control_blk_length) | 378 | xcrb->reply_control_blk_length) |
| 436 | return -EINVAL; /* overflow after alignment*/ | 379 | return -EINVAL; /* overflow after alignment*/ |
| 437 | 380 | ||
| 438 | /* | 381 | /* |
| 439 | * Overflow check | 382 | * Overflow check |
| 440 | * sum must be greater (or equal) than the largest operand | 383 | * sum must be greater (or equal) than the largest operand |
| 441 | */ | 384 | */ |
| 442 | resp_sumlen = CEIL4(xcRB->reply_control_blk_length) + | 385 | resp_sumlen = CEIL4(xcrb->reply_control_blk_length) + |
| 443 | xcRB->reply_data_length; | 386 | xcrb->reply_data_length; |
| 444 | if ((CEIL4(xcRB->reply_control_blk_length) <= xcRB->reply_data_length) ? | 387 | if ((CEIL4(xcrb->reply_control_blk_length) <= |
| 445 | (resp_sumlen < xcRB->reply_data_length) : | 388 | xcrb->reply_data_length) ? |
| 446 | (resp_sumlen < CEIL4(xcRB->reply_control_blk_length))) { | 389 | resp_sumlen < xcrb->reply_data_length : |
| 390 | resp_sumlen < CEIL4(xcrb->reply_control_blk_length)) { | ||
| 447 | return -EINVAL; | 391 | return -EINVAL; |
| 448 | } | 392 | } |
| 449 | 393 | ||
| 450 | /* prepare type6 header */ | 394 | /* prepare type6 header */ |
| 451 | msg->hdr = static_type6_hdrX; | 395 | msg->hdr = static_type6_hdrX; |
| 452 | memcpy(msg->hdr.agent_id, &(xcRB->agent_ID), sizeof(xcRB->agent_ID)); | 396 | memcpy(msg->hdr.agent_id, &xcrb->agent_ID, sizeof(xcrb->agent_ID)); |
| 453 | msg->hdr.ToCardLen1 = xcRB->request_control_blk_length; | 397 | msg->hdr.tocardlen1 = xcrb->request_control_blk_length; |
| 454 | if (xcRB->request_data_length) { | 398 | if (xcrb->request_data_length) { |
| 455 | msg->hdr.offset2 = msg->hdr.offset1 + rcblen; | 399 | msg->hdr.offset2 = msg->hdr.offset1 + rcblen; |
| 456 | msg->hdr.ToCardLen2 = xcRB->request_data_length; | 400 | msg->hdr.tocardlen2 = xcrb->request_data_length; |
| 457 | } | 401 | } |
| 458 | msg->hdr.FromCardLen1 = xcRB->reply_control_blk_length; | 402 | msg->hdr.fromcardlen1 = xcrb->reply_control_blk_length; |
| 459 | msg->hdr.FromCardLen2 = xcRB->reply_data_length; | 403 | msg->hdr.fromcardlen2 = xcrb->reply_data_length; |
| 460 | 404 | ||
| 461 | /* prepare CPRB */ | 405 | /* prepare CPRB */ |
| 462 | if (z_copy_from_user(userspace, &(msg->cprbx), xcRB->request_control_blk_addr, | 406 | if (z_copy_from_user(userspace, &msg->cprbx, xcrb->request_control_blk_addr, |
| 463 | xcRB->request_control_blk_length)) | 407 | xcrb->request_control_blk_length)) |
| 464 | return -EFAULT; | 408 | return -EFAULT; |
| 465 | if (msg->cprbx.cprb_len + sizeof(msg->hdr.function_code) > | 409 | if (msg->cprbx.cprb_len + sizeof(msg->hdr.function_code) > |
| 466 | xcRB->request_control_blk_length) | 410 | xcrb->request_control_blk_length) |
| 467 | return -EINVAL; | 411 | return -EINVAL; |
| 468 | function_code = ((unsigned char *)&msg->cprbx) + msg->cprbx.cprb_len; | 412 | function_code = ((unsigned char *)&msg->cprbx) + msg->cprbx.cprb_len; |
| 469 | memcpy(msg->hdr.function_code, function_code, | 413 | 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 | |||
| 473 | *dom = (unsigned short *)&msg->cprbx.domain; | 417 | *dom = (unsigned short *)&msg->cprbx.domain; |
| 474 | 418 | ||
| 475 | /* check subfunction, US and AU need special flag with NQAP */ | 419 | /* check subfunction, US and AU need special flag with NQAP */ |
| 476 | if (memcmp(function_code, "US", 2) == 0 | 420 | if (memcmp(function_code, "US", 2) == 0 || |
| 477 | || memcmp(function_code, "AU", 2) == 0) | 421 | memcmp(function_code, "AU", 2) == 0) |
| 478 | ap_msg->flags |= AP_MSG_FLAG_SPECIAL; | 422 | ap_msg->flags |= AP_MSG_FLAG_SPECIAL; |
| 479 | 423 | ||
| 480 | #ifdef CONFIG_ZCRYPT_DEBUG | 424 | #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 | |||
| 500 | } | 444 | } |
| 501 | 445 | ||
| 502 | /* copy data block */ | 446 | /* copy data block */ |
| 503 | if (xcRB->request_data_length && | 447 | if (xcrb->request_data_length && |
| 504 | z_copy_from_user(userspace, req_data, xcRB->request_data_address, | 448 | z_copy_from_user(userspace, req_data, xcrb->request_data_address, |
| 505 | xcRB->request_data_length)) | 449 | xcrb->request_data_length)) |
| 506 | return -EFAULT; | 450 | return -EFAULT; |
| 507 | 451 | ||
| 508 | return 0; | 452 | return 0; |
| 509 | } | 453 | } |
| 510 | 454 | ||
| 511 | static int xcrb_msg_to_type6_ep11cprb_msgx(bool userspace, struct ap_message *ap_msg, | 455 | 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, |
| 513 | unsigned int *fcode, | 457 | unsigned int *fcode, |
| 514 | unsigned int *domain) | 458 | unsigned int *domain) |
| 515 | { | 459 | { |
| @@ -539,25 +483,25 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(bool userspace, struct ap_message *ap · 23 unmodified lines | |||
| 539 | unsigned int dom_val; /* domain id */ | 483 | unsigned int dom_val; /* domain id */ |
| 540 | } __packed * payload_hdr = NULL; | 484 | } __packed * payload_hdr = NULL; |
| 541 | 485 | ||
| 542 | if (CEIL4(xcRB->req_len) < xcRB->req_len) | 486 | if (CEIL4(xcrb->req_len) < xcrb->req_len) |
| 543 | return -EINVAL; /* overflow after alignment*/ | 487 | return -EINVAL; /* overflow after alignment*/ |
| 544 | 488 | ||
| 545 | /* length checks */ | 489 | /* 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); |
| 547 | if (ap_msg->len > ap_msg->bufsize) | 491 | if (ap_msg->len > ap_msg->bufsize) |
| 548 | return -EINVAL; | 492 | return -EINVAL; |
| 549 | 493 | ||
| 550 | if (CEIL4(xcRB->resp_len) < xcRB->resp_len) | 494 | if (CEIL4(xcrb->resp_len) < xcrb->resp_len) |
| 551 | return -EINVAL; /* overflow after alignment*/ | 495 | return -EINVAL; /* overflow after alignment*/ |
| 552 | 496 | ||
| 553 | /* prepare type6 header */ | 497 | /* prepare type6 header */ |
| 554 | msg->hdr = static_type6_ep11_hdr; | 498 | msg->hdr = static_type6_ep11_hdr; |
| 555 | msg->hdr.ToCardLen1 = xcRB->req_len; | 499 | msg->hdr.tocardlen1 = xcrb->req_len; |
| 556 | msg->hdr.FromCardLen1 = xcRB->resp_len; | 500 | msg->hdr.fromcardlen1 = xcrb->resp_len; |
| 557 | 501 | ||
| 558 | /* Import CPRB data from the ioctl input parameter */ | 502 | /* Import CPRB data from the ioctl input parameter */ |
| 559 | if (z_copy_from_user(userspace, &(msg->cprbx.cprb_len), | 503 | if (z_copy_from_user(userspace, &msg->cprbx.cprb_len, |
| 560 | (char __force __user *)xcRB->req, xcRB->req_len)) { | 504 | (char __force __user *)xcrb->req, xcrb->req_len)) { |
| 561 | return -EFAULT; | 505 | return -EFAULT; |
| 562 | } | 506 | } |
| 563 | 507 | ||
| @@ -575,7 +519,7 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(bool userspace, struct ap_message *ap · 11 unmodified lines | |||
| 575 | } else { | 519 | } else { |
| 576 | lfmt = 1; /* length format #1 */ | 520 | lfmt = 1; /* length format #1 */ |
| 577 | } | 521 | } |
| 578 | payload_hdr = (struct pld_hdr *)((&(msg->pld_lenfmt))+lfmt); | 522 | payload_hdr = (struct pld_hdr *)((&msg->pld_lenfmt) + lfmt); |
| 579 | *fcode = payload_hdr->func_val & 0xFFFF; | 523 | *fcode = payload_hdr->func_val & 0xFFFF; |
| 580 | 524 | ||
| 581 | /* enable special processing based on the cprbs flags special bit */ | 525 | /* enable special processing based on the cprbs flags special bit */ |
| @@ -624,9 +568,9 @@ struct type86_ep11_reply { · 42 unmodified lines | |||
| 624 | } __packed; | 568 | } __packed; |
| 625 | 569 | ||
| 626 | static int convert_type86_ica(struct zcrypt_queue *zq, | 570 | static int convert_type86_ica(struct zcrypt_queue *zq, |
| 627 | struct ap_message *reply, | 571 | struct ap_message *reply, |
| 628 | char __user *outputdata, | 572 | char __user *outputdata, |
| 629 | unsigned int outputdatalength) | 573 | unsigned int outputdatalength) |
| 630 | { | 574 | { |
| 631 | static unsigned char static_pad[] = { | 575 | static unsigned char static_pad[] = { |
| 632 | 0x00, 0x02, | 576 | 0x00, 0x02, |
| @@ -679,18 +623,18 @@ static int convert_type86_ica(struct zcrypt_queue *zq, · 46 unmodified lines | |||
| 679 | ZCRYPT_DBF_WARN("%s dev=%02x.%04x rc/rs=%d/%d => rc=EINVAL\n", | 623 | ZCRYPT_DBF_WARN("%s dev=%02x.%04x rc/rs=%d/%d => rc=EINVAL\n", |
| 680 | __func__, AP_QID_CARD(zq->queue->qid), | 624 | __func__, AP_QID_CARD(zq->queue->qid), |
| 681 | AP_QID_QUEUE(zq->queue->qid), | 625 | AP_QID_QUEUE(zq->queue->qid), |
| 682 | (int) service_rc, (int) service_rs); | 626 | (int)service_rc, (int)service_rs); |
| 683 | return -EINVAL; | 627 | return -EINVAL; |
| 684 | } | 628 | } |
| 685 | zq->online = 0; | 629 | zq->online = 0; |
| 686 | pr_err("Crypto dev=%02x.%04x rc/rs=%d/%d online=0 rc=EAGAIN\n", | 630 | pr_err("Crypto dev=%02x.%04x rc/rs=%d/%d online=0 rc=EAGAIN\n", |
| 687 | AP_QID_CARD(zq->queue->qid), | 631 | AP_QID_CARD(zq->queue->qid), |
| 688 | AP_QID_QUEUE(zq->queue->qid), | 632 | AP_QID_QUEUE(zq->queue->qid), |
| 689 | (int) service_rc, (int) service_rs); | 633 | (int)service_rc, (int)service_rs); |
| 690 | ZCRYPT_DBF_ERR("%s dev=%02x.%04x rc/rs=%d/%d => online=0 rc=EAGAIN\n", | 634 | ZCRYPT_DBF_ERR("%s dev=%02x.%04x rc/rs=%d/%d => online=0 rc=EAGAIN\n", |
| 691 | __func__, AP_QID_CARD(zq->queue->qid), | 635 | __func__, AP_QID_CARD(zq->queue->qid), |
| 692 | AP_QID_QUEUE(zq->queue->qid), | 636 | AP_QID_QUEUE(zq->queue->qid), |
| 693 | (int) service_rc, (int) service_rs); | 637 | (int)service_rc, (int)service_rs); |
| 694 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); | 638 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); |
| 695 | return -EAGAIN; | 639 | return -EAGAIN; |
| 696 | } | 640 | } |
| @@ -729,42 +673,42 @@ static int convert_type86_ica(struct zcrypt_queue *zq, · 32 unmodified lines | |||
| 729 | * | 673 | * |
| 730 | * @zq: crypto device pointer | 674 | * @zq: crypto device pointer |
| 731 | * @reply: reply AP message. | 675 | * @reply: reply AP message. |
| 732 | * @xcRB: pointer to XCRB | 676 | * @xcrb: pointer to XCRB |
| 733 | * | 677 | * |
| 734 | * Returns 0 on success or -EINVAL, -EFAULT, -EAGAIN in case of an error. | 678 | * Returns 0 on success or -EINVAL, -EFAULT, -EAGAIN in case of an error. |
| 735 | */ | 679 | */ |
| 736 | static int convert_type86_xcrb(bool userspace, struct zcrypt_queue *zq, | 680 | static int convert_type86_xcrb(bool userspace, struct zcrypt_queue *zq, |
| 737 | struct ap_message *reply, | 681 | struct ap_message *reply, |
| 738 | struct ica_xcRB *xcRB) | 682 | struct ica_xcRB *xcrb) |
| 739 | { | 683 | { |
| 740 | struct type86_fmt2_msg *msg = reply->msg; | 684 | struct type86_fmt2_msg *msg = reply->msg; |
| 741 | char *data = reply->msg; | 685 | char *data = reply->msg; |
| 742 | 686 | ||
| 743 | /* Copy CPRB to user */ | 687 | /* Copy CPRB to user */ |
| 744 | if (xcRB->reply_control_blk_length < msg->fmt2.count1) { | 688 | if (xcrb->reply_control_blk_length < msg->fmt2.count1) { |
| 745 | ZCRYPT_DBF_DBG("%s reply_control_blk_length %u < required %u => EMSGSIZE\n", | 689 | 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, |
| 747 | msg->fmt2.count1); | 691 | msg->fmt2.count1); |
| 748 | return -EMSGSIZE; | 692 | return -EMSGSIZE; |
| 749 | } | 693 | } |
| 750 | if (z_copy_to_user(userspace, xcRB->reply_control_blk_addr, | 694 | if (z_copy_to_user(userspace, xcrb->reply_control_blk_addr, |
| 751 | data + msg->fmt2.offset1, msg->fmt2.count1)) | 695 | data + msg->fmt2.offset1, msg->fmt2.count1)) |
| 752 | return -EFAULT; | 696 | return -EFAULT; |
| 753 | xcRB->reply_control_blk_length = msg->fmt2.count1; | 697 | xcrb->reply_control_blk_length = msg->fmt2.count1; |
| 754 | 698 | ||
| 755 | /* Copy data buffer to user */ | 699 | /* Copy data buffer to user */ |
| 756 | if (msg->fmt2.count2) { | 700 | if (msg->fmt2.count2) { |
| 757 | if (xcRB->reply_data_length < msg->fmt2.count2) { | 701 | if (xcrb->reply_data_length < msg->fmt2.count2) { |
| 758 | ZCRYPT_DBF_DBG("%s reply_data_length %u < required %u => EMSGSIZE\n", | 702 | ZCRYPT_DBF_DBG("%s reply_data_length %u < required %u => EMSGSIZE\n", |
| 759 | __func__, xcRB->reply_data_length, | 703 | __func__, xcrb->reply_data_length, |
| 760 | msg->fmt2.count2); | 704 | msg->fmt2.count2); |
| 761 | return -EMSGSIZE; | 705 | return -EMSGSIZE; |
| 762 | } | 706 | } |
| 763 | if (z_copy_to_user(userspace, xcRB->reply_data_addr, | 707 | if (z_copy_to_user(userspace, xcrb->reply_data_addr, |
| 764 | data + msg->fmt2.offset2, msg->fmt2.count2)) | 708 | data + msg->fmt2.offset2, msg->fmt2.count2)) |
| 765 | return -EFAULT; | 709 | return -EFAULT; |
| 766 | } | 710 | } |
| 767 | xcRB->reply_data_length = msg->fmt2.count2; | 711 | xcrb->reply_data_length = msg->fmt2.count2; |
| 768 | 712 | ||
| 769 | return 0; | 713 | return 0; |
| 770 | } | 714 | } |
| @@ -774,35 +718,35 @@ static int convert_type86_xcrb(bool userspace, struct zcrypt_queue *zq, · 3 unmodified lines | |||
| 774 | * | 718 | * |
| 775 | * @zq: crypto device pointer | 719 | * @zq: crypto device pointer |
| 776 | * @reply: reply AP message. | 720 | * @reply: reply AP message. |
| 777 | * @xcRB: pointer to EP11 user request block | 721 | * @xcrb: pointer to EP11 user request block |
| 778 | * | 722 | * |
| 779 | * Returns 0 on success or -EINVAL, -EFAULT, -EAGAIN in case of an error. | 723 | * Returns 0 on success or -EINVAL, -EFAULT, -EAGAIN in case of an error. |
| 780 | */ | 724 | */ |
| 781 | static int convert_type86_ep11_xcrb(bool userspace, struct zcrypt_queue *zq, | 725 | static int convert_type86_ep11_xcrb(bool userspace, struct zcrypt_queue *zq, |
| 782 | struct ap_message *reply, | 726 | struct ap_message *reply, |
| 783 | struct ep11_urb *xcRB) | 727 | struct ep11_urb *xcrb) |
| 784 | { | 728 | { |
| 785 | struct type86_fmt2_msg *msg = reply->msg; | 729 | struct type86_fmt2_msg *msg = reply->msg; |
| 786 | char *data = reply->msg; | 730 | char *data = reply->msg; |
| 787 | 731 | ||
| 788 | if (xcRB->resp_len < msg->fmt2.count1) { | 732 | if (xcrb->resp_len < msg->fmt2.count1) { |
| 789 | ZCRYPT_DBF_DBG("%s resp_len %u < required %u => EMSGSIZE\n", | 733 | 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, |
| 791 | msg->fmt2.count1); | 735 | msg->fmt2.count1); |
| 792 | return -EMSGSIZE; | 736 | return -EMSGSIZE; |
| 793 | } | 737 | } |
| 794 | 738 | ||
| 795 | /* Copy response CPRB to user */ | 739 | /* 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, |
| 797 | data + msg->fmt2.offset1, msg->fmt2.count1)) | 741 | data + msg->fmt2.offset1, msg->fmt2.count1)) |
| 798 | return -EFAULT; | 742 | return -EFAULT; |
| 799 | xcRB->resp_len = msg->fmt2.count1; | 743 | xcrb->resp_len = msg->fmt2.count1; |
| 800 | return 0; | 744 | return 0; |
| 801 | } | 745 | } |
| 802 | 746 | ||
| 803 | static int convert_type86_rng(struct zcrypt_queue *zq, | 747 | static int convert_type86_rng(struct zcrypt_queue *zq, |
| 804 | struct ap_message *reply, | 748 | struct ap_message *reply, |
| 805 | char *buffer) | 749 | char *buffer) |
| 806 | { | 750 | { |
| 807 | struct { | 751 | struct { |
| 808 | struct type86_hdr hdr; | 752 | struct type86_hdr hdr; |
| @@ -818,9 +762,9 @@ static int convert_type86_rng(struct zcrypt_queue *zq, · 9 unmodified lines | |||
| 818 | } | 762 | } |
| 819 | 763 | ||
| 820 | static int convert_response_ica(struct zcrypt_queue *zq, | 764 | static int convert_response_ica(struct zcrypt_queue *zq, |
| 821 | struct ap_message *reply, | 765 | struct ap_message *reply, |
| 822 | char __user *outputdata, | 766 | char __user *outputdata, |
| 823 | unsigned int outputdatalength) | 767 | unsigned int outputdatalength) |
| 824 | { | 768 | { |
| 825 | struct type86x_reply *msg = reply->msg; | 769 | struct type86x_reply *msg = reply->msg; |
| 826 | 770 | ||
| @@ -830,13 +774,14 @@ static int convert_response_ica(struct zcrypt_queue *zq, · 3 unmodified lines | |||
| 830 | return convert_error(zq, reply); | 774 | return convert_error(zq, reply); |
| 831 | case TYPE86_RSP_CODE: | 775 | case TYPE86_RSP_CODE: |
| 832 | if (msg->cprbx.ccp_rtcode && | 776 | if (msg->cprbx.ccp_rtcode && |
| 833 | (msg->cprbx.ccp_rscode == 0x14f) && | 777 | msg->cprbx.ccp_rscode == 0x14f && |
| 834 | (outputdatalength > 256)) { | 778 | outputdatalength > 256) { |
| 835 | if (zq->zcard->max_exp_bit_length <= 17) { | 779 | if (zq->zcard->max_exp_bit_length <= 17) { |
| 836 | zq->zcard->max_exp_bit_length = 17; | 780 | zq->zcard->max_exp_bit_length = 17; |
| 837 | return -EAGAIN; | 781 | return -EAGAIN; |
| 838 | } else | 782 | } else { |
| 839 | return -EINVAL; | 783 | return -EINVAL; |
| 784 | } | ||
| 840 | } | 785 | } |
| 841 | if (msg->hdr.reply_code) | 786 | if (msg->hdr.reply_code) |
| 842 | return convert_error(zq, reply); | 787 | return convert_error(zq, reply); |
| @@ -850,11 +795,11 @@ static int convert_response_ica(struct zcrypt_queue *zq, · 7 unmodified lines | |||
| 850 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 795 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 851 | AP_QID_CARD(zq->queue->qid), | 796 | AP_QID_CARD(zq->queue->qid), |
| 852 | AP_QID_QUEUE(zq->queue->qid), | 797 | AP_QID_QUEUE(zq->queue->qid), |
| 853 | (int) msg->hdr.type); | 798 | (int)msg->hdr.type); |
| 854 | ZCRYPT_DBF_ERR( | 799 | ZCRYPT_DBF_ERR( |
| 855 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 800 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 856 | __func__, AP_QID_CARD(zq->queue->qid), | 801 | __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); |
| 858 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); | 803 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); |
| 859 | return -EAGAIN; | 804 | return -EAGAIN; |
| 860 | } | 805 | } |
| @@ -862,41 +807,41 @@ static int convert_response_ica(struct zcrypt_queue *zq, · 1 unmodified line | |||
| 862 | 807 | ||
| 863 | static int convert_response_xcrb(bool userspace, struct zcrypt_queue *zq, | 808 | static int convert_response_xcrb(bool userspace, struct zcrypt_queue *zq, |
| 864 | struct ap_message *reply, | 809 | struct ap_message *reply, |
| 865 | struct ica_xcRB *xcRB) | 810 | struct ica_xcRB *xcrb) |
| 866 | { | 811 | { |
| 867 | struct type86x_reply *msg = reply->msg; | 812 | struct type86x_reply *msg = reply->msg; |
| 868 | 813 | ||
| 869 | switch (msg->hdr.type) { | 814 | switch (msg->hdr.type) { |
| 870 | case TYPE82_RSP_CODE: | 815 | case TYPE82_RSP_CODE: |
| 871 | case TYPE88_RSP_CODE: | 816 | case TYPE88_RSP_CODE: |
| 872 | xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ | 817 | xcrb->status = 0x0008044DL; /* HDD_InvalidParm */ |
| 873 | return convert_error(zq, reply); | 818 | return convert_error(zq, reply); |
| 874 | case TYPE86_RSP_CODE: | 819 | case TYPE86_RSP_CODE: |
| 875 | if (msg->hdr.reply_code) { | 820 | if (msg->hdr.reply_code) { |
| 876 | memcpy(&(xcRB->status), msg->fmt2.apfs, sizeof(u32)); | 821 | memcpy(&xcrb->status, msg->fmt2.apfs, sizeof(u32)); |
| 877 | return convert_error(zq, reply); | 822 | return convert_error(zq, reply); |
| 878 | } | 823 | } |
| 879 | if (msg->cprbx.cprb_ver_id == 0x02) | 824 | 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); |
| 881 | fallthrough; /* wrong cprb version is an unknown response */ | 826 | fallthrough; /* wrong cprb version is an unknown response */ |
| 882 | default: /* Unknown response type, this should NEVER EVER happen */ | 827 | default: /* Unknown response type, this should NEVER EVER happen */ |
| 883 | xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ | 828 | xcrb->status = 0x0008044DL; /* HDD_InvalidParm */ |
| 884 | zq->online = 0; | 829 | zq->online = 0; |
| 885 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 830 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 886 | AP_QID_CARD(zq->queue->qid), | 831 | AP_QID_CARD(zq->queue->qid), |
| 887 | AP_QID_QUEUE(zq->queue->qid), | 832 | AP_QID_QUEUE(zq->queue->qid), |
| 888 | (int) msg->hdr.type); | 833 | (int)msg->hdr.type); |
| 889 | ZCRYPT_DBF_ERR( | 834 | ZCRYPT_DBF_ERR( |
| 890 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 835 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 891 | __func__, AP_QID_CARD(zq->queue->qid), | 836 | __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); |
| 893 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); | 838 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); |
| 894 | return -EAGAIN; | 839 | return -EAGAIN; |
| 895 | } | 840 | } |
| 896 | } | 841 | } |
| 897 | 842 | ||
| 898 | static int convert_response_ep11_xcrb(bool userspace, struct zcrypt_queue *zq, | 843 | 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) |
| 900 | { | 845 | { |
| 901 | struct type86_ep11_reply *msg = reply->msg; | 846 | struct type86_ep11_reply *msg = reply->msg; |
| 902 | 847 | ||
| @@ -908,26 +853,26 @@ static int convert_response_ep11_xcrb(bool userspace, struct zcrypt_queue *zq, · 5 unmodified lines | |||
| 908 | if (msg->hdr.reply_code) | 853 | if (msg->hdr.reply_code) |
| 909 | return convert_error(zq, reply); | 854 | return convert_error(zq, reply); |
| 910 | if (msg->cprbx.cprb_ver_id == 0x04) | 855 | 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); |
| 912 | fallthrough; /* wrong cprb version is an unknown resp */ | 857 | fallthrough; /* wrong cprb version is an unknown resp */ |
| 913 | default: /* Unknown response type, this should NEVER EVER happen */ | 858 | default: /* Unknown response type, this should NEVER EVER happen */ |
| 914 | zq->online = 0; | 859 | zq->online = 0; |
| 915 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 860 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 916 | AP_QID_CARD(zq->queue->qid), | 861 | AP_QID_CARD(zq->queue->qid), |
| 917 | AP_QID_QUEUE(zq->queue->qid), | 862 | AP_QID_QUEUE(zq->queue->qid), |
| 918 | (int) msg->hdr.type); | 863 | (int)msg->hdr.type); |
| 919 | ZCRYPT_DBF_ERR( | 864 | ZCRYPT_DBF_ERR( |
| 920 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 865 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 921 | __func__, AP_QID_CARD(zq->queue->qid), | 866 | __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); |
| 923 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); | 868 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); |
| 924 | return -EAGAIN; | 869 | return -EAGAIN; |
| 925 | } | 870 | } |
| 926 | } | 871 | } |
| 927 | 872 | ||
| 928 | static int convert_response_rng(struct zcrypt_queue *zq, | 873 | static int convert_response_rng(struct zcrypt_queue *zq, |
| 929 | struct ap_message *reply, | 874 | struct ap_message *reply, |
| 930 | char *data) | 875 | char *data) |
| 931 | { | 876 | { |
| 932 | struct type86x_reply *msg = reply->msg; | 877 | struct type86x_reply *msg = reply->msg; |
| 933 | 878 | ||
| @@ -946,11 +891,11 @@ static int convert_response_rng(struct zcrypt_queue *zq, · 12 unmodified lines | |||
| 946 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 891 | pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 947 | AP_QID_CARD(zq->queue->qid), | 892 | AP_QID_CARD(zq->queue->qid), |
| 948 | AP_QID_QUEUE(zq->queue->qid), | 893 | AP_QID_QUEUE(zq->queue->qid), |
| 949 | (int) msg->hdr.type); | 894 | (int)msg->hdr.type); |
| 950 | ZCRYPT_DBF_ERR( | 895 | ZCRYPT_DBF_ERR( |
| 951 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", | 896 | "%s dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", |
| 952 | __func__, AP_QID_CARD(zq->queue->qid), | 897 | __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); |
| 954 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); | 899 | ap_send_online_uevent(&zq->queue->ap_dev, zq->online); |
| 955 | return -EAGAIN; | 900 | return -EAGAIN; |
| 956 | } | 901 | } |
| @@ -965,15 +910,15 @@ static int convert_response_rng(struct zcrypt_queue *zq, · 8 unmodified lines | |||
| 965 | * @reply: pointer to the AP reply message | 910 | * @reply: pointer to the AP reply message |
| 966 | */ | 911 | */ |
| 967 | static void zcrypt_msgtype6_receive(struct ap_queue *aq, | 912 | static void zcrypt_msgtype6_receive(struct ap_queue *aq, |
| 968 | struct ap_message *msg, | 913 | struct ap_message *msg, |
| 969 | struct ap_message *reply) | 914 | struct ap_message *reply) |
| 970 | { | 915 | { |
| 971 | static struct error_hdr error_reply = { | 916 | static struct error_hdr error_reply = { |
| 972 | .type = TYPE82_RSP_CODE, | 917 | .type = TYPE82_RSP_CODE, |
| 973 | .reply_code = REP82_ERROR_MACHINE_FAILURE, | 918 | .reply_code = REP82_ERROR_MACHINE_FAILURE, |
| 974 | }; | 919 | }; |
| 975 | struct response_type *resp_type = | 920 | struct response_type *resp_type = |
| 976 | (struct response_type *) msg->private; | 921 | (struct response_type *)msg->private; |
| 977 | struct type86x_reply *t86r; | 922 | struct type86x_reply *t86r; |
| 978 | int len; | 923 | int len; |
| 979 | 924 | ||
| @@ -982,7 +927,7 @@ static void zcrypt_msgtype6_receive(struct ap_queue *aq, · 2 unmodified lines | |||
| 982 | goto out; /* ap_msg->rc indicates the error */ | 927 | goto out; /* ap_msg->rc indicates the error */ |
| 983 | t86r = reply->msg; | 928 | t86r = reply->msg; |
| 984 | if (t86r->hdr.type == TYPE86_RSP_CODE && | 929 | if (t86r->hdr.type == TYPE86_RSP_CODE && |
| 985 | t86r->cprbx.cprb_ver_id == 0x02) { | 930 | t86r->cprbx.cprb_ver_id == 0x02) { |
| 986 | switch (resp_type->type) { | 931 | switch (resp_type->type) { |
| 987 | case CEXXC_RESPONSE_TYPE_ICA: | 932 | case CEXXC_RESPONSE_TYPE_ICA: |
| 988 | len = sizeof(struct type86x_reply) + t86r->length - 2; | 933 | len = sizeof(struct type86x_reply) + t86r->length - 2; |
| @@ -1005,10 +950,11 @@ static void zcrypt_msgtype6_receive(struct ap_queue *aq, · 16 unmodified lines | |||
| 1005 | default: | 950 | default: |
| 1006 | memcpy(msg->msg, &error_reply, sizeof(error_reply)); | 951 | memcpy(msg->msg, &error_reply, sizeof(error_reply)); |
| 1007 | } | 952 | } |
| 1008 | } else | 953 | } else { |
| 1009 | memcpy(msg->msg, reply->msg, sizeof(error_reply)); | 954 | memcpy(msg->msg, reply->msg, sizeof(error_reply)); |
| 955 | } | ||
| 1010 | out: | 956 | out: |
| 1011 | complete(&(resp_type->work)); | 957 | complete(&resp_type->work); |
| 1012 | } | 958 | } |
| 1013 | 959 | ||
| 1014 | /* | 960 | /* |
| @@ -1055,7 +1001,7 @@ static void zcrypt_msgtype6_receive_ep11(struct ap_queue *aq, · 40 unmodified lines | |||
| 1055 | memcpy(msg->msg, reply->msg, sizeof(error_reply)); | 1001 | memcpy(msg->msg, reply->msg, sizeof(error_reply)); |
| 1056 | } | 1002 | } |
| 1057 | out: | 1003 | out: |
| 1058 | complete(&(resp_type->work)); | 1004 | complete(&resp_type->work); |
| 1059 | } | 1005 | } |
| 1060 | 1006 | ||
| 1061 | static atomic_t zcrypt_step = ATOMIC_INIT(0); | 1007 | static atomic_t zcrypt_step = ATOMIC_INIT(0); |
| @@ -1076,15 +1022,15 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq, · 14 unmodified lines | |||
| 1076 | }; | 1022 | }; |
| 1077 | int rc; | 1023 | int rc; |
| 1078 | 1024 | ||
| 1079 | ap_msg->msg = (void *) get_zeroed_page(GFP_KERNEL); | 1025 | ap_msg->msg = (void *)get_zeroed_page(GFP_KERNEL); |
| 1080 | if (!ap_msg->msg) | 1026 | if (!ap_msg->msg) |
| 1081 | return -ENOMEM; | 1027 | return -ENOMEM; |
| 1082 | ap_msg->bufsize = PAGE_SIZE; | 1028 | ap_msg->bufsize = PAGE_SIZE; |
| 1083 | ap_msg->receive = zcrypt_msgtype6_receive; | 1029 | 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) + |
| 1085 | atomic_inc_return(&zcrypt_step); | 1031 | atomic_inc_return(&zcrypt_step); |
| 1086 | ap_msg->private = &resp_type; | 1032 | 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); |
| 1088 | if (rc) | 1034 | if (rc) |
| 1089 | goto out_free; | 1035 | goto out_free; |
| 1090 | init_completion(&resp_type.work); | 1036 | init_completion(&resp_type.work); |
| @@ -1098,11 +1044,13 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq, · 7 unmodified lines | |||
| 1098 | rc = convert_response_ica(zq, ap_msg, | 1044 | rc = convert_response_ica(zq, ap_msg, |
| 1099 | mex->outputdata, | 1045 | mex->outputdata, |
| 1100 | mex->outputdatalength); | 1046 | mex->outputdatalength); |
| 1101 | } else | 1047 | } else { |
| 1102 | /* Signal pending. */ | 1048 | /* Signal pending. */ |
| 1103 | ap_cancel_message(zq->queue, ap_msg); | 1049 | ap_cancel_message(zq->queue, ap_msg); |
| 1050 | } | ||
| 1051 | |||
| 1104 | out_free: | 1052 | out_free: |
| 1105 | free_page((unsigned long) ap_msg->msg); | 1053 | free_page((unsigned long)ap_msg->msg); |
| 1106 | ap_msg->private = NULL; | 1054 | ap_msg->private = NULL; |
| 1107 | ap_msg->msg = NULL; | 1055 | ap_msg->msg = NULL; |
| 1108 | return rc; | 1056 | return rc; |
| @@ -1124,15 +1072,15 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq, · 15 unmodified lines | |||
| 1124 | }; | 1072 | }; |
| 1125 | int rc; | 1073 | int rc; |
| 1126 | 1074 | ||
| 1127 | ap_msg->msg = (void *) get_zeroed_page(GFP_KERNEL); | 1075 | ap_msg->msg = (void *)get_zeroed_page(GFP_KERNEL); |
| 1128 | if (!ap_msg->msg) | 1076 | if (!ap_msg->msg) |
| 1129 | return -ENOMEM; | 1077 | return -ENOMEM; |
| 1130 | ap_msg->bufsize = PAGE_SIZE; | 1078 | ap_msg->bufsize = PAGE_SIZE; |
| 1131 | ap_msg->receive = zcrypt_msgtype6_receive; | 1079 | 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) + |
| 1133 | atomic_inc_return(&zcrypt_step); | 1081 | atomic_inc_return(&zcrypt_step); |
| 1134 | ap_msg->private = &resp_type; | 1082 | 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); |
| 1136 | if (rc) | 1084 | if (rc) |
| 1137 | goto out_free; | 1085 | goto out_free; |
| 1138 | init_completion(&resp_type.work); | 1086 | init_completion(&resp_type.work); |
| @@ -1150,8 +1098,9 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq, · 11 unmodified lines | |||
| 1150 | /* Signal pending. */ | 1098 | /* Signal pending. */ |
| 1151 | ap_cancel_message(zq->queue, ap_msg); | 1099 | ap_cancel_message(zq->queue, ap_msg); |
| 1152 | } | 1100 | } |
| 1101 | |||
| 1153 | out_free: | 1102 | out_free: |
| 1154 | free_page((unsigned long) ap_msg->msg); | 1103 | free_page((unsigned long)ap_msg->msg); |
| 1155 | ap_msg->private = NULL; | 1104 | ap_msg->private = NULL; |
| 1156 | ap_msg->msg = NULL; | 1105 | ap_msg->msg = NULL; |
| 1157 | return rc; | 1106 | return rc; |
| @@ -1166,7 +1115,7 @@ out_free: · 8 unmodified lines | |||
| 1166 | * by the caller with ap_init_message(). Also the caller has to | 1115 | * by the caller with ap_init_message(). Also the caller has to |
| 1167 | * make sure ap_release_message() is always called even on failure. | 1116 | * make sure ap_release_message() is always called even on failure. |
| 1168 | */ | 1117 | */ |
| 1169 | int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcRB, | 1118 | int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcrb, |
| 1170 | struct ap_message *ap_msg, | 1119 | struct ap_message *ap_msg, |
| 1171 | unsigned int *func_code, unsigned short **dom) | 1120 | unsigned int *func_code, unsigned short **dom) |
| 1172 | { | 1121 | { |
| @@ -1179,12 +1128,12 @@ int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcRB, · 6 unmodified lines | |||
| 1179 | if (!ap_msg->msg) | 1128 | if (!ap_msg->msg) |
| 1180 | return -ENOMEM; | 1129 | return -ENOMEM; |
| 1181 | ap_msg->receive = zcrypt_msgtype6_receive; | 1130 | 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) + |
| 1183 | atomic_inc_return(&zcrypt_step); | 1132 | atomic_inc_return(&zcrypt_step); |
| 1184 | ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL); | 1133 | ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL); |
| 1185 | if (!ap_msg->private) | 1134 | if (!ap_msg->private) |
| 1186 | return -ENOMEM; | 1135 | 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); |
| 1188 | } | 1137 | } |
| 1189 | 1138 | ||
| 1190 | /* | 1139 | /* |
| @@ -1192,10 +1141,10 @@ int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcRB, · 1 unmodified line | |||
| 1192 | * device to handle a send_cprb request. | 1141 | * device to handle a send_cprb request. |
| 1193 | * @zq: pointer to zcrypt_queue structure that identifies the | 1142 | * @zq: pointer to zcrypt_queue structure that identifies the |
| 1194 | * CEXxC device to the request distributor | 1143 | * CEXxC device to the request distributor |
| 1195 | * @xcRB: pointer to the send_cprb request buffer | 1144 | * @xcrb: pointer to the send_cprb request buffer |
| 1196 | */ | 1145 | */ |
| 1197 | static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq, | 1146 | static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq, |
| 1198 | struct ica_xcRB *xcRB, | 1147 | struct ica_xcRB *xcrb, |
| 1199 | struct ap_message *ap_msg) | 1148 | struct ap_message *ap_msg) |
| 1200 | { | 1149 | { |
| 1201 | int rc; | 1150 | int rc; |
| @@ -1210,11 +1159,11 @@ static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq, · 8 unmodified lines | |||
| 1210 | * Set the queue's reply buffer length minus 128 byte padding | 1159 | * Set the queue's reply buffer length minus 128 byte padding |
| 1211 | * as reply limit for the card firmware. | 1160 | * as reply limit for the card firmware. |
| 1212 | */ | 1161 | */ |
| 1213 | msg->hdr.FromCardLen1 = min_t(unsigned int, msg->hdr.FromCardLen1, | 1162 | msg->hdr.fromcardlen1 = min_t(unsigned int, msg->hdr.fromcardlen1, |
| 1214 | zq->reply.bufsize - 128); | 1163 | zq->reply.bufsize - 128); |
| 1215 | if (msg->hdr.FromCardLen2) | 1164 | if (msg->hdr.fromcardlen2) |
| 1216 | msg->hdr.FromCardLen2 = | 1165 | msg->hdr.fromcardlen2 = |
| 1217 | zq->reply.bufsize - msg->hdr.FromCardLen1 - 128; | 1166 | zq->reply.bufsize - msg->hdr.fromcardlen1 - 128; |
| 1218 | 1167 | ||
| 1219 | init_completion(&rtype->work); | 1168 | init_completion(&rtype->work); |
| 1220 | rc = ap_queue_message(zq->queue, ap_msg); | 1169 | 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 | |||
| 1224 | if (rc == 0) { | 1173 | if (rc == 0) { |
| 1225 | rc = ap_msg->rc; | 1174 | rc = ap_msg->rc; |
| 1226 | if (rc == 0) | 1175 | if (rc == 0) |
| 1227 | rc = convert_response_xcrb(userspace, zq, ap_msg, xcRB); | 1176 | rc = convert_response_xcrb(userspace, zq, ap_msg, xcrb); |
| 1228 | } else | 1177 | } else { |
| 1229 | /* Signal pending. */ | 1178 | /* Signal pending. */ |
| 1230 | ap_cancel_message(zq->queue, ap_msg); | 1179 | ap_cancel_message(zq->queue, ap_msg); |
| 1180 | } | ||
| 1181 | |||
| 1231 | out: | 1182 | out: |
| 1232 | if (rc) | 1183 | if (rc) |
| 1233 | ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n", | 1184 | 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 | |||
| 1258 | if (!ap_msg->msg) | 1209 | if (!ap_msg->msg) |
| 1259 | return -ENOMEM; | 1210 | return -ENOMEM; |
| 1260 | ap_msg->receive = zcrypt_msgtype6_receive_ep11; | 1211 | 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) + |
| 1262 | atomic_inc_return(&zcrypt_step); | 1213 | atomic_inc_return(&zcrypt_step); |
| 1263 | ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL); | 1214 | ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL); |
| 1264 | if (!ap_msg->private) | 1215 | if (!ap_msg->private) |
| @@ -1272,7 +1223,7 @@ int prep_ep11_ap_msg(bool userspace, struct ep11_urb *xcrb, · 7 unmodified lines | |||
| 1272 | * device to handle a send_ep11_cprb request. | 1223 | * device to handle a send_ep11_cprb request. |
| 1273 | * @zq: pointer to zcrypt_queue structure that identifies the | 1224 | * @zq: pointer to zcrypt_queue structure that identifies the |
| 1274 | * CEX4P device to the request distributor | 1225 | * CEX4P device to the request distributor |
| 1275 | * @xcRB: pointer to the ep11 user request block | 1226 | * @xcrb: pointer to the ep11 user request block |
| 1276 | */ | 1227 | */ |
| 1277 | static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue *zq, | 1228 | static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue *zq, |
| 1278 | struct ep11_urb *xcrb, | 1229 | struct ep11_urb *xcrb, |
| @@ -1322,7 +1273,7 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue * · 43 unmodified lines | |||
| 1322 | } else { | 1273 | } else { |
| 1323 | lfmt = 1; /* length format #1 */ | 1274 | lfmt = 1; /* length format #1 */ |
| 1324 | } | 1275 | } |
| 1325 | payload_hdr = (struct pld_hdr *)((&(msg->pld_lenfmt))+lfmt); | 1276 | payload_hdr = (struct pld_hdr *)((&msg->pld_lenfmt) + lfmt); |
| 1326 | payload_hdr->dom_val = (unsigned int) | 1277 | payload_hdr->dom_val = (unsigned int) |
| 1327 | AP_QID_QUEUE(zq->queue->qid); | 1278 | AP_QID_QUEUE(zq->queue->qid); |
| 1328 | } | 1279 | } |
| @@ -1331,7 +1282,7 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue * · 2 unmodified lines | |||
| 1331 | * Set the queue's reply buffer length minus the two prepend headers | 1282 | * Set the queue's reply buffer length minus the two prepend headers |
| 1332 | * as reply limit for the card firmware. | 1283 | * as reply limit for the card firmware. |
| 1333 | */ | 1284 | */ |
| 1334 | msg->hdr.FromCardLen1 = zq->reply.bufsize - | 1285 | msg->hdr.fromcardlen1 = zq->reply.bufsize - |
| 1335 | sizeof(struct type86_hdr) - sizeof(struct type86_fmt2_ext); | 1286 | sizeof(struct type86_hdr) - sizeof(struct type86_fmt2_ext); |
| 1336 | 1287 | ||
| 1337 | init_completion(&rtype->work); | 1288 | init_completion(&rtype->work); |
| @@ -1343,9 +1294,11 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue * · 5 unmodified lines | |||
| 1343 | rc = ap_msg->rc; | 1294 | rc = ap_msg->rc; |
| 1344 | if (rc == 0) | 1295 | if (rc == 0) |
| 1345 | rc = convert_response_ep11_xcrb(userspace, zq, ap_msg, xcrb); | 1296 | rc = convert_response_ep11_xcrb(userspace, zq, ap_msg, xcrb); |
| 1346 | } else | 1297 | } else { |
| 1347 | /* Signal pending. */ | 1298 | /* Signal pending. */ |
| 1348 | ap_cancel_message(zq->queue, ap_msg); | 1299 | ap_cancel_message(zq->queue, ap_msg); |
| 1300 | } | ||
| 1301 | |||
| 1349 | out: | 1302 | out: |
| 1350 | if (rc) | 1303 | if (rc) |
| 1351 | ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n", | 1304 | 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 | |||
| 1366 | if (!ap_msg->msg) | 1319 | if (!ap_msg->msg) |
| 1367 | return -ENOMEM; | 1320 | return -ENOMEM; |
| 1368 | ap_msg->receive = zcrypt_msgtype6_receive; | 1321 | 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) + |
| 1370 | atomic_inc_return(&zcrypt_step); | 1323 | atomic_inc_return(&zcrypt_step); |
| 1371 | ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL); | 1324 | ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL); |
| 1372 | if (!ap_msg->private) | 1325 | if (!ap_msg->private) |
| 1373 | return -ENOMEM; | 1326 | return -ENOMEM; |
| 1374 | 1327 | ||
| 1375 | rng_type6CPRB_msgX(ap_msg, ZCRYPT_RNG_BUFFER_SIZE, domain); | 1328 | rng_type6cprb_msgx(ap_msg, ZCRYPT_RNG_BUFFER_SIZE, domain); |
| 1376 | 1329 | ||
| 1377 | *func_code = HWRNG; | 1330 | *func_code = HWRNG; |
| 1378 | return 0; | 1331 | return 0; |
| @@ -1411,9 +1364,10 @@ static long zcrypt_msgtype6_rng(struct zcrypt_queue *zq, · 32 unmodified lines | |||
| 1411 | rc = ap_msg->rc; | 1364 | rc = ap_msg->rc; |
| 1412 | if (rc == 0) | 1365 | if (rc == 0) |
| 1413 | rc = convert_response_rng(zq, ap_msg, buffer); | 1366 | rc = convert_response_rng(zq, ap_msg, buffer); |
| 1414 | } else | 1367 | } else { |
| 1415 | /* Signal pending. */ | 1368 | /* Signal pending. */ |
| 1416 | ap_cancel_message(zq->queue, ap_msg); | 1369 | ap_cancel_message(zq->queue, ap_msg); |
| 1370 | } | ||
| 1417 | out: | 1371 | out: |
| 1418 | return rc; | 1372 | return rc; |
| 1419 | } | 1373 | } |
| @@ -45,14 +45,14 @@ struct type6_hdr { · 44 unmodified lines | |||
| 45 | unsigned char reserved5[2]; /* 0x0000 */ | 45 | unsigned char reserved5[2]; /* 0x0000 */ |
| 46 | unsigned char function_code[2]; /* for PKD, 0x5044 (ascii 'PD') */ | 46 | unsigned char function_code[2]; /* for PKD, 0x5044 (ascii 'PD') */ |
| 47 | unsigned char reserved6[2]; /* 0x0000 */ | 47 | unsigned char reserved6[2]; /* 0x0000 */ |
| 48 | unsigned int ToCardLen1; /* (request CPRB len + 3) & -4 */ | 48 | unsigned int tocardlen1; /* (request CPRB len + 3) & -4 */ |
| 49 | unsigned int ToCardLen2; /* db len 0x00000000 for PKD */ | 49 | unsigned int tocardlen2; /* db len 0x00000000 for PKD */ |
| 50 | unsigned int ToCardLen3; /* 0x00000000 */ | 50 | unsigned int tocardlen3; /* 0x00000000 */ |
| 51 | unsigned int ToCardLen4; /* 0x00000000 */ | 51 | unsigned int tocardlen4; /* 0x00000000 */ |
| 52 | unsigned int FromCardLen1; /* response buffer length */ | 52 | unsigned int fromcardlen1; /* response buffer length */ |
| 53 | unsigned int FromCardLen2; /* db len 0x00000000 for PKD */ | 53 | unsigned int fromcardlen2; /* db len 0x00000000 for PKD */ |
| 54 | unsigned int FromCardLen3; /* 0x00000000 */ | 54 | unsigned int fromcardlen3; /* 0x00000000 */ |
| 55 | unsigned int FromCardLen4; /* 0x00000000 */ | 55 | unsigned int fromcardlen4; /* 0x00000000 */ |
| 56 | } __packed; | 56 | } __packed; |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| @@ -116,7 +116,7 @@ int speed_idx_ep11(int); · 57 unmodified lines | |||
| 116 | * @ap_dev: AP device pointer | 116 | * @ap_dev: AP device pointer |
| 117 | * @ap_msg: pointer to AP message | 117 | * @ap_msg: pointer to AP message |
| 118 | */ | 118 | */ |
| 119 | static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg, | 119 | static inline void rng_type6cprb_msgx(struct ap_message *ap_msg, |
| 120 | unsigned int random_number_length, | 120 | unsigned int random_number_length, |
| 121 | unsigned int *domain) | 121 | unsigned int *domain) |
| 122 | { | 122 | { |
| @@ -134,8 +134,8 @@ static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg, · 11 unmodified lines | |||
| 134 | .offset1 = 0x00000058, | 134 | .offset1 = 0x00000058, |
| 135 | .agent_id = {'C', 'A'}, | 135 | .agent_id = {'C', 'A'}, |
| 136 | .function_code = {'R', 'L'}, | 136 | .function_code = {'R', 'L'}, |
| 137 | .ToCardLen1 = sizeof(*msg) - sizeof(msg->hdr), | 137 | .tocardlen1 = sizeof(*msg) - sizeof(msg->hdr), |
| 138 | .FromCardLen1 = sizeof(*msg) - sizeof(msg->hdr), | 138 | .fromcardlen1 = sizeof(*msg) - sizeof(msg->hdr), |
| 139 | }; | 139 | }; |
| 140 | static struct CPRBX local_cprbx = { | 140 | static struct CPRBX local_cprbx = { |
| 141 | .cprb_len = 0x00dc, | 141 | .cprb_len = 0x00dc, |
| @@ -147,9 +147,9 @@ static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg, · 5 unmodified lines | |||
| 147 | }; | 147 | }; |
| 148 | 148 | ||
| 149 | msg->hdr = static_type6_hdrX; | 149 | msg->hdr = static_type6_hdrX; |
| 150 | msg->hdr.FromCardLen2 = random_number_length, | 150 | msg->hdr.fromcardlen2 = random_number_length; |
| 151 | msg->cprbx = local_cprbx; | 151 | msg->cprbx = local_cprbx; |
| 152 | msg->cprbx.rpl_datal = random_number_length, | 152 | msg->cprbx.rpl_datal = random_number_length; |
| 153 | memcpy(msg->function_code, msg->hdr.function_code, 0x02); | 153 | memcpy(msg->function_code, msg->hdr.function_code, 0x02); |
| 154 | msg->rule_length = 0x0a; | 154 | msg->rule_length = 0x0a; |
| 155 | memcpy(msg->rule, "RANDOM ", 8); | 155 | memcpy(msg->rule, "RANDOM ", 8); |
| @@ -114,7 +114,7 @@ struct zcrypt_queue *zcrypt_queue_alloc(size_t reply_buf_size) · 113 unmodified lines | |||
| 114 | { | 114 | { |
| 115 | struct zcrypt_queue *zq; | 115 | struct zcrypt_queue *zq; |
| 116 | 116 | ||
| 117 | zq = kzalloc(sizeof(struct zcrypt_queue), GFP_KERNEL); | 117 | zq = kzalloc(sizeof(*zq), GFP_KERNEL); |
| 118 | if (!zq) | 118 | if (!zq) |
| 119 | return NULL; | 119 | return NULL; |
| 120 | zq->reply.msg = kmalloc(reply_buf_size, GFP_KERNEL); | 120 | zq->reply.msg = kmalloc(reply_buf_size, GFP_KERNEL); |
| @@ -63,7 +63,7 @@ · 62 unmodified lines | |||
| 63 | ARCH_EXIT_TO_USER_MODE_WORK) | 63 | ARCH_EXIT_TO_USER_MODE_WORK) |
| 64 | 64 | ||
| 65 | /** | 65 | /** |
| 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 |
| 67 | * @regs: Pointer to currents pt_regs | 67 | * @regs: Pointer to currents pt_regs |
| 68 | * | 68 | * |
| 69 | * Defaults to an empty implementation. Can be replaced by architecture | 69 | * Defaults to an empty implementation. Can be replaced by architecture |
| @@ -73,10 +73,10 @@ · 3 unmodified lines | |||
| 73 | * section. Use __always_inline so the compiler cannot push it out of line | 73 | * section. Use __always_inline so the compiler cannot push it out of line |
| 74 | * and make it instrumentable. | 74 | * and make it instrumentable. |
| 75 | */ | 75 | */ |
| 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); |
| 77 | 77 | ||
| 78 | #ifndef arch_check_user_regs | 78 | #ifndef arch_enter_from_user_mode |
| 79 | static __always_inline void arch_check_user_regs(struct pt_regs *regs) {} | 79 | static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs) {} |
| 80 | #endif | 80 | #endif |
| 81 | 81 | ||
| 82 | /** | 82 | /** |
| @@ -17,7 +17,7 @@ · 16 unmodified lines | |||
| 17 | /* See comment for enter_from_user_mode() in entry-common.h */ | 17 | /* See comment for enter_from_user_mode() in entry-common.h */ |
| 18 | static __always_inline void __enter_from_user_mode(struct pt_regs *regs) | 18 | static __always_inline void __enter_from_user_mode(struct pt_regs *regs) |
| 19 | { | 19 | { |
| 20 | arch_check_user_regs(regs); | 20 | arch_enter_from_user_mode(regs); |
| 21 | lockdep_hardirqs_off(CALLER_ADDR0); | 21 | lockdep_hardirqs_off(CALLER_ADDR0); |
| 22 | 22 | ||
| 23 | CT_WARN_ON(ct_state() != CONTEXT_USER); | 23 | CT_WARN_ON(ct_state() != CONTEXT_USER); |
| @@ -24,9 +24,8 @@ icc) · 23 unmodified lines | |||
| 24 | echo 16.0.3 | 24 | echo 16.0.3 |
| 25 | ;; | 25 | ;; |
| 26 | llvm) | 26 | llvm) |
| 27 | # https://lore.kernel.org/r/YMtib5hKVyNknZt3@osiris/ | ||
| 28 | if [ "$SRCARCH" = s390 ]; then | 27 | if [ "$SRCARCH" = s390 ]; then |
| 29 | echo 13.0.0 | 28 | echo 14.0.0 |
| 30 | else | 29 | else |
| 31 | echo 11.0.0 | 30 | echo 11.0.0 |
| 32 | fi | 31 | fi |