Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'raw_dumps' into rdma.git for-next

Maor Gottlieb says:

====================
The following series adds support to get the RDMA resource data in RAW
format. The main motivation for doing this is to enable vendors to return
the entire QP/CQ/MR data without a need from the vendor to set each
field separately.
====================

Based on the mlx5-next branch at
git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux
due to dependencies

* branch 'raw_dumps':
RDMA/mlx5: Add support to get MR resource in RAW format
RDMA/mlx5: Add support to get CQ resource in RAW format
RDMA/mlx5: Add support to get QP resource in RAW format
RDMA: Add support to dump resource tracker in RAW format
RDMA: Add dedicated CM_ID resource tracker function
RDMA: Add dedicated QP resource tracker function
RDMA: Add a dedicated CQ resource tracker function
RDMA: Add dedicated MR resource tracker function
RDMA/core: Don't call fill_res_entry for PD
net/mlx5: Add support in query QP, CQ and MKEY segments
net/mlx5: Export resource dump interface

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

+4268 -2818
+27
Documentation/ABI/testing/sysfs-bus-papr-pmem
··· 1 + What: /sys/bus/nd/devices/nmemX/papr/flags 2 + Date: Apr, 2020 3 + KernelVersion: v5.8 4 + Contact: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>, linux-nvdimm@lists.01.org, 5 + Description: 6 + (RO) Report flags indicating various states of a 7 + papr-pmem NVDIMM device. Each flag maps to a one or 8 + more bits set in the dimm-health-bitmap retrieved in 9 + response to H_SCM_HEALTH hcall. The details of the bit 10 + flags returned in response to this hcall is available 11 + at 'Documentation/powerpc/papr_hcalls.rst' . Below are 12 + the flags reported in this sysfs file: 13 + 14 + * "not_armed" : Indicates that NVDIMM contents will not 15 + survive a power cycle. 16 + * "flush_fail" : Indicates that NVDIMM contents 17 + couldn't be flushed during last 18 + shut-down event. 19 + * "restore_fail": Indicates that NVDIMM contents 20 + couldn't be restored during NVDIMM 21 + initialization. 22 + * "encrypted" : NVDIMM contents are encrypted. 23 + * "smart_notify": There is health event for the NVDIMM. 24 + * "scrubbed" : Indicating that contents of the 25 + NVDIMM have been scrubbed. 26 + * "locked" : Indicating that NVDIMM contents cant 27 + be modified until next power cycle.
+3 -3
Documentation/arm64/sve.rst
··· 186 186 187 187 flags: 188 188 189 - PR_SVE_SET_VL_INHERIT 189 + PR_SVE_VL_INHERIT 190 190 191 191 Inherit the current vector length across execve(). Otherwise, the 192 192 vector length is reset to the system default at execve(). (See ··· 247 247 248 248 The following flag may be OR-ed into the result: 249 249 250 - PR_SVE_SET_VL_INHERIT 250 + PR_SVE_VL_INHERIT 251 251 252 252 Vector length will be inherited across execve(). 253 253 ··· 393 393 * At every execve() call, the new vector length of the new process is set to 394 394 the system default vector length, unless 395 395 396 - * PR_SVE_SET_VL_INHERIT (or equivalently SVE_PT_VL_INHERIT) is set for the 396 + * PR_SVE_VL_INHERIT (or equivalently SVE_PT_VL_INHERIT) is set for the 397 397 calling thread, or 398 398 399 399 * a deferred vector length change is pending, established via the
+1 -1
Documentation/driver-api/media/v4l2-subdev.rst
··· 451 451 "module_foo", "chipid", 0x36, NULL); 452 452 453 453 This loads the given module (can be ``NULL`` if no module needs to be loaded) 454 - and calls :c:func:`i2c_new_device` with the given ``i2c_adapter`` and 454 + and calls :c:func:`i2c_new_client_device` with the given ``i2c_adapter`` and 455 455 chip/address arguments. If all goes well, then it registers the subdev with 456 456 the v4l2_device. 457 457
+3 -3
Documentation/filesystems/dax.txt
··· 25 25 Currently 3 filesystems support DAX: ext2, ext4 and xfs. Enabling DAX on them 26 26 is different. 27 27 28 - Enabling DAX on ext4 and ext2 28 + Enabling DAX on ext2 29 29 ----------------------------- 30 30 31 31 When mounting the filesystem, use the "-o dax" option on the command line or ··· 33 33 within the filesystem. It is equivalent to the '-o dax=always' behavior below. 34 34 35 35 36 - Enabling DAX on xfs 37 - ------------------- 36 + Enabling DAX on xfs and ext4 37 + ---------------------------- 38 38 39 39 Summary 40 40 -------
+3
Documentation/filesystems/ext4/verity.rst
··· 39 39 40 40 Verity files cannot have blocks allocated past the end of the verity 41 41 metadata. 42 + 43 + Verity and DAX are not compatible and attempts to set both of these flags 44 + on a file will fail.
+6 -3
Documentation/gpu/amdgpu.rst
··· 197 197 .. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 198 198 :doc: pp_power_profile_mode 199 199 200 - busy_percent 201 - ~~~~~~~~~~~~ 200 + *_busy_percent 201 + ~~~~~~~~~~~~~~ 202 202 203 203 .. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 204 - :doc: busy_percent 204 + :doc: gpu_busy_percent 205 + 206 + .. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 207 + :doc: mem_busy_percent 205 208 206 209 GPU Product Information 207 210 =======================
+1 -1
Documentation/i2c/smbus-protocol.rst
··· 57 57 58 58 This sends a single bit to the device, at the place of the Rd/Wr bit:: 59 59 60 - A Addr Rd/Wr [A] P 60 + S Addr Rd/Wr [A] P 61 61 62 62 Functionality flag: I2C_FUNC_SMBUS_QUICK 63 63
+42 -4
Documentation/powerpc/papr_hcalls.rst
··· 220 220 **H_SCM_HEALTH** 221 221 222 222 | Input: drcIndex 223 - | Out: *health-bitmap, health-bit-valid-bitmap* 223 + | Out: *health-bitmap (r4), health-bit-valid-bitmap (r5)* 224 224 | Return Value: *H_Success, H_Parameter, H_Hardware* 225 225 226 226 Given a DRC Index return the info on predictive failure and overall health of 227 - the NVDIMM. The asserted bits in the health-bitmap indicate a single predictive 228 - failure and health-bit-valid-bitmap indicate which bits in health-bitmap are 229 - valid. 227 + the PMEM device. The asserted bits in the health-bitmap indicate one or more states 228 + (described in table below) of the PMEM device and health-bit-valid-bitmap indicate 229 + which bits in health-bitmap are valid. The bits are reported in 230 + reverse bit ordering for example a value of 0xC400000000000000 231 + indicates bits 0, 1, and 5 are valid. 232 + 233 + Health Bitmap Flags: 234 + 235 + +------+-----------------------------------------------------------------------+ 236 + | Bit | Definition | 237 + +======+=======================================================================+ 238 + | 00 | PMEM device is unable to persist memory contents. | 239 + | | If the system is powered down, nothing will be saved. | 240 + +------+-----------------------------------------------------------------------+ 241 + | 01 | PMEM device failed to persist memory contents. Either contents were | 242 + | | not saved successfully on power down or were not restored properly on | 243 + | | power up. | 244 + +------+-----------------------------------------------------------------------+ 245 + | 02 | PMEM device contents are persisted from previous IPL. The data from | 246 + | | the last boot were successfully restored. | 247 + +------+-----------------------------------------------------------------------+ 248 + | 03 | PMEM device contents are not persisted from previous IPL. There was no| 249 + | | data to restore from the last boot. | 250 + +------+-----------------------------------------------------------------------+ 251 + | 04 | PMEM device memory life remaining is critically low | 252 + +------+-----------------------------------------------------------------------+ 253 + | 05 | PMEM device will be garded off next IPL due to failure | 254 + +------+-----------------------------------------------------------------------+ 255 + | 06 | PMEM device contents cannot persist due to current platform health | 256 + | | status. A hardware failure may prevent data from being saved or | 257 + | | restored. | 258 + +------+-----------------------------------------------------------------------+ 259 + | 07 | PMEM device is unable to persist memory contents in certain conditions| 260 + +------+-----------------------------------------------------------------------+ 261 + | 08 | PMEM device is encrypted | 262 + +------+-----------------------------------------------------------------------+ 263 + | 09 | PMEM device has successfully completed a requested erase or secure | 264 + | | erase procedure. | 265 + +------+-----------------------------------------------------------------------+ 266 + |10:63 | Reserved / Unused | 267 + +------+-----------------------------------------------------------------------+ 230 268 231 269 **H_SCM_PERFORMANCE_STATS** 232 270
-12
Documentation/sh/index.rst
··· 16 16 .. kernel-doc:: arch/sh/kernel/cpu/sh4/sq.c 17 17 :export: 18 18 19 - SH-5 20 - ---- 21 - 22 - TLB Interfaces 23 - ~~~~~~~~~~~~~~ 24 - 25 - .. kernel-doc:: arch/sh/mm/tlb-sh5.c 26 - :internal: 27 - 28 - .. kernel-doc:: arch/sh/include/asm/tlb_64.h 29 - :internal: 30 - 31 19 Machine Specific Interfaces 32 20 =========================== 33 21
+1 -1
Documentation/userspace-api/media/conf_nitpick.py
··· 27 27 ("c:func", "copy_to_user"), 28 28 ("c:func", "determine_valid_ioctls"), 29 29 ("c:func", "ERR_PTR"), 30 - ("c:func", "i2c_new_device"), 30 + ("c:func", "i2c_new_client_device"), 31 31 ("c:func", "ioctl"), 32 32 ("c:func", "IS_ERR"), 33 33 ("c:func", "KERNEL_VERSION"),
+22 -17
MAINTAINERS
··· 11369 11369 S: Supported 11370 11370 F: drivers/dma/at_xdmac.c 11371 11371 11372 - MICROSEMI ETHERNET SWITCH DRIVER 11373 - M: Alexandre Belloni <alexandre.belloni@bootlin.com> 11374 - M: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com> 11375 - L: netdev@vger.kernel.org 11376 - S: Supported 11377 - F: drivers/net/ethernet/mscc/ 11378 - F: include/soc/mscc/ocelot* 11379 - 11380 11372 MICROSEMI MIPS SOCS 11381 11373 M: Alexandre Belloni <alexandre.belloni@bootlin.com> 11382 11374 M: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com> ··· 12326 12334 M: Peter Zijlstra <peterz@infradead.org> 12327 12335 S: Supported 12328 12336 F: tools/objtool/ 12337 + 12338 + OCELOT ETHERNET SWITCH DRIVER 12339 + M: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com> 12340 + M: Vladimir Oltean <vladimir.oltean@nxp.com> 12341 + M: Claudiu Manoil <claudiu.manoil@nxp.com> 12342 + M: Alexandre Belloni <alexandre.belloni@bootlin.com> 12343 + L: netdev@vger.kernel.org 12344 + S: Supported 12345 + F: drivers/net/dsa/ocelot/* 12346 + F: drivers/net/ethernet/mscc/ 12347 + F: include/soc/mscc/ocelot* 12348 + F: net/dsa/tag_ocelot.c 12329 12349 12330 12350 OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER 12331 12351 M: Frederic Barrat <fbarrat@linux.ibm.com> ··· 14196 14192 S: Supported 14197 14193 F: drivers/dma/qcom/hidma* 14198 14194 14195 + QUALCOMM I2C CCI DRIVER 14196 + M: Loic Poulain <loic.poulain@linaro.org> 14197 + M: Robert Foss <robert.foss@linaro.org> 14198 + L: linux-i2c@vger.kernel.org 14199 + L: linux-arm-msm@vger.kernel.org 14200 + S: Maintained 14201 + F: Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt 14202 + F: drivers/i2c/busses/i2c-qcom-cci.c 14203 + 14199 14204 QUALCOMM IOMMU 14200 14205 M: Rob Clark <robdclark@gmail.com> 14201 14206 L: iommu@lists.linux-foundation.org ··· 14547 14534 F: drivers/i2c/busses/i2c-emev2.c 14548 14535 14549 14536 RENESAS ETHERNET DRIVERS 14550 - R: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> 14537 + R: Sergei Shtylyov <sergei.shtylyov@gmail.com> 14551 14538 L: netdev@vger.kernel.org 14552 14539 L: linux-renesas-soc@vger.kernel.org 14553 14540 F: Documentation/devicetree/bindings/net/renesas,*.txt ··· 18266 18253 S: Maintained 18267 18254 F: drivers/input/serio/userio.c 18268 18255 F: include/uapi/linux/userio.h 18269 - 18270 - VITESSE FELIX ETHERNET SWITCH DRIVER 18271 - M: Vladimir Oltean <vladimir.oltean@nxp.com> 18272 - M: Claudiu Manoil <claudiu.manoil@nxp.com> 18273 - L: netdev@vger.kernel.org 18274 - S: Maintained 18275 - F: drivers/net/dsa/ocelot/* 18276 - F: net/dsa/tag_ocelot.c 18277 18256 18278 18257 VIVID VIRTUAL VIDEO DRIVER 18279 18258 M: Hans Verkuil <hverkuil@xs4all.nl>
+5 -13
Makefile
··· 2 2 VERSION = 5 3 3 PATCHLEVEL = 8 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc1 5 + EXTRAVERSION = -rc2 6 6 NAME = Kleptomaniac Octopus 7 7 8 8 # *DOCUMENTATION* ··· 828 828 829 829 ifdef CONFIG_DEBUG_INFO_COMPRESSED 830 830 DEBUG_CFLAGS += -gz=zlib 831 - KBUILD_AFLAGS += -Wa,--compress-debug-sections=zlib 831 + KBUILD_AFLAGS += -gz=zlib 832 832 KBUILD_LDFLAGS += --compress-debug-sections=zlib 833 833 endif 834 834 ··· 1336 1336 # --------------------------------------------------------------------------- 1337 1337 # Modules 1338 1338 1339 - # install modules.builtin regardless of CONFIG_MODULES 1340 - PHONY += _builtin_inst_ 1341 - _builtin_inst_: 1342 - @mkdir -p $(MODLIB)/ 1343 - @cp -f modules.builtin $(MODLIB)/ 1344 - @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ 1345 - 1346 - PHONY += install 1347 - install: _builtin_inst_ 1348 - 1349 1339 ifdef CONFIG_MODULES 1350 1340 1351 1341 # By default, build modules as well ··· 1379 1389 modules_install: _modinst_ _modinst_post 1380 1390 1381 1391 PHONY += _modinst_ 1382 - _modinst_: _builtin_inst_ 1392 + _modinst_: 1383 1393 @rm -rf $(MODLIB)/kernel 1384 1394 @rm -f $(MODLIB)/source 1385 1395 @mkdir -p $(MODLIB)/kernel ··· 1389 1399 ln -s $(CURDIR) $(MODLIB)/build ; \ 1390 1400 fi 1391 1401 @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order 1402 + @cp -f modules.builtin $(MODLIB)/ 1403 + @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ 1392 1404 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst 1393 1405 1394 1406 # This depmod is only for convenience to give the initial
+2 -1
arch/arm/kernel/ftrace.c
··· 84 84 old = __opcode_to_mem_arm(old); 85 85 86 86 if (validate) { 87 - if (probe_kernel_read(&replaced, (void *)pc, MCOUNT_INSN_SIZE)) 87 + if (copy_from_kernel_nofault(&replaced, (void *)pc, 88 + MCOUNT_INSN_SIZE)) 88 89 return -EFAULT; 89 90 90 91 if (replaced != old)
+1 -1
arch/arm/kernel/kgdb.c
··· 236 236 /* patch_text() only supports int-sized breakpoints */ 237 237 BUILD_BUG_ON(sizeof(int) != BREAK_INSTR_SIZE); 238 238 239 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr, 239 + err = copy_from_kernel_nofault(bpt->saved_instr, (char *)bpt->bpt_addr, 240 240 BREAK_INSTR_SIZE); 241 241 if (err) 242 242 return err;
+1 -1
arch/arm/kernel/traps.c
··· 396 396 u32 insn = __opcode_to_mem_arm(BUG_INSTR_VALUE); 397 397 #endif 398 398 399 - if (probe_kernel_address((unsigned *)pc, bkpt)) 399 + if (get_kernel_nofault(bkpt, (void *)pc)) 400 400 return 0; 401 401 402 402 return bkpt == insn;
+2 -2
arch/arm/mm/alignment.c
··· 774 774 if (user_mode(regs)) 775 775 fault = get_user(instr, ip); 776 776 else 777 - fault = probe_kernel_address(ip, instr); 777 + fault = get_kernel_nofault(instr, ip); 778 778 779 779 *inst = __mem_to_opcode_arm(instr); 780 780 ··· 789 789 if (user_mode(regs)) 790 790 fault = get_user(instr, ip); 791 791 else 792 - fault = probe_kernel_address(ip, instr); 792 + fault = get_kernel_nofault(instr, ip); 793 793 794 794 *inst = __mem_to_opcode_thumb16(instr); 795 795
+3 -1
arch/arm64/Kconfig
··· 1564 1564 def_bool $(cc-option,-msign-return-address=all) 1565 1565 1566 1566 config AS_HAS_PAC 1567 - def_bool $(as-option,-Wa$(comma)-march=armv8.3-a) 1567 + def_bool $(cc-option,-Wa$(comma)-march=armv8.3-a) 1568 1568 1569 1569 config AS_HAS_CFI_NEGATE_RA_STATE 1570 1570 def_bool $(as-instr,.cfi_startproc\n.cfi_negate_ra_state\n.cfi_endproc\n) ··· 1630 1630 depends on CC_HAS_BRANCH_PROT_PAC_RET_BTI 1631 1631 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94697 1632 1632 depends on !CC_IS_GCC || GCC_VERSION >= 100100 1633 + # https://reviews.llvm.org/rGb8ae3fdfa579dbf366b1bb1cbfdbf8c51db7fa55 1634 + depends on !CC_IS_CLANG || CLANG_VERSION >= 100001 1633 1635 depends on !(CC_IS_CLANG && GCOV_KERNEL) 1634 1636 depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS) 1635 1637 help
-15
arch/arm64/Kconfig.debug
··· 8 8 instructions during context switch. Say Y here only if you are 9 9 planning to use hardware trace tools with this kernel. 10 10 11 - config ARM64_RANDOMIZE_TEXT_OFFSET 12 - bool "Randomize TEXT_OFFSET at build time" 13 - help 14 - Say Y here if you want the image load offset (AKA TEXT_OFFSET) 15 - of the kernel to be randomized at build-time. When selected, 16 - this option will cause TEXT_OFFSET to be randomized upon any 17 - build of the kernel, and the offset will be reflected in the 18 - text_offset field of the resulting Image. This can be used to 19 - fuzz-test bootloaders which respect text_offset. 20 - 21 - This option is intended for bootloader and/or kernel testing 22 - only. Bootloaders must make no assumptions regarding the value 23 - of TEXT_OFFSET and platforms must not require a specific 24 - value. 25 - 26 11 config DEBUG_EFI 27 12 depends on EFI && DEBUG_INFO 28 13 bool "UEFI debugging"
-6
arch/arm64/Makefile
··· 121 121 head-y := arch/arm64/kernel/head.o 122 122 123 123 # The byte offset of the kernel image in RAM from the start of RAM. 124 - ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y) 125 - TEXT_OFFSET := $(shell awk "BEGIN {srand(); printf \"0x%06x\n\", \ 126 - int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \ 127 - rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}") 128 - else 129 124 TEXT_OFFSET := 0x0 130 - endif 131 125 132 126 ifeq ($(CONFIG_KASAN_SW_TAGS), y) 133 127 KASAN_SHADOW_SCALE_SHIFT := 4
+1 -1
arch/arm64/include/asm/pgtable.h
··· 416 416 __pgprot((pgprot_val(prot) & ~(mask)) | (bits)) 417 417 418 418 #define pgprot_nx(prot) \ 419 - __pgprot_modify(prot, 0, PTE_PXN) 419 + __pgprot_modify(prot, PTE_MAYBE_GP, PTE_PXN) 420 420 421 421 /* 422 422 * Mark the prot value as uncacheable and unbufferable.
+21 -10
arch/arm64/kernel/fpsimd.c
··· 12 12 #include <linux/bug.h> 13 13 #include <linux/cache.h> 14 14 #include <linux/compat.h> 15 + #include <linux/compiler.h> 15 16 #include <linux/cpu.h> 16 17 #include <linux/cpu_pm.h> 17 18 #include <linux/kernel.h> ··· 120 119 static DEFINE_PER_CPU(struct fpsimd_last_state_struct, fpsimd_last_state); 121 120 122 121 /* Default VL for tasks that don't set it explicitly: */ 123 - static int sve_default_vl = -1; 122 + static int __sve_default_vl = -1; 123 + 124 + static int get_sve_default_vl(void) 125 + { 126 + return READ_ONCE(__sve_default_vl); 127 + } 124 128 125 129 #ifdef CONFIG_ARM64_SVE 130 + 131 + static void set_sve_default_vl(int val) 132 + { 133 + WRITE_ONCE(__sve_default_vl, val); 134 + } 126 135 127 136 /* Maximum supported vector length across all CPUs (initially poisoned) */ 128 137 int __ro_after_init sve_max_vl = SVE_VL_MIN; ··· 349 338 return sve_vl_from_vq(__bit_to_vq(bit)); 350 339 } 351 340 352 - #ifdef CONFIG_SYSCTL 341 + #if defined(CONFIG_ARM64_SVE) && defined(CONFIG_SYSCTL) 353 342 354 343 static int sve_proc_do_default_vl(struct ctl_table *table, int write, 355 344 void *buffer, size_t *lenp, loff_t *ppos) 356 345 { 357 346 int ret; 358 - int vl = sve_default_vl; 347 + int vl = get_sve_default_vl(); 359 348 struct ctl_table tmp_table = { 360 349 .data = &vl, 361 350 .maxlen = sizeof(vl), ··· 372 361 if (!sve_vl_valid(vl)) 373 362 return -EINVAL; 374 363 375 - sve_default_vl = find_supported_vector_length(vl); 364 + set_sve_default_vl(find_supported_vector_length(vl)); 376 365 return 0; 377 366 } 378 367 ··· 394 383 return 0; 395 384 } 396 385 397 - #else /* ! CONFIG_SYSCTL */ 386 + #else /* ! (CONFIG_ARM64_SVE && CONFIG_SYSCTL) */ 398 387 static int __init sve_sysctl_init(void) { return 0; } 399 - #endif /* ! CONFIG_SYSCTL */ 388 + #endif /* ! (CONFIG_ARM64_SVE && CONFIG_SYSCTL) */ 400 389 401 390 #define ZREG(sve_state, vq, n) ((char *)(sve_state) + \ 402 391 (SVE_SIG_ZREG_OFFSET(vq, n) - SVE_SIG_REGS_OFFSET)) ··· 879 868 * For the default VL, pick the maximum supported value <= 64. 880 869 * VL == 64 is guaranteed not to grow the signal frame. 881 870 */ 882 - sve_default_vl = find_supported_vector_length(64); 871 + set_sve_default_vl(find_supported_vector_length(64)); 883 872 884 873 bitmap_andnot(tmp_map, sve_vq_partial_map, sve_vq_map, 885 874 SVE_VQ_MAX); ··· 900 889 pr_info("SVE: maximum available vector length %u bytes per vector\n", 901 890 sve_max_vl); 902 891 pr_info("SVE: default vector length %u bytes per vector\n", 903 - sve_default_vl); 892 + get_sve_default_vl()); 904 893 905 894 /* KVM decides whether to support mismatched systems. Just warn here: */ 906 895 if (sve_max_virtualisable_vl < sve_max_vl) ··· 1040 1029 * vector length configured: no kernel task can become a user 1041 1030 * task without an exec and hence a call to this function. 1042 1031 * By the time the first call to this function is made, all 1043 - * early hardware probing is complete, so sve_default_vl 1032 + * early hardware probing is complete, so __sve_default_vl 1044 1033 * should be valid. 1045 1034 * If a bug causes this to go wrong, we make some noise and 1046 1035 * try to fudge thread.sve_vl to a safe value here. 1047 1036 */ 1048 1037 vl = current->thread.sve_vl_onexec ? 1049 - current->thread.sve_vl_onexec : sve_default_vl; 1038 + current->thread.sve_vl_onexec : get_sve_default_vl(); 1050 1039 1051 1040 if (WARN_ON(!sve_vl_valid(vl))) 1052 1041 vl = SVE_VL_MIN;
+26 -18
arch/arm64/kernel/hw_breakpoint.c
··· 730 730 return 0; 731 731 } 732 732 733 + static int watchpoint_report(struct perf_event *wp, unsigned long addr, 734 + struct pt_regs *regs) 735 + { 736 + int step = is_default_overflow_handler(wp); 737 + struct arch_hw_breakpoint *info = counter_arch_bp(wp); 738 + 739 + info->trigger = addr; 740 + 741 + /* 742 + * If we triggered a user watchpoint from a uaccess routine, then 743 + * handle the stepping ourselves since userspace really can't help 744 + * us with this. 745 + */ 746 + if (!user_mode(regs) && info->ctrl.privilege == AARCH64_BREAKPOINT_EL0) 747 + step = 1; 748 + else 749 + perf_bp_event(wp, regs); 750 + 751 + return step; 752 + } 753 + 733 754 static int watchpoint_handler(unsigned long addr, unsigned int esr, 734 755 struct pt_regs *regs) 735 756 { ··· 760 739 u64 val; 761 740 struct perf_event *wp, **slots; 762 741 struct debug_info *debug_info; 763 - struct arch_hw_breakpoint *info; 764 742 struct arch_hw_breakpoint_ctrl ctrl; 765 743 766 744 slots = this_cpu_ptr(wp_on_reg); ··· 797 777 if (dist != 0) 798 778 continue; 799 779 800 - info = counter_arch_bp(wp); 801 - info->trigger = addr; 802 - perf_bp_event(wp, regs); 803 - 804 - /* Do we need to handle the stepping? */ 805 - if (is_default_overflow_handler(wp)) 806 - step = 1; 780 + step = watchpoint_report(wp, addr, regs); 807 781 } 808 - if (min_dist > 0 && min_dist != -1) { 809 - /* No exact match found. */ 810 - wp = slots[closest_match]; 811 - info = counter_arch_bp(wp); 812 - info->trigger = addr; 813 - perf_bp_event(wp, regs); 814 782 815 - /* Do we need to handle the stepping? */ 816 - if (is_default_overflow_handler(wp)) 817 - step = 1; 818 - } 783 + /* No exact match found? */ 784 + if (min_dist > 0 && min_dist != -1) 785 + step = watchpoint_report(slots[closest_match], addr, regs); 786 + 819 787 rcu_read_unlock(); 820 788 821 789 if (!step)
+2 -2
arch/arm64/kernel/insn.c
··· 135 135 int ret; 136 136 __le32 val; 137 137 138 - ret = probe_kernel_read(&val, addr, AARCH64_INSN_SIZE); 138 + ret = copy_from_kernel_nofault(&val, addr, AARCH64_INSN_SIZE); 139 139 if (!ret) 140 140 *insnp = le32_to_cpu(val); 141 141 ··· 151 151 raw_spin_lock_irqsave(&patch_lock, flags); 152 152 waddr = patch_map(addr, FIX_TEXT_POKE0); 153 153 154 - ret = probe_kernel_write(waddr, &insn, AARCH64_INSN_SIZE); 154 + ret = copy_to_kernel_nofault(waddr, &insn, AARCH64_INSN_SIZE); 155 155 156 156 patch_unmap(FIX_TEXT_POKE0); 157 157 raw_spin_unlock_irqrestore(&patch_lock, flags);
+1 -2
arch/arm64/kernel/machine_kexec_file.c
··· 219 219 MEMBLOCK_NONE, &start, &end, NULL) 220 220 nr_ranges++; 221 221 222 - cmem = kmalloc(sizeof(struct crash_mem) + 223 - sizeof(struct crash_mem_range) * nr_ranges, GFP_KERNEL); 222 + cmem = kmalloc(struct_size(cmem, ranges, nr_ranges), GFP_KERNEL); 224 223 if (!cmem) 225 224 return -ENOMEM; 226 225
+2 -1
arch/arm64/kernel/traps.c
··· 376 376 377 377 if (!user_mode(regs)) { 378 378 __le32 instr_le; 379 - if (probe_kernel_address((__force __le32 *)pc, instr_le)) 379 + if (get_kernel_nofault(instr_le, (__force __le32 *)pc)) 380 380 goto exit; 381 381 instr = le32_to_cpu(instr_le); 382 382 } else if (compat_thumb_mode(regs)) { ··· 813 813 handler[reason], smp_processor_id(), esr, 814 814 esr_get_class_string(esr)); 815 815 816 + __show_regs(regs); 816 817 local_daif_mask(); 817 818 panic("bad mode"); 818 819 }
+10 -5
arch/arm64/mm/init.c
··· 404 404 high_memory = __va(memblock_end_of_DRAM() - 1) + 1; 405 405 406 406 dma_contiguous_reserve(arm64_dma32_phys_limit); 407 - 408 - #ifdef CONFIG_ARM64_4K_PAGES 409 - hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT); 410 - #endif 411 - 412 407 } 413 408 414 409 void __init bootmem_init(void) ··· 419 424 min_low_pfn = min; 420 425 421 426 arm64_numa_init(); 427 + 428 + /* 429 + * must be done after arm64_numa_init() which calls numa_init() to 430 + * initialize node_online_map that gets used in hugetlb_cma_reserve() 431 + * while allocating required CMA size across online nodes. 432 + */ 433 + #ifdef CONFIG_ARM64_4K_PAGES 434 + hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT); 435 + #endif 436 + 422 437 /* 423 438 * Sparsemem tries to allocate bootmem in memory_present(), so must be 424 439 * done after the fixed reservations.
+1
arch/arm64/mm/mmu.c
··· 723 723 pmd_t *pmdp, pmd; 724 724 pte_t *ptep, pte; 725 725 726 + addr = arch_kasan_reset_tag(addr); 726 727 if ((((long)addr) >> VA_BITS) != -1UL) 727 728 return 0; 728 729
+3 -2
arch/csky/kernel/ftrace.c
··· 72 72 uint16_t olds[7]; 73 73 unsigned long hook_pos = hook - 2; 74 74 75 - if (probe_kernel_read((void *)olds, (void *)hook_pos, sizeof(nops))) 75 + if (copy_from_kernel_nofault((void *)olds, (void *)hook_pos, 76 + sizeof(nops))) 76 77 return -EFAULT; 77 78 78 79 if (memcmp((void *)nops, (void *)olds, sizeof(nops))) { ··· 98 97 99 98 make_jbsr(target, hook, call, nolr); 100 99 101 - ret = probe_kernel_write((void *)hook_pos, enable ? call : nops, 100 + ret = copy_to_kernel_nofault((void *)hook_pos, enable ? call : nops, 102 101 sizeof(nops)); 103 102 if (ret) 104 103 return -EPERM;
+1 -1
arch/ia64/include/asm/sections.h
··· 35 35 struct fdesc *desc = ptr; 36 36 void *p; 37 37 38 - if (!probe_kernel_address(&desc->ip, p)) 38 + if (!get_kernel_nofault(p, (void *)&desc->ip)) 39 39 ptr = p; 40 40 return ptr; 41 41 }
+3 -3
arch/ia64/kernel/ftrace.c
··· 108 108 goto skip_check; 109 109 110 110 /* read the text we want to modify */ 111 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE)) 111 + if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE)) 112 112 return -EFAULT; 113 113 114 114 /* Make sure it is what we expect it to be */ ··· 117 117 118 118 skip_check: 119 119 /* replace the text with the new text */ 120 - if (probe_kernel_write(((void *)ip), new_code, MCOUNT_INSN_SIZE)) 120 + if (copy_to_kernel_nofault(((void *)ip), new_code, MCOUNT_INSN_SIZE)) 121 121 return -EPERM; 122 122 flush_icache_range(ip, ip + MCOUNT_INSN_SIZE); 123 123 ··· 129 129 unsigned char __attribute__((aligned(8))) replaced[MCOUNT_INSN_SIZE]; 130 130 unsigned long ip = rec->ip; 131 131 132 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE)) 132 + if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE)) 133 133 return -EFAULT; 134 134 if (rec->flags & FTRACE_FL_CONVERTED) { 135 135 struct ftrace_call_insn *call_insn, *tmp_call;
+1 -1
arch/ia64/kernel/unwind_i.h
··· 42 42 43 43 struct unw_info_block { 44 44 u64 header; 45 - u64 desc[0]; /* unwind descriptors */ 45 + u64 desc[]; /* unwind descriptors */ 46 46 /* personality routine and language-specific data follow behind descriptors */ 47 47 }; 48 48
+3 -3
arch/mips/kernel/kprobes.c
··· 86 86 goto out; 87 87 } 88 88 89 - if ((probe_kernel_read(&prev_insn, p->addr - 1, 90 - sizeof(mips_instruction)) == 0) && 91 - insn_has_delayslot(prev_insn)) { 89 + if (copy_from_kernel_nofault(&prev_insn, p->addr - 1, 90 + sizeof(mips_instruction)) == 0 && 91 + insn_has_delayslot(prev_insn)) { 92 92 pr_notice("Kprobes for branch delayslot are not supported\n"); 93 93 ret = -EINVAL; 94 94 goto out;
+3 -2
arch/nds32/kernel/ftrace.c
··· 131 131 unsigned long orig_insn[3]; 132 132 133 133 if (validate) { 134 - if (probe_kernel_read(orig_insn, (void *)pc, MCOUNT_INSN_SIZE)) 134 + if (copy_from_kernel_nofault(orig_insn, (void *)pc, 135 + MCOUNT_INSN_SIZE)) 135 136 return -EFAULT; 136 137 if (memcmp(orig_insn, old_insn, MCOUNT_INSN_SIZE)) 137 138 return -EINVAL; 138 139 } 139 140 140 - if (probe_kernel_write((void *)pc, new_insn, MCOUNT_INSN_SIZE)) 141 + if (copy_to_kernel_nofault((void *)pc, new_insn, MCOUNT_INSN_SIZE)) 141 142 return -EPERM; 142 143 143 144 return 0;
+1 -1
arch/parisc/kernel/ftrace.c
··· 172 172 173 173 ip = (void *)(rec->ip + 4 - size); 174 174 175 - ret = probe_kernel_read(insn, ip, size); 175 + ret = copy_from_kernel_nofault(insn, ip, size); 176 176 if (ret) 177 177 return ret; 178 178
+2 -2
arch/parisc/kernel/kgdb.c
··· 154 154 155 155 int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) 156 156 { 157 - int ret = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr, 158 - BREAK_INSTR_SIZE); 157 + int ret = copy_from_kernel_nofault(bpt->saved_instr, 158 + (char *)bpt->bpt_addr, BREAK_INSTR_SIZE); 159 159 if (ret) 160 160 return ret; 161 161
+1 -1
arch/parisc/kernel/process.c
··· 293 293 Elf64_Fdesc *desc = ptr; 294 294 void *p; 295 295 296 - if (!probe_kernel_address(&desc->addr, p)) 296 + if (!get_kernel_nofault(p, (void *)&desc->addr)) 297 297 ptr = p; 298 298 return ptr; 299 299 }
+1 -1
arch/parisc/lib/memcpy.c
··· 57 57 EXPORT_SYMBOL(raw_copy_in_user); 58 58 EXPORT_SYMBOL(memcpy); 59 59 60 - bool probe_kernel_read_allowed(const void *unsafe_src, size_t size) 60 + bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) 61 61 { 62 62 if ((unsigned long)unsafe_src < PAGE_SIZE) 63 63 return false;
+13 -5
arch/powerpc/include/asm/nohash/32/pgtable.h
··· 205 205 *pmdp = __pmd(0); 206 206 } 207 207 208 - /* to find an entry in a page-table-directory */ 209 - #define pgd_index(address) ((address) >> PGDIR_SHIFT) 210 - #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address)) 211 - 212 208 /* 213 209 * PTE updates. This function is called whenever an existing 214 210 * valid PTE is updated. This does -not- include set_pte_at() ··· 226 230 * For other page sizes, we have a single entry in the table. 227 231 */ 228 232 #ifdef CONFIG_PPC_8xx 233 + static pmd_t *pmd_off(struct mm_struct *mm, unsigned long addr); 234 + 229 235 static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, pte_t *p, 230 236 unsigned long clr, unsigned long set, int huge) 231 237 { ··· 235 237 pte_basic_t old = pte_val(*p); 236 238 pte_basic_t new = (old & ~(pte_basic_t)clr) | set; 237 239 int num, i; 238 - pmd_t *pmd = pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, addr), addr), addr), addr); 240 + pmd_t *pmd = pmd_off(mm, addr); 239 241 240 242 if (!huge) 241 243 num = PAGE_SIZE / SZ_4K; ··· 283 285 { 284 286 return __pte(pte_update(mm, addr, ptep, ~0, 0, 0)); 285 287 } 288 + 289 + #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES) 290 + #define __HAVE_ARCH_PTEP_GET 291 + static inline pte_t ptep_get(pte_t *ptep) 292 + { 293 + pte_t pte = {READ_ONCE(ptep->pte), 0, 0, 0}; 294 + 295 + return pte; 296 + } 297 + #endif 286 298 287 299 #define __HAVE_ARCH_PTEP_SET_WRPROTECT 288 300 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
+1 -1
arch/powerpc/include/asm/sections.h
··· 85 85 struct ppc64_opd_entry *desc = ptr; 86 86 void *p; 87 87 88 - if (!probe_kernel_address(&desc->funcaddr, p)) 88 + if (!get_kernel_nofault(p, (void *)&desc->funcaddr)) 89 89 ptr = p; 90 90 return ptr; 91 91 }
+132
arch/powerpc/include/uapi/asm/papr_pdsm.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 + /* 3 + * PAPR nvDimm Specific Methods (PDSM) and structs for libndctl 4 + * 5 + * (C) Copyright IBM 2020 6 + * 7 + * Author: Vaibhav Jain <vaibhav at linux.ibm.com> 8 + */ 9 + 10 + #ifndef _UAPI_ASM_POWERPC_PAPR_PDSM_H_ 11 + #define _UAPI_ASM_POWERPC_PAPR_PDSM_H_ 12 + 13 + #include <linux/types.h> 14 + #include <linux/ndctl.h> 15 + 16 + /* 17 + * PDSM Envelope: 18 + * 19 + * The ioctl ND_CMD_CALL exchange data between user-space and kernel via 20 + * envelope which consists of 2 headers sections and payload sections as 21 + * illustrated below: 22 + * +-----------------+---------------+---------------------------+ 23 + * | 64-Bytes | 8-Bytes | Max 184-Bytes | 24 + * +-----------------+---------------+---------------------------+ 25 + * | ND-HEADER | PDSM-HEADER | PDSM-PAYLOAD | 26 + * +-----------------+---------------+---------------------------+ 27 + * | nd_family | | | 28 + * | nd_size_out | cmd_status | | 29 + * | nd_size_in | reserved | nd_pdsm_payload | 30 + * | nd_command | payload --> | | 31 + * | nd_fw_size | | | 32 + * | nd_payload ---> | | | 33 + * +---------------+-----------------+---------------------------+ 34 + * 35 + * ND Header: 36 + * This is the generic libnvdimm header described as 'struct nd_cmd_pkg' 37 + * which is interpreted by libnvdimm before passed on to papr_scm. Important 38 + * member fields used are: 39 + * 'nd_family' : (In) NVDIMM_FAMILY_PAPR_SCM 40 + * 'nd_size_in' : (In) PDSM-HEADER + PDSM-IN-PAYLOAD (usually 0) 41 + * 'nd_size_out' : (In) PDSM-HEADER + PDSM-RETURN-PAYLOAD 42 + * 'nd_command' : (In) One of PAPR_PDSM_XXX 43 + * 'nd_fw_size' : (Out) PDSM-HEADER + size of actual payload returned 44 + * 45 + * PDSM Header: 46 + * This is papr-scm specific header that precedes the payload. This is defined 47 + * as nd_cmd_pdsm_pkg. Following fields aare available in this header: 48 + * 49 + * 'cmd_status' : (Out) Errors if any encountered while servicing PDSM. 50 + * 'reserved' : Not used, reserved for future and should be set to 0. 51 + * 'payload' : A union of all the possible payload structs 52 + * 53 + * PDSM Payload: 54 + * 55 + * The layout of the PDSM Payload is defined by various structs shared between 56 + * papr_scm and libndctl so that contents of payload can be interpreted. As such 57 + * its defined as a union of all possible payload structs as 58 + * 'union nd_pdsm_payload'. Based on the value of 'nd_cmd_pkg.nd_command' 59 + * appropriate member of the union is accessed. 60 + */ 61 + 62 + /* Max payload size that we can handle */ 63 + #define ND_PDSM_PAYLOAD_MAX_SIZE 184 64 + 65 + /* Max payload size that we can handle */ 66 + #define ND_PDSM_HDR_SIZE \ 67 + (sizeof(struct nd_pkg_pdsm) - ND_PDSM_PAYLOAD_MAX_SIZE) 68 + 69 + /* Various nvdimm health indicators */ 70 + #define PAPR_PDSM_DIMM_HEALTHY 0 71 + #define PAPR_PDSM_DIMM_UNHEALTHY 1 72 + #define PAPR_PDSM_DIMM_CRITICAL 2 73 + #define PAPR_PDSM_DIMM_FATAL 3 74 + 75 + /* 76 + * Struct exchanged between kernel & ndctl in for PAPR_PDSM_HEALTH 77 + * Various flags indicate the health status of the dimm. 78 + * 79 + * extension_flags : Any extension fields present in the struct. 80 + * dimm_unarmed : Dimm not armed. So contents wont persist. 81 + * dimm_bad_shutdown : Previous shutdown did not persist contents. 82 + * dimm_bad_restore : Contents from previous shutdown werent restored. 83 + * dimm_scrubbed : Contents of the dimm have been scrubbed. 84 + * dimm_locked : Contents of the dimm cant be modified until CEC reboot 85 + * dimm_encrypted : Contents of dimm are encrypted. 86 + * dimm_health : Dimm health indicator. One of PAPR_PDSM_DIMM_XXXX 87 + */ 88 + struct nd_papr_pdsm_health { 89 + union { 90 + struct { 91 + __u32 extension_flags; 92 + __u8 dimm_unarmed; 93 + __u8 dimm_bad_shutdown; 94 + __u8 dimm_bad_restore; 95 + __u8 dimm_scrubbed; 96 + __u8 dimm_locked; 97 + __u8 dimm_encrypted; 98 + __u16 dimm_health; 99 + }; 100 + __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE]; 101 + }; 102 + }; 103 + 104 + /* 105 + * Methods to be embedded in ND_CMD_CALL request. These are sent to the kernel 106 + * via 'nd_cmd_pkg.nd_command' member of the ioctl struct 107 + */ 108 + enum papr_pdsm { 109 + PAPR_PDSM_MIN = 0x0, 110 + PAPR_PDSM_HEALTH, 111 + PAPR_PDSM_MAX, 112 + }; 113 + 114 + /* Maximal union that can hold all possible payload types */ 115 + union nd_pdsm_payload { 116 + struct nd_papr_pdsm_health health; 117 + __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE]; 118 + } __packed; 119 + 120 + /* 121 + * PDSM-header + payload expected with ND_CMD_CALL ioctl from libnvdimm 122 + * Valid member of union 'payload' is identified via 'nd_cmd_pkg.nd_command' 123 + * that should always precede this struct when sent to papr_scm via CMD_CALL 124 + * interface. 125 + */ 126 + struct nd_pkg_pdsm { 127 + __s32 cmd_status; /* Out: Sub-cmd status returned back */ 128 + __u16 reserved[2]; /* Ignored and to be set as '0' */ 129 + union nd_pdsm_payload payload; 130 + } __packed; 131 + 132 + #endif /* _UAPI_ASM_POWERPC_PAPR_PDSM_H_ */
+2 -2
arch/powerpc/kernel/exceptions-64s.S
··· 270 270 END_FTR_SECTION_IFSET(CPU_FTR_CFAR) 271 271 .endif 272 272 273 - ld r10,PACA_EXGEN+EX_CTR(r13) 273 + ld r10,IAREA+EX_CTR(r13) 274 274 mtctr r10 275 275 BEGIN_FTR_SECTION 276 276 ld r10,IAREA+EX_PPR(r13) ··· 298 298 299 299 .if IKVM_SKIP 300 300 89: mtocrf 0x80,r9 301 - ld r10,PACA_EXGEN+EX_CTR(r13) 301 + ld r10,IAREA+EX_CTR(r13) 302 302 mtctr r10 303 303 ld r9,IAREA+EX_R9(r13) 304 304 ld r10,IAREA+EX_R10(r13)
+1 -1
arch/powerpc/kernel/kgdb.c
··· 421 421 unsigned int instr; 422 422 struct ppc_inst *addr = (struct ppc_inst *)bpt->bpt_addr; 423 423 424 - err = probe_kernel_address(addr, instr); 424 + err = get_kernel_nofault(instr, (unsigned *) addr); 425 425 if (err) 426 426 return err; 427 427
+1 -1
arch/powerpc/kernel/kprobes.c
··· 289 289 if (!p) { 290 290 unsigned int instr; 291 291 292 - if (probe_kernel_address(addr, instr)) 292 + if (get_kernel_nofault(instr, addr)) 293 293 goto no_kprobe; 294 294 295 295 if (instr != BREAKPOINT_INSTRUCTION) {
+4 -2
arch/powerpc/kernel/module_64.c
··· 756 756 757 757 stub = (struct ppc64_stub_entry *)addr; 758 758 759 - if (probe_kernel_read(&magic, &stub->magic, sizeof(magic))) { 759 + if (copy_from_kernel_nofault(&magic, &stub->magic, 760 + sizeof(magic))) { 760 761 pr_err("%s: fault reading magic for stub %lx for %s\n", __func__, addr, mod->name); 761 762 return -EFAULT; 762 763 } ··· 767 766 return -EFAULT; 768 767 } 769 768 770 - if (probe_kernel_read(&funcdata, &stub->funcdata, sizeof(funcdata))) { 769 + if (copy_from_kernel_nofault(&funcdata, &stub->funcdata, 770 + sizeof(funcdata))) { 771 771 pr_err("%s: fault reading funcdata for stub %lx for %s\n", __func__, addr, mod->name); 772 772 return -EFAULT; 773 773 }
+14 -11
arch/powerpc/kernel/process.c
··· 1252 1252 static void show_instructions(struct pt_regs *regs) 1253 1253 { 1254 1254 int i; 1255 + unsigned long nip = regs->nip; 1255 1256 unsigned long pc = regs->nip - (NR_INSN_TO_PRINT * 3 / 4 * sizeof(int)); 1256 1257 1257 1258 printk("Instruction dump:"); 1259 + 1260 + /* 1261 + * If we were executing with the MMU off for instructions, adjust pc 1262 + * rather than printing XXXXXXXX. 1263 + */ 1264 + if (!IS_ENABLED(CONFIG_BOOKE) && !(regs->msr & MSR_IR)) { 1265 + pc = (unsigned long)phys_to_virt(pc); 1266 + nip = (unsigned long)phys_to_virt(regs->nip); 1267 + } 1258 1268 1259 1269 for (i = 0; i < NR_INSN_TO_PRINT; i++) { 1260 1270 int instr; ··· 1272 1262 if (!(i % 8)) 1273 1263 pr_cont("\n"); 1274 1264 1275 - #if !defined(CONFIG_BOOKE) 1276 - /* If executing with the IMMU off, adjust pc rather 1277 - * than print XXXXXXXX. 1278 - */ 1279 - if (!(regs->msr & MSR_IR)) 1280 - pc = (unsigned long)phys_to_virt(pc); 1281 - #endif 1282 - 1283 1265 if (!__kernel_text_address(pc) || 1284 - probe_kernel_address((const void *)pc, instr)) { 1266 + get_kernel_nofault(instr, (const void *)pc)) { 1285 1267 pr_cont("XXXXXXXX "); 1286 1268 } else { 1287 - if (regs->nip == pc) 1269 + if (nip == pc) 1288 1270 pr_cont("<%08x> ", instr); 1289 1271 else 1290 1272 pr_cont("%08x ", instr); ··· 1307 1305 for (i = 0; i < 8 && n; i++, n--, pc += sizeof(int)) { 1308 1306 int instr; 1309 1307 1310 - if (probe_user_read(&instr, (void __user *)pc, sizeof(instr))) { 1308 + if (copy_from_user_nofault(&instr, (void __user *)pc, 1309 + sizeof(instr))) { 1311 1310 seq_buf_printf(&s, "XXXXXXXX "); 1312 1311 continue; 1313 1312 }
+2 -2
arch/powerpc/kernel/trace/ftrace.c
··· 226 226 unsigned long ip = rec->ip; 227 227 unsigned long tramp; 228 228 229 - if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE)) 229 + if (copy_from_kernel_nofault(&op, (void *)ip, MCOUNT_INSN_SIZE)) 230 230 return -EFAULT; 231 231 232 232 /* Make sure that that this is still a 24bit jump */ ··· 249 249 pr_devel("ip:%lx jumps to %lx", ip, tramp); 250 250 251 251 /* Find where the trampoline jumps to */ 252 - if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) { 252 + if (copy_from_kernel_nofault(jmp, (void *)tramp, sizeof(jmp))) { 253 253 pr_err("Failed to read %lx\n", tramp); 254 254 return -EFAULT; 255 255 }
+2 -2
arch/powerpc/kvm/book3s_64_mmu_radix.c
··· 64 64 isync(); 65 65 66 66 if (is_load) 67 - ret = probe_user_read(to, (const void __user *)from, n); 67 + ret = copy_from_user_nofault(to, (const void __user *)from, n); 68 68 else 69 - ret = probe_user_write((void __user *)to, from, n); 69 + ret = copy_to_user_nofault((void __user *)to, from, n); 70 70 71 71 /* switch the pid first to avoid running host with unallocated pid */ 72 72 if (quadrant == 1 && pid != old_pid)
+6 -6
arch/powerpc/lib/inst.c
··· 15 15 unsigned int val, suffix; 16 16 int err; 17 17 18 - err = probe_user_read(&val, nip, sizeof(val)); 18 + err = copy_from_user_nofault(&val, nip, sizeof(val)); 19 19 if (err) 20 20 return err; 21 21 if (get_op(val) == OP_PREFIX) { 22 - err = probe_user_read(&suffix, (void __user *)nip + 4, 4); 22 + err = copy_from_user_nofault(&suffix, (void __user *)nip + 4, 4); 23 23 *inst = ppc_inst_prefix(val, suffix); 24 24 } else { 25 25 *inst = ppc_inst(val); ··· 33 33 unsigned int val, suffix; 34 34 int err; 35 35 36 - err = probe_kernel_read(&val, src, sizeof(val)); 36 + err = copy_from_kernel_nofault(&val, src, sizeof(val)); 37 37 if (err) 38 38 return err; 39 39 if (get_op(val) == OP_PREFIX) { 40 - err = probe_kernel_read(&suffix, (void *)src + 4, 4); 40 + err = copy_from_kernel_nofault(&suffix, (void *)src + 4, 4); 41 41 *inst = ppc_inst_prefix(val, suffix); 42 42 } else { 43 43 *inst = ppc_inst(val); ··· 51 51 unsigned int val; 52 52 int err; 53 53 54 - err = probe_user_read(&val, nip, sizeof(val)); 54 + err = copy_from_user_nofault(&val, nip, sizeof(val)); 55 55 if (!err) 56 56 *inst = ppc_inst(val); 57 57 ··· 64 64 unsigned int val; 65 65 int err; 66 66 67 - err = probe_kernel_read(&val, src, sizeof(val)); 67 + err = copy_from_kernel_nofault(&val, src, sizeof(val)); 68 68 if (!err) 69 69 *inst = ppc_inst(val); 70 70
+4 -2
arch/powerpc/oprofile/backtrace.c
··· 33 33 * which means that we've done all that we can do from 34 34 * interrupt context. 35 35 */ 36 - if (probe_user_read(stack_frame, (void __user *)p, sizeof(stack_frame))) 36 + if (copy_from_user_nofault(stack_frame, (void __user *)p, 37 + sizeof(stack_frame))) 37 38 return 0; 38 39 39 40 if (!is_first) ··· 52 51 { 53 52 unsigned long stack_frame[3]; 54 53 55 - if (probe_user_read(stack_frame, (void __user *)sp, sizeof(stack_frame))) 54 + if (copy_from_user_nofault(stack_frame, (void __user *)sp, 55 + sizeof(stack_frame))) 56 56 return 0; 57 57 58 58 if (!is_first)
+1 -1
arch/powerpc/perf/callchain_32.c
··· 44 44 ((unsigned long)ptr & 3)) 45 45 return -EFAULT; 46 46 47 - rc = probe_user_read(ret, ptr, sizeof(*ret)); 47 + rc = copy_from_user_nofault(ret, ptr, sizeof(*ret)); 48 48 49 49 if (IS_ENABLED(CONFIG_PPC64) && rc) 50 50 return read_user_stack_slow(ptr, ret, 4);
+1 -1
arch/powerpc/perf/callchain_64.c
··· 50 50 ((unsigned long)ptr & 7)) 51 51 return -EFAULT; 52 52 53 - if (!probe_user_read(ret, ptr, sizeof(*ret))) 53 + if (!copy_from_user_nofault(ret, ptr, sizeof(*ret))) 54 54 return 0; 55 55 56 56 return read_user_stack_slow(ptr, ret, 8);
+4 -2
arch/powerpc/perf/core-book3s.c
··· 418 418 __u64 target; 419 419 420 420 if (is_kernel_addr(addr)) { 421 - if (probe_kernel_read(&instr, (void *)addr, sizeof(instr))) 421 + if (copy_from_kernel_nofault(&instr, (void *)addr, 422 + sizeof(instr))) 422 423 return 0; 423 424 424 425 return branch_target((struct ppc_inst *)&instr); 425 426 } 426 427 427 428 /* Userspace: need copy instruction here then translate it */ 428 - if (probe_user_read(&instr, (unsigned int __user *)addr, sizeof(instr))) 429 + if (copy_from_user_nofault(&instr, (unsigned int __user *)addr, 430 + sizeof(instr))) 429 431 return 0; 430 432 431 433 target = branch_target((struct ppc_inst *)&instr);
+1 -1
arch/powerpc/platforms/cell/spu_callbacks.c
··· 35 35 */ 36 36 37 37 static void *spu_syscall_table[] = { 38 - #define __SYSCALL(nr, entry) entry, 38 + #define __SYSCALL(nr, entry) [nr] = entry, 39 39 #include <asm/syscall_table_spu.h> 40 40 #undef __SYSCALL 41 41 };
+412 -6
arch/powerpc/platforms/pseries/papr_scm.c
··· 12 12 #include <linux/libnvdimm.h> 13 13 #include <linux/platform_device.h> 14 14 #include <linux/delay.h> 15 + #include <linux/seq_buf.h> 15 16 16 17 #include <asm/plpar_wrappers.h> 18 + #include <asm/papr_pdsm.h> 17 19 18 20 #define BIND_ANY_ADDR (~0ul) 19 21 20 22 #define PAPR_SCM_DIMM_CMD_MASK \ 21 23 ((1ul << ND_CMD_GET_CONFIG_SIZE) | \ 22 24 (1ul << ND_CMD_GET_CONFIG_DATA) | \ 23 - (1ul << ND_CMD_SET_CONFIG_DATA)) 25 + (1ul << ND_CMD_SET_CONFIG_DATA) | \ 26 + (1ul << ND_CMD_CALL)) 24 27 28 + /* DIMM health bitmap bitmap indicators */ 29 + /* SCM device is unable to persist memory contents */ 30 + #define PAPR_PMEM_UNARMED (1ULL << (63 - 0)) 31 + /* SCM device failed to persist memory contents */ 32 + #define PAPR_PMEM_SHUTDOWN_DIRTY (1ULL << (63 - 1)) 33 + /* SCM device contents are persisted from previous IPL */ 34 + #define PAPR_PMEM_SHUTDOWN_CLEAN (1ULL << (63 - 2)) 35 + /* SCM device contents are not persisted from previous IPL */ 36 + #define PAPR_PMEM_EMPTY (1ULL << (63 - 3)) 37 + /* SCM device memory life remaining is critically low */ 38 + #define PAPR_PMEM_HEALTH_CRITICAL (1ULL << (63 - 4)) 39 + /* SCM device will be garded off next IPL due to failure */ 40 + #define PAPR_PMEM_HEALTH_FATAL (1ULL << (63 - 5)) 41 + /* SCM contents cannot persist due to current platform health status */ 42 + #define PAPR_PMEM_HEALTH_UNHEALTHY (1ULL << (63 - 6)) 43 + /* SCM device is unable to persist memory contents in certain conditions */ 44 + #define PAPR_PMEM_HEALTH_NON_CRITICAL (1ULL << (63 - 7)) 45 + /* SCM device is encrypted */ 46 + #define PAPR_PMEM_ENCRYPTED (1ULL << (63 - 8)) 47 + /* SCM device has been scrubbed and locked */ 48 + #define PAPR_PMEM_SCRUBBED_AND_LOCKED (1ULL << (63 - 9)) 49 + 50 + /* Bits status indicators for health bitmap indicating unarmed dimm */ 51 + #define PAPR_PMEM_UNARMED_MASK (PAPR_PMEM_UNARMED | \ 52 + PAPR_PMEM_HEALTH_UNHEALTHY) 53 + 54 + /* Bits status indicators for health bitmap indicating unflushed dimm */ 55 + #define PAPR_PMEM_BAD_SHUTDOWN_MASK (PAPR_PMEM_SHUTDOWN_DIRTY) 56 + 57 + /* Bits status indicators for health bitmap indicating unrestored dimm */ 58 + #define PAPR_PMEM_BAD_RESTORE_MASK (PAPR_PMEM_EMPTY) 59 + 60 + /* Bit status indicators for smart event notification */ 61 + #define PAPR_PMEM_SMART_EVENT_MASK (PAPR_PMEM_HEALTH_CRITICAL | \ 62 + PAPR_PMEM_HEALTH_FATAL | \ 63 + PAPR_PMEM_HEALTH_UNHEALTHY) 64 + 65 + /* private struct associated with each region */ 25 66 struct papr_scm_priv { 26 67 struct platform_device *pdev; 27 68 struct device_node *dn; ··· 80 39 struct resource res; 81 40 struct nd_region *region; 82 41 struct nd_interleave_set nd_set; 42 + 43 + /* Protect dimm health data from concurrent read/writes */ 44 + struct mutex health_mutex; 45 + 46 + /* Last time the health information of the dimm was updated */ 47 + unsigned long lasthealth_jiffies; 48 + 49 + /* Health information for the dimm */ 50 + u64 health_bitmap; 83 51 }; 84 52 85 53 static int drc_pmem_bind(struct papr_scm_priv *p) ··· 194 144 return drc_pmem_bind(p); 195 145 } 196 146 147 + /* 148 + * Issue hcall to retrieve dimm health info and populate papr_scm_priv with the 149 + * health information. 150 + */ 151 + static int __drc_pmem_query_health(struct papr_scm_priv *p) 152 + { 153 + unsigned long ret[PLPAR_HCALL_BUFSIZE]; 154 + long rc; 155 + 156 + /* issue the hcall */ 157 + rc = plpar_hcall(H_SCM_HEALTH, ret, p->drc_index); 158 + if (rc != H_SUCCESS) { 159 + dev_err(&p->pdev->dev, 160 + "Failed to query health information, Err:%ld\n", rc); 161 + return -ENXIO; 162 + } 163 + 164 + p->lasthealth_jiffies = jiffies; 165 + p->health_bitmap = ret[0] & ret[1]; 166 + 167 + dev_dbg(&p->pdev->dev, 168 + "Queried dimm health info. Bitmap:0x%016lx Mask:0x%016lx\n", 169 + ret[0], ret[1]); 170 + 171 + return 0; 172 + } 173 + 174 + /* Min interval in seconds for assuming stable dimm health */ 175 + #define MIN_HEALTH_QUERY_INTERVAL 60 176 + 177 + /* Query cached health info and if needed call drc_pmem_query_health */ 178 + static int drc_pmem_query_health(struct papr_scm_priv *p) 179 + { 180 + unsigned long cache_timeout; 181 + int rc; 182 + 183 + /* Protect concurrent modifications to papr_scm_priv */ 184 + rc = mutex_lock_interruptible(&p->health_mutex); 185 + if (rc) 186 + return rc; 187 + 188 + /* Jiffies offset for which the health data is assumed to be same */ 189 + cache_timeout = p->lasthealth_jiffies + 190 + msecs_to_jiffies(MIN_HEALTH_QUERY_INTERVAL * 1000); 191 + 192 + /* Fetch new health info is its older than MIN_HEALTH_QUERY_INTERVAL */ 193 + if (time_after(jiffies, cache_timeout)) 194 + rc = __drc_pmem_query_health(p); 195 + else 196 + /* Assume cached health data is valid */ 197 + rc = 0; 198 + 199 + mutex_unlock(&p->health_mutex); 200 + return rc; 201 + } 197 202 198 203 static int papr_scm_meta_get(struct papr_scm_priv *p, 199 204 struct nd_cmd_get_config_data_hdr *hdr) ··· 351 246 return 0; 352 247 } 353 248 249 + /* 250 + * Do a sanity checks on the inputs args to dimm-control function and return 251 + * '0' if valid. Validation of PDSM payloads happens later in 252 + * papr_scm_service_pdsm. 253 + */ 254 + static int is_cmd_valid(struct nvdimm *nvdimm, unsigned int cmd, void *buf, 255 + unsigned int buf_len) 256 + { 257 + unsigned long cmd_mask = PAPR_SCM_DIMM_CMD_MASK; 258 + struct nd_cmd_pkg *nd_cmd; 259 + struct papr_scm_priv *p; 260 + enum papr_pdsm pdsm; 261 + 262 + /* Only dimm-specific calls are supported atm */ 263 + if (!nvdimm) 264 + return -EINVAL; 265 + 266 + /* get the provider data from struct nvdimm */ 267 + p = nvdimm_provider_data(nvdimm); 268 + 269 + if (!test_bit(cmd, &cmd_mask)) { 270 + dev_dbg(&p->pdev->dev, "Unsupported cmd=%u\n", cmd); 271 + return -EINVAL; 272 + } 273 + 274 + /* For CMD_CALL verify pdsm request */ 275 + if (cmd == ND_CMD_CALL) { 276 + /* Verify the envelope and envelop size */ 277 + if (!buf || 278 + buf_len < (sizeof(struct nd_cmd_pkg) + ND_PDSM_HDR_SIZE)) { 279 + dev_dbg(&p->pdev->dev, "Invalid pkg size=%u\n", 280 + buf_len); 281 + return -EINVAL; 282 + } 283 + 284 + /* Verify that the nd_cmd_pkg.nd_family is correct */ 285 + nd_cmd = (struct nd_cmd_pkg *)buf; 286 + 287 + if (nd_cmd->nd_family != NVDIMM_FAMILY_PAPR) { 288 + dev_dbg(&p->pdev->dev, "Invalid pkg family=0x%llx\n", 289 + nd_cmd->nd_family); 290 + return -EINVAL; 291 + } 292 + 293 + pdsm = (enum papr_pdsm)nd_cmd->nd_command; 294 + 295 + /* Verify if the pdsm command is valid */ 296 + if (pdsm <= PAPR_PDSM_MIN || pdsm >= PAPR_PDSM_MAX) { 297 + dev_dbg(&p->pdev->dev, "PDSM[0x%x]: Invalid PDSM\n", 298 + pdsm); 299 + return -EINVAL; 300 + } 301 + 302 + /* Have enough space to hold returned 'nd_pkg_pdsm' header */ 303 + if (nd_cmd->nd_size_out < ND_PDSM_HDR_SIZE) { 304 + dev_dbg(&p->pdev->dev, "PDSM[0x%x]: Invalid payload\n", 305 + pdsm); 306 + return -EINVAL; 307 + } 308 + } 309 + 310 + /* Let the command be further processed */ 311 + return 0; 312 + } 313 + 314 + /* Fetch the DIMM health info and populate it in provided package. */ 315 + static int papr_pdsm_health(struct papr_scm_priv *p, 316 + union nd_pdsm_payload *payload) 317 + { 318 + int rc; 319 + 320 + /* Ensure dimm health mutex is taken preventing concurrent access */ 321 + rc = mutex_lock_interruptible(&p->health_mutex); 322 + if (rc) 323 + goto out; 324 + 325 + /* Always fetch upto date dimm health data ignoring cached values */ 326 + rc = __drc_pmem_query_health(p); 327 + if (rc) { 328 + mutex_unlock(&p->health_mutex); 329 + goto out; 330 + } 331 + 332 + /* update health struct with various flags derived from health bitmap */ 333 + payload->health = (struct nd_papr_pdsm_health) { 334 + .extension_flags = 0, 335 + .dimm_unarmed = !!(p->health_bitmap & PAPR_PMEM_UNARMED_MASK), 336 + .dimm_bad_shutdown = !!(p->health_bitmap & PAPR_PMEM_BAD_SHUTDOWN_MASK), 337 + .dimm_bad_restore = !!(p->health_bitmap & PAPR_PMEM_BAD_RESTORE_MASK), 338 + .dimm_scrubbed = !!(p->health_bitmap & PAPR_PMEM_SCRUBBED_AND_LOCKED), 339 + .dimm_locked = !!(p->health_bitmap & PAPR_PMEM_SCRUBBED_AND_LOCKED), 340 + .dimm_encrypted = !!(p->health_bitmap & PAPR_PMEM_ENCRYPTED), 341 + .dimm_health = PAPR_PDSM_DIMM_HEALTHY, 342 + }; 343 + 344 + /* Update field dimm_health based on health_bitmap flags */ 345 + if (p->health_bitmap & PAPR_PMEM_HEALTH_FATAL) 346 + payload->health.dimm_health = PAPR_PDSM_DIMM_FATAL; 347 + else if (p->health_bitmap & PAPR_PMEM_HEALTH_CRITICAL) 348 + payload->health.dimm_health = PAPR_PDSM_DIMM_CRITICAL; 349 + else if (p->health_bitmap & PAPR_PMEM_HEALTH_UNHEALTHY) 350 + payload->health.dimm_health = PAPR_PDSM_DIMM_UNHEALTHY; 351 + 352 + /* struct populated hence can release the mutex now */ 353 + mutex_unlock(&p->health_mutex); 354 + rc = sizeof(struct nd_papr_pdsm_health); 355 + 356 + out: 357 + return rc; 358 + } 359 + 360 + /* 361 + * 'struct pdsm_cmd_desc' 362 + * Identifies supported PDSMs' expected length of in/out payloads 363 + * and pdsm service function. 364 + * 365 + * size_in : Size of input payload if any in the PDSM request. 366 + * size_out : Size of output payload if any in the PDSM request. 367 + * service : Service function for the PDSM request. Return semantics: 368 + * rc < 0 : Error servicing PDSM and rc indicates the error. 369 + * rc >=0 : Serviced successfully and 'rc' indicate number of 370 + * bytes written to payload. 371 + */ 372 + struct pdsm_cmd_desc { 373 + u32 size_in; 374 + u32 size_out; 375 + int (*service)(struct papr_scm_priv *dimm, 376 + union nd_pdsm_payload *payload); 377 + }; 378 + 379 + /* Holds all supported PDSMs' command descriptors */ 380 + static const struct pdsm_cmd_desc __pdsm_cmd_descriptors[] = { 381 + [PAPR_PDSM_MIN] = { 382 + .size_in = 0, 383 + .size_out = 0, 384 + .service = NULL, 385 + }, 386 + /* New PDSM command descriptors to be added below */ 387 + 388 + [PAPR_PDSM_HEALTH] = { 389 + .size_in = 0, 390 + .size_out = sizeof(struct nd_papr_pdsm_health), 391 + .service = papr_pdsm_health, 392 + }, 393 + /* Empty */ 394 + [PAPR_PDSM_MAX] = { 395 + .size_in = 0, 396 + .size_out = 0, 397 + .service = NULL, 398 + }, 399 + }; 400 + 401 + /* Given a valid pdsm cmd return its command descriptor else return NULL */ 402 + static inline const struct pdsm_cmd_desc *pdsm_cmd_desc(enum papr_pdsm cmd) 403 + { 404 + if (cmd >= 0 || cmd < ARRAY_SIZE(__pdsm_cmd_descriptors)) 405 + return &__pdsm_cmd_descriptors[cmd]; 406 + 407 + return NULL; 408 + } 409 + 410 + /* 411 + * For a given pdsm request call an appropriate service function. 412 + * Returns errors if any while handling the pdsm command package. 413 + */ 414 + static int papr_scm_service_pdsm(struct papr_scm_priv *p, 415 + struct nd_cmd_pkg *pkg) 416 + { 417 + /* Get the PDSM header and PDSM command */ 418 + struct nd_pkg_pdsm *pdsm_pkg = (struct nd_pkg_pdsm *)pkg->nd_payload; 419 + enum papr_pdsm pdsm = (enum papr_pdsm)pkg->nd_command; 420 + const struct pdsm_cmd_desc *pdsc; 421 + int rc; 422 + 423 + /* Fetch corresponding pdsm descriptor for validation and servicing */ 424 + pdsc = pdsm_cmd_desc(pdsm); 425 + 426 + /* Validate pdsm descriptor */ 427 + /* Ensure that reserved fields are 0 */ 428 + if (pdsm_pkg->reserved[0] || pdsm_pkg->reserved[1]) { 429 + dev_dbg(&p->pdev->dev, "PDSM[0x%x]: Invalid reserved field\n", 430 + pdsm); 431 + return -EINVAL; 432 + } 433 + 434 + /* If pdsm expects some input, then ensure that the size_in matches */ 435 + if (pdsc->size_in && 436 + pkg->nd_size_in != (pdsc->size_in + ND_PDSM_HDR_SIZE)) { 437 + dev_dbg(&p->pdev->dev, "PDSM[0x%x]: Mismatched size_in=%d\n", 438 + pdsm, pkg->nd_size_in); 439 + return -EINVAL; 440 + } 441 + 442 + /* If pdsm wants to return data, then ensure that size_out matches */ 443 + if (pdsc->size_out && 444 + pkg->nd_size_out != (pdsc->size_out + ND_PDSM_HDR_SIZE)) { 445 + dev_dbg(&p->pdev->dev, "PDSM[0x%x]: Mismatched size_out=%d\n", 446 + pdsm, pkg->nd_size_out); 447 + return -EINVAL; 448 + } 449 + 450 + /* Service the pdsm */ 451 + if (pdsc->service) { 452 + dev_dbg(&p->pdev->dev, "PDSM[0x%x]: Servicing..\n", pdsm); 453 + 454 + rc = pdsc->service(p, &pdsm_pkg->payload); 455 + 456 + if (rc < 0) { 457 + /* error encountered while servicing pdsm */ 458 + pdsm_pkg->cmd_status = rc; 459 + pkg->nd_fw_size = ND_PDSM_HDR_SIZE; 460 + } else { 461 + /* pdsm serviced and 'rc' bytes written to payload */ 462 + pdsm_pkg->cmd_status = 0; 463 + pkg->nd_fw_size = ND_PDSM_HDR_SIZE + rc; 464 + } 465 + } else { 466 + dev_dbg(&p->pdev->dev, "PDSM[0x%x]: Unsupported PDSM request\n", 467 + pdsm); 468 + pdsm_pkg->cmd_status = -ENOENT; 469 + pkg->nd_fw_size = ND_PDSM_HDR_SIZE; 470 + } 471 + 472 + return pdsm_pkg->cmd_status; 473 + } 474 + 354 475 static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, 355 476 struct nvdimm *nvdimm, unsigned int cmd, void *buf, 356 477 unsigned int buf_len, int *cmd_rc) 357 478 { 358 479 struct nd_cmd_get_config_size *get_size_hdr; 480 + struct nd_cmd_pkg *call_pkg = NULL; 359 481 struct papr_scm_priv *p; 482 + int rc; 360 483 361 - /* Only dimm-specific calls are supported atm */ 362 - if (!nvdimm) 363 - return -EINVAL; 484 + rc = is_cmd_valid(nvdimm, cmd, buf, buf_len); 485 + if (rc) { 486 + pr_debug("Invalid cmd=0x%x. Err=%d\n", cmd, rc); 487 + return rc; 488 + } 489 + 490 + /* Use a local variable in case cmd_rc pointer is NULL */ 491 + if (!cmd_rc) 492 + cmd_rc = &rc; 364 493 365 494 p = nvdimm_provider_data(nvdimm); 366 495 ··· 616 277 *cmd_rc = papr_scm_meta_set(p, buf); 617 278 break; 618 279 280 + case ND_CMD_CALL: 281 + call_pkg = (struct nd_cmd_pkg *)buf; 282 + *cmd_rc = papr_scm_service_pdsm(p, call_pkg); 283 + break; 284 + 619 285 default: 286 + dev_dbg(&p->pdev->dev, "Unknown command = %d\n", cmd); 620 287 return -EINVAL; 621 288 } 622 289 ··· 630 285 631 286 return 0; 632 287 } 288 + 289 + static ssize_t flags_show(struct device *dev, 290 + struct device_attribute *attr, char *buf) 291 + { 292 + struct nvdimm *dimm = to_nvdimm(dev); 293 + struct papr_scm_priv *p = nvdimm_provider_data(dimm); 294 + struct seq_buf s; 295 + u64 health; 296 + int rc; 297 + 298 + rc = drc_pmem_query_health(p); 299 + if (rc) 300 + return rc; 301 + 302 + /* Copy health_bitmap locally, check masks & update out buffer */ 303 + health = READ_ONCE(p->health_bitmap); 304 + 305 + seq_buf_init(&s, buf, PAGE_SIZE); 306 + if (health & PAPR_PMEM_UNARMED_MASK) 307 + seq_buf_printf(&s, "not_armed "); 308 + 309 + if (health & PAPR_PMEM_BAD_SHUTDOWN_MASK) 310 + seq_buf_printf(&s, "flush_fail "); 311 + 312 + if (health & PAPR_PMEM_BAD_RESTORE_MASK) 313 + seq_buf_printf(&s, "restore_fail "); 314 + 315 + if (health & PAPR_PMEM_ENCRYPTED) 316 + seq_buf_printf(&s, "encrypted "); 317 + 318 + if (health & PAPR_PMEM_SMART_EVENT_MASK) 319 + seq_buf_printf(&s, "smart_notify "); 320 + 321 + if (health & PAPR_PMEM_SCRUBBED_AND_LOCKED) 322 + seq_buf_printf(&s, "scrubbed locked "); 323 + 324 + if (seq_buf_used(&s)) 325 + seq_buf_printf(&s, "\n"); 326 + 327 + return seq_buf_used(&s); 328 + } 329 + DEVICE_ATTR_RO(flags); 330 + 331 + /* papr_scm specific dimm attributes */ 332 + static struct attribute *papr_nd_attributes[] = { 333 + &dev_attr_flags.attr, 334 + NULL, 335 + }; 336 + 337 + static struct attribute_group papr_nd_attribute_group = { 338 + .name = "papr", 339 + .attrs = papr_nd_attributes, 340 + }; 341 + 342 + static const struct attribute_group *papr_nd_attr_groups[] = { 343 + &papr_nd_attribute_group, 344 + NULL, 345 + }; 633 346 634 347 static int papr_scm_nvdimm_init(struct papr_scm_priv *p) 635 348 { ··· 715 312 dimm_flags = 0; 716 313 set_bit(NDD_LABELING, &dimm_flags); 717 314 718 - p->nvdimm = nvdimm_create(p->bus, p, NULL, dimm_flags, 719 - PAPR_SCM_DIMM_CMD_MASK, 0, NULL); 315 + p->nvdimm = nvdimm_create(p->bus, p, papr_nd_attr_groups, 316 + dimm_flags, PAPR_SCM_DIMM_CMD_MASK, 0, NULL); 720 317 if (!p->nvdimm) { 721 318 dev_err(dev, "Error creating DIMM object for %pOF\n", p->dn); 722 319 goto err; ··· 801 398 p = kzalloc(sizeof(*p), GFP_KERNEL); 802 399 if (!p) 803 400 return -ENOMEM; 401 + 402 + /* Initialize the dimm mutex */ 403 + mutex_init(&p->health_mutex); 804 404 805 405 /* optional DT properties */ 806 406 of_property_read_u32(dn, "ibm,metadata-size", &metadata_size);
+3 -3
arch/powerpc/sysdev/fsl_pci.c
··· 1066 1066 1067 1067 if (is_in_pci_mem_space(addr)) { 1068 1068 if (user_mode(regs)) 1069 - ret = probe_user_read(&inst, (void __user *)regs->nip, 1070 - sizeof(inst)); 1069 + ret = copy_from_user_nofault(&inst, 1070 + (void __user *)regs->nip, sizeof(inst)); 1071 1071 else 1072 - ret = probe_kernel_address((void *)regs->nip, inst); 1072 + ret = get_kernel_nofault(inst, (void *)regs->nip); 1073 1073 1074 1074 if (!ret && mcheck_handle_load(regs, inst)) { 1075 1075 regs->nip += 4;
+4 -4
arch/riscv/include/asm/cmpxchg.h
··· 179 179 " bnez %1, 0b\n" \ 180 180 "1:\n" \ 181 181 : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ 182 - : "rJ" (__old), "rJ" (__new) \ 182 + : "rJ" ((long)__old), "rJ" (__new) \ 183 183 : "memory"); \ 184 184 break; \ 185 185 case 8: \ ··· 224 224 RISCV_ACQUIRE_BARRIER \ 225 225 "1:\n" \ 226 226 : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ 227 - : "rJ" (__old), "rJ" (__new) \ 227 + : "rJ" ((long)__old), "rJ" (__new) \ 228 228 : "memory"); \ 229 229 break; \ 230 230 case 8: \ ··· 270 270 " bnez %1, 0b\n" \ 271 271 "1:\n" \ 272 272 : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ 273 - : "rJ" (__old), "rJ" (__new) \ 273 + : "rJ" ((long)__old), "rJ" (__new) \ 274 274 : "memory"); \ 275 275 break; \ 276 276 case 8: \ ··· 316 316 " fence rw, rw\n" \ 317 317 "1:\n" \ 318 318 : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ 319 - : "rJ" (__old), "rJ" (__new) \ 319 + : "rJ" ((long)__old), "rJ" (__new) \ 320 320 : "memory"); \ 321 321 break; \ 322 322 case 8: \
+2 -1
arch/riscv/kernel/ftrace.c
··· 38 38 * Read the text we want to modify; 39 39 * return must be -EFAULT on read error 40 40 */ 41 - if (probe_kernel_read(replaced, (void *)hook_pos, MCOUNT_INSN_SIZE)) 41 + if (copy_from_kernel_nofault(replaced, (void *)hook_pos, 42 + MCOUNT_INSN_SIZE)) 42 43 return -EFAULT; 43 44 44 45 /*
+4 -4
arch/riscv/kernel/kgdb.c
··· 62 62 unsigned int rs1_num, rs2_num; 63 63 int op_code; 64 64 65 - if (probe_kernel_address((void *)pc, op_code)) 65 + if (get_kernel_nofault(op_code, (void *)pc)) 66 66 return -EINVAL; 67 67 if ((op_code & __INSN_LENGTH_MASK) != __INSN_LENGTH_GE_32) { 68 68 if (is_c_jalr_insn(op_code) || is_c_jr_insn(op_code)) { ··· 146 146 return error; 147 147 148 148 /* Store the op code in the stepped address */ 149 - error = probe_kernel_address((void *)addr, stepped_opcode); 149 + error = get_kernel_nofault(stepped_opcode, (void *)addr); 150 150 if (error) 151 151 return error; 152 152 153 153 stepped_address = addr; 154 154 155 155 /* Replace the op code with the break instruction */ 156 - error = probe_kernel_write((void *)stepped_address, 156 + error = copy_to_kernel_nofault((void *)stepped_address, 157 157 arch_kgdb_ops.gdb_bpt_instr, 158 158 BREAK_INSTR_SIZE); 159 159 /* Flush and return */ ··· 173 173 static void undo_single_step(struct pt_regs *regs) 174 174 { 175 175 if (stepped_opcode != 0) { 176 - probe_kernel_write((void *)stepped_address, 176 + copy_to_kernel_nofault((void *)stepped_address, 177 177 (void *)&stepped_opcode, BREAK_INSTR_SIZE); 178 178 flush_icache_range(stepped_address, 179 179 stepped_address + BREAK_INSTR_SIZE);
+2 -2
arch/riscv/kernel/patch.c
··· 63 63 64 64 waddr = patch_map(addr, FIX_TEXT_POKE0); 65 65 66 - ret = probe_kernel_write(waddr, insn, len); 66 + ret = copy_to_kernel_nofault(waddr, insn, len); 67 67 68 68 patch_unmap(FIX_TEXT_POKE0); 69 69 ··· 76 76 #else 77 77 static int patch_insn_write(void *addr, const void *insn, size_t len) 78 78 { 79 - return probe_kernel_write(addr, insn, len); 79 + return copy_to_kernel_nofault(addr, insn, len); 80 80 } 81 81 NOKPROBE_SYMBOL(patch_insn_write); 82 82 #endif /* CONFIG_MMU */
+6
arch/riscv/kernel/sys_riscv.c
··· 8 8 #include <linux/syscalls.h> 9 9 #include <asm/unistd.h> 10 10 #include <asm/cacheflush.h> 11 + #include <asm-generic/mman-common.h> 11 12 12 13 static long riscv_sys_mmap(unsigned long addr, unsigned long len, 13 14 unsigned long prot, unsigned long flags, ··· 17 16 { 18 17 if (unlikely(offset & (~PAGE_MASK >> page_shift_offset))) 19 18 return -EINVAL; 19 + 20 + if ((prot & PROT_WRITE) && (prot & PROT_EXEC)) 21 + if (unlikely(!(prot & PROT_READ))) 22 + return -EINVAL; 23 + 20 24 return ksys_mmap_pgoff(addr, len, prot, flags, fd, 21 25 offset >> (PAGE_SHIFT - page_shift_offset)); 22 26 }
+2 -2
arch/riscv/kernel/traps.c
··· 137 137 { 138 138 bug_insn_t insn; 139 139 140 - if (probe_kernel_address((bug_insn_t *)pc, insn)) 140 + if (get_kernel_nofault(insn, (bug_insn_t *)pc)) 141 141 return 0; 142 142 143 143 return GET_INSN_LENGTH(insn); ··· 165 165 166 166 if (pc < VMALLOC_START) 167 167 return 0; 168 - if (probe_kernel_address((bug_insn_t *)pc, insn)) 168 + if (get_kernel_nofault(insn, (bug_insn_t *)pc)) 169 169 return 0; 170 170 if ((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) 171 171 return (insn == __BUG_INSN_32);
+12 -2
arch/riscv/mm/pageattr.c
··· 151 151 152 152 int set_direct_map_invalid_noflush(struct page *page) 153 153 { 154 + int ret; 154 155 unsigned long start = (unsigned long)page_address(page); 155 156 unsigned long end = start + PAGE_SIZE; 156 157 struct pageattr_masks masks = { ··· 159 158 .clear_mask = __pgprot(_PAGE_PRESENT) 160 159 }; 161 160 162 - return walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); 161 + mmap_read_lock(&init_mm); 162 + ret = walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); 163 + mmap_read_unlock(&init_mm); 164 + 165 + return ret; 163 166 } 164 167 165 168 int set_direct_map_default_noflush(struct page *page) 166 169 { 170 + int ret; 167 171 unsigned long start = (unsigned long)page_address(page); 168 172 unsigned long end = start + PAGE_SIZE; 169 173 struct pageattr_masks masks = { ··· 176 170 .clear_mask = __pgprot(0) 177 171 }; 178 172 179 - return walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); 173 + mmap_read_lock(&init_mm); 174 + ret = walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); 175 + mmap_read_unlock(&init_mm); 176 + 177 + return ret; 180 178 } 181 179 182 180 void __kernel_map_pages(struct page *page, int numpages, int enable)
+1
arch/s390/Kconfig
··· 462 462 463 463 config NODES_SHIFT 464 464 int 465 + depends on NEED_MULTIPLE_NODES 465 466 default "1" 466 467 467 468 config SCHED_SMT
+7 -7
arch/s390/crypto/prng.c
··· 693 693 struct device_attribute *attr, 694 694 char *buf) 695 695 { 696 - return snprintf(buf, PAGE_SIZE, "%u\n", prng_chunk_size); 696 + return scnprintf(buf, PAGE_SIZE, "%u\n", prng_chunk_size); 697 697 } 698 698 static DEVICE_ATTR(chunksize, 0444, prng_chunksize_show, NULL); 699 699 ··· 712 712 counter = prng_data->prngws.byte_counter; 713 713 mutex_unlock(&prng_data->mutex); 714 714 715 - return snprintf(buf, PAGE_SIZE, "%llu\n", counter); 715 + return scnprintf(buf, PAGE_SIZE, "%llu\n", counter); 716 716 } 717 717 static DEVICE_ATTR(byte_counter, 0444, prng_counter_show, NULL); 718 718 ··· 721 721 struct device_attribute *attr, 722 722 char *buf) 723 723 { 724 - return snprintf(buf, PAGE_SIZE, "%d\n", prng_errorflag); 724 + return scnprintf(buf, PAGE_SIZE, "%d\n", prng_errorflag); 725 725 } 726 726 static DEVICE_ATTR(errorflag, 0444, prng_errorflag_show, NULL); 727 727 ··· 731 731 char *buf) 732 732 { 733 733 if (prng_mode == PRNG_MODE_TDES) 734 - return snprintf(buf, PAGE_SIZE, "TDES\n"); 734 + return scnprintf(buf, PAGE_SIZE, "TDES\n"); 735 735 else 736 - return snprintf(buf, PAGE_SIZE, "SHA512\n"); 736 + return scnprintf(buf, PAGE_SIZE, "SHA512\n"); 737 737 } 738 738 static DEVICE_ATTR(mode, 0444, prng_mode_show, NULL); 739 739 ··· 756 756 struct device_attribute *attr, 757 757 char *buf) 758 758 { 759 - return snprintf(buf, PAGE_SIZE, "%u\n", prng_reseed_limit); 759 + return scnprintf(buf, PAGE_SIZE, "%u\n", prng_reseed_limit); 760 760 } 761 761 static ssize_t prng_reseed_limit_store(struct device *dev, 762 762 struct device_attribute *attr, ··· 787 787 struct device_attribute *attr, 788 788 char *buf) 789 789 { 790 - return snprintf(buf, PAGE_SIZE, "256\n"); 790 + return scnprintf(buf, PAGE_SIZE, "256\n"); 791 791 } 792 792 static DEVICE_ATTR(strength, 0444, prng_strength_show, NULL); 793 793
+11 -1
arch/s390/include/asm/syscall.h
··· 33 33 static inline long syscall_get_error(struct task_struct *task, 34 34 struct pt_regs *regs) 35 35 { 36 - return IS_ERR_VALUE(regs->gprs[2]) ? regs->gprs[2] : 0; 36 + unsigned long error = regs->gprs[2]; 37 + #ifdef CONFIG_COMPAT 38 + if (test_tsk_thread_flag(task, TIF_31BIT)) { 39 + /* 40 + * Sign-extend the value so (int)-EFOO becomes (long)-EFOO 41 + * and will match correctly in comparisons. 42 + */ 43 + error = (long)(int)error; 44 + } 45 + #endif 46 + return IS_ERR_VALUE(error) ? error : 0; 37 47 } 38 48 39 49 static inline long syscall_get_return_value(struct task_struct *task,
+1
arch/s390/include/asm/vdso.h
··· 36 36 __u32 tk_shift; /* Shift used for xtime_nsec 0x60 */ 37 37 __u32 ts_dir; /* TOD steering direction 0x64 */ 38 38 __u64 ts_end; /* TOD steering end 0x68 */ 39 + __u32 hrtimer_res; /* hrtimer resolution 0x70 */ 39 40 }; 40 41 41 42 struct vdso_per_cpu_data {
+1 -1
arch/s390/kernel/asm-offsets.c
··· 76 76 OFFSET(__VDSO_TK_SHIFT, vdso_data, tk_shift); 77 77 OFFSET(__VDSO_TS_DIR, vdso_data, ts_dir); 78 78 OFFSET(__VDSO_TS_END, vdso_data, ts_end); 79 + OFFSET(__VDSO_CLOCK_REALTIME_RES, vdso_data, hrtimer_res); 79 80 OFFSET(__VDSO_ECTG_BASE, vdso_per_cpu_data, ectg_timer_base); 80 81 OFFSET(__VDSO_ECTG_USER, vdso_per_cpu_data, ectg_user_time); 81 82 OFFSET(__VDSO_GETCPU_VAL, vdso_per_cpu_data, getcpu_val); ··· 87 86 DEFINE(__CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE); 88 87 DEFINE(__CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE); 89 88 DEFINE(__CLOCK_THREAD_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID); 90 - DEFINE(__CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC); 91 89 DEFINE(__CLOCK_COARSE_RES, LOW_RES_NSEC); 92 90 BLANK(); 93 91 /* idle data offsets */
+1 -1
arch/s390/kernel/entry.S
··· 401 401 jnz .Lsysc_nr_ok 402 402 # svc 0: system call number in %r1 403 403 llgfr %r1,%r1 # clear high word in r1 404 + sth %r1,__PT_INT_CODE+2(%r11) 404 405 cghi %r1,NR_syscalls 405 406 jnl .Lsysc_nr_ok 406 - sth %r1,__PT_INT_CODE+2(%r11) 407 407 slag %r8,%r1,3 408 408 .Lsysc_nr_ok: 409 409 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
+2 -2
arch/s390/kernel/ftrace.c
··· 83 83 { 84 84 struct ftrace_insn orig, new, old; 85 85 86 - if (probe_kernel_read(&old, (void *) rec->ip, sizeof(old))) 86 + if (copy_from_kernel_nofault(&old, (void *) rec->ip, sizeof(old))) 87 87 return -EFAULT; 88 88 if (addr == MCOUNT_ADDR) { 89 89 /* Initial code replacement */ ··· 105 105 { 106 106 struct ftrace_insn orig, new, old; 107 107 108 - if (probe_kernel_read(&old, (void *) rec->ip, sizeof(old))) 108 + if (copy_from_kernel_nofault(&old, (void *) rec->ip, sizeof(old))) 109 109 return -EFAULT; 110 110 /* Replace nop with an ftrace call. */ 111 111 ftrace_generate_nop_insn(&orig);
+1 -1
arch/s390/kernel/ipl.c
··· 181 181 struct kobj_attribute *attr, \ 182 182 char *page) \ 183 183 { \ 184 - return snprintf(page, PAGE_SIZE, _format, ##args); \ 184 + return scnprintf(page, PAGE_SIZE, _format, ##args); \ 185 185 } 186 186 187 187 #define IPL_ATTR_CCW_STORE_FN(_prefix, _name, _ipl_blk) \
+69 -14
arch/s390/kernel/ptrace.c
··· 323 323 child->thread.per_user.end = data; 324 324 } 325 325 326 + static void fixup_int_code(struct task_struct *child, addr_t data) 327 + { 328 + struct pt_regs *regs = task_pt_regs(child); 329 + int ilc = regs->int_code >> 16; 330 + u16 insn; 331 + 332 + if (ilc > 6) 333 + return; 334 + 335 + if (ptrace_access_vm(child, regs->psw.addr - (regs->int_code >> 16), 336 + &insn, sizeof(insn), FOLL_FORCE) != sizeof(insn)) 337 + return; 338 + 339 + /* double check that tracee stopped on svc instruction */ 340 + if ((insn >> 8) != 0xa) 341 + return; 342 + 343 + regs->int_code = 0x20000 | (data & 0xffff); 344 + } 326 345 /* 327 346 * Write a word to the user area of a process at location addr. This 328 347 * operation does have an additional problem compared to peek_user. ··· 353 334 struct user *dummy = NULL; 354 335 addr_t offset; 355 336 337 + 356 338 if (addr < (addr_t) &dummy->regs.acrs) { 339 + struct pt_regs *regs = task_pt_regs(child); 357 340 /* 358 341 * psw and gprs are stored on the stack 359 342 */ ··· 373 352 /* Invalid addressing mode bits */ 374 353 return -EINVAL; 375 354 } 376 - *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data; 355 + 356 + if (test_pt_regs_flag(regs, PIF_SYSCALL) && 357 + addr == offsetof(struct user, regs.gprs[2])) 358 + fixup_int_code(child, data); 359 + *(addr_t *)((addr_t) &regs->psw + addr) = data; 377 360 378 361 } else if (addr < (addr_t) (&dummy->regs.orig_gpr2)) { 379 362 /* ··· 743 718 regs->psw.mask = (regs->psw.mask & ~PSW_MASK_BA) | 744 719 (__u64)(tmp & PSW32_ADDR_AMODE); 745 720 } else { 721 + 722 + if (test_pt_regs_flag(regs, PIF_SYSCALL) && 723 + addr == offsetof(struct compat_user, regs.gprs[2])) 724 + fixup_int_code(child, data); 746 725 /* gpr 0-15 */ 747 726 *(__u32*)((addr_t) &regs->psw + addr*2 + 4) = tmp; 748 727 } ··· 866 837 asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) 867 838 { 868 839 unsigned long mask = -1UL; 840 + long ret = -1; 841 + 842 + if (is_compat_task()) 843 + mask = 0xffffffff; 869 844 870 845 /* 871 846 * The sysc_tracesys code in entry.S stored the system 872 847 * call number to gprs[2]. 873 848 */ 874 849 if (test_thread_flag(TIF_SYSCALL_TRACE) && 875 - (tracehook_report_syscall_entry(regs) || 876 - regs->gprs[2] >= NR_syscalls)) { 850 + tracehook_report_syscall_entry(regs)) { 877 851 /* 878 - * Tracing decided this syscall should not happen or the 879 - * debugger stored an invalid system call number. Skip 852 + * Tracing decided this syscall should not happen. Skip 880 853 * the system call and the system call restart handling. 881 854 */ 882 - clear_pt_regs_flag(regs, PIF_SYSCALL); 883 - return -1; 855 + goto skip; 884 856 } 885 857 858 + #ifdef CONFIG_SECCOMP 886 859 /* Do the secure computing check after ptrace. */ 887 - if (secure_computing()) { 888 - /* seccomp failures shouldn't expose any additional code. */ 889 - return -1; 860 + if (unlikely(test_thread_flag(TIF_SECCOMP))) { 861 + struct seccomp_data sd; 862 + 863 + if (is_compat_task()) { 864 + sd.instruction_pointer = regs->psw.addr & 0x7fffffff; 865 + sd.arch = AUDIT_ARCH_S390; 866 + } else { 867 + sd.instruction_pointer = regs->psw.addr; 868 + sd.arch = AUDIT_ARCH_S390X; 869 + } 870 + 871 + sd.nr = regs->int_code & 0xffff; 872 + sd.args[0] = regs->orig_gpr2 & mask; 873 + sd.args[1] = regs->gprs[3] & mask; 874 + sd.args[2] = regs->gprs[4] & mask; 875 + sd.args[3] = regs->gprs[5] & mask; 876 + sd.args[4] = regs->gprs[6] & mask; 877 + sd.args[5] = regs->gprs[7] & mask; 878 + 879 + if (__secure_computing(&sd) == -1) 880 + goto skip; 890 881 } 882 + #endif /* CONFIG_SECCOMP */ 891 883 892 884 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 893 - trace_sys_enter(regs, regs->gprs[2]); 885 + trace_sys_enter(regs, regs->int_code & 0xffff); 894 886 895 - if (is_compat_task()) 896 - mask = 0xffffffff; 897 887 898 - audit_syscall_entry(regs->gprs[2], regs->orig_gpr2 & mask, 888 + audit_syscall_entry(regs->int_code & 0xffff, regs->orig_gpr2 & mask, 899 889 regs->gprs[3] &mask, regs->gprs[4] &mask, 900 890 regs->gprs[5] &mask); 901 891 892 + if ((signed long)regs->gprs[2] >= NR_syscalls) { 893 + regs->gprs[2] = -ENOSYS; 894 + ret = -ENOSYS; 895 + } 902 896 return regs->gprs[2]; 897 + skip: 898 + clear_pt_regs_flag(regs, PIF_SYSCALL); 899 + return ret; 903 900 } 904 901 905 902 asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
+1
arch/s390/kernel/time.c
··· 301 301 302 302 vdso_data->tk_mult = tk->tkr_mono.mult; 303 303 vdso_data->tk_shift = tk->tkr_mono.shift; 304 + vdso_data->hrtimer_res = hrtimer_resolution; 304 305 smp_wmb(); 305 306 ++vdso_data->tb_update_count; 306 307 }
+4 -4
arch/s390/kernel/uv.c
··· 331 331 static ssize_t uv_query_facilities(struct kobject *kobj, 332 332 struct kobj_attribute *attr, char *page) 333 333 { 334 - return snprintf(page, PAGE_SIZE, "%lx\n%lx\n%lx\n%lx\n", 334 + return scnprintf(page, PAGE_SIZE, "%lx\n%lx\n%lx\n%lx\n", 335 335 uv_info.inst_calls_list[0], 336 336 uv_info.inst_calls_list[1], 337 337 uv_info.inst_calls_list[2], ··· 344 344 static ssize_t uv_query_max_guest_cpus(struct kobject *kobj, 345 345 struct kobj_attribute *attr, char *page) 346 346 { 347 - return snprintf(page, PAGE_SIZE, "%d\n", 347 + return scnprintf(page, PAGE_SIZE, "%d\n", 348 348 uv_info.max_guest_cpus); 349 349 } 350 350 ··· 354 354 static ssize_t uv_query_max_guest_vms(struct kobject *kobj, 355 355 struct kobj_attribute *attr, char *page) 356 356 { 357 - return snprintf(page, PAGE_SIZE, "%d\n", 357 + return scnprintf(page, PAGE_SIZE, "%d\n", 358 358 uv_info.max_num_sec_conf); 359 359 } 360 360 ··· 364 364 static ssize_t uv_query_max_guest_addr(struct kobject *kobj, 365 365 struct kobj_attribute *attr, char *page) 366 366 { 367 - return snprintf(page, PAGE_SIZE, "%lx\n", 367 + return scnprintf(page, PAGE_SIZE, "%lx\n", 368 368 uv_info.max_sec_stor_addr); 369 369 } 370 370
+4 -6
arch/s390/kernel/vdso64/Makefile
··· 18 18 19 19 KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) 20 20 KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin 21 - KBUILD_CFLAGS_64 += -nostdlib -Wl,-soname=linux-vdso64.so.1 \ 22 - -Wl,--hash-style=both 21 + ldflags-y := -fPIC -shared -nostdlib -soname=linux-vdso64.so.1 \ 22 + --hash-style=both --build-id -T 23 23 24 24 $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64) 25 25 $(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64) ··· 37 37 $(obj)/vdso64_wrapper.o : $(obj)/vdso64.so 38 38 39 39 # link rule for the .so file, .lds has to be first 40 - $(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) FORCE 41 - $(call if_changed,vdso64ld) 40 + $(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) FORCE 41 + $(call if_changed,ld) 42 42 43 43 # strip rule for the .so file 44 44 $(obj)/%.so: OBJCOPYFLAGS := -S ··· 50 50 $(call if_changed_dep,vdso64as) 51 51 52 52 # actual build commands 53 - quiet_cmd_vdso64ld = VDSO64L $@ 54 - cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $(filter %.lds %.o,$^) -o $@ 55 53 quiet_cmd_vdso64as = VDSO64A $@ 56 54 cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $< 57 55
+5 -5
arch/s390/kernel/vdso64/clock_getres.S
··· 17 17 .type __kernel_clock_getres,@function 18 18 __kernel_clock_getres: 19 19 CFI_STARTPROC 20 - larl %r1,4f 20 + larl %r1,3f 21 + lg %r0,0(%r1) 21 22 cghi %r2,__CLOCK_REALTIME_COARSE 22 23 je 0f 23 24 cghi %r2,__CLOCK_MONOTONIC_COARSE 24 25 je 0f 25 - larl %r1,3f 26 + larl %r1,_vdso_data 27 + llgf %r0,__VDSO_CLOCK_REALTIME_RES(%r1) 26 28 cghi %r2,__CLOCK_REALTIME 27 29 je 0f 28 30 cghi %r2,__CLOCK_MONOTONIC ··· 38 36 jz 2f 39 37 0: ltgr %r3,%r3 40 38 jz 1f /* res == NULL */ 41 - lg %r0,0(%r1) 42 39 xc 0(8,%r3),0(%r3) /* set tp->tv_sec to zero */ 43 40 stg %r0,8(%r3) /* store tp->tv_usec */ 44 41 1: lghi %r2,0 ··· 46 45 svc 0 47 46 br %r14 48 47 CFI_ENDPROC 49 - 3: .quad __CLOCK_REALTIME_RES 50 - 4: .quad __CLOCK_COARSE_RES 48 + 3: .quad __CLOCK_COARSE_RES 51 49 .size __kernel_clock_getres,.-__kernel_clock_getres
+1 -1
arch/s390/mm/fault.c
··· 105 105 { 106 106 unsigned long dummy; 107 107 108 - return probe_kernel_address((unsigned long *)p, dummy); 108 + return get_kernel_nofault(dummy, (unsigned long *)p); 109 109 } 110 110 111 111 static void dump_pagetable(unsigned long asce, unsigned long address)
+3 -3
arch/sh/kernel/ftrace.c
··· 119 119 * But if one were to fail, then they all should, and if one were 120 120 * to succeed, then they all should. 121 121 */ 122 - mod_code_status = probe_kernel_write(mod_code_ip, mod_code_newcode, 122 + mod_code_status = copy_to_kernel_nofault(mod_code_ip, mod_code_newcode, 123 123 MCOUNT_INSN_SIZE); 124 124 125 125 /* if we fail, then kill any new writers */ ··· 203 203 */ 204 204 205 205 /* read the text we want to modify */ 206 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE)) 206 + if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE)) 207 207 return -EFAULT; 208 208 209 209 /* Make sure it is what we expect it to be */ ··· 268 268 { 269 269 unsigned char code[MCOUNT_INSN_SIZE]; 270 270 271 - if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE)) 271 + if (copy_from_kernel_nofault(code, (void *)ip, MCOUNT_INSN_SIZE)) 272 272 return -EFAULT; 273 273 274 274 if (old_addr != __raw_readl((unsigned long *)code))
+1 -1
arch/sh/kernel/traps.c
··· 118 118 119 119 if (addr < PAGE_OFFSET) 120 120 return 0; 121 - if (probe_kernel_address((insn_size_t *)addr, opcode)) 121 + if (get_kernel_nofault(opcode, (insn_size_t *)addr)) 122 122 return 0; 123 123 if (opcode == TRAPA_BUG_OPCODE) 124 124 return 1;
+1 -1
arch/um/kernel/maccess.c
··· 7 7 #include <linux/kernel.h> 8 8 #include <os.h> 9 9 10 - bool probe_kernel_read_allowed(const void *src, size_t size) 10 + bool copy_from_kernel_nofault_allowed(const void *src, size_t size) 11 11 { 12 12 void *psrc = (void *)rounddown((unsigned long)src, PAGE_SIZE); 13 13
+2 -2
arch/x86/include/asm/ptrace.h
··· 278 278 } 279 279 280 280 /* To avoid include hell, we can't include uaccess.h */ 281 - extern long probe_kernel_read(void *dst, const void *src, size_t size); 281 + extern long copy_from_kernel_nofault(void *dst, const void *src, size_t size); 282 282 283 283 /** 284 284 * regs_get_kernel_stack_nth() - get Nth entry of the stack ··· 298 298 299 299 addr = regs_get_kernel_stack_nth_addr(regs, n); 300 300 if (addr) { 301 - ret = probe_kernel_read(&val, addr, sizeof(val)); 301 + ret = copy_from_kernel_nofault(&val, addr, sizeof(val)); 302 302 if (!ret) 303 303 return val; 304 304 }
+1 -1
arch/x86/kernel/dumpstack.c
··· 106 106 bad_ip = user_mode(regs) && 107 107 __chk_range_not_ok(prologue, OPCODE_BUFSIZE, TASK_SIZE_MAX); 108 108 109 - if (bad_ip || probe_kernel_read(opcodes, (u8 *)prologue, 109 + if (bad_ip || copy_from_kernel_nofault(opcodes, (u8 *)prologue, 110 110 OPCODE_BUFSIZE)) { 111 111 printk("%sCode: Bad RIP value.\n", loglvl); 112 112 } else {
+5 -5
arch/x86/kernel/ftrace.c
··· 86 86 * sure what we read is what we expected it to be before modifying it. 87 87 */ 88 88 /* read the text we want to modify */ 89 - if (probe_kernel_read(cur_code, (void *)ip, MCOUNT_INSN_SIZE)) { 89 + if (copy_from_kernel_nofault(cur_code, (void *)ip, MCOUNT_INSN_SIZE)) { 90 90 WARN_ON(1); 91 91 return -EFAULT; 92 92 } ··· 355 355 npages = DIV_ROUND_UP(*tramp_size, PAGE_SIZE); 356 356 357 357 /* Copy ftrace_caller onto the trampoline memory */ 358 - ret = probe_kernel_read(trampoline, (void *)start_offset, size); 358 + ret = copy_from_kernel_nofault(trampoline, (void *)start_offset, size); 359 359 if (WARN_ON(ret < 0)) 360 360 goto fail; 361 361 ··· 363 363 364 364 /* The trampoline ends with ret(q) */ 365 365 retq = (unsigned long)ftrace_stub; 366 - ret = probe_kernel_read(ip, (void *)retq, RET_SIZE); 366 + ret = copy_from_kernel_nofault(ip, (void *)retq, RET_SIZE); 367 367 if (WARN_ON(ret < 0)) 368 368 goto fail; 369 369 370 370 if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) { 371 371 ip = trampoline + (ftrace_regs_caller_ret - ftrace_regs_caller); 372 - ret = probe_kernel_read(ip, (void *)retq, RET_SIZE); 372 + ret = copy_from_kernel_nofault(ip, (void *)retq, RET_SIZE); 373 373 if (WARN_ON(ret < 0)) 374 374 goto fail; 375 375 } ··· 506 506 union text_poke_insn call; 507 507 int ret; 508 508 509 - ret = probe_kernel_read(&call, ptr, CALL_INSN_SIZE); 509 + ret = copy_from_kernel_nofault(&call, ptr, CALL_INSN_SIZE); 510 510 if (WARN_ON_ONCE(ret < 0)) 511 511 return NULL; 512 512
+3 -3
arch/x86/kernel/kgdb.c
··· 732 732 int err; 733 733 734 734 bpt->type = BP_BREAKPOINT; 735 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr, 735 + err = copy_from_kernel_nofault(bpt->saved_instr, (char *)bpt->bpt_addr, 736 736 BREAK_INSTR_SIZE); 737 737 if (err) 738 738 return err; 739 - err = probe_kernel_write((char *)bpt->bpt_addr, 739 + err = copy_to_kernel_nofault((char *)bpt->bpt_addr, 740 740 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE); 741 741 if (!err) 742 742 return err; ··· 768 768 return 0; 769 769 770 770 knl_write: 771 - return probe_kernel_write((char *)bpt->bpt_addr, 771 + return copy_to_kernel_nofault((char *)bpt->bpt_addr, 772 772 (char *)bpt->saved_instr, BREAK_INSTR_SIZE); 773 773 } 774 774
+6 -15
arch/x86/kernel/kprobes/core.c
··· 243 243 * Fortunately, we know that the original code is the ideal 5-byte 244 244 * long NOP. 245 245 */ 246 - if (probe_kernel_read(buf, (void *)addr, 246 + if (copy_from_kernel_nofault(buf, (void *)addr, 247 247 MAX_INSN_SIZE * sizeof(kprobe_opcode_t))) 248 248 return 0UL; 249 249 ··· 346 346 return 0; 347 347 348 348 /* This can access kernel text if given address is not recovered */ 349 - if (probe_kernel_read(dest, (void *)recovered_insn, MAX_INSN_SIZE)) 349 + if (copy_from_kernel_nofault(dest, (void *)recovered_insn, 350 + MAX_INSN_SIZE)) 350 351 return 0; 351 352 352 353 kernel_insn_init(insn, dest, MAX_INSN_SIZE); ··· 754 753 NOKPROBE_SYMBOL(kretprobe_trampoline); 755 754 STACK_FRAME_NON_STANDARD(kretprobe_trampoline); 756 755 757 - static struct kprobe kretprobe_kprobe = { 758 - .addr = (void *)kretprobe_trampoline, 759 - }; 760 - 761 756 /* 762 757 * Called from kretprobe_trampoline 763 758 */ 764 759 __used __visible void *trampoline_handler(struct pt_regs *regs) 765 760 { 766 - struct kprobe_ctlblk *kcb; 767 761 struct kretprobe_instance *ri = NULL; 768 762 struct hlist_head *head, empty_rp; 769 763 struct hlist_node *tmp; ··· 768 772 void *frame_pointer; 769 773 bool skipped = false; 770 774 771 - preempt_disable(); 772 - 773 775 /* 774 776 * Set a dummy kprobe for avoiding kretprobe recursion. 775 777 * Since kretprobe never run in kprobe handler, kprobe must not 776 778 * be running at this point. 777 779 */ 778 - kcb = get_kprobe_ctlblk(); 779 - __this_cpu_write(current_kprobe, &kretprobe_kprobe); 780 - kcb->kprobe_status = KPROBE_HIT_ACTIVE; 780 + kprobe_busy_begin(); 781 781 782 782 INIT_HLIST_HEAD(&empty_rp); 783 783 kretprobe_hash_lock(current, &head, &flags); ··· 849 857 __this_cpu_write(current_kprobe, &ri->rp->kp); 850 858 ri->ret_addr = correct_ret_addr; 851 859 ri->rp->handler(ri, regs); 852 - __this_cpu_write(current_kprobe, &kretprobe_kprobe); 860 + __this_cpu_write(current_kprobe, &kprobe_busy); 853 861 } 854 862 855 863 recycle_rp_inst(ri, &empty_rp); ··· 865 873 866 874 kretprobe_hash_unlock(current, &flags); 867 875 868 - __this_cpu_write(current_kprobe, NULL); 869 - preempt_enable(); 876 + kprobe_busy_end(); 870 877 871 878 hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) { 872 879 hlist_del(&ri->hlist);
+1 -1
arch/x86/kernel/kprobes/opt.c
··· 56 56 * overwritten by jump destination address. In this case, original 57 57 * bytes must be recovered from op->optinsn.copied_insn buffer. 58 58 */ 59 - if (probe_kernel_read(buf, (void *)addr, 59 + if (copy_from_kernel_nofault(buf, (void *)addr, 60 60 MAX_INSN_SIZE * sizeof(kprobe_opcode_t))) 61 61 return 0UL; 62 62
+12 -12
arch/x86/kernel/probe_roms.c
··· 94 94 } 95 95 96 96 static bool probe_list(struct pci_dev *pdev, unsigned short vendor, 97 - const unsigned char *rom_list) 97 + const void *rom_list) 98 98 { 99 99 unsigned short device; 100 100 101 101 do { 102 - if (probe_kernel_address(rom_list, device) != 0) 102 + if (get_kernel_nofault(device, rom_list) != 0) 103 103 device = 0; 104 104 105 105 if (device && match_id(pdev, vendor, device)) ··· 119 119 for (i = 0; i < ARRAY_SIZE(adapter_rom_resources); i++) { 120 120 struct resource *res = &adapter_rom_resources[i]; 121 121 unsigned short offset, vendor, device, list, rev; 122 - const unsigned char *rom; 122 + const void *rom; 123 123 124 124 if (res->end == 0) 125 125 break; 126 126 127 127 rom = isa_bus_to_virt(res->start); 128 - if (probe_kernel_address(rom + 0x18, offset) != 0) 128 + if (get_kernel_nofault(offset, rom + 0x18) != 0) 129 129 continue; 130 130 131 - if (probe_kernel_address(rom + offset + 0x4, vendor) != 0) 131 + if (get_kernel_nofault(vendor, rom + offset + 0x4) != 0) 132 132 continue; 133 133 134 - if (probe_kernel_address(rom + offset + 0x6, device) != 0) 134 + if (get_kernel_nofault(device, rom + offset + 0x6) != 0) 135 135 continue; 136 136 137 137 if (match_id(pdev, vendor, device)) { ··· 139 139 break; 140 140 } 141 141 142 - if (probe_kernel_address(rom + offset + 0x8, list) == 0 && 143 - probe_kernel_address(rom + offset + 0xc, rev) == 0 && 142 + if (get_kernel_nofault(list, rom + offset + 0x8) == 0 && 143 + get_kernel_nofault(rev, rom + offset + 0xc) == 0 && 144 144 rev >= 3 && list && 145 145 probe_list(pdev, vendor, rom + offset + list)) { 146 146 oprom = res; ··· 183 183 const unsigned short * const ptr = (const unsigned short *)rom; 184 184 unsigned short sig; 185 185 186 - return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE; 186 + return get_kernel_nofault(sig, ptr) == 0 && sig == ROMSIGNATURE; 187 187 } 188 188 189 189 static int __init romchecksum(const unsigned char *rom, unsigned long length) 190 190 { 191 191 unsigned char sum, c; 192 192 193 - for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--) 193 + for (sum = 0; length && get_kernel_nofault(c, rom++) == 0; length--) 194 194 sum += c; 195 195 return !length && !sum; 196 196 } ··· 211 211 212 212 video_rom_resource.start = start; 213 213 214 - if (probe_kernel_address(rom + 2, c) != 0) 214 + if (get_kernel_nofault(c, rom + 2) != 0) 215 215 continue; 216 216 217 217 /* 0 < length <= 0x7f * 512, historically */ ··· 249 249 if (!romsignature(rom)) 250 250 continue; 251 251 252 - if (probe_kernel_address(rom + 2, c) != 0) 252 + if (get_kernel_nofault(c, rom + 2) != 0) 253 253 continue; 254 254 255 255 /* 0 < length <= 0x7f * 512, historically */
+3 -2
arch/x86/kernel/traps.c
··· 91 91 if (addr < TASK_SIZE_MAX) 92 92 return 0; 93 93 94 - if (probe_kernel_address((unsigned short *)addr, ud)) 94 + if (get_kernel_nofault(ud, (unsigned short *)addr)) 95 95 return 0; 96 96 97 97 return ud == INSN_UD0 || ud == INSN_UD2; ··· 488 488 u8 insn_buf[MAX_INSN_SIZE]; 489 489 struct insn insn; 490 490 491 - if (probe_kernel_read(insn_buf, (void *)regs->ip, MAX_INSN_SIZE)) 491 + if (copy_from_kernel_nofault(insn_buf, (void *)regs->ip, 492 + MAX_INSN_SIZE)) 492 493 return GP_NO_HINT; 493 494 494 495 kernel_insn_init(&insn, insn_buf, MAX_INSN_SIZE);
+4 -4
arch/x86/mm/fault.c
··· 99 99 return !instr_lo || (instr_lo>>1) == 1; 100 100 case 0x00: 101 101 /* Prefetch instruction is 0x0F0D or 0x0F18 */ 102 - if (probe_kernel_address(instr, opcode)) 102 + if (get_kernel_nofault(opcode, instr)) 103 103 return 0; 104 104 105 105 *prefetch = (instr_lo == 0xF) && ··· 133 133 while (instr < max_instr) { 134 134 unsigned char opcode; 135 135 136 - if (probe_kernel_address(instr, opcode)) 136 + if (get_kernel_nofault(opcode, instr)) 137 137 break; 138 138 139 139 instr++; ··· 301 301 { 302 302 unsigned long dummy; 303 303 304 - return probe_kernel_address((unsigned long *)p, dummy); 304 + return get_kernel_nofault(dummy, (unsigned long *)p); 305 305 } 306 306 307 307 static void dump_pagetable(unsigned long address) ··· 442 442 return; 443 443 } 444 444 445 - if (probe_kernel_read(&desc, (void *)(gdt->address + offset), 445 + if (copy_from_kernel_nofault(&desc, (void *)(gdt->address + offset), 446 446 sizeof(struct ldttss_desc))) { 447 447 pr_alert("%s: 0x%hx -- GDT entry is not readable\n", 448 448 name, index);
+1 -1
arch/x86/mm/init_32.c
··· 737 737 738 738 __set_fixmap(FIX_WP_TEST, __pa_symbol(empty_zero_page), PAGE_KERNEL_RO); 739 739 740 - if (probe_kernel_write((char *)fix_to_virt(FIX_WP_TEST), &z, 1)) { 740 + if (copy_to_kernel_nofault((char *)fix_to_virt(FIX_WP_TEST), &z, 1)) { 741 741 clear_fixmap(FIX_WP_TEST); 742 742 printk(KERN_CONT "Ok.\n"); 743 743 return;
+2 -2
arch/x86/mm/maccess.c
··· 9 9 return ((s64)vaddr << (64 - vaddr_bits)) >> (64 - vaddr_bits); 10 10 } 11 11 12 - bool probe_kernel_read_allowed(const void *unsafe_src, size_t size) 12 + bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) 13 13 { 14 14 unsigned long vaddr = (unsigned long)unsafe_src; 15 15 ··· 22 22 canonical_address(vaddr, boot_cpu_data.x86_virt_bits) == vaddr; 23 23 } 24 24 #else 25 - bool probe_kernel_read_allowed(const void *unsafe_src, size_t size) 25 + bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) 26 26 { 27 27 return (unsigned long)unsafe_src >= TASK_SIZE_MAX; 28 28 }
+1 -1
arch/x86/pci/pcbios.c
··· 302 302 check <= (union bios32 *) __va(0xffff0); 303 303 ++check) { 304 304 long sig; 305 - if (probe_kernel_address(&check->fields.signature, sig)) 305 + if (get_kernel_nofault(sig, &check->fields.signature)) 306 306 continue; 307 307 308 308 if (check->fields.signature != BIOS32_SIGNATURE)
+2 -2
arch/x86/platform/intel-mid/sfi.c
··· 287 287 288 288 adapter = i2c_get_adapter(i2c_bus[i]); 289 289 if (adapter) { 290 - client = i2c_new_device(adapter, i2c_devs[i]); 291 - if (!client) 290 + client = i2c_new_client_device(adapter, i2c_devs[i]); 291 + if (IS_ERR(client)) 292 292 pr_err("can't create i2c device %s\n", 293 293 i2c_devs[i]->type); 294 294 } else
+1
arch/x86/purgatory/Makefile
··· 34 34 PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel 35 35 PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss 36 36 PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING 37 + PURGATORY_CFLAGS += $(call cc-option,-fno-stack-protector) 37 38 38 39 # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That 39 40 # in turn leaves some undefined symbols like __fentry__ in purgatory and not
+1 -1
arch/x86/xen/enlighten_pv.c
··· 386 386 387 387 preempt_disable(); 388 388 389 - probe_kernel_read(&dummy, v, 1); 389 + copy_from_kernel_nofault(&dummy, v, 1); 390 390 391 391 if (HYPERVISOR_update_va_mapping((unsigned long)v, pte, 0)) 392 392 BUG();
+1 -1
block/blk-mq-tag.c
··· 376 376 void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn, 377 377 void *priv) 378 378 { 379 - return __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS); 379 + __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS); 380 380 } 381 381 382 382 /**
+3 -1
block/blk-mq.c
··· 3479 3479 3480 3480 if (set->nr_maps == 1 && nr_hw_queues > nr_cpu_ids) 3481 3481 nr_hw_queues = nr_cpu_ids; 3482 - if (nr_hw_queues < 1 || nr_hw_queues == set->nr_hw_queues) 3482 + if (nr_hw_queues < 1) 3483 + return; 3484 + if (set->nr_maps == 1 && nr_hw_queues == set->nr_hw_queues) 3483 3485 return; 3484 3486 3485 3487 list_for_each_entry(q, &set->tag_list, tag_set_list)
+1 -1
block/partitions/ldm.c
··· 910 910 return false; 911 911 912 912 disk = &vb->vblk.disk; 913 - uuid_copy(&disk->disk_id, (uuid_t *)(buffer + 0x18 + r_name)); 913 + import_uuid(&disk->disk_id, buffer + 0x18 + r_name); 914 914 return true; 915 915 } 916 916
+1 -1
block/partitions/ldm.h
··· 93 93 u8 num; /* Total number of records */ 94 94 u8 rec; /* This is record number n */ 95 95 u8 map; /* Which portions are in use */ 96 - u8 data[0]; 96 + u8 data[]; 97 97 }; 98 98 99 99 /* In memory LDM database structures. */
-2
crypto/algboss.c
··· 178 178 if (IS_ERR(thread)) 179 179 goto err_put_larval; 180 180 181 - wait_for_completion_interruptible(&larval->completion); 182 - 183 181 return NOTIFY_STOP; 184 182 185 183 err_put_larval:
+1 -5
crypto/algif_skcipher.c
··· 74 74 return PTR_ERR(areq); 75 75 76 76 /* convert iovecs of output buffers into RX SGL */ 77 - err = af_alg_get_rsgl(sk, msg, flags, areq, -1, &len); 77 + err = af_alg_get_rsgl(sk, msg, flags, areq, ctx->used, &len); 78 78 if (err) 79 79 goto free; 80 - 81 - /* Process only as much RX buffers for which we have TX data */ 82 - if (len > ctx->used) 83 - len = ctx->used; 84 80 85 81 /* 86 82 * If more buffers are to be expected to be processed, process only
+4 -2
crypto/drbg.c
··· 1631 1631 if (drbg->random_ready.func) { 1632 1632 del_random_ready_callback(&drbg->random_ready); 1633 1633 cancel_work_sync(&drbg->seed_work); 1634 - crypto_free_rng(drbg->jent); 1635 - drbg->jent = NULL; 1636 1634 } 1635 + 1636 + if (!IS_ERR_OR_NULL(drbg->jent)) 1637 + crypto_free_rng(drbg->jent); 1638 + drbg->jent = NULL; 1637 1639 1638 1640 if (drbg->d_ops) 1639 1641 drbg->d_ops->crypto_fini(drbg);
+1 -1
drivers/amba/tegra-ahb.c
··· 120 120 struct tegra_ahb { 121 121 void __iomem *regs; 122 122 struct device *dev; 123 - u32 ctx[0]; 123 + u32 ctx[]; 124 124 }; 125 125 126 126 static inline u32 gizmo_readl(struct tegra_ahb *ahb, u32 offset)
+5 -6
drivers/ata/libata-core.c
··· 42 42 #include <linux/workqueue.h> 43 43 #include <linux/scatterlist.h> 44 44 #include <linux/io.h> 45 - #include <linux/async.h> 46 45 #include <linux/log2.h> 47 46 #include <linux/slab.h> 48 47 #include <linux/glob.h> ··· 5777 5778 /* perform each probe asynchronously */ 5778 5779 for (i = 0; i < host->n_ports; i++) { 5779 5780 struct ata_port *ap = host->ports[i]; 5780 - async_schedule(async_port_probe, ap); 5781 + ap->cookie = async_schedule(async_port_probe, ap); 5781 5782 } 5782 5783 5783 5784 return 0; ··· 5919 5920 { 5920 5921 int i; 5921 5922 5922 - /* Ensure ata_port probe has completed */ 5923 - async_synchronize_full(); 5924 - 5925 - for (i = 0; i < host->n_ports; i++) 5923 + for (i = 0; i < host->n_ports; i++) { 5924 + /* Ensure ata_port probe has completed */ 5925 + async_synchronize_cookie(host->ports[i]->cookie + 1); 5926 5926 ata_port_detach(host->ports[i]); 5927 + } 5927 5928 5928 5929 /* the host is dead now, dissociate ACPI */ 5929 5930 ata_acpi_dissociate(host);
+6 -3
drivers/ata/libata-scsi.c
··· 3684 3684 { 3685 3685 struct scsi_cmnd *scmd = qc->scsicmd; 3686 3686 const u8 *cdb = scmd->cmnd; 3687 - const u8 *p; 3688 3687 u8 pg, spg; 3689 3688 unsigned six_byte, pg_len, hdr_len, bd_len; 3690 3689 int len; 3691 3690 u16 fp = (u16)-1; 3692 3691 u8 bp = 0xff; 3692 + u8 buffer[64]; 3693 + const u8 *p = buffer; 3693 3694 3694 3695 VPRINTK("ENTER\n"); 3695 3696 ··· 3724 3723 if (!scsi_sg_count(scmd) || scsi_sglist(scmd)->length < len) 3725 3724 goto invalid_param_len; 3726 3725 3727 - p = page_address(sg_page(scsi_sglist(scmd))); 3728 - 3729 3726 /* Move past header and block descriptors. */ 3730 3727 if (len < hdr_len) 3728 + goto invalid_param_len; 3729 + 3730 + if (!sg_copy_to_buffer(scsi_sglist(scmd), scsi_sg_count(scmd), 3731 + buffer, sizeof(buffer))) 3731 3732 goto invalid_param_len; 3732 3733 3733 3734 if (six_byte)
+7 -4
drivers/ata/sata_rcar.c
··· 907 907 pm_runtime_enable(dev); 908 908 ret = pm_runtime_get_sync(dev); 909 909 if (ret < 0) 910 - goto err_pm_disable; 910 + goto err_pm_put; 911 911 912 912 host = ata_host_alloc(dev, 1); 913 913 if (!host) { ··· 937 937 938 938 err_pm_put: 939 939 pm_runtime_put(dev); 940 - err_pm_disable: 941 940 pm_runtime_disable(dev); 942 941 return ret; 943 942 } ··· 990 991 int ret; 991 992 992 993 ret = pm_runtime_get_sync(dev); 993 - if (ret < 0) 994 + if (ret < 0) { 995 + pm_runtime_put(dev); 994 996 return ret; 997 + } 995 998 996 999 if (priv->type == RCAR_GEN3_SATA) { 997 1000 sata_rcar_init_module(priv); ··· 1018 1017 int ret; 1019 1018 1020 1019 ret = pm_runtime_get_sync(dev); 1021 - if (ret < 0) 1020 + if (ret < 0) { 1021 + pm_runtime_put(dev); 1022 1022 return ret; 1023 + } 1023 1024 1024 1025 sata_rcar_setup_port(host); 1025 1026
+1 -1
drivers/block/drbd/drbd_int.h
··· 620 620 unsigned int head_index; 621 621 unsigned int size; 622 622 int total; /* sum of all values */ 623 - int values[0]; 623 + int values[]; 624 624 }; 625 625 extern struct fifo_buffer *fifo_alloc(unsigned int fifo_size); 626 626
+4 -4
drivers/block/drbd/drbd_protocol.h
··· 271 271 u32 resync_rate; 272 272 273 273 /* Since protocol version 88 and higher. */ 274 - char verify_alg[0]; 274 + char verify_alg[]; 275 275 } __packed; 276 276 277 277 struct p_rs_param_89 { ··· 305 305 u32 two_primaries; 306 306 307 307 /* Since protocol version 87 and higher. */ 308 - char integrity_alg[0]; 308 + char integrity_alg[]; 309 309 310 310 } __packed; 311 311 ··· 360 360 u16 dds_flags; /* use enum dds_flags here. */ 361 361 362 362 /* optional queue_limits if (agreed_features & DRBD_FF_WSAME) */ 363 - struct o_qlim qlim[0]; 363 + struct o_qlim qlim[]; 364 364 } __packed; 365 365 366 366 struct p_state { ··· 409 409 */ 410 410 u8 encoding; 411 411 412 - u8 code[0]; 412 + u8 code[]; 413 413 } __packed; 414 414 415 415 struct p_delay_probe93 {
+4 -4
drivers/block/loop.c
··· 1368 1368 lo->lo_sizelimit != info->lo_sizelimit) { 1369 1369 size_changed = true; 1370 1370 sync_blockdev(lo->lo_device); 1371 - kill_bdev(lo->lo_device); 1371 + invalidate_bdev(lo->lo_device); 1372 1372 } 1373 1373 1374 1374 /* I/O need to be drained during transfer transition */ 1375 1375 blk_mq_freeze_queue(lo->lo_queue); 1376 1376 1377 1377 if (size_changed && lo->lo_device->bd_inode->i_mapping->nrpages) { 1378 - /* If any pages were dirtied after kill_bdev(), try again */ 1378 + /* If any pages were dirtied after invalidate_bdev(), try again */ 1379 1379 err = -EAGAIN; 1380 1380 pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n", 1381 1381 __func__, lo->lo_number, lo->lo_file_name, ··· 1615 1615 return 0; 1616 1616 1617 1617 sync_blockdev(lo->lo_device); 1618 - kill_bdev(lo->lo_device); 1618 + invalidate_bdev(lo->lo_device); 1619 1619 1620 1620 blk_mq_freeze_queue(lo->lo_queue); 1621 1621 1622 - /* kill_bdev should have truncated all the pages */ 1622 + /* invalidate_bdev should have truncated all the pages */ 1623 1623 if (lo->lo_device->bd_inode->i_mapping->nrpages) { 1624 1624 err = -EAGAIN; 1625 1625 pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n",
+3 -1
drivers/block/rbd.c
··· 1451 1451 static void rbd_osd_format_read(struct ceph_osd_request *osd_req) 1452 1452 { 1453 1453 struct rbd_obj_request *obj_request = osd_req->r_priv; 1454 + struct rbd_device *rbd_dev = obj_request->img_request->rbd_dev; 1455 + struct ceph_options *opt = rbd_dev->rbd_client->client->options; 1454 1456 1455 - osd_req->r_flags = CEPH_OSD_FLAG_READ; 1457 + osd_req->r_flags = CEPH_OSD_FLAG_READ | opt->read_from_replica; 1456 1458 osd_req->r_snapid = obj_request->img_request->snap_id; 1457 1459 } 1458 1460
+1
drivers/char/hw_random/ks-sa-rng.c
··· 244 244 ret = pm_runtime_get_sync(dev); 245 245 if (ret < 0) { 246 246 dev_err(dev, "Failed to enable SA power-domain\n"); 247 + pm_runtime_put_noidle(dev); 247 248 pm_runtime_disable(dev); 248 249 return ret; 249 250 }
+1 -1
drivers/char/mem.c
··· 171 171 if (!ptr) 172 172 goto failed; 173 173 174 - probe = probe_kernel_read(bounce, ptr, sz); 174 + probe = copy_from_kernel_nofault(bounce, ptr, sz); 175 175 unxlate_dev_mem_ptr(p, ptr); 176 176 if (probe) 177 177 goto failed;
+1 -1
drivers/crypto/caam/Kconfig
··· 147 147 select HW_RANDOM 148 148 help 149 149 Selecting this will register the SEC4 hardware rng to 150 - the hw_random API for suppying the kernel entropy pool. 150 + the hw_random API for supplying the kernel entropy pool. 151 151 152 152 endif # CRYPTO_DEV_FSL_CAAM_JR 153 153
+9 -9
drivers/crypto/caam/ctrl.c
··· 54 54 55 55 /* 56 56 * load 1 to clear written reg: 57 - * resets the done interrrupt and returns the RNG to idle. 57 + * resets the done interrupt and returns the RNG to idle. 58 58 */ 59 59 append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW); 60 60 ··· 156 156 DESC_DER_DECO_STAT_SHIFT; 157 157 158 158 /* 159 - * If an error occured in the descriptor, then 159 + * If an error occurred in the descriptor, then 160 160 * the DECO status field will be set to 0x0D 161 161 */ 162 162 if (deco_state == DECO_STAT_HOST_ERR) ··· 264 264 * - -ENODEV if DECO0 couldn't be acquired 265 265 * - -EAGAIN if an error occurred when executing the descriptor 266 266 * f.i. there was a RNG hardware error due to not "good enough" 267 - * entropy being aquired. 267 + * entropy being acquired. 268 268 */ 269 269 static int instantiate_rng(struct device *ctrldev, int state_handle_mask, 270 270 int gen_sk) ··· 733 733 handle_imx6_err005766(&ctrl->mcr); 734 734 735 735 /* 736 - * Read the Compile Time paramters and SCFGR to determine 737 - * if Virtualization is enabled for this platform 736 + * Read the Compile Time parameters and SCFGR to determine 737 + * if virtualization is enabled for this platform 738 738 */ 739 739 scfgr = rd_reg32(&ctrl->scfgr); 740 740 ··· 863 863 } 864 864 /* 865 865 * if instantiate_rng(...) fails, the loop will rerun 866 - * and the kick_trng(...) function will modfiy the 866 + * and the kick_trng(...) function will modify the 867 867 * upper and lower limits of the entropy sampling 868 - * interval, leading to a sucessful initialization of 868 + * interval, leading to a successful initialization of 869 869 * the RNG. 870 870 */ 871 871 ret = instantiate_rng(dev, inst_handles, ··· 882 882 return ret; 883 883 } 884 884 /* 885 - * Set handles init'ed by this module as the complement of the 886 - * already initialized ones 885 + * Set handles initialized by this module as the complement of 886 + * the already initialized ones 887 887 */ 888 888 ctrlpriv->rng4_sh_init = ~ctrlpriv->rng4_sh_init & RDSTA_MASK; 889 889
+2 -2
drivers/crypto/caam/desc.h
··· 18 18 */ 19 19 20 20 #define SEC4_SG_LEN_EXT 0x80000000 /* Entry points to table */ 21 - #define SEC4_SG_LEN_FIN 0x40000000 /* Last ent in table */ 21 + #define SEC4_SG_LEN_FIN 0x40000000 /* Last entry in table */ 22 22 #define SEC4_SG_BPID_MASK 0x000000ff 23 23 #define SEC4_SG_BPID_SHIFT 16 24 24 #define SEC4_SG_LEN_MASK 0x3fffffff /* Excludes EXT and FINAL */ ··· 113 113 */ 114 114 #define HDR_REVERSE 0x00000800 115 115 116 - /* Propogate DNR property to SharedDesc */ 116 + /* Propagate DNR property to SharedDesc */ 117 117 #define HDR_PROP_DNR 0x00000800 118 118 119 119 /* JobDesc/SharedDesc share property */
+1 -1
drivers/crypto/caam/pdb.h
··· 453 453 #define DSA_PDB_N_MASK 0x7f 454 454 455 455 struct dsa_sign_pdb { 456 - u32 sgf_ln; /* Use DSA_PDB_ defintions per above */ 456 + u32 sgf_ln; /* Use DSA_PDB_ definitions per above */ 457 457 u8 *q; 458 458 u8 *r; 459 459 u8 *g; /* or Gx,y */
+16 -7
drivers/crypto/ccp/sev-dev.c
··· 376 376 struct sev_device *sev = psp_master->sev_data; 377 377 struct sev_user_data_pek_csr input; 378 378 struct sev_data_pek_csr *data; 379 + void __user *input_address; 379 380 void *blob = NULL; 380 381 int ret; 381 382 ··· 395 394 goto cmd; 396 395 397 396 /* allocate a physically contiguous buffer to store the CSR blob */ 397 + input_address = (void __user *)input.address; 398 398 if (input.length > SEV_FW_BLOB_MAX_SIZE) { 399 399 ret = -EFAULT; 400 400 goto e_free; ··· 428 426 } 429 427 430 428 if (blob) { 431 - if (copy_to_user((void __user *)input.address, blob, input.length)) 429 + if (copy_to_user(input_address, blob, input.length)) 432 430 ret = -EFAULT; 433 431 } 434 432 ··· 439 437 return ret; 440 438 } 441 439 442 - void *psp_copy_user_blob(u64 __user uaddr, u32 len) 440 + void *psp_copy_user_blob(u64 uaddr, u32 len) 443 441 { 444 442 if (!uaddr || !len) 445 443 return ERR_PTR(-EINVAL); ··· 448 446 if (len > SEV_FW_BLOB_MAX_SIZE) 449 447 return ERR_PTR(-EINVAL); 450 448 451 - return memdup_user((void __user *)(uintptr_t)uaddr, len); 449 + return memdup_user((void __user *)uaddr, len); 452 450 } 453 451 EXPORT_SYMBOL_GPL(psp_copy_user_blob); 454 452 ··· 623 621 { 624 622 struct sev_user_data_get_id2 input; 625 623 struct sev_data_get_id *data; 624 + void __user *input_address; 626 625 void *id_blob = NULL; 627 626 int ret; 628 627 ··· 633 630 634 631 if (copy_from_user(&input, (void __user *)argp->data, sizeof(input))) 635 632 return -EFAULT; 633 + 634 + input_address = (void __user *)input.address; 636 635 637 636 data = kzalloc(sizeof(*data), GFP_KERNEL); 638 637 if (!data) ··· 665 660 } 666 661 667 662 if (id_blob) { 668 - if (copy_to_user((void __user *)input.address, 669 - id_blob, data->len)) { 663 + if (copy_to_user(input_address, id_blob, data->len)) { 670 664 ret = -EFAULT; 671 665 goto e_free; 672 666 } ··· 724 720 struct sev_user_data_pdh_cert_export input; 725 721 void *pdh_blob = NULL, *cert_blob = NULL; 726 722 struct sev_data_pdh_cert_export *data; 723 + void __user *input_cert_chain_address; 724 + void __user *input_pdh_cert_address; 727 725 int ret; 728 726 729 727 /* If platform is not in INIT state then transition it to INIT. */ ··· 750 744 !input.pdh_cert_len || 751 745 !input.cert_chain_address) 752 746 goto cmd; 747 + 748 + input_pdh_cert_address = (void __user *)input.pdh_cert_address; 749 + input_cert_chain_address = (void __user *)input.cert_chain_address; 753 750 754 751 /* Allocate a physically contiguous buffer to store the PDH blob. */ 755 752 if (input.pdh_cert_len > SEV_FW_BLOB_MAX_SIZE) { ··· 797 788 } 798 789 799 790 if (pdh_blob) { 800 - if (copy_to_user((void __user *)input.pdh_cert_address, 791 + if (copy_to_user(input_pdh_cert_address, 801 792 pdh_blob, input.pdh_cert_len)) { 802 793 ret = -EFAULT; 803 794 goto e_free_cert; ··· 805 796 } 806 797 807 798 if (cert_blob) { 808 - if (copy_to_user((void __user *)input.cert_chain_address, 799 + if (copy_to_user(input_cert_chain_address, 809 800 cert_blob, input.cert_chain_len)) 810 801 ret = -EFAULT; 811 802 }
+4 -4
drivers/crypto/chelsio/chcr_crypto.h
··· 223 223 224 224 struct __aead_ctx { 225 225 struct chcr_gcm_ctx gcm[0]; 226 - struct chcr_authenc_ctx authenc[0]; 226 + struct chcr_authenc_ctx authenc[]; 227 227 }; 228 228 229 229 struct chcr_aead_ctx { ··· 235 235 u8 nonce[4]; 236 236 u16 hmac_ctrl; 237 237 u16 mayverify; 238 - struct __aead_ctx ctx[0]; 238 + struct __aead_ctx ctx[]; 239 239 }; 240 240 241 241 struct hmac_ctx { ··· 247 247 struct __crypto_ctx { 248 248 struct hmac_ctx hmacctx[0]; 249 249 struct ablk_ctx ablkctx[0]; 250 - struct chcr_aead_ctx aeadctx[0]; 250 + struct chcr_aead_ctx aeadctx[]; 251 251 }; 252 252 253 253 struct chcr_context { ··· 257 257 unsigned int ntxq; 258 258 unsigned int nrxq; 259 259 struct completion cbc_aes_aio_done; 260 - struct __crypto_ctx crypto_ctx[0]; 260 + struct __crypto_ctx crypto_ctx[]; 261 261 }; 262 262 263 263 struct chcr_hctx_per_wr {
+2 -1
drivers/crypto/hisilicon/sgl.c
··· 66 66 67 67 sgl_size = sizeof(struct acc_hw_sge) * sge_nr + 68 68 sizeof(struct hisi_acc_hw_sgl); 69 - block_size = PAGE_SIZE * (1 << (MAX_ORDER - 1)); 69 + block_size = 1 << (PAGE_SHIFT + MAX_ORDER <= 32 ? 70 + PAGE_SHIFT + MAX_ORDER - 1 : 31); 70 71 sgl_num_per_block = block_size / sgl_size; 71 72 block_num = count / sgl_num_per_block; 72 73 remain_sgl = count % sgl_num_per_block;
+7 -4
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
··· 118 118 struct otx_cpt_req_info *cpt_req; 119 119 struct pci_dev *pdev; 120 120 121 + if (!cpt_info) 122 + goto complete; 123 + 121 124 cpt_req = cpt_info->req; 122 125 if (!status) { 123 126 /* ··· 132 129 !cpt_req->is_enc) 133 130 status = validate_hmac_cipher_null(cpt_req); 134 131 } 135 - if (cpt_info) { 136 - pdev = cpt_info->pdev; 137 - do_request_cleanup(pdev, cpt_info); 138 - } 132 + pdev = cpt_info->pdev; 133 + do_request_cleanup(pdev, cpt_info); 134 + 135 + complete: 139 136 if (areq) 140 137 areq->complete(areq, status); 141 138 }
+4 -2
drivers/dio/dio.c
··· 135 135 else 136 136 va = ioremap(pa, PAGE_SIZE); 137 137 138 - if (probe_kernel_read(&i, (unsigned char *)va + DIO_IDOFF, 1)) { 138 + if (copy_from_kernel_nofault(&i, 139 + (unsigned char *)va + DIO_IDOFF, 1)) { 139 140 if (scode >= DIOII_SCBASE) 140 141 iounmap(va); 141 142 continue; /* no board present at that select code */ ··· 209 208 else 210 209 va = ioremap(pa, PAGE_SIZE); 211 210 212 - if (probe_kernel_read(&i, (unsigned char *)va + DIO_IDOFF, 1)) { 211 + if (copy_from_kernel_nofault(&i, 212 + (unsigned char *)va + DIO_IDOFF, 1)) { 213 213 if (scode >= DIOII_SCBASE) 214 214 iounmap(va); 215 215 continue; /* no board present at that select code */
+1 -1
drivers/dma/milbeaut-hdmac.c
··· 77 77 struct dma_device ddev; 78 78 struct clk *clk; 79 79 void __iomem *reg_base; 80 - struct milbeaut_hdmac_chan channels[0]; 80 + struct milbeaut_hdmac_chan channels[]; 81 81 }; 82 82 83 83 static struct milbeaut_hdmac_chan *
+1 -1
drivers/dma/milbeaut-xdmac.c
··· 74 74 struct milbeaut_xdmac_device { 75 75 struct dma_device ddev; 76 76 void __iomem *reg_base; 77 - struct milbeaut_xdmac_chan channels[0]; 77 + struct milbeaut_xdmac_chan channels[]; 78 78 }; 79 79 80 80 static struct milbeaut_xdmac_chan *
+1 -1
drivers/dma/moxart-dma.c
··· 127 127 unsigned int dma_cycles; 128 128 struct virt_dma_desc vd; 129 129 uint8_t es; 130 - struct moxart_sg sg[0]; 130 + struct moxart_sg sg[]; 131 131 }; 132 132 133 133 struct moxart_chan {
+1 -1
drivers/dma/tegra20-apb-dma.c
··· 225 225 u32 global_pause_count; 226 226 227 227 /* Last member of the structure */ 228 - struct tegra_dma_channel channels[0]; 228 + struct tegra_dma_channel channels[]; 229 229 }; 230 230 231 231 static inline void tdma_write(struct tegra_dma *tdma, u32 reg, u32 val)
+1 -1
drivers/dma/ti/edma.c
··· 211 211 u32 residue; 212 212 u32 residue_stat; 213 213 214 - struct edma_pset pset[0]; 214 + struct edma_pset pset[]; 215 215 }; 216 216 217 217 struct edma_cc;
+1 -1
drivers/dma/ti/k3-udma.c
··· 170 170 void *metadata; /* pointer to provided metadata buffer (EPIP, PSdata) */ 171 171 172 172 unsigned int hwdesc_count; 173 - struct udma_hwdesc hwdesc[0]; 173 + struct udma_hwdesc hwdesc[]; 174 174 }; 175 175 176 176 enum udma_chan_state {
+1 -1
drivers/dma/timb_dma.c
··· 88 88 struct dma_device dma; 89 89 void __iomem *membase; 90 90 struct tasklet_struct tasklet; 91 - struct timb_dma_chan channels[0]; 91 + struct timb_dma_chan channels[]; 92 92 }; 93 93 94 94 static struct device *chan2dev(struct dma_chan *chan)
+1 -1
drivers/firewire/core-cdev.c
··· 117 117 struct descriptor_resource { 118 118 struct client_resource resource; 119 119 struct fw_descriptor descriptor; 120 - u32 data[0]; 120 + u32 data[]; 121 121 }; 122 122 123 123 struct iso_resource {
+1 -1
drivers/firewire/core-transaction.c
··· 620 620 u32 request_header[4]; 621 621 int ack; 622 622 u32 length; 623 - u32 data[0]; 623 + u32 data[]; 624 624 }; 625 625 626 626 static void free_response_callback(struct fw_packet *packet,
+1 -1
drivers/firewire/core.h
··· 191 191 /* Upper layer specific data. */ 192 192 void *data; 193 193 194 - struct fw_node *ports[0]; 194 + struct fw_node *ports[]; 195 195 }; 196 196 197 197 static inline struct fw_node *fw_node_get(struct fw_node *node)
+1 -1
drivers/firewire/nosy.c
··· 52 52 53 53 struct packet { 54 54 unsigned int length; 55 - char data[0]; 55 + char data[]; 56 56 }; 57 57 58 58 struct packet_buffer {
+1 -1
drivers/firewire/ohci.c
··· 111 111 dma_addr_t buffer_bus; 112 112 size_t buffer_size; 113 113 size_t used; 114 - struct descriptor buffer[0]; 114 + struct descriptor buffer[]; 115 115 }; 116 116 117 117 struct context {
+1 -1
drivers/firmware/dmi-sysfs.c
··· 262 262 u8 header_format; 263 263 u8 type_descriptors_supported_count; 264 264 u8 per_log_type_descriptor_length; 265 - u8 supported_log_type_descriptos[0]; 265 + u8 supported_log_type_descriptos[]; 266 266 } __packed; 267 267 268 268 #define DMI_SYSFS_SEL_FIELD(_field) \
+1 -1
drivers/firmware/google/memconsole-coreboot.c
··· 21 21 struct cbmem_cons { 22 22 u32 size_dont_access_after_boot; 23 23 u32 cursor; 24 - u8 body[0]; 24 + u8 body[]; 25 25 } __packed; 26 26 27 27 #define CURSOR_MASK ((1 << 28) - 1)
+1 -1
drivers/firmware/google/vpd.c
··· 32 32 u32 version; 33 33 u32 ro_size; 34 34 u32 rw_size; 35 - u8 blob[0]; 35 + u8 blob[]; 36 36 }; 37 37 38 38 struct vpd_section {
+1 -1
drivers/firmware/iscsi_ibft.c
··· 104 104 u16 tgt0_off; 105 105 u16 nic1_off; 106 106 u16 tgt1_off; 107 - u16 expansion[0]; 107 + u16 expansion[]; 108 108 } __attribute__((__packed__)); 109 109 110 110 struct ibft_initiator {
+1 -1
drivers/firmware/pcdp.h
··· 103 103 u8 creator_id[4]; 104 104 u32 creator_rev; 105 105 u32 num_uarts; 106 - struct pcdp_uart uart[0]; /* actual size is num_uarts */ 106 + struct pcdp_uart uart[]; /* actual size is num_uarts */ 107 107 /* remainder of table is pcdp_device structures */ 108 108 } __attribute__((packed));
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
··· 696 696 * default power levels, write "r" (reset) to the file to reset them. 697 697 * 698 698 * 699 - * < For Vega20 > 699 + * < For Vega20 and newer ASICs > 700 700 * 701 701 * Reading the file will display: 702 702 * ··· 1668 1668 } 1669 1669 1670 1670 /** 1671 - * DOC: busy_percent 1671 + * DOC: gpu_busy_percent 1672 1672 * 1673 1673 * The amdgpu driver provides a sysfs API for reading how busy the GPU 1674 1674 * is as a percentage. The file gpu_busy_percent is used for this.
+2 -1
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
··· 40 40 #include <drm/drm_file.h> 41 41 #include <drm/drm_drv.h> 42 42 #include <drm/drm_device.h> 43 + #include <drm/drm_ioctl.h> 43 44 #include <kgd_kfd_interface.h> 44 45 #include <linux/swap.h> 45 46 ··· 1077 1076 #if defined(CONFIG_CGROUP_DEVICE) || defined(CONFIG_CGROUP_BPF) 1078 1077 struct drm_device *ddev = kfd->ddev; 1079 1078 1080 - return devcgroup_check_permission(DEVCG_DEV_CHAR, ddev->driver->major, 1079 + return devcgroup_check_permission(DEVCG_DEV_CHAR, DRM_MAJOR, 1081 1080 ddev->render->index, 1082 1081 DEVCG_ACC_WRITE | DEVCG_ACC_READ); 1083 1082 #else
-2
drivers/gpu/drm/amd/display/dc/dsc/Makefile
··· 28 28 endif 29 29 30 30 CFLAGS_$(AMDDALPATH)/dc/dsc/rc_calc.o := $(dsc_ccflags) 31 - CFLAGS_$(AMDDALPATH)/dc/dsc/rc_calc_dpi.o := $(dsc_ccflags) 32 - CFLAGS_$(AMDDALPATH)/dc/dsc/dc_dsc.o := $(dsc_ccflags) 33 31 34 32 DSC = dc_dsc.o rc_calc.o rc_calc_dpi.o 35 33
+2 -16
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c
··· 22 22 * Author: AMD 23 23 */ 24 24 25 + #include <drm/drm_dsc.h> 25 26 #include "dc_hw_types.h" 26 27 #include "dsc.h" 27 28 #include <drm/drm_dp_helper.h> 28 29 #include "dc.h" 30 + #include "rc_calc.h" 29 31 30 32 /* This module's internal functions */ 31 33 ··· 304 302 static inline uint32_t dsc_div_by_10_round_up(uint32_t value) 305 303 { 306 304 return (value + 9) / 10; 307 - } 308 - 309 - static inline uint32_t calc_dsc_bpp_x16(uint32_t stream_bandwidth_kbps, uint32_t pix_clk_100hz, uint32_t bpp_increment_div) 310 - { 311 - uint32_t dsc_target_bpp_x16; 312 - float f_dsc_target_bpp; 313 - float f_stream_bandwidth_100bps = stream_bandwidth_kbps * 10.0f; 314 - uint32_t precision = bpp_increment_div; // bpp_increment_div is actually precision 315 - 316 - f_dsc_target_bpp = f_stream_bandwidth_100bps / pix_clk_100hz; 317 - 318 - // Round down to the nearest precision stop to bring it into DSC spec range 319 - dsc_target_bpp_x16 = (uint32_t)(f_dsc_target_bpp * precision); 320 - dsc_target_bpp_x16 = (dsc_target_bpp_x16 * 16) / precision; 321 - 322 - return dsc_target_bpp_x16; 323 305 } 324 306 325 307 /* Get DSC bandwidth range based on [min_bpp, max_bpp] target bitrate range, and timing's pixel clock
+145 -6
drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c
··· 23 23 * Authors: AMD 24 24 * 25 25 */ 26 + #include <drm/drm_dsc.h> 26 27 27 28 #include "os_types.h" 28 29 #include "rc_calc.h" ··· 41 40 break 42 41 43 42 44 - void get_qp_set(qp_set qps, enum colour_mode cm, enum bits_per_comp bpc, enum max_min max_min, float bpp) 43 + static void get_qp_set(qp_set qps, enum colour_mode cm, enum bits_per_comp bpc, 44 + enum max_min max_min, float bpp) 45 45 { 46 46 int mode = MODE_SELECT(444, 422, 420); 47 47 int sel = table_hash(mode, bpc, max_min); ··· 87 85 memcpy(qps, table[index].qps, sizeof(qp_set)); 88 86 } 89 87 90 - double dsc_roundf(double num) 88 + static double dsc_roundf(double num) 91 89 { 92 90 if (num < 0.0) 93 91 num = num - 0.5; ··· 97 95 return (int)(num); 98 96 } 99 97 100 - double dsc_ceil(double num) 98 + static double dsc_ceil(double num) 101 99 { 102 100 double retval = (int)num; 103 101 ··· 107 105 return (int)retval; 108 106 } 109 107 110 - void get_ofs_set(qp_set ofs, enum colour_mode mode, float bpp) 108 + static void get_ofs_set(qp_set ofs, enum colour_mode mode, float bpp) 111 109 { 112 110 int *p = ofs; 113 111 ··· 162 160 } 163 161 } 164 162 165 - int median3(int a, int b, int c) 163 + static int median3(int a, int b, int c) 166 164 { 167 165 if (a > b) 168 166 swap(a, b); ··· 174 172 return b; 175 173 } 176 174 177 - void calc_rc_params(struct rc_params *rc, enum colour_mode cm, enum bits_per_comp bpc, float bpp, int slice_width, int slice_height, int minor_version) 175 + static void _do_calc_rc_params(struct rc_params *rc, enum colour_mode cm, 176 + enum bits_per_comp bpc, u8 drm_bpp, 177 + bool is_navite_422_or_420, 178 + int slice_width, int slice_height, 179 + int minor_version) 178 180 { 181 + float bpp; 179 182 float bpp_group; 180 183 float initial_xmit_delay_factor; 181 184 int padding_pixels; 182 185 int i; 186 + 187 + bpp = ((float)drm_bpp / 16.0); 188 + /* in native_422 or native_420 modes, the bits_per_pixel is double the 189 + * target bpp (the latter is what calc_rc_params expects) 190 + */ 191 + if (is_navite_422_or_420) 192 + bpp /= 2.0; 183 193 184 194 rc->rc_quant_incr_limit0 = ((bpc == BPC_8) ? 11 : (bpc == BPC_10 ? 15 : 19)) - ((minor_version == 1 && cm == CM_444) ? 1 : 0); 185 195 rc->rc_quant_incr_limit1 = ((bpc == BPC_8) ? 11 : (bpc == BPC_10 ? 15 : 19)) - ((minor_version == 1 && cm == CM_444) ? 1 : 0); ··· 265 251 rc->rc_buf_thresh[13] = 8064; 266 252 } 267 253 254 + static u32 _do_bytes_per_pixel_calc(int slice_width, u8 drm_bpp, 255 + bool is_navite_422_or_420) 256 + { 257 + float bpp; 258 + u32 bytes_per_pixel; 259 + double d_bytes_per_pixel; 260 + 261 + bpp = ((float)drm_bpp / 16.0); 262 + d_bytes_per_pixel = dsc_ceil(bpp * slice_width / 8.0) / slice_width; 263 + // TODO: Make sure the formula for calculating this is precise (ceiling 264 + // vs. floor, and at what point they should be applied) 265 + if (is_navite_422_or_420) 266 + d_bytes_per_pixel /= 2; 267 + 268 + bytes_per_pixel = (u32)dsc_ceil(d_bytes_per_pixel * 0x10000000); 269 + 270 + return bytes_per_pixel; 271 + } 272 + 273 + static u32 _do_calc_dsc_bpp_x16(u32 stream_bandwidth_kbps, u32 pix_clk_100hz, 274 + u32 bpp_increment_div) 275 + { 276 + u32 dsc_target_bpp_x16; 277 + float f_dsc_target_bpp; 278 + float f_stream_bandwidth_100bps; 279 + // bpp_increment_div is actually precision 280 + u32 precision = bpp_increment_div; 281 + 282 + f_stream_bandwidth_100bps = stream_bandwidth_kbps * 10.0f; 283 + f_dsc_target_bpp = f_stream_bandwidth_100bps / pix_clk_100hz; 284 + 285 + // Round down to the nearest precision stop to bring it into DSC spec 286 + // range 287 + dsc_target_bpp_x16 = (u32)(f_dsc_target_bpp * precision); 288 + dsc_target_bpp_x16 = (dsc_target_bpp_x16 * 16) / precision; 289 + 290 + return dsc_target_bpp_x16; 291 + } 292 + 293 + /** 294 + * calc_rc_params - reads the user's cmdline mode 295 + * @rc: DC internal DSC parameters 296 + * @pps: DRM struct with all required DSC values 297 + * 298 + * This function expects a drm_dsc_config data struct with all the required DSC 299 + * values previously filled out by our driver and based on this information it 300 + * computes some of the DSC values. 301 + * 302 + * @note This calculation requires float point operation, most of it executes 303 + * under kernel_fpu_{begin,end}. 304 + */ 305 + void calc_rc_params(struct rc_params *rc, const struct drm_dsc_config *pps) 306 + { 307 + enum colour_mode mode; 308 + enum bits_per_comp bpc; 309 + bool is_navite_422_or_420; 310 + u8 drm_bpp = pps->bits_per_pixel; 311 + int slice_width = pps->slice_width; 312 + int slice_height = pps->slice_height; 313 + 314 + mode = pps->convert_rgb ? CM_RGB : (pps->simple_422 ? CM_444 : 315 + (pps->native_422 ? CM_422 : 316 + pps->native_420 ? CM_420 : CM_444)); 317 + bpc = (pps->bits_per_component == 8) ? BPC_8 : (pps->bits_per_component == 10) 318 + ? BPC_10 : BPC_12; 319 + 320 + is_navite_422_or_420 = pps->native_422 || pps->native_420; 321 + 322 + DC_FP_START(); 323 + _do_calc_rc_params(rc, mode, bpc, drm_bpp, is_navite_422_or_420, 324 + slice_width, slice_height, 325 + pps->dsc_version_minor); 326 + DC_FP_END(); 327 + } 328 + 329 + /** 330 + * calc_dsc_bytes_per_pixel - calculate bytes per pixel 331 + * @pps: DRM struct with all required DSC values 332 + * 333 + * Based on the information inside drm_dsc_config, this function calculates the 334 + * total of bytes per pixel. 335 + * 336 + * @note This calculation requires float point operation, most of it executes 337 + * under kernel_fpu_{begin,end}. 338 + * 339 + * Return: 340 + * Return the number of bytes per pixel 341 + */ 342 + u32 calc_dsc_bytes_per_pixel(const struct drm_dsc_config *pps) 343 + 344 + { 345 + u32 ret; 346 + u8 drm_bpp = pps->bits_per_pixel; 347 + int slice_width = pps->slice_width; 348 + bool is_navite_422_or_420 = pps->native_422 || pps->native_420; 349 + 350 + DC_FP_START(); 351 + ret = _do_bytes_per_pixel_calc(slice_width, drm_bpp, 352 + is_navite_422_or_420); 353 + DC_FP_END(); 354 + return ret; 355 + } 356 + 357 + /** 358 + * calc_dsc_bpp_x16 - retrieve the dsc bits per pixel 359 + * @stream_bandwidth_kbps: 360 + * @pix_clk_100hz: 361 + * @bpp_increment_div: 362 + * 363 + * Calculate the total of bits per pixel for DSC configuration. 364 + * 365 + * @note This calculation requires float point operation, most of it executes 366 + * under kernel_fpu_{begin,end}. 367 + */ 368 + u32 calc_dsc_bpp_x16(u32 stream_bandwidth_kbps, u32 pix_clk_100hz, 369 + u32 bpp_increment_div) 370 + { 371 + u32 dsc_bpp; 372 + 373 + DC_FP_START(); 374 + dsc_bpp = _do_calc_dsc_bpp_x16(stream_bandwidth_kbps, pix_clk_100hz, 375 + bpp_increment_div); 376 + DC_FP_END(); 377 + return dsc_bpp; 378 + }
+4 -1
drivers/gpu/drm/amd/display/dc/dsc/rc_calc.h
··· 77 77 78 78 typedef struct qp_entry qp_table[]; 79 79 80 - void calc_rc_params(struct rc_params *rc, enum colour_mode cm, enum bits_per_comp bpc, float bpp, int slice_width, int slice_height, int minor_version); 80 + void calc_rc_params(struct rc_params *rc, const struct drm_dsc_config *pps); 81 + u32 calc_dsc_bytes_per_pixel(const struct drm_dsc_config *pps); 82 + u32 calc_dsc_bpp_x16(u32 stream_bandwidth_kbps, u32 pix_clk_100hz, 83 + u32 bpp_increment_div); 81 84 82 85 #endif 83 86
+2 -25
drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
··· 27 27 #include "dscc_types.h" 28 28 #include "rc_calc.h" 29 29 30 - double dsc_ceil(double num); 31 - 32 30 static void copy_pps_fields(struct drm_dsc_config *to, const struct drm_dsc_config *from) 33 31 { 34 32 to->line_buf_depth = from->line_buf_depth; ··· 98 100 99 101 int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_parameters *dsc_params) 100 102 { 101 - enum colour_mode mode = pps->convert_rgb ? CM_RGB : 102 - (pps->simple_422 ? CM_444 : 103 - (pps->native_422 ? CM_422 : 104 - pps->native_420 ? CM_420 : CM_444)); 105 - enum bits_per_comp bpc = (pps->bits_per_component == 8) ? BPC_8 : 106 - (pps->bits_per_component == 10) ? BPC_10 : BPC_12; 107 - float bpp = ((float) pps->bits_per_pixel / 16.0); 108 - int slice_width = pps->slice_width; 109 - int slice_height = pps->slice_height; 110 103 int ret; 111 104 struct rc_params rc; 112 105 struct drm_dsc_config dsc_cfg; 113 106 114 - double d_bytes_per_pixel = dsc_ceil(bpp * slice_width / 8.0) / slice_width; 107 + dsc_params->bytes_per_pixel = calc_dsc_bytes_per_pixel(pps); 115 108 116 - // TODO: Make sure the formula for calculating this is precise (ceiling vs. floor, and at what point they should be applied) 117 - if (pps->native_422 || pps->native_420) 118 - d_bytes_per_pixel /= 2; 119 - 120 - dsc_params->bytes_per_pixel = (uint32_t)dsc_ceil(d_bytes_per_pixel * 0x10000000); 121 - 122 - /* in native_422 or native_420 modes, the bits_per_pixel is double the target bpp 123 - * (the latter is what calc_rc_params expects) 124 - */ 125 - if (pps->native_422 || pps->native_420) 126 - bpp /= 2.0; 127 - 128 - calc_rc_params(&rc, mode, bpc, bpp, slice_width, slice_height, pps->dsc_version_minor); 109 + calc_rc_params(&rc, pps); 129 110 dsc_params->pps = *pps; 130 111 dsc_params->pps.initial_scale_value = 8 * rc.rc_model_size / (rc.rc_model_size - rc.initial_fullness_offset); 131 112
+2 -2
drivers/gpu/drm/amd/display/modules/color/color_gamma.c
··· 843 843 pow_buffer_ptr = -1; // reset back to no optimize 844 844 ret = true; 845 845 release: 846 - kfree(coeff); 846 + kvfree(coeff); 847 847 return ret; 848 848 } 849 849 ··· 1777 1777 1778 1778 kfree(rgb_regamma); 1779 1779 rgb_regamma_alloc_fail: 1780 - kvfree(rgb_user); 1780 + kfree(rgb_user); 1781 1781 rgb_user_alloc_fail: 1782 1782 return ret; 1783 1783 }
+1 -1
drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
··· 239 239 240 240 switch (dev_id) { 241 241 case 0x67BA: 242 - case 0x66B1: 242 + case 0x67B1: 243 243 smu_data->power_tune_defaults = &defaults_hawaii_pro; 244 244 break; 245 245 case 0x67B8:
+5 -10
drivers/gpu/drm/drm_encoder_slave.c
··· 61 61 62 62 request_module("%s%s", I2C_MODULE_PREFIX, info->type); 63 63 64 - client = i2c_new_device(adap, info); 65 - if (!client) { 66 - err = -ENOMEM; 67 - goto fail; 68 - } 69 - 70 - if (!client->dev.driver) { 64 + client = i2c_new_client_device(adap, info); 65 + if (!i2c_client_has_driver(client)) { 71 66 err = -ENODEV; 72 67 goto fail_unregister; 73 68 } ··· 79 84 80 85 err = encoder_drv->encoder_init(client, dev, encoder); 81 86 if (err) 82 - goto fail_unregister; 87 + goto fail_module_put; 83 88 84 89 if (info->platform_data) 85 90 encoder->slave_funcs->set_config(&encoder->base, ··· 87 92 88 93 return 0; 89 94 95 + fail_module_put: 96 + module_put(module); 90 97 fail_unregister: 91 98 i2c_unregister_device(client); 92 - module_put(module); 93 - fail: 94 99 return err; 95 100 } 96 101 EXPORT_SYMBOL(drm_i2c_encoder_init);
+7 -5
drivers/gpu/drm/i915/display/intel_ddi.c
··· 2579 2579 2580 2580 static void 2581 2581 tgl_dkl_phy_ddi_vswing_sequence(struct intel_encoder *encoder, int link_clock, 2582 - u32 level) 2582 + u32 level, enum intel_output_type type) 2583 2583 { 2584 2584 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 2585 2585 enum tc_port tc_port = intel_port_to_tc(dev_priv, encoder->port); 2586 2586 const struct tgl_dkl_phy_ddi_buf_trans *ddi_translations; 2587 2587 u32 n_entries, val, ln, dpcnt_mask, dpcnt_val; 2588 2588 2589 - if (encoder->type == INTEL_OUTPUT_HDMI) { 2589 + if (type == INTEL_OUTPUT_HDMI) { 2590 2590 n_entries = ARRAY_SIZE(tgl_dkl_phy_hdmi_ddi_trans); 2591 2591 ddi_translations = tgl_dkl_phy_hdmi_ddi_trans; 2592 2592 } else { ··· 2638 2638 if (intel_phy_is_combo(dev_priv, phy)) 2639 2639 icl_combo_phy_ddi_vswing_sequence(encoder, level, type); 2640 2640 else 2641 - tgl_dkl_phy_ddi_vswing_sequence(encoder, link_clock, level); 2641 + tgl_dkl_phy_ddi_vswing_sequence(encoder, link_clock, level, type); 2642 2642 } 2643 2643 2644 2644 static u32 translate_signal_level(struct intel_dp *intel_dp, int signal_levels) ··· 2987 2987 ln1 = intel_de_read(dev_priv, MG_DP_MODE(1, tc_port)); 2988 2988 } 2989 2989 2990 - ln0 &= ~(MG_DP_MODE_CFG_DP_X1_MODE | MG_DP_MODE_CFG_DP_X1_MODE); 2990 + ln0 &= ~(MG_DP_MODE_CFG_DP_X1_MODE | MG_DP_MODE_CFG_DP_X2_MODE); 2991 2991 ln1 &= ~(MG_DP_MODE_CFG_DP_X1_MODE | MG_DP_MODE_CFG_DP_X2_MODE); 2992 2992 2993 2993 /* DPPATC */ ··· 3472 3472 INTEL_OUTPUT_DP_MST); 3473 3473 enum phy phy = intel_port_to_phy(dev_priv, encoder->port); 3474 3474 3475 - intel_dp_set_infoframes(encoder, false, old_crtc_state, old_conn_state); 3475 + if (!is_mst) 3476 + intel_dp_set_infoframes(encoder, false, 3477 + old_crtc_state, old_conn_state); 3476 3478 3477 3479 /* 3478 3480 * Power down sink before disabling the port, otherwise we end
+8
drivers/gpu/drm/i915/display/intel_dp_mst.c
··· 397 397 */ 398 398 drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port, 399 399 false); 400 + 401 + /* 402 + * BSpec 4287: disable DIP after the transcoder is disabled and before 403 + * the transcoder clock select is set to none. 404 + */ 405 + if (last_mst_stream) 406 + intel_dp_set_infoframes(&intel_dig_port->base, false, 407 + old_crtc_state, NULL); 400 408 /* 401 409 * From TGL spec: "If multi-stream slave transcoder: Configure 402 410 * Transcoder Clock Select to direct no clock to the transcoder"
+3 -1
drivers/gpu/drm/i915/gt/intel_engine_cs.c
··· 646 646 struct measure_breadcrumb { 647 647 struct i915_request rq; 648 648 struct intel_ring ring; 649 - u32 cs[1024]; 649 + u32 cs[2048]; 650 650 }; 651 651 652 652 static int measure_breadcrumb_dw(struct intel_context *ce) ··· 668 668 669 669 frame->ring.vaddr = frame->cs; 670 670 frame->ring.size = sizeof(frame->cs); 671 + frame->ring.wrap = 672 + BITS_PER_TYPE(frame->ring.size) - ilog2(frame->ring.size); 671 673 frame->ring.effective_size = frame->ring.size; 672 674 intel_ring_update_space(&frame->ring); 673 675 frame->rq.ring = &frame->ring;
+45 -7
drivers/gpu/drm/i915/gt/intel_lrc.c
··· 1134 1134 list_move(&rq->sched.link, pl); 1135 1135 set_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags); 1136 1136 1137 + /* Check in case we rollback so far we wrap [size/2] */ 1138 + if (intel_ring_direction(rq->ring, 1139 + intel_ring_wrap(rq->ring, 1140 + rq->tail), 1141 + rq->ring->tail) > 0) 1142 + rq->context->lrc.desc |= CTX_DESC_FORCE_RESTORE; 1143 + 1137 1144 active = rq; 1138 1145 } else { 1139 1146 struct intel_engine_cs *owner = rq->context->engine; ··· 1505 1498 * HW has a tendency to ignore us rewinding the TAIL to the end of 1506 1499 * an earlier request. 1507 1500 */ 1501 + GEM_BUG_ON(ce->lrc_reg_state[CTX_RING_TAIL] != rq->ring->tail); 1502 + prev = rq->ring->tail; 1508 1503 tail = intel_ring_set_tail(rq->ring, rq->tail); 1509 - prev = ce->lrc_reg_state[CTX_RING_TAIL]; 1510 1504 if (unlikely(intel_ring_direction(rq->ring, tail, prev) <= 0)) 1511 1505 desc |= CTX_DESC_FORCE_RESTORE; 1512 1506 ce->lrc_reg_state[CTX_RING_TAIL] = tail; ··· 1903 1895 1904 1896 static bool 1905 1897 need_timeslice(const struct intel_engine_cs *engine, 1906 - const struct i915_request *rq) 1898 + const struct i915_request *rq, 1899 + const struct rb_node *rb) 1907 1900 { 1908 1901 int hint; 1909 1902 ··· 1912 1903 return false; 1913 1904 1914 1905 hint = engine->execlists.queue_priority_hint; 1906 + 1907 + if (rb) { 1908 + const struct virtual_engine *ve = 1909 + rb_entry(rb, typeof(*ve), nodes[engine->id].rb); 1910 + const struct intel_engine_cs *inflight = 1911 + intel_context_inflight(&ve->context); 1912 + 1913 + if (!inflight || inflight == engine) { 1914 + struct i915_request *next; 1915 + 1916 + rcu_read_lock(); 1917 + next = READ_ONCE(ve->request); 1918 + if (next) 1919 + hint = max(hint, rq_prio(next)); 1920 + rcu_read_unlock(); 1921 + } 1922 + } 1923 + 1915 1924 if (!list_is_last(&rq->sched.link, &engine->active.requests)) 1916 1925 hint = max(hint, rq_prio(list_next_entry(rq, sched.link))); 1917 1926 1927 + GEM_BUG_ON(hint >= I915_PRIORITY_UNPREEMPTABLE); 1918 1928 return hint >= effective_prio(rq); 1919 1929 } 1920 1930 ··· 2005 1977 set_timer_ms(&engine->execlists.timer, duration); 2006 1978 } 2007 1979 2008 - static void start_timeslice(struct intel_engine_cs *engine) 1980 + static void start_timeslice(struct intel_engine_cs *engine, int prio) 2009 1981 { 2010 1982 struct intel_engine_execlists *execlists = &engine->execlists; 2011 - const int prio = queue_prio(execlists); 2012 1983 unsigned long duration; 2013 1984 2014 1985 if (!intel_engine_has_timeslices(engine)) ··· 2167 2140 __unwind_incomplete_requests(engine); 2168 2141 2169 2142 last = NULL; 2170 - } else if (need_timeslice(engine, last) && 2143 + } else if (need_timeslice(engine, last, rb) && 2171 2144 timeslice_expired(execlists, last)) { 2172 2145 if (i915_request_completed(last)) { 2173 2146 tasklet_hi_schedule(&execlists->tasklet); ··· 2215 2188 * Even if ELSP[1] is occupied and not worthy 2216 2189 * of timeslices, our queue might be. 2217 2190 */ 2218 - start_timeslice(engine); 2191 + start_timeslice(engine, queue_prio(execlists)); 2219 2192 return; 2220 2193 } 2221 2194 } ··· 2250 2223 2251 2224 if (last && !can_merge_rq(last, rq)) { 2252 2225 spin_unlock(&ve->base.active.lock); 2253 - start_timeslice(engine); 2226 + start_timeslice(engine, rq_prio(rq)); 2254 2227 return; /* leave this for another sibling */ 2255 2228 } 2256 2229 ··· 4766 4739 return 0; 4767 4740 } 4768 4741 4742 + static void assert_request_valid(struct i915_request *rq) 4743 + { 4744 + struct intel_ring *ring __maybe_unused = rq->ring; 4745 + 4746 + /* Can we unwind this request without appearing to go forwards? */ 4747 + GEM_BUG_ON(intel_ring_direction(ring, rq->wa_tail, rq->head) <= 0); 4748 + } 4749 + 4769 4750 /* 4770 4751 * Reserve space for 2 NOOPs at the end of each request to be 4771 4752 * used as a workaround for not being allowed to do lite ··· 4785 4750 *cs++ = MI_ARB_CHECK; 4786 4751 *cs++ = MI_NOOP; 4787 4752 request->wa_tail = intel_ring_offset(request, cs); 4753 + 4754 + /* Check that entire request is less than half the ring */ 4755 + assert_request_valid(request); 4788 4756 4789 4757 return cs; 4790 4758 }
+4
drivers/gpu/drm/i915/gt/intel_ring.c
··· 315 315 GEM_BUG_ON(rq->ring->emit & (CACHELINE_BYTES - 1)); 316 316 return 0; 317 317 } 318 + 319 + #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) 320 + #include "selftest_ring.c" 321 + #endif
+241
drivers/gpu/drm/i915/gt/intel_workarounds.c
··· 179 179 } 180 180 181 181 static void 182 + wa_write_clr(struct i915_wa_list *wal, i915_reg_t reg, u32 clr) 183 + { 184 + wa_write_masked_or(wal, reg, clr, 0); 185 + } 186 + 187 + static void 182 188 wa_masked_en(struct i915_wa_list *wal, i915_reg_t reg, u32 val) 183 189 { 184 190 wa_add(wal, reg, 0, _MASKED_BIT_ENABLE(val), val); ··· 693 687 } 694 688 695 689 static void 690 + gen4_gt_workarounds_init(struct drm_i915_private *i915, 691 + struct i915_wa_list *wal) 692 + { 693 + /* WaDisable_RenderCache_OperationalFlush:gen4,ilk */ 694 + wa_masked_dis(wal, CACHE_MODE_0, RC_OP_FLUSH_ENABLE); 695 + } 696 + 697 + static void 698 + g4x_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal) 699 + { 700 + gen4_gt_workarounds_init(i915, wal); 701 + 702 + /* WaDisableRenderCachePipelinedFlush:g4x,ilk */ 703 + wa_masked_en(wal, CACHE_MODE_0, CM0_PIPELINED_RENDER_FLUSH_DISABLE); 704 + } 705 + 706 + static void 707 + ilk_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal) 708 + { 709 + g4x_gt_workarounds_init(i915, wal); 710 + 711 + wa_masked_en(wal, _3D_CHICKEN2, _3D_CHICKEN2_WM_READ_PIPELINED); 712 + } 713 + 714 + static void 715 + snb_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal) 716 + { 717 + /* WaDisableHiZPlanesWhenMSAAEnabled:snb */ 718 + wa_masked_en(wal, 719 + _3D_CHICKEN, 720 + _3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB); 721 + 722 + /* WaDisable_RenderCache_OperationalFlush:snb */ 723 + wa_masked_dis(wal, CACHE_MODE_0, RC_OP_FLUSH_ENABLE); 724 + 725 + /* 726 + * BSpec recommends 8x4 when MSAA is used, 727 + * however in practice 16x4 seems fastest. 728 + * 729 + * Note that PS/WM thread counts depend on the WIZ hashing 730 + * disable bit, which we don't touch here, but it's good 731 + * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 732 + */ 733 + wa_add(wal, 734 + GEN6_GT_MODE, 0, 735 + _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4), 736 + GEN6_WIZ_HASHING_16x4); 737 + 738 + wa_masked_dis(wal, CACHE_MODE_0, CM0_STC_EVICT_DISABLE_LRA_SNB); 739 + 740 + wa_masked_en(wal, 741 + _3D_CHICKEN3, 742 + /* WaStripsFansDisableFastClipPerformanceFix:snb */ 743 + _3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL | 744 + /* 745 + * Bspec says: 746 + * "This bit must be set if 3DSTATE_CLIP clip mode is set 747 + * to normal and 3DSTATE_SF number of SF output attributes 748 + * is more than 16." 749 + */ 750 + _3D_CHICKEN3_SF_DISABLE_PIPELINED_ATTR_FETCH); 751 + } 752 + 753 + static void 754 + ivb_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal) 755 + { 756 + /* WaDisableEarlyCull:ivb */ 757 + wa_masked_en(wal, _3D_CHICKEN3, _3D_CHICKEN_SF_DISABLE_OBJEND_CULL); 758 + 759 + /* WaDisablePSDDualDispatchEnable:ivb */ 760 + if (IS_IVB_GT1(i915)) 761 + wa_masked_en(wal, 762 + GEN7_HALF_SLICE_CHICKEN1, 763 + GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE); 764 + 765 + /* WaDisable_RenderCache_OperationalFlush:ivb */ 766 + wa_masked_dis(wal, CACHE_MODE_0_GEN7, RC_OP_FLUSH_ENABLE); 767 + 768 + /* Apply the WaDisableRHWOOptimizationForRenderHang:ivb workaround. */ 769 + wa_masked_dis(wal, 770 + GEN7_COMMON_SLICE_CHICKEN1, 771 + GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC); 772 + 773 + /* WaApplyL3ControlAndL3ChickenMode:ivb */ 774 + wa_write(wal, GEN7_L3CNTLREG1, GEN7_WA_FOR_GEN7_L3_CONTROL); 775 + wa_write(wal, GEN7_L3_CHICKEN_MODE_REGISTER, GEN7_WA_L3_CHICKEN_MODE); 776 + 777 + /* WaForceL3Serialization:ivb */ 778 + wa_write_clr(wal, GEN7_L3SQCREG4, L3SQ_URB_READ_CAM_MATCH_DISABLE); 779 + 780 + /* 781 + * WaVSThreadDispatchOverride:ivb,vlv 782 + * 783 + * This actually overrides the dispatch 784 + * mode for all thread types. 785 + */ 786 + wa_write_masked_or(wal, GEN7_FF_THREAD_MODE, 787 + GEN7_FF_SCHED_MASK, 788 + GEN7_FF_TS_SCHED_HW | 789 + GEN7_FF_VS_SCHED_HW | 790 + GEN7_FF_DS_SCHED_HW); 791 + 792 + if (0) { /* causes HiZ corruption on ivb:gt1 */ 793 + /* enable HiZ Raw Stall Optimization */ 794 + wa_masked_dis(wal, CACHE_MODE_0_GEN7, HIZ_RAW_STALL_OPT_DISABLE); 795 + } 796 + 797 + /* WaDisable4x2SubspanOptimization:ivb */ 798 + wa_masked_en(wal, CACHE_MODE_1, PIXEL_SUBSPAN_COLLECT_OPT_DISABLE); 799 + 800 + /* 801 + * BSpec recommends 8x4 when MSAA is used, 802 + * however in practice 16x4 seems fastest. 803 + * 804 + * Note that PS/WM thread counts depend on the WIZ hashing 805 + * disable bit, which we don't touch here, but it's good 806 + * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 807 + */ 808 + wa_add(wal, GEN7_GT_MODE, 0, 809 + _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4), 810 + GEN6_WIZ_HASHING_16x4); 811 + } 812 + 813 + static void 814 + vlv_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal) 815 + { 816 + /* WaDisableEarlyCull:vlv */ 817 + wa_masked_en(wal, _3D_CHICKEN3, _3D_CHICKEN_SF_DISABLE_OBJEND_CULL); 818 + 819 + /* WaPsdDispatchEnable:vlv */ 820 + /* WaDisablePSDDualDispatchEnable:vlv */ 821 + wa_masked_en(wal, 822 + GEN7_HALF_SLICE_CHICKEN1, 823 + GEN7_MAX_PS_THREAD_DEP | 824 + GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE); 825 + 826 + /* WaDisable_RenderCache_OperationalFlush:vlv */ 827 + wa_masked_dis(wal, CACHE_MODE_0_GEN7, RC_OP_FLUSH_ENABLE); 828 + 829 + /* WaForceL3Serialization:vlv */ 830 + wa_write_clr(wal, GEN7_L3SQCREG4, L3SQ_URB_READ_CAM_MATCH_DISABLE); 831 + 832 + /* 833 + * WaVSThreadDispatchOverride:ivb,vlv 834 + * 835 + * This actually overrides the dispatch 836 + * mode for all thread types. 837 + */ 838 + wa_write_masked_or(wal, 839 + GEN7_FF_THREAD_MODE, 840 + GEN7_FF_SCHED_MASK, 841 + GEN7_FF_TS_SCHED_HW | 842 + GEN7_FF_VS_SCHED_HW | 843 + GEN7_FF_DS_SCHED_HW); 844 + 845 + /* 846 + * BSpec says this must be set, even though 847 + * WaDisable4x2SubspanOptimization isn't listed for VLV. 848 + */ 849 + wa_masked_en(wal, CACHE_MODE_1, PIXEL_SUBSPAN_COLLECT_OPT_DISABLE); 850 + 851 + /* 852 + * BSpec recommends 8x4 when MSAA is used, 853 + * however in practice 16x4 seems fastest. 854 + * 855 + * Note that PS/WM thread counts depend on the WIZ hashing 856 + * disable bit, which we don't touch here, but it's good 857 + * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 858 + */ 859 + wa_add(wal, GEN7_GT_MODE, 0, 860 + _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4), 861 + GEN6_WIZ_HASHING_16x4); 862 + 863 + /* 864 + * WaIncreaseL3CreditsForVLVB0:vlv 865 + * This is the hardware default actually. 866 + */ 867 + wa_write(wal, GEN7_L3SQCREG1, VLV_B0_WA_L3SQCREG1_VALUE); 868 + } 869 + 870 + static void 871 + hsw_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal) 872 + { 873 + /* L3 caching of data atomics doesn't work -- disable it. */ 874 + wa_write(wal, HSW_SCRATCH1, HSW_SCRATCH1_L3_DATA_ATOMICS_DISABLE); 875 + 876 + wa_add(wal, 877 + HSW_ROW_CHICKEN3, 0, 878 + _MASKED_BIT_ENABLE(HSW_ROW_CHICKEN3_L3_GLOBAL_ATOMICS_DISABLE), 879 + 0 /* XXX does this reg exist? */); 880 + 881 + /* WaVSRefCountFullforceMissDisable:hsw */ 882 + wa_write_clr(wal, GEN7_FF_THREAD_MODE, GEN7_FF_VS_REF_CNT_FFME); 883 + 884 + wa_masked_dis(wal, 885 + CACHE_MODE_0_GEN7, 886 + /* WaDisable_RenderCache_OperationalFlush:hsw */ 887 + RC_OP_FLUSH_ENABLE | 888 + /* enable HiZ Raw Stall Optimization */ 889 + HIZ_RAW_STALL_OPT_DISABLE); 890 + 891 + /* WaDisable4x2SubspanOptimization:hsw */ 892 + wa_masked_en(wal, CACHE_MODE_1, PIXEL_SUBSPAN_COLLECT_OPT_DISABLE); 893 + 894 + /* 895 + * BSpec recommends 8x4 when MSAA is used, 896 + * however in practice 16x4 seems fastest. 897 + * 898 + * Note that PS/WM thread counts depend on the WIZ hashing 899 + * disable bit, which we don't touch here, but it's good 900 + * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 901 + */ 902 + wa_add(wal, GEN7_GT_MODE, 0, 903 + _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4), 904 + GEN6_WIZ_HASHING_16x4); 905 + 906 + /* WaSampleCChickenBitEnable:hsw */ 907 + wa_masked_en(wal, HALF_SLICE_CHICKEN3, HSW_SAMPLE_C_PERFORMANCE); 908 + } 909 + 910 + static void 696 911 gen9_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal) 697 912 { 698 913 /* WaDisableKillLogic:bxt,skl,kbl */ ··· 1190 963 bxt_gt_workarounds_init(i915, wal); 1191 964 else if (IS_SKYLAKE(i915)) 1192 965 skl_gt_workarounds_init(i915, wal); 966 + else if (IS_HASWELL(i915)) 967 + hsw_gt_workarounds_init(i915, wal); 968 + else if (IS_VALLEYVIEW(i915)) 969 + vlv_gt_workarounds_init(i915, wal); 970 + else if (IS_IVYBRIDGE(i915)) 971 + ivb_gt_workarounds_init(i915, wal); 972 + else if (IS_GEN(i915, 6)) 973 + snb_gt_workarounds_init(i915, wal); 974 + else if (IS_GEN(i915, 5)) 975 + ilk_gt_workarounds_init(i915, wal); 976 + else if (IS_G4X(i915)) 977 + g4x_gt_workarounds_init(i915, wal); 978 + else if (IS_GEN(i915, 4)) 979 + gen4_gt_workarounds_init(i915, wal); 1193 980 else if (INTEL_GEN(i915) <= 8) 1194 981 return; 1195 982 else
+10 -15
drivers/gpu/drm/i915/gt/selftest_hangcheck.c
··· 310 310 1000)); 311 311 } 312 312 313 - static void engine_heartbeat_disable(struct intel_engine_cs *engine, 314 - unsigned long *saved) 313 + static void engine_heartbeat_disable(struct intel_engine_cs *engine) 315 314 { 316 - *saved = engine->props.heartbeat_interval_ms; 317 315 engine->props.heartbeat_interval_ms = 0; 318 316 319 317 intel_engine_pm_get(engine); 320 318 intel_engine_park_heartbeat(engine); 321 319 } 322 320 323 - static void engine_heartbeat_enable(struct intel_engine_cs *engine, 324 - unsigned long saved) 321 + static void engine_heartbeat_enable(struct intel_engine_cs *engine) 325 322 { 326 323 intel_engine_pm_put(engine); 327 324 328 - engine->props.heartbeat_interval_ms = saved; 325 + engine->props.heartbeat_interval_ms = 326 + engine->defaults.heartbeat_interval_ms; 329 327 } 330 328 331 329 static int igt_hang_sanitycheck(void *arg) ··· 471 473 for_each_engine(engine, gt, id) { 472 474 unsigned int reset_count, reset_engine_count, count; 473 475 struct intel_context *ce; 474 - unsigned long heartbeat; 475 476 IGT_TIMEOUT(end_time); 476 477 int err; 477 478 ··· 482 485 reset_engine_count = i915_reset_engine_count(global, engine); 483 486 count = 0; 484 487 485 - engine_heartbeat_disable(engine, &heartbeat); 488 + engine_heartbeat_disable(engine); 486 489 set_bit(I915_RESET_ENGINE + id, &gt->reset.flags); 487 490 do { 488 491 int i; ··· 526 529 } 527 530 } while (time_before(jiffies, end_time)); 528 531 clear_bit(I915_RESET_ENGINE + id, &gt->reset.flags); 529 - engine_heartbeat_enable(engine, heartbeat); 532 + engine_heartbeat_enable(engine); 530 533 531 534 pr_info("%s(%s): %d resets\n", __func__, engine->name, count); 532 535 ··· 561 564 562 565 for_each_engine(engine, gt, id) { 563 566 unsigned int reset_count, reset_engine_count; 564 - unsigned long heartbeat; 565 567 IGT_TIMEOUT(end_time); 566 568 567 569 if (active && !intel_engine_can_store_dword(engine)) ··· 576 580 reset_count = i915_reset_count(global); 577 581 reset_engine_count = i915_reset_engine_count(global, engine); 578 582 579 - engine_heartbeat_disable(engine, &heartbeat); 583 + engine_heartbeat_disable(engine); 580 584 set_bit(I915_RESET_ENGINE + id, &gt->reset.flags); 581 585 do { 582 586 if (active) { ··· 628 632 } 629 633 } while (time_before(jiffies, end_time)); 630 634 clear_bit(I915_RESET_ENGINE + id, &gt->reset.flags); 631 - engine_heartbeat_enable(engine, heartbeat); 635 + engine_heartbeat_enable(engine); 632 636 633 637 if (err) 634 638 break; ··· 785 789 struct active_engine threads[I915_NUM_ENGINES] = {}; 786 790 unsigned long device = i915_reset_count(global); 787 791 unsigned long count = 0, reported; 788 - unsigned long heartbeat; 789 792 IGT_TIMEOUT(end_time); 790 793 791 794 if (flags & TEST_ACTIVE && ··· 827 832 828 833 yield(); /* start all threads before we begin */ 829 834 830 - engine_heartbeat_disable(engine, &heartbeat); 835 + engine_heartbeat_disable(engine); 831 836 set_bit(I915_RESET_ENGINE + id, &gt->reset.flags); 832 837 do { 833 838 struct i915_request *rq = NULL; ··· 901 906 } 902 907 } while (time_before(jiffies, end_time)); 903 908 clear_bit(I915_RESET_ENGINE + id, &gt->reset.flags); 904 - engine_heartbeat_enable(engine, heartbeat); 909 + engine_heartbeat_enable(engine); 905 910 906 911 pr_info("i915_reset_engine(%s:%s): %lu resets\n", 907 912 engine->name, test_name, count);
+140 -45
drivers/gpu/drm/i915/gt/selftest_lrc.c
··· 51 51 return vma; 52 52 } 53 53 54 - static void engine_heartbeat_disable(struct intel_engine_cs *engine, 55 - unsigned long *saved) 54 + static void engine_heartbeat_disable(struct intel_engine_cs *engine) 56 55 { 57 - *saved = engine->props.heartbeat_interval_ms; 58 56 engine->props.heartbeat_interval_ms = 0; 59 57 60 58 intel_engine_pm_get(engine); 61 59 intel_engine_park_heartbeat(engine); 62 60 } 63 61 64 - static void engine_heartbeat_enable(struct intel_engine_cs *engine, 65 - unsigned long saved) 62 + static void engine_heartbeat_enable(struct intel_engine_cs *engine) 66 63 { 67 64 intel_engine_pm_put(engine); 68 65 69 - engine->props.heartbeat_interval_ms = saved; 66 + engine->props.heartbeat_interval_ms = 67 + engine->defaults.heartbeat_interval_ms; 70 68 } 71 69 72 70 static bool is_active(struct i915_request *rq) ··· 222 224 struct intel_context *ce[2] = {}; 223 225 struct i915_request *rq[2]; 224 226 struct igt_live_test t; 225 - unsigned long saved; 226 227 int n; 227 228 228 229 if (prio && !intel_engine_has_preemption(engine)) ··· 234 237 err = -EIO; 235 238 break; 236 239 } 237 - engine_heartbeat_disable(engine, &saved); 240 + engine_heartbeat_disable(engine); 238 241 239 242 for (n = 0; n < ARRAY_SIZE(ce); n++) { 240 243 struct intel_context *tmp; ··· 342 345 intel_context_put(ce[n]); 343 346 } 344 347 345 - engine_heartbeat_enable(engine, saved); 348 + engine_heartbeat_enable(engine); 346 349 if (igt_live_test_end(&t)) 347 350 err = -EIO; 348 351 if (err) ··· 463 466 464 467 for_each_engine(engine, gt, id) { 465 468 struct intel_context *ce; 466 - unsigned long heartbeat; 467 469 struct i915_request *rq; 468 470 469 471 ce = intel_context_create(engine); ··· 471 475 break; 472 476 } 473 477 474 - engine_heartbeat_disable(engine, &heartbeat); 478 + engine_heartbeat_disable(engine); 475 479 476 480 rq = igt_spinner_create_request(&spin, ce, MI_ARB_CHECK); 477 481 if (IS_ERR(rq)) { ··· 531 535 i915_request_put(rq); 532 536 533 537 out: 534 - engine_heartbeat_enable(engine, heartbeat); 538 + engine_heartbeat_enable(engine); 535 539 intel_context_put(ce); 536 540 if (err) 537 541 break; ··· 576 580 577 581 for_each_engine(engine, gt, id) { 578 582 const struct error_phase *p; 579 - unsigned long heartbeat; 580 583 int err = 0; 581 584 582 - engine_heartbeat_disable(engine, &heartbeat); 585 + engine_heartbeat_disable(engine); 583 586 584 587 for (p = phases; p->error[0] != GOOD; p++) { 585 588 struct i915_request *client[ARRAY_SIZE(phases->error)]; ··· 677 682 } 678 683 } 679 684 680 - engine_heartbeat_enable(engine, heartbeat); 685 + engine_heartbeat_enable(engine); 681 686 if (err) { 682 687 intel_gt_set_wedged(gt); 683 688 return err; ··· 823 828 } 824 829 } 825 830 826 - err = release_queue(outer, vma, n, INT_MAX); 831 + err = release_queue(outer, vma, n, I915_PRIORITY_BARRIER); 827 832 if (err) 828 833 goto out; 829 834 ··· 890 895 enum intel_engine_id id; 891 896 892 897 for_each_engine(engine, gt, id) { 893 - unsigned long saved; 894 - 895 898 if (!intel_engine_has_preemption(engine)) 896 899 continue; 897 900 898 901 memset(vaddr, 0, PAGE_SIZE); 899 902 900 - engine_heartbeat_disable(engine, &saved); 903 + engine_heartbeat_disable(engine); 901 904 err = slice_semaphore_queue(engine, vma, count); 902 - engine_heartbeat_enable(engine, saved); 905 + engine_heartbeat_enable(engine); 903 906 if (err) 904 907 goto err_pin; 905 908 ··· 1002 1009 enum { X = 1, Z, Y }; 1003 1010 struct i915_request *rq[3] = {}; 1004 1011 struct intel_context *ce; 1005 - unsigned long heartbeat; 1006 1012 unsigned long timeslice; 1007 1013 int i, err = 0; 1008 1014 u32 *slot; ··· 1020 1028 * Expect execution/evaluation order XZY 1021 1029 */ 1022 1030 1023 - engine_heartbeat_disable(engine, &heartbeat); 1031 + engine_heartbeat_disable(engine); 1024 1032 timeslice = xchg(&engine->props.timeslice_duration_ms, 1); 1025 1033 1026 1034 slot = memset32(engine->status_page.addr + 1000, 0, 4); ··· 1114 1122 wmb(); 1115 1123 1116 1124 engine->props.timeslice_duration_ms = timeslice; 1117 - engine_heartbeat_enable(engine, heartbeat); 1125 + engine_heartbeat_enable(engine); 1118 1126 for (i = 0; i < 3; i++) 1119 1127 i915_request_put(rq[i]); 1120 1128 if (igt_flush_test(gt->i915)) ··· 1194 1202 .priority = I915_USER_PRIORITY(I915_PRIORITY_MAX), 1195 1203 }; 1196 1204 struct i915_request *rq, *nop; 1197 - unsigned long saved; 1198 1205 1199 1206 if (!intel_engine_has_preemption(engine)) 1200 1207 continue; 1201 1208 1202 - engine_heartbeat_disable(engine, &saved); 1209 + engine_heartbeat_disable(engine); 1203 1210 memset(vaddr, 0, PAGE_SIZE); 1204 1211 1205 1212 /* ELSP[0]: semaphore wait */ ··· 1275 1284 err_rq: 1276 1285 i915_request_put(rq); 1277 1286 err_heartbeat: 1278 - engine_heartbeat_enable(engine, saved); 1287 + engine_heartbeat_enable(engine); 1279 1288 if (err) 1280 1289 break; 1281 1290 } ··· 1286 1295 i915_gem_object_unpin_map(obj); 1287 1296 err_obj: 1288 1297 i915_gem_object_put(obj); 1298 + return err; 1299 + } 1300 + 1301 + static int live_timeslice_nopreempt(void *arg) 1302 + { 1303 + struct intel_gt *gt = arg; 1304 + struct intel_engine_cs *engine; 1305 + enum intel_engine_id id; 1306 + struct igt_spinner spin; 1307 + int err = 0; 1308 + 1309 + /* 1310 + * We should not timeslice into a request that is marked with 1311 + * I915_REQUEST_NOPREEMPT. 1312 + */ 1313 + if (!IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION)) 1314 + return 0; 1315 + 1316 + if (igt_spinner_init(&spin, gt)) 1317 + return -ENOMEM; 1318 + 1319 + for_each_engine(engine, gt, id) { 1320 + struct intel_context *ce; 1321 + struct i915_request *rq; 1322 + unsigned long timeslice; 1323 + 1324 + if (!intel_engine_has_preemption(engine)) 1325 + continue; 1326 + 1327 + ce = intel_context_create(engine); 1328 + if (IS_ERR(ce)) { 1329 + err = PTR_ERR(ce); 1330 + break; 1331 + } 1332 + 1333 + engine_heartbeat_disable(engine); 1334 + timeslice = xchg(&engine->props.timeslice_duration_ms, 1); 1335 + 1336 + /* Create an unpreemptible spinner */ 1337 + 1338 + rq = igt_spinner_create_request(&spin, ce, MI_ARB_CHECK); 1339 + intel_context_put(ce); 1340 + if (IS_ERR(rq)) { 1341 + err = PTR_ERR(rq); 1342 + goto out_heartbeat; 1343 + } 1344 + 1345 + i915_request_get(rq); 1346 + i915_request_add(rq); 1347 + 1348 + if (!igt_wait_for_spinner(&spin, rq)) { 1349 + i915_request_put(rq); 1350 + err = -ETIME; 1351 + goto out_spin; 1352 + } 1353 + 1354 + set_bit(I915_FENCE_FLAG_NOPREEMPT, &rq->fence.flags); 1355 + i915_request_put(rq); 1356 + 1357 + /* Followed by a maximum priority barrier (heartbeat) */ 1358 + 1359 + ce = intel_context_create(engine); 1360 + if (IS_ERR(ce)) { 1361 + err = PTR_ERR(rq); 1362 + goto out_spin; 1363 + } 1364 + 1365 + rq = intel_context_create_request(ce); 1366 + intel_context_put(ce); 1367 + if (IS_ERR(rq)) { 1368 + err = PTR_ERR(rq); 1369 + goto out_spin; 1370 + } 1371 + 1372 + rq->sched.attr.priority = I915_PRIORITY_BARRIER; 1373 + i915_request_get(rq); 1374 + i915_request_add(rq); 1375 + 1376 + /* 1377 + * Wait until the barrier is in ELSP, and we know timeslicing 1378 + * will have been activated. 1379 + */ 1380 + if (wait_for_submit(engine, rq, HZ / 2)) { 1381 + i915_request_put(rq); 1382 + err = -ETIME; 1383 + goto out_spin; 1384 + } 1385 + 1386 + /* 1387 + * Since the ELSP[0] request is unpreemptible, it should not 1388 + * allow the maximum priority barrier through. Wait long 1389 + * enough to see if it is timesliced in by mistake. 1390 + */ 1391 + if (i915_request_wait(rq, 0, timeslice_threshold(engine)) >= 0) { 1392 + pr_err("%s: I915_PRIORITY_BARRIER request completed, bypassing no-preempt request\n", 1393 + engine->name); 1394 + err = -EINVAL; 1395 + } 1396 + i915_request_put(rq); 1397 + 1398 + out_spin: 1399 + igt_spinner_end(&spin); 1400 + out_heartbeat: 1401 + xchg(&engine->props.timeslice_duration_ms, timeslice); 1402 + engine_heartbeat_enable(engine); 1403 + if (err) 1404 + break; 1405 + 1406 + if (igt_flush_test(gt->i915)) { 1407 + err = -EIO; 1408 + break; 1409 + } 1410 + } 1411 + 1412 + igt_spinner_fini(&spin); 1289 1413 return err; 1290 1414 } 1291 1415 ··· 4259 4153 { 4260 4154 struct intel_engine_cs *engine; 4261 4155 struct intel_context *ve; 4262 - unsigned long *heartbeat; 4263 4156 struct igt_spinner spin; 4264 4157 struct i915_request *rq; 4265 4158 unsigned int n; ··· 4270 4165 * descendents are not executed while the capture is in progress. 4271 4166 */ 4272 4167 4273 - heartbeat = kmalloc_array(nsibling, sizeof(*heartbeat), GFP_KERNEL); 4274 - if (!heartbeat) 4168 + if (igt_spinner_init(&spin, gt)) 4275 4169 return -ENOMEM; 4276 - 4277 - if (igt_spinner_init(&spin, gt)) { 4278 - err = -ENOMEM; 4279 - goto out_free; 4280 - } 4281 4170 4282 4171 ve = intel_execlists_create_virtual(siblings, nsibling); 4283 4172 if (IS_ERR(ve)) { ··· 4280 4181 } 4281 4182 4282 4183 for (n = 0; n < nsibling; n++) 4283 - engine_heartbeat_disable(siblings[n], &heartbeat[n]); 4184 + engine_heartbeat_disable(siblings[n]); 4284 4185 4285 4186 rq = igt_spinner_create_request(&spin, ve, MI_ARB_CHECK); 4286 4187 if (IS_ERR(rq)) { ··· 4351 4252 i915_request_put(rq); 4352 4253 out_heartbeat: 4353 4254 for (n = 0; n < nsibling; n++) 4354 - engine_heartbeat_enable(siblings[n], heartbeat[n]); 4255 + engine_heartbeat_enable(siblings[n]); 4355 4256 4356 4257 intel_context_put(ve); 4357 4258 out_spin: 4358 4259 igt_spinner_fini(&spin); 4359 - out_free: 4360 - kfree(heartbeat); 4361 4260 return err; 4362 4261 } 4363 4262 ··· 4411 4314 SUBTEST(live_timeslice_preempt), 4412 4315 SUBTEST(live_timeslice_rewind), 4413 4316 SUBTEST(live_timeslice_queue), 4317 + SUBTEST(live_timeslice_nopreempt), 4414 4318 SUBTEST(live_busywait_preempt), 4415 4319 SUBTEST(live_preempt), 4416 4320 SUBTEST(live_late_preempt), ··· 5030 4932 return PTR_ERR(scratch); 5031 4933 5032 4934 for_each_engine(engine, gt, id) { 5033 - unsigned long heartbeat; 5034 - 5035 - engine_heartbeat_disable(engine, &heartbeat); 4935 + engine_heartbeat_disable(engine); 5036 4936 5037 4937 err = __live_lrc_gpr(engine, scratch, false); 5038 4938 if (err) ··· 5041 4945 goto err; 5042 4946 5043 4947 err: 5044 - engine_heartbeat_enable(engine, heartbeat); 4948 + engine_heartbeat_enable(engine); 5045 4949 if (igt_flush_test(gt->i915)) 5046 4950 err = -EIO; 5047 4951 if (err) ··· 5188 5092 */ 5189 5093 5190 5094 for_each_engine(data.engine, gt, id) { 5191 - unsigned long heartbeat; 5192 5095 int i, err = 0; 5193 5096 5194 - engine_heartbeat_disable(data.engine, &heartbeat); 5097 + engine_heartbeat_disable(data.engine); 5195 5098 5196 5099 for (i = 0; i < ARRAY_SIZE(data.ce); i++) { 5197 5100 struct intel_context *tmp; ··· 5223 5128 } 5224 5129 5225 5130 err: 5226 - engine_heartbeat_enable(data.engine, heartbeat); 5131 + engine_heartbeat_enable(data.engine); 5227 5132 for (i = 0; i < ARRAY_SIZE(data.ce); i++) { 5228 5133 if (!data.ce[i]) 5229 5134 break;
+16 -2
drivers/gpu/drm/i915/gt/selftest_mocs.c
··· 18 18 void *vaddr; 19 19 }; 20 20 21 + static struct intel_context *mocs_context_create(struct intel_engine_cs *engine) 22 + { 23 + struct intel_context *ce; 24 + 25 + ce = intel_context_create(engine); 26 + if (IS_ERR(ce)) 27 + return ce; 28 + 29 + /* We build large requests to read the registers from the ring */ 30 + ce->ring = __intel_context_ring_size(SZ_16K); 31 + 32 + return ce; 33 + } 34 + 21 35 static int request_add_sync(struct i915_request *rq, int err) 22 36 { 23 37 i915_request_get(rq); ··· 315 301 for_each_engine(engine, gt, id) { 316 302 struct intel_context *ce; 317 303 318 - ce = intel_context_create(engine); 304 + ce = mocs_context_create(engine); 319 305 if (IS_ERR(ce)) { 320 306 err = PTR_ERR(ce); 321 307 break; ··· 409 395 for_each_engine(engine, gt, id) { 410 396 struct intel_context *ce; 411 397 412 - ce = intel_context_create(engine); 398 + ce = mocs_context_create(engine); 413 399 if (IS_ERR(ce)) { 414 400 err = PTR_ERR(ce); 415 401 break;
+110
drivers/gpu/drm/i915/gt/selftest_ring.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright © 2020 Intel Corporation 4 + */ 5 + 6 + static struct intel_ring *mock_ring(unsigned long sz) 7 + { 8 + struct intel_ring *ring; 9 + 10 + ring = kzalloc(sizeof(*ring) + sz, GFP_KERNEL); 11 + if (!ring) 12 + return NULL; 13 + 14 + kref_init(&ring->ref); 15 + ring->size = sz; 16 + ring->wrap = BITS_PER_TYPE(ring->size) - ilog2(sz); 17 + ring->effective_size = sz; 18 + ring->vaddr = (void *)(ring + 1); 19 + atomic_set(&ring->pin_count, 1); 20 + 21 + intel_ring_update_space(ring); 22 + 23 + return ring; 24 + } 25 + 26 + static void mock_ring_free(struct intel_ring *ring) 27 + { 28 + kfree(ring); 29 + } 30 + 31 + static int check_ring_direction(struct intel_ring *ring, 32 + u32 next, u32 prev, 33 + int expected) 34 + { 35 + int result; 36 + 37 + result = intel_ring_direction(ring, next, prev); 38 + if (result < 0) 39 + result = -1; 40 + else if (result > 0) 41 + result = 1; 42 + 43 + if (result != expected) { 44 + pr_err("intel_ring_direction(%u, %u):%d != %d\n", 45 + next, prev, result, expected); 46 + return -EINVAL; 47 + } 48 + 49 + return 0; 50 + } 51 + 52 + static int check_ring_step(struct intel_ring *ring, u32 x, u32 step) 53 + { 54 + u32 prev = x, next = intel_ring_wrap(ring, x + step); 55 + int err = 0; 56 + 57 + err |= check_ring_direction(ring, next, next, 0); 58 + err |= check_ring_direction(ring, prev, prev, 0); 59 + err |= check_ring_direction(ring, next, prev, 1); 60 + err |= check_ring_direction(ring, prev, next, -1); 61 + 62 + return err; 63 + } 64 + 65 + static int check_ring_offset(struct intel_ring *ring, u32 x, u32 step) 66 + { 67 + int err = 0; 68 + 69 + err |= check_ring_step(ring, x, step); 70 + err |= check_ring_step(ring, intel_ring_wrap(ring, x + 1), step); 71 + err |= check_ring_step(ring, intel_ring_wrap(ring, x - 1), step); 72 + 73 + return err; 74 + } 75 + 76 + static int igt_ring_direction(void *dummy) 77 + { 78 + struct intel_ring *ring; 79 + unsigned int half = 2048; 80 + int step, err = 0; 81 + 82 + ring = mock_ring(2 * half); 83 + if (!ring) 84 + return -ENOMEM; 85 + 86 + GEM_BUG_ON(ring->size != 2 * half); 87 + 88 + /* Precision of wrap detection is limited to ring->size / 2 */ 89 + for (step = 1; step < half; step <<= 1) { 90 + err |= check_ring_offset(ring, 0, step); 91 + err |= check_ring_offset(ring, half, step); 92 + } 93 + err |= check_ring_step(ring, 0, half - 64); 94 + 95 + /* And check unwrapped handling for good measure */ 96 + err |= check_ring_offset(ring, 0, 2 * half + 64); 97 + err |= check_ring_offset(ring, 3 * half, 1); 98 + 99 + mock_ring_free(ring); 100 + return err; 101 + } 102 + 103 + int intel_ring_mock_selftests(void) 104 + { 105 + static const struct i915_subtest tests[] = { 106 + SUBTEST(igt_ring_direction), 107 + }; 108 + 109 + return i915_subtests(tests, NULL); 110 + }
+28 -41
drivers/gpu/drm/i915/gt/selftest_rps.c
··· 20 20 /* Try to isolate the impact of cstates from determing frequency response */ 21 21 #define CPU_LATENCY 0 /* -1 to disable pm_qos, 0 to disable cstates */ 22 22 23 - static unsigned long engine_heartbeat_disable(struct intel_engine_cs *engine) 23 + static void engine_heartbeat_disable(struct intel_engine_cs *engine) 24 24 { 25 - unsigned long old; 26 - 27 - old = fetch_and_zero(&engine->props.heartbeat_interval_ms); 25 + engine->props.heartbeat_interval_ms = 0; 28 26 29 27 intel_engine_pm_get(engine); 30 28 intel_engine_park_heartbeat(engine); 31 - 32 - return old; 33 29 } 34 30 35 - static void engine_heartbeat_enable(struct intel_engine_cs *engine, 36 - unsigned long saved) 31 + static void engine_heartbeat_enable(struct intel_engine_cs *engine) 37 32 { 38 33 intel_engine_pm_put(engine); 39 34 40 - engine->props.heartbeat_interval_ms = saved; 35 + engine->props.heartbeat_interval_ms = 36 + engine->defaults.heartbeat_interval_ms; 41 37 } 42 38 43 39 static void dummy_rps_work(struct work_struct *wrk) ··· 242 246 intel_gt_check_clock_frequency(gt); 243 247 244 248 for_each_engine(engine, gt, id) { 245 - unsigned long saved_heartbeat; 246 249 struct i915_request *rq; 247 250 u32 cycles; 248 251 u64 dt; ··· 249 254 if (!intel_engine_can_store_dword(engine)) 250 255 continue; 251 256 252 - saved_heartbeat = engine_heartbeat_disable(engine); 257 + engine_heartbeat_disable(engine); 253 258 254 259 rq = igt_spinner_create_request(&spin, 255 260 engine->kernel_context, 256 261 MI_NOOP); 257 262 if (IS_ERR(rq)) { 258 - engine_heartbeat_enable(engine, saved_heartbeat); 263 + engine_heartbeat_enable(engine); 259 264 err = PTR_ERR(rq); 260 265 break; 261 266 } ··· 266 271 pr_err("%s: RPS spinner did not start\n", 267 272 engine->name); 268 273 igt_spinner_end(&spin); 269 - engine_heartbeat_enable(engine, saved_heartbeat); 274 + engine_heartbeat_enable(engine); 270 275 intel_gt_set_wedged(engine->gt); 271 276 err = -EIO; 272 277 break; ··· 322 327 intel_uncore_forcewake_put(gt->uncore, FORCEWAKE_ALL); 323 328 324 329 igt_spinner_end(&spin); 325 - engine_heartbeat_enable(engine, saved_heartbeat); 330 + engine_heartbeat_enable(engine); 326 331 327 332 if (err == 0) { 328 333 u64 time = intel_gt_pm_interval_to_ns(gt, cycles); ··· 400 405 401 406 intel_gt_pm_get(gt); 402 407 for_each_engine(engine, gt, id) { 403 - unsigned long saved_heartbeat; 404 408 struct i915_request *rq; 405 409 ktime_t min_dt, max_dt; 406 410 int f, limit; ··· 408 414 if (!intel_engine_can_store_dword(engine)) 409 415 continue; 410 416 411 - saved_heartbeat = engine_heartbeat_disable(engine); 417 + engine_heartbeat_disable(engine); 412 418 413 419 rq = igt_spinner_create_request(&spin, 414 420 engine->kernel_context, ··· 424 430 pr_err("%s: RPS spinner did not start\n", 425 431 engine->name); 426 432 igt_spinner_end(&spin); 427 - engine_heartbeat_enable(engine, saved_heartbeat); 433 + engine_heartbeat_enable(engine); 428 434 intel_gt_set_wedged(engine->gt); 429 435 err = -EIO; 430 436 break; ··· 434 440 pr_err("%s: could not set minimum frequency [%x], only %x!\n", 435 441 engine->name, rps->min_freq, read_cagf(rps)); 436 442 igt_spinner_end(&spin); 437 - engine_heartbeat_enable(engine, saved_heartbeat); 443 + engine_heartbeat_enable(engine); 438 444 show_pstate_limits(rps); 439 445 err = -EINVAL; 440 446 break; ··· 451 457 pr_err("%s: could not restore minimum frequency [%x], only %x!\n", 452 458 engine->name, rps->min_freq, read_cagf(rps)); 453 459 igt_spinner_end(&spin); 454 - engine_heartbeat_enable(engine, saved_heartbeat); 460 + engine_heartbeat_enable(engine); 455 461 show_pstate_limits(rps); 456 462 err = -EINVAL; 457 463 break; ··· 466 472 min_dt = ktime_sub(ktime_get(), min_dt); 467 473 468 474 igt_spinner_end(&spin); 469 - engine_heartbeat_enable(engine, saved_heartbeat); 475 + engine_heartbeat_enable(engine); 470 476 471 477 pr_info("%s: range:[%x:%uMHz, %x:%uMHz] limit:[%x:%uMHz], %x:%x response %lluns:%lluns\n", 472 478 engine->name, ··· 629 635 rps->work.func = dummy_rps_work; 630 636 631 637 for_each_engine(engine, gt, id) { 632 - unsigned long saved_heartbeat; 633 638 struct i915_request *rq; 634 639 struct i915_vma *vma; 635 640 u32 *cancel, *cntr; ··· 637 644 int freq; 638 645 } min, max; 639 646 640 - saved_heartbeat = engine_heartbeat_disable(engine); 647 + engine_heartbeat_disable(engine); 641 648 642 649 vma = create_spin_counter(engine, 643 650 engine->kernel_context->vm, false, 644 651 &cancel, &cntr); 645 652 if (IS_ERR(vma)) { 646 653 err = PTR_ERR(vma); 647 - engine_heartbeat_enable(engine, saved_heartbeat); 654 + engine_heartbeat_enable(engine); 648 655 break; 649 656 } 650 657 ··· 725 732 i915_vma_unpin(vma); 726 733 i915_vma_put(vma); 727 734 728 - engine_heartbeat_enable(engine, saved_heartbeat); 735 + engine_heartbeat_enable(engine); 729 736 if (igt_flush_test(gt->i915)) 730 737 err = -EIO; 731 738 if (err) ··· 771 778 rps->work.func = dummy_rps_work; 772 779 773 780 for_each_engine(engine, gt, id) { 774 - unsigned long saved_heartbeat; 775 781 struct i915_request *rq; 776 782 struct i915_vma *vma; 777 783 u32 *cancel, *cntr; ··· 779 787 int freq; 780 788 } min, max; 781 789 782 - saved_heartbeat = engine_heartbeat_disable(engine); 790 + engine_heartbeat_disable(engine); 783 791 784 792 vma = create_spin_counter(engine, 785 793 engine->kernel_context->vm, true, 786 794 &cancel, &cntr); 787 795 if (IS_ERR(vma)) { 788 796 err = PTR_ERR(vma); 789 - engine_heartbeat_enable(engine, saved_heartbeat); 797 + engine_heartbeat_enable(engine); 790 798 break; 791 799 } 792 800 ··· 866 874 i915_vma_unpin(vma); 867 875 i915_vma_put(vma); 868 876 869 - engine_heartbeat_enable(engine, saved_heartbeat); 877 + engine_heartbeat_enable(engine); 870 878 if (igt_flush_test(gt->i915)) 871 879 err = -EIO; 872 880 if (err) ··· 1058 1066 for_each_engine(engine, gt, id) { 1059 1067 /* Keep the engine busy with a spinner; expect an UP! */ 1060 1068 if (pm_events & GEN6_PM_RP_UP_THRESHOLD) { 1061 - unsigned long saved_heartbeat; 1062 - 1063 1069 intel_gt_pm_wait_for_idle(engine->gt); 1064 1070 GEM_BUG_ON(intel_rps_is_active(rps)); 1065 1071 1066 - saved_heartbeat = engine_heartbeat_disable(engine); 1072 + engine_heartbeat_disable(engine); 1067 1073 1068 1074 err = __rps_up_interrupt(rps, engine, &spin); 1069 1075 1070 - engine_heartbeat_enable(engine, saved_heartbeat); 1076 + engine_heartbeat_enable(engine); 1071 1077 if (err) 1072 1078 goto out; 1073 1079 ··· 1074 1084 1075 1085 /* Keep the engine awake but idle and check for DOWN */ 1076 1086 if (pm_events & GEN6_PM_RP_DOWN_THRESHOLD) { 1077 - unsigned long saved_heartbeat; 1078 - 1079 - saved_heartbeat = engine_heartbeat_disable(engine); 1087 + engine_heartbeat_disable(engine); 1080 1088 intel_rc6_disable(&gt->rc6); 1081 1089 1082 1090 err = __rps_down_interrupt(rps, engine); 1083 1091 1084 1092 intel_rc6_enable(&gt->rc6); 1085 - engine_heartbeat_enable(engine, saved_heartbeat); 1093 + engine_heartbeat_enable(engine); 1086 1094 if (err) 1087 1095 goto out; 1088 1096 } ··· 1156 1168 rps->work.func = dummy_rps_work; 1157 1169 1158 1170 for_each_engine(engine, gt, id) { 1159 - unsigned long saved_heartbeat; 1160 1171 struct i915_request *rq; 1161 1172 struct { 1162 1173 u64 power; ··· 1165 1178 if (!intel_engine_can_store_dword(engine)) 1166 1179 continue; 1167 1180 1168 - saved_heartbeat = engine_heartbeat_disable(engine); 1181 + engine_heartbeat_disable(engine); 1169 1182 1170 1183 rq = igt_spinner_create_request(&spin, 1171 1184 engine->kernel_context, 1172 1185 MI_NOOP); 1173 1186 if (IS_ERR(rq)) { 1174 - engine_heartbeat_enable(engine, saved_heartbeat); 1187 + engine_heartbeat_enable(engine); 1175 1188 err = PTR_ERR(rq); 1176 1189 break; 1177 1190 } ··· 1182 1195 pr_err("%s: RPS spinner did not start\n", 1183 1196 engine->name); 1184 1197 igt_spinner_end(&spin); 1185 - engine_heartbeat_enable(engine, saved_heartbeat); 1198 + engine_heartbeat_enable(engine); 1186 1199 intel_gt_set_wedged(engine->gt); 1187 1200 err = -EIO; 1188 1201 break; ··· 1195 1208 min.power = measure_power_at(rps, &min.freq); 1196 1209 1197 1210 igt_spinner_end(&spin); 1198 - engine_heartbeat_enable(engine, saved_heartbeat); 1211 + engine_heartbeat_enable(engine); 1199 1212 1200 1213 pr_info("%s: min:%llumW @ %uMHz, max:%llumW @ %uMHz\n", 1201 1214 engine->name,
+6 -9
drivers/gpu/drm/i915/gt/selftest_timeline.c
··· 751 751 return err; 752 752 } 753 753 754 - static void engine_heartbeat_disable(struct intel_engine_cs *engine, 755 - unsigned long *saved) 754 + static void engine_heartbeat_disable(struct intel_engine_cs *engine) 756 755 { 757 - *saved = engine->props.heartbeat_interval_ms; 758 756 engine->props.heartbeat_interval_ms = 0; 759 757 760 758 intel_engine_pm_get(engine); 761 759 intel_engine_park_heartbeat(engine); 762 760 } 763 761 764 - static void engine_heartbeat_enable(struct intel_engine_cs *engine, 765 - unsigned long saved) 762 + static void engine_heartbeat_enable(struct intel_engine_cs *engine) 766 763 { 767 764 intel_engine_pm_put(engine); 768 765 769 - engine->props.heartbeat_interval_ms = saved; 766 + engine->props.heartbeat_interval_ms = 767 + engine->defaults.heartbeat_interval_ms; 770 768 } 771 769 772 770 static int live_hwsp_rollover_kernel(void *arg) ··· 783 785 struct intel_context *ce = engine->kernel_context; 784 786 struct intel_timeline *tl = ce->timeline; 785 787 struct i915_request *rq[3] = {}; 786 - unsigned long heartbeat; 787 788 int i; 788 789 789 - engine_heartbeat_disable(engine, &heartbeat); 790 + engine_heartbeat_disable(engine); 790 791 if (intel_gt_wait_for_idle(gt, HZ / 2)) { 791 792 err = -EIO; 792 793 goto out; ··· 836 839 out: 837 840 for (i = 0; i < ARRAY_SIZE(rq); i++) 838 841 i915_request_put(rq[i]); 839 - engine_heartbeat_enable(engine, heartbeat); 842 + engine_heartbeat_enable(engine); 840 843 if (err) 841 844 break; 842 845 }
+2
drivers/gpu/drm/i915/gt/selftest_workarounds.c
··· 623 623 err = -EINVAL; 624 624 goto out_unpin; 625 625 } 626 + } else { 627 + rsvd = 0; 626 628 } 627 629 628 630 expect = results[0];
+1
drivers/gpu/drm/i915/i915_irq.c
··· 3125 3125 3126 3126 val = I915_READ(GEN11_DE_HPD_IMR); 3127 3127 val &= ~hotplug_irqs; 3128 + val |= ~enabled_irqs & hotplug_irqs; 3128 3129 I915_WRITE(GEN11_DE_HPD_IMR, val); 3129 3130 POSTING_READ(GEN11_DE_HPD_IMR); 3130 3131
+42 -42
drivers/gpu/drm/i915/i915_pmu.c
··· 269 269 return IS_GEN(i915, 7); 270 270 } 271 271 272 + static void engine_sample(struct intel_engine_cs *engine, unsigned int period_ns) 273 + { 274 + struct intel_engine_pmu *pmu = &engine->pmu; 275 + bool busy; 276 + u32 val; 277 + 278 + val = ENGINE_READ_FW(engine, RING_CTL); 279 + if (val == 0) /* powerwell off => engine idle */ 280 + return; 281 + 282 + if (val & RING_WAIT) 283 + add_sample(&pmu->sample[I915_SAMPLE_WAIT], period_ns); 284 + if (val & RING_WAIT_SEMAPHORE) 285 + add_sample(&pmu->sample[I915_SAMPLE_SEMA], period_ns); 286 + 287 + /* No need to sample when busy stats are supported. */ 288 + if (intel_engine_supports_stats(engine)) 289 + return; 290 + 291 + /* 292 + * While waiting on a semaphore or event, MI_MODE reports the 293 + * ring as idle. However, previously using the seqno, and with 294 + * execlists sampling, we account for the ring waiting as the 295 + * engine being busy. Therefore, we record the sample as being 296 + * busy if either waiting or !idle. 297 + */ 298 + busy = val & (RING_WAIT_SEMAPHORE | RING_WAIT); 299 + if (!busy) { 300 + val = ENGINE_READ_FW(engine, RING_MI_MODE); 301 + busy = !(val & MODE_IDLE); 302 + } 303 + if (busy) 304 + add_sample(&pmu->sample[I915_SAMPLE_BUSY], period_ns); 305 + } 306 + 272 307 static void 273 308 engines_sample(struct intel_gt *gt, unsigned int period_ns) 274 309 { 275 310 struct drm_i915_private *i915 = gt->i915; 276 311 struct intel_engine_cs *engine; 277 312 enum intel_engine_id id; 313 + unsigned long flags; 278 314 279 315 if ((i915->pmu.enable & ENGINE_SAMPLE_MASK) == 0) 280 316 return; ··· 319 283 return; 320 284 321 285 for_each_engine(engine, gt, id) { 322 - struct intel_engine_pmu *pmu = &engine->pmu; 323 - spinlock_t *mmio_lock; 324 - unsigned long flags; 325 - bool busy; 326 - u32 val; 327 - 328 286 if (!intel_engine_pm_get_if_awake(engine)) 329 287 continue; 330 288 331 - mmio_lock = NULL; 332 - if (exclusive_mmio_access(i915)) 333 - mmio_lock = &engine->uncore->lock; 334 - 335 - if (unlikely(mmio_lock)) 336 - spin_lock_irqsave(mmio_lock, flags); 337 - 338 - val = ENGINE_READ_FW(engine, RING_CTL); 339 - if (val == 0) /* powerwell off => engine idle */ 340 - goto skip; 341 - 342 - if (val & RING_WAIT) 343 - add_sample(&pmu->sample[I915_SAMPLE_WAIT], period_ns); 344 - if (val & RING_WAIT_SEMAPHORE) 345 - add_sample(&pmu->sample[I915_SAMPLE_SEMA], period_ns); 346 - 347 - /* No need to sample when busy stats are supported. */ 348 - if (intel_engine_supports_stats(engine)) 349 - goto skip; 350 - 351 - /* 352 - * While waiting on a semaphore or event, MI_MODE reports the 353 - * ring as idle. However, previously using the seqno, and with 354 - * execlists sampling, we account for the ring waiting as the 355 - * engine being busy. Therefore, we record the sample as being 356 - * busy if either waiting or !idle. 357 - */ 358 - busy = val & (RING_WAIT_SEMAPHORE | RING_WAIT); 359 - if (!busy) { 360 - val = ENGINE_READ_FW(engine, RING_MI_MODE); 361 - busy = !(val & MODE_IDLE); 289 + if (exclusive_mmio_access(i915)) { 290 + spin_lock_irqsave(&engine->uncore->lock, flags); 291 + engine_sample(engine, period_ns); 292 + spin_unlock_irqrestore(&engine->uncore->lock, flags); 293 + } else { 294 + engine_sample(engine, period_ns); 362 295 } 363 - if (busy) 364 - add_sample(&pmu->sample[I915_SAMPLE_BUSY], period_ns); 365 296 366 - skip: 367 - if (unlikely(mmio_lock)) 368 - spin_unlock_irqrestore(mmio_lock, flags); 369 297 intel_engine_pm_put_async(engine); 370 298 } 371 299 }
+1 -1
drivers/gpu/drm/i915/i915_priolist_types.h
··· 42 42 * active request. 43 43 */ 44 44 #define I915_PRIORITY_UNPREEMPTABLE INT_MAX 45 - #define I915_PRIORITY_BARRIER INT_MAX 45 + #define I915_PRIORITY_BARRIER (I915_PRIORITY_UNPREEMPTABLE - 1) 46 46 47 47 struct i915_priolist { 48 48 struct list_head requests[I915_PRIORITY_COUNT];
+1 -1
drivers/gpu/drm/i915/i915_reg.h
··· 7896 7896 7897 7897 /* GEN7 chicken */ 7898 7898 #define GEN7_COMMON_SLICE_CHICKEN1 _MMIO(0x7010) 7899 - #define GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC ((1 << 10) | (1 << 26)) 7899 + #define GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC (1 << 10) 7900 7900 #define GEN9_RHWO_OPTIMIZATION_DISABLE (1 << 14) 7901 7901 7902 7902 #define COMMON_SLICE_CHICKEN2 _MMIO(0x7014)
+2 -204
drivers/gpu/drm/i915/intel_pm.c
··· 6830 6830 I915_WRITE(ILK_DISPLAY_CHICKEN2, 6831 6831 I915_READ(ILK_DISPLAY_CHICKEN2) | 6832 6832 ILK_ELPIN_409_SELECT); 6833 - I915_WRITE(_3D_CHICKEN2, 6834 - _3D_CHICKEN2_WM_READ_PIPELINED << 16 | 6835 - _3D_CHICKEN2_WM_READ_PIPELINED); 6836 - 6837 - /* WaDisableRenderCachePipelinedFlush:ilk */ 6838 - I915_WRITE(CACHE_MODE_0, 6839 - _MASKED_BIT_ENABLE(CM0_PIPELINED_RENDER_FLUSH_DISABLE)); 6840 - 6841 - /* WaDisable_RenderCache_OperationalFlush:ilk */ 6842 - I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE)); 6843 6833 6844 6834 g4x_disable_trickle_feed(dev_priv); 6845 6835 ··· 6892 6902 I915_READ(ILK_DISPLAY_CHICKEN2) | 6893 6903 ILK_ELPIN_409_SELECT); 6894 6904 6895 - /* WaDisableHiZPlanesWhenMSAAEnabled:snb */ 6896 - I915_WRITE(_3D_CHICKEN, 6897 - _MASKED_BIT_ENABLE(_3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB)); 6898 - 6899 - /* WaDisable_RenderCache_OperationalFlush:snb */ 6900 - I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE)); 6901 - 6902 - /* 6903 - * BSpec recoomends 8x4 when MSAA is used, 6904 - * however in practice 16x4 seems fastest. 6905 - * 6906 - * Note that PS/WM thread counts depend on the WIZ hashing 6907 - * disable bit, which we don't touch here, but it's good 6908 - * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 6909 - */ 6910 - I915_WRITE(GEN6_GT_MODE, 6911 - _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4)); 6912 - 6913 - I915_WRITE(CACHE_MODE_0, 6914 - _MASKED_BIT_DISABLE(CM0_STC_EVICT_DISABLE_LRA_SNB)); 6915 - 6916 6905 I915_WRITE(GEN6_UCGCTL1, 6917 6906 I915_READ(GEN6_UCGCTL1) | 6918 6907 GEN6_BLBUNIT_CLOCK_GATE_DISABLE | ··· 6913 6944 I915_WRITE(GEN6_UCGCTL2, 6914 6945 GEN6_RCPBUNIT_CLOCK_GATE_DISABLE | 6915 6946 GEN6_RCCUNIT_CLOCK_GATE_DISABLE); 6916 - 6917 - /* WaStripsFansDisableFastClipPerformanceFix:snb */ 6918 - I915_WRITE(_3D_CHICKEN3, 6919 - _MASKED_BIT_ENABLE(_3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL)); 6920 - 6921 - /* 6922 - * Bspec says: 6923 - * "This bit must be set if 3DSTATE_CLIP clip mode is set to normal and 6924 - * 3DSTATE_SF number of SF output attributes is more than 16." 6925 - */ 6926 - I915_WRITE(_3D_CHICKEN3, 6927 - _MASKED_BIT_ENABLE(_3D_CHICKEN3_SF_DISABLE_PIPELINED_ATTR_FETCH)); 6928 6947 6929 6948 /* 6930 6949 * According to the spec the following bits should be ··· 6941 6984 cpt_init_clock_gating(dev_priv); 6942 6985 6943 6986 gen6_check_mch_setup(dev_priv); 6944 - } 6945 - 6946 - static void gen7_setup_fixed_func_scheduler(struct drm_i915_private *dev_priv) 6947 - { 6948 - u32 reg = I915_READ(GEN7_FF_THREAD_MODE); 6949 - 6950 - /* 6951 - * WaVSThreadDispatchOverride:ivb,vlv 6952 - * 6953 - * This actually overrides the dispatch 6954 - * mode for all thread types. 6955 - */ 6956 - reg &= ~GEN7_FF_SCHED_MASK; 6957 - reg |= GEN7_FF_TS_SCHED_HW; 6958 - reg |= GEN7_FF_VS_SCHED_HW; 6959 - reg |= GEN7_FF_DS_SCHED_HW; 6960 - 6961 - I915_WRITE(GEN7_FF_THREAD_MODE, reg); 6962 6987 } 6963 6988 6964 6989 static void lpt_init_clock_gating(struct drm_i915_private *dev_priv) ··· 7169 7230 7170 7231 static void hsw_init_clock_gating(struct drm_i915_private *dev_priv) 7171 7232 { 7172 - /* L3 caching of data atomics doesn't work -- disable it. */ 7173 - I915_WRITE(HSW_SCRATCH1, HSW_SCRATCH1_L3_DATA_ATOMICS_DISABLE); 7174 - I915_WRITE(HSW_ROW_CHICKEN3, 7175 - _MASKED_BIT_ENABLE(HSW_ROW_CHICKEN3_L3_GLOBAL_ATOMICS_DISABLE)); 7176 - 7177 7233 /* This is required by WaCatErrorRejectionIssue:hsw */ 7178 7234 I915_WRITE(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG, 7179 - I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) | 7180 - GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB); 7181 - 7182 - /* WaVSRefCountFullforceMissDisable:hsw */ 7183 - I915_WRITE(GEN7_FF_THREAD_MODE, 7184 - I915_READ(GEN7_FF_THREAD_MODE) & ~GEN7_FF_VS_REF_CNT_FFME); 7185 - 7186 - /* WaDisable_RenderCache_OperationalFlush:hsw */ 7187 - I915_WRITE(CACHE_MODE_0_GEN7, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE)); 7188 - 7189 - /* enable HiZ Raw Stall Optimization */ 7190 - I915_WRITE(CACHE_MODE_0_GEN7, 7191 - _MASKED_BIT_DISABLE(HIZ_RAW_STALL_OPT_DISABLE)); 7192 - 7193 - /* WaDisable4x2SubspanOptimization:hsw */ 7194 - I915_WRITE(CACHE_MODE_1, 7195 - _MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE)); 7196 - 7197 - /* 7198 - * BSpec recommends 8x4 when MSAA is used, 7199 - * however in practice 16x4 seems fastest. 7200 - * 7201 - * Note that PS/WM thread counts depend on the WIZ hashing 7202 - * disable bit, which we don't touch here, but it's good 7203 - * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 7204 - */ 7205 - I915_WRITE(GEN7_GT_MODE, 7206 - _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4)); 7207 - 7208 - /* WaSampleCChickenBitEnable:hsw */ 7209 - I915_WRITE(HALF_SLICE_CHICKEN3, 7210 - _MASKED_BIT_ENABLE(HSW_SAMPLE_C_PERFORMANCE)); 7235 + I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) | 7236 + GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB); 7211 7237 7212 7238 /* WaSwitchSolVfFArbitrationPriority:hsw */ 7213 7239 I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | HSW_ECOCHK_ARB_PRIO_SOL); ··· 7186 7282 7187 7283 I915_WRITE(ILK_DSPCLK_GATE_D, ILK_VRHUNIT_CLOCK_GATE_DISABLE); 7188 7284 7189 - /* WaDisableEarlyCull:ivb */ 7190 - I915_WRITE(_3D_CHICKEN3, 7191 - _MASKED_BIT_ENABLE(_3D_CHICKEN_SF_DISABLE_OBJEND_CULL)); 7192 - 7193 7285 /* WaDisableBackToBackFlipFix:ivb */ 7194 7286 I915_WRITE(IVB_CHICKEN3, 7195 7287 CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE | 7196 7288 CHICKEN3_DGMG_DONE_FIX_DISABLE); 7197 7289 7198 - /* WaDisablePSDDualDispatchEnable:ivb */ 7199 - if (IS_IVB_GT1(dev_priv)) 7200 - I915_WRITE(GEN7_HALF_SLICE_CHICKEN1, 7201 - _MASKED_BIT_ENABLE(GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE)); 7202 - 7203 - /* WaDisable_RenderCache_OperationalFlush:ivb */ 7204 - I915_WRITE(CACHE_MODE_0_GEN7, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE)); 7205 - 7206 - /* Apply the WaDisableRHWOOptimizationForRenderHang:ivb workaround. */ 7207 - I915_WRITE(GEN7_COMMON_SLICE_CHICKEN1, 7208 - GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC); 7209 - 7210 - /* WaApplyL3ControlAndL3ChickenMode:ivb */ 7211 - I915_WRITE(GEN7_L3CNTLREG1, 7212 - GEN7_WA_FOR_GEN7_L3_CONTROL); 7213 - I915_WRITE(GEN7_L3_CHICKEN_MODE_REGISTER, 7214 - GEN7_WA_L3_CHICKEN_MODE); 7215 7290 if (IS_IVB_GT1(dev_priv)) 7216 7291 I915_WRITE(GEN7_ROW_CHICKEN2, 7217 7292 _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE)); ··· 7201 7318 I915_WRITE(GEN7_ROW_CHICKEN2_GT2, 7202 7319 _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE)); 7203 7320 } 7204 - 7205 - /* WaForceL3Serialization:ivb */ 7206 - I915_WRITE(GEN7_L3SQCREG4, I915_READ(GEN7_L3SQCREG4) & 7207 - ~L3SQ_URB_READ_CAM_MATCH_DISABLE); 7208 7321 7209 7322 /* 7210 7323 * According to the spec, bit 13 (RCZUNIT) must be set on IVB. ··· 7216 7337 7217 7338 g4x_disable_trickle_feed(dev_priv); 7218 7339 7219 - gen7_setup_fixed_func_scheduler(dev_priv); 7220 - 7221 - if (0) { /* causes HiZ corruption on ivb:gt1 */ 7222 - /* enable HiZ Raw Stall Optimization */ 7223 - I915_WRITE(CACHE_MODE_0_GEN7, 7224 - _MASKED_BIT_DISABLE(HIZ_RAW_STALL_OPT_DISABLE)); 7225 - } 7226 - 7227 - /* WaDisable4x2SubspanOptimization:ivb */ 7228 - I915_WRITE(CACHE_MODE_1, 7229 - _MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE)); 7230 - 7231 - /* 7232 - * BSpec recommends 8x4 when MSAA is used, 7233 - * however in practice 16x4 seems fastest. 7234 - * 7235 - * Note that PS/WM thread counts depend on the WIZ hashing 7236 - * disable bit, which we don't touch here, but it's good 7237 - * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 7238 - */ 7239 - I915_WRITE(GEN7_GT_MODE, 7240 - _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4)); 7241 - 7242 7340 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); 7243 7341 snpcr &= ~GEN6_MBC_SNPCR_MASK; 7244 7342 snpcr |= GEN6_MBC_SNPCR_MED; ··· 7229 7373 7230 7374 static void vlv_init_clock_gating(struct drm_i915_private *dev_priv) 7231 7375 { 7232 - /* WaDisableEarlyCull:vlv */ 7233 - I915_WRITE(_3D_CHICKEN3, 7234 - _MASKED_BIT_ENABLE(_3D_CHICKEN_SF_DISABLE_OBJEND_CULL)); 7235 - 7236 7376 /* WaDisableBackToBackFlipFix:vlv */ 7237 7377 I915_WRITE(IVB_CHICKEN3, 7238 7378 CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE | 7239 7379 CHICKEN3_DGMG_DONE_FIX_DISABLE); 7240 - 7241 - /* WaPsdDispatchEnable:vlv */ 7242 - /* WaDisablePSDDualDispatchEnable:vlv */ 7243 - I915_WRITE(GEN7_HALF_SLICE_CHICKEN1, 7244 - _MASKED_BIT_ENABLE(GEN7_MAX_PS_THREAD_DEP | 7245 - GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE)); 7246 - 7247 - /* WaDisable_RenderCache_OperationalFlush:vlv */ 7248 - I915_WRITE(CACHE_MODE_0_GEN7, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE)); 7249 - 7250 - /* WaForceL3Serialization:vlv */ 7251 - I915_WRITE(GEN7_L3SQCREG4, I915_READ(GEN7_L3SQCREG4) & 7252 - ~L3SQ_URB_READ_CAM_MATCH_DISABLE); 7253 7380 7254 7381 /* WaDisableDopClockGating:vlv */ 7255 7382 I915_WRITE(GEN7_ROW_CHICKEN2, ··· 7242 7403 I915_WRITE(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG, 7243 7404 I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) | 7244 7405 GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB); 7245 - 7246 - gen7_setup_fixed_func_scheduler(dev_priv); 7247 7406 7248 7407 /* 7249 7408 * According to the spec, bit 13 (RCZUNIT) must be set on IVB. ··· 7255 7418 * Set bit 25, to disable L3_BANK_2x_CLK_GATING */ 7256 7419 I915_WRITE(GEN7_UCGCTL4, 7257 7420 I915_READ(GEN7_UCGCTL4) | GEN7_L3BANK2X_CLOCK_GATE_DISABLE); 7258 - 7259 - /* 7260 - * BSpec says this must be set, even though 7261 - * WaDisable4x2SubspanOptimization isn't listed for VLV. 7262 - */ 7263 - I915_WRITE(CACHE_MODE_1, 7264 - _MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE)); 7265 - 7266 - /* 7267 - * BSpec recommends 8x4 when MSAA is used, 7268 - * however in practice 16x4 seems fastest. 7269 - * 7270 - * Note that PS/WM thread counts depend on the WIZ hashing 7271 - * disable bit, which we don't touch here, but it's good 7272 - * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). 7273 - */ 7274 - I915_WRITE(GEN7_GT_MODE, 7275 - _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4)); 7276 - 7277 - /* 7278 - * WaIncreaseL3CreditsForVLVB0:vlv 7279 - * This is the hardware default actually. 7280 - */ 7281 - I915_WRITE(GEN7_L3SQCREG1, VLV_B0_WA_L3SQCREG1_VALUE); 7282 7421 7283 7422 /* 7284 7423 * WaDisableVLVClockGating_VBIIssue:vlv ··· 7308 7495 dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE; 7309 7496 I915_WRITE(DSPCLK_GATE_D, dspclk_gate); 7310 7497 7311 - /* WaDisableRenderCachePipelinedFlush */ 7312 - I915_WRITE(CACHE_MODE_0, 7313 - _MASKED_BIT_ENABLE(CM0_PIPELINED_RENDER_FLUSH_DISABLE)); 7314 - 7315 - /* WaDisable_RenderCache_OperationalFlush:g4x */ 7316 - I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE)); 7317 - 7318 7498 g4x_disable_trickle_feed(dev_priv); 7319 7499 } 7320 7500 ··· 7323 7517 intel_uncore_write(uncore, 7324 7518 MI_ARB_STATE, 7325 7519 _MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE)); 7326 - 7327 - /* WaDisable_RenderCache_OperationalFlush:gen4 */ 7328 - intel_uncore_write(uncore, 7329 - CACHE_MODE_0, 7330 - _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE)); 7331 7520 } 7332 7521 7333 7522 static void i965g_init_clock_gating(struct drm_i915_private *dev_priv) ··· 7335 7534 I915_WRITE(RENCLK_GATE_D2, 0); 7336 7535 I915_WRITE(MI_ARB_STATE, 7337 7536 _MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE)); 7338 - 7339 - /* WaDisable_RenderCache_OperationalFlush:gen4 */ 7340 - I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE)); 7341 7537 } 7342 7538 7343 7539 static void gen3_init_clock_gating(struct drm_i915_private *dev_priv)
+1
drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
··· 21 21 selftest(scatterlist, scatterlist_mock_selftests) 22 22 selftest(syncmap, i915_syncmap_mock_selftests) 23 23 selftest(uncore, intel_uncore_mock_selftests) 24 + selftest(ring, intel_ring_mock_selftests) 24 25 selftest(engine, intel_engine_cs_mock_selftests) 25 26 selftest(timelines, intel_timeline_mock_selftests) 26 27 selftest(requests, i915_request_mock_selftests)
+1 -1
drivers/hwtracing/stm/policy.c
··· 34 34 unsigned int first_channel; 35 35 unsigned int last_channel; 36 36 /* this is the one that's exposed to the attributes */ 37 - unsigned char priv[0]; 37 + unsigned char priv[]; 38 38 }; 39 39 40 40 void *stp_policy_node_priv(struct stp_policy_node *pn)
+2 -2
drivers/hwtracing/stm/stm.h
··· 23 23 24 24 struct stp_master { 25 25 unsigned int nr_free; 26 - unsigned long chan_map[0]; 26 + unsigned long chan_map[]; 27 27 }; 28 28 29 29 struct stm_device { ··· 42 42 const struct config_item_type *pdrv_node_type; 43 43 /* master allocation */ 44 44 spinlock_t mc_lock; 45 - struct stp_master *masters[0]; 45 + struct stp_master *masters[]; 46 46 }; 47 47 48 48 #define to_stm_device(_d) \
-25
drivers/i2c/i2c-core-base.c
··· 816 816 EXPORT_SYMBOL_GPL(i2c_new_client_device); 817 817 818 818 /** 819 - * i2c_new_device - instantiate an i2c device 820 - * @adap: the adapter managing the device 821 - * @info: describes one I2C device; bus_num is ignored 822 - * Context: can sleep 823 - * 824 - * This deprecated function has the same functionality as 825 - * @i2c_new_client_device, it just returns NULL instead of an ERR_PTR in case of 826 - * an error for compatibility with current I2C API. It will be removed once all 827 - * users are converted. 828 - * 829 - * This returns the new i2c client, which may be saved for later use with 830 - * i2c_unregister_device(); or NULL to indicate an error. 831 - */ 832 - struct i2c_client * 833 - i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) 834 - { 835 - struct i2c_client *ret; 836 - 837 - ret = i2c_new_client_device(adap, info); 838 - return IS_ERR(ret) ? NULL : ret; 839 - } 840 - EXPORT_SYMBOL_GPL(i2c_new_device); 841 - 842 - 843 - /** 844 819 * i2c_unregister_device - reverse effect of i2c_new_*_device() 845 820 * @client: value returned from i2c_new_*_device() 846 821 * Context: can sleep
+1 -1
drivers/i2c/i2c-core-smbus.c
··· 4 4 * 5 5 * This file contains the SMBus functions which are always included in the I2C 6 6 * core because they can be emulated via I2C. SMBus specific extensions 7 - * (e.g. smbalert) are handled in a seperate i2c-smbus module. 7 + * (e.g. smbalert) are handled in a separate i2c-smbus module. 8 8 * 9 9 * All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> 10 10 * SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and
+8 -2
drivers/infiniband/core/device.c
··· 2617 2617 SET_DEVICE_OP(dev_ops, drain_rq); 2618 2618 SET_DEVICE_OP(dev_ops, drain_sq); 2619 2619 SET_DEVICE_OP(dev_ops, enable_driver); 2620 - SET_DEVICE_OP(dev_ops, fill_res_entry); 2621 - SET_DEVICE_OP(dev_ops, fill_stat_entry); 2620 + SET_DEVICE_OP(dev_ops, fill_res_cm_id_entry); 2621 + SET_DEVICE_OP(dev_ops, fill_res_cq_entry); 2622 + SET_DEVICE_OP(dev_ops, fill_res_cq_entry_raw); 2623 + SET_DEVICE_OP(dev_ops, fill_res_mr_entry); 2624 + SET_DEVICE_OP(dev_ops, fill_res_mr_entry_raw); 2625 + SET_DEVICE_OP(dev_ops, fill_res_qp_entry); 2626 + SET_DEVICE_OP(dev_ops, fill_res_qp_entry_raw); 2627 + SET_DEVICE_OP(dev_ops, fill_stat_mr_entry); 2622 2628 SET_DEVICE_OP(dev_ops, get_dev_fw_str); 2623 2629 SET_DEVICE_OP(dev_ops, get_dma_mr); 2624 2630 SET_DEVICE_OP(dev_ops, get_hw_stats);
+123 -95
drivers/infiniband/core/nldev.c
··· 114 114 [RDMA_NLDEV_ATTR_RES_PS] = { .type = NLA_U32 }, 115 115 [RDMA_NLDEV_ATTR_RES_QP] = { .type = NLA_NESTED }, 116 116 [RDMA_NLDEV_ATTR_RES_QP_ENTRY] = { .type = NLA_NESTED }, 117 + [RDMA_NLDEV_ATTR_RES_RAW] = { .type = NLA_BINARY }, 117 118 [RDMA_NLDEV_ATTR_RES_RKEY] = { .type = NLA_U32 }, 118 119 [RDMA_NLDEV_ATTR_RES_RQPN] = { .type = NLA_U32 }, 119 120 [RDMA_NLDEV_ATTR_RES_RQ_PSN] = { .type = NLA_U32 }, ··· 447 446 return err ? -EMSGSIZE : 0; 448 447 } 449 448 450 - static bool fill_res_entry(struct ib_device *dev, struct sk_buff *msg, 451 - struct rdma_restrack_entry *res) 449 + static int fill_res_qp_entry_query(struct sk_buff *msg, 450 + struct rdma_restrack_entry *res, 451 + struct ib_device *dev, 452 + struct ib_qp *qp) 452 453 { 453 - if (!dev->ops.fill_res_entry) 454 - return false; 455 - return dev->ops.fill_res_entry(msg, res); 456 - } 457 - 458 - static bool fill_stat_entry(struct ib_device *dev, struct sk_buff *msg, 459 - struct rdma_restrack_entry *res) 460 - { 461 - if (!dev->ops.fill_stat_entry) 462 - return false; 463 - return dev->ops.fill_stat_entry(msg, res); 464 - } 465 - 466 - static int fill_res_qp_entry(struct sk_buff *msg, bool has_cap_net_admin, 467 - struct rdma_restrack_entry *res, uint32_t port) 468 - { 469 - struct ib_qp *qp = container_of(res, struct ib_qp, res); 470 - struct ib_device *dev = qp->device; 471 454 struct ib_qp_init_attr qp_init_attr; 472 455 struct ib_qp_attr qp_attr; 473 456 int ret; ··· 460 475 if (ret) 461 476 return ret; 462 477 463 - if (port && port != qp_attr.port_num) 464 - return -EAGAIN; 465 - 466 - /* In create_qp() port is not set yet */ 467 - if (qp_attr.port_num && 468 - nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, qp_attr.port_num)) 469 - goto err; 470 - 471 - if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LQPN, qp->qp_num)) 472 - goto err; 473 478 if (qp->qp_type == IB_QPT_RC || qp->qp_type == IB_QPT_UC) { 474 479 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_RQPN, 475 480 qp_attr.dest_qp_num)) ··· 483 508 if (nla_put_u8(msg, RDMA_NLDEV_ATTR_RES_STATE, qp_attr.qp_state)) 484 509 goto err; 485 510 486 - if (!rdma_is_kernel_res(res) && 487 - nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_PDN, qp->pd->res.id)) 488 - goto err; 489 - 490 - if (fill_res_name_pid(msg, res)) 491 - goto err; 492 - 493 - if (fill_res_entry(dev, msg, res)) 494 - goto err; 495 - 511 + if (dev->ops.fill_res_qp_entry) 512 + return dev->ops.fill_res_qp_entry(msg, qp); 496 513 return 0; 497 514 498 515 err: return -EMSGSIZE; 516 + } 517 + 518 + static int fill_res_qp_entry(struct sk_buff *msg, bool has_cap_net_admin, 519 + struct rdma_restrack_entry *res, uint32_t port) 520 + { 521 + struct ib_qp *qp = container_of(res, struct ib_qp, res); 522 + struct ib_device *dev = qp->device; 523 + int ret; 524 + 525 + if (port && port != qp->port) 526 + return -EAGAIN; 527 + 528 + /* In create_qp() port is not set yet */ 529 + if (qp->port && nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, qp->port)) 530 + return -EINVAL; 531 + 532 + ret = nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LQPN, qp->qp_num); 533 + if (ret) 534 + return -EMSGSIZE; 535 + 536 + if (!rdma_is_kernel_res(res) && 537 + nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_PDN, qp->pd->res.id)) 538 + return -EMSGSIZE; 539 + 540 + ret = fill_res_name_pid(msg, res); 541 + if (ret) 542 + return -EMSGSIZE; 543 + 544 + return fill_res_qp_entry_query(msg, res, dev, qp); 545 + } 546 + 547 + static int fill_res_qp_raw_entry(struct sk_buff *msg, bool has_cap_net_admin, 548 + struct rdma_restrack_entry *res, uint32_t port) 549 + { 550 + struct ib_qp *qp = container_of(res, struct ib_qp, res); 551 + struct ib_device *dev = qp->device; 552 + 553 + if (port && port != qp->port) 554 + return -EAGAIN; 555 + if (!dev->ops.fill_res_qp_entry_raw) 556 + return -EINVAL; 557 + return dev->ops.fill_res_qp_entry_raw(msg, qp); 499 558 } 500 559 501 560 static int fill_res_cm_id_entry(struct sk_buff *msg, bool has_cap_net_admin, ··· 577 568 if (fill_res_name_pid(msg, res)) 578 569 goto err; 579 570 580 - if (fill_res_entry(dev, msg, res)) 581 - goto err; 582 - 571 + if (dev->ops.fill_res_cm_id_entry) 572 + return dev->ops.fill_res_cm_id_entry(msg, cm_id); 583 573 return 0; 584 574 585 575 err: return -EMSGSIZE; ··· 591 583 struct ib_device *dev = cq->device; 592 584 593 585 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CQE, cq->cqe)) 594 - goto err; 586 + return -EMSGSIZE; 595 587 if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_USECNT, 596 588 atomic_read(&cq->usecnt), RDMA_NLDEV_ATTR_PAD)) 597 - goto err; 589 + return -EMSGSIZE; 598 590 599 591 /* Poll context is only valid for kernel CQs */ 600 592 if (rdma_is_kernel_res(res) && 601 593 nla_put_u8(msg, RDMA_NLDEV_ATTR_RES_POLL_CTX, cq->poll_ctx)) 602 - goto err; 594 + return -EMSGSIZE; 603 595 604 596 if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_DIM, (cq->dim != NULL))) 605 - goto err; 597 + return -EMSGSIZE; 606 598 607 599 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CQN, res->id)) 608 - goto err; 600 + return -EMSGSIZE; 609 601 if (!rdma_is_kernel_res(res) && 610 602 nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CTXN, 611 603 cq->uobject->uevent.uobject.context->res.id)) 612 - goto err; 604 + return -EMSGSIZE; 613 605 614 606 if (fill_res_name_pid(msg, res)) 615 - goto err; 607 + return -EMSGSIZE; 616 608 617 - if (fill_res_entry(dev, msg, res)) 618 - goto err; 609 + return (dev->ops.fill_res_cq_entry) ? 610 + dev->ops.fill_res_cq_entry(msg, cq) : 0; 611 + } 619 612 620 - return 0; 613 + static int fill_res_cq_raw_entry(struct sk_buff *msg, bool has_cap_net_admin, 614 + struct rdma_restrack_entry *res, uint32_t port) 615 + { 616 + struct ib_cq *cq = container_of(res, struct ib_cq, res); 617 + struct ib_device *dev = cq->device; 621 618 622 - err: return -EMSGSIZE; 619 + if (!dev->ops.fill_res_cq_entry_raw) 620 + return -EINVAL; 621 + return dev->ops.fill_res_cq_entry_raw(msg, cq); 623 622 } 624 623 625 624 static int fill_res_mr_entry(struct sk_buff *msg, bool has_cap_net_admin, ··· 637 622 638 623 if (has_cap_net_admin) { 639 624 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_RKEY, mr->rkey)) 640 - goto err; 625 + return -EMSGSIZE; 641 626 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LKEY, mr->lkey)) 642 - goto err; 627 + return -EMSGSIZE; 643 628 } 644 629 645 630 if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_MRLEN, mr->length, 646 631 RDMA_NLDEV_ATTR_PAD)) 647 - goto err; 632 + return -EMSGSIZE; 648 633 649 634 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_MRN, res->id)) 650 - goto err; 635 + return -EMSGSIZE; 651 636 652 637 if (!rdma_is_kernel_res(res) && 653 638 nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_PDN, mr->pd->res.id)) 654 - goto err; 639 + return -EMSGSIZE; 655 640 656 641 if (fill_res_name_pid(msg, res)) 657 - goto err; 642 + return -EMSGSIZE; 658 643 659 - if (fill_res_entry(dev, msg, res)) 660 - goto err; 644 + return (dev->ops.fill_res_mr_entry) ? 645 + dev->ops.fill_res_mr_entry(msg, mr) : 646 + 0; 647 + } 661 648 662 - return 0; 649 + static int fill_res_mr_raw_entry(struct sk_buff *msg, bool has_cap_net_admin, 650 + struct rdma_restrack_entry *res, uint32_t port) 651 + { 652 + struct ib_mr *mr = container_of(res, struct ib_mr, res); 653 + struct ib_device *dev = mr->pd->device; 663 654 664 - err: return -EMSGSIZE; 655 + if (!dev->ops.fill_res_mr_entry_raw) 656 + return -EINVAL; 657 + return dev->ops.fill_res_mr_entry_raw(msg, mr); 665 658 } 666 659 667 660 static int fill_res_pd_entry(struct sk_buff *msg, bool has_cap_net_admin, 668 661 struct rdma_restrack_entry *res, uint32_t port) 669 662 { 670 663 struct ib_pd *pd = container_of(res, struct ib_pd, res); 671 - struct ib_device *dev = pd->device; 672 664 673 665 if (has_cap_net_admin) { 674 666 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY, ··· 698 676 pd->uobject->context->res.id)) 699 677 goto err; 700 678 701 - if (fill_res_name_pid(msg, res)) 702 - goto err; 703 - 704 - if (fill_res_entry(dev, msg, res)) 705 - goto err; 706 - 707 - return 0; 679 + return fill_res_name_pid(msg, res); 708 680 709 681 err: return -EMSGSIZE; 710 682 } ··· 809 793 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_MRN, res->id)) 810 794 goto err; 811 795 812 - if (fill_stat_entry(dev, msg, res)) 813 - goto err; 814 - 796 + if (dev->ops.fill_stat_mr_entry) 797 + return dev->ops.fill_stat_mr_entry(msg, mr); 815 798 return 0; 816 799 817 800 err: ··· 1192 1177 1193 1178 struct nldev_fill_res_entry { 1194 1179 enum rdma_nldev_attr nldev_attr; 1195 - enum rdma_nldev_command nldev_cmd; 1196 1180 u8 flags; 1197 1181 u32 entry; 1198 1182 u32 id; ··· 1203 1189 1204 1190 static const struct nldev_fill_res_entry fill_entries[RDMA_RESTRACK_MAX] = { 1205 1191 [RDMA_RESTRACK_QP] = { 1206 - .nldev_cmd = RDMA_NLDEV_CMD_RES_QP_GET, 1207 1192 .nldev_attr = RDMA_NLDEV_ATTR_RES_QP, 1208 1193 .entry = RDMA_NLDEV_ATTR_RES_QP_ENTRY, 1209 1194 .id = RDMA_NLDEV_ATTR_RES_LQPN, 1210 1195 }, 1211 1196 [RDMA_RESTRACK_CM_ID] = { 1212 - .nldev_cmd = RDMA_NLDEV_CMD_RES_CM_ID_GET, 1213 1197 .nldev_attr = RDMA_NLDEV_ATTR_RES_CM_ID, 1214 1198 .entry = RDMA_NLDEV_ATTR_RES_CM_ID_ENTRY, 1215 1199 .id = RDMA_NLDEV_ATTR_RES_CM_IDN, 1216 1200 }, 1217 1201 [RDMA_RESTRACK_CQ] = { 1218 - .nldev_cmd = RDMA_NLDEV_CMD_RES_CQ_GET, 1219 1202 .nldev_attr = RDMA_NLDEV_ATTR_RES_CQ, 1220 1203 .flags = NLDEV_PER_DEV, 1221 1204 .entry = RDMA_NLDEV_ATTR_RES_CQ_ENTRY, 1222 1205 .id = RDMA_NLDEV_ATTR_RES_CQN, 1223 1206 }, 1224 1207 [RDMA_RESTRACK_MR] = { 1225 - .nldev_cmd = RDMA_NLDEV_CMD_RES_MR_GET, 1226 1208 .nldev_attr = RDMA_NLDEV_ATTR_RES_MR, 1227 1209 .flags = NLDEV_PER_DEV, 1228 1210 .entry = RDMA_NLDEV_ATTR_RES_MR_ENTRY, 1229 1211 .id = RDMA_NLDEV_ATTR_RES_MRN, 1230 1212 }, 1231 1213 [RDMA_RESTRACK_PD] = { 1232 - .nldev_cmd = RDMA_NLDEV_CMD_RES_PD_GET, 1233 1214 .nldev_attr = RDMA_NLDEV_ATTR_RES_PD, 1234 1215 .flags = NLDEV_PER_DEV, 1235 1216 .entry = RDMA_NLDEV_ATTR_RES_PD_ENTRY, 1236 1217 .id = RDMA_NLDEV_ATTR_RES_PDN, 1237 1218 }, 1238 1219 [RDMA_RESTRACK_COUNTER] = { 1239 - .nldev_cmd = RDMA_NLDEV_CMD_STAT_GET, 1240 1220 .nldev_attr = RDMA_NLDEV_ATTR_STAT_COUNTER, 1241 1221 .entry = RDMA_NLDEV_ATTR_STAT_COUNTER_ENTRY, 1242 1222 .id = RDMA_NLDEV_ATTR_STAT_COUNTER_ID, ··· 1289 1281 } 1290 1282 1291 1283 nlh = nlmsg_put(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq, 1292 - RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, fe->nldev_cmd), 1284 + RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, 1285 + RDMA_NL_GET_OP(nlh->nlmsg_type)), 1293 1286 0, 0); 1294 1287 1295 1288 if (fill_nldev_handle(msg, device)) { ··· 1368 1359 } 1369 1360 1370 1361 nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, 1371 - RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, fe->nldev_cmd), 1362 + RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, 1363 + RDMA_NL_GET_OP(cb->nlh->nlmsg_type)), 1372 1364 0, NLM_F_MULTI); 1373 1365 1374 1366 if (fill_nldev_handle(skb, device)) { ··· 1451 1441 return ret; 1452 1442 } 1453 1443 1454 - #define RES_GET_FUNCS(name, type) \ 1455 - static int nldev_res_get_##name##_dumpit(struct sk_buff *skb, \ 1444 + #define RES_GET_FUNCS(name, type) \ 1445 + static int nldev_res_get_##name##_dumpit(struct sk_buff *skb, \ 1456 1446 struct netlink_callback *cb) \ 1457 - { \ 1458 - return res_get_common_dumpit(skb, cb, type, \ 1459 - fill_res_##name##_entry); \ 1460 - } \ 1461 - static int nldev_res_get_##name##_doit(struct sk_buff *skb, \ 1462 - struct nlmsghdr *nlh, \ 1447 + { \ 1448 + return res_get_common_dumpit(skb, cb, type, \ 1449 + fill_res_##name##_entry); \ 1450 + } \ 1451 + static int nldev_res_get_##name##_doit(struct sk_buff *skb, \ 1452 + struct nlmsghdr *nlh, \ 1463 1453 struct netlink_ext_ack *extack) \ 1464 - { \ 1465 - return res_get_common_doit(skb, nlh, extack, type, \ 1466 - fill_res_##name##_entry); \ 1454 + { \ 1455 + return res_get_common_doit(skb, nlh, extack, type, \ 1456 + fill_res_##name##_entry); \ 1467 1457 } 1468 1458 1469 1459 RES_GET_FUNCS(qp, RDMA_RESTRACK_QP); 1460 + RES_GET_FUNCS(qp_raw, RDMA_RESTRACK_QP); 1470 1461 RES_GET_FUNCS(cm_id, RDMA_RESTRACK_CM_ID); 1471 1462 RES_GET_FUNCS(cq, RDMA_RESTRACK_CQ); 1463 + RES_GET_FUNCS(cq_raw, RDMA_RESTRACK_CQ); 1472 1464 RES_GET_FUNCS(pd, RDMA_RESTRACK_PD); 1473 1465 RES_GET_FUNCS(mr, RDMA_RESTRACK_MR); 1466 + RES_GET_FUNCS(mr_raw, RDMA_RESTRACK_MR); 1474 1467 RES_GET_FUNCS(counter, RDMA_RESTRACK_COUNTER); 1475 1468 1476 1469 static LIST_HEAD(link_ops); ··· 2156 2143 }, 2157 2144 [RDMA_NLDEV_CMD_STAT_DEL] = { 2158 2145 .doit = nldev_stat_del_doit, 2146 + .flags = RDMA_NL_ADMIN_PERM, 2147 + }, 2148 + [RDMA_NLDEV_CMD_RES_QP_GET_RAW] = { 2149 + .doit = nldev_res_get_qp_raw_doit, 2150 + .dump = nldev_res_get_qp_raw_dumpit, 2151 + .flags = RDMA_NL_ADMIN_PERM, 2152 + }, 2153 + [RDMA_NLDEV_CMD_RES_CQ_GET_RAW] = { 2154 + .doit = nldev_res_get_cq_raw_doit, 2155 + .dump = nldev_res_get_cq_raw_dumpit, 2156 + .flags = RDMA_NL_ADMIN_PERM, 2157 + }, 2158 + [RDMA_NLDEV_CMD_RES_MR_GET_RAW] = { 2159 + .doit = nldev_res_get_mr_raw_doit, 2160 + .dump = nldev_res_get_mr_raw_dumpit, 2159 2161 .flags = RDMA_NL_ADMIN_PERM, 2160 2162 }, 2161 2163 };
+4 -3
drivers/infiniband/hw/cxgb4/iw_cxgb4.h
··· 1053 1053 const struct ib_recv_wr **bad_wr); 1054 1054 struct c4iw_wr_wait *c4iw_alloc_wr_wait(gfp_t gfp); 1055 1055 1056 - typedef int c4iw_restrack_func(struct sk_buff *msg, 1057 - struct rdma_restrack_entry *res); 1058 - extern c4iw_restrack_func *c4iw_restrack_funcs[RDMA_RESTRACK_MAX]; 1056 + int c4iw_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr); 1057 + int c4iw_fill_res_cq_entry(struct sk_buff *msg, struct ib_cq *ibcq); 1058 + int c4iw_fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ibqp); 1059 + int c4iw_fill_res_cm_id_entry(struct sk_buff *msg, struct rdma_cm_id *cm_id); 1059 1060 1060 1061 #endif
+3 -8
drivers/infiniband/hw/cxgb4/provider.c
··· 458 458 FW_HDR_FW_VER_BUILD_G(c4iw_dev->rdev.lldi.fw_vers)); 459 459 } 460 460 461 - static int fill_res_entry(struct sk_buff *msg, struct rdma_restrack_entry *res) 462 - { 463 - return (res->type < ARRAY_SIZE(c4iw_restrack_funcs) && 464 - c4iw_restrack_funcs[res->type]) ? 465 - c4iw_restrack_funcs[res->type](msg, res) : 0; 466 - } 467 - 468 461 static const struct ib_device_ops c4iw_dev_ops = { 469 462 .owner = THIS_MODULE, 470 463 .driver_id = RDMA_DRIVER_CXGB4, ··· 478 485 .destroy_cq = c4iw_destroy_cq, 479 486 .destroy_qp = c4iw_destroy_qp, 480 487 .destroy_srq = c4iw_destroy_srq, 481 - .fill_res_entry = fill_res_entry, 488 + .fill_res_cq_entry = c4iw_fill_res_cq_entry, 489 + .fill_res_cm_id_entry = c4iw_fill_res_cm_id_entry, 490 + .fill_res_mr_entry = c4iw_fill_res_mr_entry, 482 491 .get_dev_fw_str = get_dev_fw_str, 483 492 .get_dma_mr = c4iw_get_dma_mr, 484 493 .get_hw_stats = c4iw_get_mib,
+5 -19
drivers/infiniband/hw/cxgb4/restrack.c
··· 134 134 return -EMSGSIZE; 135 135 } 136 136 137 - static int fill_res_qp_entry(struct sk_buff *msg, 138 - struct rdma_restrack_entry *res) 137 + int c4iw_fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ibqp) 139 138 { 140 - struct ib_qp *ibqp = container_of(res, struct ib_qp, res); 141 139 struct t4_swsqe *fsp = NULL, *lsp = NULL; 142 140 struct c4iw_qp *qhp = to_c4iw_qp(ibqp); 143 141 u16 first_sq_idx = 0, last_sq_idx = 0; ··· 193 195 struct c4iw_ep ep; 194 196 }; 195 197 196 - static int fill_res_ep_entry(struct sk_buff *msg, 197 - struct rdma_restrack_entry *res) 198 + int c4iw_fill_res_cm_id_entry(struct sk_buff *msg, 199 + struct rdma_cm_id *cm_id) 198 200 { 199 - struct rdma_cm_id *cm_id = rdma_res_to_id(res); 200 201 struct nlattr *table_attr; 201 202 struct c4iw_ep_common *epcp; 202 203 struct c4iw_listen_ep *listen_ep = NULL; ··· 369 372 return -EMSGSIZE; 370 373 } 371 374 372 - static int fill_res_cq_entry(struct sk_buff *msg, 373 - struct rdma_restrack_entry *res) 375 + int c4iw_fill_res_cq_entry(struct sk_buff *msg, struct ib_cq *ibcq) 374 376 { 375 - struct ib_cq *ibcq = container_of(res, struct ib_cq, res); 376 377 struct c4iw_cq *chp = to_c4iw_cq(ibcq); 377 378 struct nlattr *table_attr; 378 379 struct t4_cqe hwcqes[2]; ··· 428 433 return -EMSGSIZE; 429 434 } 430 435 431 - static int fill_res_mr_entry(struct sk_buff *msg, 432 - struct rdma_restrack_entry *res) 436 + int c4iw_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr) 433 437 { 434 - struct ib_mr *ibmr = container_of(res, struct ib_mr, res); 435 438 struct c4iw_mr *mhp = to_c4iw_mr(ibmr); 436 439 struct c4iw_dev *dev = mhp->rhp; 437 440 u32 stag = mhp->attr.stag; ··· 485 492 err: 486 493 return -EMSGSIZE; 487 494 } 488 - 489 - c4iw_restrack_func *c4iw_restrack_funcs[RDMA_RESTRACK_MAX] = { 490 - [RDMA_RESTRACK_QP] = fill_res_qp_entry, 491 - [RDMA_RESTRACK_CM_ID] = fill_res_ep_entry, 492 - [RDMA_RESTRACK_CQ] = fill_res_cq_entry, 493 - [RDMA_RESTRACK_MR] = fill_res_mr_entry, 494 - };
+2 -2
drivers/infiniband/hw/hns/hns_roce_device.h
··· 1266 1266 int hns_roce_init(struct hns_roce_dev *hr_dev); 1267 1267 void hns_roce_exit(struct hns_roce_dev *hr_dev); 1268 1268 1269 - int hns_roce_fill_res_entry(struct sk_buff *msg, 1270 - struct rdma_restrack_entry *res); 1269 + int hns_roce_fill_res_cq_entry(struct sk_buff *msg, 1270 + struct ib_cq *ib_cq); 1271 1271 #endif /* _HNS_ROCE_DEVICE_H */
+1 -1
drivers/infiniband/hw/hns/hns_roce_main.c
··· 428 428 .destroy_ah = hns_roce_destroy_ah, 429 429 .destroy_cq = hns_roce_destroy_cq, 430 430 .disassociate_ucontext = hns_roce_disassociate_ucontext, 431 - .fill_res_entry = hns_roce_fill_res_entry, 431 + .fill_res_cq_entry = hns_roce_fill_res_cq_entry, 432 432 .get_dma_mr = hns_roce_get_dma_mr, 433 433 .get_link_layer = hns_roce_get_link_layer, 434 434 .get_port_immutable = hns_roce_port_immutable,
+2 -12
drivers/infiniband/hw/hns/hns_roce_restrack.c
··· 76 76 return -EMSGSIZE; 77 77 } 78 78 79 - static int hns_roce_fill_res_cq_entry(struct sk_buff *msg, 80 - struct rdma_restrack_entry *res) 79 + int hns_roce_fill_res_cq_entry(struct sk_buff *msg, 80 + struct ib_cq *ib_cq) 81 81 { 82 - struct ib_cq *ib_cq = container_of(res, struct ib_cq, res); 83 82 struct hns_roce_dev *hr_dev = to_hr_dev(ib_cq->device); 84 83 struct hns_roce_cq *hr_cq = to_hr_cq(ib_cq); 85 84 struct hns_roce_v2_cq_context *context; ··· 117 118 err: 118 119 kfree(context); 119 120 return ret; 120 - } 121 - 122 - int hns_roce_fill_res_entry(struct sk_buff *msg, 123 - struct rdma_restrack_entry *res) 124 - { 125 - if (res->type == RDMA_RESTRACK_CQ) 126 - return hns_roce_fill_res_cq_entry(msg, res); 127 - 128 - return 0; 129 121 }
+5 -2
drivers/infiniband/hw/mlx5/main.c
··· 6598 6598 .drain_rq = mlx5_ib_drain_rq, 6599 6599 .drain_sq = mlx5_ib_drain_sq, 6600 6600 .enable_driver = mlx5_ib_enable_driver, 6601 - .fill_res_entry = mlx5_ib_fill_res_entry, 6602 - .fill_stat_entry = mlx5_ib_fill_stat_entry, 6601 + .fill_res_cq_entry_raw = mlx5_ib_fill_res_cq_entry_raw, 6602 + .fill_res_mr_entry = mlx5_ib_fill_res_mr_entry, 6603 + .fill_res_mr_entry_raw = mlx5_ib_fill_res_mr_entry_raw, 6604 + .fill_res_qp_entry_raw = mlx5_ib_fill_res_qp_entry_raw, 6605 + .fill_stat_mr_entry = mlx5_ib_fill_stat_mr_entry, 6603 6606 .get_dev_fw_str = get_dev_fw_str, 6604 6607 .get_dma_mr = mlx5_ib_get_dma_mr, 6605 6608 .get_link_layer = mlx5_ib_port_link_layer,
+5 -4
drivers/infiniband/hw/mlx5/mlx5_ib.h
··· 1375 1375 u8 *native_port_num); 1376 1376 void mlx5_ib_put_native_port_mdev(struct mlx5_ib_dev *dev, 1377 1377 u8 port_num); 1378 - int mlx5_ib_fill_res_entry(struct sk_buff *msg, 1379 - struct rdma_restrack_entry *res); 1380 - int mlx5_ib_fill_stat_entry(struct sk_buff *msg, 1381 - struct rdma_restrack_entry *res); 1378 + int mlx5_ib_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr); 1379 + int mlx5_ib_fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ib_mr); 1380 + int mlx5_ib_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ibqp); 1381 + int mlx5_ib_fill_res_cq_entry_raw(struct sk_buff *msg, struct ib_cq *ibcq); 1382 + int mlx5_ib_fill_stat_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr); 1382 1383 1383 1384 extern const struct uapi_definition mlx5_ib_devx_defs[]; 1384 1385 extern const struct uapi_definition mlx5_ib_flow_defs[];
+89 -16
drivers/infiniband/hw/mlx5/restrack.c
··· 4 4 */ 5 5 6 6 #include <uapi/rdma/rdma_netlink.h> 7 + #include <linux/mlx5/rsc_dump.h> 7 8 #include <rdma/ib_umem_odp.h> 8 9 #include <rdma/restrack.h> 9 10 #include "mlx5_ib.h" 10 11 11 - static int fill_stat_mr_entry(struct sk_buff *msg, 12 - struct rdma_restrack_entry *res) 12 + #define MAX_DUMP_SIZE 1024 13 + 14 + static int dump_rsc(struct mlx5_core_dev *dev, enum mlx5_sgmt_type type, 15 + int index, void *data, int *data_len) 13 16 { 14 - struct ib_mr *ibmr = container_of(res, struct ib_mr, res); 17 + struct mlx5_core_dev *mdev = dev; 18 + struct mlx5_rsc_dump_cmd *cmd; 19 + struct mlx5_rsc_key key = {}; 20 + struct page *page; 21 + int offset = 0; 22 + int err = 0; 23 + int cmd_err; 24 + int size; 25 + 26 + page = alloc_page(GFP_KERNEL); 27 + if (!page) 28 + return -ENOMEM; 29 + 30 + key.size = PAGE_SIZE; 31 + key.rsc = type; 32 + key.index1 = index; 33 + key.num_of_obj1 = 1; 34 + 35 + cmd = mlx5_rsc_dump_cmd_create(mdev, &key); 36 + if (IS_ERR(cmd)) { 37 + err = PTR_ERR(cmd); 38 + goto free_page; 39 + } 40 + 41 + do { 42 + cmd_err = mlx5_rsc_dump_next(mdev, cmd, page, &size); 43 + if (cmd_err < 0 || size + offset > MAX_DUMP_SIZE) { 44 + err = cmd_err; 45 + goto destroy_cmd; 46 + } 47 + memcpy(data + offset, page_address(page), size); 48 + offset += size; 49 + } while (cmd_err > 0); 50 + *data_len = offset; 51 + 52 + destroy_cmd: 53 + mlx5_rsc_dump_cmd_destroy(cmd); 54 + free_page: 55 + __free_page(page); 56 + return err; 57 + } 58 + 59 + static int fill_res_raw(struct sk_buff *msg, struct mlx5_ib_dev *dev, 60 + enum mlx5_sgmt_type type, u32 key) 61 + { 62 + int len = 0; 63 + void *data; 64 + int err; 65 + 66 + data = kzalloc(MAX_DUMP_SIZE, GFP_KERNEL); 67 + if (!data) 68 + return -ENOMEM; 69 + 70 + err = dump_rsc(dev->mdev, type, key, data, &len); 71 + if (err) 72 + goto out; 73 + 74 + err = nla_put(msg, RDMA_NLDEV_ATTR_RES_RAW, len, data); 75 + out: 76 + kfree(data); 77 + return err; 78 + } 79 + 80 + int mlx5_ib_fill_stat_mr_entry(struct sk_buff *msg, 81 + struct ib_mr *ibmr) 82 + { 15 83 struct mlx5_ib_mr *mr = to_mmr(ibmr); 16 84 struct nlattr *table_attr; 17 85 ··· 109 41 return -EMSGSIZE; 110 42 } 111 43 112 - static int fill_res_mr_entry(struct sk_buff *msg, 113 - struct rdma_restrack_entry *res) 44 + int mlx5_ib_fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ibmr) 114 45 { 115 - struct ib_mr *ibmr = container_of(res, struct ib_mr, res); 46 + struct mlx5_ib_mr *mr = to_mmr(ibmr); 47 + 48 + return fill_res_raw(msg, mr->dev, MLX5_SGMT_TYPE_PRM_QUERY_MKEY, 49 + mlx5_mkey_to_idx(mr->mmkey.key)); 50 + } 51 + 52 + int mlx5_ib_fill_res_mr_entry(struct sk_buff *msg, 53 + struct ib_mr *ibmr) 54 + { 116 55 struct mlx5_ib_mr *mr = to_mmr(ibmr); 117 56 struct nlattr *table_attr; 118 57 ··· 146 71 return -EMSGSIZE; 147 72 } 148 73 149 - int mlx5_ib_fill_res_entry(struct sk_buff *msg, 150 - struct rdma_restrack_entry *res) 74 + int mlx5_ib_fill_res_cq_entry_raw(struct sk_buff *msg, struct ib_cq *ibcq) 151 75 { 152 - if (res->type == RDMA_RESTRACK_MR) 153 - return fill_res_mr_entry(msg, res); 76 + struct mlx5_ib_dev *dev = to_mdev(ibcq->device); 77 + struct mlx5_ib_cq *cq = to_mcq(ibcq); 154 78 155 - return 0; 79 + return fill_res_raw(msg, dev, MLX5_SGMT_TYPE_PRM_QUERY_CQ, cq->mcq.cqn); 156 80 } 157 81 158 - int mlx5_ib_fill_stat_entry(struct sk_buff *msg, 159 - struct rdma_restrack_entry *res) 82 + int mlx5_ib_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ibqp) 160 83 { 161 - if (res->type == RDMA_RESTRACK_MR) 162 - return fill_stat_mr_entry(msg, res); 84 + struct mlx5_ib_dev *dev = to_mdev(ibqp->device); 163 85 164 - return 0; 86 + return fill_res_raw(msg, dev, MLX5_SGMT_TYPE_PRM_QUERY_QP, 87 + ibqp->qp_num); 165 88 }
+1 -1
drivers/input/serio/hp_sdc.c
··· 1021 1021 hp_sdc.base_io = (unsigned long) 0xf0428000; 1022 1022 hp_sdc.data_io = (unsigned long) hp_sdc.base_io + 1; 1023 1023 hp_sdc.status_io = (unsigned long) hp_sdc.base_io + 3; 1024 - if (!probe_kernel_read(&i, (unsigned char *)hp_sdc.data_io, 1)) 1024 + if (!copy_from_kernel_nofault(&i, (unsigned char *)hp_sdc.data_io, 1)) 1025 1025 hp_sdc.dev = (void *)1; 1026 1026 hp_sdc.dev_err = hp_sdc_init(); 1027 1027 #endif
+6 -2
drivers/md/bcache/btree.c
··· 1389 1389 if (__set_blocks(n1, n1->keys + n2->keys, 1390 1390 block_bytes(b->c)) > 1391 1391 btree_blocks(new_nodes[i])) 1392 - goto out_nocoalesce; 1392 + goto out_unlock_nocoalesce; 1393 1393 1394 1394 keys = n2->keys; 1395 1395 /* Take the key of the node we're getting rid of */ ··· 1418 1418 1419 1419 if (__bch_keylist_realloc(&keylist, 1420 1420 bkey_u64s(&new_nodes[i]->key))) 1421 - goto out_nocoalesce; 1421 + goto out_unlock_nocoalesce; 1422 1422 1423 1423 bch_btree_node_write(new_nodes[i], &cl); 1424 1424 bch_keylist_add(&keylist, &new_nodes[i]->key); ··· 1463 1463 1464 1464 /* Invalidated our iterator */ 1465 1465 return -EINTR; 1466 + 1467 + out_unlock_nocoalesce: 1468 + for (i = 0; i < nodes; i++) 1469 + mutex_unlock(&new_nodes[i]->write_lock); 1466 1470 1467 1471 out_nocoalesce: 1468 1472 closure_sync(&cl);
+26 -9
drivers/md/bcache/super.c
··· 19 19 #include <linux/genhd.h> 20 20 #include <linux/idr.h> 21 21 #include <linux/kthread.h> 22 + #include <linux/workqueue.h> 22 23 #include <linux/module.h> 23 24 #include <linux/random.h> 24 25 #include <linux/reboot.h> ··· 820 819 } 821 820 822 821 static int bcache_device_init(struct bcache_device *d, unsigned int block_size, 823 - sector_t sectors, make_request_fn make_request_fn) 822 + sector_t sectors, make_request_fn make_request_fn, 823 + struct block_device *cached_bdev) 824 824 { 825 825 struct request_queue *q; 826 826 const size_t max_stripes = min_t(size_t, INT_MAX, ··· 887 885 q->limits.io_min = block_size; 888 886 q->limits.logical_block_size = block_size; 889 887 q->limits.physical_block_size = block_size; 888 + 889 + if (q->limits.logical_block_size > PAGE_SIZE && cached_bdev) { 890 + /* 891 + * This should only happen with BCACHE_SB_VERSION_BDEV. 892 + * Block/page size is checked for BCACHE_SB_VERSION_CDEV. 893 + */ 894 + pr_info("%s: sb/logical block size (%u) greater than page size (%lu) falling back to device logical block size (%u)\n", 895 + d->disk->disk_name, q->limits.logical_block_size, 896 + PAGE_SIZE, bdev_logical_block_size(cached_bdev)); 897 + 898 + /* This also adjusts physical block size/min io size if needed */ 899 + blk_queue_logical_block_size(q, bdev_logical_block_size(cached_bdev)); 900 + } 901 + 890 902 blk_queue_flag_set(QUEUE_FLAG_NONROT, d->disk->queue); 891 903 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, d->disk->queue); 892 904 blk_queue_flag_set(QUEUE_FLAG_DISCARD, d->disk->queue); ··· 1356 1340 1357 1341 ret = bcache_device_init(&dc->disk, block_size, 1358 1342 dc->bdev->bd_part->nr_sects - dc->sb.data_offset, 1359 - cached_dev_make_request); 1343 + cached_dev_make_request, dc->bdev); 1360 1344 if (ret) 1361 1345 return ret; 1362 1346 ··· 1469 1453 kobject_init(&d->kobj, &bch_flash_dev_ktype); 1470 1454 1471 1455 if (bcache_device_init(d, block_bytes(c), u->sectors, 1472 - flash_dev_make_request)) 1456 + flash_dev_make_request, NULL)) 1473 1457 goto err; 1474 1458 1475 1459 bcache_device_attach(d, c, u - c->uuids); ··· 2380 2364 } 2381 2365 2382 2366 struct async_reg_args { 2383 - struct work_struct reg_work; 2367 + struct delayed_work reg_work; 2384 2368 char *path; 2385 2369 struct cache_sb *sb; 2386 2370 struct cache_sb_disk *sb_disk; ··· 2391 2375 { 2392 2376 int fail = false; 2393 2377 struct async_reg_args *args = 2394 - container_of(work, struct async_reg_args, reg_work); 2378 + container_of(work, struct async_reg_args, reg_work.work); 2395 2379 struct cached_dev *dc; 2396 2380 2397 2381 dc = kzalloc(sizeof(*dc), GFP_KERNEL); ··· 2421 2405 { 2422 2406 int fail = false; 2423 2407 struct async_reg_args *args = 2424 - container_of(work, struct async_reg_args, reg_work); 2408 + container_of(work, struct async_reg_args, reg_work.work); 2425 2409 struct cache *ca; 2426 2410 2427 2411 ca = kzalloc(sizeof(*ca), GFP_KERNEL); ··· 2449 2433 static void register_device_aync(struct async_reg_args *args) 2450 2434 { 2451 2435 if (SB_IS_BDEV(args->sb)) 2452 - INIT_WORK(&args->reg_work, register_bdev_worker); 2436 + INIT_DELAYED_WORK(&args->reg_work, register_bdev_worker); 2453 2437 else 2454 - INIT_WORK(&args->reg_work, register_cache_worker); 2438 + INIT_DELAYED_WORK(&args->reg_work, register_cache_worker); 2455 2439 2456 - queue_work(system_wq, &args->reg_work); 2440 + /* 10 jiffies is enough for a delay */ 2441 + queue_delayed_work(system_wq, &args->reg_work, 10); 2457 2442 } 2458 2443 2459 2444 static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
+1 -1
drivers/media/usb/pwc/pwc.h
··· 193 193 decompressor) */ 194 194 __u8 cmd[4]; /* the four byte of the command (in case of 195 195 nala, only the first 3 bytes is filled) */ 196 - __u8 rawframe[0]; /* frame_size = H / 4 * vbandlength */ 196 + __u8 rawframe[]; /* frame_size = H / 4 * vbandlength */ 197 197 } __packed; 198 198 199 199 /* intermediate buffers with raw data from the USB cam */
+1
drivers/mfd/mt6360-core.c
··· 412 412 413 413 static struct i2c_driver mt6360_pmu_driver = { 414 414 .driver = { 415 + .name = "mt6360_pmu", 415 416 .pm = &mt6360_pmu_pm_ops, 416 417 .of_match_table = of_match_ptr(mt6360_pmu_of_id), 417 418 },
+3 -3
drivers/misc/kgdbts.c
··· 828 828 char before[BREAK_INSTR_SIZE]; 829 829 char after[BREAK_INSTR_SIZE]; 830 830 831 - probe_kernel_read(before, (char *)kgdbts_break_test, 831 + copy_from_kernel_nofault(before, (char *)kgdbts_break_test, 832 832 BREAK_INSTR_SIZE); 833 833 init_simple_test(); 834 834 ts.tst = plant_and_detach_test; ··· 836 836 /* Activate test with initial breakpoint */ 837 837 if (!is_early) 838 838 kgdb_breakpoint(); 839 - probe_kernel_read(after, (char *)kgdbts_break_test, 840 - BREAK_INSTR_SIZE); 839 + copy_from_kernel_nofault(after, (char *)kgdbts_break_test, 840 + BREAK_INSTR_SIZE); 841 841 if (memcmp(before, after, BREAK_INSTR_SIZE)) { 842 842 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n"); 843 843 panic("kgdb memory corruption");
+2
drivers/net/bareudp.c
··· 552 552 static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf, 553 553 struct netlink_ext_ack *extack) 554 554 { 555 + memset(conf, 0, sizeof(*conf)); 556 + 555 557 if (!data[IFLA_BAREUDP_PORT]) { 556 558 NL_SET_ERR_MSG(extack, "port not specified"); 557 559 return -EINVAL;
+2 -2
drivers/net/can/peak_canfd/peak_pciefd_main.c
··· 146 146 __le32 irq_status; 147 147 __le32 sys_time_low; 148 148 __le32 sys_time_high; 149 - struct pucan_rx_msg msg[0]; 149 + struct pucan_rx_msg msg[]; 150 150 } __packed __aligned(4); 151 151 152 152 /* Tx Link record */ ··· 194 194 struct pci_dev *pci_dev; 195 195 int can_count; 196 196 spinlock_t cmd_lock; /* 64-bits cmds must be atomic */ 197 - struct pciefd_can *can[0]; /* array of network devices */ 197 + struct pciefd_can *can[]; /* array of network devices */ 198 198 }; 199 199 200 200 /* supported device ids. */
+4 -4
drivers/net/dsa/sja1105/sja1105_ptp.c
··· 891 891 892 892 mutex_lock(&ptp_data->lock); 893 893 894 - rc = sja1105_ptpclkval_read(priv, &ticks, NULL); 894 + rc = sja1105_ptpegr_ts_poll(ds, port, &ts); 895 895 if (rc < 0) { 896 - dev_err(ds->dev, "Failed to read PTP clock: %d\n", rc); 896 + dev_err(ds->dev, "timed out polling for tstamp\n"); 897 897 kfree_skb(skb); 898 898 goto out; 899 899 } 900 900 901 - rc = sja1105_ptpegr_ts_poll(ds, port, &ts); 901 + rc = sja1105_ptpclkval_read(priv, &ticks, NULL); 902 902 if (rc < 0) { 903 - dev_err(ds->dev, "timed out polling for tstamp\n"); 903 + dev_err(ds->dev, "Failed to read PTP clock: %d\n", rc); 904 904 kfree_skb(skb); 905 905 goto out; 906 906 }
+5 -4
drivers/net/ethernet/atheros/alx/main.c
··· 1249 1249 1250 1250 static void __alx_stop(struct alx_priv *alx) 1251 1251 { 1252 - alx_halt(alx); 1253 1252 alx_free_irq(alx); 1253 + 1254 + cancel_work_sync(&alx->link_check_wk); 1255 + cancel_work_sync(&alx->reset_wk); 1256 + 1257 + alx_halt(alx); 1254 1258 alx_free_rings(alx); 1255 1259 alx_free_napis(alx); 1256 1260 } ··· 1858 1854 { 1859 1855 struct alx_priv *alx = pci_get_drvdata(pdev); 1860 1856 struct alx_hw *hw = &alx->hw; 1861 - 1862 - cancel_work_sync(&alx->link_check_wk); 1863 - cancel_work_sync(&alx->reset_wk); 1864 1857 1865 1858 /* restore permanent mac address */ 1866 1859 alx_set_macaddr(hw, hw->perm_addr);
+17 -18
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 10037 10037 struct bnxt *bp = from_timer(bp, t, timer); 10038 10038 struct net_device *dev = bp->dev; 10039 10039 10040 - if (!netif_running(dev)) 10040 + if (!netif_running(dev) || !test_bit(BNXT_STATE_OPEN, &bp->state)) 10041 10041 return; 10042 10042 10043 10043 if (atomic_read(&bp->intr_sem) != 0) ··· 12133 12133 goto resume_exit; 12134 12134 } 12135 12135 12136 - if (bnxt_hwrm_queue_qportcfg(bp)) { 12137 - rc = -ENODEV; 12136 + rc = bnxt_hwrm_func_qcaps(bp); 12137 + if (rc) 12138 12138 goto resume_exit; 12139 - } 12140 - 12141 - if (bp->hwrm_spec_code >= 0x10803) { 12142 - if (bnxt_alloc_ctx_mem(bp)) { 12143 - rc = -ENODEV; 12144 - goto resume_exit; 12145 - } 12146 - } 12147 - if (BNXT_NEW_RM(bp)) 12148 - bnxt_hwrm_func_resc_qcaps(bp, false); 12149 12139 12150 12140 if (bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, false)) { 12151 12141 rc = -ENODEV; ··· 12151 12161 12152 12162 resume_exit: 12153 12163 bnxt_ulp_start(bp, rc); 12164 + if (!rc) 12165 + bnxt_reenable_sriov(bp); 12154 12166 rtnl_unlock(); 12155 12167 return rc; 12156 12168 } ··· 12196 12204 bnxt_close(netdev); 12197 12205 12198 12206 pci_disable_device(pdev); 12207 + bnxt_free_ctx_mem(bp); 12208 + kfree(bp->ctx); 12209 + bp->ctx = NULL; 12199 12210 rtnl_unlock(); 12200 12211 12201 12212 /* Request a slot slot reset. */ ··· 12232 12237 pci_set_master(pdev); 12233 12238 12234 12239 err = bnxt_hwrm_func_reset(bp); 12235 - if (!err && netif_running(netdev)) 12236 - err = bnxt_open(netdev); 12237 - 12238 - if (!err) 12239 - result = PCI_ERS_RESULT_RECOVERED; 12240 + if (!err) { 12241 + err = bnxt_hwrm_func_qcaps(bp); 12242 + if (!err && netif_running(netdev)) 12243 + err = bnxt_open(netdev); 12244 + } 12240 12245 bnxt_ulp_start(bp, err); 12246 + if (!err) { 12247 + bnxt_reenable_sriov(bp); 12248 + result = PCI_ERS_RESULT_RECOVERED; 12249 + } 12241 12250 } 12242 12251 12243 12252 if (result != PCI_ERS_RESULT_RECOVERED) {
+4 -5
drivers/net/ethernet/cadence/macb_main.c
··· 2565 2565 if (bp->ptp_info) 2566 2566 bp->ptp_info->ptp_init(dev); 2567 2567 2568 + return 0; 2569 + 2568 2570 napi_exit: 2569 2571 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) 2570 2572 napi_disable(&queue->napi); 2571 2573 pm_exit: 2572 - if (err) { 2573 - pm_runtime_put_sync(&bp->pdev->dev); 2574 - return err; 2575 - } 2576 - return 0; 2574 + pm_runtime_put_sync(&bp->pdev->dev); 2575 + return err; 2577 2576 } 2578 2577 2579 2578 static int macb_close(struct net_device *dev)
+17 -4
drivers/net/ethernet/ibm/ibmvnic.c
··· 842 842 struct ibmvnic_adapter *adapter = netdev_priv(netdev); 843 843 unsigned long timeout = msecs_to_jiffies(30000); 844 844 int retry_count = 0; 845 + int retries = 10; 845 846 bool retry; 846 847 int rc; 847 848 848 849 do { 849 850 retry = false; 850 - if (retry_count > IBMVNIC_MAX_QUEUES) { 851 + if (retry_count > retries) { 851 852 netdev_warn(netdev, "Login attempts exceeded\n"); 852 853 return -1; 853 854 } ··· 863 862 864 863 if (!wait_for_completion_timeout(&adapter->init_done, 865 864 timeout)) { 866 - netdev_warn(netdev, "Login timed out\n"); 867 - return -1; 865 + netdev_warn(netdev, "Login timed out, retrying...\n"); 866 + retry = true; 867 + adapter->init_done_rc = 0; 868 + retry_count++; 869 + continue; 868 870 } 869 871 870 - if (adapter->init_done_rc == PARTIALSUCCESS) { 872 + if (adapter->init_done_rc == ABORTED) { 873 + netdev_warn(netdev, "Login aborted, retrying...\n"); 874 + retry = true; 875 + adapter->init_done_rc = 0; 876 + retry_count++; 877 + /* FW or device may be busy, so 878 + * wait a bit before retrying login 879 + */ 880 + msleep(500); 881 + } else if (adapter->init_done_rc == PARTIALSUCCESS) { 871 882 retry_count++; 872 883 release_sub_crqs(adapter, 1); 873 884
+13 -36
drivers/net/ethernet/intel/e1000/e1000_main.c
··· 151 151 __be16 proto, u16 vid); 152 152 static void e1000_restore_vlan(struct e1000_adapter *adapter); 153 153 154 - #ifdef CONFIG_PM 155 - static int e1000_suspend(struct pci_dev *pdev, pm_message_t state); 156 - static int e1000_resume(struct pci_dev *pdev); 157 - #endif 154 + static int __maybe_unused e1000_suspend(struct device *dev); 155 + static int __maybe_unused e1000_resume(struct device *dev); 158 156 static void e1000_shutdown(struct pci_dev *pdev); 159 157 160 158 #ifdef CONFIG_NET_POLL_CONTROLLER ··· 177 179 .resume = e1000_io_resume, 178 180 }; 179 181 182 + static SIMPLE_DEV_PM_OPS(e1000_pm_ops, e1000_suspend, e1000_resume); 183 + 180 184 static struct pci_driver e1000_driver = { 181 185 .name = e1000_driver_name, 182 186 .id_table = e1000_pci_tbl, 183 187 .probe = e1000_probe, 184 188 .remove = e1000_remove, 185 - #ifdef CONFIG_PM 186 - /* Power Management Hooks */ 187 - .suspend = e1000_suspend, 188 - .resume = e1000_resume, 189 - #endif 189 + .driver = { 190 + .pm = &e1000_pm_ops, 191 + }, 190 192 .shutdown = e1000_shutdown, 191 193 .err_handler = &e1000_err_handler 192 194 }; ··· 5058 5060 struct e1000_hw *hw = &adapter->hw; 5059 5061 u32 ctrl, ctrl_ext, rctl, status; 5060 5062 u32 wufc = adapter->wol; 5061 - #ifdef CONFIG_PM 5062 - int retval = 0; 5063 - #endif 5064 5063 5065 5064 netif_device_detach(netdev); 5066 5065 ··· 5070 5075 WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); 5071 5076 e1000_down(adapter); 5072 5077 } 5073 - 5074 - #ifdef CONFIG_PM 5075 - retval = pci_save_state(pdev); 5076 - if (retval) 5077 - return retval; 5078 - #endif 5079 5078 5080 5079 status = er32(STATUS); 5081 5080 if (status & E1000_STATUS_LU) ··· 5131 5142 return 0; 5132 5143 } 5133 5144 5134 - #ifdef CONFIG_PM 5135 - static int e1000_suspend(struct pci_dev *pdev, pm_message_t state) 5145 + static int __maybe_unused e1000_suspend(struct device *dev) 5136 5146 { 5137 5147 int retval; 5148 + struct pci_dev *pdev = to_pci_dev(dev); 5138 5149 bool wake; 5139 5150 5140 5151 retval = __e1000_shutdown(pdev, &wake); 5141 - if (retval) 5142 - return retval; 5152 + device_set_wakeup_enable(dev, wake); 5143 5153 5144 - if (wake) { 5145 - pci_prepare_to_sleep(pdev); 5146 - } else { 5147 - pci_wake_from_d3(pdev, false); 5148 - pci_set_power_state(pdev, PCI_D3hot); 5149 - } 5150 - 5151 - return 0; 5154 + return retval; 5152 5155 } 5153 5156 5154 - static int e1000_resume(struct pci_dev *pdev) 5157 + static int __maybe_unused e1000_resume(struct device *dev) 5155 5158 { 5159 + struct pci_dev *pdev = to_pci_dev(dev); 5156 5160 struct net_device *netdev = pci_get_drvdata(pdev); 5157 5161 struct e1000_adapter *adapter = netdev_priv(netdev); 5158 5162 struct e1000_hw *hw = &adapter->hw; 5159 5163 u32 err; 5160 - 5161 - pci_set_power_state(pdev, PCI_D0); 5162 - pci_restore_state(pdev); 5163 - pci_save_state(pdev); 5164 5164 5165 5165 if (adapter->need_ioport) 5166 5166 err = pci_enable_device(pdev); ··· 5187 5209 5188 5210 return 0; 5189 5211 } 5190 - #endif 5191 5212 5192 5213 static void e1000_shutdown(struct pci_dev *pdev) 5193 5214 {
+15 -15
drivers/net/ethernet/intel/e1000e/netdev.c
··· 6349 6349 pm_runtime_put_sync(netdev->dev.parent); 6350 6350 } 6351 6351 6352 - #ifdef CONFIG_PM_SLEEP 6353 6352 /* S0ix implementation */ 6354 6353 static void e1000e_s0ix_entry_flow(struct e1000_adapter *adapter) 6355 6354 { ··· 6570 6571 mac_data &= ~E1000_CTRL_EXT_FORCE_SMBUS; 6571 6572 ew32(CTRL_EXT, mac_data); 6572 6573 } 6573 - #endif /* CONFIG_PM_SLEEP */ 6574 6574 6575 6575 static int e1000e_pm_freeze(struct device *dev) 6576 6576 { ··· 6609 6611 struct net_device *netdev = pci_get_drvdata(pdev); 6610 6612 struct e1000_adapter *adapter = netdev_priv(netdev); 6611 6613 struct e1000_hw *hw = &adapter->hw; 6612 - u32 ctrl, ctrl_ext, rctl, status; 6613 - /* Runtime suspend should only enable wakeup for link changes */ 6614 - u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol; 6614 + u32 ctrl, ctrl_ext, rctl, status, wufc; 6615 6615 int retval = 0; 6616 + 6617 + /* Runtime suspend should only enable wakeup for link changes */ 6618 + if (runtime) 6619 + wufc = E1000_WUFC_LNKC; 6620 + else if (device_may_wakeup(&pdev->dev)) 6621 + wufc = adapter->wol; 6622 + else 6623 + wufc = 0; 6616 6624 6617 6625 status = er32(STATUS); 6618 6626 if (status & E1000_STATUS_LU) ··· 6676 6672 if (adapter->hw.phy.type == e1000_phy_igp_3) { 6677 6673 e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw); 6678 6674 } else if (hw->mac.type >= e1000_pch_lpt) { 6679 - if (!(wufc & (E1000_WUFC_EX | E1000_WUFC_MC | E1000_WUFC_BC))) 6675 + if (wufc && !(wufc & (E1000_WUFC_EX | E1000_WUFC_MC | E1000_WUFC_BC))) 6680 6676 /* ULP does not support wake from unicast, multicast 6681 6677 * or broadcast. 6682 6678 */ ··· 6873 6869 return rc; 6874 6870 } 6875 6871 6876 - #ifdef CONFIG_PM 6877 6872 static int __e1000_resume(struct pci_dev *pdev) 6878 6873 { 6879 6874 struct net_device *netdev = pci_get_drvdata(pdev); ··· 6938 6935 return 0; 6939 6936 } 6940 6937 6941 - #ifdef CONFIG_PM_SLEEP 6942 - static int e1000e_pm_suspend(struct device *dev) 6938 + static __maybe_unused int e1000e_pm_suspend(struct device *dev) 6943 6939 { 6944 6940 struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev)); 6945 6941 struct e1000_adapter *adapter = netdev_priv(netdev); ··· 6962 6960 return rc; 6963 6961 } 6964 6962 6965 - static int e1000e_pm_resume(struct device *dev) 6963 + static __maybe_unused int e1000e_pm_resume(struct device *dev) 6966 6964 { 6967 6965 struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev)); 6968 6966 struct e1000_adapter *adapter = netdev_priv(netdev); ··· 6981 6979 6982 6980 return e1000e_pm_thaw(dev); 6983 6981 } 6984 - #endif /* CONFIG_PM_SLEEP */ 6985 6982 6986 - static int e1000e_pm_runtime_idle(struct device *dev) 6983 + static __maybe_unused int e1000e_pm_runtime_idle(struct device *dev) 6987 6984 { 6988 6985 struct net_device *netdev = dev_get_drvdata(dev); 6989 6986 struct e1000_adapter *adapter = netdev_priv(netdev); ··· 6998 6997 return -EBUSY; 6999 6998 } 7000 6999 7001 - static int e1000e_pm_runtime_resume(struct device *dev) 7000 + static __maybe_unused int e1000e_pm_runtime_resume(struct device *dev) 7002 7001 { 7003 7002 struct pci_dev *pdev = to_pci_dev(dev); 7004 7003 struct net_device *netdev = pci_get_drvdata(pdev); ··· 7015 7014 return rc; 7016 7015 } 7017 7016 7018 - static int e1000e_pm_runtime_suspend(struct device *dev) 7017 + static __maybe_unused int e1000e_pm_runtime_suspend(struct device *dev) 7019 7018 { 7020 7019 struct pci_dev *pdev = to_pci_dev(dev); 7021 7020 struct net_device *netdev = pci_get_drvdata(pdev); ··· 7040 7039 7041 7040 return 0; 7042 7041 } 7043 - #endif /* CONFIG_PM */ 7044 7042 7045 7043 static void e1000_shutdown(struct pci_dev *pdev) 7046 7044 {
+7 -4
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
··· 1544 1544 for (q = 0; q < port->ntxqs; q++) 1545 1545 for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_txq_regs); i++) 1546 1546 *pstats++ += mvpp2_read_index(port->priv, 1547 - MVPP22_CTRS_TX_CTR(port->id, i), 1547 + MVPP22_CTRS_TX_CTR(port->id, q), 1548 1548 mvpp2_ethtool_txq_regs[i].offset); 1549 1549 1550 1550 /* Rxqs are numbered from 0 from the user standpoint, but not from the ··· 1553 1553 for (q = 0; q < port->nrxqs; q++) 1554 1554 for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_rxq_regs); i++) 1555 1555 *pstats++ += mvpp2_read_index(port->priv, 1556 - port->first_rxq + i, 1556 + port->first_rxq + q, 1557 1557 mvpp2_ethtool_rxq_regs[i].offset); 1558 1558 } 1559 1559 ··· 5983 5983 { 5984 5984 struct mvpp2 *priv = platform_get_drvdata(pdev); 5985 5985 struct fwnode_handle *fwnode = pdev->dev.fwnode; 5986 + int i = 0, poolnum = MVPP2_BM_POOLS_NUM; 5986 5987 struct fwnode_handle *port_fwnode; 5987 - int i = 0; 5988 5988 5989 5989 mvpp2_dbgfs_cleanup(priv); 5990 5990 ··· 5998 5998 5999 5999 destroy_workqueue(priv->stats_queue); 6000 6000 6001 - for (i = 0; i < MVPP2_BM_POOLS_NUM; i++) { 6001 + if (priv->percpu_pools) 6002 + poolnum = mvpp2_get_nrxqs(priv) * 2; 6003 + 6004 + for (i = 0; i < poolnum; i++) { 6002 6005 struct mvpp2_bm_pool *bm_pool = &priv->bm_pools[i]; 6003 6006 6004 6007 mvpp2_bm_pool_destroy(&pdev->dev, priv, bm_pool);
+29 -89
drivers/net/ethernet/mediatek/mtk_star_emac.c
··· 24 24 #include <linux/regmap.h> 25 25 #include <linux/skbuff.h> 26 26 #include <linux/spinlock.h> 27 - #include <linux/workqueue.h> 28 27 29 28 #define MTK_STAR_DRVNAME "mtk_star_emac" 30 29 ··· 261 262 spinlock_t lock; 262 263 263 264 struct rtnl_link_stats64 stats; 264 - struct work_struct stats_work; 265 265 }; 266 266 267 267 static struct device *mtk_star_get_dev(struct mtk_star_priv *priv) ··· 428 430 static void mtk_star_intr_disable(struct mtk_star_priv *priv) 429 431 { 430 432 regmap_write(priv->regs, MTK_STAR_REG_INT_MASK, ~0); 431 - } 432 - 433 - static void mtk_star_intr_enable_tx(struct mtk_star_priv *priv) 434 - { 435 - regmap_clear_bits(priv->regs, MTK_STAR_REG_INT_MASK, 436 - MTK_STAR_BIT_INT_STS_TNTC); 437 - } 438 - 439 - static void mtk_star_intr_enable_rx(struct mtk_star_priv *priv) 440 - { 441 - regmap_clear_bits(priv->regs, MTK_STAR_REG_INT_MASK, 442 - MTK_STAR_BIT_INT_STS_FNRC); 443 - } 444 - 445 - static void mtk_star_intr_enable_stats(struct mtk_star_priv *priv) 446 - { 447 - regmap_clear_bits(priv->regs, MTK_STAR_REG_INT_MASK, 448 - MTK_STAR_REG_INT_STS_MIB_CNT_TH); 449 - } 450 - 451 - static void mtk_star_intr_disable_tx(struct mtk_star_priv *priv) 452 - { 453 - regmap_set_bits(priv->regs, MTK_STAR_REG_INT_MASK, 454 - MTK_STAR_BIT_INT_STS_TNTC); 455 - } 456 - 457 - static void mtk_star_intr_disable_rx(struct mtk_star_priv *priv) 458 - { 459 - regmap_set_bits(priv->regs, MTK_STAR_REG_INT_MASK, 460 - MTK_STAR_BIT_INT_STS_FNRC); 461 - } 462 - 463 - static void mtk_star_intr_disable_stats(struct mtk_star_priv *priv) 464 - { 465 - regmap_set_bits(priv->regs, MTK_STAR_REG_INT_MASK, 466 - MTK_STAR_REG_INT_STS_MIB_CNT_TH); 467 433 } 468 434 469 435 static unsigned int mtk_star_intr_read(struct mtk_star_priv *priv) ··· 625 663 stats->rx_errors += stats->rx_fifo_errors; 626 664 } 627 665 628 - /* This runs in process context and parallel TX and RX paths executing in 629 - * napi context may result in losing some stats data but this should happen 630 - * seldom enough to be acceptable. 631 - */ 632 - static void mtk_star_update_stats_work(struct work_struct *work) 633 - { 634 - struct mtk_star_priv *priv = container_of(work, struct mtk_star_priv, 635 - stats_work); 636 - 637 - mtk_star_update_stats(priv); 638 - mtk_star_reset_counters(priv); 639 - mtk_star_intr_enable_stats(priv); 640 - } 641 - 642 666 static struct sk_buff *mtk_star_alloc_skb(struct net_device *ndev) 643 667 { 644 668 uintptr_t tail, offset; ··· 715 767 mtk_star_ring_free_skbs(priv, ring, mtk_star_dma_unmap_tx); 716 768 } 717 769 718 - /* All processing for TX and RX happens in the napi poll callback. */ 770 + /* All processing for TX and RX happens in the napi poll callback. 771 + * 772 + * FIXME: The interrupt handling should be more fine-grained with each 773 + * interrupt enabled/disabled independently when needed. Unfortunatly this 774 + * turned out to impact the driver's stability and until we have something 775 + * working properly, we're disabling all interrupts during TX & RX processing 776 + * or when resetting the counter registers. 777 + */ 719 778 static irqreturn_t mtk_star_handle_irq(int irq, void *data) 720 779 { 721 780 struct mtk_star_priv *priv; 722 781 struct net_device *ndev; 723 - bool need_napi = false; 724 - unsigned int status; 725 782 726 783 ndev = data; 727 784 priv = netdev_priv(ndev); 728 785 729 786 if (netif_running(ndev)) { 730 - status = mtk_star_intr_read(priv); 731 - 732 - if (status & MTK_STAR_BIT_INT_STS_TNTC) { 733 - mtk_star_intr_disable_tx(priv); 734 - need_napi = true; 735 - } 736 - 737 - if (status & MTK_STAR_BIT_INT_STS_FNRC) { 738 - mtk_star_intr_disable_rx(priv); 739 - need_napi = true; 740 - } 741 - 742 - if (need_napi) 743 - napi_schedule(&priv->napi); 744 - 745 - /* One of the counters reached 0x8000000 - update stats and 746 - * reset all counters. 747 - */ 748 - if (unlikely(status & MTK_STAR_REG_INT_STS_MIB_CNT_TH)) { 749 - mtk_star_intr_disable_stats(priv); 750 - schedule_work(&priv->stats_work); 751 - } 752 - 753 - mtk_star_intr_ack_all(priv); 787 + mtk_star_intr_disable(priv); 788 + napi_schedule(&priv->napi); 754 789 } 755 790 756 791 return IRQ_HANDLED; ··· 1100 1169 if (wake && netif_queue_stopped(ndev)) 1101 1170 netif_wake_queue(ndev); 1102 1171 1103 - mtk_star_intr_enable_tx(priv); 1104 - 1105 1172 spin_unlock(&priv->lock); 1106 1173 } 1107 1174 ··· 1261 1332 static int mtk_star_poll(struct napi_struct *napi, int budget) 1262 1333 { 1263 1334 struct mtk_star_priv *priv; 1335 + unsigned int status; 1264 1336 int received = 0; 1265 1337 1266 1338 priv = container_of(napi, struct mtk_star_priv, napi); 1267 1339 1268 - /* Clean-up all TX descriptors. */ 1269 - mtk_star_tx_complete_all(priv); 1270 - /* Receive up to $budget packets. */ 1271 - received = mtk_star_process_rx(priv, budget); 1340 + status = mtk_star_intr_read(priv); 1341 + mtk_star_intr_ack_all(priv); 1272 1342 1273 - if (received < budget) { 1274 - napi_complete_done(napi, received); 1275 - mtk_star_intr_enable_rx(priv); 1343 + if (status & MTK_STAR_BIT_INT_STS_TNTC) 1344 + /* Clean-up all TX descriptors. */ 1345 + mtk_star_tx_complete_all(priv); 1346 + 1347 + if (status & MTK_STAR_BIT_INT_STS_FNRC) 1348 + /* Receive up to $budget packets. */ 1349 + received = mtk_star_process_rx(priv, budget); 1350 + 1351 + if (unlikely(status & MTK_STAR_REG_INT_STS_MIB_CNT_TH)) { 1352 + mtk_star_update_stats(priv); 1353 + mtk_star_reset_counters(priv); 1276 1354 } 1355 + 1356 + if (received < budget) 1357 + napi_complete_done(napi, received); 1358 + 1359 + mtk_star_intr_enable(priv); 1277 1360 1278 1361 return received; 1279 1362 } ··· 1473 1532 ndev->max_mtu = MTK_STAR_MAX_FRAME_SIZE; 1474 1533 1475 1534 spin_lock_init(&priv->lock); 1476 - INIT_WORK(&priv->stats_work, mtk_star_update_stats_work); 1477 1535 1478 1536 base = devm_platform_ioremap_resource(pdev, 0); 1479 1537 if (IS_ERR(base))
+6
drivers/net/ethernet/mellanox/mlx5/core/diag/rsc_dump.c
··· 23 23 MLX5_SGMT_STR_ASSING(SX_SLICE_ALL), 24 24 MLX5_SGMT_STR_ASSING(RDB), 25 25 MLX5_SGMT_STR_ASSING(RX_SLICE_ALL), 26 + MLX5_SGMT_STR_ASSING(PRM_QUERY_QP), 27 + MLX5_SGMT_STR_ASSING(PRM_QUERY_CQ), 28 + MLX5_SGMT_STR_ASSING(PRM_QUERY_MKEY), 26 29 }; 27 30 28 31 struct mlx5_rsc_dump { ··· 133 130 cmd->mem_size = key->size; 134 131 return cmd; 135 132 } 133 + EXPORT_SYMBOL(mlx5_rsc_dump_cmd_create); 136 134 137 135 void mlx5_rsc_dump_cmd_destroy(struct mlx5_rsc_dump_cmd *cmd) 138 136 { 139 137 kfree(cmd); 140 138 } 139 + EXPORT_SYMBOL(mlx5_rsc_dump_cmd_destroy); 141 140 142 141 int mlx5_rsc_dump_next(struct mlx5_core_dev *dev, struct mlx5_rsc_dump_cmd *cmd, 143 142 struct page *page, int *size) ··· 160 155 161 156 return more_dump; 162 157 } 158 + EXPORT_SYMBOL(mlx5_rsc_dump_next); 163 159 164 160 #define MLX5_RSC_DUMP_MENU_SEGMENT 0xffff 165 161 static int mlx5_rsc_dump_menu(struct mlx5_core_dev *dev)
+1 -32
drivers/net/ethernet/mellanox/mlx5/core/diag/rsc_dump.h
··· 4 4 #ifndef __MLX5_RSC_DUMP_H 5 5 #define __MLX5_RSC_DUMP_H 6 6 7 + #include <linux/mlx5/rsc_dump.h> 7 8 #include <linux/mlx5/driver.h> 8 9 #include "mlx5_core.h" 9 - 10 - enum mlx5_sgmt_type { 11 - MLX5_SGMT_TYPE_HW_CQPC, 12 - MLX5_SGMT_TYPE_HW_SQPC, 13 - MLX5_SGMT_TYPE_HW_RQPC, 14 - MLX5_SGMT_TYPE_FULL_SRQC, 15 - MLX5_SGMT_TYPE_FULL_CQC, 16 - MLX5_SGMT_TYPE_FULL_EQC, 17 - MLX5_SGMT_TYPE_FULL_QPC, 18 - MLX5_SGMT_TYPE_SND_BUFF, 19 - MLX5_SGMT_TYPE_RCV_BUFF, 20 - MLX5_SGMT_TYPE_SRQ_BUFF, 21 - MLX5_SGMT_TYPE_CQ_BUFF, 22 - MLX5_SGMT_TYPE_EQ_BUFF, 23 - MLX5_SGMT_TYPE_SX_SLICE, 24 - MLX5_SGMT_TYPE_SX_SLICE_ALL, 25 - MLX5_SGMT_TYPE_RDB, 26 - MLX5_SGMT_TYPE_RX_SLICE_ALL, 27 - MLX5_SGMT_TYPE_MENU, 28 - MLX5_SGMT_TYPE_TERMINATE, 29 - 30 - MLX5_SGMT_TYPE_NUM, /* Keep last */ 31 - }; 32 - 33 - struct mlx5_rsc_key { 34 - enum mlx5_sgmt_type rsc; 35 - int index1; 36 - int index2; 37 - int num_of_obj1; 38 - int num_of_obj2; 39 - int size; 40 - }; 41 10 42 11 #define MLX5_RSC_DUMP_ALL 0xFFFF 43 12 struct mlx5_rsc_dump_cmd;
+2
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
··· 978 978 979 979 lossy = !(pfc || pause_en); 980 980 thres_cells = mlxsw_sp_pg_buf_threshold_get(mlxsw_sp, mtu); 981 + mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, &thres_cells); 981 982 delay_cells = mlxsw_sp_pg_buf_delay_get(mlxsw_sp, mtu, delay, 982 983 pfc, pause_en); 984 + mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, &delay_cells); 983 985 total_cells = thres_cells + delay_cells; 984 986 985 987 taken_headroom_cells += total_cells;
+13
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
··· 374 374 return NULL; 375 375 } 376 376 377 + static inline void 378 + mlxsw_sp_port_headroom_8x_adjust(const struct mlxsw_sp_port *mlxsw_sp_port, 379 + u16 *p_size) 380 + { 381 + /* Ports with eight lanes use two headroom buffers between which the 382 + * configured headroom size is split. Therefore, multiply the calculated 383 + * headroom size by two. 384 + */ 385 + if (mlxsw_sp_port->mapping.width != 8) 386 + return; 387 + *p_size *= 2; 388 + } 389 + 377 390 enum mlxsw_sp_flood_type { 378 391 MLXSW_SP_FLOOD_TYPE_UC, 379 392 MLXSW_SP_FLOOD_TYPE_BC,
+1
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
··· 312 312 313 313 if (i == MLXSW_SP_PB_UNUSED) 314 314 continue; 315 + mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, &size); 315 316 mlxsw_reg_pbmc_lossy_buffer_pack(pbmc_pl, i, size); 316 317 } 317 318 mlxsw_reg_pbmc_lossy_buffer_pack(pbmc_pl,
+1
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
··· 782 782 speed = 0; 783 783 784 784 buffsize = mlxsw_sp_span_buffsize_get(mlxsw_sp, speed, mtu); 785 + mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, (u16 *) &buffsize); 785 786 mlxsw_reg_sbib_pack(sbib_pl, mlxsw_sp_port->local_port, buffsize); 786 787 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sbib), sbib_pl); 787 788 }
+2
drivers/net/ethernet/microchip/lan743x_main.c
··· 3091 3091 { 0, } 3092 3092 }; 3093 3093 3094 + MODULE_DEVICE_TABLE(pci, lan743x_pcidev_tbl); 3095 + 3094 3096 static struct pci_driver lan743x_pcidev_driver = { 3095 3097 .name = DRIVER_NAME, 3096 3098 .id_table = lan743x_pcidev_tbl,
+17 -17
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
··· 269 269 struct bin_attribute *attr, char *buf, 270 270 loff_t offset, size_t size) 271 271 { 272 - struct device *dev = container_of(kobj, struct device, kobj); 272 + struct device *dev = kobj_to_dev(kobj); 273 273 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 274 274 int ret; 275 275 ··· 286 286 struct bin_attribute *attr, char *buf, 287 287 loff_t offset, size_t size) 288 288 { 289 - struct device *dev = container_of(kobj, struct device, kobj); 289 + struct device *dev = kobj_to_dev(kobj); 290 290 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 291 291 int ret; 292 292 ··· 315 315 struct bin_attribute *attr, char *buf, 316 316 loff_t offset, size_t size) 317 317 { 318 - struct device *dev = container_of(kobj, struct device, kobj); 318 + struct device *dev = kobj_to_dev(kobj); 319 319 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 320 320 u64 data; 321 321 int ret; ··· 337 337 struct bin_attribute *attr, char *buf, 338 338 loff_t offset, size_t size) 339 339 { 340 - struct device *dev = container_of(kobj, struct device, kobj); 340 + struct device *dev = kobj_to_dev(kobj); 341 341 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 342 342 u64 data; 343 343 int ret; ··· 402 402 char *buf, loff_t offset, 403 403 size_t size) 404 404 { 405 - struct device *dev = container_of(kobj, struct device, kobj); 405 + struct device *dev = kobj_to_dev(kobj); 406 406 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 407 407 struct qlcnic_pm_func_cfg *pm_cfg; 408 408 u32 id, action, pci_func; ··· 452 452 char *buf, loff_t offset, 453 453 size_t size) 454 454 { 455 - struct device *dev = container_of(kobj, struct device, kobj); 455 + struct device *dev = kobj_to_dev(kobj); 456 456 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 457 457 struct qlcnic_pm_func_cfg *pm_cfg; 458 458 u8 pci_func; ··· 545 545 char *buf, loff_t offset, 546 546 size_t size) 547 547 { 548 - struct device *dev = container_of(kobj, struct device, kobj); 548 + struct device *dev = kobj_to_dev(kobj); 549 549 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 550 550 struct qlcnic_esw_func_cfg *esw_cfg; 551 551 struct qlcnic_npar_info *npar; ··· 629 629 char *buf, loff_t offset, 630 630 size_t size) 631 631 { 632 - struct device *dev = container_of(kobj, struct device, kobj); 632 + struct device *dev = kobj_to_dev(kobj); 633 633 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 634 634 struct qlcnic_esw_func_cfg *esw_cfg; 635 635 u8 pci_func; ··· 681 681 char *buf, loff_t offset, 682 682 size_t size) 683 683 { 684 - struct device *dev = container_of(kobj, struct device, kobj); 684 + struct device *dev = kobj_to_dev(kobj); 685 685 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 686 686 struct qlcnic_info nic_info; 687 687 struct qlcnic_npar_func_cfg *np_cfg; ··· 728 728 char *buf, loff_t offset, 729 729 size_t size) 730 730 { 731 - struct device *dev = container_of(kobj, struct device, kobj); 731 + struct device *dev = kobj_to_dev(kobj); 732 732 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 733 733 struct qlcnic_npar_func_cfg *np_cfg; 734 734 struct qlcnic_info nic_info; ··· 775 775 char *buf, loff_t offset, 776 776 size_t size) 777 777 { 778 - struct device *dev = container_of(kobj, struct device, kobj); 778 + struct device *dev = kobj_to_dev(kobj); 779 779 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 780 780 struct qlcnic_esw_statistics port_stats; 781 781 int ret; ··· 810 810 char *buf, loff_t offset, 811 811 size_t size) 812 812 { 813 - struct device *dev = container_of(kobj, struct device, kobj); 813 + struct device *dev = kobj_to_dev(kobj); 814 814 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 815 815 struct qlcnic_esw_statistics esw_stats; 816 816 int ret; ··· 845 845 char *buf, loff_t offset, 846 846 size_t size) 847 847 { 848 - struct device *dev = container_of(kobj, struct device, kobj); 848 + struct device *dev = kobj_to_dev(kobj); 849 849 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 850 850 int ret; 851 851 ··· 875 875 size_t size) 876 876 { 877 877 878 - struct device *dev = container_of(kobj, struct device, kobj); 878 + struct device *dev = kobj_to_dev(kobj); 879 879 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 880 880 int ret; 881 881 ··· 904 904 char *buf, loff_t offset, 905 905 size_t size) 906 906 { 907 - struct device *dev = container_of(kobj, struct device, kobj); 907 + struct device *dev = kobj_to_dev(kobj); 908 908 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 909 909 struct qlcnic_pci_func_cfg *pci_cfg; 910 910 struct qlcnic_pci_info *pci_info; ··· 946 946 { 947 947 unsigned char *p_read_buf; 948 948 int ret, count; 949 - struct device *dev = container_of(kobj, struct device, kobj); 949 + struct device *dev = kobj_to_dev(kobj); 950 950 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 951 951 952 952 if (!size) ··· 1124 1124 int ret; 1125 1125 static int flash_mode; 1126 1126 unsigned long data; 1127 - struct device *dev = container_of(kobj, struct device, kobj); 1127 + struct device *dev = kobj_to_dev(kobj); 1128 1128 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 1129 1129 1130 1130 ret = kstrtoul(buf, 16, &data);
+2 -2
drivers/net/ethernet/rocker/rocker_main.c
··· 647 647 err_dma_event_ring_bufs_alloc: 648 648 rocker_dma_ring_destroy(rocker, &rocker->event_ring); 649 649 err_dma_event_ring_create: 650 + rocker_dma_cmd_ring_waits_free(rocker); 651 + err_dma_cmd_ring_waits_alloc: 650 652 rocker_dma_ring_bufs_free(rocker, &rocker->cmd_ring, 651 653 PCI_DMA_BIDIRECTIONAL); 652 - err_dma_cmd_ring_waits_alloc: 653 - rocker_dma_cmd_ring_waits_free(rocker); 654 654 err_dma_cmd_ring_bufs_alloc: 655 655 rocker_dma_ring_destroy(rocker, &rocker->cmd_ring); 656 656 return err;
+1 -1
drivers/net/ethernet/xilinx/xilinx_axienet.h
··· 186 186 #define XAE_RAF_TXVSTRPMODE_MASK 0x00000180 /* Tx VLAN STRIP mode */ 187 187 #define XAE_RAF_RXVSTRPMODE_MASK 0x00000600 /* Rx VLAN STRIP mode */ 188 188 #define XAE_RAF_NEWFNCENBL_MASK 0x00000800 /* New function mode */ 189 - /* Exteneded Multicast Filtering mode */ 189 + /* Extended Multicast Filtering mode */ 190 190 #define XAE_RAF_EMULTIFLTRENBL_MASK 0x00001000 191 191 #define XAE_RAF_STATSRST_MASK 0x00002000 /* Stats. Counter Reset */ 192 192 #define XAE_RAF_RXBADFRMEN_MASK 0x00004000 /* Recv Bad Frame Enable */
+2 -12
drivers/nvdimm/region_devs.c
··· 679 679 return a->mode; 680 680 } 681 681 682 - if (a == &dev_attr_align.attr) { 683 - int i; 684 - 685 - for (i = 0; i < nd_region->ndr_mappings; i++) { 686 - struct nd_mapping *nd_mapping = &nd_region->mapping[i]; 687 - struct nvdimm *nvdimm = nd_mapping->nvdimm; 688 - 689 - if (test_bit(NDD_LABELING, &nvdimm->flags)) 690 - return a->mode; 691 - } 692 - return 0; 693 - } 682 + if (a == &dev_attr_align.attr) 683 + return a->mode; 694 684 695 685 if (a != &dev_attr_set_cookie.attr 696 686 && a != &dev_attr_available_size.attr)
+1 -1
drivers/oprofile/cpu_buffer.h
··· 33 33 struct op_sample { 34 34 unsigned long eip; 35 35 unsigned long event; 36 - unsigned long data[0]; 36 + unsigned long data[]; 37 37 }; 38 38 39 39 struct op_entry;
+1 -1
drivers/phy/samsung/phy-samsung-usb2.h
··· 43 43 struct regmap *reg_pmu; 44 44 struct regmap *reg_sys; 45 45 spinlock_t lock; 46 - struct samsung_usb2_phy_instance instances[0]; 46 + struct samsung_usb2_phy_instance instances[]; 47 47 }; 48 48 49 49 struct samsung_usb2_common_phy {
+3 -4
drivers/pinctrl/freescale/pinctrl-imx.c
··· 824 824 return -EINVAL; 825 825 } 826 826 827 - ipctl->input_sel_base = devm_of_iomap(&pdev->dev, np, 828 - 0, NULL); 827 + ipctl->input_sel_base = of_iomap(np, 0); 829 828 of_node_put(np); 830 - if (IS_ERR(ipctl->input_sel_base)) { 829 + if (!ipctl->input_sel_base) { 831 830 dev_err(&pdev->dev, 832 831 "iomuxc input select base address not found\n"); 833 - return PTR_ERR(ipctl->input_sel_base); 832 + return -ENOMEM; 834 833 } 835 834 } 836 835 }
+1 -4
drivers/pinctrl/pinctrl-mcp23s08_spi.c
··· 126 126 copy->name = name; 127 127 128 128 mcp->regmap = devm_regmap_init(dev, &mcp23sxx_spi_regmap, mcp, copy); 129 - if (IS_ERR(mcp->regmap)) 130 - return PTR_ERR(mcp->regmap); 131 - 132 - return 0; 129 + return PTR_ERR_OR_ZERO(mcp->regmap); 133 130 } 134 131 135 132 static int mcp23s08_probe(struct spi_device *spi)
+1 -1
drivers/pinctrl/pinctrl-single.c
··· 958 958 } 959 959 960 960 /** 961 - * smux_parse_one_pinctrl_entry() - parses a device tree mux entry 961 + * pcs_parse_one_pinctrl_entry() - parses a device tree mux entry 962 962 * @pctldev: pin controller device 963 963 * @pcs: pinctrl driver instance 964 964 * @np: device node of the mux entry
+2 -1
drivers/pinctrl/qcom/pinctrl-ipq6018.c
··· 367 367 368 368 static const char * const qpic_pad_groups[] = { 369 369 "gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio9", "gpio10", 370 - "gpio11", "gpio17", 370 + "gpio11", "gpio17", "gpio15", "gpio12", "gpio13", "gpio14", "gpio5", 371 + "gpio6", "gpio7", "gpio8", 371 372 }; 372 373 373 374 static const char * const burn0_groups[] = {
+10 -11
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
··· 170 170 struct regmap *map; 171 171 struct pinctrl_dev *ctrl; 172 172 struct gpio_chip chip; 173 + struct irq_chip irq; 173 174 }; 174 175 175 176 static const struct pinconf_generic_params pmic_gpio_bindings[] = { ··· 918 917 return 0; 919 918 } 920 919 921 - static struct irq_chip pmic_gpio_irq_chip = { 922 - .name = "spmi-gpio", 923 - .irq_ack = irq_chip_ack_parent, 924 - .irq_mask = irq_chip_mask_parent, 925 - .irq_unmask = irq_chip_unmask_parent, 926 - .irq_set_type = irq_chip_set_type_parent, 927 - .irq_set_wake = irq_chip_set_wake_parent, 928 - .flags = IRQCHIP_MASK_ON_SUSPEND, 929 - }; 930 - 931 920 static int pmic_gpio_domain_translate(struct irq_domain *domain, 932 921 struct irq_fwspec *fwspec, 933 922 unsigned long *hwirq, ··· 1044 1053 if (!parent_domain) 1045 1054 return -ENXIO; 1046 1055 1056 + state->irq.name = "spmi-gpio", 1057 + state->irq.irq_ack = irq_chip_ack_parent, 1058 + state->irq.irq_mask = irq_chip_mask_parent, 1059 + state->irq.irq_unmask = irq_chip_unmask_parent, 1060 + state->irq.irq_set_type = irq_chip_set_type_parent, 1061 + state->irq.irq_set_wake = irq_chip_set_wake_parent, 1062 + state->irq.flags = IRQCHIP_MASK_ON_SUSPEND, 1063 + 1047 1064 girq = &state->chip.irq; 1048 - girq->chip = &pmic_gpio_irq_chip; 1065 + girq->chip = &state->irq; 1049 1066 girq->default_type = IRQ_TYPE_NONE; 1050 1067 girq->handler = handle_level_irq; 1051 1068 girq->fwnode = of_node_to_fwnode(state->dev->of_node);
+2 -2
drivers/pinctrl/tegra/pinctrl-tegra.c
··· 731 731 } 732 732 733 733 const struct dev_pm_ops tegra_pinctrl_pm = { 734 - .suspend = &tegra_pinctrl_suspend, 735 - .resume = &tegra_pinctrl_resume 734 + .suspend_noirq = &tegra_pinctrl_suspend, 735 + .resume_noirq = &tegra_pinctrl_resume 736 736 }; 737 737 738 738 static bool tegra_pinctrl_gpio_node_has_range(struct tegra_pmx *pmx)
+1 -1
drivers/rapidio/rio-scan.c
··· 39 39 u16 start; /* logical minimal id */ 40 40 u32 max; /* max number of IDs in table */ 41 41 spinlock_t lock; 42 - unsigned long table[0]; 42 + unsigned long table[]; 43 43 }; 44 44 45 45 static int next_destid = 0;
+3 -4
drivers/s390/cio/qdio.h
··· 182 182 }; 183 183 184 184 struct qdio_input_q { 185 - /* first ACK'ed buffer */ 186 - int ack_start; 187 - /* how many SBALs are acknowledged */ 188 - int ack_count; 185 + /* Batch of SBALs that we processed while polling the queue: */ 186 + unsigned int batch_start; 187 + unsigned int batch_count; 189 188 /* last time of noticing incoming data */ 190 189 u64 timestamp; 191 190 };
+2 -2
drivers/s390/cio/qdio_debug.c
··· 110 110 seq_printf(m, "nr_used: %d ftc: %d\n", 111 111 atomic_read(&q->nr_buf_used), q->first_to_check); 112 112 if (q->is_input_q) { 113 - seq_printf(m, "ack start: %d ack count: %d\n", 114 - q->u.in.ack_start, q->u.in.ack_count); 113 + seq_printf(m, "batch start: %u batch count: %u\n", 114 + q->u.in.batch_start, q->u.in.batch_count); 115 115 seq_printf(m, "DSCI: %x IRQs disabled: %u\n", 116 116 *(u8 *)q->irq_ptr->dsci, 117 117 test_bit(QDIO_IRQ_DISABLED,
+41 -60
drivers/s390/cio/qdio_main.c
··· 254 254 if (is_qebsm(q)) 255 255 return qdio_do_sqbs(q, state, bufnr, count); 256 256 257 + /* Ensure that all preceding changes to the SBALs are visible: */ 258 + mb(); 259 + 257 260 for (i = 0; i < count; i++) { 258 - xchg(&q->slsb.val[bufnr], state); 261 + WRITE_ONCE(q->slsb.val[bufnr], state); 259 262 bufnr = next_buf(bufnr); 260 263 } 264 + 265 + /* Make our SLSB changes visible: */ 266 + mb(); 267 + 261 268 return count; 262 269 } 263 270 ··· 400 393 401 394 static inline void qdio_stop_polling(struct qdio_q *q) 402 395 { 403 - if (!q->u.in.ack_count) 396 + if (!q->u.in.batch_count) 404 397 return; 405 398 406 399 qperf_inc(q, stop_polling); 407 400 408 401 /* show the card that we are not polling anymore */ 409 - set_buf_states(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT, 410 - q->u.in.ack_count); 411 - q->u.in.ack_count = 0; 402 + set_buf_states(q, q->u.in.batch_start, SLSB_P_INPUT_NOT_INIT, 403 + q->u.in.batch_count); 404 + q->u.in.batch_count = 0; 412 405 } 413 406 414 407 static inline void account_sbals(struct qdio_q *q, unsigned int count) ··· 448 441 static inline void inbound_handle_work(struct qdio_q *q, unsigned int start, 449 442 int count, bool auto_ack) 450 443 { 451 - int new; 444 + /* ACK the newest SBAL: */ 445 + if (!auto_ack) 446 + set_buf_state(q, add_buf(start, count - 1), SLSB_P_INPUT_ACK); 452 447 453 - if (auto_ack) { 454 - if (!q->u.in.ack_count) { 455 - q->u.in.ack_count = count; 456 - q->u.in.ack_start = start; 457 - return; 458 - } 459 - 460 - /* delete the previous ACK's */ 461 - set_buf_states(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT, 462 - q->u.in.ack_count); 463 - q->u.in.ack_count = count; 464 - q->u.in.ack_start = start; 465 - return; 466 - } 467 - 468 - /* 469 - * ACK the newest buffer. The ACK will be removed in qdio_stop_polling 470 - * or by the next inbound run. 471 - */ 472 - new = add_buf(start, count - 1); 473 - set_buf_state(q, new, SLSB_P_INPUT_ACK); 474 - 475 - /* delete the previous ACKs */ 476 - if (q->u.in.ack_count) 477 - set_buf_states(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT, 478 - q->u.in.ack_count); 479 - 480 - q->u.in.ack_count = 1; 481 - q->u.in.ack_start = new; 482 - count--; 483 - if (!count) 484 - return; 485 - /* need to change ALL buffers to get more interrupts */ 486 - set_buf_states(q, start, SLSB_P_INPUT_NOT_INIT, count); 448 + if (!q->u.in.batch_count) 449 + q->u.in.batch_start = start; 450 + q->u.in.batch_count += count; 487 451 } 488 452 489 453 static int get_inbound_buffer_frontier(struct qdio_q *q, unsigned int start) ··· 503 525 account_sbals_error(q, count); 504 526 return count; 505 527 case SLSB_CU_INPUT_EMPTY: 506 - case SLSB_P_INPUT_NOT_INIT: 507 - case SLSB_P_INPUT_ACK: 508 528 if (q->irq_ptr->perf_stat_enabled) 509 529 q->q_stats.nr_sbal_nop++; 510 530 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in nop:%1d %#02x", 511 531 q->nr, start); 512 532 return 0; 533 + case SLSB_P_INPUT_NOT_INIT: 534 + case SLSB_P_INPUT_ACK: 535 + /* We should never see this state, throw a WARN: */ 513 536 default: 514 - WARN_ON_ONCE(1); 537 + dev_WARN_ONCE(&q->irq_ptr->cdev->dev, 1, 538 + "found state %#x at index %u on queue %u\n", 539 + state, start, q->nr); 515 540 return 0; 516 541 } 517 542 } ··· 719 738 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "out primed:%1d", 720 739 q->nr); 721 740 return 0; 722 - case SLSB_P_OUTPUT_NOT_INIT: 723 741 case SLSB_P_OUTPUT_HALTED: 724 742 return 0; 743 + case SLSB_P_OUTPUT_NOT_INIT: 744 + /* We should never see this state, throw a WARN: */ 725 745 default: 726 - WARN_ON_ONCE(1); 746 + dev_WARN_ONCE(&q->irq_ptr->cdev->dev, 1, 747 + "found state %#x at index %u on queue %u\n", 748 + state, start, q->nr); 727 749 return 0; 728 750 } 729 751 } ··· 922 938 } 923 939 } 924 940 925 - static void qdio_handle_activate_check(struct ccw_device *cdev, 926 - unsigned long intparm, int cstat, int dstat) 941 + static void qdio_handle_activate_check(struct qdio_irq *irq_ptr, 942 + unsigned long intparm, int cstat, 943 + int dstat) 927 944 { 928 - struct qdio_irq *irq_ptr = cdev->private->qdio_data; 929 945 struct qdio_q *q; 930 946 931 947 DBF_ERROR("%4x ACT CHECK", irq_ptr->schid.sch_no); ··· 952 968 lgr_info_log(); 953 969 } 954 970 955 - static void qdio_establish_handle_irq(struct ccw_device *cdev, int cstat, 971 + static void qdio_establish_handle_irq(struct qdio_irq *irq_ptr, int cstat, 956 972 int dstat) 957 973 { 958 - struct qdio_irq *irq_ptr = cdev->private->qdio_data; 959 - 960 974 DBF_DEV_EVENT(DBF_INFO, irq_ptr, "qest irq"); 961 975 962 976 if (cstat) ··· 1001 1019 1002 1020 switch (irq_ptr->state) { 1003 1021 case QDIO_IRQ_STATE_INACTIVE: 1004 - qdio_establish_handle_irq(cdev, cstat, dstat); 1022 + qdio_establish_handle_irq(irq_ptr, cstat, dstat); 1005 1023 break; 1006 1024 case QDIO_IRQ_STATE_CLEANUP: 1007 1025 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE); ··· 1013 1031 return; 1014 1032 } 1015 1033 if (cstat || dstat) 1016 - qdio_handle_activate_check(cdev, intparm, cstat, 1034 + qdio_handle_activate_check(irq_ptr, intparm, cstat, 1017 1035 dstat); 1018 1036 break; 1019 1037 case QDIO_IRQ_STATE_STOPPED: ··· 1428 1446 1429 1447 qperf_inc(q, inbound_call); 1430 1448 1431 - /* If any ACKed SBALs are returned to HW, adjust ACK tracking: */ 1432 - overlap = min(count - sub_buf(q->u.in.ack_start, bufnr), 1433 - q->u.in.ack_count); 1449 + /* If any processed SBALs are returned to HW, adjust our tracking: */ 1450 + overlap = min_t(int, count - sub_buf(q->u.in.batch_start, bufnr), 1451 + q->u.in.batch_count); 1434 1452 if (overlap > 0) { 1435 - q->u.in.ack_start = add_buf(q->u.in.ack_start, overlap); 1436 - q->u.in.ack_count -= overlap; 1453 + q->u.in.batch_start = add_buf(q->u.in.batch_start, overlap); 1454 + q->u.in.batch_count -= overlap; 1437 1455 } 1438 1456 1439 1457 count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count); ··· 1517 1535 int do_QDIO(struct ccw_device *cdev, unsigned int callflags, 1518 1536 int q_nr, unsigned int bufnr, unsigned int count) 1519 1537 { 1520 - struct qdio_irq *irq_ptr; 1538 + struct qdio_irq *irq_ptr = cdev->private->qdio_data; 1521 1539 1522 1540 if (bufnr >= QDIO_MAX_BUFFERS_PER_Q || count > QDIO_MAX_BUFFERS_PER_Q) 1523 1541 return -EINVAL; 1524 1542 1525 - irq_ptr = cdev->private->qdio_data; 1526 1543 if (!irq_ptr) 1527 1544 return -ENODEV; 1528 1545
+1 -2
drivers/s390/crypto/zcrypt_ep11misc.c
··· 195 195 size_t len = sizeof(struct ep11_cprb) + payload_len; 196 196 struct ep11_cprb *cprb; 197 197 198 - cprb = kmalloc(len, GFP_KERNEL); 198 + cprb = kzalloc(len, GFP_KERNEL); 199 199 if (!cprb) 200 200 return NULL; 201 201 202 - memset(cprb, 0, len); 203 202 cprb->cprb_len = sizeof(struct ep11_cprb); 204 203 cprb->cprb_ver_id = 0x04; 205 204 memcpy(cprb->func_id, "T4", 2);
-26
drivers/s390/virtio/virtio_ccw.c
··· 1372 1372 {}, 1373 1373 }; 1374 1374 1375 - #ifdef CONFIG_PM_SLEEP 1376 - static int virtio_ccw_freeze(struct ccw_device *cdev) 1377 - { 1378 - struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev); 1379 - 1380 - return virtio_device_freeze(&vcdev->vdev); 1381 - } 1382 - 1383 - static int virtio_ccw_restore(struct ccw_device *cdev) 1384 - { 1385 - struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev); 1386 - int ret; 1387 - 1388 - ret = virtio_ccw_set_transport_rev(vcdev); 1389 - if (ret) 1390 - return ret; 1391 - 1392 - return virtio_device_restore(&vcdev->vdev); 1393 - } 1394 - #endif 1395 - 1396 1375 static struct ccw_driver virtio_ccw_driver = { 1397 1376 .driver = { 1398 1377 .owner = THIS_MODULE, ··· 1384 1405 .set_online = virtio_ccw_online, 1385 1406 .notify = virtio_ccw_cio_notify, 1386 1407 .int_class = IRQIO_VIR, 1387 - #ifdef CONFIG_PM_SLEEP 1388 - .freeze = virtio_ccw_freeze, 1389 - .thaw = virtio_ccw_restore, 1390 - .restore = virtio_ccw_restore, 1391 - #endif 1392 1408 }; 1393 1409 1394 1410 static int __init pure_hex(char **cp, unsigned int *val, int min_digit,
+1
drivers/scsi/aic94xx/aic94xx_init.c
··· 40 40 /* .name is initialized */ 41 41 .name = "aic94xx", 42 42 .queuecommand = sas_queuecommand, 43 + .dma_need_drain = ata_scsi_dma_need_drain, 43 44 .target_alloc = sas_target_alloc, 44 45 .slave_configure = sas_slave_configure, 45 46 .scan_finished = asd_scan_finished,
+1
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
··· 1756 1756 .proc_name = DRV_NAME, 1757 1757 .module = THIS_MODULE, 1758 1758 .queuecommand = sas_queuecommand, 1759 + .dma_need_drain = ata_scsi_dma_need_drain, 1759 1760 .target_alloc = sas_target_alloc, 1760 1761 .slave_configure = hisi_sas_slave_configure, 1761 1762 .scan_finished = hisi_sas_scan_finished,
+1
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
··· 3532 3532 .proc_name = DRV_NAME, 3533 3533 .module = THIS_MODULE, 3534 3534 .queuecommand = sas_queuecommand, 3535 + .dma_need_drain = ata_scsi_dma_need_drain, 3535 3536 .target_alloc = sas_target_alloc, 3536 3537 .slave_configure = hisi_sas_slave_configure, 3537 3538 .scan_finished = hisi_sas_scan_finished,
+1
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 3075 3075 .proc_name = DRV_NAME, 3076 3076 .module = THIS_MODULE, 3077 3077 .queuecommand = sas_queuecommand, 3078 + .dma_need_drain = ata_scsi_dma_need_drain, 3078 3079 .target_alloc = sas_target_alloc, 3079 3080 .slave_configure = hisi_sas_slave_configure, 3080 3081 .scan_finished = hisi_sas_scan_finished,
+1
drivers/scsi/ipr.c
··· 6731 6731 .compat_ioctl = ipr_ioctl, 6732 6732 #endif 6733 6733 .queuecommand = ipr_queuecommand, 6734 + .dma_need_drain = ata_scsi_dma_need_drain, 6734 6735 .eh_abort_handler = ipr_eh_abort, 6735 6736 .eh_device_reset_handler = ipr_eh_dev_reset, 6736 6737 .eh_host_reset_handler = ipr_eh_host_reset,
+1
drivers/scsi/isci/init.c
··· 153 153 .name = DRV_NAME, 154 154 .proc_name = DRV_NAME, 155 155 .queuecommand = sas_queuecommand, 156 + .dma_need_drain = ata_scsi_dma_need_drain, 156 157 .target_alloc = sas_target_alloc, 157 158 .slave_configure = sas_slave_configure, 158 159 .scan_finished = isci_host_scan_finished,
+1
drivers/scsi/mvsas/mv_init.c
··· 33 33 .module = THIS_MODULE, 34 34 .name = DRV_NAME, 35 35 .queuecommand = sas_queuecommand, 36 + .dma_need_drain = ata_scsi_dma_need_drain, 36 37 .target_alloc = sas_target_alloc, 37 38 .slave_configure = sas_slave_configure, 38 39 .scan_finished = mvs_scan_finished,
+1
drivers/scsi/pm8001/pm8001_init.c
··· 87 87 .module = THIS_MODULE, 88 88 .name = DRV_NAME, 89 89 .queuecommand = sas_queuecommand, 90 + .dma_need_drain = ata_scsi_dma_need_drain, 90 91 .target_alloc = sas_target_alloc, 91 92 .slave_configure = sas_slave_configure, 92 93 .scan_finished = pm8001_scan_finished,
+3 -1
drivers/scsi/ufs/ufs_bsg.c
··· 106 106 desc_op = bsg_request->upiu_req.qr.opcode; 107 107 ret = ufs_bsg_alloc_desc_buffer(hba, job, &desc_buff, 108 108 &desc_len, desc_op); 109 - if (ret) 109 + if (ret) { 110 + pm_runtime_put_sync(hba->dev); 110 111 goto out; 112 + } 111 113 112 114 /* fall through */ 113 115 case UPIU_TRANSACTION_NOP_OUT:
+1 -1
drivers/soc/ti/knav_qmss.h
··· 67 67 u32 link_ram_size0; 68 68 u32 link_ram_base1; 69 69 u32 __pad2[2]; 70 - u32 starvation[0]; 70 + u32 starvation[]; 71 71 }; 72 72 73 73 struct knav_reg_region {
+2 -2
drivers/video/backlight/tosa_lcd.c
··· 107 107 /* TG LCD GVSS */ 108 108 tosa_tg_send(spi, TG_PINICTL, 0x0); 109 109 110 - if (!data->i2c) { 110 + if (IS_ERR_OR_NULL(data->i2c)) { 111 111 /* 112 112 * after the pannel is powered up the first time, 113 113 * we can access the i2c bus so probe for the DAC ··· 119 119 .addr = DAC_BASE, 120 120 .platform_data = data->spi, 121 121 }; 122 - data->i2c = i2c_new_device(adap, &info); 122 + data->i2c = i2c_new_client_device(adap, &info); 123 123 } 124 124 } 125 125
+1 -1
drivers/video/fbdev/hpfb.c
··· 402 402 if (err) 403 403 return err; 404 404 405 - err = probe_kernel_read(&i, (unsigned char *)INTFBVADDR + DIO_IDOFF, 1); 405 + err = copy_from_kernel_nofault(&i, (unsigned char *)INTFBVADDR + DIO_IDOFF, 1); 406 406 407 407 if (!err && (i == DIO_ID_FBUFFER) && topcat_sid_ok(sid = DIO_SECID(INTFBVADDR))) { 408 408 if (!request_mem_region(INTFBPADDR, DIO_DEVSIZE, "Internal Topcat"))
+2 -2
drivers/w1/w1_netlink.h
··· 73 73 __u32 res; 74 74 } mst; 75 75 } id; 76 - __u8 data[0]; 76 + __u8 data[]; 77 77 }; 78 78 79 79 /** ··· 122 122 __u8 cmd; 123 123 __u8 res; 124 124 __u16 len; 125 - __u8 data[0]; 125 + __u8 data[]; 126 126 }; 127 127 128 128 #ifdef __KERNEL__
+56 -8
fs/afs/dir.c
··· 648 648 vp = &op->file[0]; 649 649 abort_code = vp->scb.status.abort_code; 650 650 if (abort_code != 0) { 651 - op->abort_code = abort_code; 651 + op->ac.abort_code = abort_code; 652 652 op->error = afs_abort_to_error(abort_code); 653 653 } 654 654 break; ··· 696 696 .success = afs_do_lookup_success, 697 697 }; 698 698 699 - static const struct afs_operation_ops afs_fetch_status_operation = { 699 + static const struct afs_operation_ops afs_lookup_fetch_status_operation = { 700 700 .issue_afs_rpc = afs_fs_fetch_status, 701 701 .issue_yfs_rpc = yfs_fs_fetch_status, 702 702 .success = afs_do_lookup_success, 703 + .aborted = afs_check_for_remote_deletion, 703 704 }; 704 705 705 706 /* ··· 845 844 * to FS.FetchStatus for op->file[1]. 846 845 */ 847 846 op->fetch_status.which = 1; 848 - op->ops = &afs_fetch_status_operation; 847 + op->ops = &afs_lookup_fetch_status_operation; 849 848 afs_begin_vnode_operation(op); 850 849 afs_wait_for_operation(op); 851 850 } ··· 1237 1236 _enter("%pd", dentry); 1238 1237 } 1239 1238 1239 + void afs_check_for_remote_deletion(struct afs_operation *op) 1240 + { 1241 + struct afs_vnode *vnode = op->file[0].vnode; 1242 + 1243 + switch (op->ac.abort_code) { 1244 + case VNOVNODE: 1245 + set_bit(AFS_VNODE_DELETED, &vnode->flags); 1246 + afs_break_callback(vnode, afs_cb_break_for_deleted); 1247 + } 1248 + } 1249 + 1240 1250 /* 1241 1251 * Create a new inode for create/mkdir/symlink 1242 1252 */ ··· 1280 1268 static void afs_create_success(struct afs_operation *op) 1281 1269 { 1282 1270 _enter("op=%08x", op->debug_id); 1283 - afs_check_for_remote_deletion(op, op->file[0].vnode); 1271 + op->ctime = op->file[0].scb.status.mtime_client; 1284 1272 afs_vnode_commit_status(op, &op->file[0]); 1285 1273 afs_update_dentry_version(op, &op->file[0], op->dentry); 1286 1274 afs_vnode_new_inode(op); ··· 1314 1302 .issue_afs_rpc = afs_fs_make_dir, 1315 1303 .issue_yfs_rpc = yfs_fs_make_dir, 1316 1304 .success = afs_create_success, 1305 + .aborted = afs_check_for_remote_deletion, 1317 1306 .edit_dir = afs_create_edit_dir, 1318 1307 .put = afs_create_put, 1319 1308 }; ··· 1338 1325 1339 1326 afs_op_set_vnode(op, 0, dvnode); 1340 1327 op->file[0].dv_delta = 1; 1328 + op->file[0].update_ctime = true; 1341 1329 op->dentry = dentry; 1342 1330 op->create.mode = S_IFDIR | mode; 1343 1331 op->create.reason = afs_edit_dir_for_mkdir; ··· 1364 1350 static void afs_rmdir_success(struct afs_operation *op) 1365 1351 { 1366 1352 _enter("op=%08x", op->debug_id); 1367 - afs_check_for_remote_deletion(op, op->file[0].vnode); 1353 + op->ctime = op->file[0].scb.status.mtime_client; 1368 1354 afs_vnode_commit_status(op, &op->file[0]); 1369 1355 afs_update_dentry_version(op, &op->file[0], op->dentry); 1370 1356 } ··· 1396 1382 .issue_afs_rpc = afs_fs_remove_dir, 1397 1383 .issue_yfs_rpc = yfs_fs_remove_dir, 1398 1384 .success = afs_rmdir_success, 1385 + .aborted = afs_check_for_remote_deletion, 1399 1386 .edit_dir = afs_rmdir_edit_dir, 1400 1387 .put = afs_rmdir_put, 1401 1388 }; ··· 1419 1404 1420 1405 afs_op_set_vnode(op, 0, dvnode); 1421 1406 op->file[0].dv_delta = 1; 1407 + op->file[0].update_ctime = true; 1422 1408 1423 1409 op->dentry = dentry; 1424 1410 op->ops = &afs_rmdir_operation; ··· 1495 1479 static void afs_unlink_success(struct afs_operation *op) 1496 1480 { 1497 1481 _enter("op=%08x", op->debug_id); 1498 - afs_check_for_remote_deletion(op, op->file[0].vnode); 1482 + op->ctime = op->file[0].scb.status.mtime_client; 1483 + afs_check_dir_conflict(op, &op->file[0]); 1499 1484 afs_vnode_commit_status(op, &op->file[0]); 1500 1485 afs_vnode_commit_status(op, &op->file[1]); 1501 1486 afs_update_dentry_version(op, &op->file[0], op->dentry); ··· 1528 1511 .issue_afs_rpc = afs_fs_remove_file, 1529 1512 .issue_yfs_rpc = yfs_fs_remove_file, 1530 1513 .success = afs_unlink_success, 1514 + .aborted = afs_check_for_remote_deletion, 1531 1515 .edit_dir = afs_unlink_edit_dir, 1532 1516 .put = afs_unlink_put, 1533 1517 }; ··· 1555 1537 1556 1538 afs_op_set_vnode(op, 0, dvnode); 1557 1539 op->file[0].dv_delta = 1; 1540 + op->file[0].update_ctime = true; 1558 1541 1559 1542 /* Try to make sure we have a callback promise on the victim. */ 1560 1543 ret = afs_validate(vnode, op->key); ··· 1580 1561 spin_unlock(&dentry->d_lock); 1581 1562 1582 1563 op->file[1].vnode = vnode; 1564 + op->file[1].update_ctime = true; 1565 + op->file[1].op_unlinked = true; 1583 1566 op->dentry = dentry; 1584 1567 op->ops = &afs_unlink_operation; 1585 - return afs_do_sync_operation(op); 1568 + afs_begin_vnode_operation(op); 1569 + afs_wait_for_operation(op); 1570 + 1571 + /* If there was a conflict with a third party, check the status of the 1572 + * unlinked vnode. 1573 + */ 1574 + if (op->error == 0 && (op->flags & AFS_OPERATION_DIR_CONFLICT)) { 1575 + op->file[1].update_ctime = false; 1576 + op->fetch_status.which = 1; 1577 + op->ops = &afs_fetch_status_operation; 1578 + afs_begin_vnode_operation(op); 1579 + afs_wait_for_operation(op); 1580 + } 1581 + 1582 + return afs_put_operation(op); 1586 1583 1587 1584 error: 1588 1585 return afs_put_operation(op); ··· 1608 1573 .issue_afs_rpc = afs_fs_create_file, 1609 1574 .issue_yfs_rpc = yfs_fs_create_file, 1610 1575 .success = afs_create_success, 1576 + .aborted = afs_check_for_remote_deletion, 1611 1577 .edit_dir = afs_create_edit_dir, 1612 1578 .put = afs_create_put, 1613 1579 }; ··· 1637 1601 1638 1602 afs_op_set_vnode(op, 0, dvnode); 1639 1603 op->file[0].dv_delta = 1; 1604 + op->file[0].update_ctime = true; 1640 1605 1641 1606 op->dentry = dentry; 1642 1607 op->create.mode = S_IFREG | mode; ··· 1657 1620 struct afs_vnode_param *vp = &op->file[1]; 1658 1621 1659 1622 _enter("op=%08x", op->debug_id); 1623 + op->ctime = dvp->scb.status.mtime_client; 1660 1624 afs_vnode_commit_status(op, dvp); 1661 1625 afs_vnode_commit_status(op, vp); 1662 1626 afs_update_dentry_version(op, dvp, op->dentry); ··· 1678 1640 .issue_afs_rpc = afs_fs_link, 1679 1641 .issue_yfs_rpc = yfs_fs_link, 1680 1642 .success = afs_link_success, 1643 + .aborted = afs_check_for_remote_deletion, 1681 1644 .edit_dir = afs_create_edit_dir, 1682 1645 .put = afs_link_put, 1683 1646 }; ··· 1711 1672 afs_op_set_vnode(op, 0, dvnode); 1712 1673 afs_op_set_vnode(op, 1, vnode); 1713 1674 op->file[0].dv_delta = 1; 1675 + op->file[0].update_ctime = true; 1676 + op->file[1].update_ctime = true; 1714 1677 1715 1678 op->dentry = dentry; 1716 1679 op->dentry_2 = from; ··· 1730 1689 .issue_afs_rpc = afs_fs_symlink, 1731 1690 .issue_yfs_rpc = yfs_fs_symlink, 1732 1691 .success = afs_create_success, 1692 + .aborted = afs_check_for_remote_deletion, 1733 1693 .edit_dir = afs_create_edit_dir, 1734 1694 .put = afs_create_put, 1735 1695 }; ··· 1782 1740 { 1783 1741 _enter("op=%08x", op->debug_id); 1784 1742 1743 + op->ctime = op->file[0].scb.status.mtime_client; 1744 + afs_check_dir_conflict(op, &op->file[1]); 1785 1745 afs_vnode_commit_status(op, &op->file[0]); 1786 - if (op->file[1].vnode != op->file[0].vnode) 1746 + if (op->file[1].vnode != op->file[0].vnode) { 1747 + op->ctime = op->file[1].scb.status.mtime_client; 1787 1748 afs_vnode_commit_status(op, &op->file[1]); 1749 + } 1788 1750 } 1789 1751 1790 1752 static void afs_rename_edit_dir(struct afs_operation *op) ··· 1906 1860 afs_op_set_vnode(op, 1, new_dvnode); /* May be same as orig_dvnode */ 1907 1861 op->file[0].dv_delta = 1; 1908 1862 op->file[1].dv_delta = 1; 1863 + op->file[0].update_ctime = true; 1864 + op->file[1].update_ctime = true; 1909 1865 1910 1866 op->dentry = old_dentry; 1911 1867 op->dentry_2 = new_dentry;
+28 -10
fs/afs/dir_silly.c
··· 16 16 { 17 17 _enter("op=%08x", op->debug_id); 18 18 19 + afs_check_dir_conflict(op, &op->file[0]); 19 20 afs_vnode_commit_status(op, &op->file[0]); 20 21 } 21 22 ··· 70 69 return PTR_ERR(op); 71 70 72 71 afs_op_set_vnode(op, 0, dvnode); 72 + afs_op_set_vnode(op, 1, dvnode); 73 + op->file[0].dv_delta = 1; 74 + op->file[1].dv_delta = 1; 75 + op->file[0].update_ctime = true; 76 + op->file[1].update_ctime = true; 73 77 74 78 op->dentry = old; 75 79 op->dentry_2 = new; ··· 135 129 switch (ret) { 136 130 case 0: 137 131 /* The rename succeeded. */ 132 + set_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags); 138 133 d_move(dentry, sdentry); 139 134 break; 140 135 case -ERESTARTSYS: ··· 155 148 156 149 static void afs_silly_unlink_success(struct afs_operation *op) 157 150 { 158 - struct afs_vnode *vnode = op->file[1].vnode; 159 - 160 151 _enter("op=%08x", op->debug_id); 161 - afs_check_for_remote_deletion(op, op->file[0].vnode); 152 + afs_check_dir_conflict(op, &op->file[0]); 162 153 afs_vnode_commit_status(op, &op->file[0]); 163 154 afs_vnode_commit_status(op, &op->file[1]); 164 155 afs_update_dentry_version(op, &op->file[0], op->dentry); 165 - 166 - drop_nlink(&vnode->vfs_inode); 167 - if (vnode->vfs_inode.i_nlink == 0) { 168 - set_bit(AFS_VNODE_DELETED, &vnode->flags); 169 - clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags); 170 - } 171 156 } 172 157 173 158 static void afs_silly_unlink_edit_dir(struct afs_operation *op) ··· 180 181 .issue_afs_rpc = afs_fs_remove_file, 181 182 .issue_yfs_rpc = yfs_fs_remove_file, 182 183 .success = afs_silly_unlink_success, 184 + .aborted = afs_check_for_remote_deletion, 183 185 .edit_dir = afs_silly_unlink_edit_dir, 184 186 }; 185 187 ··· 200 200 201 201 afs_op_set_vnode(op, 0, dvnode); 202 202 afs_op_set_vnode(op, 1, vnode); 203 + op->file[0].dv_delta = 1; 204 + op->file[0].update_ctime = true; 205 + op->file[1].op_unlinked = true; 206 + op->file[1].update_ctime = true; 203 207 204 208 op->dentry = dentry; 205 209 op->ops = &afs_silly_unlink_operation; 206 210 207 211 trace_afs_silly_rename(vnode, true); 208 - return afs_do_sync_operation(op); 212 + afs_begin_vnode_operation(op); 213 + afs_wait_for_operation(op); 214 + 215 + /* If there was a conflict with a third party, check the status of the 216 + * unlinked vnode. 217 + */ 218 + if (op->error == 0 && (op->flags & AFS_OPERATION_DIR_CONFLICT)) { 219 + op->file[1].update_ctime = false; 220 + op->fetch_status.which = 1; 221 + op->ops = &afs_fetch_status_operation; 222 + afs_begin_vnode_operation(op); 223 + afs_wait_for_operation(op); 224 + } 225 + 226 + return afs_put_operation(op); 209 227 } 210 228 211 229 /*
+1 -1
fs/afs/file.c
··· 225 225 struct afs_vnode *vnode = op->file[0].vnode; 226 226 227 227 _enter("op=%08x", op->debug_id); 228 - afs_check_for_remote_deletion(op, vnode); 229 228 afs_vnode_commit_status(op, &op->file[0]); 230 229 afs_stat_v(vnode, n_fetches); 231 230 atomic_long_add(op->fetch.req->actual_len, &op->net->n_fetch_bytes); ··· 239 240 .issue_afs_rpc = afs_fs_fetch_data, 240 241 .issue_yfs_rpc = yfs_fs_fetch_data, 241 242 .success = afs_fetch_data_success, 243 + .aborted = afs_check_for_remote_deletion, 242 244 .put = afs_fetch_data_put, 243 245 }; 244 246
+1 -3
fs/afs/flock.c
··· 175 175 176 176 static void afs_lock_success(struct afs_operation *op) 177 177 { 178 - struct afs_vnode *vnode = op->file[0].vnode; 179 - 180 178 _enter("op=%08x", op->debug_id); 181 - afs_check_for_remote_deletion(op, vnode); 182 179 afs_vnode_commit_status(op, &op->file[0]); 183 180 } 184 181 ··· 183 186 .issue_afs_rpc = afs_fs_set_lock, 184 187 .issue_yfs_rpc = yfs_fs_set_lock, 185 188 .success = afs_lock_success, 189 + .aborted = afs_check_for_remote_deletion, 186 190 }; 187 191 188 192 /*
+9 -1
fs/afs/fs_operation.c
··· 187 187 op->error = afs_wait_for_call_to_complete(op->call, &op->ac); 188 188 } 189 189 190 - if (op->error == 0) { 190 + switch (op->error) { 191 + case 0: 191 192 _debug("success"); 192 193 op->ops->success(op); 194 + break; 195 + case -ECONNABORTED: 196 + if (op->ops->aborted) 197 + op->ops->aborted(op); 198 + break; 199 + default: 200 + break; 193 201 } 194 202 195 203 afs_end_vnode_operation(op);
+10 -1
fs/afs/fs_probe.c
··· 314 314 { 315 315 struct afs_net *net = container_of(timer, struct afs_net, fs_probe_timer); 316 316 317 - if (!queue_work(afs_wq, &net->fs_prober)) 317 + if (!net->live || !queue_work(afs_wq, &net->fs_prober)) 318 318 afs_dec_servers_outstanding(net); 319 319 } 320 320 ··· 457 457 if (timo == 0) 458 458 return -ETIME; 459 459 return -EDESTADDRREQ; 460 + } 461 + 462 + /* 463 + * Clean up the probing when the namespace is killed off. 464 + */ 465 + void afs_fs_probe_cleanup(struct afs_net *net) 466 + { 467 + if (del_timer_sync(&net->fs_probe_timer)) 468 + afs_dec_servers_outstanding(net); 460 469 }
+71 -20
fs/afs/inode.c
··· 165 165 { 166 166 struct afs_file_status *status = &vp->scb.status; 167 167 struct afs_vnode *vnode = vp->vnode; 168 + struct inode *inode = &vnode->vfs_inode; 168 169 struct timespec64 t; 169 170 umode_t mode; 170 171 bool data_changed = false; 172 + bool change_size = vp->set_size; 171 173 172 174 _enter("{%llx:%llu.%u} %s", 173 175 vp->fid.vid, vp->fid.vnode, vp->fid.unique, ··· 188 186 } 189 187 190 188 if (status->nlink != vnode->status.nlink) 191 - set_nlink(&vnode->vfs_inode, status->nlink); 189 + set_nlink(inode, status->nlink); 192 190 193 191 if (status->owner != vnode->status.owner) 194 - vnode->vfs_inode.i_uid = make_kuid(&init_user_ns, status->owner); 192 + inode->i_uid = make_kuid(&init_user_ns, status->owner); 195 193 196 194 if (status->group != vnode->status.group) 197 - vnode->vfs_inode.i_gid = make_kgid(&init_user_ns, status->group); 195 + inode->i_gid = make_kgid(&init_user_ns, status->group); 198 196 199 197 if (status->mode != vnode->status.mode) { 200 - mode = vnode->vfs_inode.i_mode; 198 + mode = inode->i_mode; 201 199 mode &= ~S_IALLUGO; 202 200 mode |= status->mode; 203 - WRITE_ONCE(vnode->vfs_inode.i_mode, mode); 201 + WRITE_ONCE(inode->i_mode, mode); 204 202 } 205 203 206 204 t = status->mtime_client; 207 - vnode->vfs_inode.i_ctime = t; 208 - vnode->vfs_inode.i_mtime = t; 209 - vnode->vfs_inode.i_atime = t; 205 + inode->i_mtime = t; 206 + if (vp->update_ctime) 207 + inode->i_ctime = op->ctime; 210 208 211 209 if (vnode->status.data_version != status->data_version) 212 210 data_changed = true; ··· 228 226 } else { 229 227 set_bit(AFS_VNODE_ZAP_DATA, &vnode->flags); 230 228 } 229 + change_size = true; 231 230 } else if (vnode->status.type == AFS_FTYPE_DIR) { 232 231 /* Expected directory change is handled elsewhere so 233 232 * that we can locally edit the directory and save on a ··· 236 233 */ 237 234 if (test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) 238 235 data_changed = false; 236 + change_size = true; 239 237 } 240 238 241 239 if (data_changed) { 242 - inode_set_iversion_raw(&vnode->vfs_inode, status->data_version); 243 - afs_set_i_size(vnode, status->size); 240 + inode_set_iversion_raw(inode, status->data_version); 241 + 242 + /* Only update the size if the data version jumped. If the 243 + * file is being modified locally, then we might have our own 244 + * idea of what the size should be that's not the same as 245 + * what's on the server. 246 + */ 247 + if (change_size) { 248 + afs_set_i_size(vnode, status->size); 249 + inode->i_ctime = t; 250 + inode->i_atime = t; 251 + } 244 252 } 245 253 } 246 254 ··· 281 267 282 268 _enter(""); 283 269 284 - ASSERTCMP(op->error, ==, 0); 285 - 286 270 write_seqlock(&vnode->cb_lock); 287 271 288 272 if (vp->scb.have_error) { 273 + /* A YFS server will return this from RemoveFile2 and AFS and 274 + * YFS will return this from InlineBulkStatus. 275 + */ 289 276 if (vp->scb.status.abort_code == VNOVNODE) { 290 277 set_bit(AFS_VNODE_DELETED, &vnode->flags); 291 278 clear_nlink(&vnode->vfs_inode); 292 279 __afs_break_callback(vnode, afs_cb_break_for_deleted); 280 + op->flags &= ~AFS_OPERATION_DIR_CONFLICT; 293 281 } 294 - } else { 295 - if (vp->scb.have_status) 296 - afs_apply_status(op, vp); 282 + } else if (vp->scb.have_status) { 283 + afs_apply_status(op, vp); 297 284 if (vp->scb.have_cb) 298 285 afs_apply_callback(op, vp); 286 + } else if (vp->op_unlinked && !(op->flags & AFS_OPERATION_DIR_CONFLICT)) { 287 + drop_nlink(&vnode->vfs_inode); 288 + if (vnode->vfs_inode.i_nlink == 0) { 289 + set_bit(AFS_VNODE_DELETED, &vnode->flags); 290 + __afs_break_callback(vnode, afs_cb_break_for_deleted); 291 + } 299 292 } 300 293 301 294 write_sequnlock(&vnode->cb_lock); 302 295 303 - if (op->error == 0 && vp->scb.have_status) 296 + if (vp->scb.have_status) 304 297 afs_cache_permit(vnode, op->key, vp->cb_break_before, &vp->scb); 305 298 } 306 299 307 300 static void afs_fetch_status_success(struct afs_operation *op) 308 301 { 309 - struct afs_vnode_param *vp = &op->file[0]; 302 + struct afs_vnode_param *vp = &op->file[op->fetch_status.which]; 310 303 struct afs_vnode *vnode = vp->vnode; 311 304 int ret; 312 305 ··· 327 306 } 328 307 } 329 308 330 - static const struct afs_operation_ops afs_fetch_status_operation = { 309 + const struct afs_operation_ops afs_fetch_status_operation = { 331 310 .issue_afs_rpc = afs_fs_fetch_status, 332 311 .issue_yfs_rpc = yfs_fs_fetch_status, 333 312 .success = afs_fetch_status_success, 313 + .aborted = afs_check_for_remote_deletion, 334 314 }; 335 315 336 316 /* ··· 738 716 do { 739 717 read_seqbegin_or_lock(&vnode->cb_lock, &seq); 740 718 generic_fillattr(inode, stat); 719 + if (test_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags) && 720 + stat->nlink > 0) 721 + stat->nlink -= 1; 741 722 } while (need_seqretry(&vnode->cb_lock, seq)); 742 723 743 724 done_seqretry(&vnode->cb_lock, seq); ··· 810 785 811 786 static void afs_setattr_success(struct afs_operation *op) 812 787 { 788 + struct inode *inode = &op->file[0].vnode->vfs_inode; 789 + 813 790 afs_vnode_commit_status(op, &op->file[0]); 791 + if (op->setattr.attr->ia_valid & ATTR_SIZE) { 792 + loff_t i_size = inode->i_size, size = op->setattr.attr->ia_size; 793 + if (size > i_size) 794 + pagecache_isize_extended(inode, i_size, size); 795 + truncate_pagecache(inode, size); 796 + } 814 797 } 815 798 816 799 static const struct afs_operation_ops afs_setattr_operation = { ··· 834 801 { 835 802 struct afs_operation *op; 836 803 struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry)); 804 + int ret; 837 805 838 806 _enter("{%llx:%llu},{n=%pd},%x", 839 807 vnode->fid.vid, vnode->fid.vnode, dentry, 840 808 attr->ia_valid); 841 809 842 810 if (!(attr->ia_valid & (ATTR_SIZE | ATTR_MODE | ATTR_UID | ATTR_GID | 843 - ATTR_MTIME))) { 811 + ATTR_MTIME | ATTR_MTIME_SET | ATTR_TIMES_SET | 812 + ATTR_TOUCH))) { 844 813 _leave(" = 0 [unsupported]"); 845 814 return 0; 815 + } 816 + 817 + if (attr->ia_valid & ATTR_SIZE) { 818 + if (!S_ISREG(vnode->vfs_inode.i_mode)) 819 + return -EISDIR; 820 + 821 + ret = inode_newsize_ok(&vnode->vfs_inode, attr->ia_size); 822 + if (ret) 823 + return ret; 824 + 825 + if (attr->ia_size == i_size_read(&vnode->vfs_inode)) 826 + attr->ia_valid &= ~ATTR_SIZE; 846 827 } 847 828 848 829 /* flush any dirty data outstanding on a regular file */ ··· 872 825 afs_op_set_vnode(op, 0, vnode); 873 826 op->setattr.attr = attr; 874 827 875 - if (attr->ia_valid & ATTR_SIZE) 828 + if (attr->ia_valid & ATTR_SIZE) { 876 829 op->file[0].dv_delta = 1; 830 + op->file[0].set_size = true; 831 + } 832 + op->ctime = attr->ia_ctime; 833 + op->file[0].update_ctime = 1; 877 834 878 835 op->ops = &afs_setattr_operation; 879 836 return afs_do_sync_operation(op);
+24 -13
fs/afs/internal.h
··· 634 634 #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */ 635 635 #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */ 636 636 #define AFS_VNODE_NEW_CONTENT 8 /* Set if file has new content (create/trunc-0) */ 637 + #define AFS_VNODE_SILLY_DELETED 9 /* Set if file has been silly-deleted */ 637 638 638 639 struct list_head wb_keys; /* List of keys available for writeback */ 639 640 struct list_head pending_locks; /* locks waiting to be granted */ ··· 745 744 afs_dataversion_t dv_before; /* Data version before the call */ 746 745 unsigned int cb_break_before; /* cb_break + cb_s_break before the call */ 747 746 u8 dv_delta; /* Expected change in data version */ 748 - bool put_vnode; /* T if we have a ref on the vnode */ 749 - bool need_io_lock; /* T if we need the I/O lock on this */ 747 + bool put_vnode:1; /* T if we have a ref on the vnode */ 748 + bool need_io_lock:1; /* T if we need the I/O lock on this */ 749 + bool update_ctime:1; /* Need to update the ctime */ 750 + bool set_size:1; /* Must update i_size */ 751 + bool op_unlinked:1; /* True if file was unlinked by op */ 750 752 }; 751 753 752 754 /* ··· 770 766 struct dentry *dentry; /* Dentry to be altered */ 771 767 struct dentry *dentry_2; /* Second dentry to be altered */ 772 768 struct timespec64 mtime; /* Modification time to record */ 769 + struct timespec64 ctime; /* Change time to set */ 773 770 short nr_files; /* Number of entries in file[], more_files */ 774 771 short error; 775 - unsigned int abort_code; 776 772 unsigned int debug_id; 777 773 778 774 unsigned int cb_v_break; /* Volume break counter before op */ ··· 841 837 #define AFS_OPERATION_LOCK_1 0x0200 /* Set if have io_lock on file[1] */ 842 838 #define AFS_OPERATION_TRIED_ALL 0x0400 /* Set if we've tried all the fileservers */ 843 839 #define AFS_OPERATION_RETRY_SERVER 0x0800 /* Set if we should retry the current server */ 840 + #define AFS_OPERATION_DIR_CONFLICT 0x1000 /* Set if we detected a 3rd-party dir change */ 844 841 }; 845 842 846 843 /* ··· 937 932 extern const struct dentry_operations afs_fs_dentry_operations; 938 933 939 934 extern void afs_d_release(struct dentry *); 935 + extern void afs_check_for_remote_deletion(struct afs_operation *); 940 936 941 937 /* 942 938 * dir_edit.c ··· 1065 1059 extern void afs_probe_fileserver(struct afs_net *, struct afs_server *); 1066 1060 extern void afs_fs_probe_dispatcher(struct work_struct *); 1067 1061 extern int afs_wait_for_one_fs_probe(struct afs_server *, bool); 1062 + extern void afs_fs_probe_cleanup(struct afs_net *); 1068 1063 1069 1064 /* 1070 1065 * inode.c 1071 1066 */ 1067 + extern const struct afs_operation_ops afs_fetch_status_operation; 1068 + 1072 1069 extern void afs_vnode_commit_status(struct afs_operation *, struct afs_vnode_param *); 1073 1070 extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t *); 1074 1071 extern int afs_ilookup5_test_by_fid(struct inode *, void *); ··· 1444 1435 /* 1445 1436 * yfsclient.c 1446 1437 */ 1447 - extern void yfs_fs_fetch_file_status(struct afs_operation *); 1448 1438 extern void yfs_fs_fetch_data(struct afs_operation *); 1449 1439 extern void yfs_fs_create_file(struct afs_operation *); 1450 1440 extern void yfs_fs_make_dir(struct afs_operation *); ··· 1489 1481 return &vnode->vfs_inode; 1490 1482 } 1491 1483 1492 - static inline void afs_check_for_remote_deletion(struct afs_operation *op, 1493 - struct afs_vnode *vnode) 1494 - { 1495 - if (op->error == -ENOENT) { 1496 - set_bit(AFS_VNODE_DELETED, &vnode->flags); 1497 - afs_break_callback(vnode, afs_cb_break_for_deleted); 1498 - } 1499 - } 1500 - 1501 1484 /* 1502 1485 * Note that a dentry got changed. We need to set d_fsdata to the data version 1503 1486 * number derived from the result of the operation. It doesn't matter if ··· 1501 1502 if (!op->error) 1502 1503 dentry->d_fsdata = 1503 1504 (void *)(unsigned long)dir_vp->scb.status.data_version; 1505 + } 1506 + 1507 + /* 1508 + * Check for a conflicting operation on a directory that we just unlinked from. 1509 + * If someone managed to sneak a link or an unlink in on the file we just 1510 + * unlinked, we won't be able to trust nlink on an AFS file (but not YFS). 1511 + */ 1512 + static inline void afs_check_dir_conflict(struct afs_operation *op, 1513 + struct afs_vnode_param *dvp) 1514 + { 1515 + if (dvp->dv_before + dvp->dv_delta != dvp->scb.status.data_version) 1516 + op->flags |= AFS_OPERATION_DIR_CONFLICT; 1504 1517 } 1505 1518 1506 1519 static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
+3
fs/afs/main.c
··· 100 100 timer_setup(&net->fs_timer, afs_servers_timer, 0); 101 101 INIT_WORK(&net->fs_prober, afs_fs_probe_dispatcher); 102 102 timer_setup(&net->fs_probe_timer, afs_fs_probe_timer, 0); 103 + atomic_set(&net->servers_outstanding, 1); 103 104 104 105 ret = -ENOMEM; 105 106 sysnames = kzalloc(sizeof(*sysnames), GFP_KERNEL); ··· 131 130 132 131 error_open_socket: 133 132 net->live = false; 133 + afs_fs_probe_cleanup(net); 134 134 afs_cell_purge(net); 135 135 afs_purge_servers(net); 136 136 error_cell_init: ··· 152 150 struct afs_net *net = afs_net(net_ns); 153 151 154 152 net->live = false; 153 + afs_fs_probe_cleanup(net); 155 154 afs_cell_purge(net); 156 155 afs_purge_servers(net); 157 156 afs_close_socket(net);
+1
fs/afs/misc.c
··· 83 83 case UAENOLCK: return -ENOLCK; 84 84 case UAENOTEMPTY: return -ENOTEMPTY; 85 85 case UAELOOP: return -ELOOP; 86 + case UAEOVERFLOW: return -EOVERFLOW; 86 87 case UAENOMEDIUM: return -ENOMEDIUM; 87 88 case UAEDQUOT: return -EDQUOT; 88 89
+2 -1
fs/afs/server.c
··· 605 605 _enter(""); 606 606 607 607 if (del_timer_sync(&net->fs_timer)) 608 - atomic_dec(&net->servers_outstanding); 608 + afs_dec_servers_outstanding(net); 609 609 610 610 afs_queue_server_manager(net); 611 611 612 612 _debug("wait"); 613 + atomic_dec(&net->servers_outstanding); 613 614 wait_var_event(&net->servers_outstanding, 614 615 !atomic_read(&net->servers_outstanding)); 615 616 _leave("");
+10 -2
fs/afs/write.c
··· 194 194 195 195 i_size = i_size_read(&vnode->vfs_inode); 196 196 if (maybe_i_size > i_size) { 197 - spin_lock(&vnode->wb_lock); 197 + write_seqlock(&vnode->cb_lock); 198 198 i_size = i_size_read(&vnode->vfs_inode); 199 199 if (maybe_i_size > i_size) 200 200 i_size_write(&vnode->vfs_inode, maybe_i_size); 201 - spin_unlock(&vnode->wb_lock); 201 + write_sequnlock(&vnode->cb_lock); 202 202 } 203 203 204 204 if (!PageUptodate(page)) { ··· 393 393 { 394 394 struct afs_vnode *vnode = op->file[0].vnode; 395 395 396 + op->ctime = op->file[0].scb.status.mtime_client; 396 397 afs_vnode_commit_status(op, &op->file[0]); 397 398 if (op->error == 0) { 398 399 afs_pages_written_back(vnode, op->store.first, op->store.last); ··· 492 491 unsigned long count, priv; 493 492 unsigned n, offset, to, f, t; 494 493 pgoff_t start, first, last; 494 + loff_t i_size, end; 495 495 int loop, ret; 496 496 497 497 _enter(",%lx", primary_page->index); ··· 593 591 first = primary_page->index; 594 592 last = first + count - 1; 595 593 594 + end = (loff_t)last * PAGE_SIZE + to; 595 + i_size = i_size_read(&vnode->vfs_inode); 596 + 596 597 _debug("write back %lx[%u..] to %lx[..%u]", first, offset, last, to); 598 + if (end > i_size) 599 + to = i_size & ~PAGE_MASK; 597 600 598 601 ret = afs_store_data(mapping, first, last, offset, to); 599 602 switch (ret) { ··· 851 844 vmf->page->index, priv); 852 845 SetPagePrivate(vmf->page); 853 846 set_page_private(vmf->page, priv); 847 + file_update_time(file); 854 848 855 849 sb_end_pagefault(inode->i_sb); 856 850 return VM_FAULT_LOCKED;
+26 -67
fs/afs/yfsclient.c
··· 330 330 } 331 331 332 332 /* 333 - * Deliver a reply that's a status, callback and volsync. 334 - */ 335 - static int yfs_deliver_fs_status_cb_and_volsync(struct afs_call *call) 336 - { 337 - struct afs_operation *op = call->op; 338 - const __be32 *bp; 339 - int ret; 340 - 341 - ret = afs_transfer_reply(call); 342 - if (ret < 0) 343 - return ret; 344 - 345 - /* unmarshall the reply once we've received all of it */ 346 - bp = call->buffer; 347 - xdr_decode_YFSFetchStatus(&bp, call, &op->file[0].scb); 348 - xdr_decode_YFSCallBack(&bp, call, &op->file[0].scb); 349 - xdr_decode_YFSVolSync(&bp, &op->volsync); 350 - 351 - _leave(" = 0 [done]"); 352 - return 0; 353 - } 354 - 355 - /* 356 333 * Deliver reply data to operations that just return a file status and a volume 357 334 * sync record. 358 335 */ ··· 349 372 350 373 _leave(" = 0 [done]"); 351 374 return 0; 352 - } 353 - 354 - /* 355 - * YFS.FetchStatus operation type 356 - */ 357 - static const struct afs_call_type yfs_RXYFSFetchStatus_vnode = { 358 - .name = "YFS.FetchStatus(vnode)", 359 - .op = yfs_FS_FetchStatus, 360 - .deliver = yfs_deliver_fs_status_cb_and_volsync, 361 - .destructor = afs_flat_call_destructor, 362 - }; 363 - 364 - /* 365 - * Fetch the status information for a file. 366 - */ 367 - void yfs_fs_fetch_file_status(struct afs_operation *op) 368 - { 369 - struct afs_vnode_param *vp = &op->file[0]; 370 - struct afs_call *call; 371 - __be32 *bp; 372 - 373 - _enter(",%x,{%llx:%llu},,", 374 - key_serial(op->key), vp->fid.vid, vp->fid.vnode); 375 - 376 - call = afs_alloc_flat_call(op->net, &yfs_RXYFSFetchStatus_vnode, 377 - sizeof(__be32) * 2 + 378 - sizeof(struct yfs_xdr_YFSFid), 379 - sizeof(struct yfs_xdr_YFSFetchStatus) + 380 - sizeof(struct yfs_xdr_YFSCallBack) + 381 - sizeof(struct yfs_xdr_YFSVolSync)); 382 - if (!call) 383 - return afs_op_nomem(op); 384 - 385 - /* marshall the parameters */ 386 - bp = call->request; 387 - bp = xdr_encode_u32(bp, YFSFETCHSTATUS); 388 - bp = xdr_encode_u32(bp, 0); /* RPC flags */ 389 - bp = xdr_encode_YFSFid(bp, &vp->fid); 390 - yfs_check_req(call, bp); 391 - 392 - trace_afs_make_fs_call(call, &vp->fid); 393 - afs_make_op_call(op, call, GFP_NOFS); 394 375 } 395 376 396 377 /* ··· 1540 1605 } 1541 1606 1542 1607 /* 1608 + * Deliver a reply to YFS.FetchStatus 1609 + */ 1610 + static int yfs_deliver_fs_fetch_status(struct afs_call *call) 1611 + { 1612 + struct afs_operation *op = call->op; 1613 + struct afs_vnode_param *vp = &op->file[op->fetch_status.which]; 1614 + const __be32 *bp; 1615 + int ret; 1616 + 1617 + ret = afs_transfer_reply(call); 1618 + if (ret < 0) 1619 + return ret; 1620 + 1621 + /* unmarshall the reply once we've received all of it */ 1622 + bp = call->buffer; 1623 + xdr_decode_YFSFetchStatus(&bp, call, &vp->scb); 1624 + xdr_decode_YFSCallBack(&bp, call, &vp->scb); 1625 + xdr_decode_YFSVolSync(&bp, &op->volsync); 1626 + 1627 + _leave(" = 0 [done]"); 1628 + return 0; 1629 + } 1630 + 1631 + /* 1543 1632 * YFS.FetchStatus operation type 1544 1633 */ 1545 1634 static const struct afs_call_type yfs_RXYFSFetchStatus = { 1546 1635 .name = "YFS.FetchStatus", 1547 1636 .op = yfs_FS_FetchStatus, 1548 - .deliver = yfs_deliver_fs_status_cb_and_volsync, 1637 + .deliver = yfs_deliver_fs_fetch_status, 1549 1638 .destructor = afs_flat_call_destructor, 1550 1639 }; 1551 1640 ··· 1578 1619 */ 1579 1620 void yfs_fs_fetch_status(struct afs_operation *op) 1580 1621 { 1581 - struct afs_vnode_param *vp = &op->file[0]; 1622 + struct afs_vnode_param *vp = &op->file[op->fetch_status.which]; 1582 1623 struct afs_call *call; 1583 1624 __be32 *bp; 1584 1625
+1 -1
fs/aio.c
··· 67 67 unsigned header_length; /* size of aio_ring */ 68 68 69 69 70 - struct io_event io_events[0]; 70 + struct io_event io_events[]; 71 71 }; /* 128 bytes + ring size */ 72 72 73 73 /*
+9 -8
fs/block_dev.c
··· 75 75 } 76 76 77 77 /* Kill _all_ buffers and pagecache , dirty or not.. */ 78 - void kill_bdev(struct block_device *bdev) 78 + static void kill_bdev(struct block_device *bdev) 79 79 { 80 80 struct address_space *mapping = bdev->bd_inode->i_mapping; 81 81 ··· 84 84 85 85 invalidate_bh_lrus(); 86 86 truncate_inode_pages(mapping, 0); 87 - } 88 - EXPORT_SYMBOL(kill_bdev); 87 + } 89 88 90 89 /* Invalidate clean unused buffers and pagecache. */ 91 90 void invalidate_bdev(struct block_device *bdev) ··· 1564 1565 */ 1565 1566 if (!for_part) { 1566 1567 ret = devcgroup_inode_permission(bdev->bd_inode, perm); 1567 - if (ret != 0) { 1568 - bdput(bdev); 1568 + if (ret != 0) 1569 1569 return ret; 1570 - } 1571 1570 } 1572 1571 1573 1572 restart: ··· 1634 1637 goto out_clear; 1635 1638 BUG_ON(for_part); 1636 1639 ret = __blkdev_get(whole, mode, 1); 1637 - if (ret) 1640 + if (ret) { 1641 + bdput(whole); 1638 1642 goto out_clear; 1643 + } 1639 1644 bdev->bd_contains = whole; 1640 1645 bdev->bd_part = disk_get_part(disk, partno); 1641 1646 if (!(disk->flags & GENHD_FL_UP) || ··· 1687 1688 disk_unblock_events(disk); 1688 1689 put_disk_and_module(disk); 1689 1690 out: 1690 - bdput(bdev); 1691 1691 1692 1692 return ret; 1693 1693 } ··· 1752 1754 mutex_unlock(&bdev->bd_mutex); 1753 1755 bdput(whole); 1754 1756 } 1757 + 1758 + if (res) 1759 + bdput(bdev); 1755 1760 1756 1761 return res; 1757 1762 }
+2 -1
fs/ext4/Makefile
··· 9 9 extents_status.o file.o fsmap.o fsync.o hash.o ialloc.o \ 10 10 indirect.o inline.o inode.o ioctl.o mballoc.o migrate.o \ 11 11 mmp.o move_extent.o namei.o page-io.o readpage.o resize.o \ 12 - super.o symlink.o sysfs.o xattr.o xattr_trusted.o xattr_user.o 12 + super.o symlink.o sysfs.o xattr.o xattr_hurd.o xattr_trusted.o \ 13 + xattr_user.o 13 14 14 15 ext4-$(CONFIG_EXT4_FS_POSIX_ACL) += acl.o 15 16 ext4-$(CONFIG_EXT4_FS_SECURITY) += xattr_security.o
+16
fs/ext4/dir.c
··· 675 675 struct qstr qstr = {.name = str, .len = len }; 676 676 const struct dentry *parent = READ_ONCE(dentry->d_parent); 677 677 const struct inode *inode = READ_ONCE(parent->d_inode); 678 + char strbuf[DNAME_INLINE_LEN]; 678 679 679 680 if (!inode || !IS_CASEFOLDED(inode) || 680 681 !EXT4_SB(inode->i_sb)->s_encoding) { 681 682 if (len != name->len) 682 683 return -1; 683 684 return memcmp(str, name->name, len); 685 + } 686 + 687 + /* 688 + * If the dentry name is stored in-line, then it may be concurrently 689 + * modified by a rename. If this happens, the VFS will eventually retry 690 + * the lookup, so it doesn't matter what ->d_compare() returns. 691 + * However, it's unsafe to call utf8_strncasecmp() with an unstable 692 + * string. Therefore, we have to copy the name into a temporary buffer. 693 + */ 694 + if (len <= DNAME_INLINE_LEN - 1) { 695 + memcpy(strbuf, str, len); 696 + strbuf[len] = 0; 697 + qstr.name = strbuf; 698 + /* prevent compiler from optimizing out the temporary buffer */ 699 + barrier(); 684 700 } 685 701 686 702 return ext4_ci_compare(inode, name, &qstr, false);
+20 -7
fs/ext4/ext4.h
··· 426 426 #define EXT4_VERITY_FL 0x00100000 /* Verity protected inode */ 427 427 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */ 428 428 /* 0x00400000 was formerly EXT4_EOFBLOCKS_FL */ 429 + 430 + #define EXT4_DAX_FL 0x02000000 /* Inode is DAX */ 431 + 429 432 #define EXT4_INLINE_DATA_FL 0x10000000 /* Inode has inline data. */ 430 433 #define EXT4_PROJINHERIT_FL 0x20000000 /* Create with parents projid */ 431 434 #define EXT4_CASEFOLD_FL 0x40000000 /* Casefolded directory */ 432 435 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */ 433 436 434 - #define EXT4_FL_USER_VISIBLE 0x705BDFFF /* User visible flags */ 435 - #define EXT4_FL_USER_MODIFIABLE 0x604BC0FF /* User modifiable flags */ 437 + #define EXT4_FL_USER_VISIBLE 0x725BDFFF /* User visible flags */ 438 + #define EXT4_FL_USER_MODIFIABLE 0x624BC0FF /* User modifiable flags */ 436 439 437 440 /* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */ 438 441 #define EXT4_FL_XFLAG_VISIBLE (EXT4_SYNC_FL | \ ··· 443 440 EXT4_APPEND_FL | \ 444 441 EXT4_NODUMP_FL | \ 445 442 EXT4_NOATIME_FL | \ 446 - EXT4_PROJINHERIT_FL) 443 + EXT4_PROJINHERIT_FL | \ 444 + EXT4_DAX_FL) 447 445 448 446 /* Flags that should be inherited by new inodes from their parent. */ 449 447 #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\ 450 448 EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\ 451 449 EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\ 452 450 EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\ 453 - EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL) 451 + EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL |\ 452 + EXT4_DAX_FL) 454 453 455 454 /* Flags that are appropriate for regular files (all but dir-specific ones). */ 456 455 #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL | EXT4_CASEFOLD_FL |\ ··· 463 458 464 459 /* The only flags that should be swapped */ 465 460 #define EXT4_FL_SHOULD_SWAP (EXT4_HUGE_FILE_FL | EXT4_EXTENTS_FL) 461 + 462 + /* Flags which are mutually exclusive to DAX */ 463 + #define EXT4_DAX_MUT_EXCL (EXT4_VERITY_FL | EXT4_ENCRYPT_FL |\ 464 + EXT4_JOURNAL_DATA_FL) 466 465 467 466 /* Mask out flags that are inappropriate for the given type of inode. */ 468 467 static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags) ··· 508 499 EXT4_INODE_VERITY = 20, /* Verity protected inode */ 509 500 EXT4_INODE_EA_INODE = 21, /* Inode used for large EA */ 510 501 /* 22 was formerly EXT4_INODE_EOFBLOCKS */ 502 + EXT4_INODE_DAX = 25, /* Inode is DAX */ 511 503 EXT4_INODE_INLINE_DATA = 28, /* Data in inode. */ 512 504 EXT4_INODE_PROJINHERIT = 29, /* Create with parents projid */ 513 505 EXT4_INODE_CASEFOLD = 30, /* Casefolded directory */ ··· 1145 1135 #define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */ 1146 1136 #define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/ 1147 1137 #ifdef CONFIG_FS_DAX 1148 - #define EXT4_MOUNT_DAX 0x00200 /* Direct Access */ 1138 + #define EXT4_MOUNT_DAX_ALWAYS 0x00200 /* Direct Access */ 1149 1139 #else 1150 - #define EXT4_MOUNT_DAX 0 1140 + #define EXT4_MOUNT_DAX_ALWAYS 0 1151 1141 #endif 1152 1142 #define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */ 1153 1143 #define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */ ··· 1190 1180 blocks */ 1191 1181 #define EXT4_MOUNT2_HURD_COMPAT 0x00000004 /* Support HURD-castrated 1192 1182 file systems */ 1183 + #define EXT4_MOUNT2_DAX_NEVER 0x00000008 /* Do not allow Direct Access */ 1184 + #define EXT4_MOUNT2_DAX_INODE 0x00000010 /* For printing options only */ 1193 1185 1194 1186 #define EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM 0x00000008 /* User explicitly 1195 1187 specified journal checksum */ ··· 2004 1992 */ 2005 1993 #define EXT4_FLAGS_RESIZING 0 2006 1994 #define EXT4_FLAGS_SHUTDOWN 1 1995 + #define EXT4_FLAGS_BDEV_IS_DAX 2 2007 1996 2008 1997 static inline int ext4_forced_shutdown(struct ext4_sb_info *sbi) 2009 1998 { ··· 2718 2705 extern int ext4_truncate(struct inode *); 2719 2706 extern int ext4_break_layouts(struct inode *); 2720 2707 extern int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length); 2721 - extern void ext4_set_inode_flags(struct inode *); 2708 + extern void ext4_set_inode_flags(struct inode *, bool init); 2722 2709 extern int ext4_alloc_da_blocks(struct inode *inode); 2723 2710 extern void ext4_set_aops(struct inode *inode); 2724 2711 extern int ext4_writepage_trans_blocks(struct inode *);
+1 -1
fs/ext4/extents.c
··· 2844 2844 * in use to avoid freeing it when removing blocks. 2845 2845 */ 2846 2846 if (sbi->s_cluster_ratio > 1) { 2847 - pblk = ext4_ext_pblock(ex) + end - ee_block + 2; 2847 + pblk = ext4_ext_pblock(ex) + end - ee_block + 1; 2848 2848 partial.pclu = EXT4_B2C(sbi, pblk); 2849 2849 partial.state = nofree; 2850 2850 }
+1 -1
fs/ext4/ialloc.c
··· 1116 1116 ei->i_block_group = group; 1117 1117 ei->i_last_alloc_group = ~0; 1118 1118 1119 - ext4_set_inode_flags(inode); 1119 + ext4_set_inode_flags(inode, true); 1120 1120 if (IS_DIRSYNC(inode)) 1121 1121 ext4_handle_sync(handle); 1122 1122 if (insert_inode_locked(inode) < 0) {
+20 -6
fs/ext4/inode.c
··· 4403 4403 !ext4_test_inode_state(inode, EXT4_STATE_XATTR)); 4404 4404 } 4405 4405 4406 - static bool ext4_should_use_dax(struct inode *inode) 4406 + static bool ext4_should_enable_dax(struct inode *inode) 4407 4407 { 4408 - if (!test_opt(inode->i_sb, DAX)) 4408 + struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 4409 + 4410 + if (test_opt2(inode->i_sb, DAX_NEVER)) 4409 4411 return false; 4410 4412 if (!S_ISREG(inode->i_mode)) 4411 4413 return false; ··· 4419 4417 return false; 4420 4418 if (ext4_test_inode_flag(inode, EXT4_INODE_VERITY)) 4421 4419 return false; 4422 - return true; 4420 + if (!test_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags)) 4421 + return false; 4422 + if (test_opt(inode->i_sb, DAX_ALWAYS)) 4423 + return true; 4424 + 4425 + return ext4_test_inode_flag(inode, EXT4_INODE_DAX); 4423 4426 } 4424 4427 4425 - void ext4_set_inode_flags(struct inode *inode) 4428 + void ext4_set_inode_flags(struct inode *inode, bool init) 4426 4429 { 4427 4430 unsigned int flags = EXT4_I(inode)->i_flags; 4428 4431 unsigned int new_fl = 0; 4432 + 4433 + WARN_ON_ONCE(IS_DAX(inode) && init); 4429 4434 4430 4435 if (flags & EXT4_SYNC_FL) 4431 4436 new_fl |= S_SYNC; ··· 4444 4435 new_fl |= S_NOATIME; 4445 4436 if (flags & EXT4_DIRSYNC_FL) 4446 4437 new_fl |= S_DIRSYNC; 4447 - if (ext4_should_use_dax(inode)) 4438 + 4439 + /* Because of the way inode_set_flags() works we must preserve S_DAX 4440 + * here if already set. */ 4441 + new_fl |= (inode->i_flags & S_DAX); 4442 + if (init && ext4_should_enable_dax(inode)) 4448 4443 new_fl |= S_DAX; 4444 + 4449 4445 if (flags & EXT4_ENCRYPT_FL) 4450 4446 new_fl |= S_ENCRYPTED; 4451 4447 if (flags & EXT4_CASEFOLD_FL) ··· 4664 4650 * not initialized on a new filesystem. */ 4665 4651 } 4666 4652 ei->i_flags = le32_to_cpu(raw_inode->i_flags); 4667 - ext4_set_inode_flags(inode); 4653 + ext4_set_inode_flags(inode, true); 4668 4654 inode->i_blocks = ext4_inode_blocks(raw_inode, ei); 4669 4655 ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl_lo); 4670 4656 if (ext4_has_feature_64bit(sb))
+54 -11
fs/ext4/ioctl.c
··· 292 292 return 0; 293 293 } 294 294 295 + static void ext4_dax_dontcache(struct inode *inode, unsigned int flags) 296 + { 297 + struct ext4_inode_info *ei = EXT4_I(inode); 298 + 299 + if (S_ISDIR(inode->i_mode)) 300 + return; 301 + 302 + if (test_opt2(inode->i_sb, DAX_NEVER) || 303 + test_opt(inode->i_sb, DAX_ALWAYS)) 304 + return; 305 + 306 + if ((ei->i_flags ^ flags) & EXT4_DAX_FL) 307 + d_mark_dontcache(inode); 308 + } 309 + 310 + static bool dax_compatible(struct inode *inode, unsigned int oldflags, 311 + unsigned int flags) 312 + { 313 + if (flags & EXT4_DAX_FL) { 314 + if ((oldflags & EXT4_DAX_MUT_EXCL) || 315 + ext4_test_inode_state(inode, 316 + EXT4_STATE_VERITY_IN_PROGRESS)) { 317 + return false; 318 + } 319 + } 320 + 321 + if ((flags & EXT4_DAX_MUT_EXCL) && (oldflags & EXT4_DAX_FL)) 322 + return false; 323 + 324 + return true; 325 + } 326 + 295 327 static int ext4_ioctl_setflags(struct inode *inode, 296 328 unsigned int flags) 297 329 { ··· 332 300 int err = -EPERM, migrate = 0; 333 301 struct ext4_iloc iloc; 334 302 unsigned int oldflags, mask, i; 335 - unsigned int jflag; 336 303 struct super_block *sb = inode->i_sb; 337 304 338 305 /* Is it quota file? Do not allow user to mess with it */ ··· 339 308 goto flags_out; 340 309 341 310 oldflags = ei->i_flags; 342 - 343 - /* The JOURNAL_DATA flag is modifiable only by root */ 344 - jflag = flags & EXT4_JOURNAL_DATA_FL; 345 311 346 312 err = vfs_ioc_setflags_prepare(inode, oldflags, flags); 347 313 if (err) ··· 348 320 * The JOURNAL_DATA flag can only be changed by 349 321 * the relevant capability. 350 322 */ 351 - if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) { 323 + if ((flags ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) { 352 324 if (!capable(CAP_SYS_RESOURCE)) 353 325 goto flags_out; 354 326 } 327 + 328 + if (!dax_compatible(inode, oldflags, flags)) { 329 + err = -EOPNOTSUPP; 330 + goto flags_out; 331 + } 332 + 355 333 if ((flags ^ oldflags) & EXT4_EXTENTS_FL) 356 334 migrate = 1; 357 335 ··· 403 369 if (err) 404 370 goto flags_err; 405 371 372 + ext4_dax_dontcache(inode, flags); 373 + 406 374 for (i = 0, mask = 1; i < 32; i++, mask <<= 1) { 407 375 if (!(mask & EXT4_FL_USER_MODIFIABLE)) 408 376 continue; ··· 417 381 ext4_clear_inode_flag(inode, i); 418 382 } 419 383 420 - ext4_set_inode_flags(inode); 384 + ext4_set_inode_flags(inode, false); 385 + 421 386 inode->i_ctime = current_time(inode); 422 387 423 388 err = ext4_mark_iloc_dirty(handle, inode, &iloc); ··· 427 390 if (err) 428 391 goto flags_out; 429 392 430 - if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) { 393 + if ((flags ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) { 431 394 /* 432 395 * Changes to the journaling mode can cause unsafe changes to 433 - * S_DAX if we are using the DAX mount option. 396 + * S_DAX if the inode is DAX 434 397 */ 435 - if (test_opt(inode->i_sb, DAX)) { 398 + if (IS_DAX(inode)) { 436 399 err = -EBUSY; 437 400 goto flags_out; 438 401 } 439 402 440 - err = ext4_change_inode_journal_flag(inode, jflag); 403 + err = ext4_change_inode_journal_flag(inode, 404 + flags & EXT4_JOURNAL_DATA_FL); 441 405 if (err) 442 406 goto flags_out; 443 407 } ··· 565 527 xflags |= FS_XFLAG_NOATIME; 566 528 if (iflags & EXT4_PROJINHERIT_FL) 567 529 xflags |= FS_XFLAG_PROJINHERIT; 530 + if (iflags & EXT4_DAX_FL) 531 + xflags |= FS_XFLAG_DAX; 568 532 return xflags; 569 533 } 570 534 571 535 #define EXT4_SUPPORTED_FS_XFLAGS (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | \ 572 536 FS_XFLAG_APPEND | FS_XFLAG_NODUMP | \ 573 - FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT) 537 + FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT | \ 538 + FS_XFLAG_DAX) 574 539 575 540 /* Transfer xflags flags to internal */ 576 541 static inline unsigned long ext4_xflags_to_iflags(__u32 xflags) ··· 592 551 iflags |= EXT4_NOATIME_FL; 593 552 if (xflags & FS_XFLAG_PROJINHERIT) 594 553 iflags |= EXT4_PROJINHERIT_FL; 554 + if (xflags & FS_XFLAG_DAX) 555 + iflags |= EXT4_DAX_FL; 595 556 596 557 return iflags; 597 558 }
+1 -1
fs/ext4/mballoc.c
··· 4708 4708 } 4709 4709 4710 4710 ac->ac_op = EXT4_MB_HISTORY_PREALLOC; 4711 - seq = *this_cpu_ptr(&discard_pa_seq); 4711 + seq = this_cpu_read(discard_pa_seq); 4712 4712 if (!ext4_mb_use_preallocated(ac)) { 4713 4713 ac->ac_op = EXT4_MB_HISTORY_ALLOC; 4714 4714 ext4_mb_normalize_request(ac, ar);
+89 -35
fs/ext4/super.c
··· 522 522 smp_wmb(); 523 523 sb->s_flags |= SB_RDONLY; 524 524 } else if (test_opt(sb, ERRORS_PANIC)) { 525 - if (EXT4_SB(sb)->s_journal && 526 - !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) 527 - return; 528 525 panic("EXT4-fs (device %s): panic forced after error\n", 529 526 sb->s_id); 530 527 } ··· 722 725 va_end(args); 723 726 724 727 if (sb_rdonly(sb) == 0) { 725 - ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); 726 728 EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; 729 + if (EXT4_SB(sb)->s_journal) 730 + jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); 731 + 732 + ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); 727 733 /* 728 734 * Make sure updated value of ->s_mount_flags will be visible 729 735 * before ->s_flags update 730 736 */ 731 737 smp_wmb(); 732 738 sb->s_flags |= SB_RDONLY; 733 - if (EXT4_SB(sb)->s_journal) 734 - jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); 735 739 } 736 - if (test_opt(sb, ERRORS_PANIC) && !system_going_down()) { 737 - if (EXT4_SB(sb)->s_journal && 738 - !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) 739 - return; 740 + if (test_opt(sb, ERRORS_PANIC) && !system_going_down()) 740 741 panic("EXT4-fs panic from previous error\n"); 741 - } 742 742 } 743 743 744 744 void __ext4_msg(struct super_block *sb, ··· 1318 1324 if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode))) 1319 1325 return -EINVAL; 1320 1326 1327 + if (ext4_test_inode_flag(inode, EXT4_INODE_DAX)) 1328 + return -EOPNOTSUPP; 1329 + 1321 1330 res = ext4_convert_inline_data(inode); 1322 1331 if (res) 1323 1332 return res; ··· 1346 1349 * Update inode->i_flags - S_ENCRYPTED will be enabled, 1347 1350 * S_DAX may be disabled 1348 1351 */ 1349 - ext4_set_inode_flags(inode); 1352 + ext4_set_inode_flags(inode, false); 1350 1353 } 1351 1354 return res; 1352 1355 } ··· 1373 1376 * Update inode->i_flags - S_ENCRYPTED will be enabled, 1374 1377 * S_DAX may be disabled 1375 1378 */ 1376 - ext4_set_inode_flags(inode); 1379 + ext4_set_inode_flags(inode, false); 1377 1380 res = ext4_mark_inode_dirty(handle, inode); 1378 1381 if (res) 1379 1382 EXT4_ERROR_INODE(inode, "Failed to mark inode dirty"); ··· 1511 1514 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, 1512 1515 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, 1513 1516 Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err, 1514 - Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_i_version, Opt_dax, 1517 + Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_i_version, 1518 + Opt_dax, Opt_dax_always, Opt_dax_inode, Opt_dax_never, 1515 1519 Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_warn_on_error, 1516 1520 Opt_nowarn_on_error, Opt_mblk_io_submit, 1517 1521 Opt_lazytime, Opt_nolazytime, Opt_debug_want_extra_isize, ··· 1579 1581 {Opt_nobarrier, "nobarrier"}, 1580 1582 {Opt_i_version, "i_version"}, 1581 1583 {Opt_dax, "dax"}, 1584 + {Opt_dax_always, "dax=always"}, 1585 + {Opt_dax_inode, "dax=inode"}, 1586 + {Opt_dax_never, "dax=never"}, 1582 1587 {Opt_stripe, "stripe=%u"}, 1583 1588 {Opt_delalloc, "delalloc"}, 1584 1589 {Opt_warn_on_error, "warn_on_error"}, ··· 1730 1729 #define MOPT_NO_EXT3 0x0200 1731 1730 #define MOPT_EXT4_ONLY (MOPT_NO_EXT2 | MOPT_NO_EXT3) 1732 1731 #define MOPT_STRING 0x0400 1732 + #define MOPT_SKIP 0x0800 1733 1733 1734 1734 static const struct mount_opts { 1735 1735 int token; ··· 1780 1778 {Opt_min_batch_time, 0, MOPT_GTE0}, 1781 1779 {Opt_inode_readahead_blks, 0, MOPT_GTE0}, 1782 1780 {Opt_init_itable, 0, MOPT_GTE0}, 1783 - {Opt_dax, EXT4_MOUNT_DAX, MOPT_SET}, 1781 + {Opt_dax, EXT4_MOUNT_DAX_ALWAYS, MOPT_SET | MOPT_SKIP}, 1782 + {Opt_dax_always, EXT4_MOUNT_DAX_ALWAYS, 1783 + MOPT_EXT4_ONLY | MOPT_SET | MOPT_SKIP}, 1784 + {Opt_dax_inode, EXT4_MOUNT2_DAX_INODE, 1785 + MOPT_EXT4_ONLY | MOPT_SET | MOPT_SKIP}, 1786 + {Opt_dax_never, EXT4_MOUNT2_DAX_NEVER, 1787 + MOPT_EXT4_ONLY | MOPT_SET | MOPT_SKIP}, 1784 1788 {Opt_stripe, 0, MOPT_GTE0}, 1785 1789 {Opt_resuid, 0, MOPT_GTE0}, 1786 1790 {Opt_resgid, 0, MOPT_GTE0}, ··· 2131 2123 } 2132 2124 sbi->s_jquota_fmt = m->mount_opt; 2133 2125 #endif 2134 - } else if (token == Opt_dax) { 2126 + } else if (token == Opt_dax || token == Opt_dax_always || 2127 + token == Opt_dax_inode || token == Opt_dax_never) { 2135 2128 #ifdef CONFIG_FS_DAX 2136 - ext4_msg(sb, KERN_WARNING, 2137 - "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); 2138 - sbi->s_mount_opt |= m->mount_opt; 2129 + switch (token) { 2130 + case Opt_dax: 2131 + case Opt_dax_always: 2132 + if (is_remount && 2133 + (!(sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) || 2134 + (sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER))) { 2135 + fail_dax_change_remount: 2136 + ext4_msg(sb, KERN_ERR, "can't change " 2137 + "dax mount option while remounting"); 2138 + return -1; 2139 + } 2140 + if (is_remount && 2141 + (test_opt(sb, DATA_FLAGS) == 2142 + EXT4_MOUNT_JOURNAL_DATA)) { 2143 + ext4_msg(sb, KERN_ERR, "can't mount with " 2144 + "both data=journal and dax"); 2145 + return -1; 2146 + } 2147 + ext4_msg(sb, KERN_WARNING, 2148 + "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); 2149 + sbi->s_mount_opt |= EXT4_MOUNT_DAX_ALWAYS; 2150 + sbi->s_mount_opt2 &= ~EXT4_MOUNT2_DAX_NEVER; 2151 + break; 2152 + case Opt_dax_never: 2153 + if (is_remount && 2154 + (!(sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER) || 2155 + (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS))) 2156 + goto fail_dax_change_remount; 2157 + sbi->s_mount_opt2 |= EXT4_MOUNT2_DAX_NEVER; 2158 + sbi->s_mount_opt &= ~EXT4_MOUNT_DAX_ALWAYS; 2159 + break; 2160 + case Opt_dax_inode: 2161 + if (is_remount && 2162 + ((sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) || 2163 + (sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER) || 2164 + !(sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_INODE))) 2165 + goto fail_dax_change_remount; 2166 + sbi->s_mount_opt &= ~EXT4_MOUNT_DAX_ALWAYS; 2167 + sbi->s_mount_opt2 &= ~EXT4_MOUNT2_DAX_NEVER; 2168 + /* Strictly for printing options */ 2169 + sbi->s_mount_opt2 |= EXT4_MOUNT2_DAX_INODE; 2170 + break; 2171 + } 2139 2172 #else 2140 2173 ext4_msg(sb, KERN_INFO, "dax option not supported"); 2174 + sbi->s_mount_opt2 |= EXT4_MOUNT2_DAX_NEVER; 2175 + sbi->s_mount_opt &= ~EXT4_MOUNT_DAX_ALWAYS; 2141 2176 return -1; 2142 2177 #endif 2143 2178 } else if (token == Opt_data_err_abort) { ··· 2344 2293 for (m = ext4_mount_opts; m->token != Opt_err; m++) { 2345 2294 int want_set = m->flags & MOPT_SET; 2346 2295 if (((m->flags & (MOPT_SET|MOPT_CLEAR)) == 0) || 2347 - (m->flags & MOPT_CLEAR_ERR)) 2296 + (m->flags & MOPT_CLEAR_ERR) || m->flags & MOPT_SKIP) 2348 2297 continue; 2349 2298 if (!nodefs && !(m->mount_opt & (sbi->s_mount_opt ^ def_mount_opt))) 2350 2299 continue; /* skip if same as the default */ ··· 2404 2353 2405 2354 fscrypt_show_test_dummy_encryption(seq, sep, sb); 2406 2355 2356 + if (test_opt(sb, DAX_ALWAYS)) { 2357 + if (IS_EXT2_SB(sb)) 2358 + SEQ_OPTS_PUTS("dax"); 2359 + else 2360 + SEQ_OPTS_PUTS("dax=always"); 2361 + } else if (test_opt2(sb, DAX_NEVER)) { 2362 + SEQ_OPTS_PUTS("dax=never"); 2363 + } else if (test_opt2(sb, DAX_INODE)) { 2364 + SEQ_OPTS_PUTS("dax=inode"); 2365 + } 2366 + 2407 2367 ext4_show_quota_options(seq, sb); 2408 2368 return 0; 2409 2369 } ··· 2445 2383 ext4_msg(sb, KERN_ERR, "revision level too high, " 2446 2384 "forcing read-only mode"); 2447 2385 err = -EROFS; 2386 + goto done; 2448 2387 } 2449 2388 if (read_only) 2450 2389 goto done; ··· 4080 4017 "both data=journal and delalloc"); 4081 4018 goto failed_mount; 4082 4019 } 4083 - if (test_opt(sb, DAX)) { 4020 + if (test_opt(sb, DAX_ALWAYS)) { 4084 4021 ext4_msg(sb, KERN_ERR, "can't mount with " 4085 4022 "both data=journal and dax"); 4086 4023 goto failed_mount; ··· 4190 4127 goto failed_mount; 4191 4128 } 4192 4129 4193 - if (sbi->s_mount_opt & EXT4_MOUNT_DAX) { 4130 + if (bdev_dax_supported(sb->s_bdev, blocksize)) 4131 + set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags); 4132 + 4133 + if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) { 4194 4134 if (ext4_has_feature_inline_data(sb)) { 4195 4135 ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" 4196 4136 " that may contain inline data"); 4197 4137 goto failed_mount; 4198 4138 } 4199 - if (!bdev_dax_supported(sb->s_bdev, blocksize)) { 4139 + if (!test_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags)) { 4200 4140 ext4_msg(sb, KERN_ERR, 4201 4141 "DAX unsupported by block device."); 4202 4142 goto failed_mount; ··· 5513 5447 err = -EINVAL; 5514 5448 goto restore_opts; 5515 5449 } 5516 - if (test_opt(sb, DAX)) { 5517 - ext4_msg(sb, KERN_ERR, "can't mount with " 5518 - "both data=journal and dax"); 5519 - err = -EINVAL; 5520 - goto restore_opts; 5521 - } 5522 5450 } else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) { 5523 5451 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { 5524 5452 ext4_msg(sb, KERN_ERR, "can't mount with " ··· 5526 5466 ext4_msg(sb, KERN_ERR, "can't enable nombcache during remount"); 5527 5467 err = -EINVAL; 5528 5468 goto restore_opts; 5529 - } 5530 - 5531 - if ((sbi->s_mount_opt ^ old_opts.s_mount_opt) & EXT4_MOUNT_DAX) { 5532 - ext4_msg(sb, KERN_WARNING, "warning: refusing change of " 5533 - "dax flag with busy inodes while remounting"); 5534 - sbi->s_mount_opt ^= EXT4_MOUNT_DAX; 5535 5469 } 5536 5470 5537 5471 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
+4 -1
fs/ext4/verity.c
··· 113 113 handle_t *handle; 114 114 int err; 115 115 116 + if (IS_DAX(inode) || ext4_test_inode_flag(inode, EXT4_INODE_DAX)) 117 + return -EINVAL; 118 + 116 119 if (ext4_verity_in_progress(inode)) 117 120 return -EBUSY; 118 121 ··· 244 241 if (err) 245 242 goto out_stop; 246 243 ext4_set_inode_flag(inode, EXT4_INODE_VERITY); 247 - ext4_set_inode_flags(inode); 244 + ext4_set_inode_flags(inode, false); 248 245 err = ext4_mark_iloc_dirty(handle, inode, &iloc); 249 246 } 250 247 out_stop:
+2
fs/ext4/xattr.c
··· 93 93 #ifdef CONFIG_EXT4_FS_SECURITY 94 94 [EXT4_XATTR_INDEX_SECURITY] = &ext4_xattr_security_handler, 95 95 #endif 96 + [EXT4_XATTR_INDEX_HURD] = &ext4_xattr_hurd_handler, 96 97 }; 97 98 98 99 const struct xattr_handler *ext4_xattr_handlers[] = { ··· 106 105 #ifdef CONFIG_EXT4_FS_SECURITY 107 106 &ext4_xattr_security_handler, 108 107 #endif 108 + &ext4_xattr_hurd_handler, 109 109 NULL 110 110 }; 111 111
+1
fs/ext4/xattr.h
··· 124 124 extern const struct xattr_handler ext4_xattr_user_handler; 125 125 extern const struct xattr_handler ext4_xattr_trusted_handler; 126 126 extern const struct xattr_handler ext4_xattr_security_handler; 127 + extern const struct xattr_handler ext4_xattr_hurd_handler; 127 128 128 129 #define EXT4_XATTR_NAME_ENCRYPTION_CONTEXT "c" 129 130
+51
fs/ext4/xattr_hurd.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * linux/fs/ext4/xattr_hurd.c 4 + * Handler for extended gnu attributes for the Hurd. 5 + * 6 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org> 7 + * Copyright (C) 2020 by Jan (janneke) Nieuwenhuizen, <janneke@gnu.org> 8 + */ 9 + 10 + #include <linux/init.h> 11 + #include <linux/string.h> 12 + #include "ext4.h" 13 + #include "xattr.h" 14 + 15 + static bool 16 + ext4_xattr_hurd_list(struct dentry *dentry) 17 + { 18 + return test_opt(dentry->d_sb, XATTR_USER); 19 + } 20 + 21 + static int 22 + ext4_xattr_hurd_get(const struct xattr_handler *handler, 23 + struct dentry *unused, struct inode *inode, 24 + const char *name, void *buffer, size_t size) 25 + { 26 + if (!test_opt(inode->i_sb, XATTR_USER)) 27 + return -EOPNOTSUPP; 28 + 29 + return ext4_xattr_get(inode, EXT4_XATTR_INDEX_HURD, 30 + name, buffer, size); 31 + } 32 + 33 + static int 34 + ext4_xattr_hurd_set(const struct xattr_handler *handler, 35 + struct dentry *unused, struct inode *inode, 36 + const char *name, const void *value, 37 + size_t size, int flags) 38 + { 39 + if (!test_opt(inode->i_sb, XATTR_USER)) 40 + return -EOPNOTSUPP; 41 + 42 + return ext4_xattr_set(inode, EXT4_XATTR_INDEX_HURD, 43 + name, value, size, flags); 44 + } 45 + 46 + const struct xattr_handler ext4_xattr_hurd_handler = { 47 + .prefix = XATTR_HURD_PREFIX, 48 + .list = ext4_xattr_hurd_list, 49 + .get = ext4_xattr_hurd_get, 50 + .set = ext4_xattr_hurd_set, 51 + };
+59 -55
fs/io-wq.c
··· 903 903 struct io_cb_cancel_data { 904 904 work_cancel_fn *fn; 905 905 void *data; 906 + int nr_running; 907 + int nr_pending; 908 + bool cancel_all; 906 909 }; 907 910 908 911 static bool io_wq_worker_cancel(struct io_worker *worker, void *data) 909 912 { 910 913 struct io_cb_cancel_data *match = data; 911 914 unsigned long flags; 912 - bool ret = false; 913 915 914 916 /* 915 917 * Hold the lock to avoid ->cur_work going out of scope, caller ··· 922 920 !(worker->cur_work->flags & IO_WQ_WORK_NO_CANCEL) && 923 921 match->fn(worker->cur_work, match->data)) { 924 922 send_sig(SIGINT, worker->task, 1); 925 - ret = true; 923 + match->nr_running++; 926 924 } 927 925 spin_unlock_irqrestore(&worker->lock, flags); 928 926 929 - return ret; 927 + return match->nr_running && !match->cancel_all; 930 928 } 931 929 932 - static enum io_wq_cancel io_wqe_cancel_work(struct io_wqe *wqe, 933 - struct io_cb_cancel_data *match) 930 + static void io_wqe_cancel_pending_work(struct io_wqe *wqe, 931 + struct io_cb_cancel_data *match) 934 932 { 935 933 struct io_wq_work_node *node, *prev; 936 934 struct io_wq_work *work; 937 935 unsigned long flags; 938 - bool found = false; 936 + 937 + retry: 938 + spin_lock_irqsave(&wqe->lock, flags); 939 + wq_list_for_each(node, prev, &wqe->work_list) { 940 + work = container_of(node, struct io_wq_work, list); 941 + if (!match->fn(work, match->data)) 942 + continue; 943 + 944 + wq_list_del(&wqe->work_list, node, prev); 945 + spin_unlock_irqrestore(&wqe->lock, flags); 946 + io_run_cancel(work, wqe); 947 + match->nr_pending++; 948 + if (!match->cancel_all) 949 + return; 950 + 951 + /* not safe to continue after unlock */ 952 + goto retry; 953 + } 954 + spin_unlock_irqrestore(&wqe->lock, flags); 955 + } 956 + 957 + static void io_wqe_cancel_running_work(struct io_wqe *wqe, 958 + struct io_cb_cancel_data *match) 959 + { 960 + rcu_read_lock(); 961 + io_wq_for_each_worker(wqe, io_wq_worker_cancel, match); 962 + rcu_read_unlock(); 963 + } 964 + 965 + enum io_wq_cancel io_wq_cancel_cb(struct io_wq *wq, work_cancel_fn *cancel, 966 + void *data, bool cancel_all) 967 + { 968 + struct io_cb_cancel_data match = { 969 + .fn = cancel, 970 + .data = data, 971 + .cancel_all = cancel_all, 972 + }; 973 + int node; 939 974 940 975 /* 941 976 * First check pending list, if we're lucky we can just remove it 942 977 * from there. CANCEL_OK means that the work is returned as-new, 943 978 * no completion will be posted for it. 944 979 */ 945 - spin_lock_irqsave(&wqe->lock, flags); 946 - wq_list_for_each(node, prev, &wqe->work_list) { 947 - work = container_of(node, struct io_wq_work, list); 980 + for_each_node(node) { 981 + struct io_wqe *wqe = wq->wqes[node]; 948 982 949 - if (match->fn(work, match->data)) { 950 - wq_list_del(&wqe->work_list, node, prev); 951 - found = true; 952 - break; 953 - } 954 - } 955 - spin_unlock_irqrestore(&wqe->lock, flags); 956 - 957 - if (found) { 958 - io_run_cancel(work, wqe); 959 - return IO_WQ_CANCEL_OK; 983 + io_wqe_cancel_pending_work(wqe, &match); 984 + if (match.nr_pending && !match.cancel_all) 985 + return IO_WQ_CANCEL_OK; 960 986 } 961 987 962 988 /* ··· 993 963 * as an indication that we attempt to signal cancellation. The 994 964 * completion will run normally in this case. 995 965 */ 996 - rcu_read_lock(); 997 - found = io_wq_for_each_worker(wqe, io_wq_worker_cancel, match); 998 - rcu_read_unlock(); 999 - return found ? IO_WQ_CANCEL_RUNNING : IO_WQ_CANCEL_NOTFOUND; 1000 - } 1001 - 1002 - enum io_wq_cancel io_wq_cancel_cb(struct io_wq *wq, work_cancel_fn *cancel, 1003 - void *data) 1004 - { 1005 - struct io_cb_cancel_data match = { 1006 - .fn = cancel, 1007 - .data = data, 1008 - }; 1009 - enum io_wq_cancel ret = IO_WQ_CANCEL_NOTFOUND; 1010 - int node; 1011 - 1012 966 for_each_node(node) { 1013 967 struct io_wqe *wqe = wq->wqes[node]; 1014 968 1015 - ret = io_wqe_cancel_work(wqe, &match); 1016 - if (ret != IO_WQ_CANCEL_NOTFOUND) 1017 - break; 969 + io_wqe_cancel_running_work(wqe, &match); 970 + if (match.nr_running && !match.cancel_all) 971 + return IO_WQ_CANCEL_RUNNING; 1018 972 } 1019 973 1020 - return ret; 974 + if (match.nr_running) 975 + return IO_WQ_CANCEL_RUNNING; 976 + if (match.nr_pending) 977 + return IO_WQ_CANCEL_OK; 978 + return IO_WQ_CANCEL_NOTFOUND; 1021 979 } 1022 980 1023 981 static bool io_wq_io_cb_cancel_data(struct io_wq_work *work, void *data) ··· 1015 997 1016 998 enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork) 1017 999 { 1018 - return io_wq_cancel_cb(wq, io_wq_io_cb_cancel_data, (void *)cwork); 1019 - } 1020 - 1021 - static bool io_wq_pid_match(struct io_wq_work *work, void *data) 1022 - { 1023 - pid_t pid = (pid_t) (unsigned long) data; 1024 - 1025 - return work->task_pid == pid; 1026 - } 1027 - 1028 - enum io_wq_cancel io_wq_cancel_pid(struct io_wq *wq, pid_t pid) 1029 - { 1030 - void *data = (void *) (unsigned long) pid; 1031 - 1032 - return io_wq_cancel_cb(wq, io_wq_pid_match, data); 1000 + return io_wq_cancel_cb(wq, io_wq_io_cb_cancel_data, (void *)cwork, false); 1033 1001 } 1034 1002 1035 1003 struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data)
+1 -3
fs/io-wq.h
··· 90 90 const struct cred *creds; 91 91 struct fs_struct *fs; 92 92 unsigned flags; 93 - pid_t task_pid; 94 93 }; 95 94 96 95 static inline struct io_wq_work *wq_next_work(struct io_wq_work *work) ··· 124 125 125 126 void io_wq_cancel_all(struct io_wq *wq); 126 127 enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork); 127 - enum io_wq_cancel io_wq_cancel_pid(struct io_wq *wq, pid_t pid); 128 128 129 129 typedef bool (work_cancel_fn)(struct io_wq_work *, void *); 130 130 131 131 enum io_wq_cancel io_wq_cancel_cb(struct io_wq *wq, work_cancel_fn *cancel, 132 - void *data); 132 + void *data, bool cancel_all); 133 133 134 134 struct task_struct *io_wq_get_task(struct io_wq *wq); 135 135
+120 -57
fs/io_uring.c
··· 541 541 REQ_F_NO_FILE_TABLE_BIT, 542 542 REQ_F_QUEUE_TIMEOUT_BIT, 543 543 REQ_F_WORK_INITIALIZED_BIT, 544 + REQ_F_TASK_PINNED_BIT, 544 545 545 546 /* not a real bit, just to check we're not overflowing the space */ 546 547 __REQ_F_LAST_BIT, ··· 599 598 REQ_F_QUEUE_TIMEOUT = BIT(REQ_F_QUEUE_TIMEOUT_BIT), 600 599 /* io_wq_work is initialized */ 601 600 REQ_F_WORK_INITIALIZED = BIT(REQ_F_WORK_INITIALIZED_BIT), 601 + /* req->task is refcounted */ 602 + REQ_F_TASK_PINNED = BIT(REQ_F_TASK_PINNED_BIT), 602 603 }; 603 604 604 605 struct async_poll { ··· 913 910 } 914 911 EXPORT_SYMBOL(io_uring_get_socket); 915 912 913 + static void io_get_req_task(struct io_kiocb *req) 914 + { 915 + if (req->flags & REQ_F_TASK_PINNED) 916 + return; 917 + get_task_struct(req->task); 918 + req->flags |= REQ_F_TASK_PINNED; 919 + } 920 + 921 + /* not idempotent -- it doesn't clear REQ_F_TASK_PINNED */ 922 + static void __io_put_req_task(struct io_kiocb *req) 923 + { 924 + if (req->flags & REQ_F_TASK_PINNED) 925 + put_task_struct(req->task); 926 + } 927 + 916 928 static void io_file_put_work(struct work_struct *work); 917 929 918 930 /* ··· 1063 1045 } 1064 1046 spin_unlock(&current->fs->lock); 1065 1047 } 1066 - if (!req->work.task_pid) 1067 - req->work.task_pid = task_pid_vnr(current); 1068 1048 } 1069 1049 1070 1050 static inline void io_req_work_drop_env(struct io_kiocb *req) ··· 1103 1087 req->work.flags |= IO_WQ_WORK_UNBOUND; 1104 1088 } 1105 1089 1090 + io_req_init_async(req); 1106 1091 io_req_work_grab_env(req, def); 1107 1092 1108 1093 *link = io_prep_linked_timeout(req); ··· 1415 1398 kfree(req->io); 1416 1399 if (req->file) 1417 1400 io_put_file(req, req->file, (req->flags & REQ_F_FIXED_FILE)); 1418 - if (req->task) 1419 - put_task_struct(req->task); 1420 - 1401 + __io_put_req_task(req); 1421 1402 io_req_work_drop_env(req); 1422 1403 } 1423 1404 ··· 1742 1727 return cflags; 1743 1728 } 1744 1729 1730 + static void io_iopoll_queue(struct list_head *again) 1731 + { 1732 + struct io_kiocb *req; 1733 + 1734 + do { 1735 + req = list_first_entry(again, struct io_kiocb, list); 1736 + list_del(&req->list); 1737 + refcount_inc(&req->refs); 1738 + io_queue_async_work(req); 1739 + } while (!list_empty(again)); 1740 + } 1741 + 1745 1742 /* 1746 1743 * Find and free completed poll iocbs 1747 1744 */ ··· 1762 1735 { 1763 1736 struct req_batch rb; 1764 1737 struct io_kiocb *req; 1738 + LIST_HEAD(again); 1739 + 1740 + /* order with ->result store in io_complete_rw_iopoll() */ 1741 + smp_rmb(); 1765 1742 1766 1743 rb.to_free = rb.need_iter = 0; 1767 1744 while (!list_empty(done)) { 1768 1745 int cflags = 0; 1769 1746 1770 1747 req = list_first_entry(done, struct io_kiocb, list); 1748 + if (READ_ONCE(req->result) == -EAGAIN) { 1749 + req->iopoll_completed = 0; 1750 + list_move_tail(&req->list, &again); 1751 + continue; 1752 + } 1771 1753 list_del(&req->list); 1772 1754 1773 1755 if (req->flags & REQ_F_BUFFER_SELECTED) ··· 1794 1758 if (ctx->flags & IORING_SETUP_SQPOLL) 1795 1759 io_cqring_ev_posted(ctx); 1796 1760 io_free_req_many(ctx, &rb); 1797 - } 1798 1761 1799 - static void io_iopoll_queue(struct list_head *again) 1800 - { 1801 - struct io_kiocb *req; 1802 - 1803 - do { 1804 - req = list_first_entry(again, struct io_kiocb, list); 1805 - list_del(&req->list); 1806 - refcount_inc(&req->refs); 1807 - io_queue_async_work(req); 1808 - } while (!list_empty(again)); 1762 + if (!list_empty(&again)) 1763 + io_iopoll_queue(&again); 1809 1764 } 1810 1765 1811 1766 static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events, ··· 1804 1777 { 1805 1778 struct io_kiocb *req, *tmp; 1806 1779 LIST_HEAD(done); 1807 - LIST_HEAD(again); 1808 1780 bool spin; 1809 1781 int ret; 1810 1782 ··· 1829 1803 if (!list_empty(&done)) 1830 1804 break; 1831 1805 1832 - if (req->result == -EAGAIN) { 1833 - list_move_tail(&req->list, &again); 1834 - continue; 1835 - } 1836 - if (!list_empty(&again)) 1837 - break; 1838 - 1839 1806 ret = kiocb->ki_filp->f_op->iopoll(kiocb, spin); 1840 1807 if (ret < 0) 1841 1808 break; ··· 1840 1821 1841 1822 if (!list_empty(&done)) 1842 1823 io_iopoll_complete(ctx, nr_events, &done); 1843 - 1844 - if (!list_empty(&again)) 1845 - io_iopoll_queue(&again); 1846 1824 1847 1825 return ret; 1848 1826 } ··· 1989 1973 if (kiocb->ki_flags & IOCB_WRITE) 1990 1974 kiocb_end_write(req); 1991 1975 1992 - if (res != req->result) 1976 + if (res != -EAGAIN && res != req->result) 1993 1977 req_set_fail_links(req); 1994 - req->result = res; 1995 - if (res != -EAGAIN) 1978 + 1979 + WRITE_ONCE(req->result, res); 1980 + /* order with io_poll_complete() checking ->result */ 1981 + if (res != -EAGAIN) { 1982 + smp_wmb(); 1996 1983 WRITE_ONCE(req->iopoll_completed, 1); 1984 + } 1997 1985 } 1998 1986 1999 1987 /* ··· 2670 2650 } 2671 2651 } 2672 2652 out_free: 2673 - kfree(iovec); 2674 - req->flags &= ~REQ_F_NEED_CLEANUP; 2653 + if (!(req->flags & REQ_F_NEED_CLEANUP)) 2654 + kfree(iovec); 2675 2655 return ret; 2676 2656 } 2677 2657 ··· 2793 2773 } 2794 2774 } 2795 2775 out_free: 2796 - req->flags &= ~REQ_F_NEED_CLEANUP; 2797 - kfree(iovec); 2776 + if (!(req->flags & REQ_F_NEED_CLEANUP)) 2777 + kfree(iovec); 2798 2778 return ret; 2799 2779 } 2800 2780 ··· 4256 4236 __io_queue_proc(&pt->req->apoll->poll, pt, head); 4257 4237 } 4258 4238 4239 + static void io_sq_thread_drop_mm(struct io_ring_ctx *ctx) 4240 + { 4241 + struct mm_struct *mm = current->mm; 4242 + 4243 + if (mm) { 4244 + kthread_unuse_mm(mm); 4245 + mmput(mm); 4246 + } 4247 + } 4248 + 4249 + static int io_sq_thread_acquire_mm(struct io_ring_ctx *ctx, 4250 + struct io_kiocb *req) 4251 + { 4252 + if (io_op_defs[req->opcode].needs_mm && !current->mm) { 4253 + if (unlikely(!mmget_not_zero(ctx->sqo_mm))) 4254 + return -EFAULT; 4255 + kthread_use_mm(ctx->sqo_mm); 4256 + } 4257 + 4258 + return 0; 4259 + } 4260 + 4259 4261 static void io_async_task_func(struct callback_head *cb) 4260 4262 { 4261 4263 struct io_kiocb *req = container_of(cb, struct io_kiocb, task_work); ··· 4312 4270 4313 4271 if (!canceled) { 4314 4272 __set_current_state(TASK_RUNNING); 4273 + if (io_sq_thread_acquire_mm(ctx, req)) { 4274 + io_cqring_add_event(req, -EFAULT); 4275 + goto end_req; 4276 + } 4315 4277 mutex_lock(&ctx->uring_lock); 4316 4278 __io_queue_sqe(req, NULL); 4317 4279 mutex_unlock(&ctx->uring_lock); 4318 4280 } else { 4319 4281 io_cqring_ev_posted(ctx); 4282 + end_req: 4320 4283 req_set_fail_links(req); 4321 4284 io_double_put_req(req); 4322 4285 } ··· 4413 4366 memcpy(&apoll->work, &req->work, sizeof(req->work)); 4414 4367 had_io = req->io != NULL; 4415 4368 4416 - get_task_struct(current); 4417 - req->task = current; 4369 + io_get_req_task(req); 4418 4370 req->apoll = apoll; 4419 4371 INIT_HLIST_NODE(&req->hash_node); 4420 4372 ··· 4601 4555 events = READ_ONCE(sqe->poll_events); 4602 4556 poll->events = demangle_poll(events) | EPOLLERR | EPOLLHUP; 4603 4557 4604 - get_task_struct(current); 4605 - req->task = current; 4558 + io_get_req_task(req); 4606 4559 return 0; 4607 4560 } 4608 4561 ··· 4817 4772 enum io_wq_cancel cancel_ret; 4818 4773 int ret = 0; 4819 4774 4820 - cancel_ret = io_wq_cancel_cb(ctx->io_wq, io_cancel_cb, sqe_addr); 4775 + cancel_ret = io_wq_cancel_cb(ctx->io_wq, io_cancel_cb, sqe_addr, false); 4821 4776 switch (cancel_ret) { 4822 4777 case IO_WQ_CANCEL_OK: 4823 4778 ret = 0; ··· 5862 5817 req->flags = 0; 5863 5818 /* one is dropped after submission, the other at completion */ 5864 5819 refcount_set(&req->refs, 2); 5865 - req->task = NULL; 5820 + req->task = current; 5866 5821 req->result = 0; 5867 5822 5868 5823 if (unlikely(req->opcode >= IORING_OP_LAST)) 5869 5824 return -EINVAL; 5870 5825 5871 - if (io_op_defs[req->opcode].needs_mm && !current->mm) { 5872 - if (unlikely(!mmget_not_zero(ctx->sqo_mm))) 5873 - return -EFAULT; 5874 - kthread_use_mm(ctx->sqo_mm); 5875 - } 5826 + if (unlikely(io_sq_thread_acquire_mm(ctx, req))) 5827 + return -EFAULT; 5876 5828 5877 5829 sqe_flags = READ_ONCE(sqe->flags); 5878 5830 /* enforce forwards compatibility on users */ ··· 5976 5934 io_commit_sqring(ctx); 5977 5935 5978 5936 return submitted; 5979 - } 5980 - 5981 - static inline void io_sq_thread_drop_mm(struct io_ring_ctx *ctx) 5982 - { 5983 - struct mm_struct *mm = current->mm; 5984 - 5985 - if (mm) { 5986 - kthread_unuse_mm(mm); 5987 - mmput(mm); 5988 - } 5989 5937 } 5990 5938 5991 5939 static int io_sq_thread(void *data) ··· 7363 7331 if (ctx->rings) 7364 7332 io_cqring_overflow_flush(ctx, true); 7365 7333 7366 - wait_for_completion(&ctx->ref_comp); 7334 + /* 7335 + * If we're doing polled IO and end up having requests being 7336 + * submitted async (out-of-line), then completions can come in while 7337 + * we're waiting for refs to drop. We need to reap these manually, 7338 + * as nobody else will be looking for them. 7339 + */ 7340 + while (!wait_for_completion_timeout(&ctx->ref_comp, HZ/20)) { 7341 + io_iopoll_reap_events(ctx); 7342 + if (ctx->rings) 7343 + io_cqring_overflow_flush(ctx, true); 7344 + } 7367 7345 io_ring_ctx_free(ctx); 7368 7346 } 7369 7347 ··· 7407 7365 return 0; 7408 7366 } 7409 7367 7368 + static bool io_wq_files_match(struct io_wq_work *work, void *data) 7369 + { 7370 + struct files_struct *files = data; 7371 + 7372 + return work->files == files; 7373 + } 7374 + 7410 7375 static void io_uring_cancel_files(struct io_ring_ctx *ctx, 7411 7376 struct files_struct *files) 7412 7377 { 7378 + if (list_empty_careful(&ctx->inflight_list)) 7379 + return; 7380 + 7381 + /* cancel all at once, should be faster than doing it one by one*/ 7382 + io_wq_cancel_cb(ctx->io_wq, io_wq_files_match, files, true); 7383 + 7413 7384 while (!list_empty_careful(&ctx->inflight_list)) { 7414 7385 struct io_kiocb *cancel_req = NULL, *req; 7415 7386 DEFINE_WAIT(wait); ··· 7478 7423 } 7479 7424 } 7480 7425 7426 + static bool io_cancel_task_cb(struct io_wq_work *work, void *data) 7427 + { 7428 + struct io_kiocb *req = container_of(work, struct io_kiocb, work); 7429 + struct task_struct *task = data; 7430 + 7431 + return req->task == task; 7432 + } 7433 + 7481 7434 static int io_uring_flush(struct file *file, void *data) 7482 7435 { 7483 7436 struct io_ring_ctx *ctx = file->private_data; ··· 7496 7433 * If the task is going away, cancel work it may have pending 7497 7434 */ 7498 7435 if (fatal_signal_pending(current) || (current->flags & PF_EXITING)) 7499 - io_wq_cancel_pid(ctx->io_wq, task_pid_vnr(current)); 7436 + io_wq_cancel_cb(ctx->io_wq, io_cancel_task_cb, current, true); 7500 7437 7501 7438 return 0; 7502 7439 }
+12 -5
fs/jbd2/journal.c
··· 1140 1140 init_waitqueue_head(&journal->j_wait_commit); 1141 1141 init_waitqueue_head(&journal->j_wait_updates); 1142 1142 init_waitqueue_head(&journal->j_wait_reserved); 1143 + mutex_init(&journal->j_abort_mutex); 1143 1144 mutex_init(&journal->j_barrier); 1144 1145 mutex_init(&journal->j_checkpoint_mutex); 1145 1146 spin_lock_init(&journal->j_revoke_lock); ··· 1403 1402 printk(KERN_ERR "JBD2: Error %d detected when updating " 1404 1403 "journal superblock for %s.\n", ret, 1405 1404 journal->j_devname); 1406 - jbd2_journal_abort(journal, ret); 1405 + if (!is_journal_aborted(journal)) 1406 + jbd2_journal_abort(journal, ret); 1407 1407 } 1408 1408 1409 1409 return ret; ··· 2156 2154 transaction_t *transaction; 2157 2155 2158 2156 /* 2157 + * Lock the aborting procedure until everything is done, this avoid 2158 + * races between filesystem's error handling flow (e.g. ext4_abort()), 2159 + * ensure panic after the error info is written into journal's 2160 + * superblock. 2161 + */ 2162 + mutex_lock(&journal->j_abort_mutex); 2163 + /* 2159 2164 * ESHUTDOWN always takes precedence because a file system check 2160 2165 * caused by any other journal abort error is not required after 2161 2166 * a shutdown triggered. ··· 2176 2167 journal->j_errno = errno; 2177 2168 jbd2_journal_update_sb_errno(journal); 2178 2169 } 2170 + mutex_unlock(&journal->j_abort_mutex); 2179 2171 return; 2180 2172 } 2181 2173 ··· 2198 2188 * layer could realise that a filesystem check is needed. 2199 2189 */ 2200 2190 jbd2_journal_update_sb_errno(journal); 2201 - 2202 - write_lock(&journal->j_state_lock); 2203 - journal->j_flags |= JBD2_REC_ERR; 2204 - write_unlock(&journal->j_state_lock); 2191 + mutex_unlock(&journal->j_abort_mutex); 2205 2192 } 2206 2193 2207 2194 /**
+1 -1
fs/jffs2/nodelist.h
··· 259 259 uint32_t ino; /* == zero for unlink */ 260 260 unsigned int nhash; 261 261 unsigned char type; 262 - unsigned char name[0]; 262 + unsigned char name[]; 263 263 }; 264 264 265 265 /*
+2 -2
fs/jffs2/summary.h
··· 61 61 jint32_t ino; /* == zero for unlink */ 62 62 uint8_t nsize; /* dirent name size */ 63 63 uint8_t type; /* dirent type */ 64 - uint8_t name[0]; /* dirent name */ 64 + uint8_t name[]; /* dirent name */ 65 65 } __attribute__((packed)); 66 66 67 67 struct jffs2_sum_xattr_flash ··· 117 117 jint32_t ino; /* == zero for unlink */ 118 118 uint8_t nsize; /* dirent name size */ 119 119 uint8_t type; /* dirent type */ 120 - uint8_t name[0]; /* dirent name */ 120 + uint8_t name[]; /* dirent name */ 121 121 } __attribute__((packed)); 122 122 123 123 struct jffs2_sum_xattr_mem
+10 -5
fs/proc/bootconfig.c
··· 26 26 static int __init copy_xbc_key_value_list(char *dst, size_t size) 27 27 { 28 28 struct xbc_node *leaf, *vnode; 29 - const char *val; 30 29 char *key, *end = dst + size; 30 + const char *val; 31 + char q; 31 32 int ret = 0; 32 33 33 34 key = kzalloc(XBC_KEYLEN_MAX, GFP_KERNEL); ··· 42 41 break; 43 42 dst += ret; 44 43 vnode = xbc_node_get_child(leaf); 45 - if (vnode && xbc_node_is_array(vnode)) { 44 + if (vnode) { 46 45 xbc_array_for_each_value(vnode, val) { 47 - ret = snprintf(dst, rest(dst, end), "\"%s\"%s", 48 - val, vnode->next ? ", " : "\n"); 46 + if (strchr(val, '"')) 47 + q = '\''; 48 + else 49 + q = '"'; 50 + ret = snprintf(dst, rest(dst, end), "%c%s%c%s", 51 + q, val, q, vnode->next ? ", " : "\n"); 49 52 if (ret < 0) 50 53 goto out; 51 54 dst += ret; 52 55 } 53 56 } else { 54 - ret = snprintf(dst, rest(dst, end), "\"%s\"\n", val); 57 + ret = snprintf(dst, rest(dst, end), "\"\"\n"); 55 58 if (ret < 0) 56 59 break; 57 60 dst += ret;
+2 -1
fs/proc/kcore.c
··· 512 512 * Using bounce buffer to bypass the 513 513 * hardened user copy kernel text checks. 514 514 */ 515 - if (probe_kernel_read(buf, (void *) start, tsz)) { 515 + if (copy_from_kernel_nofault(buf, (void *)start, 516 + tsz)) { 516 517 if (clear_user(buffer, tsz)) { 517 518 ret = -EFAULT; 518 519 goto out;
+8 -8
fs/squashfs/squashfs_fs.h
··· 262 262 __le32 index; 263 263 __le32 start_block; 264 264 __le32 size; 265 - unsigned char name[0]; 265 + unsigned char name[]; 266 266 }; 267 267 268 268 struct squashfs_base_inode { ··· 327 327 __le32 inode_number; 328 328 __le32 nlink; 329 329 __le32 symlink_size; 330 - char symlink[0]; 330 + char symlink[]; 331 331 }; 332 332 333 333 struct squashfs_reg_inode { ··· 341 341 __le32 fragment; 342 342 __le32 offset; 343 343 __le32 file_size; 344 - __le16 block_list[0]; 344 + __le16 block_list[]; 345 345 }; 346 346 347 347 struct squashfs_lreg_inode { ··· 358 358 __le32 fragment; 359 359 __le32 offset; 360 360 __le32 xattr; 361 - __le16 block_list[0]; 361 + __le16 block_list[]; 362 362 }; 363 363 364 364 struct squashfs_dir_inode { ··· 389 389 __le16 i_count; 390 390 __le16 offset; 391 391 __le32 xattr; 392 - struct squashfs_dir_index index[0]; 392 + struct squashfs_dir_index index[]; 393 393 }; 394 394 395 395 union squashfs_inode { ··· 410 410 __le16 inode_number; 411 411 __le16 type; 412 412 __le16 size; 413 - char name[0]; 413 + char name[]; 414 414 }; 415 415 416 416 struct squashfs_dir_header { ··· 428 428 struct squashfs_xattr_entry { 429 429 __le16 type; 430 430 __le16 size; 431 - char data[0]; 431 + char data[]; 432 432 }; 433 433 434 434 struct squashfs_xattr_val { 435 435 __le32 vsize; 436 - char value[0]; 436 + char value[]; 437 437 }; 438 438 439 439 struct squashfs_xattr_id {
+1 -1
include/asm-generic/hugetlb.h
··· 122 122 #ifndef __HAVE_ARCH_HUGE_PTEP_GET 123 123 static inline pte_t huge_ptep_get(pte_t *ptep) 124 124 { 125 - return READ_ONCE(*ptep); 125 + return ptep_get(ptep); 126 126 } 127 127 #endif 128 128
+1 -1
include/drm/drm_displayid.h
··· 89 89 90 90 struct displayid_detailed_timing_block { 91 91 struct displayid_block base; 92 - struct displayid_detailed_timings_1 timings[0]; 92 + struct displayid_detailed_timings_1 timings[]; 93 93 }; 94 94 95 95 #define for_each_displayid_db(displayid, block, idx, length) \
+1 -1
include/keys/encrypted-type.h
··· 27 27 unsigned short payload_datalen; /* payload data length */ 28 28 unsigned short encrypted_key_format; /* encrypted key format */ 29 29 u8 *decrypted_data; /* decrypted data */ 30 - u8 payload_data[0]; /* payload data + datablob + hmac */ 30 + u8 payload_data[]; /* payload data + datablob + hmac */ 31 31 }; 32 32 33 33 extern struct key_type key_type_encrypted;
+2 -2
include/keys/rxrpc-type.h
··· 28 28 u8 primary_flag; /* T if key for primary cell for this user */ 29 29 u16 ticket_len; /* length of ticket[] */ 30 30 u8 session_key[8]; /* DES session key */ 31 - u8 ticket[0]; /* the encrypted ticket */ 31 + u8 ticket[]; /* the encrypted ticket */ 32 32 }; 33 33 34 34 /* ··· 100 100 u32 expiry; /* time_t */ 101 101 u32 kvno; 102 102 u8 session_key[8]; 103 - u8 ticket[0]; 103 + u8 ticket[]; 104 104 }; 105 105 106 106 /*
+1 -1
include/linux/can/skb.h
··· 34 34 struct can_skb_priv { 35 35 int ifindex; 36 36 int skbcnt; 37 - struct can_frame cf[0]; 37 + struct can_frame cf[]; 38 38 }; 39 39 40 40 static inline struct can_skb_priv *can_skb_prv(struct sk_buff *skb)
+1 -1
include/linux/cb710.h
··· 36 36 unsigned slot_mask; 37 37 unsigned slots; 38 38 spinlock_t irq_lock; 39 - struct cb710_slot slot[0]; 39 + struct cb710_slot slot[]; 40 40 }; 41 41 42 42 /* NOTE: cb710_chip.slots is modified only during device init/exit and
+2 -2
include/linux/ceph/libceph.h
··· 52 52 unsigned long osd_idle_ttl; /* jiffies */ 53 53 unsigned long osd_keepalive_timeout; /* jiffies */ 54 54 unsigned long osd_request_timeout; /* jiffies */ 55 - 56 - u32 osd_req_flags; /* CEPH_OSD_FLAG_*, applied to each OSD request */ 55 + u32 read_from_replica; /* CEPH_OSD_FLAG_BALANCE/LOCALIZE_READS */ 57 56 58 57 /* 59 58 * any type that can't be simply compared or doesn't need ··· 75 76 #define CEPH_OSD_KEEPALIVE_DEFAULT msecs_to_jiffies(5 * 1000) 76 77 #define CEPH_OSD_IDLE_TTL_DEFAULT msecs_to_jiffies(60 * 1000) 77 78 #define CEPH_OSD_REQUEST_TIMEOUT_DEFAULT 0 /* no timeout */ 79 + #define CEPH_READ_FROM_REPLICA_DEFAULT 0 /* read from primary */ 78 80 79 81 #define CEPH_MONC_HUNT_INTERVAL msecs_to_jiffies(3 * 1000) 80 82 #define CEPH_MONC_PING_INTERVAL msecs_to_jiffies(10 * 1000)
+4 -4
include/linux/compiler_types.h
··· 5 5 #ifndef __ASSEMBLY__ 6 6 7 7 #ifdef __CHECKER__ 8 - # define __user __attribute__((noderef, address_space(1))) 9 8 # define __kernel __attribute__((address_space(0))) 9 + # define __user __attribute__((noderef, address_space(__user))) 10 10 # define __safe __attribute__((safe)) 11 11 # define __force __attribute__((force)) 12 12 # define __nocast __attribute__((nocast)) 13 - # define __iomem __attribute__((noderef, address_space(2))) 13 + # define __iomem __attribute__((noderef, address_space(__iomem))) 14 14 # define __must_hold(x) __attribute__((context(x,1,1))) 15 15 # define __acquires(x) __attribute__((context(x,0,1))) 16 16 # define __releases(x) __attribute__((context(x,1,0))) 17 17 # define __acquire(x) __context__(x,1) 18 18 # define __release(x) __context__(x,-1) 19 19 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0) 20 - # define __percpu __attribute__((noderef, address_space(3))) 21 - # define __rcu __attribute__((noderef, address_space(4))) 20 + # define __percpu __attribute__((noderef, address_space(__percpu))) 21 + # define __rcu __attribute__((noderef, address_space(__rcu))) 22 22 # define __private __attribute__((noderef)) 23 23 extern void __chk_user_ptr(const volatile void __user *); 24 24 extern void __chk_io_ptr(const volatile void __iomem *);
+2 -2
include/linux/dmaengine.h
··· 153 153 bool dst_sgl; 154 154 size_t numf; 155 155 size_t frame_size; 156 - struct data_chunk sgl[0]; 156 + struct data_chunk sgl[]; 157 157 }; 158 158 159 159 /** ··· 535 535 struct device *dev; 536 536 struct kref kref; 537 537 size_t len; 538 - dma_addr_t addr[0]; 538 + dma_addr_t addr[]; 539 539 }; 540 540 541 541 struct dma_async_tx_descriptor;
-2
include/linux/fs.h
··· 2592 2592 extern void invalidate_bdev(struct block_device *); 2593 2593 extern void iterate_bdevs(void (*)(struct block_device *, void *), void *); 2594 2594 extern int sync_blockdev(struct block_device *bdev); 2595 - extern void kill_bdev(struct block_device *); 2596 2595 extern struct super_block *freeze_bdev(struct block_device *); 2597 2596 extern void emergency_thaw_all(void); 2598 2597 extern void emergency_thaw_bdev(struct super_block *sb); ··· 2607 2608 #else 2608 2609 static inline void bd_forget(struct inode *inode) {} 2609 2610 static inline int sync_blockdev(struct block_device *bdev) { return 0; } 2610 - static inline void kill_bdev(struct block_device *bdev) {} 2611 2611 static inline void invalidate_bdev(struct block_device *bdev) {} 2612 2612 2613 2613 static inline struct super_block *freeze_bdev(struct block_device *sb)
+1 -1
include/linux/fscache-cache.h
··· 46 46 unsigned long flags; 47 47 #define FSCACHE_TAG_RESERVED 0 /* T if tag is reserved for a cache */ 48 48 atomic_t usage; 49 - char name[0]; /* tag name */ 49 + char name[]; /* tag name */ 50 50 }; 51 51 52 52 /*
+3 -5
include/linux/i2c.h
··· 408 408 * that are present. This information is used to grow the driver model tree. 409 409 * For mainboards this is done statically using i2c_register_board_info(); 410 410 * bus numbers identify adapters that aren't yet available. For add-on boards, 411 - * i2c_new_device() does this dynamically with the adapter already known. 411 + * i2c_new_client_device() does this dynamically with the adapter already known. 412 412 */ 413 413 struct i2c_board_info { 414 414 char type[I2C_NAME_SIZE]; ··· 439 439 440 440 441 441 #if IS_ENABLED(CONFIG_I2C) 442 - /* Add-on boards should register/unregister their devices; e.g. a board 442 + /* 443 + * Add-on boards should register/unregister their devices; e.g. a board 443 444 * with integrated I2C, a config eeprom, sensors, and a codec that's 444 445 * used in conjunction with the primary hardware. 445 446 */ 446 - struct i2c_client * 447 - i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info); 448 - 449 447 struct i2c_client * 450 448 i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *info); 451 449
+5 -1
include/linux/jbd2.h
··· 766 766 int j_errno; 767 767 768 768 /** 769 + * @j_abort_mutex: Lock the whole aborting procedure. 770 + */ 771 + struct mutex j_abort_mutex; 772 + 773 + /** 769 774 * @j_sb_buffer: The first part of the superblock buffer. 770 775 */ 771 776 struct buffer_head *j_sb_buffer; ··· 1252 1247 #define JBD2_ABORT_ON_SYNCDATA_ERR 0x040 /* Abort the journal on file 1253 1248 * data write error in ordered 1254 1249 * mode */ 1255 - #define JBD2_REC_ERR 0x080 /* The errno in the sb has been recorded */ 1256 1250 1257 1251 /* 1258 1252 * Function declarations for the journaling transaction and buffer
+1 -1
include/linux/kexec.h
··· 208 208 struct crash_mem { 209 209 unsigned int max_nr_ranges; 210 210 unsigned int nr_ranges; 211 - struct crash_mem_range ranges[0]; 211 + struct crash_mem_range ranges[]; 212 212 }; 213 213 214 214 extern int crash_exclude_mem_range(struct crash_mem *mem,
+5 -1
include/linux/kprobes.h
··· 161 161 kprobe_opcode_t *ret_addr; 162 162 struct task_struct *task; 163 163 void *fp; 164 - char data[0]; 164 + char data[]; 165 165 }; 166 166 167 167 struct kretprobe_blackpoint { ··· 349 349 { 350 350 return this_cpu_ptr(&kprobe_ctlblk); 351 351 } 352 + 353 + extern struct kprobe kprobe_busy; 354 + void kprobe_busy_begin(void); 355 + void kprobe_busy_end(void); 352 356 353 357 kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset); 354 358 int register_kprobe(struct kprobe *p);
+1 -1
include/linux/kvm_host.h
··· 409 409 * Array indexed by gsi. Each entry contains list of irq chips 410 410 * the gsi is connected to. 411 411 */ 412 - struct hlist_head map[0]; 412 + struct hlist_head map[]; 413 413 }; 414 414 #endif 415 415
+8 -1
include/linux/libata.h
··· 22 22 #include <linux/acpi.h> 23 23 #include <linux/cdrom.h> 24 24 #include <linux/sched.h> 25 + #include <linux/async.h> 25 26 26 27 /* 27 28 * Define if arch has non-standard setup. This is a _PCI_ standard ··· 610 609 struct task_struct *eh_owner; 611 610 612 611 struct ata_port *simplex_claimed; /* channel owning the DMA */ 613 - struct ata_port *ports[0]; 612 + struct ata_port *ports[]; 614 613 }; 615 614 616 615 struct ata_queued_cmd { ··· 873 872 struct timer_list fastdrain_timer; 874 873 unsigned long fastdrain_cnt; 875 874 875 + async_cookie_t cookie; 876 + 876 877 int em_message_type; 877 878 void *private_data; 878 879 ··· 1095 1092 #define ATA_SCSI_COMPAT_IOCTL /* empty */ 1096 1093 #endif 1097 1094 extern int ata_scsi_queuecmd(struct Scsi_Host *h, struct scsi_cmnd *cmd); 1095 + #if IS_ENABLED(CONFIG_ATA) 1098 1096 bool ata_scsi_dma_need_drain(struct request *rq); 1097 + #else 1098 + #define ata_scsi_dma_need_drain NULL 1099 + #endif 1099 1100 extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev, 1100 1101 unsigned int cmd, void __user *arg); 1101 1102 extern bool ata_link_online(struct ata_link *link);
+51
include/linux/mlx5/rsc_dump.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 + /* Copyright (c) 2020 Mellanox Technologies inc. */ 3 + 4 + #include <linux/mlx5/driver.h> 5 + 6 + #ifndef __MLX5_RSC_DUMP 7 + #define __MLX5_RSC_DUMP 8 + 9 + enum mlx5_sgmt_type { 10 + MLX5_SGMT_TYPE_HW_CQPC, 11 + MLX5_SGMT_TYPE_HW_SQPC, 12 + MLX5_SGMT_TYPE_HW_RQPC, 13 + MLX5_SGMT_TYPE_FULL_SRQC, 14 + MLX5_SGMT_TYPE_FULL_CQC, 15 + MLX5_SGMT_TYPE_FULL_EQC, 16 + MLX5_SGMT_TYPE_FULL_QPC, 17 + MLX5_SGMT_TYPE_SND_BUFF, 18 + MLX5_SGMT_TYPE_RCV_BUFF, 19 + MLX5_SGMT_TYPE_SRQ_BUFF, 20 + MLX5_SGMT_TYPE_CQ_BUFF, 21 + MLX5_SGMT_TYPE_EQ_BUFF, 22 + MLX5_SGMT_TYPE_SX_SLICE, 23 + MLX5_SGMT_TYPE_SX_SLICE_ALL, 24 + MLX5_SGMT_TYPE_RDB, 25 + MLX5_SGMT_TYPE_RX_SLICE_ALL, 26 + MLX5_SGMT_TYPE_PRM_QUERY_QP, 27 + MLX5_SGMT_TYPE_PRM_QUERY_CQ, 28 + MLX5_SGMT_TYPE_PRM_QUERY_MKEY, 29 + MLX5_SGMT_TYPE_MENU, 30 + MLX5_SGMT_TYPE_TERMINATE, 31 + 32 + MLX5_SGMT_TYPE_NUM, /* Keep last */ 33 + }; 34 + 35 + struct mlx5_rsc_key { 36 + enum mlx5_sgmt_type rsc; 37 + int index1; 38 + int index2; 39 + int num_of_obj1; 40 + int num_of_obj2; 41 + int size; 42 + }; 43 + 44 + struct mlx5_rsc_dump_cmd; 45 + 46 + struct mlx5_rsc_dump_cmd *mlx5_rsc_dump_cmd_create(struct mlx5_core_dev *dev, 47 + struct mlx5_rsc_key *key); 48 + void mlx5_rsc_dump_cmd_destroy(struct mlx5_rsc_dump_cmd *cmd); 49 + int mlx5_rsc_dump_next(struct mlx5_core_dev *dev, struct mlx5_rsc_dump_cmd *cmd, 50 + struct page *page, int *size); 51 + #endif /* __MLX5_RSC_DUMP */
+21 -4
include/linux/overflow.h
··· 304 304 * struct_size() - Calculate size of structure with trailing array. 305 305 * @p: Pointer to the structure. 306 306 * @member: Name of the array member. 307 - * @n: Number of elements in the array. 307 + * @count: Number of elements in the array. 308 308 * 309 309 * Calculates size of memory needed for structure @p followed by an 310 - * array of @n @member elements. 310 + * array of @count number of @member elements. 311 311 * 312 312 * Return: number of bytes needed or SIZE_MAX on overflow. 313 313 */ 314 - #define struct_size(p, member, n) \ 315 - __ab_c_size(n, \ 314 + #define struct_size(p, member, count) \ 315 + __ab_c_size(count, \ 316 316 sizeof(*(p)->member) + __must_be_array((p)->member),\ 317 317 sizeof(*(p))) 318 + 319 + /** 320 + * flex_array_size() - Calculate size of a flexible array member 321 + * within an enclosing structure. 322 + * 323 + * @p: Pointer to the structure. 324 + * @member: Name of the flexible array member. 325 + * @count: Number of elements in the array. 326 + * 327 + * Calculates size of a flexible array of @count number of @member 328 + * elements, at the end of structure @p. 329 + * 330 + * Return: number of bytes needed or SIZE_MAX on overflow. 331 + */ 332 + #define flex_array_size(p, member, count) \ 333 + array_size(count, \ 334 + sizeof(*(p)->member) + __must_be_array((p)->member)) 318 335 319 336 #endif /* __LINUX_OVERFLOW_H */
+7
include/linux/pgtable.h
··· 249 249 } 250 250 #endif 251 251 252 + #ifndef __HAVE_ARCH_PTEP_GET 253 + static inline pte_t ptep_get(pte_t *ptep) 254 + { 255 + return READ_ONCE(*ptep); 256 + } 257 + #endif 258 + 252 259 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 253 260 #ifndef __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR 254 261 static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
+1 -1
include/linux/psp-sev.h
··· 597 597 */ 598 598 int sev_guest_decommission(struct sev_data_decommission *data, int *error); 599 599 600 - void *psp_copy_user_blob(u64 __user uaddr, u32 len); 600 + void *psp_copy_user_blob(u64 uaddr, u32 len); 601 601 602 602 #else /* !CONFIG_CRYPTO_DEV_SP_PSP */ 603 603
+18 -18
include/linux/sctp.h
··· 221 221 __be16 stream; 222 222 __be16 ssn; 223 223 __u32 ppid; 224 - __u8 payload[0]; 224 + __u8 payload[]; 225 225 }; 226 226 227 227 struct sctp_data_chunk { ··· 269 269 __be16 num_outbound_streams; 270 270 __be16 num_inbound_streams; 271 271 __be32 initial_tsn; 272 - __u8 params[0]; 272 + __u8 params[]; 273 273 }; 274 274 275 275 struct sctp_init_chunk { ··· 299 299 /* Section 3.3.2.1 Host Name Address (11) */ 300 300 struct sctp_hostname_param { 301 301 struct sctp_paramhdr param_hdr; 302 - uint8_t hostname[0]; 302 + uint8_t hostname[]; 303 303 }; 304 304 305 305 /* Section 3.3.2.1 Supported Address Types (12) */ 306 306 struct sctp_supported_addrs_param { 307 307 struct sctp_paramhdr param_hdr; 308 - __be16 types[0]; 308 + __be16 types[]; 309 309 }; 310 310 311 311 /* ADDIP Section 3.2.6 Adaptation Layer Indication */ ··· 317 317 /* ADDIP Section 4.2.7 Supported Extensions Parameter */ 318 318 struct sctp_supported_ext_param { 319 319 struct sctp_paramhdr param_hdr; 320 - __u8 chunks[0]; 320 + __u8 chunks[]; 321 321 }; 322 322 323 323 /* AUTH Section 3.1 Random */ 324 324 struct sctp_random_param { 325 325 struct sctp_paramhdr param_hdr; 326 - __u8 random_val[0]; 326 + __u8 random_val[]; 327 327 }; 328 328 329 329 /* AUTH Section 3.2 Chunk List */ 330 330 struct sctp_chunks_param { 331 331 struct sctp_paramhdr param_hdr; 332 - __u8 chunks[0]; 332 + __u8 chunks[]; 333 333 }; 334 334 335 335 /* AUTH Section 3.3 HMAC Algorithm */ 336 336 struct sctp_hmac_algo_param { 337 337 struct sctp_paramhdr param_hdr; 338 - __be16 hmac_ids[0]; 338 + __be16 hmac_ids[]; 339 339 }; 340 340 341 341 /* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2): ··· 350 350 /* Section 3.3.3.1 State Cookie (7) */ 351 351 struct sctp_cookie_param { 352 352 struct sctp_paramhdr p; 353 - __u8 body[0]; 353 + __u8 body[]; 354 354 }; 355 355 356 356 /* Section 3.3.3.1 Unrecognized Parameters (8) */ ··· 384 384 __be32 a_rwnd; 385 385 __be16 num_gap_ack_blocks; 386 386 __be16 num_dup_tsns; 387 - union sctp_sack_variable variable[0]; 387 + union sctp_sack_variable variable[]; 388 388 }; 389 389 390 390 struct sctp_sack_chunk { ··· 436 436 struct sctp_errhdr { 437 437 __be16 cause; 438 438 __be16 length; 439 - __u8 variable[0]; 439 + __u8 variable[]; 440 440 }; 441 441 442 442 struct sctp_operr_chunk { ··· 594 594 595 595 struct sctp_fwdtsn_hdr { 596 596 __be32 new_cum_tsn; 597 - struct sctp_fwdtsn_skip skip[0]; 597 + struct sctp_fwdtsn_skip skip[]; 598 598 }; 599 599 600 600 struct sctp_fwdtsn_chunk { ··· 611 611 612 612 struct sctp_ifwdtsn_hdr { 613 613 __be32 new_cum_tsn; 614 - struct sctp_ifwdtsn_skip skip[0]; 614 + struct sctp_ifwdtsn_skip skip[]; 615 615 }; 616 616 617 617 struct sctp_ifwdtsn_chunk { ··· 658 658 659 659 struct sctp_addiphdr { 660 660 __be32 serial; 661 - __u8 params[0]; 661 + __u8 params[]; 662 662 }; 663 663 664 664 struct sctp_addip_chunk { ··· 718 718 struct sctp_authhdr { 719 719 __be16 shkey_id; 720 720 __be16 hmac_id; 721 - __u8 hmac[0]; 721 + __u8 hmac[]; 722 722 }; 723 723 724 724 struct sctp_auth_chunk { ··· 733 733 734 734 struct sctp_reconf_chunk { 735 735 struct sctp_chunkhdr chunk_hdr; 736 - __u8 params[0]; 736 + __u8 params[]; 737 737 }; 738 738 739 739 struct sctp_strreset_outreq { ··· 741 741 __be32 request_seq; 742 742 __be32 response_seq; 743 743 __be32 send_reset_at_tsn; 744 - __be16 list_of_streams[0]; 744 + __be16 list_of_streams[]; 745 745 }; 746 746 747 747 struct sctp_strreset_inreq { 748 748 struct sctp_paramhdr param_hdr; 749 749 __be32 request_seq; 750 - __be16 list_of_streams[0]; 750 + __be16 list_of_streams[]; 751 751 }; 752 752 753 753 struct sctp_strreset_tsnreq {
+1 -1
include/linux/tifm.h
··· 124 124 int (*has_ms_pif)(struct tifm_adapter *fm, 125 125 struct tifm_dev *sock); 126 126 127 - struct tifm_dev *sockets[0]; 127 + struct tifm_dev *sockets[]; 128 128 }; 129 129 130 130 struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
+13 -10
include/linux/uaccess.h
··· 301 301 return 0; 302 302 } 303 303 304 - bool probe_kernel_read_allowed(const void *unsafe_src, size_t size); 304 + bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size); 305 305 306 - extern long probe_kernel_read(void *dst, const void *src, size_t size); 307 - extern long probe_user_read(void *dst, const void __user *src, size_t size); 306 + long copy_from_kernel_nofault(void *dst, const void *src, size_t size); 307 + long notrace copy_to_kernel_nofault(void *dst, const void *src, size_t size); 308 308 309 - extern long notrace probe_kernel_write(void *dst, const void *src, size_t size); 310 - extern long notrace probe_user_write(void __user *dst, const void *src, size_t size); 309 + long copy_from_user_nofault(void *dst, const void __user *src, size_t size); 310 + long notrace copy_to_user_nofault(void __user *dst, const void *src, 311 + size_t size); 311 312 312 313 long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, 313 314 long count); ··· 318 317 long strnlen_user_nofault(const void __user *unsafe_addr, long count); 319 318 320 319 /** 321 - * probe_kernel_address(): safely attempt to read from a location 322 - * @addr: address to read from 323 - * @retval: read into this variable 320 + * get_kernel_nofault(): safely attempt to read from a location 321 + * @val: read into this variable 322 + * @ptr: address to read from 324 323 * 325 324 * Returns 0 on success, or -EFAULT. 326 325 */ 327 - #define probe_kernel_address(addr, retval) \ 328 - probe_kernel_read(&retval, addr, sizeof(retval)) 326 + #define get_kernel_nofault(val, ptr) ({ \ 327 + const typeof(val) *__gk_ptr = (ptr); \ 328 + copy_from_kernel_nofault(&(val), __gk_ptr, sizeof(val));\ 329 + }) 329 330 330 331 #ifndef user_access_begin 331 332 #define user_access_begin(ptr,len) access_ok(ptr, len)
+45 -4
include/net/netfilter/nf_flow_table.h
··· 161 161 struct flow_offload *flow_offload_alloc(struct nf_conn *ct); 162 162 void flow_offload_free(struct flow_offload *flow); 163 163 164 - int nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table, 165 - flow_setup_cb_t *cb, void *cb_priv); 166 - void nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table, 167 - flow_setup_cb_t *cb, void *cb_priv); 164 + static inline int 165 + nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table, 166 + flow_setup_cb_t *cb, void *cb_priv) 167 + { 168 + struct flow_block *block = &flow_table->flow_block; 169 + struct flow_block_cb *block_cb; 170 + int err = 0; 171 + 172 + down_write(&flow_table->flow_block_lock); 173 + block_cb = flow_block_cb_lookup(block, cb, cb_priv); 174 + if (block_cb) { 175 + err = -EEXIST; 176 + goto unlock; 177 + } 178 + 179 + block_cb = flow_block_cb_alloc(cb, cb_priv, cb_priv, NULL); 180 + if (IS_ERR(block_cb)) { 181 + err = PTR_ERR(block_cb); 182 + goto unlock; 183 + } 184 + 185 + list_add_tail(&block_cb->list, &block->cb_list); 186 + 187 + unlock: 188 + up_write(&flow_table->flow_block_lock); 189 + return err; 190 + } 191 + 192 + static inline void 193 + nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table, 194 + flow_setup_cb_t *cb, void *cb_priv) 195 + { 196 + struct flow_block *block = &flow_table->flow_block; 197 + struct flow_block_cb *block_cb; 198 + 199 + down_write(&flow_table->flow_block_lock); 200 + block_cb = flow_block_cb_lookup(block, cb, cb_priv); 201 + if (block_cb) { 202 + list_del(&block_cb->list); 203 + flow_block_cb_free(block_cb); 204 + } else { 205 + WARN_ON(true); 206 + } 207 + up_write(&flow_table->flow_block_lock); 208 + } 168 209 169 210 int flow_offload_route_init(struct flow_offload *flow, 170 211 const struct nf_flow_route *route);
+10 -1
include/net/tc_act/tc_ct.h
··· 66 66 #endif /* CONFIG_NF_CONNTRACK */ 67 67 68 68 #if IS_ENABLED(CONFIG_NET_ACT_CT) 69 - void tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie); 69 + static inline void 70 + tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie) 71 + { 72 + enum ip_conntrack_info ctinfo = cookie & NFCT_INFOMASK; 73 + struct nf_conn *ct; 74 + 75 + ct = (struct nf_conn *)(cookie & NFCT_PTRMASK); 76 + nf_conntrack_get(&ct->ct_general); 77 + nf_ct_set(skb, ct, ctinfo); 78 + } 70 79 #else 71 80 static inline void 72 81 tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie) { }
+9 -4
include/rdma/ib_verbs.h
··· 75 75 struct ib_uqp_object; 76 76 struct ib_usrq_object; 77 77 struct ib_uwq_object; 78 + struct rdma_cm_id; 78 79 79 80 extern struct workqueue_struct *ib_wq; 80 81 extern struct workqueue_struct *ib_comp_wq; ··· 2582 2581 /** 2583 2582 * Allows rdma drivers to add their own restrack attributes. 2584 2583 */ 2585 - int (*fill_res_entry)(struct sk_buff *msg, 2586 - struct rdma_restrack_entry *entry); 2584 + int (*fill_res_mr_entry)(struct sk_buff *msg, struct ib_mr *ibmr); 2585 + int (*fill_res_mr_entry_raw)(struct sk_buff *msg, struct ib_mr *ibmr); 2586 + int (*fill_res_cq_entry)(struct sk_buff *msg, struct ib_cq *ibcq); 2587 + int (*fill_res_cq_entry_raw)(struct sk_buff *msg, struct ib_cq *ibcq); 2588 + int (*fill_res_qp_entry)(struct sk_buff *msg, struct ib_qp *ibqp); 2589 + int (*fill_res_qp_entry_raw)(struct sk_buff *msg, struct ib_qp *ibqp); 2590 + int (*fill_res_cm_id_entry)(struct sk_buff *msg, struct rdma_cm_id *id); 2587 2591 2588 2592 /* Device lifecycle callbacks */ 2589 2593 /* ··· 2643 2637 * Allows rdma drivers to add their own restrack attributes 2644 2638 * dumped via 'rdma stat' iproute2 command. 2645 2639 */ 2646 - int (*fill_stat_entry)(struct sk_buff *msg, 2647 - struct rdma_restrack_entry *entry); 2640 + int (*fill_stat_mr_entry)(struct sk_buff *msg, struct ib_mr *ibmr); 2648 2641 2649 2642 DECLARE_RDMA_OBJ_SIZE(ib_ah); 2650 2643 DECLARE_RDMA_OBJ_SIZE(ib_cq);
-1
include/trace/events/block.h
··· 254 254 * block_bio_complete - completed all work on the block operation 255 255 * @q: queue holding the block operation 256 256 * @bio: block operation completed 257 - * @error: io error value 258 257 * 259 258 * This tracepoint indicates there is no further work to do on this 260 259 * block IO operation @bio.
+1
include/uapi/linux/fs.h
··· 262 262 #define FS_EA_INODE_FL 0x00200000 /* Inode used for large EA */ 263 263 #define FS_EOFBLOCKS_FL 0x00400000 /* Reserved for ext4 */ 264 264 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */ 265 + #define FS_DAX_FL 0x02000000 /* Inode is DAX */ 265 266 #define FS_INLINE_DATA_FL 0x10000000 /* Reserved for ext4 */ 266 267 #define FS_PROJINHERIT_FL 0x20000000 /* Create with parents projid */ 267 268 #define FS_CASEFOLD_FL 0x40000000 /* Folder is case insensitive */
+1
include/uapi/linux/ndctl.h
··· 244 244 #define NVDIMM_FAMILY_HPE2 2 245 245 #define NVDIMM_FAMILY_MSFT 3 246 246 #define NVDIMM_FAMILY_HYPERV 4 247 + #define NVDIMM_FAMILY_PAPR 5 247 248 248 249 #define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL,\ 249 250 struct nd_cmd_pkg)
+4
include/uapi/linux/xattr.h
··· 7 7 Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org> 8 8 Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. 9 9 Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com> 10 + Copyright (c) 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> 10 11 */ 11 12 12 13 #include <linux/libc-compat.h> ··· 31 30 32 31 #define XATTR_BTRFS_PREFIX "btrfs." 33 32 #define XATTR_BTRFS_PREFIX_LEN (sizeof(XATTR_BTRFS_PREFIX) - 1) 33 + 34 + #define XATTR_HURD_PREFIX "gnu." 35 + #define XATTR_HURD_PREFIX_LEN (sizeof(XATTR_HURD_PREFIX) - 1) 34 36 35 37 #define XATTR_SECURITY_PREFIX "security." 36 38 #define XATTR_SECURITY_PREFIX_LEN (sizeof(XATTR_SECURITY_PREFIX) - 1)
+8
include/uapi/rdma/rdma_netlink.h
··· 287 287 288 288 RDMA_NLDEV_CMD_STAT_DEL, 289 289 290 + RDMA_NLDEV_CMD_RES_QP_GET_RAW, 291 + 292 + RDMA_NLDEV_CMD_RES_CQ_GET_RAW, 293 + 294 + RDMA_NLDEV_CMD_RES_MR_GET_RAW, 295 + 290 296 RDMA_NLDEV_NUM_OPS 291 297 }; 292 298 ··· 530 524 * CQ adaptive moderatio (DIM) 531 525 */ 532 526 RDMA_NLDEV_ATTR_DEV_DIM, /* u8 */ 527 + 528 + RDMA_NLDEV_ATTR_RES_RAW, /* binary */ 533 529 534 530 /* 535 531 * Always the end
+3 -3
kernel/debug/debug_core.c
··· 169 169 { 170 170 int err; 171 171 172 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr, 172 + err = copy_from_kernel_nofault(bpt->saved_instr, (char *)bpt->bpt_addr, 173 173 BREAK_INSTR_SIZE); 174 174 if (err) 175 175 return err; 176 - err = probe_kernel_write((char *)bpt->bpt_addr, 176 + err = copy_to_kernel_nofault((char *)bpt->bpt_addr, 177 177 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE); 178 178 return err; 179 179 } 180 180 181 181 int __weak kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) 182 182 { 183 - return probe_kernel_write((char *)bpt->bpt_addr, 183 + return copy_to_kernel_nofault((char *)bpt->bpt_addr, 184 184 (char *)bpt->saved_instr, BREAK_INSTR_SIZE); 185 185 } 186 186
+3 -3
kernel/debug/gdbstub.c
··· 247 247 */ 248 248 tmp = buf + count; 249 249 250 - err = probe_kernel_read(tmp, mem, count); 250 + err = copy_from_kernel_nofault(tmp, mem, count); 251 251 if (err) 252 252 return NULL; 253 253 while (count > 0) { ··· 283 283 *tmp_raw |= hex_to_bin(*tmp_hex--) << 4; 284 284 } 285 285 286 - return probe_kernel_write(mem, tmp_raw, count); 286 + return copy_to_kernel_nofault(mem, tmp_raw, count); 287 287 } 288 288 289 289 /* ··· 335 335 size++; 336 336 } 337 337 338 - return probe_kernel_write(mem, c, size); 338 + return copy_to_kernel_nofault(mem, c, size); 339 339 } 340 340 341 341 #if DBG_MAX_REG_NUM > 0
+2 -1
kernel/debug/kdb/kdb_main.c
··· 2326 2326 int cpu; 2327 2327 unsigned long tmp; 2328 2328 2329 - if (!p || probe_kernel_read(&tmp, (char *)p, sizeof(unsigned long))) 2329 + if (!p || 2330 + copy_from_kernel_nofault(&tmp, (char *)p, sizeof(unsigned long))) 2330 2331 return; 2331 2332 2332 2333 cpu = kdb_process_cpu(p);
+4 -3
kernel/debug/kdb/kdb_support.c
··· 325 325 */ 326 326 int kdb_getarea_size(void *res, unsigned long addr, size_t size) 327 327 { 328 - int ret = probe_kernel_read((char *)res, (char *)addr, size); 328 + int ret = copy_from_kernel_nofault((char *)res, (char *)addr, size); 329 329 if (ret) { 330 330 if (!KDB_STATE(SUPPRESS)) { 331 331 kdb_printf("kdb_getarea: Bad address 0x%lx\n", addr); ··· 350 350 */ 351 351 int kdb_putarea_size(unsigned long addr, void *res, size_t size) 352 352 { 353 - int ret = probe_kernel_read((char *)addr, (char *)res, size); 353 + int ret = copy_from_kernel_nofault((char *)addr, (char *)res, size); 354 354 if (ret) { 355 355 if (!KDB_STATE(SUPPRESS)) { 356 356 kdb_printf("kdb_putarea: Bad address 0x%lx\n", addr); ··· 624 624 char state; 625 625 unsigned long tmp; 626 626 627 - if (!p || probe_kernel_read(&tmp, (char *)p, sizeof(unsigned long))) 627 + if (!p || 628 + copy_from_kernel_nofault(&tmp, (char *)p, sizeof(unsigned long))) 628 629 return 'E'; 629 630 630 631 cpu = kdb_process_cpu(p);
+5 -5
kernel/dma/Kconfig
··· 73 73 config DMA_NONCOHERENT_MMAP 74 74 bool 75 75 76 + config DMA_COHERENT_POOL 77 + bool 78 + 76 79 config DMA_REMAP 80 + bool 77 81 depends on MMU 78 82 select GENERIC_ALLOCATOR 79 83 select DMA_NONCOHERENT_MMAP 80 - bool 81 - 82 - config DMA_COHERENT_POOL 83 - bool 84 - select DMA_REMAP 85 84 86 85 config DMA_DIRECT_REMAP 87 86 bool 87 + select DMA_REMAP 88 88 select DMA_COHERENT_POOL 89 89 90 90 config DMA_CMA
+3 -4
kernel/dma/pool.c
··· 175 175 * sizes to 128KB per 1GB of memory, min 128KB, max MAX_ORDER-1. 176 176 */ 177 177 if (!atomic_pool_size) { 178 - atomic_pool_size = max(totalram_pages() >> PAGE_SHIFT, 1UL) * 179 - SZ_128K; 180 - atomic_pool_size = min_t(size_t, atomic_pool_size, 181 - 1 << (PAGE_SHIFT + MAX_ORDER-1)); 178 + unsigned long pages = totalram_pages() / (SZ_1G / SZ_128K); 179 + pages = min_t(unsigned long, pages, MAX_ORDER_NR_PAGES); 180 + atomic_pool_size = max_t(size_t, pages << PAGE_SHIFT, SZ_128K); 182 181 } 183 182 INIT_WORK(&atomic_pool_work, atomic_pool_work_fn); 184 183
+48 -13
kernel/kprobes.c
··· 46 46 47 47 48 48 static int kprobes_initialized; 49 + /* kprobe_table can be accessed by 50 + * - Normal hlist traversal and RCU add/del under kprobe_mutex is held. 51 + * Or 52 + * - RCU hlist traversal under disabling preempt (breakpoint handlers) 53 + */ 49 54 static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE]; 50 55 static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE]; 51 56 ··· 331 326 struct kprobe *p; 332 327 333 328 head = &kprobe_table[hash_ptr(addr, KPROBE_HASH_BITS)]; 334 - hlist_for_each_entry_rcu(p, head, hlist) { 329 + hlist_for_each_entry_rcu(p, head, hlist, 330 + lockdep_is_held(&kprobe_mutex)) { 335 331 if (p->addr == addr) 336 332 return p; 337 333 } ··· 592 586 mutex_unlock(&module_mutex); 593 587 mutex_unlock(&text_mutex); 594 588 cpus_read_unlock(); 595 - mutex_unlock(&kprobe_mutex); 596 589 597 590 /* Step 5: Kick optimizer again if needed */ 598 591 if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list)) 599 592 kick_kprobe_optimizer(); 593 + 594 + mutex_unlock(&kprobe_mutex); 600 595 } 601 596 602 597 /* Wait for completing optimization and unoptimization */ ··· 675 668 lockdep_assert_cpus_held(); 676 669 arch_unoptimize_kprobe(op); 677 670 op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED; 678 - if (kprobe_disabled(&op->kp)) 679 - arch_disarm_kprobe(&op->kp); 680 671 } 681 672 682 673 /* Unoptimize a kprobe if p is optimized */ ··· 854 849 kprobes_allow_optimization = true; 855 850 for (i = 0; i < KPROBE_TABLE_SIZE; i++) { 856 851 head = &kprobe_table[i]; 857 - hlist_for_each_entry_rcu(p, head, hlist) 852 + hlist_for_each_entry(p, head, hlist) 858 853 if (!kprobe_disabled(p)) 859 854 optimize_kprobe(p); 860 855 } ··· 881 876 kprobes_allow_optimization = false; 882 877 for (i = 0; i < KPROBE_TABLE_SIZE; i++) { 883 878 head = &kprobe_table[i]; 884 - hlist_for_each_entry_rcu(p, head, hlist) { 879 + hlist_for_each_entry(p, head, hlist) { 885 880 if (!kprobe_disabled(p)) 886 881 unoptimize_kprobe(p, false); 887 882 } ··· 1241 1236 } 1242 1237 NOKPROBE_SYMBOL(kretprobe_table_unlock); 1243 1238 1239 + struct kprobe kprobe_busy = { 1240 + .addr = (void *) get_kprobe, 1241 + }; 1242 + 1243 + void kprobe_busy_begin(void) 1244 + { 1245 + struct kprobe_ctlblk *kcb; 1246 + 1247 + preempt_disable(); 1248 + __this_cpu_write(current_kprobe, &kprobe_busy); 1249 + kcb = get_kprobe_ctlblk(); 1250 + kcb->kprobe_status = KPROBE_HIT_ACTIVE; 1251 + } 1252 + 1253 + void kprobe_busy_end(void) 1254 + { 1255 + __this_cpu_write(current_kprobe, NULL); 1256 + preempt_enable(); 1257 + } 1258 + 1244 1259 /* 1245 1260 * This function is called from finish_task_switch when task tk becomes dead, 1246 1261 * so that we can recycle any function-return probe instances associated ··· 1278 1253 /* Early boot. kretprobe_table_locks not yet initialized. */ 1279 1254 return; 1280 1255 1256 + kprobe_busy_begin(); 1257 + 1281 1258 INIT_HLIST_HEAD(&empty_rp); 1282 1259 hash = hash_ptr(tk, KPROBE_HASH_BITS); 1283 1260 head = &kretprobe_inst_table[hash]; ··· 1293 1266 hlist_del(&ri->hlist); 1294 1267 kfree(ri); 1295 1268 } 1269 + 1270 + kprobe_busy_end(); 1296 1271 } 1297 1272 NOKPROBE_SYMBOL(kprobe_flush_task); 1298 1273 ··· 1528 1499 { 1529 1500 struct kprobe *ap, *list_p; 1530 1501 1502 + lockdep_assert_held(&kprobe_mutex); 1503 + 1531 1504 ap = get_kprobe(p->addr); 1532 1505 if (unlikely(!ap)) 1533 1506 return NULL; 1534 1507 1535 1508 if (p != ap) { 1536 - list_for_each_entry_rcu(list_p, &ap->list, list) 1509 + list_for_each_entry(list_p, &ap->list, list) 1537 1510 if (list_p == p) 1538 1511 /* kprobe p is a valid probe */ 1539 1512 goto valid; ··· 1700 1669 { 1701 1670 struct kprobe *kp; 1702 1671 1703 - list_for_each_entry_rcu(kp, &ap->list, list) 1672 + lockdep_assert_held(&kprobe_mutex); 1673 + 1674 + list_for_each_entry(kp, &ap->list, list) 1704 1675 if (!kprobe_disabled(kp)) 1705 1676 /* 1706 1677 * There is an active probe on the list. ··· 1781 1748 else { 1782 1749 /* If disabling probe has special handlers, update aggrprobe */ 1783 1750 if (p->post_handler && !kprobe_gone(p)) { 1784 - list_for_each_entry_rcu(list_p, &ap->list, list) { 1751 + list_for_each_entry(list_p, &ap->list, list) { 1785 1752 if ((list_p != p) && (list_p->post_handler)) 1786 1753 goto noclean; 1787 1754 } ··· 2095 2062 { 2096 2063 struct kprobe *kp; 2097 2064 2065 + lockdep_assert_held(&kprobe_mutex); 2066 + 2098 2067 p->flags |= KPROBE_FLAG_GONE; 2099 2068 if (kprobe_aggrprobe(p)) { 2100 2069 /* 2101 2070 * If this is an aggr_kprobe, we have to list all the 2102 2071 * chained probes and mark them GONE. 2103 2072 */ 2104 - list_for_each_entry_rcu(kp, &p->list, list) 2073 + list_for_each_entry(kp, &p->list, list) 2105 2074 kp->flags |= KPROBE_FLAG_GONE; 2106 2075 p->post_handler = NULL; 2107 2076 kill_optimized_kprobe(p); ··· 2347 2312 mutex_lock(&kprobe_mutex); 2348 2313 for (i = 0; i < KPROBE_TABLE_SIZE; i++) { 2349 2314 head = &kprobe_table[i]; 2350 - hlist_for_each_entry_rcu(p, head, hlist) 2315 + hlist_for_each_entry(p, head, hlist) 2351 2316 if (within_module_init((unsigned long)p->addr, mod) || 2352 2317 (checkcore && 2353 2318 within_module_core((unsigned long)p->addr, mod))) { ··· 2585 2550 for (i = 0; i < KPROBE_TABLE_SIZE; i++) { 2586 2551 head = &kprobe_table[i]; 2587 2552 /* Arm all kprobes on a best-effort basis */ 2588 - hlist_for_each_entry_rcu(p, head, hlist) { 2553 + hlist_for_each_entry(p, head, hlist) { 2589 2554 if (!kprobe_disabled(p)) { 2590 2555 err = arm_kprobe(p); 2591 2556 if (err) { ··· 2628 2593 for (i = 0; i < KPROBE_TABLE_SIZE; i++) { 2629 2594 head = &kprobe_table[i]; 2630 2595 /* Disarm all kprobes on a best-effort basis */ 2631 - hlist_for_each_entry_rcu(p, head, hlist) { 2596 + hlist_for_each_entry(p, head, hlist) { 2632 2597 if (!arch_trampoline_kprobe(p) && !kprobe_disabled(p)) { 2633 2598 err = disarm_kprobe(p, false); 2634 2599 if (err) {
+1 -1
kernel/kthread.c
··· 201 201 struct kthread *kthread = to_kthread(task); 202 202 void *data = NULL; 203 203 204 - probe_kernel_read(&data, &kthread->data, sizeof(data)); 204 + copy_from_kernel_nofault(&data, &kthread->data, sizeof(data)); 205 205 return data; 206 206 } 207 207
+20 -10
kernel/trace/blktrace.c
··· 3 3 * Copyright (C) 2006 Jens Axboe <axboe@kernel.dk> 4 4 * 5 5 */ 6 + 7 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 + 6 9 #include <linux/kernel.h> 7 10 #include <linux/blkdev.h> 8 11 #include <linux/blktrace_api.h> ··· 347 344 { 348 345 struct blk_trace *bt; 349 346 350 - bt = xchg(&q->blk_trace, NULL); 347 + bt = rcu_replace_pointer(q->blk_trace, NULL, 348 + lockdep_is_held(&q->blk_trace_mutex)); 351 349 if (!bt) 352 350 return -EINVAL; 353 351 ··· 498 494 */ 499 495 strreplace(buts->name, '/', '_'); 500 496 497 + /* 498 + * bdev can be NULL, as with scsi-generic, this is a helpful as 499 + * we can be. 500 + */ 501 + if (rcu_dereference_protected(q->blk_trace, 502 + lockdep_is_held(&q->blk_trace_mutex))) { 503 + pr_warn("Concurrent blktraces are not allowed on %s\n", 504 + buts->name); 505 + return -EBUSY; 506 + } 507 + 501 508 bt = kzalloc(sizeof(*bt), GFP_KERNEL); 502 509 if (!bt) 503 510 return -ENOMEM; ··· 558 543 bt->pid = buts->pid; 559 544 bt->trace_state = Blktrace_setup; 560 545 561 - ret = -EBUSY; 562 - if (cmpxchg(&q->blk_trace, NULL, bt)) 563 - goto err; 564 - 546 + rcu_assign_pointer(q->blk_trace, bt); 565 547 get_probe_ref(); 566 548 567 549 ret = 0; ··· 1641 1629 { 1642 1630 struct blk_trace *bt; 1643 1631 1644 - bt = xchg(&q->blk_trace, NULL); 1632 + bt = rcu_replace_pointer(q->blk_trace, NULL, 1633 + lockdep_is_held(&q->blk_trace_mutex)); 1645 1634 if (bt == NULL) 1646 1635 return -EINVAL; 1647 1636 ··· 1674 1661 1675 1662 blk_trace_setup_lba(bt, bdev); 1676 1663 1677 - ret = -EBUSY; 1678 - if (cmpxchg(&q->blk_trace, NULL, bt)) 1679 - goto free_bt; 1680 - 1664 + rcu_assign_pointer(q->blk_trace, bt); 1681 1665 get_probe_ref(); 1682 1666 return 0; 1683 1667
+4 -4
kernel/trace/bpf_trace.c
··· 141 141 { 142 142 int ret; 143 143 144 - ret = probe_user_read(dst, unsafe_ptr, size); 144 + ret = copy_from_user_nofault(dst, unsafe_ptr, size); 145 145 if (unlikely(ret < 0)) 146 146 memset(dst, 0, size); 147 147 return ret; ··· 196 196 197 197 if (unlikely(ret < 0)) 198 198 goto fail; 199 - ret = probe_kernel_read(dst, unsafe_ptr, size); 199 + ret = copy_from_kernel_nofault(dst, unsafe_ptr, size); 200 200 if (unlikely(ret < 0)) 201 201 goto fail; 202 202 return ret; ··· 326 326 if (unlikely(!nmi_uaccess_okay())) 327 327 return -EPERM; 328 328 329 - return probe_user_write(unsafe_ptr, src, size); 329 + return copy_to_user_nofault(unsafe_ptr, src, size); 330 330 } 331 331 332 332 static const struct bpf_func_proto bpf_probe_write_user_proto = { ··· 661 661 662 662 copy_size = (fmt[i + 2] == '4') ? 4 : 16; 663 663 664 - err = probe_kernel_read(bufs->buf[memcpy_cnt], 664 + err = copy_from_kernel_nofault(bufs->buf[memcpy_cnt], 665 665 (void *) (long) args[fmt_cnt], 666 666 copy_size); 667 667 if (err < 0)
+10 -2
kernel/trace/ftrace.c
··· 2260 2260 2261 2261 if (hash_contains_ip(ip, op->func_hash)) 2262 2262 return op; 2263 - } 2263 + } 2264 2264 2265 2265 return NULL; 2266 2266 } ··· 3599 3599 if (direct) 3600 3600 seq_printf(m, "\n\tdirect-->%pS", (void *)direct); 3601 3601 } 3602 - } 3602 + } 3603 3603 3604 3604 seq_putc(m, '\n'); 3605 3605 ··· 7151 7151 case TRACE_NO_PIDS: 7152 7152 seq_ops = &ftrace_no_pid_sops; 7153 7153 break; 7154 + default: 7155 + trace_array_put(tr); 7156 + WARN_ON_ONCE(1); 7157 + return -EINVAL; 7154 7158 } 7155 7159 7156 7160 ret = seq_open(file, seq_ops); ··· 7233 7229 other_pids = rcu_dereference_protected(tr->function_pids, 7234 7230 lockdep_is_held(&ftrace_lock)); 7235 7231 break; 7232 + default: 7233 + ret = -EINVAL; 7234 + WARN_ON_ONCE(1); 7235 + goto out; 7236 7236 } 7237 7237 7238 7238 ret = trace_pid_write(filtered_pids, &pid_list, ubuf, cnt);
+1 -2
kernel/trace/trace.c
··· 3570 3570 3571 3571 void tracing_iter_reset(struct trace_iterator *iter, int cpu) 3572 3572 { 3573 - struct ring_buffer_event *event; 3574 3573 struct ring_buffer_iter *buf_iter; 3575 3574 unsigned long entries = 0; 3576 3575 u64 ts; ··· 3587 3588 * that a reset never took place on a cpu. This is evident 3588 3589 * by the timestamp being before the start of the buffer. 3589 3590 */ 3590 - while ((event = ring_buffer_iter_peek(buf_iter, &ts))) { 3591 + while (ring_buffer_iter_peek(buf_iter, &ts)) { 3591 3592 if (ts >= iter->array_buffer->time_start) 3592 3593 break; 3593 3594 entries++;
+3
kernel/trace/trace.h
··· 61 61 #undef __field_desc 62 62 #define __field_desc(type, container, item) 63 63 64 + #undef __field_packed 65 + #define __field_packed(type, container, item) 66 + 64 67 #undef __array 65 68 #define __array(type, item, size) type item[size]; 66 69
+7 -7
kernel/trace/trace_entries.h
··· 78 78 79 79 F_STRUCT( 80 80 __field_struct( struct ftrace_graph_ent, graph_ent ) 81 - __field_desc( unsigned long, graph_ent, func ) 82 - __field_desc( int, graph_ent, depth ) 81 + __field_packed( unsigned long, graph_ent, func ) 82 + __field_packed( int, graph_ent, depth ) 83 83 ), 84 84 85 85 F_printk("--> %ps (%d)", (void *)__entry->func, __entry->depth) ··· 92 92 93 93 F_STRUCT( 94 94 __field_struct( struct ftrace_graph_ret, ret ) 95 - __field_desc( unsigned long, ret, func ) 96 - __field_desc( unsigned long, ret, overrun ) 97 - __field_desc( unsigned long long, ret, calltime) 98 - __field_desc( unsigned long long, ret, rettime ) 99 - __field_desc( int, ret, depth ) 95 + __field_packed( unsigned long, ret, func ) 96 + __field_packed( unsigned long, ret, overrun ) 97 + __field_packed( unsigned long long, ret, calltime) 98 + __field_packed( unsigned long long, ret, rettime ) 99 + __field_packed( int, ret, depth ) 100 100 ), 101 101 102 102 F_printk("<-- %ps (%d) (start: %llx end: %llx) over: %d",
+16
kernel/trace/trace_export.c
··· 45 45 #undef __field_desc 46 46 #define __field_desc(type, container, item) type item; 47 47 48 + #undef __field_packed 49 + #define __field_packed(type, container, item) type item; 50 + 48 51 #undef __array 49 52 #define __array(type, item, size) type item[size]; 50 53 ··· 88 85 .size = sizeof(_type), .align = __alignof__(_type), \ 89 86 is_signed_type(_type), .filter_type = _filter_type }, 90 87 88 + 89 + #undef __field_ext_packed 90 + #define __field_ext_packed(_type, _item, _filter_type) { \ 91 + .type = #_type, .name = #_item, \ 92 + .size = sizeof(_type), .align = 1, \ 93 + is_signed_type(_type), .filter_type = _filter_type }, 94 + 91 95 #undef __field 92 96 #define __field(_type, _item) __field_ext(_type, _item, FILTER_OTHER) 93 97 ··· 103 93 104 94 #undef __field_desc 105 95 #define __field_desc(_type, _container, _item) __field_ext(_type, _item, FILTER_OTHER) 96 + 97 + #undef __field_packed 98 + #define __field_packed(_type, _container, _item) __field_ext_packed(_type, _item, FILTER_OTHER) 106 99 107 100 #undef __array 108 101 #define __array(_type, _item, _len) { \ ··· 141 128 142 129 #undef __field_desc 143 130 #define __field_desc(type, container, item) 131 + 132 + #undef __field_packed 133 + #define __field_packed(type, container, item) 144 134 145 135 #undef __array 146 136 #define __array(type, item, len)
+1 -1
kernel/trace/trace_functions.c
··· 42 42 if (!ops) 43 43 return -ENOMEM; 44 44 45 - /* Currently only the non stack verision is supported */ 45 + /* Currently only the non stack version is supported */ 46 46 ops->func = function_trace_call; 47 47 ops->flags = FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_PID; 48 48
+3 -3
kernel/trace/trace_kprobe.c
··· 1222 1222 #endif 1223 1223 1224 1224 do { 1225 - ret = probe_kernel_read(&c, (u8 *)addr + len, 1); 1225 + ret = copy_from_kernel_nofault(&c, (u8 *)addr + len, 1); 1226 1226 len++; 1227 1227 } while (c && ret == 0 && len < MAX_STRING_SIZE); 1228 1228 ··· 1290 1290 { 1291 1291 const void __user *uaddr = (__force const void __user *)src; 1292 1292 1293 - return probe_user_read(dest, uaddr, size); 1293 + return copy_from_user_nofault(dest, uaddr, size); 1294 1294 } 1295 1295 1296 1296 static nokprobe_inline int ··· 1300 1300 if ((unsigned long)src < TASK_SIZE) 1301 1301 return probe_mem_read_user(dest, src, size); 1302 1302 #endif 1303 - return probe_kernel_read(dest, src, size); 1303 + return copy_from_kernel_nofault(dest, src, size); 1304 1304 } 1305 1305 1306 1306 /* Note that we don't verify it, since the code does not come from user space */
+2 -2
kernel/trace/trace_probe.c
··· 639 639 ret = -EINVAL; 640 640 goto fail; 641 641 } 642 - if ((code->op == FETCH_OP_IMM || code->op == FETCH_OP_COMM) || 643 - parg->count) { 642 + if ((code->op == FETCH_OP_IMM || code->op == FETCH_OP_COMM || 643 + code->op == FETCH_OP_DATA) || parg->count) { 644 644 /* 645 645 * IMM, DATA and COMM is pointing actual address, those 646 646 * must be kept, and if parg->count != 0, this is an
+1 -1
kernel/trace/trace_probe.h
··· 236 236 struct trace_event_call call; 237 237 struct list_head files; 238 238 struct list_head probes; 239 - struct trace_uprobe_filter filter[0]; 239 + struct trace_uprobe_filter filter[]; 240 240 }; 241 241 242 242 struct trace_probe {
+5 -5
kernel/workqueue.c
··· 4638 4638 * Carefully copy the associated workqueue's workfn, name and desc. 4639 4639 * Keep the original last '\0' in case the original is garbage. 4640 4640 */ 4641 - probe_kernel_read(&fn, &worker->current_func, sizeof(fn)); 4642 - probe_kernel_read(&pwq, &worker->current_pwq, sizeof(pwq)); 4643 - probe_kernel_read(&wq, &pwq->wq, sizeof(wq)); 4644 - probe_kernel_read(name, wq->name, sizeof(name) - 1); 4645 - probe_kernel_read(desc, worker->desc, sizeof(desc) - 1); 4641 + copy_from_kernel_nofault(&fn, &worker->current_func, sizeof(fn)); 4642 + copy_from_kernel_nofault(&pwq, &worker->current_pwq, sizeof(pwq)); 4643 + copy_from_kernel_nofault(&wq, &pwq->wq, sizeof(wq)); 4644 + copy_from_kernel_nofault(name, wq->name, sizeof(name) - 1); 4645 + copy_from_kernel_nofault(desc, worker->desc, sizeof(desc) - 1); 4646 4646 4647 4647 if (fn || name[0] || desc[0]) { 4648 4648 printk("%sWorkqueue: %s %ps", log_lvl, name, fn);
-1
lib/Kconfig.debug
··· 229 229 bool "Compressed debugging information" 230 230 depends on DEBUG_INFO 231 231 depends on $(cc-option,-gz=zlib) 232 - depends on $(as-option,-Wa$(comma)--compress-debug-sections=zlib) 233 232 depends on $(ld-option,--compress-debug-sections=zlib) 234 233 help 235 234 Compress the debug information using zlib. Requires GCC 5.0+ or Clang
+1
lib/seq_buf.c
··· 91 91 92 92 return ret; 93 93 } 94 + EXPORT_SYMBOL_GPL(seq_buf_printf); 94 95 95 96 #ifdef CONFIG_BINARY_PRINTF 96 97 /**
+3 -3
lib/test_lockup.c
··· 419 419 /* should be at least readable kernel address */ 420 420 if (access_ok(ptr, 1) || 421 421 access_ok(ptr + size - 1, 1) || 422 - probe_kernel_address(ptr, buf) || 423 - probe_kernel_address(ptr + size - 1, buf)) { 422 + get_kernel_nofault(buf, ptr) || 423 + get_kernel_nofault(buf, ptr + size - 1)) { 424 424 pr_err("invalid kernel ptr: %#lx\n", addr); 425 425 return true; 426 426 } ··· 437 437 if (!addr) 438 438 return false; 439 439 440 - if (probe_kernel_address(ptr, magic) || magic != expected) { 440 + if (get_kernel_nofault(magic, ptr) || magic != expected) { 441 441 pr_err("invalid magic at %#lx + %#x = %#x, expected %#x\n", 442 442 addr, offset, magic, expected); 443 443 return true;
+2 -2
lib/test_objagg.c
··· 979 979 err_world2_obj_get: 980 980 for (i--; i >= 0; i--) 981 981 world_obj_put(&world2, objagg, hints_case->key_ids[i]); 982 - objagg_hints_put(hints); 983 - objagg_destroy(objagg2); 984 982 i = hints_case->key_ids_count; 983 + objagg_destroy(objagg2); 985 984 err_check_expect_hints_stats: 985 + objagg_hints_put(hints); 986 986 err_hints_get: 987 987 err_check_expect_stats: 988 988 err_world_obj_get:
+4 -4
mm/debug.c
··· 120 120 * mapping can be invalid pointer and we don't want to crash 121 121 * accessing it, so probe everything depending on it carefully 122 122 */ 123 - if (probe_kernel_read(&host, &mapping->host, 123 + if (copy_from_kernel_nofault(&host, &mapping->host, 124 124 sizeof(struct inode *)) || 125 - probe_kernel_read(&a_ops, &mapping->a_ops, 125 + copy_from_kernel_nofault(&a_ops, &mapping->a_ops, 126 126 sizeof(struct address_space_operations *))) { 127 127 pr_warn("failed to read mapping->host or a_ops, mapping not a valid kernel address?\n"); 128 128 goto out_mapping; ··· 133 133 goto out_mapping; 134 134 } 135 135 136 - if (probe_kernel_read(&dentry_first, 136 + if (copy_from_kernel_nofault(&dentry_first, 137 137 &host->i_dentry.first, sizeof(struct hlist_node *))) { 138 138 pr_warn("mapping->a_ops:%ps with invalid mapping->host inode address %px\n", 139 139 a_ops, host); ··· 146 146 } 147 147 148 148 dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias); 149 - if (probe_kernel_read(&dentry, dentry_ptr, 149 + if (copy_from_kernel_nofault(&dentry, dentry_ptr, 150 150 sizeof(struct dentry))) { 151 151 pr_warn("mapping->aops:%ps with invalid mapping->host->i_dentry.first %px\n", 152 152 a_ops, dentry_ptr);
+2 -2
mm/gup.c
··· 2196 2196 */ 2197 2197 static inline pte_t gup_get_pte(pte_t *ptep) 2198 2198 { 2199 - return READ_ONCE(*ptep); 2199 + return ptep_get(ptep); 2200 2200 } 2201 2201 #endif /* CONFIG_GUP_GET_PTE_LOW_HIGH */ 2202 2202 ··· 2425 2425 if (pte_end < end) 2426 2426 end = pte_end; 2427 2427 2428 - pte = READ_ONCE(*ptep); 2428 + pte = huge_ptep_get(ptep); 2429 2429 2430 2430 if (!pte_access_permitted(pte, flags & FOLL_WRITE)) 2431 2431 return 0;
+31 -30
mm/maccess.c
··· 6 6 #include <linux/mm.h> 7 7 #include <linux/uaccess.h> 8 8 9 - bool __weak probe_kernel_read_allowed(const void *unsafe_src, size_t size) 9 + bool __weak copy_from_kernel_nofault_allowed(const void *unsafe_src, 10 + size_t size) 10 11 { 11 12 return true; 12 13 } 13 14 14 15 #ifdef HAVE_GET_KERNEL_NOFAULT 15 16 16 - #define probe_kernel_read_loop(dst, src, len, type, err_label) \ 17 + #define copy_from_kernel_nofault_loop(dst, src, len, type, err_label) \ 17 18 while (len >= sizeof(type)) { \ 18 19 __get_kernel_nofault(dst, src, type, err_label); \ 19 20 dst += sizeof(type); \ ··· 22 21 len -= sizeof(type); \ 23 22 } 24 23 25 - long probe_kernel_read(void *dst, const void *src, size_t size) 24 + long copy_from_kernel_nofault(void *dst, const void *src, size_t size) 26 25 { 27 - if (!probe_kernel_read_allowed(src, size)) 26 + if (!copy_from_kernel_nofault_allowed(src, size)) 28 27 return -ERANGE; 29 28 30 29 pagefault_disable(); 31 - probe_kernel_read_loop(dst, src, size, u64, Efault); 32 - probe_kernel_read_loop(dst, src, size, u32, Efault); 33 - probe_kernel_read_loop(dst, src, size, u16, Efault); 34 - probe_kernel_read_loop(dst, src, size, u8, Efault); 30 + copy_from_kernel_nofault_loop(dst, src, size, u64, Efault); 31 + copy_from_kernel_nofault_loop(dst, src, size, u32, Efault); 32 + copy_from_kernel_nofault_loop(dst, src, size, u16, Efault); 33 + copy_from_kernel_nofault_loop(dst, src, size, u8, Efault); 35 34 pagefault_enable(); 36 35 return 0; 37 36 Efault: 38 37 pagefault_enable(); 39 38 return -EFAULT; 40 39 } 41 - EXPORT_SYMBOL_GPL(probe_kernel_read); 40 + EXPORT_SYMBOL_GPL(copy_from_kernel_nofault); 42 41 43 - #define probe_kernel_write_loop(dst, src, len, type, err_label) \ 42 + #define copy_to_kernel_nofault_loop(dst, src, len, type, err_label) \ 44 43 while (len >= sizeof(type)) { \ 45 44 __put_kernel_nofault(dst, src, type, err_label); \ 46 45 dst += sizeof(type); \ ··· 48 47 len -= sizeof(type); \ 49 48 } 50 49 51 - long probe_kernel_write(void *dst, const void *src, size_t size) 50 + long copy_to_kernel_nofault(void *dst, const void *src, size_t size) 52 51 { 53 52 pagefault_disable(); 54 - probe_kernel_write_loop(dst, src, size, u64, Efault); 55 - probe_kernel_write_loop(dst, src, size, u32, Efault); 56 - probe_kernel_write_loop(dst, src, size, u16, Efault); 57 - probe_kernel_write_loop(dst, src, size, u8, Efault); 53 + copy_to_kernel_nofault_loop(dst, src, size, u64, Efault); 54 + copy_to_kernel_nofault_loop(dst, src, size, u32, Efault); 55 + copy_to_kernel_nofault_loop(dst, src, size, u16, Efault); 56 + copy_to_kernel_nofault_loop(dst, src, size, u8, Efault); 58 57 pagefault_enable(); 59 58 return 0; 60 59 Efault: ··· 68 67 69 68 if (unlikely(count <= 0)) 70 69 return 0; 71 - if (!probe_kernel_read_allowed(unsafe_addr, count)) 70 + if (!copy_from_kernel_nofault_allowed(unsafe_addr, count)) 72 71 return -ERANGE; 73 72 74 73 pagefault_disable(); ··· 88 87 } 89 88 #else /* HAVE_GET_KERNEL_NOFAULT */ 90 89 /** 91 - * probe_kernel_read(): safely attempt to read from kernel-space 90 + * copy_from_kernel_nofault(): safely attempt to read from kernel-space 92 91 * @dst: pointer to the buffer that shall take the data 93 92 * @src: address to read from 94 93 * @size: size of the data chunk ··· 99 98 * 100 99 * We ensure that the copy_from_user is executed in atomic context so that 101 100 * do_page_fault() doesn't attempt to take mmap_lock. This makes 102 - * probe_kernel_read() suitable for use within regions where the caller 101 + * copy_from_kernel_nofault() suitable for use within regions where the caller 103 102 * already holds mmap_lock, or other locks which nest inside mmap_lock. 104 103 */ 105 - long probe_kernel_read(void *dst, const void *src, size_t size) 104 + long copy_from_kernel_nofault(void *dst, const void *src, size_t size) 106 105 { 107 106 long ret; 108 107 mm_segment_t old_fs = get_fs(); 109 108 110 - if (!probe_kernel_read_allowed(src, size)) 109 + if (!copy_from_kernel_nofault_allowed(src, size)) 111 110 return -ERANGE; 112 111 113 112 set_fs(KERNEL_DS); ··· 121 120 return -EFAULT; 122 121 return 0; 123 122 } 124 - EXPORT_SYMBOL_GPL(probe_kernel_read); 123 + EXPORT_SYMBOL_GPL(copy_from_kernel_nofault); 125 124 126 125 /** 127 - * probe_kernel_write(): safely attempt to write to a location 126 + * copy_to_kernel_nofault(): safely attempt to write to a location 128 127 * @dst: address to write to 129 128 * @src: pointer to the data that shall be written 130 129 * @size: size of the data chunk ··· 132 131 * Safely write to address @dst from the buffer at @src. If a kernel fault 133 132 * happens, handle that and return -EFAULT. 134 133 */ 135 - long probe_kernel_write(void *dst, const void *src, size_t size) 134 + long copy_to_kernel_nofault(void *dst, const void *src, size_t size) 136 135 { 137 136 long ret; 138 137 mm_segment_t old_fs = get_fs(); ··· 175 174 176 175 if (unlikely(count <= 0)) 177 176 return 0; 178 - if (!probe_kernel_read_allowed(unsafe_addr, count)) 177 + if (!copy_from_kernel_nofault_allowed(unsafe_addr, count)) 179 178 return -ERANGE; 180 179 181 180 set_fs(KERNEL_DS); ··· 194 193 #endif /* HAVE_GET_KERNEL_NOFAULT */ 195 194 196 195 /** 197 - * probe_user_read(): safely attempt to read from a user-space location 196 + * copy_from_user_nofault(): safely attempt to read from a user-space location 198 197 * @dst: pointer to the buffer that shall take the data 199 198 * @src: address to read from. This must be a user address. 200 199 * @size: size of the data chunk ··· 202 201 * Safely read from user address @src to the buffer at @dst. If a kernel fault 203 202 * happens, handle that and return -EFAULT. 204 203 */ 205 - long probe_user_read(void *dst, const void __user *src, size_t size) 204 + long copy_from_user_nofault(void *dst, const void __user *src, size_t size) 206 205 { 207 206 long ret = -EFAULT; 208 207 mm_segment_t old_fs = get_fs(); ··· 219 218 return -EFAULT; 220 219 return 0; 221 220 } 222 - EXPORT_SYMBOL_GPL(probe_user_read); 221 + EXPORT_SYMBOL_GPL(copy_from_user_nofault); 223 222 224 223 /** 225 - * probe_user_write(): safely attempt to write to a user-space location 224 + * copy_to_user_nofault(): safely attempt to write to a user-space location 226 225 * @dst: address to write to 227 226 * @src: pointer to the data that shall be written 228 227 * @size: size of the data chunk ··· 230 229 * Safely write to address @dst from the buffer at @src. If a kernel fault 231 230 * happens, handle that and return -EFAULT. 232 231 */ 233 - long probe_user_write(void __user *dst, const void *src, size_t size) 232 + long copy_to_user_nofault(void __user *dst, const void *src, size_t size) 234 233 { 235 234 long ret = -EFAULT; 236 235 mm_segment_t old_fs = get_fs(); ··· 247 246 return -EFAULT; 248 247 return 0; 249 248 } 250 - EXPORT_SYMBOL_GPL(probe_user_write); 249 + EXPORT_SYMBOL_GPL(copy_to_user_nofault); 251 250 252 251 /** 253 252 * strncpy_from_user_nofault: - Copy a NUL terminated string from unsafe user
+1 -1
mm/rodata_test.c
··· 25 25 } 26 26 27 27 /* test 2: write to the variable; this should fault */ 28 - if (!probe_kernel_write((void *)&rodata_test_data, 28 + if (!copy_to_kernel_nofault((void *)&rodata_test_data, 29 29 (void *)&zero, sizeof(zero))) { 30 30 pr_err("test data was not read only\n"); 31 31 return;
+1 -1
mm/slub.c
··· 292 292 return get_freepointer(s, object); 293 293 294 294 freepointer_addr = (unsigned long)object + s->offset; 295 - probe_kernel_read(&p, (void **)freepointer_addr, sizeof(p)); 295 + copy_from_kernel_nofault(&p, (void **)freepointer_addr, sizeof(p)); 296 296 return freelist_ptr(s, p, freepointer_addr); 297 297 } 298 298
+6 -8
net/ceph/ceph_common.c
··· 332 332 opt->mount_timeout = CEPH_MOUNT_TIMEOUT_DEFAULT; 333 333 opt->osd_idle_ttl = CEPH_OSD_IDLE_TTL_DEFAULT; 334 334 opt->osd_request_timeout = CEPH_OSD_REQUEST_TIMEOUT_DEFAULT; 335 + opt->read_from_replica = CEPH_READ_FROM_REPLICA_DEFAULT; 335 336 return opt; 336 337 } 337 338 EXPORT_SYMBOL(ceph_alloc_options); ··· 491 490 case Opt_read_from_replica: 492 491 switch (result.uint_32) { 493 492 case Opt_read_from_replica_no: 494 - opt->osd_req_flags &= ~(CEPH_OSD_FLAG_BALANCE_READS | 495 - CEPH_OSD_FLAG_LOCALIZE_READS); 493 + opt->read_from_replica = 0; 496 494 break; 497 495 case Opt_read_from_replica_balance: 498 - opt->osd_req_flags |= CEPH_OSD_FLAG_BALANCE_READS; 499 - opt->osd_req_flags &= ~CEPH_OSD_FLAG_LOCALIZE_READS; 496 + opt->read_from_replica = CEPH_OSD_FLAG_BALANCE_READS; 500 497 break; 501 498 case Opt_read_from_replica_localize: 502 - opt->osd_req_flags |= CEPH_OSD_FLAG_LOCALIZE_READS; 503 - opt->osd_req_flags &= ~CEPH_OSD_FLAG_BALANCE_READS; 499 + opt->read_from_replica = CEPH_OSD_FLAG_LOCALIZE_READS; 504 500 break; 505 501 default: 506 502 BUG(); ··· 611 613 } 612 614 seq_putc(m, ','); 613 615 } 614 - if (opt->osd_req_flags & CEPH_OSD_FLAG_BALANCE_READS) { 616 + if (opt->read_from_replica == CEPH_OSD_FLAG_BALANCE_READS) { 615 617 seq_puts(m, "read_from_replica=balance,"); 616 - } else if (opt->osd_req_flags & CEPH_OSD_FLAG_LOCALIZE_READS) { 618 + } else if (opt->read_from_replica == CEPH_OSD_FLAG_LOCALIZE_READS) { 617 619 seq_puts(m, "read_from_replica=localize,"); 618 620 } 619 621
+4 -5
net/ceph/osd_client.c
··· 445 445 dest->size = src->size; 446 446 dest->min_size = src->min_size; 447 447 dest->sort_bitwise = src->sort_bitwise; 448 + dest->recovery_deletes = src->recovery_deletes; 448 449 449 450 dest->flags = src->flags; 451 + dest->used_replica = src->used_replica; 450 452 dest->paused = src->paused; 451 453 452 454 dest->epoch = src->epoch; ··· 1119 1117 truncate_size, truncate_seq); 1120 1118 } 1121 1119 1122 - req->r_flags = flags; 1123 1120 req->r_base_oloc.pool = layout->pool_id; 1124 1121 req->r_base_oloc.pool_ns = ceph_try_get_string(layout->pool_ns); 1125 1122 ceph_oid_printf(&req->r_base_oid, "%llx.%08llx", vino.ino, objnum); 1123 + req->r_flags = flags | osdc->client->options->read_from_replica; 1126 1124 1127 1125 req->r_snapid = vino.snap; 1128 1126 if (flags & CEPH_OSD_FLAG_WRITE) ··· 2433 2431 2434 2432 static void account_request(struct ceph_osd_request *req) 2435 2433 { 2436 - struct ceph_osd_client *osdc = req->r_osdc; 2437 - 2438 2434 WARN_ON(req->r_flags & (CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK)); 2439 2435 WARN_ON(!(req->r_flags & (CEPH_OSD_FLAG_READ | CEPH_OSD_FLAG_WRITE))); 2440 2436 2441 2437 req->r_flags |= CEPH_OSD_FLAG_ONDISK; 2442 - req->r_flags |= osdc->client->options->osd_req_flags; 2443 - atomic_inc(&osdc->num_requests); 2438 + atomic_inc(&req->r_osdc->num_requests); 2444 2439 2445 2440 req->r_start_stamp = jiffies; 2446 2441 req->r_start_latency = ktime_get();
+10 -2
net/ipv4/tcp_input.c
··· 4605 4605 if (tcp_ooo_try_coalesce(sk, tp->ooo_last_skb, 4606 4606 skb, &fragstolen)) { 4607 4607 coalesce_done: 4608 - tcp_grow_window(sk, skb); 4608 + /* For non sack flows, do not grow window to force DUPACK 4609 + * and trigger fast retransmit. 4610 + */ 4611 + if (tcp_is_sack(tp)) 4612 + tcp_grow_window(sk, skb); 4609 4613 kfree_skb_partial(skb, fragstolen); 4610 4614 skb = NULL; 4611 4615 goto add_sack; ··· 4693 4689 tcp_sack_new_ofo_skb(sk, seq, end_seq); 4694 4690 end: 4695 4691 if (skb) { 4696 - tcp_grow_window(sk, skb); 4692 + /* For non sack flows, do not grow window to force DUPACK 4693 + * and trigger fast retransmit. 4694 + */ 4695 + if (tcp_is_sack(tp)) 4696 + tcp_grow_window(sk, skb); 4697 4697 skb_condense(skb); 4698 4698 skb_set_owner_r(skb, sk); 4699 4699 }
+1
net/ipv6/mcast.c
··· 2615 2615 idev->mc_list = i->next; 2616 2616 2617 2617 write_unlock_bh(&idev->lock); 2618 + ip6_mc_clear_src(i); 2618 2619 ma_put(i); 2619 2620 write_lock_bh(&idev->lock); 2620 2621 }
+1 -6
net/mptcp/protocol.h
··· 135 135 ((nib & 0xF) << 8) | field); 136 136 } 137 137 138 - #define MPTCP_PM_MAX_ADDR 4 139 - 140 138 struct mptcp_addr_info { 141 139 sa_family_t family; 142 140 __be16 port; ··· 232 234 { 233 235 struct mptcp_sock *msk = mptcp_sk(sk); 234 236 235 - if (list_empty(&msk->rtx_queue)) 236 - return NULL; 237 - 238 - return list_first_entry(&msk->rtx_queue, struct mptcp_data_frag, list); 237 + return list_first_entry_or_null(&msk->rtx_queue, struct mptcp_data_frag, list); 239 238 } 240 239 241 240 struct mptcp_subflow_request_sock {
+3 -1
net/mptcp/subflow.c
··· 1053 1053 err = tcp_set_ulp(sf->sk, "mptcp"); 1054 1054 release_sock(sf->sk); 1055 1055 1056 - if (err) 1056 + if (err) { 1057 + sock_release(sf); 1057 1058 return err; 1059 + } 1058 1060 1059 1061 /* the newly created socket really belongs to the owning MPTCP master 1060 1062 * socket, even if for additional subflows the allocation is performed
+22 -10
net/netfilter/nf_conntrack_netlink.c
··· 939 939 filter->mark.mask = 0xffffffff; 940 940 } 941 941 } else if (cda[CTA_MARK_MASK]) { 942 - return ERR_PTR(-EINVAL); 942 + err = -EINVAL; 943 + goto err_filter; 943 944 } 944 945 #endif 945 946 if (!cda[CTA_FILTER]) ··· 948 947 949 948 err = ctnetlink_parse_zone(cda[CTA_ZONE], &filter->zone); 950 949 if (err < 0) 951 - return ERR_PTR(err); 950 + goto err_filter; 952 951 953 952 err = ctnetlink_parse_filter(cda[CTA_FILTER], filter); 954 953 if (err < 0) 955 - return ERR_PTR(err); 954 + goto err_filter; 956 955 957 956 if (filter->orig_flags) { 958 - if (!cda[CTA_TUPLE_ORIG]) 959 - return ERR_PTR(-EINVAL); 957 + if (!cda[CTA_TUPLE_ORIG]) { 958 + err = -EINVAL; 959 + goto err_filter; 960 + } 960 961 961 962 err = ctnetlink_parse_tuple_filter(cda, &filter->orig, 962 963 CTA_TUPLE_ORIG, ··· 966 963 &filter->zone, 967 964 filter->orig_flags); 968 965 if (err < 0) 969 - return ERR_PTR(err); 966 + goto err_filter; 970 967 } 971 968 972 969 if (filter->reply_flags) { 973 - if (!cda[CTA_TUPLE_REPLY]) 974 - return ERR_PTR(-EINVAL); 970 + if (!cda[CTA_TUPLE_REPLY]) { 971 + err = -EINVAL; 972 + goto err_filter; 973 + } 975 974 976 975 err = ctnetlink_parse_tuple_filter(cda, &filter->reply, 977 976 CTA_TUPLE_REPLY, 978 977 filter->family, 979 978 &filter->zone, 980 979 filter->orig_flags); 981 - if (err < 0) 982 - return ERR_PTR(err); 980 + if (err < 0) { 981 + err = -EINVAL; 982 + goto err_filter; 983 + } 983 984 } 984 985 985 986 return filter; 987 + 988 + err_filter: 989 + kfree(filter); 990 + 991 + return ERR_PTR(err); 986 992 } 987 993 988 994 static bool ctnetlink_needs_filter(u8 family, const struct nlattr * const *cda)
-45
net/netfilter/nf_flow_table_core.c
··· 387 387 queue_delayed_work(system_power_efficient_wq, &flow_table->gc_work, HZ); 388 388 } 389 389 390 - int nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table, 391 - flow_setup_cb_t *cb, void *cb_priv) 392 - { 393 - struct flow_block *block = &flow_table->flow_block; 394 - struct flow_block_cb *block_cb; 395 - int err = 0; 396 - 397 - down_write(&flow_table->flow_block_lock); 398 - block_cb = flow_block_cb_lookup(block, cb, cb_priv); 399 - if (block_cb) { 400 - err = -EEXIST; 401 - goto unlock; 402 - } 403 - 404 - block_cb = flow_block_cb_alloc(cb, cb_priv, cb_priv, NULL); 405 - if (IS_ERR(block_cb)) { 406 - err = PTR_ERR(block_cb); 407 - goto unlock; 408 - } 409 - 410 - list_add_tail(&block_cb->list, &block->cb_list); 411 - 412 - unlock: 413 - up_write(&flow_table->flow_block_lock); 414 - return err; 415 - } 416 - EXPORT_SYMBOL_GPL(nf_flow_table_offload_add_cb); 417 - 418 - void nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table, 419 - flow_setup_cb_t *cb, void *cb_priv) 420 - { 421 - struct flow_block *block = &flow_table->flow_block; 422 - struct flow_block_cb *block_cb; 423 - 424 - down_write(&flow_table->flow_block_lock); 425 - block_cb = flow_block_cb_lookup(block, cb, cb_priv); 426 - if (block_cb) { 427 - list_del(&block_cb->list); 428 - flow_block_cb_free(block_cb); 429 - } else { 430 - WARN_ON(true); 431 - } 432 - up_write(&flow_table->flow_block_lock); 433 - } 434 - EXPORT_SYMBOL_GPL(nf_flow_table_offload_del_cb); 435 390 436 391 static int nf_flow_nat_port_tcp(struct sk_buff *skb, unsigned int thoff, 437 392 __be16 port, __be16 new_port)
+24 -7
net/netfilter/nf_tables_api.c
··· 6550 6550 return err; 6551 6551 } 6552 6552 6553 + static void nft_flowtable_hook_release(struct nft_flowtable_hook *flowtable_hook) 6554 + { 6555 + struct nft_hook *this, *next; 6556 + 6557 + list_for_each_entry_safe(this, next, &flowtable_hook->list, list) { 6558 + list_del(&this->list); 6559 + kfree(this); 6560 + } 6561 + } 6562 + 6553 6563 static int nft_delflowtable_hook(struct nft_ctx *ctx, 6554 6564 struct nft_flowtable *flowtable) 6555 6565 { 6556 6566 const struct nlattr * const *nla = ctx->nla; 6557 6567 struct nft_flowtable_hook flowtable_hook; 6558 - struct nft_hook *this, *next, *hook; 6568 + struct nft_hook *this, *hook; 6559 6569 struct nft_trans *trans; 6560 6570 int err; 6561 6571 ··· 6574 6564 if (err < 0) 6575 6565 return err; 6576 6566 6577 - list_for_each_entry_safe(this, next, &flowtable_hook.list, list) { 6567 + list_for_each_entry(this, &flowtable_hook.list, list) { 6578 6568 hook = nft_hook_list_find(&flowtable->hook_list, this); 6579 6569 if (!hook) { 6580 6570 err = -ENOENT; 6581 6571 goto err_flowtable_del_hook; 6582 6572 } 6583 6573 hook->inactive = true; 6584 - list_del(&this->list); 6585 - kfree(this); 6586 6574 } 6587 6575 6588 6576 trans = nft_trans_alloc(ctx, NFT_MSG_DELFLOWTABLE, 6589 6577 sizeof(struct nft_trans_flowtable)); 6590 - if (!trans) 6591 - return -ENOMEM; 6578 + if (!trans) { 6579 + err = -ENOMEM; 6580 + goto err_flowtable_del_hook; 6581 + } 6592 6582 6593 6583 nft_trans_flowtable(trans) = flowtable; 6594 6584 nft_trans_flowtable_update(trans) = true; 6595 6585 INIT_LIST_HEAD(&nft_trans_flowtable_hooks(trans)); 6586 + nft_flowtable_hook_release(&flowtable_hook); 6596 6587 6597 6588 list_add_tail(&trans->list, &ctx->net->nft.commit_list); 6598 6589 6599 6590 return 0; 6600 6591 6601 6592 err_flowtable_del_hook: 6602 - list_for_each_entry(hook, &flowtable_hook.list, list) 6593 + list_for_each_entry(this, &flowtable_hook.list, list) { 6594 + hook = nft_hook_list_find(&flowtable->hook_list, this); 6595 + if (!hook) 6596 + break; 6597 + 6603 6598 hook->inactive = false; 6599 + } 6600 + nft_flowtable_hook_release(&flowtable_hook); 6604 6601 6605 6602 return err; 6606 6603 }
+5 -1
net/netfilter/nft_set_pipapo.c
··· 1242 1242 end += NFT_PIPAPO_GROUPS_PADDED_SIZE(f); 1243 1243 } 1244 1244 1245 - if (!*this_cpu_ptr(m->scratch) || bsize_max > m->bsize_max) { 1245 + if (!*get_cpu_ptr(m->scratch) || bsize_max > m->bsize_max) { 1246 + put_cpu_ptr(m->scratch); 1247 + 1246 1248 err = pipapo_realloc_scratch(m, bsize_max); 1247 1249 if (err) 1248 1250 return err; ··· 1252 1250 this_cpu_write(nft_pipapo_scratch_index, false); 1253 1251 1254 1252 m->bsize_max = bsize_max; 1253 + } else { 1254 + put_cpu_ptr(m->scratch); 1255 1255 } 1256 1256 1257 1257 *ext2 = &e->ext;
+14 -7
net/netfilter/nft_set_rbtree.c
··· 271 271 272 272 if (nft_rbtree_interval_start(new)) { 273 273 if (nft_rbtree_interval_end(rbe) && 274 - nft_set_elem_active(&rbe->ext, genmask)) 274 + nft_set_elem_active(&rbe->ext, genmask) && 275 + !nft_set_elem_expired(&rbe->ext)) 275 276 overlap = false; 276 277 } else { 277 278 overlap = nft_rbtree_interval_end(rbe) && 278 279 nft_set_elem_active(&rbe->ext, 279 - genmask); 280 + genmask) && 281 + !nft_set_elem_expired(&rbe->ext); 280 282 } 281 283 } else if (d > 0) { 282 284 p = &parent->rb_right; ··· 286 284 if (nft_rbtree_interval_end(new)) { 287 285 overlap = nft_rbtree_interval_end(rbe) && 288 286 nft_set_elem_active(&rbe->ext, 289 - genmask); 287 + genmask) && 288 + !nft_set_elem_expired(&rbe->ext); 290 289 } else if (nft_rbtree_interval_end(rbe) && 291 - nft_set_elem_active(&rbe->ext, genmask)) { 290 + nft_set_elem_active(&rbe->ext, genmask) && 291 + !nft_set_elem_expired(&rbe->ext)) { 292 292 overlap = true; 293 293 } 294 294 } else { ··· 298 294 nft_rbtree_interval_start(new)) { 299 295 p = &parent->rb_left; 300 296 301 - if (nft_set_elem_active(&rbe->ext, genmask)) 297 + if (nft_set_elem_active(&rbe->ext, genmask) && 298 + !nft_set_elem_expired(&rbe->ext)) 302 299 overlap = false; 303 300 } else if (nft_rbtree_interval_start(rbe) && 304 301 nft_rbtree_interval_end(new)) { 305 302 p = &parent->rb_right; 306 303 307 - if (nft_set_elem_active(&rbe->ext, genmask)) 304 + if (nft_set_elem_active(&rbe->ext, genmask) && 305 + !nft_set_elem_expired(&rbe->ext)) 308 306 overlap = false; 309 - } else if (nft_set_elem_active(&rbe->ext, genmask)) { 307 + } else if (nft_set_elem_active(&rbe->ext, genmask) && 308 + !nft_set_elem_expired(&rbe->ext)) { 310 309 *ext = &rbe->ext; 311 310 return -EEXIST; 312 311 } else {
+7 -1
net/rds/ib.h
··· 264 264 int *vector_load; 265 265 }; 266 266 267 - #define ibdev_to_node(ibdev) dev_to_node((ibdev)->dev.parent) 267 + static inline int ibdev_to_node(struct ib_device *ibdev) 268 + { 269 + struct device *parent; 270 + 271 + parent = ibdev->dev.parent; 272 + return parent ? dev_to_node(parent) : NUMA_NO_NODE; 273 + } 268 274 #define rdsibdev_to_node(rdsibdev) ibdev_to_node(rdsibdev->dev) 269 275 270 276 /* bits for i_ack_flags */
-11
net/sched/act_ct.c
··· 1543 1543 destroy_workqueue(act_ct_wq); 1544 1544 } 1545 1545 1546 - void tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie) 1547 - { 1548 - enum ip_conntrack_info ctinfo = cookie & NFCT_INFOMASK; 1549 - struct nf_conn *ct; 1550 - 1551 - ct = (struct nf_conn *)(cookie & NFCT_PTRMASK); 1552 - nf_conntrack_get(&ct->ct_general); 1553 - nf_ct_set(skb, ct, ctinfo); 1554 - } 1555 - EXPORT_SYMBOL_GPL(tcf_ct_flow_table_restore_skb); 1556 - 1557 1546 module_init(ct_init_module); 1558 1547 module_exit(ct_cleanup_module); 1559 1548 MODULE_AUTHOR("Paul Blakey <paulb@mellanox.com>");
+1 -1
samples/Kconfig
··· 211 211 212 212 config SAMPLE_WATCH_QUEUE 213 213 bool "Build example /dev/watch_queue notification consumer" 214 - depends on HEADERS_INSTALL 214 + depends on CC_CAN_LINK && HEADERS_INSTALL 215 215 help 216 216 Build example userspace program to use the new mount_notify(), 217 217 sb_notify() syscalls and the KEYCTL_WATCH_KEY keyctl() function.
+18 -6
samples/ftrace/sample-trace-array.c
··· 6 6 #include <linux/timer.h> 7 7 #include <linux/err.h> 8 8 #include <linux/jiffies.h> 9 + #include <linux/workqueue.h> 9 10 10 11 /* 11 12 * Any file that uses trace points, must include the header. ··· 21 20 static void mytimer_handler(struct timer_list *unused); 22 21 static struct task_struct *simple_tsk; 23 22 23 + static void trace_work_fn(struct work_struct *work) 24 + { 25 + /* 26 + * Disable tracing for event "sample_event". 27 + */ 28 + trace_array_set_clr_event(tr, "sample-subsystem", "sample_event", 29 + false); 30 + } 31 + static DECLARE_WORK(trace_work, trace_work_fn); 32 + 24 33 /* 25 34 * mytimer: Timer setup to disable tracing for event "sample_event". This 26 35 * timer is only for the purposes of the sample module to demonstrate access of ··· 40 29 41 30 static void mytimer_handler(struct timer_list *unused) 42 31 { 43 - /* 44 - * Disable tracing for event "sample_event". 45 - */ 46 - trace_array_set_clr_event(tr, "sample-subsystem", "sample_event", 47 - false); 32 + schedule_work(&trace_work); 48 33 } 49 34 50 35 static void simple_thread_func(int count) ··· 83 76 simple_thread_func(count++); 84 77 85 78 del_timer(&mytimer); 79 + cancel_work_sync(&trace_work); 86 80 87 81 /* 88 82 * trace_array_put() decrements the reference counter associated with ··· 115 107 trace_printk_init_buffers(); 116 108 117 109 simple_tsk = kthread_run(simple_thread, NULL, "sample-instance"); 118 - if (IS_ERR(simple_tsk)) 110 + if (IS_ERR(simple_tsk)) { 111 + trace_array_put(tr); 112 + trace_array_destroy(tr); 119 113 return -1; 114 + } 115 + 120 116 return 0; 121 117 } 122 118
+1 -1
samples/mei/mei-amt-version.c
··· 267 267 struct amt_host_if_resp_header { 268 268 struct amt_host_if_msg_header header; 269 269 uint32_t status; 270 - unsigned char data[0]; 270 + unsigned char data[]; 271 271 } __attribute__((packed)); 272 272 273 273 const uuid_le MEI_IAMTHIF = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, \
+4 -6
samples/watch_queue/Makefile
··· 1 - # List of programs to build 2 - hostprogs := watch_test 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + userprogs := watch_test 3 + always-y := $(userprogs) 3 4 4 - # Tell kbuild to always build the programs 5 - always-y := $(hostprogs) 6 - 7 - HOSTCFLAGS_watch_test.o += -I$(objtree)/usr/include 5 + userccflags += -I usr/include
+6 -5
scripts/Kbuild.include
··· 86 86 $(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c)))) 87 87 88 88 # output directory for tests below 89 - TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) 89 + TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$ 90 90 91 91 # try-run 92 92 # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) 93 93 # Exit code chooses option. "$$TMP" serves as a temporary file and is 94 94 # automatically cleaned up. 95 95 try-run = $(shell set -e; \ 96 - TMP="$(TMPOUT).$$$$.tmp"; \ 97 - TMPO="$(TMPOUT).$$$$.o"; \ 96 + TMP=$(TMPOUT)/tmp; \ 97 + TMPO=$(TMPOUT)/tmp.o; \ 98 + mkdir -p $(TMPOUT); \ 99 + trap "rm -rf $(TMPOUT)" EXIT; \ 98 100 if ($(1)) >/dev/null 2>&1; \ 99 101 then echo "$(2)"; \ 100 102 else echo "$(3)"; \ 101 - fi; \ 102 - rm -f "$$TMP" "$$TMPO") 103 + fi) 103 104 104 105 # as-option 105 106 # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
+1 -7
scripts/Kconfig.include
··· 25 25 26 26 # $(cc-option,<flag>) 27 27 # Return y if the compiler supports <flag>, n otherwise 28 - cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null) 28 + cc-option = $(success,mkdir .tmp_$$$$; trap "rm -rf .tmp_$$$$" EXIT; $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_$$$$/tmp.o) 29 29 30 30 # $(ld-option,<flag>) 31 31 # Return y if the linker supports <flag>, n otherwise 32 32 ld-option = $(success,$(LD) -v $(1)) 33 - 34 - # $(as-option,<flag>) 35 - # /dev/zero is used as output instead of /dev/null as some assembler cribs when 36 - # both input and output are same. Also both of them have same write behaviour so 37 - # can be easily substituted. 38 - as-option = $(success, $(CC) $(CLANG_FLAGS) $(1) -c -x assembler /dev/null -o /dev/zero) 39 33 40 34 # $(as-instr,<instr>) 41 35 # Return y if the assembler supports <instr>, n otherwise
+4 -1
scripts/decode_stacktrace.sh
··· 27 27 elif [[ "${modcache[$module]+isset}" == "isset" ]]; then 28 28 local objfile=${modcache[$module]} 29 29 else 30 - [[ $modpath == "" ]] && return 30 + if [[ $modpath == "" ]]; then 31 + echo "WARNING! Modules path isn't set, but is needed to parse this symbol" >&2 32 + return 33 + fi 31 34 local objfile=$(find "$modpath" -name "${module//_/[-_]}.ko*" -print -quit) 32 35 [[ $objfile == "" ]] && return 33 36 modcache[$module]=$objfile
+1 -1
scripts/headers_install.sh
··· 11 11 echo "asm/inline/volatile keywords." 12 12 echo 13 13 echo "INFILE: header file to operate on" 14 - echo "OUTFILE: output file which the processed header is writen to" 14 + echo "OUTFILE: output file which the processed header is written to" 15 15 16 16 exit 1 17 17 fi
+92 -6
scripts/recordmcount.h
··· 29 29 #undef has_rel_mcount 30 30 #undef tot_relsize 31 31 #undef get_mcountsym 32 + #undef find_symtab 33 + #undef get_shnum 34 + #undef set_shnum 35 + #undef get_shstrndx 36 + #undef get_symindex 32 37 #undef get_sym_str_and_relp 33 38 #undef do_func 34 39 #undef Elf_Addr ··· 63 58 # define __has_rel_mcount __has64_rel_mcount 64 59 # define has_rel_mcount has64_rel_mcount 65 60 # define tot_relsize tot64_relsize 61 + # define find_symtab find_symtab64 62 + # define get_shnum get_shnum64 63 + # define set_shnum set_shnum64 64 + # define get_shstrndx get_shstrndx64 65 + # define get_symindex get_symindex64 66 66 # define get_sym_str_and_relp get_sym_str_and_relp_64 67 67 # define do_func do64 68 68 # define get_mcountsym get_mcountsym_64 ··· 101 91 # define __has_rel_mcount __has32_rel_mcount 102 92 # define has_rel_mcount has32_rel_mcount 103 93 # define tot_relsize tot32_relsize 94 + # define find_symtab find_symtab32 95 + # define get_shnum get_shnum32 96 + # define set_shnum set_shnum32 97 + # define get_shstrndx get_shstrndx32 98 + # define get_symindex get_symindex32 104 99 # define get_sym_str_and_relp get_sym_str_and_relp_32 105 100 # define do_func do32 106 101 # define get_mcountsym get_mcountsym_32 ··· 188 173 return is_fake; 189 174 } 190 175 176 + static unsigned int get_symindex(Elf_Sym const *sym, Elf32_Word const *symtab, 177 + Elf32_Word const *symtab_shndx) 178 + { 179 + unsigned long offset; 180 + int index; 181 + 182 + if (sym->st_shndx != SHN_XINDEX) 183 + return w2(sym->st_shndx); 184 + 185 + offset = (unsigned long)sym - (unsigned long)symtab; 186 + index = offset / sizeof(*sym); 187 + 188 + return w(symtab_shndx[index]); 189 + } 190 + 191 + static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0) 192 + { 193 + if (shdr0 && !ehdr->e_shnum) 194 + return w(shdr0->sh_size); 195 + 196 + return w2(ehdr->e_shnum); 197 + } 198 + 199 + static void set_shnum(Elf_Ehdr *ehdr, Elf_Shdr *shdr0, unsigned int new_shnum) 200 + { 201 + if (new_shnum >= SHN_LORESERVE) { 202 + ehdr->e_shnum = 0; 203 + shdr0->sh_size = w(new_shnum); 204 + } else 205 + ehdr->e_shnum = w2(new_shnum); 206 + } 207 + 208 + static int get_shstrndx(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0) 209 + { 210 + if (ehdr->e_shstrndx != SHN_XINDEX) 211 + return w2(ehdr->e_shstrndx); 212 + 213 + return w(shdr0->sh_link); 214 + } 215 + 216 + static void find_symtab(Elf_Ehdr *const ehdr, Elf_Shdr const *shdr0, 217 + unsigned const nhdr, Elf32_Word **symtab, 218 + Elf32_Word **symtab_shndx) 219 + { 220 + Elf_Shdr const *relhdr; 221 + unsigned k; 222 + 223 + *symtab = NULL; 224 + *symtab_shndx = NULL; 225 + 226 + for (relhdr = shdr0, k = nhdr; k; --k, ++relhdr) { 227 + if (relhdr->sh_type == SHT_SYMTAB) 228 + *symtab = (void *)ehdr + relhdr->sh_offset; 229 + else if (relhdr->sh_type == SHT_SYMTAB_SHNDX) 230 + *symtab_shndx = (void *)ehdr + relhdr->sh_offset; 231 + 232 + if (*symtab && *symtab_shndx) 233 + break; 234 + } 235 + } 236 + 191 237 /* Append the new shstrtab, Elf_Shdr[], __mcount_loc and its relocations. */ 192 238 static int append_func(Elf_Ehdr *const ehdr, 193 239 Elf_Shdr *const shstr, ··· 264 188 char const *mc_name = (sizeof(Elf_Rela) == rel_entsize) 265 189 ? ".rela__mcount_loc" 266 190 : ".rel__mcount_loc"; 267 - unsigned const old_shnum = w2(ehdr->e_shnum); 268 191 uint_t const old_shoff = _w(ehdr->e_shoff); 269 192 uint_t const old_shstr_sh_size = _w(shstr->sh_size); 270 193 uint_t const old_shstr_sh_offset = _w(shstr->sh_offset); 194 + Elf_Shdr *const shdr0 = (Elf_Shdr *)(old_shoff + (void *)ehdr); 195 + unsigned int const old_shnum = get_shnum(ehdr, shdr0); 196 + unsigned int const new_shnum = 2 + old_shnum; /* {.rel,}__mcount_loc */ 271 197 uint_t t = 1 + strlen(mc_name) + _w(shstr->sh_size); 272 198 uint_t new_e_shoff; 273 199 ··· 278 200 t += sb.st_size; 279 201 t += (_align & -t); /* word-byte align */ 280 202 new_e_shoff = t; 203 + 204 + set_shnum(ehdr, shdr0, new_shnum); 281 205 282 206 /* body for new shstrtab */ 283 207 if (ulseek(sb.st_size, SEEK_SET) < 0) ··· 335 255 return -1; 336 256 337 257 ehdr->e_shoff = _w(new_e_shoff); 338 - ehdr->e_shnum = w2(2 + w2(ehdr->e_shnum)); /* {.rel,}__mcount_loc */ 339 258 if (ulseek(0, SEEK_SET) < 0) 340 259 return -1; 341 260 if (uwrite(ehdr, sizeof(*ehdr)) < 0) ··· 513 434 uint_t *const recvalp, 514 435 unsigned int *sym_index, 515 436 Elf_Shdr const *const symhdr, 437 + Elf32_Word const *symtab, 438 + Elf32_Word const *symtab_shndx, 516 439 Elf_Ehdr const *const ehdr) 517 440 { 518 441 Elf_Sym const *const sym0 = (Elf_Sym const *)(_w(symhdr->sh_offset) ··· 526 445 for (symp = sym0, t = nsym; t; --t, ++symp) { 527 446 unsigned int const st_bind = ELF_ST_BIND(symp->st_info); 528 447 529 - if (txtndx == w2(symp->st_shndx) 448 + if (txtndx == get_symindex(symp, symtab, symtab_shndx) 530 449 /* avoid STB_WEAK */ 531 450 && (STB_LOCAL == st_bind || STB_GLOBAL == st_bind)) { 532 451 /* function symbols on ARM have quirks, avoid them */ ··· 597 516 return totrelsz; 598 517 } 599 518 600 - 601 519 /* Overall supervision for Elf32 ET_REL file. */ 602 520 static int do_func(Elf_Ehdr *const ehdr, char const *const fname, 603 521 unsigned const reltype) 604 522 { 605 523 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) 606 524 + (void *)ehdr); 607 - unsigned const nhdr = w2(ehdr->e_shnum); 608 - Elf_Shdr *const shstr = &shdr0[w2(ehdr->e_shstrndx)]; 525 + unsigned const nhdr = get_shnum(ehdr, shdr0); 526 + Elf_Shdr *const shstr = &shdr0[get_shstrndx(ehdr, shdr0)]; 609 527 char const *const shstrtab = (char const *)(_w(shstr->sh_offset) 610 528 + (void *)ehdr); 611 529 612 530 Elf_Shdr const *relhdr; 613 531 unsigned k; 532 + 533 + Elf32_Word *symtab; 534 + Elf32_Word *symtab_shndx; 614 535 615 536 /* Upper bound on space: assume all relevant relocs are for mcount. */ 616 537 unsigned totrelsz; ··· 644 561 return -1; 645 562 } 646 563 564 + find_symtab(ehdr, shdr0, nhdr, &symtab, &symtab_shndx); 565 + 647 566 for (relhdr = shdr0, k = nhdr; k; --k, ++relhdr) { 648 567 char const *const txtname = has_rel_mcount(relhdr, shdr0, 649 568 shstrtab, fname); ··· 662 577 result = find_secsym_ndx(w(relhdr->sh_info), txtname, 663 578 &recval, &recsym, 664 579 &shdr0[symsec_sh_link], 580 + symtab, symtab_shndx, 665 581 ehdr); 666 582 if (result) 667 583 goto out;
+2 -2
security/integrity/integrity.h
··· 107 107 } ng; 108 108 u8 data[2]; 109 109 } xattr; 110 - u8 digest[0]; 110 + u8 digest[]; 111 111 } __packed; 112 112 113 113 /* ··· 119 119 uint8_t hash_algo; /* Digest algorithm [enum hash_algo] */ 120 120 __be32 keyid; /* IMA key identifier - not X509/PGP specific */ 121 121 __be16 sig_size; /* signature size */ 122 - uint8_t sig[0]; /* signature payload */ 122 + uint8_t sig[]; /* signature payload */ 123 123 } __packed; 124 124 125 125 /* integrity data associated with an inode */
+8 -13
security/selinux/ss/conditional.c
··· 27 27 int s[COND_EXPR_MAXDEPTH]; 28 28 int sp = -1; 29 29 30 + if (expr->len == 0) 31 + return -1; 32 + 30 33 for (i = 0; i < expr->len; i++) { 31 34 struct cond_expr_node *node = &expr->nodes[i]; 32 35 ··· 395 392 396 393 rc = next_entry(buf, fp, sizeof(u32) * 2); 397 394 if (rc) 398 - goto err; 395 + return rc; 399 396 400 397 expr->expr_type = le32_to_cpu(buf[0]); 401 398 expr->bool = le32_to_cpu(buf[1]); 402 399 403 - if (!expr_node_isvalid(p, expr)) { 404 - rc = -EINVAL; 405 - goto err; 406 - } 400 + if (!expr_node_isvalid(p, expr)) 401 + return -EINVAL; 407 402 } 408 403 409 404 rc = cond_read_av_list(p, fp, &node->true_list, NULL); 410 405 if (rc) 411 - goto err; 412 - rc = cond_read_av_list(p, fp, &node->false_list, &node->true_list); 413 - if (rc) 414 - goto err; 415 - return 0; 416 - err: 417 - cond_node_destroy(node); 418 - return rc; 406 + return rc; 407 + return cond_read_av_list(p, fp, &node->false_list, &node->true_list); 419 408 } 420 409 421 410 int cond_read_list(struct policydb *p, void *fp)
+4
security/selinux/ss/services.c
··· 2888 2888 if (*names) { 2889 2889 for (i = 0; i < *len; i++) 2890 2890 kfree((*names)[i]); 2891 + kfree(*names); 2891 2892 } 2892 2893 kfree(*values); 2894 + *len = 0; 2895 + *names = NULL; 2896 + *values = NULL; 2893 2897 goto out; 2894 2898 } 2895 2899
+4 -4
sound/soc/sof/probe.h
··· 36 36 struct sof_ipc_probe_dma_add_params { 37 37 struct sof_ipc_cmd_hdr hdr; 38 38 unsigned int num_elems; 39 - struct sof_probe_dma dma[0]; 39 + struct sof_probe_dma dma[]; 40 40 } __packed; 41 41 42 42 struct sof_ipc_probe_info_params { ··· 51 51 struct sof_ipc_probe_dma_remove_params { 52 52 struct sof_ipc_cmd_hdr hdr; 53 53 unsigned int num_elems; 54 - unsigned int stream_tag[0]; 54 + unsigned int stream_tag[]; 55 55 } __packed; 56 56 57 57 struct sof_ipc_probe_point_add_params { 58 58 struct sof_ipc_cmd_hdr hdr; 59 59 unsigned int num_elems; 60 - struct sof_probe_point_desc desc[0]; 60 + struct sof_probe_point_desc desc[]; 61 61 } __packed; 62 62 63 63 struct sof_ipc_probe_point_remove_params { 64 64 struct sof_ipc_cmd_hdr hdr; 65 65 unsigned int num_elems; 66 - unsigned int buffer_id[0]; 66 + unsigned int buffer_id[]; 67 67 } __packed; 68 68 69 69 int sof_ipc_probe_init(struct snd_sof_dev *sdev,
+2
tools/arch/x86/include/asm/cpufeatures.h
··· 362 362 #define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */ 363 363 #define X86_FEATURE_FSRM (18*32+ 4) /* Fast Short Rep Mov */ 364 364 #define X86_FEATURE_AVX512_VP2INTERSECT (18*32+ 8) /* AVX-512 Intersect for D/Q */ 365 + #define X86_FEATURE_SRBDS_CTRL (18*32+ 9) /* "" SRBDS mitigation MSR available */ 365 366 #define X86_FEATURE_MD_CLEAR (18*32+10) /* VERW clears CPU buffers */ 366 367 #define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */ 367 368 #define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */ ··· 408 407 #define X86_BUG_SWAPGS X86_BUG(21) /* CPU is affected by speculation through SWAPGS */ 409 408 #define X86_BUG_TAA X86_BUG(22) /* CPU is affected by TSX Async Abort(TAA) */ 410 409 #define X86_BUG_ITLB_MULTIHIT X86_BUG(23) /* CPU may incur MCE during certain page attribute changes */ 410 + #define X86_BUG_SRBDS X86_BUG(24) /* CPU may leak RNG bits if not mitigated */ 411 411 412 412 #endif /* _ASM_X86_CPUFEATURES_H */
+4
tools/arch/x86/include/asm/msr-index.h
··· 128 128 #define TSX_CTRL_RTM_DISABLE BIT(0) /* Disable RTM feature */ 129 129 #define TSX_CTRL_CPUID_CLEAR BIT(1) /* Disable TSX enumeration */ 130 130 131 + /* SRBDS support */ 132 + #define MSR_IA32_MCU_OPT_CTRL 0x00000123 133 + #define RNGDS_MITG_DIS BIT(0) 134 + 131 135 #define MSR_IA32_SYSENTER_CS 0x00000174 132 136 #define MSR_IA32_SYSENTER_ESP 0x00000175 133 137 #define MSR_IA32_SYSENTER_EIP 0x00000176
+19 -2
tools/arch/x86/include/uapi/asm/kvm.h
··· 385 385 #define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4) 386 386 387 387 #define KVM_STATE_NESTED_FORMAT_VMX 0 388 - #define KVM_STATE_NESTED_FORMAT_SVM 1 /* unused */ 388 + #define KVM_STATE_NESTED_FORMAT_SVM 1 389 389 390 390 #define KVM_STATE_NESTED_GUEST_MODE 0x00000001 391 391 #define KVM_STATE_NESTED_RUN_PENDING 0x00000002 392 392 #define KVM_STATE_NESTED_EVMCS 0x00000004 393 393 #define KVM_STATE_NESTED_MTF_PENDING 0x00000008 394 + #define KVM_STATE_NESTED_GIF_SET 0x00000100 394 395 395 396 #define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001 396 397 #define KVM_STATE_NESTED_SMM_VMXON 0x00000002 397 398 398 399 #define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000 399 400 401 + #define KVM_STATE_NESTED_SVM_VMCB_SIZE 0x1000 402 + 403 + #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001 404 + 400 405 struct kvm_vmx_nested_state_data { 401 406 __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; 402 407 __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; 403 - __u64 preemption_timer_deadline; 404 408 }; 405 409 406 410 struct kvm_vmx_nested_state_hdr { 411 + __u32 flags; 407 412 __u64 vmxon_pa; 408 413 __u64 vmcs12_pa; 414 + __u64 preemption_timer_deadline; 409 415 410 416 struct { 411 417 __u16 flags; 412 418 } smm; 419 + }; 420 + 421 + struct kvm_svm_nested_state_data { 422 + /* Save area only used if KVM_STATE_NESTED_RUN_PENDING. */ 423 + __u8 vmcb12[KVM_STATE_NESTED_SVM_VMCB_SIZE]; 424 + }; 425 + 426 + struct kvm_svm_nested_state_hdr { 427 + __u64 vmcb_pa; 413 428 }; 414 429 415 430 /* for KVM_CAP_NESTED_STATE */ ··· 435 420 436 421 union { 437 422 struct kvm_vmx_nested_state_hdr vmx; 423 + struct kvm_svm_nested_state_hdr svm; 438 424 439 425 /* Pad the header to 128 bytes. */ 440 426 __u8 pad[120]; ··· 448 432 */ 449 433 union { 450 434 struct kvm_vmx_nested_state_data vmx[0]; 435 + struct kvm_svm_nested_state_data svm[0]; 451 436 } data; 452 437 }; 453 438
+8 -1
tools/arch/x86/include/uapi/asm/unistd.h
··· 2 2 #ifndef _UAPI_ASM_X86_UNISTD_H 3 3 #define _UAPI_ASM_X86_UNISTD_H 4 4 5 - /* x32 syscall flag bit */ 5 + /* 6 + * x32 syscall flag bit. Some user programs expect syscall NR macros 7 + * and __X32_SYSCALL_BIT to have type int, even though syscall numbers 8 + * are, for practical purposes, unsigned long. 9 + * 10 + * Fortunately, expressions like (nr & ~__X32_SYSCALL_BIT) do the right 11 + * thing regardless. 12 + */ 6 13 #define __X32_SYSCALL_BIT 0x40000000 7 14 8 15 #ifndef __KERNEL__
+3
tools/arch/x86/include/uapi/asm/vmx.h
··· 150 150 { EXIT_REASON_UMWAIT, "UMWAIT" }, \ 151 151 { EXIT_REASON_TPAUSE, "TPAUSE" } 152 152 153 + #define VMX_EXIT_REASON_FLAGS \ 154 + { VMX_EXIT_REASONS_FAILED_VMENTRY, "FAILED_VMENTRY" } 155 + 153 156 #define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1 154 157 #define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2 155 158 #define VMX_ABORT_LOAD_HOST_MSR_FAIL 4
+14 -10
tools/bootconfig/main.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/bootconfig.h> 16 16 17 - static int xbc_show_array(struct xbc_node *node) 17 + static int xbc_show_value(struct xbc_node *node) 18 18 { 19 19 const char *val; 20 + char q; 20 21 int i = 0; 21 22 22 23 xbc_array_for_each_value(node, val) { 23 - printf("\"%s\"%s", val, node->next ? ", " : ";\n"); 24 + if (strchr(val, '"')) 25 + q = '\''; 26 + else 27 + q = '"'; 28 + printf("%c%s%c%s", q, val, q, node->next ? ", " : ";\n"); 24 29 i++; 25 30 } 26 31 return i; ··· 53 48 continue; 54 49 } else if (cnode && xbc_node_is_value(cnode)) { 55 50 printf("%s = ", xbc_node_get_data(node)); 56 - if (cnode->next) 57 - xbc_show_array(cnode); 58 - else 59 - printf("\"%s\";\n", xbc_node_get_data(cnode)); 51 + xbc_show_value(cnode); 60 52 } else { 61 53 printf("%s;\n", xbc_node_get_data(node)); 62 54 } ··· 207 205 } 208 206 209 207 ret = load_xbc_from_initrd(fd, &buf); 210 - if (ret < 0) 208 + if (ret < 0) { 211 209 pr_err("Failed to load a boot config from initrd: %d\n", ret); 212 - else 213 - xbc_show_compact_tree(); 214 - 210 + goto out; 211 + } 212 + xbc_show_compact_tree(); 213 + ret = 0; 214 + out: 215 215 close(fd); 216 216 free(buf); 217 217
+10
tools/bootconfig/test-bootconfig.sh
··· 55 55 xpass $BOOTCONF -a $TEMPCONF $INITRD 56 56 new_size=$(stat -c %s $INITRD) 57 57 58 + echo "Show command test" 59 + xpass $BOOTCONF $INITRD 60 + 58 61 echo "File size check" 59 62 xpass test $new_size -eq $(expr $bconf_size + $initrd_size + 9 + 12) 60 63 ··· 116 113 xpass grep -q "bar" $OUTFILE 117 114 xpass grep -q "baz" $OUTFILE 118 115 xpass grep -q "qux" $OUTFILE 116 + 117 + echo "Double/single quotes test" 118 + echo "key = '\"string\"';" > $TEMPCONF 119 + $BOOTCONF -a $TEMPCONF $INITRD 120 + $BOOTCONF $INITRD > $TEMPCONF 121 + cat $TEMPCONF 122 + xpass grep \'\"string\"\' $TEMPCONF 119 123 120 124 echo "=== expected failure cases ===" 121 125 for i in samples/bad-* ; do
+3 -1
tools/include/uapi/asm-generic/unistd.h
··· 855 855 __SYSCALL(__NR_openat2, sys_openat2) 856 856 #define __NR_pidfd_getfd 438 857 857 __SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd) 858 + #define __NR_faccessat2 439 859 + __SYSCALL(__NR_faccessat2, sys_faccessat2) 858 860 859 861 #undef __NR_syscalls 860 - #define __NR_syscalls 439 862 + #define __NR_syscalls 440 861 863 862 864 /* 863 865 * 32 bit systems traditionally used different
+24
tools/include/uapi/drm/i915_drm.h
··· 1969 1969 */ 1970 1970 DRM_I915_PERF_PROP_HOLD_PREEMPTION, 1971 1971 1972 + /** 1973 + * Specifying this pins all contexts to the specified SSEU power 1974 + * configuration for the duration of the recording. 1975 + * 1976 + * This parameter's value is a pointer to a struct 1977 + * drm_i915_gem_context_param_sseu. 1978 + * 1979 + * This property is available in perf revision 4. 1980 + */ 1981 + DRM_I915_PERF_PROP_GLOBAL_SSEU, 1982 + 1983 + /** 1984 + * This optional parameter specifies the timer interval in nanoseconds 1985 + * at which the i915 driver will check the OA buffer for available data. 1986 + * Minimum allowed value is 100 microseconds. A default value is used by 1987 + * the driver if this parameter is not specified. Note that larger timer 1988 + * values will reduce cpu consumption during OA perf captures. However, 1989 + * excessively large values would potentially result in OA buffer 1990 + * overwrites as captures reach end of the OA buffer. 1991 + * 1992 + * This property is available in perf revision 5. 1993 + */ 1994 + DRM_I915_PERF_PROP_POLL_OA_PERIOD, 1995 + 1972 1996 DRM_I915_PERF_PROP_MAX /* non-ABI */ 1973 1997 }; 1974 1998
+10
tools/include/uapi/linux/fcntl.h
··· 84 84 #define DN_ATTRIB 0x00000020 /* File changed attibutes */ 85 85 #define DN_MULTISHOT 0x80000000 /* Don't remove notifier */ 86 86 87 + /* 88 + * The constants AT_REMOVEDIR and AT_EACCESS have the same value. AT_EACCESS is 89 + * meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to 90 + * unlinkat. The two functions do completely different things and therefore, 91 + * the flags can be allowed to overlap. For example, passing AT_REMOVEDIR to 92 + * faccessat would be undefined behavior and thus treating it equivalent to 93 + * AT_EACCESS is valid undefined behavior. 94 + */ 87 95 #define AT_FDCWD -100 /* Special value used to indicate 88 96 openat should use the current 89 97 working directory. */ 90 98 #define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */ 99 + #define AT_EACCESS 0x200 /* Test access permitted for 100 + effective IDs, not real IDs. */ 91 101 #define AT_REMOVEDIR 0x200 /* Remove directory instead of 92 102 unlinking file. */ 93 103 #define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
+1
tools/include/uapi/linux/fs.h
··· 262 262 #define FS_EA_INODE_FL 0x00200000 /* Inode used for large EA */ 263 263 #define FS_EOFBLOCKS_FL 0x00400000 /* Reserved for ext4 */ 264 264 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */ 265 + #define FS_DAX_FL 0x02000000 /* Inode is DAX */ 265 266 #define FS_INLINE_DATA_FL 0x10000000 /* Reserved for ext4 */ 266 267 #define FS_PROJINHERIT_FL 0x20000000 /* Create with parents projid */ 267 268 #define FS_CASEFOLD_FL 0x40000000 /* Folder is case insensitive */
+2 -1
tools/include/uapi/linux/fscrypt.h
··· 19 19 #define FSCRYPT_POLICY_FLAGS_PAD_MASK 0x03 20 20 #define FSCRYPT_POLICY_FLAG_DIRECT_KEY 0x04 21 21 #define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 0x08 22 - #define FSCRYPT_POLICY_FLAGS_VALID 0x0F 22 + #define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 0x10 23 + #define FSCRYPT_POLICY_FLAGS_VALID 0x1F 23 24 24 25 /* Encryption algorithms */ 25 26 #define FSCRYPT_MODE_AES_256_XTS 1
+14
tools/include/uapi/linux/kvm.h
··· 188 188 struct kvm_hyperv_exit { 189 189 #define KVM_EXIT_HYPERV_SYNIC 1 190 190 #define KVM_EXIT_HYPERV_HCALL 2 191 + #define KVM_EXIT_HYPERV_SYNDBG 3 191 192 __u32 type; 193 + __u32 pad1; 192 194 union { 193 195 struct { 194 196 __u32 msr; 197 + __u32 pad2; 195 198 __u64 control; 196 199 __u64 evt_page; 197 200 __u64 msg_page; ··· 204 201 __u64 result; 205 202 __u64 params[2]; 206 203 } hcall; 204 + struct { 205 + __u32 msr; 206 + __u32 pad2; 207 + __u64 control; 208 + __u64 status; 209 + __u64 send_page; 210 + __u64 recv_page; 211 + __u64 pending_page; 212 + } syndbg; 207 213 } u; 208 214 }; 209 215 ··· 1029 1017 #define KVM_CAP_S390_VCPU_RESETS 179 1030 1018 #define KVM_CAP_S390_PROTECTED 180 1031 1019 #define KVM_CAP_PPC_SECURE_GUEST 181 1020 + #define KVM_CAP_HALT_POLL 182 1021 + #define KVM_CAP_ASYNC_PF_INT 183 1032 1022 1033 1023 #ifdef KVM_CAP_IRQ_ROUTING 1034 1024
+7 -1
tools/include/uapi/linux/stat.h
··· 123 123 __u32 stx_dev_major; /* ID of device containing file [uncond] */ 124 124 __u32 stx_dev_minor; 125 125 /* 0x90 */ 126 - __u64 __spare2[14]; /* Spare space for future expansion */ 126 + __u64 stx_mnt_id; 127 + __u64 __spare2; 128 + /* 0xa0 */ 129 + __u64 __spare3[12]; /* Spare space for future expansion */ 127 130 /* 0x100 */ 128 131 }; 129 132 ··· 151 148 #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ 152 149 #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ 153 150 #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ 151 + #define STATX_MNT_ID 0x00001000U /* Got stx_mnt_id */ 154 152 155 153 #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ 156 154 ··· 181 177 #define STATX_ATTR_NODUMP 0x00000040 /* [I] File is not to be dumped */ 182 178 #define STATX_ATTR_ENCRYPTED 0x00000800 /* [I] File requires key to decrypt in fs */ 183 179 #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ 180 + #define STATX_ATTR_MOUNT_ROOT 0x00002000 /* Root of a mount */ 184 181 #define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */ 182 + #define STATX_ATTR_DAX 0x00002000 /* [I] File is DAX */ 185 183 186 184 187 185 #endif /* _UAPI_LINUX_STAT_H */
+4
tools/include/uapi/linux/vhost.h
··· 15 15 #include <linux/types.h> 16 16 #include <linux/ioctl.h> 17 17 18 + #define VHOST_FILE_UNBIND -1 19 + 18 20 /* ioctls */ 19 21 20 22 #define VHOST_VIRTIO 0xAF ··· 142 140 /* Get the max ring size. */ 143 141 #define VHOST_VDPA_GET_VRING_NUM _IOR(VHOST_VIRTIO, 0x76, __u16) 144 142 143 + /* Set event fd for config interrupt*/ 144 + #define VHOST_VDPA_SET_CONFIG_CALL _IOW(VHOST_VIRTIO, 0x77, int) 145 145 #endif
+111 -57
tools/lib/traceevent/event-parse.c
··· 1425 1425 return 0; 1426 1426 } 1427 1427 1428 + static int append(char **buf, const char *delim, const char *str) 1429 + { 1430 + char *new_buf; 1431 + 1432 + new_buf = realloc(*buf, strlen(*buf) + strlen(delim) + strlen(str) + 1); 1433 + if (!new_buf) 1434 + return -1; 1435 + strcat(new_buf, delim); 1436 + strcat(new_buf, str); 1437 + *buf = new_buf; 1438 + return 0; 1439 + } 1440 + 1428 1441 static int event_read_fields(struct tep_event *event, struct tep_format_field **fields) 1429 1442 { 1430 1443 struct tep_format_field *field = NULL; 1431 1444 enum tep_event_type type; 1432 1445 char *token; 1433 1446 char *last_token; 1447 + char *delim = " "; 1434 1448 int count = 0; 1449 + int ret; 1435 1450 1436 1451 do { 1437 1452 unsigned int size_dynamic = 0; ··· 1505 1490 field->flags |= TEP_FIELD_IS_POINTER; 1506 1491 1507 1492 if (field->type) { 1508 - char *new_type; 1509 - new_type = realloc(field->type, 1510 - strlen(field->type) + 1511 - strlen(last_token) + 2); 1512 - if (!new_type) { 1513 - free(last_token); 1514 - goto fail; 1515 - } 1516 - field->type = new_type; 1517 - strcat(field->type, " "); 1518 - strcat(field->type, last_token); 1493 + ret = append(&field->type, delim, last_token); 1519 1494 free(last_token); 1495 + if (ret < 0) 1496 + goto fail; 1520 1497 } else 1521 1498 field->type = last_token; 1522 1499 last_token = token; 1500 + delim = " "; 1523 1501 continue; 1524 1502 } 1525 1503 1504 + /* Handle __attribute__((user)) */ 1505 + if ((type == TEP_EVENT_DELIM) && 1506 + strcmp("__attribute__", last_token) == 0 && 1507 + token[0] == '(') { 1508 + int depth = 1; 1509 + int ret; 1510 + 1511 + ret = append(&field->type, " ", last_token); 1512 + ret |= append(&field->type, "", "("); 1513 + if (ret < 0) 1514 + goto fail; 1515 + 1516 + delim = " "; 1517 + while ((type = read_token(&token)) != TEP_EVENT_NONE) { 1518 + if (type == TEP_EVENT_DELIM) { 1519 + if (token[0] == '(') 1520 + depth++; 1521 + else if (token[0] == ')') 1522 + depth--; 1523 + if (!depth) 1524 + break; 1525 + ret = append(&field->type, "", token); 1526 + delim = ""; 1527 + } else { 1528 + ret = append(&field->type, delim, token); 1529 + delim = " "; 1530 + } 1531 + if (ret < 0) 1532 + goto fail; 1533 + free(last_token); 1534 + last_token = token; 1535 + } 1536 + continue; 1537 + } 1526 1538 break; 1527 1539 } 1528 1540 ··· 1565 1523 if (strcmp(token, "[") == 0) { 1566 1524 enum tep_event_type last_type = type; 1567 1525 char *brackets = token; 1568 - char *new_brackets; 1569 - int len; 1570 1526 1571 1527 field->flags |= TEP_FIELD_IS_ARRAY; 1572 1528 ··· 1576 1536 field->arraylen = 0; 1577 1537 1578 1538 while (strcmp(token, "]") != 0) { 1539 + const char *delim; 1540 + 1579 1541 if (last_type == TEP_EVENT_ITEM && 1580 1542 type == TEP_EVENT_ITEM) 1581 - len = 2; 1543 + delim = " "; 1582 1544 else 1583 - len = 1; 1545 + delim = ""; 1546 + 1584 1547 last_type = type; 1585 1548 1586 - new_brackets = realloc(brackets, 1587 - strlen(brackets) + 1588 - strlen(token) + len); 1589 - if (!new_brackets) { 1549 + ret = append(&brackets, delim, token); 1550 + if (ret < 0) { 1590 1551 free(brackets); 1591 1552 goto fail; 1592 1553 } 1593 - brackets = new_brackets; 1594 - if (len == 2) 1595 - strcat(brackets, " "); 1596 - strcat(brackets, token); 1597 1554 /* We only care about the last token */ 1598 1555 field->arraylen = strtoul(token, NULL, 0); 1599 1556 free_token(token); 1600 1557 type = read_token(&token); 1601 1558 if (type == TEP_EVENT_NONE) { 1559 + free(brackets); 1602 1560 do_warning_event(event, "failed to find token"); 1603 1561 goto fail; 1604 1562 } ··· 1604 1566 1605 1567 free_token(token); 1606 1568 1607 - new_brackets = realloc(brackets, strlen(brackets) + 2); 1608 - if (!new_brackets) { 1569 + ret = append(&brackets, "", "]"); 1570 + if (ret < 0) { 1609 1571 free(brackets); 1610 1572 goto fail; 1611 1573 } 1612 - brackets = new_brackets; 1613 - strcat(brackets, "]"); 1614 1574 1615 1575 /* add brackets to type */ 1616 1576 ··· 1618 1582 * the format: type [] item; 1619 1583 */ 1620 1584 if (type == TEP_EVENT_ITEM) { 1621 - char *new_type; 1622 - new_type = realloc(field->type, 1623 - strlen(field->type) + 1624 - strlen(field->name) + 1625 - strlen(brackets) + 2); 1626 - if (!new_type) { 1585 + ret = append(&field->type, " ", field->name); 1586 + if (ret < 0) { 1627 1587 free(brackets); 1628 1588 goto fail; 1629 1589 } 1630 - field->type = new_type; 1631 - strcat(field->type, " "); 1632 - strcat(field->type, field->name); 1590 + ret = append(&field->type, "", brackets); 1591 + 1633 1592 size_dynamic = type_size(field->name); 1634 1593 free_token(field->name); 1635 - strcat(field->type, brackets); 1636 1594 field->name = field->alias = token; 1637 1595 type = read_token(&token); 1638 1596 } else { 1639 - char *new_type; 1640 - new_type = realloc(field->type, 1641 - strlen(field->type) + 1642 - strlen(brackets) + 1); 1643 - if (!new_type) { 1597 + ret = append(&field->type, "", brackets); 1598 + if (ret < 0) { 1644 1599 free(brackets); 1645 1600 goto fail; 1646 1601 } 1647 - field->type = new_type; 1648 - strcat(field->type, brackets); 1649 1602 } 1650 1603 free(brackets); 1651 1604 } ··· 2071 2046 /* could just be a type pointer */ 2072 2047 if ((strcmp(arg->op.op, "*") == 0) && 2073 2048 type == TEP_EVENT_DELIM && (strcmp(token, ")") == 0)) { 2074 - char *new_atom; 2049 + int ret; 2075 2050 2076 2051 if (left->type != TEP_PRINT_ATOM) { 2077 2052 do_warning_event(event, "bad pointer type"); 2078 2053 goto out_free; 2079 2054 } 2080 - new_atom = realloc(left->atom.atom, 2081 - strlen(left->atom.atom) + 3); 2082 - if (!new_atom) 2055 + ret = append(&left->atom.atom, " ", "*"); 2056 + if (ret < 0) 2083 2057 goto out_warn_free; 2084 2058 2085 - left->atom.atom = new_atom; 2086 - strcat(left->atom.atom, " *"); 2087 2059 free(arg->op.op); 2088 2060 *arg = *left; 2089 2061 free(left); ··· 3085 3063 } 3086 3064 3087 3065 static enum tep_event_type 3066 + process_builtin_expect(struct tep_event *event, struct tep_print_arg *arg, char **tok) 3067 + { 3068 + enum tep_event_type type; 3069 + char *token = NULL; 3070 + 3071 + /* Handle __builtin_expect( cond, #) */ 3072 + type = process_arg(event, arg, &token); 3073 + 3074 + if (type != TEP_EVENT_DELIM || token[0] != ',') 3075 + goto out_free; 3076 + 3077 + free_token(token); 3078 + 3079 + /* We don't care what the second parameter is of the __builtin_expect() */ 3080 + if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) 3081 + goto out_free; 3082 + 3083 + if (read_expected(TEP_EVENT_DELIM, ")") < 0) 3084 + goto out_free; 3085 + 3086 + free_token(token); 3087 + type = read_token_item(tok); 3088 + return type; 3089 + 3090 + out_free: 3091 + free_token(token); 3092 + *tok = NULL; 3093 + return TEP_EVENT_ERROR; 3094 + } 3095 + 3096 + static enum tep_event_type 3088 3097 process_function(struct tep_event *event, struct tep_print_arg *arg, 3089 3098 char *token, char **tok) 3090 3099 { ··· 3158 3105 if (strcmp(token, "__get_dynamic_array_len") == 0) { 3159 3106 free_token(token); 3160 3107 return process_dynamic_array_len(event, arg, tok); 3108 + } 3109 + if (strcmp(token, "__builtin_expect") == 0) { 3110 + free_token(token); 3111 + return process_builtin_expect(event, arg, tok); 3161 3112 } 3162 3113 3163 3114 func = find_func_handler(event->tep, token); ··· 3208 3151 } 3209 3152 /* atoms can be more than one token long */ 3210 3153 while (type == TEP_EVENT_ITEM) { 3211 - char *new_atom; 3212 - new_atom = realloc(atom, 3213 - strlen(atom) + strlen(token) + 2); 3214 - if (!new_atom) { 3154 + int ret; 3155 + 3156 + ret = append(&atom, " ", token); 3157 + if (ret < 0) { 3215 3158 free(atom); 3216 3159 *tok = NULL; 3217 3160 free_token(token); 3218 3161 return TEP_EVENT_ERROR; 3219 3162 } 3220 - atom = new_atom; 3221 - strcat(atom, " "); 3222 - strcat(atom, token); 3223 3163 free_token(token); 3224 3164 type = read_token_item(&token); 3225 3165 }
+12
tools/perf/Makefile.config
··· 396 396 NO_LIBBPF := 1 397 397 NO_JVMTI := 1 398 398 else 399 + ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),) 400 + ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0) 401 + msg := $(error No libasan found, please install libasan); 402 + endif 403 + endif 404 + 405 + ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),) 406 + ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0) 407 + msg := $(error No libubsan found, please install libubsan); 408 + endif 409 + endif 410 + 399 411 ifneq ($(filter s% -static%,$(LDFLAGS),),) 400 412 msg := $(error No static glibc found, please install glibc-static); 401 413 else
+1
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
··· 359 359 435 common clone3 sys_clone3 360 360 437 common openat2 sys_openat2 361 361 438 common pidfd_getfd sys_pidfd_getfd 362 + 439 common faccessat2 sys_faccessat2 362 363 363 364 # 364 365 # x32-specific system call numbers start at 512 to avoid cache impact
+1 -2
tools/perf/builtin-report.c
··· 478 478 if (rep->time_str) 479 479 ret += fprintf(fp, " (time slices: %s)", rep->time_str); 480 480 481 - if (symbol_conf.show_ref_callgraph && 482 - strstr(evname, "call-graph=no")) { 481 + if (symbol_conf.show_ref_callgraph && evname && strstr(evname, "call-graph=no")) { 483 482 ret += fprintf(fp, ", show reference callgraph"); 484 483 } 485 484
+3
tools/perf/builtin-script.c
··· 3837 3837 if (err) 3838 3838 goto out_delete; 3839 3839 3840 + if (zstd_init(&(session->zstd_data), 0) < 0) 3841 + pr_warning("Decompression initialization failed. Reported data may be incomplete.\n"); 3842 + 3840 3843 err = __cmd_script(&script); 3841 3844 3842 3845 flush_scripting();
+1
tools/perf/trace/beauty/statx.c
··· 65 65 P_FLAG(SIZE); 66 66 P_FLAG(BLOCKS); 67 67 P_FLAG(BTIME); 68 + P_FLAG(MNT_ID); 68 69 69 70 #undef P_FLAG 70 71
+10 -4
tools/perf/util/bpf-prologue.c
··· 142 142 gen_read_mem(struct bpf_insn_pos *pos, 143 143 int src_base_addr_reg, 144 144 int dst_addr_reg, 145 - long offset) 145 + long offset, 146 + int probeid) 146 147 { 147 148 /* mov arg3, src_base_addr_reg */ 148 149 if (src_base_addr_reg != BPF_REG_ARG3) ··· 160 159 ins(BPF_MOV64_REG(BPF_REG_ARG1, dst_addr_reg), pos); 161 160 162 161 /* Call probe_read */ 163 - ins(BPF_EMIT_CALL(BPF_FUNC_probe_read), pos); 162 + ins(BPF_EMIT_CALL(probeid), pos); 164 163 /* 165 164 * Error processing: if read fail, goto error code, 166 165 * will be relocated. Target should be the start of ··· 242 241 gen_prologue_slowpath(struct bpf_insn_pos *pos, 243 242 struct probe_trace_arg *args, int nargs) 244 243 { 245 - int err, i; 244 + int err, i, probeid; 246 245 247 246 for (i = 0; i < nargs; i++) { 248 247 struct probe_trace_arg *arg = &args[i]; ··· 277 276 stack_offset), pos); 278 277 279 278 ref = arg->ref; 279 + probeid = BPF_FUNC_probe_read_kernel; 280 280 while (ref) { 281 281 pr_debug("prologue: arg %d: offset %ld\n", 282 282 i, ref->offset); 283 + 284 + if (ref->user_access) 285 + probeid = BPF_FUNC_probe_read_user; 286 + 283 287 err = gen_read_mem(pos, BPF_REG_3, BPF_REG_7, 284 - ref->offset); 288 + ref->offset, probeid); 285 289 if (err) { 286 290 pr_err("prologue: failed to generate probe_read function call\n"); 287 291 goto errout;
+2 -2
tools/perf/util/parse-events.y
··· 26 26 YYABORT; \ 27 27 } while (0) 28 28 29 - static struct list_head* alloc_list() 29 + static struct list_head* alloc_list(void) 30 30 { 31 31 struct list_head *list; 32 32 ··· 349 349 struct list_head *list; 350 350 char pmu_name[128]; 351 351 352 - snprintf(&pmu_name, 128, "%s-%s", $1, $3); 352 + snprintf(pmu_name, sizeof(pmu_name), "%s-%s", $1, $3); 353 353 free($1); 354 354 free($3); 355 355 if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0)
-1
tools/perf/util/pmu.h
··· 86 86 struct perf_pmu_info *info); 87 87 struct list_head *perf_pmu__alias(struct perf_pmu *pmu, 88 88 struct list_head *head_terms); 89 - int perf_pmu_wrap(void); 90 89 void perf_pmu_error(struct list_head *list, char *name, char const *msg); 91 90 92 91 int perf_pmu__new_format(struct list_head *list, char *name,
+5 -2
tools/perf/util/probe-event.c
··· 1575 1575 } 1576 1576 1577 1577 tmp = strchr(str, '@'); 1578 - if (tmp && tmp != str && strcmp(tmp + 1, "user")) { /* user attr */ 1578 + if (tmp && tmp != str && !strcmp(tmp + 1, "user")) { /* user attr */ 1579 1579 if (!user_access_is_supported()) { 1580 1580 semantic_error("ftrace does not support user access\n"); 1581 1581 return -EINVAL; ··· 1995 1995 if (depth < 0) 1996 1996 return depth; 1997 1997 } 1998 - err = strbuf_addf(buf, "%+ld(", ref->offset); 1998 + if (ref->user_access) 1999 + err = strbuf_addf(buf, "%s%ld(", "+u", ref->offset); 2000 + else 2001 + err = strbuf_addf(buf, "%+ld(", ref->offset); 1999 2002 return (err < 0) ? err : depth; 2000 2003 } 2001 2004
+1 -1
tools/perf/util/probe-file.c
··· 1044 1044 DEFINE_TYPE(FTRACE_README_PROBE_TYPE_X, "*type: * x8/16/32/64,*"), 1045 1045 DEFINE_TYPE(FTRACE_README_KRETPROBE_OFFSET, "*place (kretprobe): *"), 1046 1046 DEFINE_TYPE(FTRACE_README_UPROBE_REF_CTR, "*ref_ctr_offset*"), 1047 - DEFINE_TYPE(FTRACE_README_USER_ACCESS, "*[u]<offset>*"), 1047 + DEFINE_TYPE(FTRACE_README_USER_ACCESS, "*u]<offset>*"), 1048 1048 DEFINE_TYPE(FTRACE_README_MULTIPROBE_EVENT, "*Create/append/*"), 1049 1049 DEFINE_TYPE(FTRACE_README_IMMEDIATE_VALUE, "*\\imm-value,*"), 1050 1050 };
+2 -2
tools/perf/util/stat-display.c
··· 668 668 int s; 669 669 bool first; 670 670 671 - if (!(config->aggr_map || config->aggr_get_id)) 671 + if (!config->aggr_map || !config->aggr_get_id) 672 672 return; 673 673 674 674 aggr_update_shadow(config, evlist); ··· 1169 1169 int s; 1170 1170 bool first = true; 1171 1171 1172 - if (!(config->aggr_map || config->aggr_get_id)) 1172 + if (!config->aggr_map || !config->aggr_get_id) 1173 1173 return; 1174 1174 1175 1175 if (config->percore_show_thread)
+3 -3
tools/testing/nvdimm/test/nfit_test.h
··· 51 51 __u32 nfit_device_handle; 52 52 __u32 _reserved; 53 53 __u64 dpa; 54 - } __packed devices[0]; 54 + } __packed devices[]; 55 55 56 56 } __packed; 57 57 ··· 74 74 struct nd_error_stat_query_record { 75 75 __u64 err_inj_stat_spa_range_base; 76 76 __u64 err_inj_stat_spa_range_length; 77 - } __packed record[0]; 77 + } __packed record[]; 78 78 } __packed; 79 79 80 80 #define ND_INTEL_SMART 1 ··· 180 180 __u32 context; 181 181 __u32 offset; 182 182 __u32 length; 183 - __u8 data[0]; 183 + __u8 data[]; 184 184 /* this field is not declared due ot variable data from input */ 185 185 /* __u32 status; */ 186 186 } __packed;
+9 -2
tools/testing/selftests/ftrace/ftracetest
··· 263 263 264 264 testcase() { # testfile 265 265 CASENO=$((CASENO+1)) 266 - desc=`grep "^#[ \t]*description:" $1 | cut -f2 -d:` 266 + desc=`grep "^#[ \t]*description:" $1 | cut -f2- -d:` 267 267 prlog -n "[$CASENO]$INSTANCE$desc" 268 + } 269 + 270 + checkreq() { # testfile 271 + requires=`grep "^#[ \t]*requires:" $1 | cut -f2- -d:` 272 + # Use eval to pass quoted-patterns correctly. 273 + eval check_requires "$requires" 268 274 } 269 275 270 276 test_on_instance() { # testfile ··· 362 356 363 357 __run_test() { # testfile 364 358 # setup PID and PPID, $$ is not updated. 365 - (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; initialize_ftrace; . $1) 359 + (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; 360 + checkreq $1; initialize_ftrace; . $1) 366 361 [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID 367 362 } 368 363
+1 -2
tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc
··· 1 1 #!/bin/sh 2 2 # description: Snapshot and tracing setting 3 + # requires: snapshot 3 4 # flags: instance 4 - 5 - [ ! -f snapshot ] && exit_unsupported 6 5 7 6 echo "Set tracing off" 8 7 echo 0 > tracing_on
+1 -2
tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: trace_pipe and trace_marker 4 + # requires: trace_marker 4 5 # flags: instance 5 - 6 - [ ! -f trace_marker ] && exit_unsupported 7 6 8 7 echo "test input 1" > trace_marker 9 8
+1 -5
tools/testing/selftests/ftrace/test.d/direct/kprobe-direct.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Test ftrace direct functions against kprobes 4 + # requires: kprobe_events 4 5 5 6 rmmod ftrace-direct ||: 6 7 if ! modprobe ftrace-direct ; then 7 8 echo "No ftrace-direct sample module - please build with CONFIG_SAMPLE_FTRACE_DIRECT=m" 8 9 exit_unresolved; 9 - fi 10 - 11 - if [ ! -f kprobe_events ]; then 12 - echo "No kprobe_events file -please build CONFIG_KPROBE_EVENTS" 13 - exit_unresolved; 14 10 fi 15 11 16 12 echo "Let the module run a little"
+1 -5
tools/testing/selftests/ftrace/test.d/dynevent/add_remove_kprobe.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Generic dynamic event - add/remove kprobe events 4 - 5 - [ -f dynamic_events ] || exit_unsupported 6 - 7 - grep -q "place: \[<module>:\]<symbol>" README || exit_unsupported 8 - grep -q "place (kretprobe): \[<module>:\]<symbol>" README || exit_unsupported 4 + # requires: dynamic_events "place: [<module>:]<symbol>":README "place (kretprobe): [<module>:]<symbol>":README 9 5 10 6 echo 0 > events/enable 11 7 echo > dynamic_events
+1 -4
tools/testing/selftests/ftrace/test.d/dynevent/add_remove_synth.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Generic dynamic event - add/remove synthetic events 4 - 5 - [ -f dynamic_events ] || exit_unsupported 6 - 7 - grep -q "s:\[synthetic/\]" README || exit_unsupported 4 + # requires: dynamic_events "s:[synthetic/]":README 8 5 9 6 echo 0 > events/enable 10 7 echo > dynamic_events
+1 -10
tools/testing/selftests/ftrace/test.d/dynevent/clear_select_events.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Generic dynamic event - selective clear (compatibility) 4 - 5 - [ -f dynamic_events ] || exit_unsupported 6 - 7 - grep -q "place: \[<module>:\]<symbol>" README || exit_unsupported 8 - grep -q "place (kretprobe): \[<module>:\]<symbol>" README || exit_unsupported 9 - 10 - grep -q "s:\[synthetic/\]" README || exit_unsupported 11 - 12 - [ -f synthetic_events ] || exit_unsupported 13 - [ -f kprobe_events ] || exit_unsupported 4 + # requires: dynamic_events kprobe_events synthetic_events "place: [<module>:]<symbol>":README "place (kretprobe): [<module>:]<symbol>":README "s:[synthetic/]":README 14 5 15 6 echo 0 > events/enable 16 7 echo > dynamic_events
+1 -7
tools/testing/selftests/ftrace/test.d/dynevent/generic_clear_event.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Generic dynamic event - generic clear event 4 - 5 - [ -f dynamic_events ] || exit_unsupported 6 - 7 - grep -q "place: \[<module>:\]<symbol>" README || exit_unsupported 8 - grep -q "place (kretprobe): \[<module>:\]<symbol>" README || exit_unsupported 9 - 10 - grep -q "s:\[synthetic/\]" README || exit_unsupported 4 + # requires: dynamic_events "place: [<module>:]<symbol>":README "place (kretprobe): [<module>:]<symbol>":README "s:[synthetic/]":README 11 5 12 6 echo 0 > events/enable 13 7 echo > dynamic_events
+1 -5
tools/testing/selftests/ftrace/test.d/event/event-enable.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event tracing - enable/disable with event level files 4 + # requires: set_event events/sched 4 5 # flags: instance 5 6 6 7 do_reset() { ··· 13 12 echo $1 14 13 exit_fail 15 14 } 16 - 17 - if [ ! -f set_event -o ! -d events/sched ]; then 18 - echo "event tracing is not supported" 19 - exit_unsupported 20 - fi 21 15 22 16 echo 'sched:sched_switch' > set_event 23 17
+1 -10
tools/testing/selftests/ftrace/test.d/event/event-no-pid.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event tracing - restricts events based on pid notrace filtering 4 + # requires: set_event events/sched set_event_pid set_event_notrace_pid 4 5 # flags: instance 5 6 6 7 do_reset() { ··· 56 55 enable_system thermal 57 56 echo 1 > tracing_on 58 57 } 59 - 60 - if [ ! -f set_event -o ! -d events/sched ]; then 61 - echo "event tracing is not supported" 62 - exit_unsupported 63 - fi 64 - 65 - if [ ! -f set_event_pid -o ! -f set_event_notrace_pid ]; then 66 - echo "event pid notrace filtering is not supported" 67 - exit_unsupported 68 - fi 69 58 70 59 echo 0 > options/event-fork 71 60
+1 -10
tools/testing/selftests/ftrace/test.d/event/event-pid.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event tracing - restricts events based on pid 4 + # requires: set_event set_event_pid events/sched 4 5 # flags: instance 5 6 6 7 do_reset() { ··· 16 15 echo $1 17 16 exit_fail 18 17 } 19 - 20 - if [ ! -f set_event -o ! -d events/sched ]; then 21 - echo "event tracing is not supported" 22 - exit_unsupported 23 - fi 24 - 25 - if [ ! -f set_event_pid ]; then 26 - echo "event pid filtering is not supported" 27 - exit_unsupported 28 - fi 29 18 30 19 echo 0 > options/event-fork 31 20
+1 -5
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event tracing - enable/disable with subsystem level files 4 + # requires: set_event events/sched/enable 4 5 # flags: instance 5 6 6 7 do_reset() { ··· 13 12 echo $1 14 13 exit_fail 15 14 } 16 - 17 - if [ ! -f set_event -o ! -d events/sched ]; then 18 - echo "event tracing is not supported" 19 - exit_unsupported 20 - fi 21 15 22 16 echo 'sched:*' > set_event 23 17
+1 -5
tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event tracing - enable/disable with top level files 4 + # requires: available_events set_event events/enable 4 5 5 6 do_reset() { 6 7 echo > set_event ··· 12 11 echo $1 13 12 exit_fail 14 13 } 15 - 16 - if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then 17 - echo "event tracing is not supported" 18 - exit_unsupported 19 - fi 20 14 21 15 echo '*:*' > set_event 22 16
+1 -13
tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function graph filters with stack tracer 4 + # requires: stack_trace set_ftrace_filter function_graph:tracer 4 5 5 6 # Make sure that function graph filtering works, and is not 6 7 # affected by other tracers enabled (like stack tracer) 7 - 8 - if ! grep -q function_graph available_tracers; then 9 - echo "no function graph tracer configured" 10 - exit_unsupported 11 - fi 12 - 13 - check_filter_file set_ftrace_filter 14 8 15 9 do_reset() { 16 10 if [ -e /proc/sys/kernel/stack_tracer_enabled ]; then ··· 30 36 fi 31 37 32 38 echo function_graph > current_tracer 33 - 34 - if [ ! -f stack_trace ]; then 35 - echo "Stack tracer not configured" 36 - do_reset 37 - exit_unsupported; 38 - fi 39 39 40 40 echo "Now testing with stack tracer" 41 41
+1 -7
tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function graph filters 4 + # requires: set_ftrace_filter function_graph:tracer 4 5 5 6 # Make sure that function graph filtering works 6 - 7 - if ! grep -q function_graph available_tracers; then 8 - echo "no function graph tracer configured" 9 - exit_unsupported 10 - fi 11 - 12 - check_filter_file set_ftrace_filter 13 7 14 8 fail() { # msg 15 9 echo $1
+1 -7
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function glob filters 4 + # requires: set_ftrace_filter function:tracer 4 5 5 6 # Make sure that function glob matching filter works. 6 - 7 - if ! grep -q function available_tracers; then 8 - echo "no function tracer configured" 9 - exit_unsupported 10 - fi 11 - 12 - check_filter_file set_ftrace_filter 13 7 14 8 disable_tracing 15 9 clear_trace
+1 -12
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-notrace-pid.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function pid notrace filters 4 + # requires: set_ftrace_notrace_pid set_ftrace_filter function:tracer 4 5 # flags: instance 5 6 6 7 # Make sure that function pid matching filter with notrace works. 7 - 8 - if ! grep -q function available_tracers; then 9 - echo "no function tracer configured" 10 - exit_unsupported 11 - fi 12 - 13 - if [ ! -f set_ftrace_notrace_pid ]; then 14 - echo "set_ftrace_notrace_pid not found? Is function tracer not set?" 15 - exit_unsupported 16 - fi 17 - 18 - check_filter_file set_ftrace_filter 19 8 20 9 do_function_fork=1 21 10
+1 -12
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function pid filters 4 + # requires: set_ftrace_pid set_ftrace_filter function:tracer 4 5 # flags: instance 5 6 6 7 # Make sure that function pid matching filter works. 7 8 # Also test it on an instance directory 8 - 9 - if ! grep -q function available_tracers; then 10 - echo "no function tracer configured" 11 - exit_unsupported 12 - fi 13 - 14 - if [ ! -f set_ftrace_pid ]; then 15 - echo "set_ftrace_pid not found? Is function tracer not set?" 16 - exit_unsupported 17 - fi 18 - 19 - check_filter_file set_ftrace_filter 20 9 21 10 do_function_fork=1 22 11
+1 -2
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - stacktrace filter command 4 + # requires: set_ftrace_filter 4 5 # flags: instance 5 - 6 - check_filter_file set_ftrace_filter 7 6 8 7 echo _do_fork:stacktrace >> set_ftrace_filter 9 8
+1 -5
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function trace with cpumask 4 + # requires: function:tracer 4 5 5 6 if ! which nproc ; then 6 7 nproc() { ··· 14 13 if [ $NP -eq 1 ] ;then 15 14 echo "We can not test cpumask on UP environment" 16 15 exit_unresolved 17 - fi 18 - 19 - if ! grep -q "function" available_tracers ; then 20 - echo "Function trace is not enabled" 21 - exit_unsupported 22 16 fi 23 17 24 18 ORIG_CPUMASK=`cat tracing_cpumask`
+3 -4
tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
··· 3 3 # description: ftrace - test for function event triggers 4 4 # flags: instance 5 5 # 6 + # The triggers are set within the set_ftrace_filter file 7 + # requires: set_ftrace_filter 8 + # 6 9 # Ftrace allows to add triggers to functions, such as enabling or disabling 7 10 # tracing, enabling or disabling trace events, or recording a stack trace 8 11 # within the ring buffer. 9 12 # 10 13 # This test is designed to test event triggers 11 - # 12 - 13 - # The triggers are set within the set_ftrace_filter file 14 - check_filter_file set_ftrace_filter 15 14 16 15 do_reset() { 17 16 reset_ftrace_filter
+1 -2
tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function trace on module 4 - 5 - check_filter_file set_ftrace_filter 4 + # requires: set_ftrace_filter 6 5 7 6 : "mod: allows to filter a non exist function" 8 7 echo 'non_exist_func:mod:non_exist_module' > set_ftrace_filter
+1 -2
tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function profiling 4 - 5 - [ ! -f function_profile_enabled ] && exit_unsupported 4 + # requires: function_profile_enabled 6 5 7 6 : "Enable function profile" 8 7 echo 1 > function_profile_enabled
+1 -11
tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function profiler with function tracing 4 + # requires: function_profile_enabled set_ftrace_filter function_graph:tracer 4 5 5 6 # There was a bug after a rewrite of the ftrace infrastructure that 6 7 # caused the function_profiler not to be able to run with the function ··· 14 13 # This test triggers those bugs on those kernels. 15 14 # 16 15 # We need function_graph and profiling to to run this test 17 - if ! grep -q function_graph available_tracers; then 18 - echo "no function graph tracer configured" 19 - exit_unsupported; 20 - fi 21 - 22 - check_filter_file set_ftrace_filter 23 - 24 - if [ ! -f function_profile_enabled ]; then 25 - echo "function_profile_enabled not found, function profiling enabled?" 26 - exit_unsupported 27 - fi 28 16 29 17 fail() { # mesg 30 18 echo $1
+3 -3
tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - test reading of set_ftrace_filter 4 4 # 5 + # The triggers are set within the set_ftrace_filter file 6 + # requires: set_ftrace_filter 7 + # 5 8 # The set_ftrace_filter file of ftrace is used to list functions as well as 6 9 # triggers (probes) attached to functions. The code to read this file is not 7 10 # straight forward and has had various bugs in the past. This test is designed 8 11 # to add functions and triggers to that file in various ways and read that 9 12 # file in various ways (cat vs dd). 10 13 # 11 - 12 - # The triggers are set within the set_ftrace_filter file 13 - check_filter_file set_ftrace_filter 14 14 15 15 fail() { # mesg 16 16 echo $1
+1 -7
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - Max stack tracer 4 + # requires: stack_trace stack_trace_filter 4 5 # Test the basic function of max-stack usage tracing 5 - 6 - if [ ! -f stack_trace ]; then 7 - echo "Max stack tracer is not supported - please make CONFIG_STACK_TRACER=y" 8 - exit_unsupported 9 - fi 10 - 11 - check_filter_file stack_trace_filter 12 6 13 7 echo > stack_trace_filter 14 8 echo 0 > stack_max_size
+3 -3
tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
··· 3 3 # description: ftrace - test for function traceon/off triggers 4 4 # flags: instance 5 5 # 6 + # The triggers are set within the set_ftrace_filter file 7 + # requires: set_ftrace_filter 8 + # 6 9 # Ftrace allows to add triggers to functions, such as enabling or disabling 7 10 # tracing, enabling or disabling trace events, or recording a stack trace 8 11 # within the ring buffer. 9 12 # 10 13 # This test is designed to test enabling and disabling tracing triggers 11 14 # 12 - 13 - # The triggers are set within the set_ftrace_filter file 14 - check_filter_file set_ftrace_filter 15 15 16 16 fail() { # mesg 17 17 echo $1
+3 -9
tools/testing/selftests/ftrace/test.d/ftrace/tracing-error-log.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - test tracing error log support 4 + # event tracing is currently the only ftrace tracer that uses the 5 + # tracing error_log, hence this check 6 + # requires: set_event error_log 4 7 5 8 fail() { #msg 6 9 echo $1 7 10 exit_fail 8 11 } 9 - 10 - # event tracing is currently the only ftrace tracer that uses the 11 - # tracing error_log, hence this check 12 - if [ ! -f set_event ]; then 13 - echo "event tracing is not supported" 14 - exit_unsupported 15 - fi 16 - 17 - [ -f error_log ] || exit_unsupported 18 12 19 13 ftrace_errlog_check 'event filter parse error' '((sig >= 10 && sig < 15) || dsig ^== 17) && comm != bash' 'events/signal/signal_generate/filter' 20 14
+21 -7
tools/testing/selftests/ftrace/test.d/functions
··· 1 - check_filter_file() { # check filter file introduced by dynamic ftrace 2 - if [ ! -f "$1" ]; then 3 - echo "$1 not found? Is dynamic ftrace not set?" 4 - exit_unsupported 5 - fi 6 - } 7 - 8 1 clear_trace() { # reset trace output 9 2 echo > trace 10 3 } ··· 104 111 [ -f snapshot ] && echo 0 > snapshot 105 112 clear_trace 106 113 enable_tracing 114 + } 115 + 116 + check_requires() { # Check required files and tracers 117 + for i in "$@" ; do 118 + r=${i%:README} 119 + t=${i%:tracer} 120 + if [ $t != $i ]; then 121 + if ! grep -wq $t available_tracers ; then 122 + echo "Required tracer $t is not configured." 123 + exit_unsupported 124 + fi 125 + elif [ $r != $i ]; then 126 + if ! grep -Fq "$r" README ; then 127 + echo "Required feature pattern \"$r\" is not in README." 128 + exit_unsupported 129 + fi 130 + elif [ ! -e $i ]; then 131 + echo "Required feature interface $i doesn't exist." 132 + exit_unsupported 133 + fi 134 + done 107 135 } 108 136 109 137 LOCALHOST=127.0.0.1
+1 -5
tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Test creation and deletion of trace instances while setting an event 4 - 5 - if [ ! -d instances ] ; then 6 - echo "no instance directory with this kernel" 7 - exit_unsupported; 8 - fi 4 + # requires: instances 9 5 10 6 fail() { # mesg 11 7 rmdir foo 2>/dev/null
+1 -5
tools/testing/selftests/ftrace/test.d/instances/instance.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Test creation and deletion of trace instances 4 - 5 - if [ ! -d instances ] ; then 6 - echo "no instance directory with this kernel" 7 - exit_unsupported; 8 - fi 4 + # requires: instances 9 5 10 6 fail() { # mesg 11 7 rmdir x y z 2>/dev/null
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe dynamic event - adding and removing 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 echo p:myevent _do_fork > kprobe_events 8 7 grep myevent kprobe_events
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe dynamic event - busy event check 4 - 5 - [ -f kprobe_events ] || exit_unsupported 4 + # requires: kprobe_events 6 5 7 6 echo p:myevent _do_fork > kprobe_events 8 7 test -d events/kprobes/myevent
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe dynamic event with arguments 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 echo 'p:testprobe _do_fork $stack $stack0 +0($stack)' > kprobe_events 8 7 grep testprobe kprobe_events | grep -q 'arg1=\$stack arg2=\$stack0 arg3=+0(\$stack)'
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_comm.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe event with comm arguments 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 grep -A1 "fetcharg:" README | grep -q "\$comm" || exit_unsupported # this is too old 8 7
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe event string type argument 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 case `uname -m` in 8 7 x86_64)
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe event symbol argument 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 SYMBOL="linux_proc_banner" 8 7
+1 -4
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe event argument syntax 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 6 - 7 - grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue 4 + # requires: kprobe_events "x8/16/32/64":README 8 5 9 6 PROBEFUNC="vfs_read" 10 7 GOODREG=
+1 -4
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobes event arguments with types 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 6 - 7 - grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue 4 + # requires: kprobe_events "x8/16/32/64":README 8 5 9 6 gen_event() { # Bitsize 10 7 echo "p:testprobe _do_fork \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1"
+1 -3
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe event user-memory access 4 + # requires: kprobe_events '$arg<N>':README 4 5 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 6 - 7 - grep -q '\$arg<N>' README || exit_unresolved # depends on arch 8 6 grep -A10 "fetcharg:" README | grep -q 'ustring' || exit_unsupported 9 7 grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported 10 8
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe event auto/manual naming 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 :;: "Add an event on function without name" ;: 8 7
+1 -5
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe dynamic event with function tracer 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 6 - grep "function" available_tracers || exit_unsupported # this is configurable 7 - 8 - check_filter_file set_ftrace_filter 4 + # requires: kprobe_events stack_trace_filter function:tracer 9 5 10 6 # prepare 11 7 echo nop > current_tracer
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe dynamic event - probing module 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 rmmod trace-printk ||: 8 7 if ! modprobe trace-printk ; then
+1 -4
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_multiprobe.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Create/delete multiprobe on kprobe event 4 - 5 - [ -f kprobe_events ] || exit_unsupported 6 - 7 - grep -q "Create/append/" README || exit_unsupported 4 + # requires: kprobe_events "Create/append/":README 8 5 9 6 # Choose 2 symbols for target 10 7 SYM1=_do_fork
+1 -4
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe event parser error log check 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 6 - 7 - [ -f error_log ] || exit_unsupported 4 + # requires: kprobe_events error_log 8 5 9 6 check_error() { # command-with-error-pos-by-^ 10 7 ftrace_errlog_check 'trace_kprobe' "$1" 'kprobe_events'
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kretprobe dynamic event with arguments 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 # Add new kretprobe event 8 7 echo 'r:testprobe2 _do_fork $retval' > kprobe_events
+1 -3
tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_maxactive.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kretprobe dynamic event with maxactive 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 6 - grep -q 'r\[maxactive\]' README || exit_unsupported # this is older version 4 + # requires: kprobe_events 'r[maxactive]':README 7 5 8 6 # Test if we successfully reject unknown messages 9 7 if echo 'a:myprobeaccept inet_csk_accept' > kprobe_events; then false; else true; fi
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Register/unregister many kprobe events 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 # ftrace fentry skip size depends on the machine architecture. 8 7 # Currently HAVE_KPROBES_ON_FTRACE defined on x86 and powerpc64le
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe events - probe points 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 TARGET_FUNC=tracefs_create_dir 8 7
+1 -2
tools/testing/selftests/ftrace/test.d/kprobe/profile.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Kprobe dynamic event - adding and removing 4 - 5 - [ -f kprobe_events ] || exit_unsupported # this is configurable 4 + # requires: kprobe_events 6 5 7 6 ! grep -q 'myevent' kprobe_profile 8 7 echo p:myevent _do_fork > kprobe_events
+1 -4
tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Uprobe event parser error log check 4 - 5 - [ -f uprobe_events ] || exit_unsupported # this is configurable 6 - 7 - [ -f error_log ] || exit_unsupported 4 + # requires: uprobe_events error_log 8 5 9 6 check_error() { # command-with-error-pos-by-^ 10 7 ftrace_errlog_check 'trace_uprobe' "$1" 'uprobe_events'
+1 -3
tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: test for the preemptirqsoff tracer 4 + # requires: preemptoff:tracer irqsoff:tracer 4 5 5 6 MOD=preemptirq_delay_test 6 7 ··· 27 26 28 27 modprobe $MOD || unres "$MOD module not available" 29 28 rmmod $MOD 30 - 31 - grep -q "preemptoff" available_tracers || unsup "preemptoff tracer not enabled" 32 - grep -q "irqsoff" available_tracers || unsup "irqsoff tracer not enabled" 33 29 34 30 reset_tracer 35 31
+4
tools/testing/selftests/ftrace/test.d/template
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: %HERE DESCRIBE WHAT THIS DOES% 4 + # requires: %HERE LIST THE REQUIRED FILES, TRACERS OR README-STRINGS% 5 + # The required tracer needs :tracer suffix, e.g. function:tracer 6 + # The required README string needs :README suffix, e.g. "x8/16/32/64":README 7 + # and the README string is treated as a fixed-string instead of regexp pattern. 4 8 # you have to add ".tc" extention for your testcase file 5 9 # Note that all tests are run with "errexit" option. 6 10
+1 -5
tools/testing/selftests/ftrace/test.d/tracer/wakeup.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Test wakeup tracer 4 + # requires: wakeup:tracer 4 5 5 6 if ! which chrt ; then 6 7 echo "chrt is not found. This test requires nice command." 7 8 exit_unresolved 8 - fi 9 - 10 - if ! grep -wq "wakeup" available_tracers ; then 11 - echo "wakeup tracer is not supported" 12 - exit_unsupported 13 9 fi 14 10 15 11 echo wakeup > current_tracer
+1 -5
tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: Test wakeup RT tracer 4 + # requires: wakeup_rt:tracer 4 5 5 6 if ! which chrt ; then 6 7 echo "chrt is not found. This test requires chrt command." 7 8 exit_unresolved 8 - fi 9 - 10 - if ! grep -wq "wakeup_rt" available_tracers ; then 11 - echo "wakeup_rt tracer is not supported" 12 - exit_unsupported 13 9 fi 14 10 15 11 echo wakeup_rt > current_tracer
+1 -12
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-action-hist-xfail.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test inter-event histogram trigger expected fail actions 4 + # requires: set_event snapshot "snapshot()":README 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f snapshot ]; then 16 - echo "snapshot is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - grep -q "snapshot()" README || exit_unsupported # version issue 21 10 22 11 echo "Test expected snapshot action failure" 23 12
+1 -15
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test field variable support 4 + # requires: set_event synthetic_events events/sched/sched_process_fork/hist 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f synthetic_events ]; then 16 - echo "synthetic event is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - if [ ! -f events/sched/sched_process_fork/hist ]; then 21 - echo "hist trigger is not supported" 22 - exit_unsupported 23 - fi 24 10 25 11 echo "Test field variable support" 26 12
+1 -15
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test inter-event combined histogram trigger 4 + # requires: set_event synthetic_events events/sched/sched_process_fork/hist 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f synthetic_events ]; then 16 - echo "synthetic event is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - if [ ! -f events/sched/sched_process_fork/hist ]; then 21 - echo "hist trigger is not supported" 22 - exit_unsupported 23 - fi 24 10 25 11 echo "Test create synthetic event" 26 12
+1 -15
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-multi-actions-accept.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test multiple actions on hist trigger 4 + # requires: set_event synthetic_events events/sched/sched_process_fork/hist 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f synthetic_events ]; then 16 - echo "synthetic event is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - if [ ! -f events/sched/sched_process_fork/hist ]; then 21 - echo "hist trigger is not supported" 22 - exit_unsupported 23 - fi 24 10 25 11 echo "Test multiple actions on hist trigger" 26 12 echo 'wakeup_latency u64 lat; pid_t pid' >> synthetic_events
+1 -7
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test inter-event histogram trigger onchange action 4 + # requires: set_event "onchange(var)":README 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - grep -q "onchange(var)" README || exit_unsupported # version issue 16 10 17 11 echo "Test onchange action" 18 12
+1 -15
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test inter-event histogram trigger onmatch action 4 + # requires: set_event synthetic_events events/sched/sched_process_fork/hist 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f synthetic_events ]; then 16 - echo "synthetic event is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - if [ ! -f events/sched/sched_process_fork/hist ]; then 21 - echo "hist trigger is not supported" 22 - exit_unsupported 23 - fi 24 10 25 11 echo "Test create synthetic event" 26 12
+1 -15
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test inter-event histogram trigger onmatch-onmax action 4 + # requires: set_event synthetic_events events/sched/sched_process_fork/hist 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f synthetic_events ]; then 16 - echo "synthetic event is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - if [ ! -f events/sched/sched_process_fork/hist ]; then 21 - echo "hist trigger is not supported" 22 - exit_unsupported 23 - fi 24 10 25 11 echo "Test create synthetic event" 26 12
+1 -15
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test inter-event histogram trigger onmax action 4 + # requires: set_event synthetic_events events/sched/sched_process_fork/hist 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f synthetic_events ]; then 16 - echo "synthetic event is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - if [ ! -f events/sched/sched_process_fork/hist ]; then 21 - echo "hist trigger is not supported" 22 - exit_unsupported 23 - fi 24 10 25 11 echo "Test create synthetic event" 26 12
+1 -19
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test inter-event histogram trigger snapshot action 4 + # requires: set_event snapshot events/sched/sched_process_fork/hist "onchange(var)":README "snapshot()":README 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f events/sched/sched_process_fork/hist ]; then 16 - echo "hist trigger is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - if [ ! -f snapshot ]; then 21 - echo "snapshot is not supported" 22 - exit_unsupported 23 - fi 24 - 25 - grep -q "onchange(var)" README || exit_unsupported # version issue 26 - 27 - grep -q "snapshot()" README || exit_unsupported # version issue 28 10 29 11 echo "Test snapshot action" 30 12
+1 -10
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test synthetic event create remove 4 + # requires: set_event synthetic_events 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f synthetic_events ]; then 16 - echo "synthetic event is not supported" 17 - exit_unsupported 18 - fi 19 10 20 11 echo "Test create synthetic event" 21 12
+1 -10
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-syntax.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test synthetic_events syntax parser 4 + # requires: set_event synthetic_events 4 5 5 6 do_reset() { 6 7 reset_trigger ··· 14 13 echo $1 15 14 exit_fail 16 15 } 17 - 18 - if [ ! -f set_event ]; then 19 - echo "event tracing is not supported" 20 - exit_unsupported 21 - fi 22 - 23 - if [ ! -f synthetic_events ]; then 24 - echo "synthetic event is not supported" 25 - exit_unsupported 26 - fi 27 16 28 17 reset_tracer 29 18 do_reset
+1 -17
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-trace-action-hist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test inter-event histogram trigger trace action 4 + # requires: set_event synthetic_events events/sched/sched_process_fork/hist "trace(<synthetic_event>":README 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f synthetic_events ]; then 16 - echo "synthetic event is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - if [ ! -f events/sched/sched_process_fork/hist ]; then 21 - echo "hist trigger is not supported" 22 - exit_unsupported 23 - fi 24 - 25 - grep -q "trace(<synthetic_event>" README || exit_unsupported # version issue 26 10 27 11 echo "Test create synthetic event" 28 12
+1 -10
tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test event enable/disable trigger 4 + # requires: set_event events/sched/sched_process_fork/trigger 4 5 # flags: instance 5 6 6 7 fail() { #msg 7 8 echo $1 8 9 exit_fail 9 10 } 10 - 11 - if [ ! -f set_event -o ! -d events/sched ]; then 12 - echo "event tracing is not supported" 13 - exit_unsupported 14 - fi 15 - 16 - if [ ! -f events/sched/sched_process_fork/trigger ]; then 17 - echo "event trigger is not supported" 18 - exit_unsupported 19 - fi 20 11 21 12 FEATURE=`grep enable_event events/sched/sched_process_fork/trigger` 22 13 if [ -z "$FEATURE" ]; then
+1 -10
tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test trigger filter 4 + # requires: set_event events/sched/sched_process_fork/trigger 4 5 # flags: instance 5 6 6 7 fail() { #msg 7 8 echo $1 8 9 exit_fail 9 10 } 10 - 11 - if [ ! -f set_event -o ! -d events/sched ]; then 12 - echo "event tracing is not supported" 13 - exit_unsupported 14 - fi 15 - 16 - if [ ! -f events/sched/sched_process_fork/trigger ]; then 17 - echo "event trigger is not supported" 18 - exit_unsupported 19 - fi 20 11 21 12 echo "Test trigger filter" 22 13 echo 1 > tracing_on
+1 -15
tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test histogram modifiers 4 + # requires: set_event events/sched/sched_process_fork/trigger events/sched/sched_process_fork/hist 4 5 # flags: instance 5 6 6 7 fail() { #msg 7 8 echo $1 8 9 exit_fail 9 10 } 10 - 11 - if [ ! -f set_event -o ! -d events/sched ]; then 12 - echo "event tracing is not supported" 13 - exit_unsupported 14 - fi 15 - 16 - if [ ! -f events/sched/sched_process_fork/trigger ]; then 17 - echo "event trigger is not supported" 18 - exit_unsupported 19 - fi 20 - 21 - if [ ! -f events/sched/sched_process_fork/hist ]; then 22 - echo "hist trigger is not supported" 23 - exit_unsupported 24 - fi 25 11 26 12 echo "Test histogram with execname modifier" 27 13
+1 -17
tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-syntax-errors.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test histogram parser errors 4 - 5 - if [ ! -f set_event -o ! -d events/kmem ]; then 6 - echo "event tracing is not supported" 7 - exit_unsupported 8 - fi 9 - 10 - if [ ! -f events/kmem/kmalloc/trigger ]; then 11 - echo "event trigger is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f events/kmem/kmalloc/hist ]; then 16 - echo "hist trigger is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - [ -f error_log ] || exit_unsupported 4 + # requires: set_event events/kmem/kmalloc/trigger events/kmem/kmalloc/hist error_log 21 5 22 6 check_error() { # command-with-error-pos-by-^ 23 7 ftrace_errlog_check 'hist:kmem:kmalloc' "$1" 'events/kmem/kmalloc/trigger'
+2 -16
tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test histogram trigger 4 + # requires: set_event events/sched/sched_process_fork/trigger events/sched/sched_process_fork/hist 4 5 # flags: instance 5 6 6 7 fail() { #msg ··· 9 8 exit_fail 10 9 } 11 10 12 - if [ ! -f set_event -o ! -d events/sched ]; then 13 - echo "event tracing is not supported" 14 - exit_unsupported 15 - fi 16 - 17 - if [ ! -f events/sched/sched_process_fork/trigger ]; then 18 - echo "event trigger is not supported" 19 - exit_unsupported 20 - fi 21 - 22 - if [ ! -f events/sched/sched_process_fork/hist ]; then 23 - echo "hist trigger is not supported" 24 - exit_unsupported 25 - fi 26 - 27 - echo "Test histogram basic tigger" 11 + echo "Test histogram basic trigger" 28 12 29 13 echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger 30 14 for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
+1 -15
tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test multiple histogram triggers 4 + # requires: set_event events/sched/sched_process_fork/trigger events/sched/sched_process_fork/hist 4 5 # flags: instance 5 6 6 7 fail() { #msg 7 8 echo $1 8 9 exit_fail 9 10 } 10 - 11 - if [ ! -f set_event -o ! -d events/sched ]; then 12 - echo "event tracing is not supported" 13 - exit_unsupported 14 - fi 15 - 16 - if [ ! -f events/sched/sched_process_fork/trigger ]; then 17 - echo "event trigger is not supported" 18 - exit_unsupported 19 - fi 20 - 21 - if [ ! -f events/sched/sched_process_fork/hist ]; then 22 - echo "hist trigger is not supported" 23 - exit_unsupported 24 - fi 25 11 26 12 echo "Test histogram multiple triggers" 27 13
+1 -15
tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test snapshot-trigger 4 + # requires: set_event events/sched/sched_process_fork/trigger snapshot 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event -o ! -d events/sched ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f events/sched/sched_process_fork/trigger ]; then 16 - echo "event trigger is not supported" 17 - exit_unsupported 18 - fi 19 - 20 - if [ ! -f snapshot ]; then 21 - echo "snapshot is not supported" 22 - exit_unsupported 23 - fi 24 10 25 11 FEATURE=`grep snapshot events/sched/sched_process_fork/trigger` 26 12 if [ -z "$FEATURE" ]; then
+2 -11
tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test stacktrace-trigger 4 + # requires: set_event events/sched/sched_process_fork/trigger 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event -o ! -d events/sched ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f events/sched/sched_process_fork/trigger ]; then 16 - echo "event trigger is not supported" 17 - exit_unsupported 18 - fi 19 10 20 11 FEATURE=`grep stacktrace events/sched/sched_process_fork/trigger` 21 12 if [ -z "$FEATURE" ]; then ··· 14 23 exit_unsupported 15 24 fi 16 25 17 - echo "Test stacktrace tigger" 26 + echo "Test stacktrace trigger" 18 27 echo 0 > trace 19 28 echo 0 > options/stacktrace 20 29 echo 'stacktrace' > events/sched/sched_process_fork/trigger
+2 -21
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-hist.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: trace_marker trigger - test histogram trigger 4 + # requires: set_event events/ftrace/print/trigger events/ftrace/print/hist 4 5 # flags: instance 5 6 6 7 fail() { #msg ··· 9 8 exit_fail 10 9 } 11 10 12 - if [ ! -f set_event ]; then 13 - echo "event tracing is not supported" 14 - exit_unsupported 15 - fi 16 - 17 - if [ ! -d events/ftrace/print ]; then 18 - echo "event trace_marker is not supported" 19 - exit_unsupported 20 - fi 21 - 22 - if [ ! -f events/ftrace/print/trigger ]; then 23 - echo "event trigger is not supported" 24 - exit_unsupported 25 - fi 26 - 27 - if [ ! -f events/ftrace/print/hist ]; then 28 - echo "hist trigger is not supported" 29 - exit_unsupported 30 - fi 31 - 32 - echo "Test histogram trace_marker tigger" 11 + echo "Test histogram trace_marker trigger" 33 12 34 13 echo 'hist:keys=common_pid' > events/ftrace/print/trigger 35 14 for i in `seq 1 10` ; do echo "hello" > trace_marker; done
+2 -21
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: trace_marker trigger - test snapshot trigger 4 + # requires: set_event snapshot events/ftrace/print/trigger 4 5 # flags: instance 5 6 6 7 fail() { #msg 7 8 echo $1 8 9 exit_fail 9 10 } 10 - 11 - if [ ! -f set_event ]; then 12 - echo "event tracing is not supported" 13 - exit_unsupported 14 - fi 15 - 16 - if [ ! -f snapshot ]; then 17 - echo "snapshot is not supported" 18 - exit_unsupported 19 - fi 20 - 21 - if [ ! -d events/ftrace/print ]; then 22 - echo "event trace_marker is not supported" 23 - exit_unsupported 24 - fi 25 - 26 - if [ ! -f events/ftrace/print/trigger ]; then 27 - echo "event trigger is not supported" 28 - exit_unsupported 29 - fi 30 11 31 12 test_trace() { 32 13 file=$1 ··· 27 46 done 28 47 } 29 48 30 - echo "Test snapshot trace_marker tigger" 49 + echo "Test snapshot trace_marker trigger" 31 50 32 51 echo 'snapshot' > events/ftrace/print/trigger 33 52
+1 -30
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic-kernel.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: trace_marker trigger - test histogram with synthetic event against kernel event 4 + # requires: set_event synthetic_events events/sched/sched_waking events/ftrace/print/trigger events/ftrace/print/hist 4 5 # flags: 5 6 6 7 fail() { #msg 7 8 echo $1 8 9 exit_fail 9 10 } 10 - 11 - if [ ! -f set_event ]; then 12 - echo "event tracing is not supported" 13 - exit_unsupported 14 - fi 15 - 16 - if [ ! -f synthetic_events ]; then 17 - echo "synthetic events not supported" 18 - exit_unsupported 19 - fi 20 - 21 - if [ ! -d events/ftrace/print ]; then 22 - echo "event trace_marker is not supported" 23 - exit_unsupported 24 - fi 25 - 26 - if [ ! -d events/sched/sched_waking ]; then 27 - echo "event sched_waking is not supported" 28 - exit_unsupported 29 - fi 30 - 31 - if [ ! -f events/ftrace/print/trigger ]; then 32 - echo "event trigger is not supported" 33 - exit_unsupported 34 - fi 35 - 36 - if [ ! -f events/ftrace/print/hist ]; then 37 - echo "hist trigger is not supported" 38 - exit_unsupported 39 - fi 40 11 41 12 echo "Test histogram kernel event to trace_marker latency histogram trigger" 42 13
+1 -25
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: trace_marker trigger - test histogram with synthetic event 4 + # requires: set_event synthetic_events events/ftrace/print/trigger events/ftrace/print/hist 4 5 # flags: 5 6 6 7 fail() { #msg 7 8 echo $1 8 9 exit_fail 9 10 } 10 - 11 - if [ ! -f set_event ]; then 12 - echo "event tracing is not supported" 13 - exit_unsupported 14 - fi 15 - 16 - if [ ! -f synthetic_events ]; then 17 - echo "synthetic events not supported" 18 - exit_unsupported 19 - fi 20 - 21 - if [ ! -d events/ftrace/print ]; then 22 - echo "event trace_marker is not supported" 23 - exit_unsupported 24 - fi 25 - 26 - if [ ! -f events/ftrace/print/trigger ]; then 27 - echo "event trigger is not supported" 28 - exit_unsupported 29 - fi 30 - 31 - if [ ! -f events/ftrace/print/hist ]; then 32 - echo "hist trigger is not supported" 33 - exit_unsupported 34 - fi 35 11 36 12 echo "Test histogram trace_marker to trace_marker latency histogram trigger" 37 13
+1 -10
tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: event trigger - test traceon/off trigger 4 + # requires: set_event events/sched/sched_process_fork/trigger 4 5 5 6 fail() { #msg 6 7 echo $1 7 8 exit_fail 8 9 } 9 - 10 - if [ ! -f set_event -o ! -d events/sched ]; then 11 - echo "event tracing is not supported" 12 - exit_unsupported 13 - fi 14 - 15 - if [ ! -f events/sched/sched_process_fork/trigger ]; then 16 - echo "event trigger is not supported" 17 - exit_unsupported 18 - fi 19 10 20 11 echo "Test traceoff trigger" 21 12 echo 1 > tracing_on
+1
tools/testing/selftests/seccomp/seccomp_bpf.c
··· 1615 1615 # define ARCH_REGS s390_regs 1616 1616 # define SYSCALL_NUM gprs[2] 1617 1617 # define SYSCALL_RET gprs[2] 1618 + # define SYSCALL_NUM_RET_SHARE_REG 1618 1619 #elif defined(__mips__) 1619 1620 # define ARCH_REGS struct pt_regs 1620 1621 # define SYSCALL_NUM regs[2]