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

Merge tag 'v5.17-rc2' into usb-next

We need the USB fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+4638 -2084
+1
.mailmap
··· 70 70 Boris Brezillon <bbrezillon@kernel.org> <boris.brezillon@free-electrons.com> 71 71 Brian Avery <b.avery@hp.com> 72 72 Brian King <brking@us.ibm.com> 73 + Brian Silverman <bsilver16384@gmail.com> <brian.silverman@bluerivertech.com> 73 74 Changbin Du <changbin.du@intel.com> <changbin.du@gmail.com> 74 75 Changbin Du <changbin.du@intel.com> <changbin.du@intel.com> 75 76 Chao Yu <chao@kernel.org> <chao2.yu@samsung.com>
+2 -1
Documentation/accounting/psi.rst
··· 92 92 for the same psi metric can be specified. However for each trigger a separate 93 93 file descriptor is required to be able to poll it separately from others, 94 94 therefore for each trigger a separate open() syscall should be made even 95 - when opening the same psi interface file. 95 + when opening the same psi interface file. Write operations to a file descriptor 96 + with an already existing psi trigger will fail with EBUSY. 96 97 97 98 Monitors activate only when system enters stall state for the monitored 98 99 psi metric and deactivates upon exit from the stall state. While system is
+1
Documentation/admin-guide/gpio/index.rst
··· 10 10 gpio-aggregator 11 11 sysfs 12 12 gpio-mockup 13 + gpio-sim 13 14 14 15 .. only:: subproject and html 15 16
+2
Documentation/arm/marvell.rst
··· 266 266 ------------- 267 267 268 268 Flavors: 269 + - 88F6500 269 270 - 88F6510 270 271 - 88F6530P 271 272 - 88F6550 272 273 - 88F6560 274 + - 88F6601 273 275 274 276 Homepage: 275 277 https://web.archive.org/web/20181005145041/http://www.marvell.com/broadband/
+12
Documentation/arm64/silicon-errata.rst
··· 52 52 | Allwinner | A64/R18 | UNKNOWN1 | SUN50I_ERRATUM_UNKNOWN1 | 53 53 +----------------+-----------------+-----------------+-----------------------------+ 54 54 +----------------+-----------------+-----------------+-----------------------------+ 55 + | ARM | Cortex-A510 | #2064142 | ARM64_ERRATUM_2064142 | 56 + +----------------+-----------------+-----------------+-----------------------------+ 57 + | ARM | Cortex-A510 | #2038923 | ARM64_ERRATUM_2038923 | 58 + +----------------+-----------------+-----------------+-----------------------------+ 59 + | ARM | Cortex-A510 | #1902691 | ARM64_ERRATUM_1902691 | 60 + +----------------+-----------------+-----------------+-----------------------------+ 55 61 | ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 | 56 62 +----------------+-----------------+-----------------+-----------------------------+ 57 63 | ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 | ··· 98 92 +----------------+-----------------+-----------------+-----------------------------+ 99 93 | ARM | Cortex-A77 | #1508412 | ARM64_ERRATUM_1508412 | 100 94 +----------------+-----------------+-----------------+-----------------------------+ 95 + | ARM | Cortex-A510 | #2051678 | ARM64_ERRATUM_2051678 | 96 + +----------------+-----------------+-----------------+-----------------------------+ 101 97 | ARM | Cortex-A710 | #2119858 | ARM64_ERRATUM_2119858 | 102 98 +----------------+-----------------+-----------------+-----------------------------+ 103 99 | ARM | Cortex-A710 | #2054223 | ARM64_ERRATUM_2054223 | 104 100 +----------------+-----------------+-----------------+-----------------------------+ 105 101 | ARM | Cortex-A710 | #2224489 | ARM64_ERRATUM_2224489 | 102 + +----------------+-----------------+-----------------+-----------------------------+ 103 + | ARM | Cortex-X2 | #2119858 | ARM64_ERRATUM_2119858 | 104 + +----------------+-----------------+-----------------+-----------------------------+ 105 + | ARM | Cortex-X2 | #2224489 | ARM64_ERRATUM_2224489 | 106 106 +----------------+-----------------+-----------------+-----------------------------+ 107 107 | ARM | Neoverse-N1 | #1188873,1418040| ARM64_ERRATUM_1418040 | 108 108 +----------------+-----------------+-----------------+-----------------------------+
+1
Documentation/devicetree/bindings/interrupt-controller/renesas,irqc.yaml
··· 36 36 - renesas,intc-ex-r8a77980 # R-Car V3H 37 37 - renesas,intc-ex-r8a77990 # R-Car E3 38 38 - renesas,intc-ex-r8a77995 # R-Car D3 39 + - renesas,intc-ex-r8a779a0 # R-Car V3U 39 40 - const: renesas,irqc 40 41 41 42 '#interrupt-cells':
+6 -6
Documentation/devicetree/bindings/interrupt-controller/sifive,plic-1.0.0.yaml
··· 62 62 63 63 interrupts-extended: 64 64 minItems: 1 65 + maxItems: 15872 65 66 description: 66 67 Specifies which contexts are connected to the PLIC, with "-1" specifying 67 68 that a context is not present. Each node pointed to should be a ··· 91 90 #interrupt-cells = <1>; 92 91 compatible = "sifive,fu540-c000-plic", "sifive,plic-1.0.0"; 93 92 interrupt-controller; 94 - interrupts-extended = < 95 - &cpu0_intc 11 96 - &cpu1_intc 11 &cpu1_intc 9 97 - &cpu2_intc 11 &cpu2_intc 9 98 - &cpu3_intc 11 &cpu3_intc 9 99 - &cpu4_intc 11 &cpu4_intc 9>; 93 + interrupts-extended = <&cpu0_intc 11>, 94 + <&cpu1_intc 11>, <&cpu1_intc 9>, 95 + <&cpu2_intc 11>, <&cpu2_intc 9>, 96 + <&cpu3_intc 11>, <&cpu3_intc 9>, 97 + <&cpu4_intc 11>, <&cpu4_intc 9>; 100 98 reg = <0xc000000 0x4000000>; 101 99 riscv,ndev = <10>; 102 100 };
+1 -1
Documentation/devicetree/bindings/net/can/tcan4x5x.txt
··· 31 31 #address-cells = <1>; 32 32 #size-cells = <1>; 33 33 spi-max-frequency = <10000000>; 34 - bosch,mram-cfg = <0x0 0 0 32 0 0 1 1>; 34 + bosch,mram-cfg = <0x0 0 0 16 0 0 1 1>; 35 35 interrupt-parent = <&gpio1>; 36 36 interrupts = <14 IRQ_TYPE_LEVEL_LOW>; 37 37 device-state-gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>;
+1
Documentation/index.rst
··· 166 166 .. toctree:: 167 167 :maxdepth: 2 168 168 169 + tools/index 169 170 staging/index 170 171 watch_queue 171 172
+1 -1
Documentation/kernel-hacking/locking.rst
··· 295 295 296 296 - If you are in a process context (any syscall) and want to lock other 297 297 process out, use a mutex. You can take a mutex and sleep 298 - (``copy_from_user*(`` or ``kmalloc(x,GFP_KERNEL)``). 298 + (``copy_from_user()`` or ``kmalloc(x,GFP_KERNEL)``). 299 299 300 300 - Otherwise (== data can be touched in an interrupt), use 301 301 spin_lock_irqsave() and
+20
Documentation/tools/index.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ============ 4 + Kernel tools 5 + ============ 6 + 7 + This book covers user-space tools that are shipped with the kernel source; 8 + more additions are needed here: 9 + 10 + .. toctree:: 11 + :maxdepth: 1 12 + 13 + rtla/index 14 + 15 + .. only:: subproject and html 16 + 17 + Indices 18 + ======= 19 + 20 + * :ref:`genindex`
+26
Documentation/tools/rtla/index.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ================================ 4 + The realtime Linux analysis tool 5 + ================================ 6 + 7 + RTLA provides a set of tools for the analysis of the kernel's realtime 8 + behavior on specific hardware. 9 + 10 + .. toctree:: 11 + :maxdepth: 1 12 + 13 + rtla 14 + rtla-osnoise 15 + rtla-osnoise-hist 16 + rtla-osnoise-top 17 + rtla-timerlat 18 + rtla-timerlat-hist 19 + rtla-timerlat-top 20 + 21 + .. only:: subproject and html 22 + 23 + Indices 24 + ======= 25 + 26 + * :ref:`genindex`
+3 -1
Documentation/virt/kvm/api.rst
··· 3268 3268 3269 3269 :Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device, 3270 3270 KVM_CAP_VCPU_ATTRIBUTES for vcpu device 3271 + KVM_CAP_SYS_ATTRIBUTES for system (/dev/kvm) device (no set) 3271 3272 :Type: device ioctl, vm ioctl, vcpu ioctl 3272 3273 :Parameters: struct kvm_device_attr 3273 3274 :Returns: 0 on success, -1 on error ··· 3303 3302 ------------------------ 3304 3303 3305 3304 :Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device, 3306 - KVM_CAP_VCPU_ATTRIBUTES for vcpu device 3305 + KVM_CAP_VCPU_ATTRIBUTES for vcpu device 3306 + KVM_CAP_SYS_ATTRIBUTES for system (/dev/kvm) device 3307 3307 :Type: device ioctl, vm ioctl, vcpu ioctl 3308 3308 :Parameters: struct kvm_device_attr 3309 3309 :Returns: 0 on success, -1 on error
+1 -1
Documentation/vm/page_table_check.rst
··· 9 9 Introduction 10 10 ============ 11 11 12 - Page table check allows to hardern the kernel by ensuring that some types of 12 + Page table check allows to harden the kernel by ensuring that some types of 13 13 the memory corruptions are prevented. 14 14 15 15 Page table check performs extra verifications at the time when new pages become
+19 -13
MAINTAINERS
··· 190 190 L: linux-wireless@vger.kernel.org 191 191 S: Maintained 192 192 W: https://wireless.wiki.kernel.org/ 193 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 194 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 193 + Q: https://patchwork.kernel.org/project/linux-wireless/list/ 194 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git 195 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git 195 196 F: Documentation/driver-api/80211/cfg80211.rst 196 197 F: Documentation/networking/regulatory.rst 197 198 F: include/linux/ieee80211.h ··· 7209 7208 F: drivers/net/pcs/ 7210 7209 F: drivers/net/phy/ 7211 7210 F: include/dt-bindings/net/qca-ar803x.h 7211 + F: include/linux/linkmode.h 7212 7212 F: include/linux/*mdio*.h 7213 7213 F: include/linux/mdio/*.h 7214 + F: include/linux/mii.h 7214 7215 F: include/linux/of_net.h 7215 7216 F: include/linux/phy.h 7216 7217 F: include/linux/phy_fixed.h ··· 11369 11366 L: linux-wireless@vger.kernel.org 11370 11367 S: Maintained 11371 11368 W: https://wireless.wiki.kernel.org/ 11372 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 11373 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 11369 + Q: https://patchwork.kernel.org/project/linux-wireless/list/ 11370 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git 11371 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git 11374 11372 F: Documentation/networking/mac80211-injection.rst 11375 11373 F: Documentation/networking/mac80211_hwsim/mac80211_hwsim.rst 11376 11374 F: drivers/net/wireless/mac80211_hwsim.[ch] ··· 13378 13374 M: Kalle Valo <kvalo@kernel.org> 13379 13375 L: linux-wireless@vger.kernel.org 13380 13376 S: Maintained 13381 - Q: http://patchwork.kernel.org/project/linux-wireless/list/ 13382 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers.git 13383 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git 13377 + W: https://wireless.wiki.kernel.org/ 13378 + Q: https://patchwork.kernel.org/project/linux-wireless/list/ 13379 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git 13380 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git 13384 13381 F: Documentation/devicetree/bindings/net/wireless/ 13385 13382 F: drivers/net/wireless/ 13386 13383 ··· 13454 13449 S: Maintained 13455 13450 T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git 13456 13451 F: arch/x86/net/* 13452 + F: include/linux/ip.h 13453 + F: include/linux/ipv6* 13454 + F: include/net/fib* 13457 13455 F: include/net/ip* 13456 + F: include/net/route.h 13458 13457 F: net/ipv4/ 13459 13458 F: net/ipv6/ 13460 13459 ··· 13518 13509 F: include/net/tls.h 13519 13510 F: include/uapi/linux/tls.h 13520 13511 F: net/tls/* 13521 - 13522 - NETWORKING [WIRELESS] 13523 - L: linux-wireless@vger.kernel.org 13524 - Q: http://patchwork.kernel.org/project/linux-wireless/list/ 13525 13512 13526 13513 NETXEN (1/10) GbE SUPPORT 13527 13514 M: Manish Chopra <manishc@marvell.com> ··· 16537 16532 L: linux-wireless@vger.kernel.org 16538 16533 S: Maintained 16539 16534 W: https://wireless.wiki.kernel.org/ 16540 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 16541 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 16535 + Q: https://patchwork.kernel.org/project/linux-wireless/list/ 16536 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git 16537 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git 16542 16538 F: Documentation/ABI/stable/sysfs-class-rfkill 16543 16539 F: Documentation/driver-api/rfkill.rst 16544 16540 F: include/linux/rfkill.h
+1 -1
Makefile
··· 2 2 VERSION = 5 3 3 PATCHLEVEL = 17 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc1 5 + EXTRAVERSION = -rc2 6 6 NAME = Gobble Gobble 7 7 8 8 # *DOCUMENTATION*
+1
arch/arm/Kconfig
··· 83 83 select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32 84 84 select HAVE_CONTEXT_TRACKING 85 85 select HAVE_C_RECORDMCOUNT 86 + select HAVE_BUILDTIME_MCOUNT_SORT 86 87 select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL 87 88 select HAVE_DMA_CONTIGUOUS if MMU 88 89 select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
+2
arch/arm/include/asm/assembler.h
··· 288 288 */ 289 289 #define ALT_UP(instr...) \ 290 290 .pushsection ".alt.smp.init", "a" ;\ 291 + .align 2 ;\ 291 292 .long 9998b - . ;\ 292 293 9997: instr ;\ 293 294 .if . - 9997b == 2 ;\ ··· 300 299 .popsection 301 300 #define ALT_UP_B(label) \ 302 301 .pushsection ".alt.smp.init", "a" ;\ 302 + .align 2 ;\ 303 303 .long 9998b - . ;\ 304 304 W(b) . + (label - 9998b) ;\ 305 305 .popsection
+1
arch/arm/include/asm/processor.h
··· 96 96 #define __ALT_SMP_ASM(smp, up) \ 97 97 "9998: " smp "\n" \ 98 98 " .pushsection \".alt.smp.init\", \"a\"\n" \ 99 + " .align 2\n" \ 99 100 " .long 9998b - .\n" \ 100 101 " " up "\n" \ 101 102 " .popsection\n"
+8 -2
arch/arm/include/asm/uaccess.h
··· 11 11 #include <linux/string.h> 12 12 #include <asm/memory.h> 13 13 #include <asm/domain.h> 14 + #include <asm/unaligned.h> 14 15 #include <asm/unified.h> 15 16 #include <asm/compiler.h> 16 17 ··· 498 497 } \ 499 498 default: __err = __get_user_bad(); break; \ 500 499 } \ 501 - *(type *)(dst) = __val; \ 500 + if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)) \ 501 + put_unaligned(__val, (type *)(dst)); \ 502 + else \ 503 + *(type *)(dst) = __val; /* aligned by caller */ \ 502 504 if (__err) \ 503 505 goto err_label; \ 504 506 } while (0) ··· 511 507 const type *__pk_ptr = (dst); \ 512 508 unsigned long __dst = (unsigned long)__pk_ptr; \ 513 509 int __err = 0; \ 514 - type __val = *(type *)src; \ 510 + type __val = IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) \ 511 + ? get_unaligned((type *)(src)) \ 512 + : *(type *)(src); /* aligned by caller */ \ 515 513 switch (sizeof(type)) { \ 516 514 case 1: __put_user_asm_byte(__val, __dst, __err, ""); break; \ 517 515 case 2: __put_user_asm_half(__val, __dst, __err, ""); break; \
+3
arch/arm/probes/kprobes/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 + KASAN_SANITIZE_actions-common.o := n 3 + KASAN_SANITIZE_actions-arm.o := n 4 + KASAN_SANITIZE_actions-thumb.o := n 2 5 obj-$(CONFIG_KPROBES) += core.o actions-common.o checkers-common.o 3 6 obj-$(CONFIG_ARM_KPROBES_TEST) += test-kprobes.o 4 7 test-kprobes-objs := test-core.o
+75 -6
arch/arm64/Kconfig
··· 670 670 config ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE 671 671 bool 672 672 673 + config ARM64_ERRATUM_2051678 674 + bool "Cortex-A510: 2051678: disable Hardware Update of the page table dirty bit" 675 + help 676 + This options adds the workaround for ARM Cortex-A510 erratum ARM64_ERRATUM_2051678. 677 + Affected Coretex-A510 might not respect the ordering rules for 678 + hardware update of the page table's dirty bit. The workaround 679 + is to not enable the feature on affected CPUs. 680 + 681 + If unsure, say Y. 682 + 673 683 config ARM64_ERRATUM_2119858 674 - bool "Cortex-A710: 2119858: workaround TRBE overwriting trace data in FILL mode" 684 + bool "Cortex-A710/X2: 2119858: workaround TRBE overwriting trace data in FILL mode" 675 685 default y 676 686 depends on CORESIGHT_TRBE 677 687 select ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE 678 688 help 679 - This option adds the workaround for ARM Cortex-A710 erratum 2119858. 689 + This option adds the workaround for ARM Cortex-A710/X2 erratum 2119858. 680 690 681 - Affected Cortex-A710 cores could overwrite up to 3 cache lines of trace 691 + Affected Cortex-A710/X2 cores could overwrite up to 3 cache lines of trace 682 692 data at the base of the buffer (pointed to by TRBASER_EL1) in FILL mode in 683 693 the event of a WRAP event. 684 694 ··· 771 761 If unsure, say Y. 772 762 773 763 config ARM64_ERRATUM_2224489 774 - bool "Cortex-A710: 2224489: workaround TRBE writing to address out-of-range" 764 + bool "Cortex-A710/X2: 2224489: workaround TRBE writing to address out-of-range" 775 765 depends on CORESIGHT_TRBE 776 766 default y 777 767 select ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE 778 768 help 779 - This option adds the workaround for ARM Cortex-A710 erratum 2224489. 769 + This option adds the workaround for ARM Cortex-A710/X2 erratum 2224489. 780 770 781 - Affected Cortex-A710 cores might write to an out-of-range address, not reserved 771 + Affected Cortex-A710/X2 cores might write to an out-of-range address, not reserved 782 772 for TRBE. Under some conditions, the TRBE might generate a write to the next 783 773 virtually addressed page following the last page of the TRBE address space 784 774 (i.e., the TRBLIMITR_EL1.LIMIT), instead of wrapping around to the base. 785 775 786 776 Work around this in the driver by always making sure that there is a 787 777 page beyond the TRBLIMITR_EL1.LIMIT, within the space allowed for the TRBE. 778 + 779 + If unsure, say Y. 780 + 781 + config ARM64_ERRATUM_2064142 782 + bool "Cortex-A510: 2064142: workaround TRBE register writes while disabled" 783 + depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in 784 + default y 785 + help 786 + This option adds the workaround for ARM Cortex-A510 erratum 2064142. 787 + 788 + Affected Cortex-A510 core might fail to write into system registers after the 789 + TRBE has been disabled. Under some conditions after the TRBE has been disabled 790 + writes into TRBE registers TRBLIMITR_EL1, TRBPTR_EL1, TRBBASER_EL1, TRBSR_EL1, 791 + and TRBTRG_EL1 will be ignored and will not be effected. 792 + 793 + Work around this in the driver by executing TSB CSYNC and DSB after collection 794 + is stopped and before performing a system register write to one of the affected 795 + registers. 796 + 797 + If unsure, say Y. 798 + 799 + config ARM64_ERRATUM_2038923 800 + bool "Cortex-A510: 2038923: workaround TRBE corruption with enable" 801 + depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in 802 + default y 803 + help 804 + This option adds the workaround for ARM Cortex-A510 erratum 2038923. 805 + 806 + Affected Cortex-A510 core might cause an inconsistent view on whether trace is 807 + prohibited within the CPU. As a result, the trace buffer or trace buffer state 808 + might be corrupted. This happens after TRBE buffer has been enabled by setting 809 + TRBLIMITR_EL1.E, followed by just a single context synchronization event before 810 + execution changes from a context, in which trace is prohibited to one where it 811 + isn't, or vice versa. In these mentioned conditions, the view of whether trace 812 + is prohibited is inconsistent between parts of the CPU, and the trace buffer or 813 + the trace buffer state might be corrupted. 814 + 815 + Work around this in the driver by preventing an inconsistent view of whether the 816 + trace is prohibited or not based on TRBLIMITR_EL1.E by immediately following a 817 + change to TRBLIMITR_EL1.E with at least one ISB instruction before an ERET, or 818 + two ISB instructions if no ERET is to take place. 819 + 820 + If unsure, say Y. 821 + 822 + config ARM64_ERRATUM_1902691 823 + bool "Cortex-A510: 1902691: workaround TRBE trace corruption" 824 + depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in 825 + default y 826 + help 827 + This option adds the workaround for ARM Cortex-A510 erratum 1902691. 828 + 829 + Affected Cortex-A510 core might cause trace data corruption, when being written 830 + into the memory. Effectively TRBE is broken and hence cannot be used to capture 831 + trace data. 832 + 833 + Work around this problem in the driver by just preventing TRBE initialization on 834 + affected cpus. The firmware must have disabled the access to TRBE for the kernel 835 + on such implementations. This will cover the kernel for any firmware that doesn't 836 + do this already. 788 837 789 838 If unsure, say Y. 790 839
+4
arch/arm64/include/asm/cputype.h
··· 73 73 #define ARM_CPU_PART_CORTEX_A76 0xD0B 74 74 #define ARM_CPU_PART_NEOVERSE_N1 0xD0C 75 75 #define ARM_CPU_PART_CORTEX_A77 0xD0D 76 + #define ARM_CPU_PART_CORTEX_A510 0xD46 76 77 #define ARM_CPU_PART_CORTEX_A710 0xD47 78 + #define ARM_CPU_PART_CORTEX_X2 0xD48 77 79 #define ARM_CPU_PART_NEOVERSE_N2 0xD49 78 80 79 81 #define APM_CPU_PART_POTENZA 0x000 ··· 117 115 #define MIDR_CORTEX_A76 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A76) 118 116 #define MIDR_NEOVERSE_N1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N1) 119 117 #define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77) 118 + #define MIDR_CORTEX_A510 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A510) 120 119 #define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710) 120 + #define MIDR_CORTEX_X2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X2) 121 121 #define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2) 122 122 #define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX) 123 123 #define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX)
+29
arch/arm64/kernel/cpu_errata.c
··· 347 347 #endif 348 348 #ifdef CONFIG_ARM64_ERRATUM_2119858 349 349 MIDR_ALL_VERSIONS(MIDR_CORTEX_A710), 350 + MIDR_RANGE(MIDR_CORTEX_X2, 0, 0, 2, 0), 350 351 #endif 351 352 {}, 352 353 }; ··· 372 371 #endif 373 372 #ifdef CONFIG_ARM64_ERRATUM_2224489 374 373 MIDR_ALL_VERSIONS(MIDR_CORTEX_A710), 374 + MIDR_RANGE(MIDR_CORTEX_X2, 0, 0, 2, 0), 375 375 #endif 376 376 {}, 377 377 }; ··· 598 596 .capability = ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE, 599 597 .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, 600 598 CAP_MIDR_RANGE_LIST(trbe_write_out_of_range_cpus), 599 + }, 600 + #endif 601 + #ifdef CONFIG_ARM64_ERRATUM_2064142 602 + { 603 + .desc = "ARM erratum 2064142", 604 + .capability = ARM64_WORKAROUND_2064142, 605 + 606 + /* Cortex-A510 r0p0 - r0p2 */ 607 + ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) 608 + }, 609 + #endif 610 + #ifdef CONFIG_ARM64_ERRATUM_2038923 611 + { 612 + .desc = "ARM erratum 2038923", 613 + .capability = ARM64_WORKAROUND_2038923, 614 + 615 + /* Cortex-A510 r0p0 - r0p2 */ 616 + ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) 617 + }, 618 + #endif 619 + #ifdef CONFIG_ARM64_ERRATUM_1902691 620 + { 621 + .desc = "ARM erratum 1902691", 622 + .capability = ARM64_WORKAROUND_1902691, 623 + 624 + /* Cortex-A510 r0p0 - r0p1 */ 625 + ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 1) 601 626 }, 602 627 #endif 603 628 {
+3
arch/arm64/kernel/cpufeature.c
··· 1646 1646 /* Kryo4xx Silver (rdpe => r1p0) */ 1647 1647 MIDR_REV(MIDR_QCOM_KRYO_4XX_SILVER, 0xd, 0xe), 1648 1648 #endif 1649 + #ifdef CONFIG_ARM64_ERRATUM_2051678 1650 + MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2), 1651 + #endif 1649 1652 {}, 1650 1653 }; 1651 1654
+3 -2
arch/arm64/kernel/stacktrace.c
··· 33 33 */ 34 34 35 35 36 - static void start_backtrace(struct stackframe *frame, unsigned long fp, 37 - unsigned long pc) 36 + static notrace void start_backtrace(struct stackframe *frame, unsigned long fp, 37 + unsigned long pc) 38 38 { 39 39 frame->fp = fp; 40 40 frame->pc = pc; ··· 55 55 frame->prev_fp = 0; 56 56 frame->prev_type = STACK_TYPE_UNKNOWN; 57 57 } 58 + NOKPROBE_SYMBOL(start_backtrace); 58 59 59 60 /* 60 61 * Unwind from one frame record (A) to the next frame record (B).
+4 -1
arch/arm64/kernel/vdso/Makefile
··· 29 29 ccflags-y := -fno-common -fno-builtin -fno-stack-protector -ffixed-x18 30 30 ccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO 31 31 32 + # -Wmissing-prototypes and -Wmissing-declarations are removed from 33 + # the CFLAGS of vgettimeofday.c to make possible to build the 34 + # kernel with CONFIG_WERROR enabled. 32 35 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) $(GCC_PLUGINS_CFLAGS) \ 33 - $(CC_FLAGS_LTO) 36 + $(CC_FLAGS_LTO) -Wmissing-prototypes -Wmissing-declarations 34 37 KASAN_SANITIZE := n 35 38 KCSAN_SANITIZE := n 36 39 UBSAN_SANITIZE := n
+4 -1
arch/arm64/kvm/hyp/exception.c
··· 38 38 39 39 static void __vcpu_write_spsr(struct kvm_vcpu *vcpu, u64 val) 40 40 { 41 - write_sysreg_el1(val, SYS_SPSR); 41 + if (has_vhe()) 42 + write_sysreg_el1(val, SYS_SPSR); 43 + else 44 + __vcpu_sys_reg(vcpu, SPSR_EL1) = val; 42 45 } 43 46 44 47 static void __vcpu_write_spsr_abt(struct kvm_vcpu *vcpu, u64 val)
+6 -12
arch/arm64/kvm/hyp/pgtable.c
··· 983 983 */ 984 984 stage2_put_pte(ptep, mmu, addr, level, mm_ops); 985 985 986 - if (need_flush) { 987 - kvm_pte_t *pte_follow = kvm_pte_follow(pte, mm_ops); 988 - 989 - dcache_clean_inval_poc((unsigned long)pte_follow, 990 - (unsigned long)pte_follow + 991 - kvm_granule_size(level)); 992 - } 986 + if (need_flush && mm_ops->dcache_clean_inval_poc) 987 + mm_ops->dcache_clean_inval_poc(kvm_pte_follow(pte, mm_ops), 988 + kvm_granule_size(level)); 993 989 994 990 if (childp) 995 991 mm_ops->put_page(childp); ··· 1147 1151 struct kvm_pgtable *pgt = arg; 1148 1152 struct kvm_pgtable_mm_ops *mm_ops = pgt->mm_ops; 1149 1153 kvm_pte_t pte = *ptep; 1150 - kvm_pte_t *pte_follow; 1151 1154 1152 1155 if (!kvm_pte_valid(pte) || !stage2_pte_cacheable(pgt, pte)) 1153 1156 return 0; 1154 1157 1155 - pte_follow = kvm_pte_follow(pte, mm_ops); 1156 - dcache_clean_inval_poc((unsigned long)pte_follow, 1157 - (unsigned long)pte_follow + 1158 - kvm_granule_size(level)); 1158 + if (mm_ops->dcache_clean_inval_poc) 1159 + mm_ops->dcache_clean_inval_poc(kvm_pte_follow(pte, mm_ops), 1160 + kvm_granule_size(level)); 1159 1161 return 0; 1160 1162 } 1161 1163
+3
arch/arm64/kvm/hyp/vgic-v3-sr.c
··· 983 983 val = ((vtr >> 29) & 7) << ICC_CTLR_EL1_PRI_BITS_SHIFT; 984 984 /* IDbits */ 985 985 val |= ((vtr >> 23) & 7) << ICC_CTLR_EL1_ID_BITS_SHIFT; 986 + /* SEIS */ 987 + if (kvm_vgic_global_state.ich_vtr_el2 & ICH_VTR_SEIS_MASK) 988 + val |= BIT(ICC_CTLR_EL1_SEIS_SHIFT); 986 989 /* A3V */ 987 990 val |= ((vtr >> 21) & 1) << ICC_CTLR_EL1_A3V_SHIFT; 988 991 /* EOImode */
+15 -2
arch/arm64/kvm/vgic/vgic-v3.c
··· 609 609 } 610 610 early_param("kvm-arm.vgic_v4_enable", early_gicv4_enable); 611 611 612 + static const struct midr_range broken_seis[] = { 613 + MIDR_ALL_VERSIONS(MIDR_APPLE_M1_ICESTORM), 614 + MIDR_ALL_VERSIONS(MIDR_APPLE_M1_FIRESTORM), 615 + {}, 616 + }; 617 + 618 + static bool vgic_v3_broken_seis(void) 619 + { 620 + return ((kvm_vgic_global_state.ich_vtr_el2 & ICH_VTR_SEIS_MASK) && 621 + is_midr_in_range_list(read_cpuid_id(), broken_seis)); 622 + } 623 + 612 624 /** 613 625 * vgic_v3_probe - probe for a VGICv3 compatible interrupt controller 614 626 * @info: pointer to the GIC description ··· 688 676 group1_trap = true; 689 677 } 690 678 691 - if (kvm_vgic_global_state.ich_vtr_el2 & ICH_VTR_SEIS_MASK) { 692 - kvm_info("GICv3 with locally generated SEI\n"); 679 + if (vgic_v3_broken_seis()) { 680 + kvm_info("GICv3 with broken locally generated SEI\n"); 693 681 682 + kvm_vgic_global_state.ich_vtr_el2 &= ~ICH_VTR_SEIS_MASK; 694 683 group0_trap = true; 695 684 group1_trap = true; 696 685 if (ich_vtr_el2 & ICH_VTR_TDS_MASK)
+2 -2
arch/arm64/mm/extable.c
··· 40 40 ex_handler_load_unaligned_zeropad(const struct exception_table_entry *ex, 41 41 struct pt_regs *regs) 42 42 { 43 - int reg_data = FIELD_GET(EX_DATA_REG_DATA, ex->type); 44 - int reg_addr = FIELD_GET(EX_DATA_REG_ADDR, ex->type); 43 + int reg_data = FIELD_GET(EX_DATA_REG_DATA, ex->data); 44 + int reg_addr = FIELD_GET(EX_DATA_REG_ADDR, ex->data); 45 45 unsigned long data, addr, offset; 46 46 47 47 addr = pt_regs_read_reg(regs, reg_addr);
+3
arch/arm64/tools/cpucaps
··· 55 55 WORKAROUND_1463225 56 56 WORKAROUND_1508412 57 57 WORKAROUND_1542419 58 + WORKAROUND_2064142 59 + WORKAROUND_2038923 60 + WORKAROUND_1902691 58 61 WORKAROUND_TRBE_OVERWRITE_FILL_MODE 59 62 WORKAROUND_TSB_FLUSH_FAILURE 60 63 WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
+1 -1
arch/ia64/Kconfig
··· 318 318 depends on PROC_KCORE 319 319 320 320 config IA64_MCA_RECOVERY 321 - tristate "MCA recovery from errors other than TLB." 321 + bool "MCA recovery from errors other than TLB." 322 322 323 323 config IA64_PALINFO 324 324 tristate "/proc/pal support"
+2 -2
arch/ia64/pci/fixup.c
··· 76 76 } 77 77 } 78 78 } 79 - DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, 80 - PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video); 79 + DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_ANY_ID, PCI_ANY_ID, 80 + PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video);
+2 -2
arch/mips/include/asm/asm.h
··· 285 285 286 286 #define PTR_SCALESHIFT 2 287 287 288 - #define PTR .word 288 + #define PTR_WD .word 289 289 #define PTRSIZE 4 290 290 #define PTRLOG 2 291 291 #endif ··· 310 310 311 311 #define PTR_SCALESHIFT 3 312 312 313 - #define PTR .dword 313 + #define PTR_WD .dword 314 314 #define PTRSIZE 8 315 315 #define PTRLOG 3 316 316 #endif
+2 -2
arch/mips/include/asm/ftrace.h
··· 32 32 ".previous\n" \ 33 33 \ 34 34 ".section\t__ex_table,\"a\"\n\t" \ 35 - STR(PTR) "\t1b, 3b\n\t" \ 35 + STR(PTR_WD) "\t1b, 3b\n\t" \ 36 36 ".previous\n" \ 37 37 \ 38 38 : [tmp_dst] "=&r" (dst), [tmp_err] "=r" (error)\ ··· 54 54 ".previous\n" \ 55 55 \ 56 56 ".section\t__ex_table,\"a\"\n\t"\ 57 - STR(PTR) "\t1b, 3b\n\t" \ 57 + STR(PTR_WD) "\t1b, 3b\n\t" \ 58 58 ".previous\n" \ 59 59 \ 60 60 : [tmp_err] "=r" (error) \
+2 -2
arch/mips/include/asm/r4kcache.h
··· 119 119 " j 2b \n" \ 120 120 " .previous \n" \ 121 121 " .section __ex_table,\"a\" \n" \ 122 - " "STR(PTR)" 1b, 3b \n" \ 122 + " "STR(PTR_WD)" 1b, 3b \n" \ 123 123 " .previous" \ 124 124 : "+r" (__err) \ 125 125 : "i" (op), "r" (addr), "i" (-EFAULT)); \ ··· 142 142 " j 2b \n" \ 143 143 " .previous \n" \ 144 144 " .section __ex_table,\"a\" \n" \ 145 - " "STR(PTR)" 1b, 3b \n" \ 145 + " "STR(PTR_WD)" 1b, 3b \n" \ 146 146 " .previous" \ 147 147 : "+r" (__err) \ 148 148 : "i" (op), "r" (addr), "i" (-EFAULT)); \
+88 -88
arch/mips/include/asm/unaligned-emul.h
··· 20 20 "j\t3b\n\t" \ 21 21 ".previous\n\t" \ 22 22 ".section\t__ex_table,\"a\"\n\t" \ 23 - STR(PTR)"\t1b, 4b\n\t" \ 24 - STR(PTR)"\t2b, 4b\n\t" \ 23 + STR(PTR_WD)"\t1b, 4b\n\t" \ 24 + STR(PTR_WD)"\t2b, 4b\n\t" \ 25 25 ".previous" \ 26 26 : "=&r" (value), "=r" (res) \ 27 27 : "r" (addr), "i" (-EFAULT)); \ ··· 41 41 "j\t3b\n\t" \ 42 42 ".previous\n\t" \ 43 43 ".section\t__ex_table,\"a\"\n\t" \ 44 - STR(PTR)"\t1b, 4b\n\t" \ 45 - STR(PTR)"\t2b, 4b\n\t" \ 44 + STR(PTR_WD)"\t1b, 4b\n\t" \ 45 + STR(PTR_WD)"\t2b, 4b\n\t" \ 46 46 ".previous" \ 47 47 : "=&r" (value), "=r" (res) \ 48 48 : "r" (addr), "i" (-EFAULT)); \ ··· 74 74 "j\t10b\n\t" \ 75 75 ".previous\n\t" \ 76 76 ".section\t__ex_table,\"a\"\n\t" \ 77 - STR(PTR)"\t1b, 11b\n\t" \ 78 - STR(PTR)"\t2b, 11b\n\t" \ 79 - STR(PTR)"\t3b, 11b\n\t" \ 80 - STR(PTR)"\t4b, 11b\n\t" \ 77 + STR(PTR_WD)"\t1b, 11b\n\t" \ 78 + STR(PTR_WD)"\t2b, 11b\n\t" \ 79 + STR(PTR_WD)"\t3b, 11b\n\t" \ 80 + STR(PTR_WD)"\t4b, 11b\n\t" \ 81 81 ".previous" \ 82 82 : "=&r" (value), "=r" (res) \ 83 83 : "r" (addr), "i" (-EFAULT)); \ ··· 102 102 "j\t3b\n\t" \ 103 103 ".previous\n\t" \ 104 104 ".section\t__ex_table,\"a\"\n\t" \ 105 - STR(PTR)"\t1b, 4b\n\t" \ 106 - STR(PTR)"\t2b, 4b\n\t" \ 105 + STR(PTR_WD)"\t1b, 4b\n\t" \ 106 + STR(PTR_WD)"\t2b, 4b\n\t" \ 107 107 ".previous" \ 108 108 : "=&r" (value), "=r" (res) \ 109 109 : "r" (addr), "i" (-EFAULT)); \ ··· 125 125 "j\t3b\n\t" \ 126 126 ".previous\n\t" \ 127 127 ".section\t__ex_table,\"a\"\n\t" \ 128 - STR(PTR)"\t1b, 4b\n\t" \ 129 - STR(PTR)"\t2b, 4b\n\t" \ 128 + STR(PTR_WD)"\t1b, 4b\n\t" \ 129 + STR(PTR_WD)"\t2b, 4b\n\t" \ 130 130 ".previous" \ 131 131 : "=&r" (value), "=r" (res) \ 132 132 : "r" (addr), "i" (-EFAULT)); \ ··· 145 145 "j\t3b\n\t" \ 146 146 ".previous\n\t" \ 147 147 ".section\t__ex_table,\"a\"\n\t" \ 148 - STR(PTR)"\t1b, 4b\n\t" \ 149 - STR(PTR)"\t2b, 4b\n\t" \ 148 + STR(PTR_WD)"\t1b, 4b\n\t" \ 149 + STR(PTR_WD)"\t2b, 4b\n\t" \ 150 150 ".previous" \ 151 151 : "=&r" (value), "=r" (res) \ 152 152 : "r" (addr), "i" (-EFAULT)); \ ··· 178 178 "j\t10b\n\t" \ 179 179 ".previous\n\t" \ 180 180 ".section\t__ex_table,\"a\"\n\t" \ 181 - STR(PTR)"\t1b, 11b\n\t" \ 182 - STR(PTR)"\t2b, 11b\n\t" \ 183 - STR(PTR)"\t3b, 11b\n\t" \ 184 - STR(PTR)"\t4b, 11b\n\t" \ 181 + STR(PTR_WD)"\t1b, 11b\n\t" \ 182 + STR(PTR_WD)"\t2b, 11b\n\t" \ 183 + STR(PTR_WD)"\t3b, 11b\n\t" \ 184 + STR(PTR_WD)"\t4b, 11b\n\t" \ 185 185 ".previous" \ 186 186 : "=&r" (value), "=r" (res) \ 187 187 : "r" (addr), "i" (-EFAULT)); \ ··· 223 223 "j\t10b\n\t" \ 224 224 ".previous\n\t" \ 225 225 ".section\t__ex_table,\"a\"\n\t" \ 226 - STR(PTR)"\t1b, 11b\n\t" \ 227 - STR(PTR)"\t2b, 11b\n\t" \ 228 - STR(PTR)"\t3b, 11b\n\t" \ 229 - STR(PTR)"\t4b, 11b\n\t" \ 230 - STR(PTR)"\t5b, 11b\n\t" \ 231 - STR(PTR)"\t6b, 11b\n\t" \ 232 - STR(PTR)"\t7b, 11b\n\t" \ 233 - STR(PTR)"\t8b, 11b\n\t" \ 226 + STR(PTR_WD)"\t1b, 11b\n\t" \ 227 + STR(PTR_WD)"\t2b, 11b\n\t" \ 228 + STR(PTR_WD)"\t3b, 11b\n\t" \ 229 + STR(PTR_WD)"\t4b, 11b\n\t" \ 230 + STR(PTR_WD)"\t5b, 11b\n\t" \ 231 + STR(PTR_WD)"\t6b, 11b\n\t" \ 232 + STR(PTR_WD)"\t7b, 11b\n\t" \ 233 + STR(PTR_WD)"\t8b, 11b\n\t" \ 234 234 ".previous" \ 235 235 : "=&r" (value), "=r" (res) \ 236 236 : "r" (addr), "i" (-EFAULT)); \ ··· 255 255 "j\t3b\n\t" \ 256 256 ".previous\n\t" \ 257 257 ".section\t__ex_table,\"a\"\n\t" \ 258 - STR(PTR)"\t1b, 4b\n\t" \ 259 - STR(PTR)"\t2b, 4b\n\t" \ 258 + STR(PTR_WD)"\t1b, 4b\n\t" \ 259 + STR(PTR_WD)"\t2b, 4b\n\t" \ 260 260 ".previous" \ 261 261 : "=r" (res) \ 262 262 : "r" (value), "r" (addr), "i" (-EFAULT));\ ··· 276 276 "j\t3b\n\t" \ 277 277 ".previous\n\t" \ 278 278 ".section\t__ex_table,\"a\"\n\t" \ 279 - STR(PTR)"\t1b, 4b\n\t" \ 280 - STR(PTR)"\t2b, 4b\n\t" \ 279 + STR(PTR_WD)"\t1b, 4b\n\t" \ 280 + STR(PTR_WD)"\t2b, 4b\n\t" \ 281 281 ".previous" \ 282 282 : "=r" (res) \ 283 283 : "r" (value), "r" (addr), "i" (-EFAULT)); \ ··· 296 296 "j\t3b\n\t" \ 297 297 ".previous\n\t" \ 298 298 ".section\t__ex_table,\"a\"\n\t" \ 299 - STR(PTR)"\t1b, 4b\n\t" \ 300 - STR(PTR)"\t2b, 4b\n\t" \ 299 + STR(PTR_WD)"\t1b, 4b\n\t" \ 300 + STR(PTR_WD)"\t2b, 4b\n\t" \ 301 301 ".previous" \ 302 302 : "=r" (res) \ 303 303 : "r" (value), "r" (addr), "i" (-EFAULT)); \ ··· 325 325 "j\t10b\n\t" \ 326 326 ".previous\n\t" \ 327 327 ".section\t__ex_table,\"a\"\n\t" \ 328 - STR(PTR)"\t1b, 11b\n\t" \ 329 - STR(PTR)"\t2b, 11b\n\t" \ 330 - STR(PTR)"\t3b, 11b\n\t" \ 331 - STR(PTR)"\t4b, 11b\n\t" \ 328 + STR(PTR_WD)"\t1b, 11b\n\t" \ 329 + STR(PTR_WD)"\t2b, 11b\n\t" \ 330 + STR(PTR_WD)"\t3b, 11b\n\t" \ 331 + STR(PTR_WD)"\t4b, 11b\n\t" \ 332 332 ".previous" \ 333 333 : "=&r" (res) \ 334 334 : "r" (value), "r" (addr), "i" (-EFAULT) \ ··· 365 365 "j\t10b\n\t" \ 366 366 ".previous\n\t" \ 367 367 ".section\t__ex_table,\"a\"\n\t" \ 368 - STR(PTR)"\t1b, 11b\n\t" \ 369 - STR(PTR)"\t2b, 11b\n\t" \ 370 - STR(PTR)"\t3b, 11b\n\t" \ 371 - STR(PTR)"\t4b, 11b\n\t" \ 372 - STR(PTR)"\t5b, 11b\n\t" \ 373 - STR(PTR)"\t6b, 11b\n\t" \ 374 - STR(PTR)"\t7b, 11b\n\t" \ 375 - STR(PTR)"\t8b, 11b\n\t" \ 368 + STR(PTR_WD)"\t1b, 11b\n\t" \ 369 + STR(PTR_WD)"\t2b, 11b\n\t" \ 370 + STR(PTR_WD)"\t3b, 11b\n\t" \ 371 + STR(PTR_WD)"\t4b, 11b\n\t" \ 372 + STR(PTR_WD)"\t5b, 11b\n\t" \ 373 + STR(PTR_WD)"\t6b, 11b\n\t" \ 374 + STR(PTR_WD)"\t7b, 11b\n\t" \ 375 + STR(PTR_WD)"\t8b, 11b\n\t" \ 376 376 ".previous" \ 377 377 : "=&r" (res) \ 378 378 : "r" (value), "r" (addr), "i" (-EFAULT) \ ··· 398 398 "j\t3b\n\t" \ 399 399 ".previous\n\t" \ 400 400 ".section\t__ex_table,\"a\"\n\t" \ 401 - STR(PTR)"\t1b, 4b\n\t" \ 402 - STR(PTR)"\t2b, 4b\n\t" \ 401 + STR(PTR_WD)"\t1b, 4b\n\t" \ 402 + STR(PTR_WD)"\t2b, 4b\n\t" \ 403 403 ".previous" \ 404 404 : "=&r" (value), "=r" (res) \ 405 405 : "r" (addr), "i" (-EFAULT)); \ ··· 419 419 "j\t3b\n\t" \ 420 420 ".previous\n\t" \ 421 421 ".section\t__ex_table,\"a\"\n\t" \ 422 - STR(PTR)"\t1b, 4b\n\t" \ 423 - STR(PTR)"\t2b, 4b\n\t" \ 422 + STR(PTR_WD)"\t1b, 4b\n\t" \ 423 + STR(PTR_WD)"\t2b, 4b\n\t" \ 424 424 ".previous" \ 425 425 : "=&r" (value), "=r" (res) \ 426 426 : "r" (addr), "i" (-EFAULT)); \ ··· 452 452 "j\t10b\n\t" \ 453 453 ".previous\n\t" \ 454 454 ".section\t__ex_table,\"a\"\n\t" \ 455 - STR(PTR)"\t1b, 11b\n\t" \ 456 - STR(PTR)"\t2b, 11b\n\t" \ 457 - STR(PTR)"\t3b, 11b\n\t" \ 458 - STR(PTR)"\t4b, 11b\n\t" \ 455 + STR(PTR_WD)"\t1b, 11b\n\t" \ 456 + STR(PTR_WD)"\t2b, 11b\n\t" \ 457 + STR(PTR_WD)"\t3b, 11b\n\t" \ 458 + STR(PTR_WD)"\t4b, 11b\n\t" \ 459 459 ".previous" \ 460 460 : "=&r" (value), "=r" (res) \ 461 461 : "r" (addr), "i" (-EFAULT)); \ ··· 481 481 "j\t3b\n\t" \ 482 482 ".previous\n\t" \ 483 483 ".section\t__ex_table,\"a\"\n\t" \ 484 - STR(PTR)"\t1b, 4b\n\t" \ 485 - STR(PTR)"\t2b, 4b\n\t" \ 484 + STR(PTR_WD)"\t1b, 4b\n\t" \ 485 + STR(PTR_WD)"\t2b, 4b\n\t" \ 486 486 ".previous" \ 487 487 : "=&r" (value), "=r" (res) \ 488 488 : "r" (addr), "i" (-EFAULT)); \ ··· 504 504 "j\t3b\n\t" \ 505 505 ".previous\n\t" \ 506 506 ".section\t__ex_table,\"a\"\n\t" \ 507 - STR(PTR)"\t1b, 4b\n\t" \ 508 - STR(PTR)"\t2b, 4b\n\t" \ 507 + STR(PTR_WD)"\t1b, 4b\n\t" \ 508 + STR(PTR_WD)"\t2b, 4b\n\t" \ 509 509 ".previous" \ 510 510 : "=&r" (value), "=r" (res) \ 511 511 : "r" (addr), "i" (-EFAULT)); \ ··· 524 524 "j\t3b\n\t" \ 525 525 ".previous\n\t" \ 526 526 ".section\t__ex_table,\"a\"\n\t" \ 527 - STR(PTR)"\t1b, 4b\n\t" \ 528 - STR(PTR)"\t2b, 4b\n\t" \ 527 + STR(PTR_WD)"\t1b, 4b\n\t" \ 528 + STR(PTR_WD)"\t2b, 4b\n\t" \ 529 529 ".previous" \ 530 530 : "=&r" (value), "=r" (res) \ 531 531 : "r" (addr), "i" (-EFAULT)); \ ··· 557 557 "j\t10b\n\t" \ 558 558 ".previous\n\t" \ 559 559 ".section\t__ex_table,\"a\"\n\t" \ 560 - STR(PTR)"\t1b, 11b\n\t" \ 561 - STR(PTR)"\t2b, 11b\n\t" \ 562 - STR(PTR)"\t3b, 11b\n\t" \ 563 - STR(PTR)"\t4b, 11b\n\t" \ 560 + STR(PTR_WD)"\t1b, 11b\n\t" \ 561 + STR(PTR_WD)"\t2b, 11b\n\t" \ 562 + STR(PTR_WD)"\t3b, 11b\n\t" \ 563 + STR(PTR_WD)"\t4b, 11b\n\t" \ 564 564 ".previous" \ 565 565 : "=&r" (value), "=r" (res) \ 566 566 : "r" (addr), "i" (-EFAULT)); \ ··· 602 602 "j\t10b\n\t" \ 603 603 ".previous\n\t" \ 604 604 ".section\t__ex_table,\"a\"\n\t" \ 605 - STR(PTR)"\t1b, 11b\n\t" \ 606 - STR(PTR)"\t2b, 11b\n\t" \ 607 - STR(PTR)"\t3b, 11b\n\t" \ 608 - STR(PTR)"\t4b, 11b\n\t" \ 609 - STR(PTR)"\t5b, 11b\n\t" \ 610 - STR(PTR)"\t6b, 11b\n\t" \ 611 - STR(PTR)"\t7b, 11b\n\t" \ 612 - STR(PTR)"\t8b, 11b\n\t" \ 605 + STR(PTR_WD)"\t1b, 11b\n\t" \ 606 + STR(PTR_WD)"\t2b, 11b\n\t" \ 607 + STR(PTR_WD)"\t3b, 11b\n\t" \ 608 + STR(PTR_WD)"\t4b, 11b\n\t" \ 609 + STR(PTR_WD)"\t5b, 11b\n\t" \ 610 + STR(PTR_WD)"\t6b, 11b\n\t" \ 611 + STR(PTR_WD)"\t7b, 11b\n\t" \ 612 + STR(PTR_WD)"\t8b, 11b\n\t" \ 613 613 ".previous" \ 614 614 : "=&r" (value), "=r" (res) \ 615 615 : "r" (addr), "i" (-EFAULT)); \ ··· 632 632 "j\t3b\n\t" \ 633 633 ".previous\n\t" \ 634 634 ".section\t__ex_table,\"a\"\n\t" \ 635 - STR(PTR)"\t1b, 4b\n\t" \ 636 - STR(PTR)"\t2b, 4b\n\t" \ 635 + STR(PTR_WD)"\t1b, 4b\n\t" \ 636 + STR(PTR_WD)"\t2b, 4b\n\t" \ 637 637 ".previous" \ 638 638 : "=r" (res) \ 639 639 : "r" (value), "r" (addr), "i" (-EFAULT));\ ··· 653 653 "j\t3b\n\t" \ 654 654 ".previous\n\t" \ 655 655 ".section\t__ex_table,\"a\"\n\t" \ 656 - STR(PTR)"\t1b, 4b\n\t" \ 657 - STR(PTR)"\t2b, 4b\n\t" \ 656 + STR(PTR_WD)"\t1b, 4b\n\t" \ 657 + STR(PTR_WD)"\t2b, 4b\n\t" \ 658 658 ".previous" \ 659 659 : "=r" (res) \ 660 660 : "r" (value), "r" (addr), "i" (-EFAULT)); \ ··· 673 673 "j\t3b\n\t" \ 674 674 ".previous\n\t" \ 675 675 ".section\t__ex_table,\"a\"\n\t" \ 676 - STR(PTR)"\t1b, 4b\n\t" \ 677 - STR(PTR)"\t2b, 4b\n\t" \ 676 + STR(PTR_WD)"\t1b, 4b\n\t" \ 677 + STR(PTR_WD)"\t2b, 4b\n\t" \ 678 678 ".previous" \ 679 679 : "=r" (res) \ 680 680 : "r" (value), "r" (addr), "i" (-EFAULT)); \ ··· 703 703 "j\t10b\n\t" \ 704 704 ".previous\n\t" \ 705 705 ".section\t__ex_table,\"a\"\n\t" \ 706 - STR(PTR)"\t1b, 11b\n\t" \ 707 - STR(PTR)"\t2b, 11b\n\t" \ 708 - STR(PTR)"\t3b, 11b\n\t" \ 709 - STR(PTR)"\t4b, 11b\n\t" \ 706 + STR(PTR_WD)"\t1b, 11b\n\t" \ 707 + STR(PTR_WD)"\t2b, 11b\n\t" \ 708 + STR(PTR_WD)"\t3b, 11b\n\t" \ 709 + STR(PTR_WD)"\t4b, 11b\n\t" \ 710 710 ".previous" \ 711 711 : "=&r" (res) \ 712 712 : "r" (value), "r" (addr), "i" (-EFAULT) \ ··· 743 743 "j\t10b\n\t" \ 744 744 ".previous\n\t" \ 745 745 ".section\t__ex_table,\"a\"\n\t" \ 746 - STR(PTR)"\t1b, 11b\n\t" \ 747 - STR(PTR)"\t2b, 11b\n\t" \ 748 - STR(PTR)"\t3b, 11b\n\t" \ 749 - STR(PTR)"\t4b, 11b\n\t" \ 750 - STR(PTR)"\t5b, 11b\n\t" \ 751 - STR(PTR)"\t6b, 11b\n\t" \ 752 - STR(PTR)"\t7b, 11b\n\t" \ 753 - STR(PTR)"\t8b, 11b\n\t" \ 746 + STR(PTR_WD)"\t1b, 11b\n\t" \ 747 + STR(PTR_WD)"\t2b, 11b\n\t" \ 748 + STR(PTR_WD)"\t3b, 11b\n\t" \ 749 + STR(PTR_WD)"\t4b, 11b\n\t" \ 750 + STR(PTR_WD)"\t5b, 11b\n\t" \ 751 + STR(PTR_WD)"\t6b, 11b\n\t" \ 752 + STR(PTR_WD)"\t7b, 11b\n\t" \ 753 + STR(PTR_WD)"\t8b, 11b\n\t" \ 754 754 ".previous" \ 755 755 : "=&r" (res) \ 756 756 : "r" (value), "r" (addr), "i" (-EFAULT) \
+52 -52
arch/mips/kernel/mips-r2-to-r6-emul.c
··· 1258 1258 " j 10b\n" 1259 1259 " .previous\n" 1260 1260 " .section __ex_table,\"a\"\n" 1261 - STR(PTR) " 1b,8b\n" 1262 - STR(PTR) " 2b,8b\n" 1263 - STR(PTR) " 3b,8b\n" 1264 - STR(PTR) " 4b,8b\n" 1261 + STR(PTR_WD) " 1b,8b\n" 1262 + STR(PTR_WD) " 2b,8b\n" 1263 + STR(PTR_WD) " 3b,8b\n" 1264 + STR(PTR_WD) " 4b,8b\n" 1265 1265 " .previous\n" 1266 1266 " .set pop\n" 1267 1267 : "+&r"(rt), "=&r"(rs), ··· 1333 1333 " j 10b\n" 1334 1334 " .previous\n" 1335 1335 " .section __ex_table,\"a\"\n" 1336 - STR(PTR) " 1b,8b\n" 1337 - STR(PTR) " 2b,8b\n" 1338 - STR(PTR) " 3b,8b\n" 1339 - STR(PTR) " 4b,8b\n" 1336 + STR(PTR_WD) " 1b,8b\n" 1337 + STR(PTR_WD) " 2b,8b\n" 1338 + STR(PTR_WD) " 3b,8b\n" 1339 + STR(PTR_WD) " 4b,8b\n" 1340 1340 " .previous\n" 1341 1341 " .set pop\n" 1342 1342 : "+&r"(rt), "=&r"(rs), ··· 1404 1404 " j 9b\n" 1405 1405 " .previous\n" 1406 1406 " .section __ex_table,\"a\"\n" 1407 - STR(PTR) " 1b,8b\n" 1408 - STR(PTR) " 2b,8b\n" 1409 - STR(PTR) " 3b,8b\n" 1410 - STR(PTR) " 4b,8b\n" 1407 + STR(PTR_WD) " 1b,8b\n" 1408 + STR(PTR_WD) " 2b,8b\n" 1409 + STR(PTR_WD) " 3b,8b\n" 1410 + STR(PTR_WD) " 4b,8b\n" 1411 1411 " .previous\n" 1412 1412 " .set pop\n" 1413 1413 : "+&r"(rt), "=&r"(rs), ··· 1474 1474 " j 9b\n" 1475 1475 " .previous\n" 1476 1476 " .section __ex_table,\"a\"\n" 1477 - STR(PTR) " 1b,8b\n" 1478 - STR(PTR) " 2b,8b\n" 1479 - STR(PTR) " 3b,8b\n" 1480 - STR(PTR) " 4b,8b\n" 1477 + STR(PTR_WD) " 1b,8b\n" 1478 + STR(PTR_WD) " 2b,8b\n" 1479 + STR(PTR_WD) " 3b,8b\n" 1480 + STR(PTR_WD) " 4b,8b\n" 1481 1481 " .previous\n" 1482 1482 " .set pop\n" 1483 1483 : "+&r"(rt), "=&r"(rs), ··· 1589 1589 " j 9b\n" 1590 1590 " .previous\n" 1591 1591 " .section __ex_table,\"a\"\n" 1592 - STR(PTR) " 1b,8b\n" 1593 - STR(PTR) " 2b,8b\n" 1594 - STR(PTR) " 3b,8b\n" 1595 - STR(PTR) " 4b,8b\n" 1596 - STR(PTR) " 5b,8b\n" 1597 - STR(PTR) " 6b,8b\n" 1598 - STR(PTR) " 7b,8b\n" 1599 - STR(PTR) " 0b,8b\n" 1592 + STR(PTR_WD) " 1b,8b\n" 1593 + STR(PTR_WD) " 2b,8b\n" 1594 + STR(PTR_WD) " 3b,8b\n" 1595 + STR(PTR_WD) " 4b,8b\n" 1596 + STR(PTR_WD) " 5b,8b\n" 1597 + STR(PTR_WD) " 6b,8b\n" 1598 + STR(PTR_WD) " 7b,8b\n" 1599 + STR(PTR_WD) " 0b,8b\n" 1600 1600 " .previous\n" 1601 1601 " .set pop\n" 1602 1602 : "+&r"(rt), "=&r"(rs), ··· 1708 1708 " j 9b\n" 1709 1709 " .previous\n" 1710 1710 " .section __ex_table,\"a\"\n" 1711 - STR(PTR) " 1b,8b\n" 1712 - STR(PTR) " 2b,8b\n" 1713 - STR(PTR) " 3b,8b\n" 1714 - STR(PTR) " 4b,8b\n" 1715 - STR(PTR) " 5b,8b\n" 1716 - STR(PTR) " 6b,8b\n" 1717 - STR(PTR) " 7b,8b\n" 1718 - STR(PTR) " 0b,8b\n" 1711 + STR(PTR_WD) " 1b,8b\n" 1712 + STR(PTR_WD) " 2b,8b\n" 1713 + STR(PTR_WD) " 3b,8b\n" 1714 + STR(PTR_WD) " 4b,8b\n" 1715 + STR(PTR_WD) " 5b,8b\n" 1716 + STR(PTR_WD) " 6b,8b\n" 1717 + STR(PTR_WD) " 7b,8b\n" 1718 + STR(PTR_WD) " 0b,8b\n" 1719 1719 " .previous\n" 1720 1720 " .set pop\n" 1721 1721 : "+&r"(rt), "=&r"(rs), ··· 1827 1827 " j 9b\n" 1828 1828 " .previous\n" 1829 1829 " .section __ex_table,\"a\"\n" 1830 - STR(PTR) " 1b,8b\n" 1831 - STR(PTR) " 2b,8b\n" 1832 - STR(PTR) " 3b,8b\n" 1833 - STR(PTR) " 4b,8b\n" 1834 - STR(PTR) " 5b,8b\n" 1835 - STR(PTR) " 6b,8b\n" 1836 - STR(PTR) " 7b,8b\n" 1837 - STR(PTR) " 0b,8b\n" 1830 + STR(PTR_WD) " 1b,8b\n" 1831 + STR(PTR_WD) " 2b,8b\n" 1832 + STR(PTR_WD) " 3b,8b\n" 1833 + STR(PTR_WD) " 4b,8b\n" 1834 + STR(PTR_WD) " 5b,8b\n" 1835 + STR(PTR_WD) " 6b,8b\n" 1836 + STR(PTR_WD) " 7b,8b\n" 1837 + STR(PTR_WD) " 0b,8b\n" 1838 1838 " .previous\n" 1839 1839 " .set pop\n" 1840 1840 : "+&r"(rt), "=&r"(rs), ··· 1945 1945 " j 9b\n" 1946 1946 " .previous\n" 1947 1947 " .section __ex_table,\"a\"\n" 1948 - STR(PTR) " 1b,8b\n" 1949 - STR(PTR) " 2b,8b\n" 1950 - STR(PTR) " 3b,8b\n" 1951 - STR(PTR) " 4b,8b\n" 1952 - STR(PTR) " 5b,8b\n" 1953 - STR(PTR) " 6b,8b\n" 1954 - STR(PTR) " 7b,8b\n" 1955 - STR(PTR) " 0b,8b\n" 1948 + STR(PTR_WD) " 1b,8b\n" 1949 + STR(PTR_WD) " 2b,8b\n" 1950 + STR(PTR_WD) " 3b,8b\n" 1951 + STR(PTR_WD) " 4b,8b\n" 1952 + STR(PTR_WD) " 5b,8b\n" 1953 + STR(PTR_WD) " 6b,8b\n" 1954 + STR(PTR_WD) " 7b,8b\n" 1955 + STR(PTR_WD) " 0b,8b\n" 1956 1956 " .previous\n" 1957 1957 " .set pop\n" 1958 1958 : "+&r"(rt), "=&r"(rs), ··· 2007 2007 "j 2b\n" 2008 2008 ".previous\n" 2009 2009 ".section __ex_table,\"a\"\n" 2010 - STR(PTR) " 1b,3b\n" 2010 + STR(PTR_WD) " 1b,3b\n" 2011 2011 ".previous\n" 2012 2012 : "=&r"(res), "+&r"(err) 2013 2013 : "r"(vaddr), "i"(SIGSEGV) ··· 2065 2065 "j 2b\n" 2066 2066 ".previous\n" 2067 2067 ".section __ex_table,\"a\"\n" 2068 - STR(PTR) " 1b,3b\n" 2068 + STR(PTR_WD) " 1b,3b\n" 2069 2069 ".previous\n" 2070 2070 : "+&r"(res), "+&r"(err) 2071 2071 : "r"(vaddr), "i"(SIGSEGV)); ··· 2126 2126 "j 2b\n" 2127 2127 ".previous\n" 2128 2128 ".section __ex_table,\"a\"\n" 2129 - STR(PTR) " 1b,3b\n" 2129 + STR(PTR_WD) " 1b,3b\n" 2130 2130 ".previous\n" 2131 2131 : "=&r"(res), "+&r"(err) 2132 2132 : "r"(vaddr), "i"(SIGSEGV) ··· 2189 2189 "j 2b\n" 2190 2190 ".previous\n" 2191 2191 ".section __ex_table,\"a\"\n" 2192 - STR(PTR) " 1b,3b\n" 2192 + STR(PTR_WD) " 1b,3b\n" 2193 2193 ".previous\n" 2194 2194 : "+&r"(res), "+&r"(err) 2195 2195 : "r"(vaddr), "i"(SIGSEGV));
+3 -3
arch/mips/kernel/r2300_fpu.S
··· 23 23 #define EX(a,b) \ 24 24 9: a,##b; \ 25 25 .section __ex_table,"a"; \ 26 - PTR 9b,fault; \ 26 + PTR_WD 9b,fault; \ 27 27 .previous 28 28 29 29 #define EX2(a,b) \ 30 30 9: a,##b; \ 31 31 .section __ex_table,"a"; \ 32 - PTR 9b,fault; \ 33 - PTR 9b+4,fault; \ 32 + PTR_WD 9b,fault; \ 33 + PTR_WD 9b+4,fault; \ 34 34 .previous 35 35 36 36 .set mips1
+1 -1
arch/mips/kernel/r4k_fpu.S
··· 31 31 .ex\@: \insn \reg, \src 32 32 .set pop 33 33 .section __ex_table,"a" 34 - PTR .ex\@, fault 34 + PTR_WD .ex\@, fault 35 35 .previous 36 36 .endm 37 37
+11 -11
arch/mips/kernel/relocate_kernel.S
··· 147 147 148 148 kexec_args: 149 149 EXPORT(kexec_args) 150 - arg0: PTR 0x0 151 - arg1: PTR 0x0 152 - arg2: PTR 0x0 153 - arg3: PTR 0x0 150 + arg0: PTR_WD 0x0 151 + arg1: PTR_WD 0x0 152 + arg2: PTR_WD 0x0 153 + arg3: PTR_WD 0x0 154 154 .size kexec_args,PTRSIZE*4 155 155 156 156 #ifdef CONFIG_SMP ··· 161 161 */ 162 162 secondary_kexec_args: 163 163 EXPORT(secondary_kexec_args) 164 - s_arg0: PTR 0x0 165 - s_arg1: PTR 0x0 166 - s_arg2: PTR 0x0 167 - s_arg3: PTR 0x0 164 + s_arg0: PTR_WD 0x0 165 + s_arg1: PTR_WD 0x0 166 + s_arg2: PTR_WD 0x0 167 + s_arg3: PTR_WD 0x0 168 168 .size secondary_kexec_args,PTRSIZE*4 169 169 kexec_flag: 170 170 LONG 0x1 ··· 173 173 174 174 kexec_start_address: 175 175 EXPORT(kexec_start_address) 176 - PTR 0x0 176 + PTR_WD 0x0 177 177 .size kexec_start_address, PTRSIZE 178 178 179 179 kexec_indirection_page: 180 180 EXPORT(kexec_indirection_page) 181 - PTR 0 181 + PTR_WD 0 182 182 .size kexec_indirection_page, PTRSIZE 183 183 184 184 relocate_new_kernel_end: 185 185 186 186 relocate_new_kernel_size: 187 187 EXPORT(relocate_new_kernel_size) 188 - PTR relocate_new_kernel_end - relocate_new_kernel 188 + PTR_WD relocate_new_kernel_end - relocate_new_kernel 189 189 .size relocate_new_kernel_size, PTRSIZE
+5 -5
arch/mips/kernel/scall32-o32.S
··· 72 72 .set pop 73 73 74 74 .section __ex_table,"a" 75 - PTR load_a4, bad_stack_a4 76 - PTR load_a5, bad_stack_a5 77 - PTR load_a6, bad_stack_a6 78 - PTR load_a7, bad_stack_a7 75 + PTR_WD load_a4, bad_stack_a4 76 + PTR_WD load_a5, bad_stack_a5 77 + PTR_WD load_a6, bad_stack_a6 78 + PTR_WD load_a7, bad_stack_a7 79 79 .previous 80 80 81 81 lw t0, TI_FLAGS($28) # syscall tracing enabled? ··· 216 216 #endif /* CONFIG_MIPS_MT_FPAFF */ 217 217 218 218 #define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native) 219 - #define __SYSCALL(nr, entry) PTR entry 219 + #define __SYSCALL(nr, entry) PTR_WD entry 220 220 .align 2 221 221 .type sys_call_table, @object 222 222 EXPORT(sys_call_table)
+1 -1
arch/mips/kernel/scall64-n32.S
··· 101 101 102 102 END(handle_sysn32) 103 103 104 - #define __SYSCALL(nr, entry) PTR entry 104 + #define __SYSCALL(nr, entry) PTR_WD entry 105 105 .type sysn32_call_table, @object 106 106 EXPORT(sysn32_call_table) 107 107 #include <asm/syscall_table_n32.h>
+1 -1
arch/mips/kernel/scall64-n64.S
··· 109 109 j n64_syscall_exit 110 110 END(handle_sys64) 111 111 112 - #define __SYSCALL(nr, entry) PTR entry 112 + #define __SYSCALL(nr, entry) PTR_WD entry 113 113 .align 3 114 114 .type sys_call_table, @object 115 115 EXPORT(sys_call_table)
+5 -5
arch/mips/kernel/scall64-o32.S
··· 73 73 loads_done: 74 74 75 75 .section __ex_table,"a" 76 - PTR load_a4, bad_stack_a4 77 - PTR load_a5, bad_stack_a5 78 - PTR load_a6, bad_stack_a6 79 - PTR load_a7, bad_stack_a7 76 + PTR_WD load_a4, bad_stack_a4 77 + PTR_WD load_a5, bad_stack_a5 78 + PTR_WD load_a6, bad_stack_a6 79 + PTR_WD load_a7, bad_stack_a7 80 80 .previous 81 81 82 82 li t1, _TIF_WORK_SYSCALL_ENTRY ··· 214 214 END(sys32_syscall) 215 215 216 216 #define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, compat) 217 - #define __SYSCALL(nr, entry) PTR entry 217 + #define __SYSCALL(nr, entry) PTR_WD entry 218 218 .align 3 219 219 .type sys32_call_table,@object 220 220 EXPORT(sys32_call_table)
+4 -4
arch/mips/kernel/syscall.c
··· 122 122 " j 3b \n" 123 123 " .previous \n" 124 124 " .section __ex_table,\"a\" \n" 125 - " "STR(PTR)" 1b, 4b \n" 126 - " "STR(PTR)" 2b, 4b \n" 125 + " "STR(PTR_WD)" 1b, 4b \n" 126 + " "STR(PTR_WD)" 2b, 4b \n" 127 127 " .previous \n" 128 128 " .set pop \n" 129 129 : [old] "=&r" (old), ··· 152 152 " j 3b \n" 153 153 " .previous \n" 154 154 " .section __ex_table,\"a\" \n" 155 - " "STR(PTR)" 1b, 5b \n" 156 - " "STR(PTR)" 2b, 5b \n" 155 + " "STR(PTR_WD)" 1b, 5b \n" 156 + " "STR(PTR_WD)" 2b, 5b \n" 157 157 " .previous \n" 158 158 " .set pop \n" 159 159 : [old] "=&r" (old),
+2 -2
arch/mips/lib/csum_partial.S
··· 347 347 .if \mode == LEGACY_MODE; \ 348 348 9: insn reg, addr; \ 349 349 .section __ex_table,"a"; \ 350 - PTR 9b, .L_exc; \ 350 + PTR_WD 9b, .L_exc; \ 351 351 .previous; \ 352 352 /* This is enabled in EVA mode */ \ 353 353 .else; \ ··· 356 356 ((\to == USEROP) && (type == ST_INSN)); \ 357 357 9: __BUILD_EVA_INSN(insn##e, reg, addr); \ 358 358 .section __ex_table,"a"; \ 359 - PTR 9b, .L_exc; \ 359 + PTR_WD 9b, .L_exc; \ 360 360 .previous; \ 361 361 .else; \ 362 362 /* EVA without exception */ \
+2 -2
arch/mips/lib/memcpy.S
··· 116 116 .if \mode == LEGACY_MODE; \ 117 117 9: insn reg, addr; \ 118 118 .section __ex_table,"a"; \ 119 - PTR 9b, handler; \ 119 + PTR_WD 9b, handler; \ 120 120 .previous; \ 121 121 /* This is assembled in EVA mode */ \ 122 122 .else; \ ··· 125 125 ((\to == USEROP) && (type == ST_INSN)); \ 126 126 9: __BUILD_EVA_INSN(insn##e, reg, addr); \ 127 127 .section __ex_table,"a"; \ 128 - PTR 9b, handler; \ 128 + PTR_WD 9b, handler; \ 129 129 .previous; \ 130 130 .else; \ 131 131 /* \
+1 -1
arch/mips/lib/memset.S
··· 52 52 9: ___BUILD_EVA_INSN(insn, reg, addr); \ 53 53 .endif; \ 54 54 .section __ex_table,"a"; \ 55 - PTR 9b, handler; \ 55 + PTR_WD 9b, handler; \ 56 56 .previous 57 57 58 58 .macro f_fill64 dst, offset, val, fixup, mode
+2 -2
arch/mips/lib/strncpy_user.S
··· 15 15 #define EX(insn,reg,addr,handler) \ 16 16 9: insn reg, addr; \ 17 17 .section __ex_table,"a"; \ 18 - PTR 9b, handler; \ 18 + PTR_WD 9b, handler; \ 19 19 .previous 20 20 21 21 /* ··· 59 59 jr ra 60 60 61 61 .section __ex_table,"a" 62 - PTR 1b, .Lfault 62 + PTR_WD 1b, .Lfault 63 63 .previous 64 64 65 65 EXPORT_SYMBOL(__strncpy_from_user_asm)
+1 -1
arch/mips/lib/strnlen_user.S
··· 14 14 #define EX(insn,reg,addr,handler) \ 15 15 9: insn reg, addr; \ 16 16 .section __ex_table,"a"; \ 17 - PTR 9b, handler; \ 17 + PTR_WD 9b, handler; \ 18 18 .previous 19 19 20 20 /*
+4 -5
arch/mips/loongson64/vbios_quirk.c
··· 3 3 #include <linux/pci.h> 4 4 #include <loongson.h> 5 5 6 - static void pci_fixup_radeon(struct pci_dev *pdev) 6 + static void pci_fixup_video(struct pci_dev *pdev) 7 7 { 8 8 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE]; 9 9 ··· 22 22 res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW | 23 23 IORESOURCE_PCI_FIXED; 24 24 25 - dev_info(&pdev->dev, "BAR %d: assigned %pR for Radeon ROM\n", 26 - PCI_ROM_RESOURCE, res); 25 + dev_info(&pdev->dev, "Video device with shadowed ROM at %pR\n", res); 27 26 } 28 - DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_ATI, 0x9615, 29 - PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_radeon); 27 + DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_ATI, 0x9615, 28 + PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video);
+2
arch/powerpc/include/asm/book3s/32/mmu-hash.h
··· 223 223 update_user_segment(15, val); 224 224 } 225 225 226 + int __init find_free_bat(void); 227 + unsigned int bat_block_size(unsigned long base, unsigned long top); 226 228 #endif /* !__ASSEMBLY__ */ 227 229 228 230 /* We happily ignore the smaller BATs on 601, we don't actually use
+1
arch/powerpc/include/asm/book3s/32/pgtable.h
··· 178 178 #ifndef __ASSEMBLY__ 179 179 180 180 int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot); 181 + void unmap_kernel_page(unsigned long va); 181 182 182 183 #endif /* !__ASSEMBLY__ */ 183 184
+2
arch/powerpc/include/asm/book3s/64/pgtable.h
··· 1082 1082 return hash__map_kernel_page(ea, pa, prot); 1083 1083 } 1084 1084 1085 + void unmap_kernel_page(unsigned long va); 1086 + 1085 1087 static inline int __meminit vmemmap_create_mapping(unsigned long start, 1086 1088 unsigned long page_size, 1087 1089 unsigned long phys)
+4 -2
arch/powerpc/include/asm/fixmap.h
··· 111 111 BUILD_BUG_ON(idx >= __end_of_fixed_addresses); 112 112 else if (WARN_ON(idx >= __end_of_fixed_addresses)) 113 113 return; 114 - 115 - map_kernel_page(__fix_to_virt(idx), phys, flags); 114 + if (pgprot_val(flags)) 115 + map_kernel_page(__fix_to_virt(idx), phys, flags); 116 + else 117 + unmap_kernel_page(__fix_to_virt(idx)); 116 118 } 117 119 118 120 #define __early_set_fixmap __set_fixmap
+1 -1
arch/powerpc/include/asm/hw_irq.h
··· 473 473 return !(regs->msr & MSR_EE); 474 474 } 475 475 476 - static inline bool should_hard_irq_enable(void) 476 + static __always_inline bool should_hard_irq_enable(void) 477 477 { 478 478 return false; 479 479 }
-1
arch/powerpc/include/asm/kvm_book3s_64.h
··· 39 39 pgd_t *shadow_pgtable; /* our page table for this guest */ 40 40 u64 l1_gr_to_hr; /* L1's addr of part'n-scoped table */ 41 41 u64 process_table; /* process table entry for this guest */ 42 - u64 hfscr; /* HFSCR that the L1 requested for this nested guest */ 43 42 long refcnt; /* number of pointers to this struct */ 44 43 struct mutex tlb_lock; /* serialize page faults and tlbies */ 45 44 struct kvm_nested_guest *next;
+1
arch/powerpc/include/asm/kvm_host.h
··· 818 818 819 819 /* For support of nested guests */ 820 820 struct kvm_nested_guest *nested; 821 + u64 nested_hfscr; /* HFSCR that the L1 requested for the nested guest */ 821 822 u32 nested_vcpu_id; 822 823 gpa_t nested_io_gpr; 823 824 #endif
+1
arch/powerpc/include/asm/nohash/32/pgtable.h
··· 64 64 #ifndef __ASSEMBLY__ 65 65 66 66 int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot); 67 + void unmap_kernel_page(unsigned long va); 67 68 68 69 #endif /* !__ASSEMBLY__ */ 69 70
+1
arch/powerpc/include/asm/nohash/64/pgtable.h
··· 308 308 #define __swp_entry_to_pte(x) __pte((x).val) 309 309 310 310 int map_kernel_page(unsigned long ea, unsigned long pa, pgprot_t prot); 311 + void unmap_kernel_page(unsigned long va); 311 312 extern int __meminit vmemmap_create_mapping(unsigned long start, 312 313 unsigned long page_size, 313 314 unsigned long phys);
+1
arch/powerpc/include/asm/ppc-opcode.h
··· 500 500 #define PPC_RAW_LDX(r, base, b) (0x7c00002a | ___PPC_RT(r) | ___PPC_RA(base) | ___PPC_RB(b)) 501 501 #define PPC_RAW_LHZ(r, base, i) (0xa0000000 | ___PPC_RT(r) | ___PPC_RA(base) | IMM_L(i)) 502 502 #define PPC_RAW_LHBRX(r, base, b) (0x7c00062c | ___PPC_RT(r) | ___PPC_RA(base) | ___PPC_RB(b)) 503 + #define PPC_RAW_LWBRX(r, base, b) (0x7c00042c | ___PPC_RT(r) | ___PPC_RA(base) | ___PPC_RB(b)) 503 504 #define PPC_RAW_LDBRX(r, base, b) (0x7c000428 | ___PPC_RT(r) | ___PPC_RA(base) | ___PPC_RB(b)) 504 505 #define PPC_RAW_STWCX(s, a, b) (0x7c00012d | ___PPC_RS(s) | ___PPC_RA(a) | ___PPC_RB(b)) 505 506 #define PPC_RAW_CMPWI(a, i) (0x2c000000 | ___PPC_RA(a) | IMM_L(i))
+2 -2
arch/powerpc/include/asm/syscall.h
··· 90 90 unsigned long val, mask = -1UL; 91 91 unsigned int n = 6; 92 92 93 - if (is_32bit_task()) 93 + if (is_tsk_32bit_task(task)) 94 94 mask = 0xffffffff; 95 95 96 96 while (n--) { ··· 105 105 106 106 static inline int syscall_get_arch(struct task_struct *task) 107 107 { 108 - if (is_32bit_task()) 108 + if (is_tsk_32bit_task(task)) 109 109 return AUDIT_ARCH_PPC; 110 110 else if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN)) 111 111 return AUDIT_ARCH_PPC64LE;
+2
arch/powerpc/include/asm/thread_info.h
··· 168 168 169 169 #ifdef CONFIG_COMPAT 170 170 #define is_32bit_task() (test_thread_flag(TIF_32BIT)) 171 + #define is_tsk_32bit_task(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT)) 171 172 #else 172 173 #define is_32bit_task() (IS_ENABLED(CONFIG_PPC32)) 174 + #define is_tsk_32bit_task(tsk) (IS_ENABLED(CONFIG_PPC32)) 173 175 #endif 174 176 175 177 #if defined(CONFIG_PPC64)
+2
arch/powerpc/kernel/interrupt_64.S
··· 30 30 .ifc \srr,srr 31 31 mfspr r11,SPRN_SRR0 32 32 ld r12,_NIP(r1) 33 + clrrdi r11,r11,2 33 34 clrrdi r12,r12,2 34 35 100: tdne r11,r12 35 36 EMIT_WARN_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE) ··· 41 40 .else 42 41 mfspr r11,SPRN_HSRR0 43 42 ld r12,_NIP(r1) 43 + clrrdi r11,r11,2 44 44 clrrdi r12,r12,2 45 45 100: tdne r11,r12 46 46 EMIT_WARN_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
+3 -2
arch/powerpc/kernel/time.c
··· 649 649 __this_cpu_inc(irq_stat.timer_irqs_event); 650 650 } else { 651 651 now = *next_tb - now; 652 - if (now <= decrementer_max) 653 - set_dec_or_work(now); 652 + if (now > decrementer_max) 653 + now = decrementer_max; 654 + set_dec_or_work(now); 654 655 __this_cpu_inc(irq_stat.timer_irqs_others); 655 656 } 656 657
+1 -2
arch/powerpc/kvm/book3s_hv.c
··· 1816 1816 1817 1817 static int kvmppc_handle_nested_exit(struct kvm_vcpu *vcpu) 1818 1818 { 1819 - struct kvm_nested_guest *nested = vcpu->arch.nested; 1820 1819 int r; 1821 1820 int srcu_idx; 1822 1821 ··· 1921 1922 * it into a HEAI. 1922 1923 */ 1923 1924 if (!(vcpu->arch.hfscr_permitted & (1UL << cause)) || 1924 - (nested->hfscr & (1UL << cause))) { 1925 + (vcpu->arch.nested_hfscr & (1UL << cause))) { 1925 1926 vcpu->arch.trap = BOOK3S_INTERRUPT_H_EMUL_ASSIST; 1926 1927 1927 1928 /*
+1 -1
arch/powerpc/kvm/book3s_hv_nested.c
··· 363 363 /* set L1 state to L2 state */ 364 364 vcpu->arch.nested = l2; 365 365 vcpu->arch.nested_vcpu_id = l2_hv.vcpu_token; 366 - l2->hfscr = l2_hv.hfscr; 366 + vcpu->arch.nested_hfscr = l2_hv.hfscr; 367 367 vcpu->arch.regs = l2_regs; 368 368 369 369 /* Guest must always run with ME enabled, HV disabled. */
+5 -5
arch/powerpc/mm/book3s32/mmu.c
··· 76 76 return 0; 77 77 } 78 78 79 - static int __init find_free_bat(void) 79 + int __init find_free_bat(void) 80 80 { 81 81 int b; 82 82 int n = mmu_has_feature(MMU_FTR_USE_HIGH_BATS) ? 8 : 4; ··· 100 100 * - block size has to be a power of two. This is calculated by finding the 101 101 * highest bit set to 1. 102 102 */ 103 - static unsigned int block_size(unsigned long base, unsigned long top) 103 + unsigned int bat_block_size(unsigned long base, unsigned long top) 104 104 { 105 105 unsigned int max_size = SZ_256M; 106 106 unsigned int base_shift = (ffs(base) - 1) & 31; ··· 145 145 int idx; 146 146 147 147 while ((idx = find_free_bat()) != -1 && base != top) { 148 - unsigned int size = block_size(base, top); 148 + unsigned int size = bat_block_size(base, top); 149 149 150 150 if (size < 128 << 10) 151 151 break; ··· 201 201 unsigned long size; 202 202 203 203 for (i = 0; i < nb - 1 && base < top;) { 204 - size = block_size(base, top); 204 + size = bat_block_size(base, top); 205 205 setibat(i++, PAGE_OFFSET + base, base, size, PAGE_KERNEL_TEXT); 206 206 base += size; 207 207 } 208 208 if (base < top) { 209 - size = block_size(base, top); 209 + size = bat_block_size(base, top); 210 210 if ((top - base) > size) { 211 211 size <<= 1; 212 212 if (strict_kernel_rwx_enabled() && base + size > border)
+29 -26
arch/powerpc/mm/kasan/book3s_32.c
··· 10 10 { 11 11 unsigned long k_start = (unsigned long)kasan_mem_to_shadow(start); 12 12 unsigned long k_end = (unsigned long)kasan_mem_to_shadow(start + size); 13 - unsigned long k_cur = k_start; 14 - int k_size = k_end - k_start; 15 - int k_size_base = 1 << (ffs(k_size) - 1); 13 + unsigned long k_nobat = k_start; 14 + unsigned long k_cur; 15 + phys_addr_t phys; 16 16 int ret; 17 - void *block; 18 17 19 - block = memblock_alloc(k_size, k_size_base); 18 + while (k_nobat < k_end) { 19 + unsigned int k_size = bat_block_size(k_nobat, k_end); 20 + int idx = find_free_bat(); 20 21 21 - if (block && k_size_base >= SZ_128K && k_start == ALIGN(k_start, k_size_base)) { 22 - int shift = ffs(k_size - k_size_base); 23 - int k_size_more = shift ? 1 << (shift - 1) : 0; 22 + if (idx == -1) 23 + break; 24 + if (k_size < SZ_128K) 25 + break; 26 + phys = memblock_phys_alloc_range(k_size, k_size, 0, 27 + MEMBLOCK_ALLOC_ANYWHERE); 28 + if (!phys) 29 + break; 24 30 25 - setbat(-1, k_start, __pa(block), k_size_base, PAGE_KERNEL); 26 - if (k_size_more >= SZ_128K) 27 - setbat(-1, k_start + k_size_base, __pa(block) + k_size_base, 28 - k_size_more, PAGE_KERNEL); 29 - if (v_block_mapped(k_start)) 30 - k_cur = k_start + k_size_base; 31 - if (v_block_mapped(k_start + k_size_base)) 32 - k_cur = k_start + k_size_base + k_size_more; 33 - 34 - update_bats(); 31 + setbat(idx, k_nobat, phys, k_size, PAGE_KERNEL); 32 + k_nobat += k_size; 35 33 } 34 + if (k_nobat != k_start) 35 + update_bats(); 36 36 37 - if (!block) 38 - block = memblock_alloc(k_size, PAGE_SIZE); 39 - if (!block) 40 - return -ENOMEM; 37 + if (k_nobat < k_end) { 38 + phys = memblock_phys_alloc_range(k_end - k_nobat, PAGE_SIZE, 0, 39 + MEMBLOCK_ALLOC_ANYWHERE); 40 + if (!phys) 41 + return -ENOMEM; 42 + } 41 43 42 44 ret = kasan_init_shadow_page_tables(k_start, k_end); 43 45 if (ret) 44 46 return ret; 45 47 46 - kasan_update_early_region(k_start, k_cur, __pte(0)); 48 + kasan_update_early_region(k_start, k_nobat, __pte(0)); 47 49 48 - for (; k_cur < k_end; k_cur += PAGE_SIZE) { 50 + for (k_cur = k_nobat; k_cur < k_end; k_cur += PAGE_SIZE) { 49 51 pmd_t *pmd = pmd_off_k(k_cur); 50 - void *va = block + k_cur - k_start; 51 - pte_t pte = pfn_pte(PHYS_PFN(__pa(va)), PAGE_KERNEL); 52 + pte_t pte = pfn_pte(PHYS_PFN(phys + k_cur - k_nobat), PAGE_KERNEL); 52 53 53 54 __set_pte_at(&init_mm, k_cur, pte_offset_kernel(pmd, k_cur), pte, 0); 54 55 } 55 56 flush_tlb_kernel_range(k_start, k_end); 57 + memset(kasan_mem_to_shadow(start), 0, k_end - k_start); 58 + 56 59 return 0; 57 60 }
+9
arch/powerpc/mm/pgtable.c
··· 206 206 __set_pte_at(mm, addr, ptep, pte, 0); 207 207 } 208 208 209 + void unmap_kernel_page(unsigned long va) 210 + { 211 + pmd_t *pmdp = pmd_off_k(va); 212 + pte_t *ptep = pte_offset_kernel(pmdp, va); 213 + 214 + pte_clear(&init_mm, va, ptep); 215 + flush_tlb_kernel_range(va, va + PAGE_SIZE); 216 + } 217 + 209 218 /* 210 219 * This is called when relaxing access to a PTE. It's also called in the page 211 220 * fault path when we don't hit any of the major fault cases, ie, a minor
+23 -6
arch/powerpc/net/bpf_jit_comp.c
··· 23 23 memset32(area, BREAKPOINT_INSTRUCTION, size / 4); 24 24 } 25 25 26 - /* Fix the branch target addresses for subprog calls */ 27 - static int bpf_jit_fixup_subprog_calls(struct bpf_prog *fp, u32 *image, 28 - struct codegen_context *ctx, u32 *addrs) 26 + /* Fix updated addresses (for subprog calls, ldimm64, et al) during extra pass */ 27 + static int bpf_jit_fixup_addresses(struct bpf_prog *fp, u32 *image, 28 + struct codegen_context *ctx, u32 *addrs) 29 29 { 30 30 const struct bpf_insn *insn = fp->insnsi; 31 31 bool func_addr_fixed; 32 32 u64 func_addr; 33 33 u32 tmp_idx; 34 - int i, ret; 34 + int i, j, ret; 35 35 36 36 for (i = 0; i < fp->len; i++) { 37 37 /* ··· 66 66 * of the JITed sequence remains unchanged. 67 67 */ 68 68 ctx->idx = tmp_idx; 69 + } else if (insn[i].code == (BPF_LD | BPF_IMM | BPF_DW)) { 70 + tmp_idx = ctx->idx; 71 + ctx->idx = addrs[i] / 4; 72 + #ifdef CONFIG_PPC32 73 + PPC_LI32(ctx->b2p[insn[i].dst_reg] - 1, (u32)insn[i + 1].imm); 74 + PPC_LI32(ctx->b2p[insn[i].dst_reg], (u32)insn[i].imm); 75 + for (j = ctx->idx - addrs[i] / 4; j < 4; j++) 76 + EMIT(PPC_RAW_NOP()); 77 + #else 78 + func_addr = ((u64)(u32)insn[i].imm) | (((u64)(u32)insn[i + 1].imm) << 32); 79 + PPC_LI64(b2p[insn[i].dst_reg], func_addr); 80 + /* overwrite rest with nops */ 81 + for (j = ctx->idx - addrs[i] / 4; j < 5; j++) 82 + EMIT(PPC_RAW_NOP()); 83 + #endif 84 + ctx->idx = tmp_idx; 85 + i++; 69 86 } 70 87 } 71 88 ··· 217 200 /* 218 201 * Do not touch the prologue and epilogue as they will remain 219 202 * unchanged. Only fix the branch target address for subprog 220 - * calls in the body. 203 + * calls in the body, and ldimm64 instructions. 221 204 * 222 205 * This does not change the offsets and lengths of the subprog 223 206 * call instruction sequences and hence, the size of the JITed 224 207 * image as well. 225 208 */ 226 - bpf_jit_fixup_subprog_calls(fp, code_base, &cgctx, addrs); 209 + bpf_jit_fixup_addresses(fp, code_base, &cgctx, addrs); 227 210 228 211 /* There is no need to perform the usual passes. */ 229 212 goto skip_codegen_passes;
+9
arch/powerpc/net/bpf_jit_comp32.c
··· 191 191 192 192 if (image && rel < 0x2000000 && rel >= -0x2000000) { 193 193 PPC_BL_ABS(func); 194 + EMIT(PPC_RAW_NOP()); 195 + EMIT(PPC_RAW_NOP()); 196 + EMIT(PPC_RAW_NOP()); 194 197 } else { 195 198 /* Load function address into r0 */ 196 199 EMIT(PPC_RAW_LIS(_R0, IMM_H(func))); ··· 293 290 bool func_addr_fixed; 294 291 u64 func_addr; 295 292 u32 true_cond; 293 + u32 tmp_idx; 294 + int j; 296 295 297 296 /* 298 297 * addrs[] maps a BPF bytecode address into a real offset from ··· 910 905 * 16 byte instruction that uses two 'struct bpf_insn' 911 906 */ 912 907 case BPF_LD | BPF_IMM | BPF_DW: /* dst = (u64) imm */ 908 + tmp_idx = ctx->idx; 913 909 PPC_LI32(dst_reg_h, (u32)insn[i + 1].imm); 914 910 PPC_LI32(dst_reg, (u32)insn[i].imm); 911 + /* padding to allow full 4 instructions for later patching */ 912 + for (j = ctx->idx - tmp_idx; j < 4; j++) 913 + EMIT(PPC_RAW_NOP()); 915 914 /* Adjust for two bpf instructions */ 916 915 addrs[++i] = ctx->idx * 4; 917 916 break;
+19 -10
arch/powerpc/net/bpf_jit_comp64.c
··· 319 319 u64 imm64; 320 320 u32 true_cond; 321 321 u32 tmp_idx; 322 + int j; 322 323 323 324 /* 324 325 * addrs[] maps a BPF bytecode address into a real offset from ··· 634 633 EMIT(PPC_RAW_MR(dst_reg, b2p[TMP_REG_1])); 635 634 break; 636 635 case 64: 637 - /* 638 - * Way easier and faster(?) to store the value 639 - * into stack and then use ldbrx 640 - * 641 - * ctx->seen will be reliable in pass2, but 642 - * the instructions generated will remain the 643 - * same across all passes 644 - */ 636 + /* Store the value to stack and then use byte-reverse loads */ 645 637 PPC_BPF_STL(dst_reg, 1, bpf_jit_stack_local(ctx)); 646 638 EMIT(PPC_RAW_ADDI(b2p[TMP_REG_1], 1, bpf_jit_stack_local(ctx))); 647 - EMIT(PPC_RAW_LDBRX(dst_reg, 0, b2p[TMP_REG_1])); 639 + if (cpu_has_feature(CPU_FTR_ARCH_206)) { 640 + EMIT(PPC_RAW_LDBRX(dst_reg, 0, b2p[TMP_REG_1])); 641 + } else { 642 + EMIT(PPC_RAW_LWBRX(dst_reg, 0, b2p[TMP_REG_1])); 643 + if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN)) 644 + EMIT(PPC_RAW_SLDI(dst_reg, dst_reg, 32)); 645 + EMIT(PPC_RAW_LI(b2p[TMP_REG_2], 4)); 646 + EMIT(PPC_RAW_LWBRX(b2p[TMP_REG_2], b2p[TMP_REG_2], b2p[TMP_REG_1])); 647 + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) 648 + EMIT(PPC_RAW_SLDI(b2p[TMP_REG_2], b2p[TMP_REG_2], 32)); 649 + EMIT(PPC_RAW_OR(dst_reg, dst_reg, b2p[TMP_REG_2])); 650 + } 648 651 break; 649 652 } 650 653 break; ··· 853 848 case BPF_LD | BPF_IMM | BPF_DW: /* dst = (u64) imm */ 854 849 imm64 = ((u64)(u32) insn[i].imm) | 855 850 (((u64)(u32) insn[i+1].imm) << 32); 851 + tmp_idx = ctx->idx; 852 + PPC_LI64(dst_reg, imm64); 853 + /* padding to allow full 5 instructions for later patching */ 854 + for (j = ctx->idx - tmp_idx; j < 5; j++) 855 + EMIT(PPC_RAW_NOP()); 856 856 /* Adjust for two bpf instructions */ 857 857 addrs[++i] = ctx->idx * 4; 858 - PPC_LI64(dst_reg, imm64); 859 858 break; 860 859 861 860 /*
+42 -33
arch/powerpc/perf/core-book3s.c
··· 776 776 mtspr(SPRN_PMC6, pmcs[5]); 777 777 } 778 778 779 + /* 780 + * If the perf subsystem wants performance monitor interrupts as soon as 781 + * possible (e.g., to sample the instruction address and stack chain), 782 + * this should return true. The IRQ masking code can then enable MSR[EE] 783 + * in some places (e.g., interrupt handlers) that allows PMI interrupts 784 + * through to improve accuracy of profiles, at the cost of some performance. 785 + * 786 + * The PMU counters can be enabled by other means (e.g., sysfs raw SPR 787 + * access), but in that case there is no need for prompt PMI handling. 788 + * 789 + * This currently returns true if any perf counter is being used. It 790 + * could possibly return false if only events are being counted rather than 791 + * samples being taken, but for now this is good enough. 792 + */ 793 + bool power_pmu_wants_prompt_pmi(void) 794 + { 795 + struct cpu_hw_events *cpuhw; 796 + 797 + /* 798 + * This could simply test local_paca->pmcregs_in_use if that were not 799 + * under ifdef KVM. 800 + */ 801 + if (!ppmu) 802 + return false; 803 + 804 + cpuhw = this_cpu_ptr(&cpu_hw_events); 805 + return cpuhw->n_events; 806 + } 779 807 #endif /* CONFIG_PPC64 */ 780 808 781 809 static void perf_event_interrupt(struct pt_regs *regs); ··· 1355 1327 * Otherwise provide a warning if there is PMI pending, but 1356 1328 * no counter is found overflown. 1357 1329 */ 1358 - if (any_pmc_overflown(cpuhw)) 1359 - clear_pmi_irq_pending(); 1360 - else 1330 + if (any_pmc_overflown(cpuhw)) { 1331 + /* 1332 + * Since power_pmu_disable runs under local_irq_save, it 1333 + * could happen that code hits a PMC overflow without PMI 1334 + * pending in paca. Hence only clear PMI pending if it was 1335 + * set. 1336 + * 1337 + * If a PMI is pending, then MSR[EE] must be disabled (because 1338 + * the masked PMI handler disabling EE). So it is safe to 1339 + * call clear_pmi_irq_pending(). 1340 + */ 1341 + if (pmi_irq_pending()) 1342 + clear_pmi_irq_pending(); 1343 + } else 1361 1344 WARN_ON(pmi_irq_pending()); 1362 1345 1363 1346 val = mmcra = cpuhw->mmcr.mmcra; ··· 2475 2436 2476 2437 __perf_event_interrupt(regs); 2477 2438 perf_sample_event_took(sched_clock() - start_clock); 2478 - } 2479 - 2480 - /* 2481 - * If the perf subsystem wants performance monitor interrupts as soon as 2482 - * possible (e.g., to sample the instruction address and stack chain), 2483 - * this should return true. The IRQ masking code can then enable MSR[EE] 2484 - * in some places (e.g., interrupt handlers) that allows PMI interrupts 2485 - * though to improve accuracy of profiles, at the cost of some performance. 2486 - * 2487 - * The PMU counters can be enabled by other means (e.g., sysfs raw SPR 2488 - * access), but in that case there is no need for prompt PMI handling. 2489 - * 2490 - * This currently returns true if any perf counter is being used. It 2491 - * could possibly return false if only events are being counted rather than 2492 - * samples being taken, but for now this is good enough. 2493 - */ 2494 - bool power_pmu_wants_prompt_pmi(void) 2495 - { 2496 - struct cpu_hw_events *cpuhw; 2497 - 2498 - /* 2499 - * This could simply test local_paca->pmcregs_in_use if that were not 2500 - * under ifdef KVM. 2501 - */ 2502 - 2503 - if (!ppmu) 2504 - return false; 2505 - 2506 - cpuhw = this_cpu_ptr(&cpu_hw_events); 2507 - return cpuhw->n_events; 2508 2439 } 2509 2440 2510 2441 static int power_pmu_prepare_cpu(unsigned int cpu)
+15
arch/s390/Kconfig
··· 945 945 946 946 endmenu 947 947 948 + config S390_MODULES_SANITY_TEST_HELPERS 949 + def_bool n 950 + 948 951 menu "Selftests" 949 952 950 953 config S390_UNWIND_SELFTEST ··· 974 971 975 972 Say N if you are unsure. 976 973 974 + config S390_MODULES_SANITY_TEST 975 + def_tristate n 976 + depends on KUNIT 977 + default KUNIT_ALL_TESTS 978 + prompt "Enable s390 specific modules tests" 979 + select S390_MODULES_SANITY_TEST_HELPERS 980 + help 981 + This option enables an s390 specific modules test. This option is 982 + not useful for distributions or general kernels, but only for 983 + kernel developers working on architecture code. 984 + 985 + Say N if you are unsure. 977 986 endmenu
+10 -10
arch/s390/configs/debug_defconfig
··· 63 63 CONFIG_KVM=m 64 64 CONFIG_S390_UNWIND_SELFTEST=m 65 65 CONFIG_S390_KPROBES_SANITY_TEST=m 66 + CONFIG_S390_MODULES_SANITY_TEST=m 66 67 CONFIG_KPROBES=y 67 68 CONFIG_JUMP_LABEL=y 68 69 CONFIG_STATIC_KEYS_SELFTEST=y ··· 97 96 CONFIG_MEMORY_HOTREMOVE=y 98 97 CONFIG_KSM=y 99 98 CONFIG_TRANSPARENT_HUGEPAGE=y 100 - CONFIG_FRONTSWAP=y 101 99 CONFIG_CMA_DEBUG=y 102 100 CONFIG_CMA_DEBUGFS=y 103 101 CONFIG_CMA_SYSFS=y ··· 109 109 CONFIG_IDLE_PAGE_TRACKING=y 110 110 CONFIG_PERCPU_STATS=y 111 111 CONFIG_GUP_TEST=y 112 + CONFIG_ANON_VMA_NAME=y 112 113 CONFIG_NET=y 113 114 CONFIG_PACKET=y 114 115 CONFIG_PACKET_DIAG=m ··· 117 116 CONFIG_UNIX_DIAG=m 118 117 CONFIG_XFRM_USER=m 119 118 CONFIG_NET_KEY=m 120 - CONFIG_NET_SWITCHDEV=y 121 119 CONFIG_SMC=m 122 120 CONFIG_SMC_DIAG=m 123 121 CONFIG_INET=y ··· 185 185 CONFIG_NF_TABLES=m 186 186 CONFIG_NF_TABLES_INET=y 187 187 CONFIG_NFT_CT=m 188 - CONFIG_NFT_COUNTER=m 189 188 CONFIG_NFT_LOG=m 190 189 CONFIG_NFT_LIMIT=m 191 190 CONFIG_NFT_NAT=m ··· 390 391 CONFIG_VSOCKETS=m 391 392 CONFIG_VIRTIO_VSOCKETS=m 392 393 CONFIG_NETLINK_DIAG=m 394 + CONFIG_NET_SWITCHDEV=y 393 395 CONFIG_CGROUP_NET_PRIO=y 394 396 CONFIG_NET_PKTGEN=m 395 397 CONFIG_PCI=y ··· 400 400 CONFIG_HOTPLUG_PCI=y 401 401 CONFIG_HOTPLUG_PCI_S390=y 402 402 CONFIG_DEVTMPFS=y 403 + CONFIG_DEVTMPFS_SAFE=y 403 404 CONFIG_CONNECTOR=y 404 405 CONFIG_ZRAM=y 405 406 CONFIG_BLK_DEV_LOOP=m ··· 502 501 # CONFIG_NET_VENDOR_DEC is not set 503 502 # CONFIG_NET_VENDOR_DLINK is not set 504 503 # CONFIG_NET_VENDOR_EMULEX is not set 504 + # CONFIG_NET_VENDOR_ENGLEDER is not set 505 505 # CONFIG_NET_VENDOR_EZCHIP is not set 506 506 # CONFIG_NET_VENDOR_GOOGLE is not set 507 507 # CONFIG_NET_VENDOR_HUAWEI is not set ··· 513 511 CONFIG_MLX4_EN=m 514 512 CONFIG_MLX5_CORE=m 515 513 CONFIG_MLX5_CORE_EN=y 516 - CONFIG_MLX5_ESWITCH=y 517 514 # CONFIG_NET_VENDOR_MICREL is not set 518 515 # CONFIG_NET_VENDOR_MICROCHIP is not set 519 516 # CONFIG_NET_VENDOR_MICROSEMI is not set ··· 543 542 # CONFIG_NET_VENDOR_SYNOPSYS is not set 544 543 # CONFIG_NET_VENDOR_TEHUTI is not set 545 544 # CONFIG_NET_VENDOR_TI is not set 545 + # CONFIG_NET_VENDOR_VERTEXCOM is not set 546 546 # CONFIG_NET_VENDOR_VIA is not set 547 547 # CONFIG_NET_VENDOR_WIZNET is not set 548 548 # CONFIG_NET_VENDOR_XILINX is not set ··· 594 592 CONFIG_VIRTIO_INPUT=y 595 593 CONFIG_VHOST_NET=m 596 594 CONFIG_VHOST_VSOCK=m 595 + # CONFIG_SURFACE_PLATFORMS is not set 597 596 CONFIG_S390_CCW_IOMMU=y 598 597 CONFIG_S390_AP_IOMMU=y 599 598 CONFIG_EXT4_FS=y ··· 759 756 CONFIG_CRYPTO_USER_API_RNG=m 760 757 CONFIG_CRYPTO_USER_API_AEAD=m 761 758 CONFIG_CRYPTO_STATS=y 762 - CONFIG_CRYPTO_LIB_BLAKE2S=m 763 - CONFIG_CRYPTO_LIB_CURVE25519=m 764 - CONFIG_CRYPTO_LIB_CHACHA20POLY1305=m 765 759 CONFIG_ZCRYPT=m 766 760 CONFIG_PKEY=m 767 761 CONFIG_CRYPTO_PAES_S390=m ··· 774 774 CONFIG_CRYPTO_CRC32_S390=y 775 775 CONFIG_CRYPTO_DEV_VIRTIO=m 776 776 CONFIG_CORDIC=m 777 + CONFIG_CRYPTO_LIB_CURVE25519=m 778 + CONFIG_CRYPTO_LIB_CHACHA20POLY1305=m 777 779 CONFIG_CRC32_SELFTEST=y 778 780 CONFIG_CRC4=m 779 781 CONFIG_CRC7=m ··· 809 807 CONFIG_SLUB_STATS=y 810 808 CONFIG_DEBUG_STACK_USAGE=y 811 809 CONFIG_DEBUG_VM=y 812 - CONFIG_DEBUG_VM_VMACACHE=y 813 810 CONFIG_DEBUG_VM_PGFLAGS=y 814 811 CONFIG_DEBUG_MEMORY_INIT=y 815 812 CONFIG_MEMORY_NOTIFIER_ERROR_INJECT=m ··· 820 819 CONFIG_DETECT_HUNG_TASK=y 821 820 CONFIG_WQ_WATCHDOG=y 822 821 CONFIG_TEST_LOCKUP=m 823 - CONFIG_DEBUG_TIMEKEEPING=y 824 822 CONFIG_PROVE_LOCKING=y 825 823 CONFIG_LOCK_STAT=y 826 - CONFIG_DEBUG_LOCKDEP=y 827 824 CONFIG_DEBUG_ATOMIC_SLEEP=y 828 825 CONFIG_DEBUG_LOCKING_API_SELFTESTS=y 826 + CONFIG_DEBUG_IRQFLAGS=y 829 827 CONFIG_DEBUG_SG=y 830 828 CONFIG_DEBUG_NOTIFIERS=y 831 829 CONFIG_BUG_ON_DATA_CORRUPTION=y
+9 -7
arch/s390/configs/defconfig
··· 61 61 CONFIG_KVM=m 62 62 CONFIG_S390_UNWIND_SELFTEST=m 63 63 CONFIG_S390_KPROBES_SANITY_TEST=m 64 + CONFIG_S390_MODULES_SANITY_TEST=m 64 65 CONFIG_KPROBES=y 65 66 CONFIG_JUMP_LABEL=y 66 67 # CONFIG_GCC_PLUGINS is not set ··· 92 91 CONFIG_MEMORY_HOTREMOVE=y 93 92 CONFIG_KSM=y 94 93 CONFIG_TRANSPARENT_HUGEPAGE=y 95 - CONFIG_FRONTSWAP=y 96 94 CONFIG_CMA_SYSFS=y 97 95 CONFIG_CMA_AREAS=7 98 96 CONFIG_MEM_SOFT_DIRTY=y ··· 101 101 CONFIG_DEFERRED_STRUCT_PAGE_INIT=y 102 102 CONFIG_IDLE_PAGE_TRACKING=y 103 103 CONFIG_PERCPU_STATS=y 104 + CONFIG_ANON_VMA_NAME=y 104 105 CONFIG_NET=y 105 106 CONFIG_PACKET=y 106 107 CONFIG_PACKET_DIAG=m ··· 109 108 CONFIG_UNIX_DIAG=m 110 109 CONFIG_XFRM_USER=m 111 110 CONFIG_NET_KEY=m 112 - CONFIG_NET_SWITCHDEV=y 113 111 CONFIG_SMC=m 114 112 CONFIG_SMC_DIAG=m 115 113 CONFIG_INET=y ··· 177 177 CONFIG_NF_TABLES=m 178 178 CONFIG_NF_TABLES_INET=y 179 179 CONFIG_NFT_CT=m 180 - CONFIG_NFT_COUNTER=m 181 180 CONFIG_NFT_LOG=m 182 181 CONFIG_NFT_LIMIT=m 183 182 CONFIG_NFT_NAT=m ··· 381 382 CONFIG_VSOCKETS=m 382 383 CONFIG_VIRTIO_VSOCKETS=m 383 384 CONFIG_NETLINK_DIAG=m 385 + CONFIG_NET_SWITCHDEV=y 384 386 CONFIG_CGROUP_NET_PRIO=y 385 387 CONFIG_NET_PKTGEN=m 386 388 CONFIG_PCI=y ··· 391 391 CONFIG_HOTPLUG_PCI_S390=y 392 392 CONFIG_UEVENT_HELPER=y 393 393 CONFIG_DEVTMPFS=y 394 + CONFIG_DEVTMPFS_SAFE=y 394 395 CONFIG_CONNECTOR=y 395 396 CONFIG_ZRAM=y 396 397 CONFIG_BLK_DEV_LOOP=m ··· 493 492 # CONFIG_NET_VENDOR_DEC is not set 494 493 # CONFIG_NET_VENDOR_DLINK is not set 495 494 # CONFIG_NET_VENDOR_EMULEX is not set 495 + # CONFIG_NET_VENDOR_ENGLEDER is not set 496 496 # CONFIG_NET_VENDOR_EZCHIP is not set 497 497 # CONFIG_NET_VENDOR_GOOGLE is not set 498 498 # CONFIG_NET_VENDOR_HUAWEI is not set ··· 504 502 CONFIG_MLX4_EN=m 505 503 CONFIG_MLX5_CORE=m 506 504 CONFIG_MLX5_CORE_EN=y 507 - CONFIG_MLX5_ESWITCH=y 508 505 # CONFIG_NET_VENDOR_MICREL is not set 509 506 # CONFIG_NET_VENDOR_MICROCHIP is not set 510 507 # CONFIG_NET_VENDOR_MICROSEMI is not set ··· 534 533 # CONFIG_NET_VENDOR_SYNOPSYS is not set 535 534 # CONFIG_NET_VENDOR_TEHUTI is not set 536 535 # CONFIG_NET_VENDOR_TI is not set 536 + # CONFIG_NET_VENDOR_VERTEXCOM is not set 537 537 # CONFIG_NET_VENDOR_VIA is not set 538 538 # CONFIG_NET_VENDOR_WIZNET is not set 539 539 # CONFIG_NET_VENDOR_XILINX is not set ··· 584 582 CONFIG_VIRTIO_INPUT=y 585 583 CONFIG_VHOST_NET=m 586 584 CONFIG_VHOST_VSOCK=m 585 + # CONFIG_SURFACE_PLATFORMS is not set 587 586 CONFIG_S390_CCW_IOMMU=y 588 587 CONFIG_S390_AP_IOMMU=y 589 588 CONFIG_EXT4_FS=y ··· 746 743 CONFIG_CRYPTO_USER_API_RNG=m 747 744 CONFIG_CRYPTO_USER_API_AEAD=m 748 745 CONFIG_CRYPTO_STATS=y 749 - CONFIG_CRYPTO_LIB_BLAKE2S=m 750 - CONFIG_CRYPTO_LIB_CURVE25519=m 751 - CONFIG_CRYPTO_LIB_CHACHA20POLY1305=m 752 746 CONFIG_ZCRYPT=m 753 747 CONFIG_PKEY=m 754 748 CONFIG_CRYPTO_PAES_S390=m ··· 762 762 CONFIG_CRYPTO_DEV_VIRTIO=m 763 763 CONFIG_CORDIC=m 764 764 CONFIG_PRIME_NUMBERS=m 765 + CONFIG_CRYPTO_LIB_CURVE25519=m 766 + CONFIG_CRYPTO_LIB_CHACHA20POLY1305=m 765 767 CONFIG_CRC4=m 766 768 CONFIG_CRC7=m 767 769 CONFIG_CRC8=m
+3
arch/s390/configs/zfcpdump_defconfig
··· 1 1 # CONFIG_SWAP is not set 2 2 CONFIG_NO_HZ_IDLE=y 3 3 CONFIG_HIGH_RES_TIMERS=y 4 + CONFIG_BPF_SYSCALL=y 4 5 # CONFIG_CPU_ISOLATION is not set 5 6 # CONFIG_UTS_NS is not set 6 7 # CONFIG_TIME_NS is not set ··· 35 34 # CONFIG_PCPU_DEV_REFCNT is not set 36 35 # CONFIG_ETHTOOL_NETLINK is not set 37 36 CONFIG_DEVTMPFS=y 37 + CONFIG_DEVTMPFS_SAFE=y 38 38 CONFIG_BLK_DEV_RAM=y 39 39 # CONFIG_DCSSBLK is not set 40 40 # CONFIG_DASD is not set ··· 60 58 # CONFIG_HID is not set 61 59 # CONFIG_VIRTIO_MENU is not set 62 60 # CONFIG_VHOST_MENU is not set 61 + # CONFIG_SURFACE_PLATFORMS is not set 63 62 # CONFIG_IOMMU_SUPPORT is not set 64 63 # CONFIG_DNOTIFY is not set 65 64 # CONFIG_INOTIFY_USER is not set
+4 -2
arch/s390/hypfs/hypfs_vm.c
··· 20 20 21 21 static char local_guest[] = " "; 22 22 static char all_guests[] = "* "; 23 + static char *all_groups = all_guests; 23 24 static char *guest_query; 24 25 25 26 struct diag2fc_data { ··· 63 62 64 63 memcpy(parm_list.userid, query, NAME_LEN); 65 64 ASCEBC(parm_list.userid, NAME_LEN); 66 - parm_list.addr = (unsigned long) addr ; 65 + memcpy(parm_list.aci_grp, all_groups, NAME_LEN); 66 + ASCEBC(parm_list.aci_grp, NAME_LEN); 67 + parm_list.addr = (unsigned long)addr; 67 68 parm_list.size = size; 68 69 parm_list.fmt = 0x02; 69 - memset(parm_list.aci_grp, 0x40, NAME_LEN); 70 70 rc = -1; 71 71 72 72 diag_stat_inc(DIAG_STAT_X2FC);
+2 -2
arch/s390/include/asm/uaccess.h
··· 47 47 int __put_user_bad(void) __attribute__((noreturn)); 48 48 int __get_user_bad(void) __attribute__((noreturn)); 49 49 50 - #ifdef CONFIG_HAVE_MARCH_Z10_FEATURES 51 - 52 50 union oac { 53 51 unsigned int val; 54 52 struct { ··· 68 70 } oac2; 69 71 }; 70 72 }; 73 + 74 + #ifdef CONFIG_HAVE_MARCH_Z10_FEATURES 71 75 72 76 #define __put_get_user_asm(to, from, size, oac_spec) \ 73 77 ({ \
+17 -18
arch/s390/kernel/module.c
··· 33 33 #define DEBUGP(fmt , ...) 34 34 #endif 35 35 36 - #define PLT_ENTRY_SIZE 20 36 + #define PLT_ENTRY_SIZE 22 37 37 38 38 void *module_alloc(unsigned long size) 39 39 { ··· 341 341 case R_390_PLTOFF32: /* 32 bit offset from GOT to PLT. */ 342 342 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */ 343 343 if (info->plt_initialized == 0) { 344 - unsigned int insn[5]; 345 - unsigned int *ip = me->core_layout.base + 346 - me->arch.plt_offset + 347 - info->plt_offset; 344 + unsigned char insn[PLT_ENTRY_SIZE]; 345 + char *plt_base; 346 + char *ip; 348 347 349 - insn[0] = 0x0d10e310; /* basr 1,0 */ 350 - insn[1] = 0x100a0004; /* lg 1,10(1) */ 348 + plt_base = me->core_layout.base + me->arch.plt_offset; 349 + ip = plt_base + info->plt_offset; 350 + *(int *)insn = 0x0d10e310; /* basr 1,0 */ 351 + *(int *)&insn[4] = 0x100c0004; /* lg 1,12(1) */ 351 352 if (IS_ENABLED(CONFIG_EXPOLINE) && !nospec_disable) { 352 - unsigned int *ij; 353 - ij = me->core_layout.base + 354 - me->arch.plt_offset + 355 - me->arch.plt_size - PLT_ENTRY_SIZE; 356 - insn[2] = 0xa7f40000 + /* j __jump_r1 */ 357 - (unsigned int)(u16) 358 - (((unsigned long) ij - 8 - 359 - (unsigned long) ip) / 2); 353 + char *jump_r1; 354 + 355 + jump_r1 = plt_base + me->arch.plt_size - 356 + PLT_ENTRY_SIZE; 357 + /* brcl 0xf,__jump_r1 */ 358 + *(short *)&insn[8] = 0xc0f4; 359 + *(int *)&insn[10] = (jump_r1 - (ip + 8)) / 2; 360 360 } else { 361 - insn[2] = 0x07f10000; /* br %r1 */ 361 + *(int *)&insn[8] = 0x07f10000; /* br %r1 */ 362 362 } 363 - insn[3] = (unsigned int) (val >> 32); 364 - insn[4] = (unsigned int) val; 363 + *(long *)&insn[14] = val; 365 364 366 365 write(ip, insn, sizeof(insn)); 367 366 info->plt_initialized = 1;
+22 -5
arch/s390/kernel/nmi.c
··· 264 264 /* Validate vector registers */ 265 265 union ctlreg0 cr0; 266 266 267 - if (!mci.vr) { 267 + /* 268 + * The vector validity must only be checked if not running a 269 + * KVM guest. For KVM guests the machine check is forwarded by 270 + * KVM and it is the responsibility of the guest to take 271 + * appropriate actions. The host vector or FPU values have been 272 + * saved by KVM and will be restored by KVM. 273 + */ 274 + if (!mci.vr && !test_cpu_flag(CIF_MCCK_GUEST)) { 268 275 /* 269 276 * Vector registers can't be restored. If the kernel 270 277 * currently uses vector registers the system is ··· 314 307 if (cr2.gse) { 315 308 if (!mci.gs) { 316 309 /* 317 - * Guarded storage register can't be restored and 318 - * the current processes uses guarded storage. 319 - * It has to be terminated. 310 + * 2 cases: 311 + * - machine check in kernel or userspace 312 + * - machine check while running SIE (KVM guest) 313 + * For kernel or userspace the userspace values of 314 + * guarded storage control can not be recreated, the 315 + * process must be terminated. 316 + * For SIE the guest values of guarded storage can not 317 + * be recreated. This is either due to a bug or due to 318 + * GS being disabled in the guest. The guest will be 319 + * notified by KVM code and the guests machine check 320 + * handling must take care of this. The host values 321 + * are saved by KVM and are not affected. 320 322 */ 321 - kill_task = 1; 323 + if (!test_cpu_flag(CIF_MCCK_GUEST)) 324 + kill_task = 1; 322 325 } else { 323 326 load_gs_cb((struct gs_cb *)mcesa->guarded_storage_save_area); 324 327 }
+3
arch/s390/lib/Makefile
··· 17 17 obj-$(CONFIG_S390_UNWIND_SELFTEST) += test_unwind.o 18 18 CFLAGS_test_unwind.o += -fno-optimize-sibling-calls 19 19 20 + obj-$(CONFIG_S390_MODULES_SANITY_TEST) += test_modules.o 21 + obj-$(CONFIG_S390_MODULES_SANITY_TEST_HELPERS) += test_modules_helpers.o 22 + 20 23 lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
+35
arch/s390/lib/test_modules.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + 3 + #include <kunit/test.h> 4 + #include <linux/module.h> 5 + 6 + #include "test_modules.h" 7 + 8 + #define DECLARE_RETURN(i) int test_modules_return_ ## i(void) 9 + REPEAT_10000(DECLARE_RETURN); 10 + 11 + /* 12 + * Test that modules with many relocations are loaded properly. 13 + */ 14 + static void test_modules_many_vmlinux_relocs(struct kunit *test) 15 + { 16 + int result = 0; 17 + 18 + #define CALL_RETURN(i) result += test_modules_return_ ## i() 19 + REPEAT_10000(CALL_RETURN); 20 + KUNIT_ASSERT_EQ(test, result, 49995000); 21 + } 22 + 23 + static struct kunit_case modules_testcases[] = { 24 + KUNIT_CASE(test_modules_many_vmlinux_relocs), 25 + {} 26 + }; 27 + 28 + static struct kunit_suite modules_test_suite = { 29 + .name = "modules_test_s390", 30 + .test_cases = modules_testcases, 31 + }; 32 + 33 + kunit_test_suites(&modules_test_suite); 34 + 35 + MODULE_LICENSE("GPL");
+50
arch/s390/lib/test_modules.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 + #ifndef TEST_MODULES_H 3 + #define TEST_MODULES_H 4 + 5 + #define __REPEAT_10000_3(f, x) \ 6 + f(x ## 0); \ 7 + f(x ## 1); \ 8 + f(x ## 2); \ 9 + f(x ## 3); \ 10 + f(x ## 4); \ 11 + f(x ## 5); \ 12 + f(x ## 6); \ 13 + f(x ## 7); \ 14 + f(x ## 8); \ 15 + f(x ## 9) 16 + #define __REPEAT_10000_2(f, x) \ 17 + __REPEAT_10000_3(f, x ## 0); \ 18 + __REPEAT_10000_3(f, x ## 1); \ 19 + __REPEAT_10000_3(f, x ## 2); \ 20 + __REPEAT_10000_3(f, x ## 3); \ 21 + __REPEAT_10000_3(f, x ## 4); \ 22 + __REPEAT_10000_3(f, x ## 5); \ 23 + __REPEAT_10000_3(f, x ## 6); \ 24 + __REPEAT_10000_3(f, x ## 7); \ 25 + __REPEAT_10000_3(f, x ## 8); \ 26 + __REPEAT_10000_3(f, x ## 9) 27 + #define __REPEAT_10000_1(f, x) \ 28 + __REPEAT_10000_2(f, x ## 0); \ 29 + __REPEAT_10000_2(f, x ## 1); \ 30 + __REPEAT_10000_2(f, x ## 2); \ 31 + __REPEAT_10000_2(f, x ## 3); \ 32 + __REPEAT_10000_2(f, x ## 4); \ 33 + __REPEAT_10000_2(f, x ## 5); \ 34 + __REPEAT_10000_2(f, x ## 6); \ 35 + __REPEAT_10000_2(f, x ## 7); \ 36 + __REPEAT_10000_2(f, x ## 8); \ 37 + __REPEAT_10000_2(f, x ## 9) 38 + #define REPEAT_10000(f) \ 39 + __REPEAT_10000_1(f, 0); \ 40 + __REPEAT_10000_1(f, 1); \ 41 + __REPEAT_10000_1(f, 2); \ 42 + __REPEAT_10000_1(f, 3); \ 43 + __REPEAT_10000_1(f, 4); \ 44 + __REPEAT_10000_1(f, 5); \ 45 + __REPEAT_10000_1(f, 6); \ 46 + __REPEAT_10000_1(f, 7); \ 47 + __REPEAT_10000_1(f, 8); \ 48 + __REPEAT_10000_1(f, 9) 49 + 50 + #endif
+13
arch/s390/lib/test_modules_helpers.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + 3 + #include <linux/export.h> 4 + 5 + #include "test_modules.h" 6 + 7 + #define DEFINE_RETURN(i) \ 8 + int test_modules_return_ ## i(void) \ 9 + { \ 10 + return 1 ## i - 10000; \ 11 + } \ 12 + EXPORT_SYMBOL_GPL(test_modules_return_ ## i) 13 + REPEAT_10000(DEFINE_RETURN);
+1
arch/x86/Kconfig
··· 186 186 select HAVE_CONTEXT_TRACKING_OFFSTACK if HAVE_CONTEXT_TRACKING 187 187 select HAVE_C_RECORDMCOUNT 188 188 select HAVE_OBJTOOL_MCOUNT if STACK_VALIDATION 189 + select HAVE_BUILDTIME_MCOUNT_SORT 189 190 select HAVE_DEBUG_KMEMLEAK 190 191 select HAVE_DMA_CONTIGUOUS 191 192 select HAVE_DYNAMIC_FTRACE
+15
arch/x86/events/intel/core.c
··· 6236 6236 pmu->num_counters = x86_pmu.num_counters; 6237 6237 pmu->num_counters_fixed = x86_pmu.num_counters_fixed; 6238 6238 } 6239 + 6240 + /* 6241 + * Quirk: For some Alder Lake machine, when all E-cores are disabled in 6242 + * a BIOS, the leaf 0xA will enumerate all counters of P-cores. However, 6243 + * the X86_FEATURE_HYBRID_CPU is still set. The above codes will 6244 + * mistakenly add extra counters for P-cores. Correct the number of 6245 + * counters here. 6246 + */ 6247 + if ((pmu->num_counters > 8) || (pmu->num_counters_fixed > 4)) { 6248 + pmu->num_counters = x86_pmu.num_counters; 6249 + pmu->num_counters_fixed = x86_pmu.num_counters_fixed; 6250 + } 6251 + 6239 6252 pmu->max_pebs_events = min_t(unsigned, MAX_PEBS_EVENTS, pmu->num_counters); 6240 6253 pmu->unconstrained = (struct event_constraint) 6241 6254 __EVENT_CONSTRAINT(0, (1ULL << pmu->num_counters) - 1, ··· 6353 6340 } 6354 6341 6355 6342 if (x86_pmu.lbr_nr) { 6343 + intel_pmu_lbr_init(); 6344 + 6356 6345 pr_cont("%d-deep LBR, ", x86_pmu.lbr_nr); 6357 6346 6358 6347 /* only support branch_stack snapshot for perfmon >= v2 */
+99 -65
arch/x86/events/intel/lbr.c
··· 8 8 9 9 #include "../perf_event.h" 10 10 11 - static const enum { 12 - LBR_EIP_FLAGS = 1, 13 - LBR_TSX = 2, 14 - } lbr_desc[LBR_FORMAT_MAX_KNOWN + 1] = { 15 - [LBR_FORMAT_EIP_FLAGS] = LBR_EIP_FLAGS, 16 - [LBR_FORMAT_EIP_FLAGS2] = LBR_EIP_FLAGS | LBR_TSX, 17 - }; 18 - 19 11 /* 20 12 * Intel LBR_SELECT bits 21 13 * Intel Vol3a, April 2011, Section 16.7 Table 16-10 ··· 235 243 for (i = 0; i < x86_pmu.lbr_nr; i++) { 236 244 wrmsrl(x86_pmu.lbr_from + i, 0); 237 245 wrmsrl(x86_pmu.lbr_to + i, 0); 238 - if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO) 246 + if (x86_pmu.lbr_has_info) 239 247 wrmsrl(x86_pmu.lbr_info + i, 0); 240 248 } 241 249 } ··· 297 305 */ 298 306 static inline bool lbr_from_signext_quirk_needed(void) 299 307 { 300 - int lbr_format = x86_pmu.intel_cap.lbr_format; 301 308 bool tsx_support = boot_cpu_has(X86_FEATURE_HLE) || 302 309 boot_cpu_has(X86_FEATURE_RTM); 303 310 304 - return !tsx_support && (lbr_desc[lbr_format] & LBR_TSX); 311 + return !tsx_support && x86_pmu.lbr_has_tsx; 305 312 } 306 313 307 314 static DEFINE_STATIC_KEY_FALSE(lbr_from_quirk_key); ··· 418 427 419 428 void intel_pmu_lbr_restore(void *ctx) 420 429 { 421 - bool need_info = x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO; 422 430 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); 423 431 struct x86_perf_task_context *task_ctx = ctx; 424 - int i; 425 - unsigned lbr_idx, mask; 432 + bool need_info = x86_pmu.lbr_has_info; 426 433 u64 tos = task_ctx->tos; 434 + unsigned lbr_idx, mask; 435 + int i; 427 436 428 437 mask = x86_pmu.lbr_nr - 1; 429 438 for (i = 0; i < task_ctx->valid_lbrs; i++) { ··· 435 444 lbr_idx = (tos - i) & mask; 436 445 wrlbr_from(lbr_idx, 0); 437 446 wrlbr_to(lbr_idx, 0); 438 - if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO) 447 + if (need_info) 439 448 wrlbr_info(lbr_idx, 0); 440 449 } 441 450 ··· 510 519 511 520 void intel_pmu_lbr_save(void *ctx) 512 521 { 513 - bool need_info = x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO; 514 522 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); 515 523 struct x86_perf_task_context *task_ctx = ctx; 524 + bool need_info = x86_pmu.lbr_has_info; 516 525 unsigned lbr_idx, mask; 517 526 u64 tos; 518 527 int i; ··· 807 816 { 808 817 bool need_info = false, call_stack = false; 809 818 unsigned long mask = x86_pmu.lbr_nr - 1; 810 - int lbr_format = x86_pmu.intel_cap.lbr_format; 811 819 u64 tos = intel_pmu_lbr_tos(); 812 820 int i; 813 821 int out = 0; ··· 821 831 for (i = 0; i < num; i++) { 822 832 unsigned long lbr_idx = (tos - i) & mask; 823 833 u64 from, to, mis = 0, pred = 0, in_tx = 0, abort = 0; 824 - int skip = 0; 825 834 u16 cycles = 0; 826 - int lbr_flags = lbr_desc[lbr_format]; 827 835 828 836 from = rdlbr_from(lbr_idx, NULL); 829 837 to = rdlbr_to(lbr_idx, NULL); ··· 833 845 if (call_stack && !from) 834 846 break; 835 847 836 - if (lbr_format == LBR_FORMAT_INFO && need_info) { 837 - u64 info; 848 + if (x86_pmu.lbr_has_info) { 849 + if (need_info) { 850 + u64 info; 838 851 839 - info = rdlbr_info(lbr_idx, NULL); 840 - mis = !!(info & LBR_INFO_MISPRED); 841 - pred = !mis; 842 - in_tx = !!(info & LBR_INFO_IN_TX); 843 - abort = !!(info & LBR_INFO_ABORT); 844 - cycles = (info & LBR_INFO_CYCLES); 845 - } 852 + info = rdlbr_info(lbr_idx, NULL); 853 + mis = !!(info & LBR_INFO_MISPRED); 854 + pred = !mis; 855 + cycles = (info & LBR_INFO_CYCLES); 856 + if (x86_pmu.lbr_has_tsx) { 857 + in_tx = !!(info & LBR_INFO_IN_TX); 858 + abort = !!(info & LBR_INFO_ABORT); 859 + } 860 + } 861 + } else { 862 + int skip = 0; 846 863 847 - if (lbr_format == LBR_FORMAT_TIME) { 848 - mis = !!(from & LBR_FROM_FLAG_MISPRED); 849 - pred = !mis; 850 - skip = 1; 851 - cycles = ((to >> 48) & LBR_INFO_CYCLES); 864 + if (x86_pmu.lbr_from_flags) { 865 + mis = !!(from & LBR_FROM_FLAG_MISPRED); 866 + pred = !mis; 867 + skip = 1; 868 + } 869 + if (x86_pmu.lbr_has_tsx) { 870 + in_tx = !!(from & LBR_FROM_FLAG_IN_TX); 871 + abort = !!(from & LBR_FROM_FLAG_ABORT); 872 + skip = 3; 873 + } 874 + from = (u64)((((s64)from) << skip) >> skip); 852 875 853 - to = (u64)((((s64)to) << 16) >> 16); 876 + if (x86_pmu.lbr_to_cycles) { 877 + cycles = ((to >> 48) & LBR_INFO_CYCLES); 878 + to = (u64)((((s64)to) << 16) >> 16); 879 + } 854 880 } 855 - 856 - if (lbr_flags & LBR_EIP_FLAGS) { 857 - mis = !!(from & LBR_FROM_FLAG_MISPRED); 858 - pred = !mis; 859 - skip = 1; 860 - } 861 - if (lbr_flags & LBR_TSX) { 862 - in_tx = !!(from & LBR_FROM_FLAG_IN_TX); 863 - abort = !!(from & LBR_FROM_FLAG_ABORT); 864 - skip = 3; 865 - } 866 - from = (u64)((((s64)from) << skip) >> skip); 867 881 868 882 /* 869 883 * Some CPUs report duplicated abort records, ··· 893 903 cpuc->lbr_stack.hw_idx = tos; 894 904 } 895 905 906 + static DEFINE_STATIC_KEY_FALSE(x86_lbr_mispred); 907 + static DEFINE_STATIC_KEY_FALSE(x86_lbr_cycles); 908 + static DEFINE_STATIC_KEY_FALSE(x86_lbr_type); 909 + 896 910 static __always_inline int get_lbr_br_type(u64 info) 897 911 { 898 - if (!static_cpu_has(X86_FEATURE_ARCH_LBR) || !x86_pmu.lbr_br_type) 899 - return 0; 912 + int type = 0; 900 913 901 - return (info & LBR_INFO_BR_TYPE) >> LBR_INFO_BR_TYPE_OFFSET; 914 + if (static_branch_likely(&x86_lbr_type)) 915 + type = (info & LBR_INFO_BR_TYPE) >> LBR_INFO_BR_TYPE_OFFSET; 916 + 917 + return type; 902 918 } 903 919 904 920 static __always_inline bool get_lbr_mispred(u64 info) 905 921 { 906 - if (static_cpu_has(X86_FEATURE_ARCH_LBR) && !x86_pmu.lbr_mispred) 907 - return 0; 922 + bool mispred = 0; 908 923 909 - return !!(info & LBR_INFO_MISPRED); 910 - } 924 + if (static_branch_likely(&x86_lbr_mispred)) 925 + mispred = !!(info & LBR_INFO_MISPRED); 911 926 912 - static __always_inline bool get_lbr_predicted(u64 info) 913 - { 914 - if (static_cpu_has(X86_FEATURE_ARCH_LBR) && !x86_pmu.lbr_mispred) 915 - return 0; 916 - 917 - return !(info & LBR_INFO_MISPRED); 927 + return mispred; 918 928 } 919 929 920 930 static __always_inline u16 get_lbr_cycles(u64 info) 921 931 { 922 - if (static_cpu_has(X86_FEATURE_ARCH_LBR) && 923 - !(x86_pmu.lbr_timed_lbr && info & LBR_INFO_CYC_CNT_VALID)) 924 - return 0; 932 + u16 cycles = info & LBR_INFO_CYCLES; 925 933 926 - return info & LBR_INFO_CYCLES; 934 + if (static_cpu_has(X86_FEATURE_ARCH_LBR) && 935 + (!static_branch_likely(&x86_lbr_cycles) || 936 + !(info & LBR_INFO_CYC_CNT_VALID))) 937 + cycles = 0; 938 + 939 + return cycles; 927 940 } 928 941 929 942 static void intel_pmu_store_lbr(struct cpu_hw_events *cpuc, ··· 954 961 e->from = from; 955 962 e->to = to; 956 963 e->mispred = get_lbr_mispred(info); 957 - e->predicted = get_lbr_predicted(info); 964 + e->predicted = !e->mispred; 958 965 e->in_tx = !!(info & LBR_INFO_IN_TX); 959 966 e->abort = !!(info & LBR_INFO_ABORT); 960 967 e->cycles = get_lbr_cycles(info); ··· 1113 1120 1114 1121 if ((br_type & PERF_SAMPLE_BRANCH_NO_CYCLES) && 1115 1122 (br_type & PERF_SAMPLE_BRANCH_NO_FLAGS) && 1116 - (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)) 1123 + x86_pmu.lbr_has_info) 1117 1124 reg->config |= LBR_NO_INFO; 1118 1125 1119 1126 return 0; ··· 1699 1706 x86_pmu.intel_cap.lbr_format = LBR_FORMAT_EIP_FLAGS; 1700 1707 } 1701 1708 1709 + void intel_pmu_lbr_init(void) 1710 + { 1711 + switch (x86_pmu.intel_cap.lbr_format) { 1712 + case LBR_FORMAT_EIP_FLAGS2: 1713 + x86_pmu.lbr_has_tsx = 1; 1714 + fallthrough; 1715 + case LBR_FORMAT_EIP_FLAGS: 1716 + x86_pmu.lbr_from_flags = 1; 1717 + break; 1718 + 1719 + case LBR_FORMAT_INFO: 1720 + x86_pmu.lbr_has_tsx = 1; 1721 + fallthrough; 1722 + case LBR_FORMAT_INFO2: 1723 + x86_pmu.lbr_has_info = 1; 1724 + break; 1725 + 1726 + case LBR_FORMAT_TIME: 1727 + x86_pmu.lbr_from_flags = 1; 1728 + x86_pmu.lbr_to_cycles = 1; 1729 + break; 1730 + } 1731 + 1732 + if (x86_pmu.lbr_has_info) { 1733 + /* 1734 + * Only used in combination with baseline pebs. 1735 + */ 1736 + static_branch_enable(&x86_lbr_mispred); 1737 + static_branch_enable(&x86_lbr_cycles); 1738 + } 1739 + } 1740 + 1702 1741 /* 1703 1742 * LBR state size is variable based on the max number of registers. 1704 1743 * This calculates the expected state size, which should match ··· 1751 1726 * Check the LBR state with the corresponding software structure. 1752 1727 * Disable LBR XSAVES support if the size doesn't match. 1753 1728 */ 1729 + if (xfeature_size(XFEATURE_LBR) == 0) 1730 + return false; 1731 + 1754 1732 if (WARN_ON(xfeature_size(XFEATURE_LBR) != get_lbr_state_size())) 1755 1733 return false; 1756 1734 ··· 1793 1765 x86_pmu.lbr_br_type = ecx.split.lbr_br_type; 1794 1766 x86_pmu.lbr_nr = lbr_nr; 1795 1767 1768 + if (x86_pmu.lbr_mispred) 1769 + static_branch_enable(&x86_lbr_mispred); 1770 + if (x86_pmu.lbr_timed_lbr) 1771 + static_branch_enable(&x86_lbr_cycles); 1772 + if (x86_pmu.lbr_br_type) 1773 + static_branch_enable(&x86_lbr_type); 1796 1774 1797 1775 arch_lbr_xsave = is_arch_lbr_xsave_available(); 1798 1776 if (arch_lbr_xsave) {
+1 -1
arch/x86/events/intel/uncore.c
··· 1762 1762 1763 1763 static const struct intel_uncore_init_fun adl_uncore_init __initconst = { 1764 1764 .cpu_init = adl_uncore_cpu_init, 1765 - .mmio_init = tgl_uncore_mmio_init, 1765 + .mmio_init = adl_uncore_mmio_init, 1766 1766 }; 1767 1767 1768 1768 static const struct intel_uncore_init_fun icx_uncore_init __initconst = {
+2 -1
arch/x86/events/intel/uncore.h
··· 584 584 void nhm_uncore_cpu_init(void); 585 585 void skl_uncore_cpu_init(void); 586 586 void icl_uncore_cpu_init(void); 587 - void adl_uncore_cpu_init(void); 588 587 void tgl_uncore_cpu_init(void); 588 + void adl_uncore_cpu_init(void); 589 589 void tgl_uncore_mmio_init(void); 590 590 void tgl_l_uncore_mmio_init(void); 591 + void adl_uncore_mmio_init(void); 591 592 int snb_pci2phy_map_init(int devid); 592 593 593 594 /* uncore_snbep.c */
+2 -2
arch/x86/events/intel/uncore_discovery.c
··· 494 494 writel(0, box->io_addr); 495 495 } 496 496 497 - static void intel_generic_uncore_mmio_enable_event(struct intel_uncore_box *box, 498 - struct perf_event *event) 497 + void intel_generic_uncore_mmio_enable_event(struct intel_uncore_box *box, 498 + struct perf_event *event) 499 499 { 500 500 struct hw_perf_event *hwc = &event->hw; 501 501
+2
arch/x86/events/intel/uncore_discovery.h
··· 139 139 void intel_generic_uncore_mmio_enable_box(struct intel_uncore_box *box); 140 140 void intel_generic_uncore_mmio_disable_event(struct intel_uncore_box *box, 141 141 struct perf_event *event); 142 + void intel_generic_uncore_mmio_enable_event(struct intel_uncore_box *box, 143 + struct perf_event *event); 142 144 143 145 void intel_generic_uncore_pci_init_box(struct intel_uncore_box *box); 144 146 void intel_generic_uncore_pci_disable_box(struct intel_uncore_box *box);
+213 -1
arch/x86/events/intel/uncore_snb.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* Nehalem/SandBridge/Haswell/Broadwell/Skylake uncore support */ 3 3 #include "uncore.h" 4 + #include "uncore_discovery.h" 4 5 5 6 /* Uncore IMC PCI IDs */ 6 7 #define PCI_DEVICE_ID_INTEL_SNB_IMC 0x0100 ··· 65 64 #define PCI_DEVICE_ID_INTEL_RKL_2_IMC 0x4c53 66 65 #define PCI_DEVICE_ID_INTEL_ADL_1_IMC 0x4660 67 66 #define PCI_DEVICE_ID_INTEL_ADL_2_IMC 0x4641 67 + #define PCI_DEVICE_ID_INTEL_ADL_3_IMC 0x4601 68 + #define PCI_DEVICE_ID_INTEL_ADL_4_IMC 0x4602 69 + #define PCI_DEVICE_ID_INTEL_ADL_5_IMC 0x4609 70 + #define PCI_DEVICE_ID_INTEL_ADL_6_IMC 0x460a 71 + #define PCI_DEVICE_ID_INTEL_ADL_7_IMC 0x4621 72 + #define PCI_DEVICE_ID_INTEL_ADL_8_IMC 0x4623 73 + #define PCI_DEVICE_ID_INTEL_ADL_9_IMC 0x4629 74 + #define PCI_DEVICE_ID_INTEL_ADL_10_IMC 0x4637 75 + #define PCI_DEVICE_ID_INTEL_ADL_11_IMC 0x463b 76 + #define PCI_DEVICE_ID_INTEL_ADL_12_IMC 0x4648 77 + #define PCI_DEVICE_ID_INTEL_ADL_13_IMC 0x4649 78 + #define PCI_DEVICE_ID_INTEL_ADL_14_IMC 0x4650 79 + #define PCI_DEVICE_ID_INTEL_ADL_15_IMC 0x4668 80 + #define PCI_DEVICE_ID_INTEL_ADL_16_IMC 0x4670 68 81 69 82 /* SNB event control */ 70 83 #define SNB_UNC_CTL_EV_SEL_MASK 0x000000ff ··· 170 155 171 156 DEFINE_UNCORE_FORMAT_ATTR(event, event, "config:0-7"); 172 157 DEFINE_UNCORE_FORMAT_ATTR(umask, umask, "config:8-15"); 158 + DEFINE_UNCORE_FORMAT_ATTR(chmask, chmask, "config:8-11"); 173 159 DEFINE_UNCORE_FORMAT_ATTR(edge, edge, "config:18"); 174 160 DEFINE_UNCORE_FORMAT_ATTR(inv, inv, "config:23"); 175 161 DEFINE_UNCORE_FORMAT_ATTR(cmask5, cmask, "config:24-28"); ··· 1350 1334 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_2_IMC), 1351 1335 .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1352 1336 }, 1337 + { /* IMC */ 1338 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_3_IMC), 1339 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1340 + }, 1341 + { /* IMC */ 1342 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_4_IMC), 1343 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1344 + }, 1345 + { /* IMC */ 1346 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_5_IMC), 1347 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1348 + }, 1349 + { /* IMC */ 1350 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_6_IMC), 1351 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1352 + }, 1353 + { /* IMC */ 1354 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_7_IMC), 1355 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1356 + }, 1357 + { /* IMC */ 1358 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_8_IMC), 1359 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1360 + }, 1361 + { /* IMC */ 1362 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_9_IMC), 1363 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1364 + }, 1365 + { /* IMC */ 1366 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_10_IMC), 1367 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1368 + }, 1369 + { /* IMC */ 1370 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_11_IMC), 1371 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1372 + }, 1373 + { /* IMC */ 1374 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_12_IMC), 1375 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1376 + }, 1377 + { /* IMC */ 1378 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_13_IMC), 1379 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1380 + }, 1381 + { /* IMC */ 1382 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_14_IMC), 1383 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1384 + }, 1385 + { /* IMC */ 1386 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_15_IMC), 1387 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1388 + }, 1389 + { /* IMC */ 1390 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ADL_16_IMC), 1391 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), 1392 + }, 1353 1393 { /* end: all zeroes */ } 1354 1394 }; 1355 1395 ··· 1462 1390 #define TGL_UNCORE_MMIO_IMC_MEM_OFFSET 0x10000 1463 1391 #define TGL_UNCORE_PCI_IMC_MAP_SIZE 0xe000 1464 1392 1465 - static void tgl_uncore_imc_freerunning_init_box(struct intel_uncore_box *box) 1393 + static void __uncore_imc_init_box(struct intel_uncore_box *box, 1394 + unsigned int base_offset) 1466 1395 { 1467 1396 struct pci_dev *pdev = tgl_uncore_get_mc_dev(); 1468 1397 struct intel_uncore_pmu *pmu = box->pmu; ··· 1490 1417 addr |= ((resource_size_t)mch_bar << 32); 1491 1418 #endif 1492 1419 1420 + addr += base_offset; 1493 1421 box->io_addr = ioremap(addr, type->mmio_map_size); 1494 1422 if (!box->io_addr) 1495 1423 pr_warn("perf uncore: Failed to ioremap for %s.\n", type->name); 1424 + } 1425 + 1426 + static void tgl_uncore_imc_freerunning_init_box(struct intel_uncore_box *box) 1427 + { 1428 + __uncore_imc_init_box(box, 0); 1496 1429 } 1497 1430 1498 1431 static struct intel_uncore_ops tgl_uncore_imc_freerunning_ops = { ··· 1548 1469 } 1549 1470 1550 1471 /* end of Tiger Lake MMIO uncore support */ 1472 + 1473 + /* Alder Lake MMIO uncore support */ 1474 + #define ADL_UNCORE_IMC_BASE 0xd900 1475 + #define ADL_UNCORE_IMC_MAP_SIZE 0x200 1476 + #define ADL_UNCORE_IMC_CTR 0xe8 1477 + #define ADL_UNCORE_IMC_CTRL 0xd0 1478 + #define ADL_UNCORE_IMC_GLOBAL_CTL 0xc0 1479 + #define ADL_UNCORE_IMC_BOX_CTL 0xc4 1480 + #define ADL_UNCORE_IMC_FREERUNNING_BASE 0xd800 1481 + #define ADL_UNCORE_IMC_FREERUNNING_MAP_SIZE 0x100 1482 + 1483 + #define ADL_UNCORE_IMC_CTL_FRZ (1 << 0) 1484 + #define ADL_UNCORE_IMC_CTL_RST_CTRL (1 << 1) 1485 + #define ADL_UNCORE_IMC_CTL_RST_CTRS (1 << 2) 1486 + #define ADL_UNCORE_IMC_CTL_INT (ADL_UNCORE_IMC_CTL_RST_CTRL | \ 1487 + ADL_UNCORE_IMC_CTL_RST_CTRS) 1488 + 1489 + static void adl_uncore_imc_init_box(struct intel_uncore_box *box) 1490 + { 1491 + __uncore_imc_init_box(box, ADL_UNCORE_IMC_BASE); 1492 + 1493 + /* The global control in MC1 can control both MCs. */ 1494 + if (box->io_addr && (box->pmu->pmu_idx == 1)) 1495 + writel(ADL_UNCORE_IMC_CTL_INT, box->io_addr + ADL_UNCORE_IMC_GLOBAL_CTL); 1496 + } 1497 + 1498 + static void adl_uncore_mmio_disable_box(struct intel_uncore_box *box) 1499 + { 1500 + if (!box->io_addr) 1501 + return; 1502 + 1503 + writel(ADL_UNCORE_IMC_CTL_FRZ, box->io_addr + uncore_mmio_box_ctl(box)); 1504 + } 1505 + 1506 + static void adl_uncore_mmio_enable_box(struct intel_uncore_box *box) 1507 + { 1508 + if (!box->io_addr) 1509 + return; 1510 + 1511 + writel(0, box->io_addr + uncore_mmio_box_ctl(box)); 1512 + } 1513 + 1514 + static struct intel_uncore_ops adl_uncore_mmio_ops = { 1515 + .init_box = adl_uncore_imc_init_box, 1516 + .exit_box = uncore_mmio_exit_box, 1517 + .disable_box = adl_uncore_mmio_disable_box, 1518 + .enable_box = adl_uncore_mmio_enable_box, 1519 + .disable_event = intel_generic_uncore_mmio_disable_event, 1520 + .enable_event = intel_generic_uncore_mmio_enable_event, 1521 + .read_counter = uncore_mmio_read_counter, 1522 + }; 1523 + 1524 + #define ADL_UNC_CTL_CHMASK_MASK 0x00000f00 1525 + #define ADL_UNC_IMC_EVENT_MASK (SNB_UNC_CTL_EV_SEL_MASK | \ 1526 + ADL_UNC_CTL_CHMASK_MASK | \ 1527 + SNB_UNC_CTL_EDGE_DET) 1528 + 1529 + static struct attribute *adl_uncore_imc_formats_attr[] = { 1530 + &format_attr_event.attr, 1531 + &format_attr_chmask.attr, 1532 + &format_attr_edge.attr, 1533 + NULL, 1534 + }; 1535 + 1536 + static const struct attribute_group adl_uncore_imc_format_group = { 1537 + .name = "format", 1538 + .attrs = adl_uncore_imc_formats_attr, 1539 + }; 1540 + 1541 + static struct intel_uncore_type adl_uncore_imc = { 1542 + .name = "imc", 1543 + .num_counters = 5, 1544 + .num_boxes = 2, 1545 + .perf_ctr_bits = 64, 1546 + .perf_ctr = ADL_UNCORE_IMC_CTR, 1547 + .event_ctl = ADL_UNCORE_IMC_CTRL, 1548 + .event_mask = ADL_UNC_IMC_EVENT_MASK, 1549 + .box_ctl = ADL_UNCORE_IMC_BOX_CTL, 1550 + .mmio_offset = 0, 1551 + .mmio_map_size = ADL_UNCORE_IMC_MAP_SIZE, 1552 + .ops = &adl_uncore_mmio_ops, 1553 + .format_group = &adl_uncore_imc_format_group, 1554 + }; 1555 + 1556 + enum perf_adl_uncore_imc_freerunning_types { 1557 + ADL_MMIO_UNCORE_IMC_DATA_TOTAL, 1558 + ADL_MMIO_UNCORE_IMC_DATA_READ, 1559 + ADL_MMIO_UNCORE_IMC_DATA_WRITE, 1560 + ADL_MMIO_UNCORE_IMC_FREERUNNING_TYPE_MAX 1561 + }; 1562 + 1563 + static struct freerunning_counters adl_uncore_imc_freerunning[] = { 1564 + [ADL_MMIO_UNCORE_IMC_DATA_TOTAL] = { 0x40, 0x0, 0x0, 1, 64 }, 1565 + [ADL_MMIO_UNCORE_IMC_DATA_READ] = { 0x58, 0x0, 0x0, 1, 64 }, 1566 + [ADL_MMIO_UNCORE_IMC_DATA_WRITE] = { 0xA0, 0x0, 0x0, 1, 64 }, 1567 + }; 1568 + 1569 + static void adl_uncore_imc_freerunning_init_box(struct intel_uncore_box *box) 1570 + { 1571 + __uncore_imc_init_box(box, ADL_UNCORE_IMC_FREERUNNING_BASE); 1572 + } 1573 + 1574 + static struct intel_uncore_ops adl_uncore_imc_freerunning_ops = { 1575 + .init_box = adl_uncore_imc_freerunning_init_box, 1576 + .exit_box = uncore_mmio_exit_box, 1577 + .read_counter = uncore_mmio_read_counter, 1578 + .hw_config = uncore_freerunning_hw_config, 1579 + }; 1580 + 1581 + static struct intel_uncore_type adl_uncore_imc_free_running = { 1582 + .name = "imc_free_running", 1583 + .num_counters = 3, 1584 + .num_boxes = 2, 1585 + .num_freerunning_types = ADL_MMIO_UNCORE_IMC_FREERUNNING_TYPE_MAX, 1586 + .mmio_map_size = ADL_UNCORE_IMC_FREERUNNING_MAP_SIZE, 1587 + .freerunning = adl_uncore_imc_freerunning, 1588 + .ops = &adl_uncore_imc_freerunning_ops, 1589 + .event_descs = tgl_uncore_imc_events, 1590 + .format_group = &tgl_uncore_imc_format_group, 1591 + }; 1592 + 1593 + static struct intel_uncore_type *adl_mmio_uncores[] = { 1594 + &adl_uncore_imc, 1595 + &adl_uncore_imc_free_running, 1596 + NULL 1597 + }; 1598 + 1599 + void adl_uncore_mmio_init(void) 1600 + { 1601 + uncore_mmio_uncores = adl_mmio_uncores; 1602 + } 1603 + 1604 + /* end of Alder Lake MMIO uncore support */
+1 -1
arch/x86/events/intel/uncore_snbep.c
··· 5482 5482 .fixed_ctr_bits = 48, 5483 5483 .fixed_ctr = SNR_IMC_MMIO_PMON_FIXED_CTR, 5484 5484 .fixed_ctl = SNR_IMC_MMIO_PMON_FIXED_CTL, 5485 - .event_descs = hswep_uncore_imc_events, 5485 + .event_descs = snr_uncore_imc_events, 5486 5486 .perf_ctr = SNR_IMC_MMIO_PMON_CTR0, 5487 5487 .event_ctl = SNR_IMC_MMIO_PMON_CTL0, 5488 5488 .event_mask = SNBEP_PMON_RAW_EVENT_MASK,
+9 -1
arch/x86/events/perf_event.h
··· 215 215 LBR_FORMAT_EIP_FLAGS2 = 0x04, 216 216 LBR_FORMAT_INFO = 0x05, 217 217 LBR_FORMAT_TIME = 0x06, 218 - LBR_FORMAT_MAX_KNOWN = LBR_FORMAT_TIME, 218 + LBR_FORMAT_INFO2 = 0x07, 219 + LBR_FORMAT_MAX_KNOWN = LBR_FORMAT_INFO2, 219 220 }; 220 221 221 222 enum { ··· 841 840 bool lbr_double_abort; /* duplicated lbr aborts */ 842 841 bool lbr_pt_coexist; /* (LBR|BTS) may coexist with PT */ 843 842 843 + unsigned int lbr_has_info:1; 844 + unsigned int lbr_has_tsx:1; 845 + unsigned int lbr_from_flags:1; 846 + unsigned int lbr_to_cycles:1; 847 + 844 848 /* 845 849 * Intel Architectural LBR CPUID Enumeration 846 850 */ ··· 1397 1391 void intel_pmu_lbr_init_skl(void); 1398 1392 1399 1393 void intel_pmu_lbr_init_knl(void); 1394 + 1395 + void intel_pmu_lbr_init(void); 1400 1396 1401 1397 void intel_pmu_arch_lbr_init(void); 1402 1398
+6 -3
arch/x86/events/rapl.c
··· 536 536 * - perf_msr_probe(PERF_RAPL_MAX) 537 537 * - want to use same event codes across both architectures 538 538 */ 539 - static struct perf_msr amd_rapl_msrs[PERF_RAPL_MAX] = { 540 - [PERF_RAPL_PKG] = { MSR_AMD_PKG_ENERGY_STATUS, &rapl_events_pkg_group, test_msr }, 539 + static struct perf_msr amd_rapl_msrs[] = { 540 + [PERF_RAPL_PP0] = { 0, &rapl_events_cores_group, 0, false, 0 }, 541 + [PERF_RAPL_PKG] = { MSR_AMD_PKG_ENERGY_STATUS, &rapl_events_pkg_group, test_msr, false, RAPL_MSR_MASK }, 542 + [PERF_RAPL_RAM] = { 0, &rapl_events_ram_group, 0, false, 0 }, 543 + [PERF_RAPL_PP1] = { 0, &rapl_events_gpu_group, 0, false, 0 }, 544 + [PERF_RAPL_PSYS] = { 0, &rapl_events_psys_group, 0, false, 0 }, 541 545 }; 542 - 543 546 544 547 static int rapl_cpu_offline(unsigned int cpu) 545 548 {
+3 -2
arch/x86/include/asm/kvm_host.h
··· 1483 1483 1484 1484 int (*get_msr_feature)(struct kvm_msr_entry *entry); 1485 1485 1486 - bool (*can_emulate_instruction)(struct kvm_vcpu *vcpu, void *insn, int insn_len); 1486 + bool (*can_emulate_instruction)(struct kvm_vcpu *vcpu, int emul_type, 1487 + void *insn, int insn_len); 1487 1488 1488 1489 bool (*apic_init_signal_blocked)(struct kvm_vcpu *vcpu); 1489 1490 int (*enable_direct_tlbflush)(struct kvm_vcpu *vcpu); ··· 1497 1496 }; 1498 1497 1499 1498 struct kvm_x86_nested_ops { 1499 + void (*leave_nested)(struct kvm_vcpu *vcpu); 1500 1500 int (*check_events)(struct kvm_vcpu *vcpu); 1501 1501 bool (*hv_timer_pending)(struct kvm_vcpu *vcpu); 1502 1502 void (*triple_fault)(struct kvm_vcpu *vcpu); ··· 1863 1861 int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu); 1864 1862 int kvm_cpu_get_interrupt(struct kvm_vcpu *v); 1865 1863 void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event); 1866 - void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu); 1867 1864 1868 1865 int kvm_pv_send_ipi(struct kvm *kvm, unsigned long ipi_bitmap_low, 1869 1866 unsigned long ipi_bitmap_high, u32 min,
+3
arch/x86/include/uapi/asm/kvm.h
··· 452 452 453 453 #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001 454 454 455 + /* attributes for system fd (group 0) */ 456 + #define KVM_X86_XCOMP_GUEST_SUPP 0 457 + 455 458 struct kvm_vmx_nested_state_data { 456 459 __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; 457 460 __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
+1 -1
arch/x86/kernel/cpu/mce/amd.c
··· 423 423 u32 hi, lo; 424 424 425 425 /* sysfs write might race against an offline operation */ 426 - if (this_cpu_read(threshold_banks)) 426 + if (!this_cpu_read(threshold_banks) && !tr->set_lvt_off) 427 427 return; 428 428 429 429 rdmsr(tr->b->address, lo, hi);
+1
arch/x86/kernel/cpu/mce/intel.c
··· 486 486 case INTEL_FAM6_BROADWELL_X: 487 487 case INTEL_FAM6_SKYLAKE_X: 488 488 case INTEL_FAM6_ICELAKE_X: 489 + case INTEL_FAM6_ICELAKE_D: 489 490 case INTEL_FAM6_SAPPHIRERAPIDS_X: 490 491 case INTEL_FAM6_XEON_PHI_KNL: 491 492 case INTEL_FAM6_XEON_PHI_KNM:
+55 -35
arch/x86/kvm/cpuid.c
··· 133 133 orig = &vcpu->arch.cpuid_entries[i]; 134 134 if (e2[i].function != orig->function || 135 135 e2[i].index != orig->index || 136 + e2[i].flags != orig->flags || 136 137 e2[i].eax != orig->eax || e2[i].ebx != orig->ebx || 137 138 e2[i].ecx != orig->ecx || e2[i].edx != orig->edx) 138 139 return -EINVAL; ··· 197 196 vcpu->arch.pv_cpuid.features = best->eax; 198 197 } 199 198 199 + /* 200 + * Calculate guest's supported XCR0 taking into account guest CPUID data and 201 + * supported_xcr0 (comprised of host configuration and KVM_SUPPORTED_XCR0). 202 + */ 203 + static u64 cpuid_get_supported_xcr0(struct kvm_cpuid_entry2 *entries, int nent) 204 + { 205 + struct kvm_cpuid_entry2 *best; 206 + 207 + best = cpuid_entry2_find(entries, nent, 0xd, 0); 208 + if (!best) 209 + return 0; 210 + 211 + return (best->eax | ((u64)best->edx << 32)) & supported_xcr0; 212 + } 213 + 200 214 static void __kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 *entries, 201 215 int nent) 202 216 { 203 217 struct kvm_cpuid_entry2 *best; 218 + u64 guest_supported_xcr0 = cpuid_get_supported_xcr0(entries, nent); 204 219 205 220 best = cpuid_entry2_find(entries, nent, 1, 0); 206 221 if (best) { ··· 255 238 vcpu->arch.ia32_misc_enable_msr & 256 239 MSR_IA32_MISC_ENABLE_MWAIT); 257 240 } 241 + 242 + /* 243 + * Bits 127:0 of the allowed SECS.ATTRIBUTES (CPUID.0x12.0x1) enumerate 244 + * the supported XSAVE Feature Request Mask (XFRM), i.e. the enclave's 245 + * requested XCR0 value. The enclave's XFRM must be a subset of XCRO 246 + * at the time of EENTER, thus adjust the allowed XFRM by the guest's 247 + * supported XCR0. Similar to XCR0 handling, FP and SSE are forced to 248 + * '1' even on CPUs that don't support XSAVE. 249 + */ 250 + best = cpuid_entry2_find(entries, nent, 0x12, 0x1); 251 + if (best) { 252 + best->ecx &= guest_supported_xcr0 & 0xffffffff; 253 + best->edx &= guest_supported_xcr0 >> 32; 254 + best->ecx |= XFEATURE_MASK_FPSSE; 255 + } 258 256 } 259 257 260 258 void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu) ··· 293 261 kvm_apic_set_version(vcpu); 294 262 } 295 263 296 - best = kvm_find_cpuid_entry(vcpu, 0xD, 0); 297 - if (!best) 298 - vcpu->arch.guest_supported_xcr0 = 0; 299 - else 300 - vcpu->arch.guest_supported_xcr0 = 301 - (best->eax | ((u64)best->edx << 32)) & supported_xcr0; 302 - 303 - /* 304 - * Bits 127:0 of the allowed SECS.ATTRIBUTES (CPUID.0x12.0x1) enumerate 305 - * the supported XSAVE Feature Request Mask (XFRM), i.e. the enclave's 306 - * requested XCR0 value. The enclave's XFRM must be a subset of XCRO 307 - * at the time of EENTER, thus adjust the allowed XFRM by the guest's 308 - * supported XCR0. Similar to XCR0 handling, FP and SSE are forced to 309 - * '1' even on CPUs that don't support XSAVE. 310 - */ 311 - best = kvm_find_cpuid_entry(vcpu, 0x12, 0x1); 312 - if (best) { 313 - best->ecx &= vcpu->arch.guest_supported_xcr0 & 0xffffffff; 314 - best->edx &= vcpu->arch.guest_supported_xcr0 >> 32; 315 - best->ecx |= XFEATURE_MASK_FPSSE; 316 - } 264 + vcpu->arch.guest_supported_xcr0 = 265 + cpuid_get_supported_xcr0(vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent); 317 266 318 267 kvm_update_pv_runtime(vcpu); 319 268 ··· 359 346 * KVM_SET_CPUID{,2} again. To support this legacy behavior, check 360 347 * whether the supplied CPUID data is equal to what's already set. 361 348 */ 362 - if (vcpu->arch.last_vmentry_cpu != -1) 363 - return kvm_cpuid_check_equal(vcpu, e2, nent); 349 + if (vcpu->arch.last_vmentry_cpu != -1) { 350 + r = kvm_cpuid_check_equal(vcpu, e2, nent); 351 + if (r) 352 + return r; 353 + 354 + kvfree(e2); 355 + return 0; 356 + } 364 357 365 358 r = kvm_check_cpuid(vcpu, e2, nent); 366 359 if (r) ··· 906 887 } 907 888 break; 908 889 case 0xd: { 909 - u64 guest_perm = xstate_get_guest_group_perm(); 890 + u64 permitted_xcr0 = supported_xcr0 & xstate_get_guest_group_perm(); 891 + u64 permitted_xss = supported_xss; 910 892 911 - entry->eax &= supported_xcr0 & guest_perm; 912 - entry->ebx = xstate_required_size(supported_xcr0, false); 893 + entry->eax &= permitted_xcr0; 894 + entry->ebx = xstate_required_size(permitted_xcr0, false); 913 895 entry->ecx = entry->ebx; 914 - entry->edx &= (supported_xcr0 & guest_perm) >> 32; 915 - if (!supported_xcr0) 896 + entry->edx &= permitted_xcr0 >> 32; 897 + if (!permitted_xcr0) 916 898 break; 917 899 918 900 entry = do_host_cpuid(array, function, 1); ··· 922 902 923 903 cpuid_entry_override(entry, CPUID_D_1_EAX); 924 904 if (entry->eax & (F(XSAVES)|F(XSAVEC))) 925 - entry->ebx = xstate_required_size(supported_xcr0 | supported_xss, 905 + entry->ebx = xstate_required_size(permitted_xcr0 | permitted_xss, 926 906 true); 927 907 else { 928 - WARN_ON_ONCE(supported_xss != 0); 908 + WARN_ON_ONCE(permitted_xss != 0); 929 909 entry->ebx = 0; 930 910 } 931 - entry->ecx &= supported_xss; 932 - entry->edx &= supported_xss >> 32; 911 + entry->ecx &= permitted_xss; 912 + entry->edx &= permitted_xss >> 32; 933 913 934 914 for (i = 2; i < 64; ++i) { 935 915 bool s_state; 936 - if (supported_xcr0 & BIT_ULL(i)) 916 + if (permitted_xcr0 & BIT_ULL(i)) 937 917 s_state = false; 938 - else if (supported_xss & BIT_ULL(i)) 918 + else if (permitted_xss & BIT_ULL(i)) 939 919 s_state = true; 940 920 else 941 921 continue; ··· 949 929 * invalid sub-leafs. Only valid sub-leafs should 950 930 * reach this point, and they should have a non-zero 951 931 * save state size. Furthermore, check whether the 952 - * processor agrees with supported_xcr0/supported_xss 932 + * processor agrees with permitted_xcr0/permitted_xss 953 933 * on whether this is an XCR0- or IA32_XSS-managed area. 954 934 */ 955 935 if (WARN_ON_ONCE(!entry->eax || (entry->ecx & 0x1) != s_state)) {
+1 -1
arch/x86/kvm/lapic.c
··· 2629 2629 kvm_apic_set_version(vcpu); 2630 2630 2631 2631 apic_update_ppr(apic); 2632 - hrtimer_cancel(&apic->lapic_timer.timer); 2632 + cancel_apic_timer(apic); 2633 2633 apic->lapic_timer.expired_tscdeadline = 0; 2634 2634 apic_update_lvtt(apic); 2635 2635 apic_manage_nmi_watchdog(apic, kvm_lapic_get_reg(apic, APIC_LVT0));
+5 -4
arch/x86/kvm/svm/nested.c
··· 983 983 /* 984 984 * Forcibly leave nested mode in order to be able to reset the VCPU later on. 985 985 */ 986 - void svm_leave_nested(struct vcpu_svm *svm) 986 + void svm_leave_nested(struct kvm_vcpu *vcpu) 987 987 { 988 - struct kvm_vcpu *vcpu = &svm->vcpu; 988 + struct vcpu_svm *svm = to_svm(vcpu); 989 989 990 990 if (is_guest_mode(vcpu)) { 991 991 svm->nested.nested_run_pending = 0; ··· 1411 1411 return -EINVAL; 1412 1412 1413 1413 if (!(kvm_state->flags & KVM_STATE_NESTED_GUEST_MODE)) { 1414 - svm_leave_nested(svm); 1414 + svm_leave_nested(vcpu); 1415 1415 svm_set_gif(svm, !!(kvm_state->flags & KVM_STATE_NESTED_GIF_SET)); 1416 1416 return 0; 1417 1417 } ··· 1478 1478 */ 1479 1479 1480 1480 if (is_guest_mode(vcpu)) 1481 - svm_leave_nested(svm); 1481 + svm_leave_nested(vcpu); 1482 1482 else 1483 1483 svm->nested.vmcb02.ptr->save = svm->vmcb01.ptr->save; 1484 1484 ··· 1532 1532 } 1533 1533 1534 1534 struct kvm_x86_nested_ops svm_nested_ops = { 1535 + .leave_nested = svm_leave_nested, 1535 1536 .check_events = svm_check_nested_events, 1536 1537 .triple_fault = nested_svm_triple_fault, 1537 1538 .get_nested_state_pages = svm_get_nested_state_pages,
+7 -2
arch/x86/kvm/svm/sev.c
··· 2100 2100 if (!sev_enabled || !npt_enabled) 2101 2101 goto out; 2102 2102 2103 - /* Does the CPU support SEV? */ 2104 - if (!boot_cpu_has(X86_FEATURE_SEV)) 2103 + /* 2104 + * SEV must obviously be supported in hardware. Sanity check that the 2105 + * CPU supports decode assists, which is mandatory for SEV guests to 2106 + * support instruction emulation. 2107 + */ 2108 + if (!boot_cpu_has(X86_FEATURE_SEV) || 2109 + WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS))) 2105 2110 goto out; 2106 2111 2107 2112 /* Retrieve SEV CPUID information */
+124 -57
arch/x86/kvm/svm/svm.c
··· 290 290 291 291 if ((old_efer & EFER_SVME) != (efer & EFER_SVME)) { 292 292 if (!(efer & EFER_SVME)) { 293 - svm_leave_nested(svm); 293 + svm_leave_nested(vcpu); 294 294 svm_set_gif(svm, true); 295 295 /* #GP intercept is still needed for vmware backdoor */ 296 296 if (!enable_vmware_backdoor) ··· 312 312 return ret; 313 313 } 314 314 315 - if (svm_gp_erratum_intercept) 315 + /* 316 + * Never intercept #GP for SEV guests, KVM can't 317 + * decrypt guest memory to workaround the erratum. 318 + */ 319 + if (svm_gp_erratum_intercept && !sev_guest(vcpu->kvm)) 316 320 set_exception_intercept(svm, GP_VECTOR); 317 321 } 318 322 } ··· 1014 1010 * Guest access to VMware backdoor ports could legitimately 1015 1011 * trigger #GP because of TSS I/O permission bitmap. 1016 1012 * We intercept those #GP and allow access to them anyway 1017 - * as VMware does. 1013 + * as VMware does. Don't intercept #GP for SEV guests as KVM can't 1014 + * decrypt guest memory to decode the faulting instruction. 1018 1015 */ 1019 - if (enable_vmware_backdoor) 1016 + if (enable_vmware_backdoor && !sev_guest(vcpu->kvm)) 1020 1017 set_exception_intercept(svm, GP_VECTOR); 1021 1018 1022 1019 svm_set_intercept(svm, INTERCEPT_INTR); ··· 2096 2091 if (error_code) 2097 2092 goto reinject; 2098 2093 2099 - /* All SVM instructions expect page aligned RAX */ 2100 - if (svm->vmcb->save.rax & ~PAGE_MASK) 2101 - goto reinject; 2102 - 2103 2094 /* Decode the instruction for usage later */ 2104 2095 if (x86_decode_emulated_instruction(vcpu, 0, NULL, 0) != EMULATION_OK) 2105 2096 goto reinject; ··· 2113 2112 if (!is_guest_mode(vcpu)) 2114 2113 return kvm_emulate_instruction(vcpu, 2115 2114 EMULTYPE_VMWARE_GP | EMULTYPE_NO_DECODE); 2116 - } else 2115 + } else { 2116 + /* All SVM instructions expect page aligned RAX */ 2117 + if (svm->vmcb->save.rax & ~PAGE_MASK) 2118 + goto reinject; 2119 + 2117 2120 return emulate_svm_instr(vcpu, opcode); 2121 + } 2118 2122 2119 2123 reinject: 2120 2124 kvm_queue_exception_e(vcpu, GP_VECTOR, error_code); ··· 4258 4252 } 4259 4253 } 4260 4254 4261 - static bool svm_can_emulate_instruction(struct kvm_vcpu *vcpu, void *insn, int insn_len) 4255 + static bool svm_can_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type, 4256 + void *insn, int insn_len) 4262 4257 { 4263 4258 bool smep, smap, is_user; 4264 4259 unsigned long cr4; 4260 + u64 error_code; 4261 + 4262 + /* Emulation is always possible when KVM has access to all guest state. */ 4263 + if (!sev_guest(vcpu->kvm)) 4264 + return true; 4265 + 4266 + /* #UD and #GP should never be intercepted for SEV guests. */ 4267 + WARN_ON_ONCE(emul_type & (EMULTYPE_TRAP_UD | 4268 + EMULTYPE_TRAP_UD_FORCED | 4269 + EMULTYPE_VMWARE_GP)); 4265 4270 4266 4271 /* 4267 - * When the guest is an SEV-ES guest, emulation is not possible. 4272 + * Emulation is impossible for SEV-ES guests as KVM doesn't have access 4273 + * to guest register state. 4268 4274 */ 4269 4275 if (sev_es_guest(vcpu->kvm)) 4270 4276 return false; 4271 4277 4272 4278 /* 4273 - * Detect and workaround Errata 1096 Fam_17h_00_0Fh. 4274 - * 4275 - * Errata: 4276 - * When CPU raise #NPF on guest data access and vCPU CR4.SMAP=1, it is 4277 - * possible that CPU microcode implementing DecodeAssist will fail 4278 - * to read bytes of instruction which caused #NPF. In this case, 4279 - * GuestIntrBytes field of the VMCB on a VMEXIT will incorrectly 4280 - * return 0 instead of the correct guest instruction bytes. 4281 - * 4282 - * This happens because CPU microcode reading instruction bytes 4283 - * uses a special opcode which attempts to read data using CPL=0 4284 - * privileges. The microcode reads CS:RIP and if it hits a SMAP 4285 - * fault, it gives up and returns no instruction bytes. 4286 - * 4287 - * Detection: 4288 - * We reach here in case CPU supports DecodeAssist, raised #NPF and 4289 - * returned 0 in GuestIntrBytes field of the VMCB. 4290 - * First, errata can only be triggered in case vCPU CR4.SMAP=1. 4291 - * Second, if vCPU CR4.SMEP=1, errata could only be triggered 4292 - * in case vCPU CPL==3 (Because otherwise guest would have triggered 4293 - * a SMEP fault instead of #NPF). 4294 - * Otherwise, vCPU CR4.SMEP=0, errata could be triggered by any vCPU CPL. 4295 - * As most guests enable SMAP if they have also enabled SMEP, use above 4296 - * logic in order to attempt minimize false-positive of detecting errata 4297 - * while still preserving all cases semantic correctness. 4298 - * 4299 - * Workaround: 4300 - * To determine what instruction the guest was executing, the hypervisor 4301 - * will have to decode the instruction at the instruction pointer. 4302 - * 4303 - * In non SEV guest, hypervisor will be able to read the guest 4304 - * memory to decode the instruction pointer when insn_len is zero 4305 - * so we return true to indicate that decoding is possible. 4306 - * 4307 - * But in the SEV guest, the guest memory is encrypted with the 4308 - * guest specific key and hypervisor will not be able to decode the 4309 - * instruction pointer so we will not able to workaround it. Lets 4310 - * print the error and request to kill the guest. 4279 + * Emulation is possible if the instruction is already decoded, e.g. 4280 + * when completing I/O after returning from userspace. 4311 4281 */ 4312 - if (likely(!insn || insn_len)) 4282 + if (emul_type & EMULTYPE_NO_DECODE) 4313 4283 return true; 4314 4284 4315 4285 /* 4316 - * If RIP is invalid, go ahead with emulation which will cause an 4317 - * internal error exit. 4286 + * Emulation is possible for SEV guests if and only if a prefilled 4287 + * buffer containing the bytes of the intercepted instruction is 4288 + * available. SEV guest memory is encrypted with a guest specific key 4289 + * and cannot be decrypted by KVM, i.e. KVM would read cyphertext and 4290 + * decode garbage. 4291 + * 4292 + * Inject #UD if KVM reached this point without an instruction buffer. 4293 + * In practice, this path should never be hit by a well-behaved guest, 4294 + * e.g. KVM doesn't intercept #UD or #GP for SEV guests, but this path 4295 + * is still theoretically reachable, e.g. via unaccelerated fault-like 4296 + * AVIC access, and needs to be handled by KVM to avoid putting the 4297 + * guest into an infinite loop. Injecting #UD is somewhat arbitrary, 4298 + * but its the least awful option given lack of insight into the guest. 4318 4299 */ 4319 - if (!kvm_vcpu_gfn_to_memslot(vcpu, kvm_rip_read(vcpu) >> PAGE_SHIFT)) 4300 + if (unlikely(!insn)) { 4301 + kvm_queue_exception(vcpu, UD_VECTOR); 4302 + return false; 4303 + } 4304 + 4305 + /* 4306 + * Emulate for SEV guests if the insn buffer is not empty. The buffer 4307 + * will be empty if the DecodeAssist microcode cannot fetch bytes for 4308 + * the faulting instruction because the code fetch itself faulted, e.g. 4309 + * the guest attempted to fetch from emulated MMIO or a guest page 4310 + * table used to translate CS:RIP resides in emulated MMIO. 4311 + */ 4312 + if (likely(insn_len)) 4320 4313 return true; 4314 + 4315 + /* 4316 + * Detect and workaround Errata 1096 Fam_17h_00_0Fh. 4317 + * 4318 + * Errata: 4319 + * When CPU raises #NPF on guest data access and vCPU CR4.SMAP=1, it is 4320 + * possible that CPU microcode implementing DecodeAssist will fail to 4321 + * read guest memory at CS:RIP and vmcb.GuestIntrBytes will incorrectly 4322 + * be '0'. This happens because microcode reads CS:RIP using a _data_ 4323 + * loap uop with CPL=0 privileges. If the load hits a SMAP #PF, ucode 4324 + * gives up and does not fill the instruction bytes buffer. 4325 + * 4326 + * As above, KVM reaches this point iff the VM is an SEV guest, the CPU 4327 + * supports DecodeAssist, a #NPF was raised, KVM's page fault handler 4328 + * triggered emulation (e.g. for MMIO), and the CPU returned 0 in the 4329 + * GuestIntrBytes field of the VMCB. 4330 + * 4331 + * This does _not_ mean that the erratum has been encountered, as the 4332 + * DecodeAssist will also fail if the load for CS:RIP hits a legitimate 4333 + * #PF, e.g. if the guest attempt to execute from emulated MMIO and 4334 + * encountered a reserved/not-present #PF. 4335 + * 4336 + * To hit the erratum, the following conditions must be true: 4337 + * 1. CR4.SMAP=1 (obviously). 4338 + * 2. CR4.SMEP=0 || CPL=3. If SMEP=1 and CPL<3, the erratum cannot 4339 + * have been hit as the guest would have encountered a SMEP 4340 + * violation #PF, not a #NPF. 4341 + * 3. The #NPF is not due to a code fetch, in which case failure to 4342 + * retrieve the instruction bytes is legitimate (see abvoe). 4343 + * 4344 + * In addition, don't apply the erratum workaround if the #NPF occurred 4345 + * while translating guest page tables (see below). 4346 + */ 4347 + error_code = to_svm(vcpu)->vmcb->control.exit_info_1; 4348 + if (error_code & (PFERR_GUEST_PAGE_MASK | PFERR_FETCH_MASK)) 4349 + goto resume_guest; 4321 4350 4322 4351 cr4 = kvm_read_cr4(vcpu); 4323 4352 smep = cr4 & X86_CR4_SMEP; 4324 4353 smap = cr4 & X86_CR4_SMAP; 4325 4354 is_user = svm_get_cpl(vcpu) == 3; 4326 4355 if (smap && (!smep || is_user)) { 4327 - if (!sev_guest(vcpu->kvm)) 4328 - return true; 4329 - 4330 4356 pr_err_ratelimited("KVM: SEV Guest triggered AMD Erratum 1096\n"); 4331 - kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu); 4357 + 4358 + /* 4359 + * If the fault occurred in userspace, arbitrarily inject #GP 4360 + * to avoid killing the guest and to hopefully avoid confusing 4361 + * the guest kernel too much, e.g. injecting #PF would not be 4362 + * coherent with respect to the guest's page tables. Request 4363 + * triple fault if the fault occurred in the kernel as there's 4364 + * no fault that KVM can inject without confusing the guest. 4365 + * In practice, the triple fault is moot as no sane SEV kernel 4366 + * will execute from user memory while also running with SMAP=1. 4367 + */ 4368 + if (is_user) 4369 + kvm_inject_gp(vcpu, 0); 4370 + else 4371 + kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu); 4332 4372 } 4333 4373 4374 + resume_guest: 4375 + /* 4376 + * If the erratum was not hit, simply resume the guest and let it fault 4377 + * again. While awful, e.g. the vCPU may get stuck in an infinite loop 4378 + * if the fault is at CPL=0, it's the lesser of all evils. Exiting to 4379 + * userspace will kill the guest, and letting the emulator read garbage 4380 + * will yield random behavior and potentially corrupt the guest. 4381 + * 4382 + * Simply resuming the guest is technically not a violation of the SEV 4383 + * architecture. AMD's APM states that all code fetches and page table 4384 + * accesses for SEV guest are encrypted, regardless of the C-Bit. The 4385 + * APM also states that encrypted accesses to MMIO are "ignored", but 4386 + * doesn't explicitly define "ignored", i.e. doing nothing and letting 4387 + * the guest spin is technically "ignoring" the access. 4388 + */ 4334 4389 return false; 4335 4390 } 4336 4391
+1 -6
arch/x86/kvm/svm/svm.h
··· 304 304 & ~VMCB_ALWAYS_DIRTY_MASK; 305 305 } 306 306 307 - static inline bool vmcb_is_clean(struct vmcb *vmcb, int bit) 308 - { 309 - return (vmcb->control.clean & (1 << bit)); 310 - } 311 - 312 307 static inline void vmcb_mark_dirty(struct vmcb *vmcb, int bit) 313 308 { 314 309 vmcb->control.clean &= ~(1 << bit); ··· 520 525 521 526 int enter_svm_guest_mode(struct kvm_vcpu *vcpu, 522 527 u64 vmcb_gpa, struct vmcb *vmcb12, bool from_vmrun); 523 - void svm_leave_nested(struct vcpu_svm *svm); 528 + void svm_leave_nested(struct kvm_vcpu *vcpu); 524 529 void svm_free_nested(struct vcpu_svm *svm); 525 530 int svm_allocate_nested(struct vcpu_svm *svm); 526 531 int nested_svm_vmrun(struct kvm_vcpu *vcpu);
+4 -8
arch/x86/kvm/svm/svm_onhyperv.h
··· 46 46 if (npt_enabled && 47 47 ms_hyperv.nested_features & HV_X64_NESTED_ENLIGHTENED_TLB) 48 48 hve->hv_enlightenments_control.enlightened_npt_tlb = 1; 49 + 50 + if (ms_hyperv.nested_features & HV_X64_NESTED_MSR_BITMAP) 51 + hve->hv_enlightenments_control.msr_bitmap = 1; 49 52 } 50 53 51 54 static inline void svm_hv_hardware_setup(void) ··· 86 83 struct hv_enlightenments *hve = 87 84 (struct hv_enlightenments *)vmcb->control.reserved_sw; 88 85 89 - /* 90 - * vmcb can be NULL if called during early vcpu init. 91 - * And its okay not to mark vmcb dirty during vcpu init 92 - * as we mark it dirty unconditionally towards end of vcpu 93 - * init phase. 94 - */ 95 - if (vmcb_is_clean(vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS) && 96 - hve->hv_enlightenments_control.msr_bitmap) 86 + if (hve->hv_enlightenments_control.msr_bitmap) 97 87 vmcb_mark_dirty(vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS); 98 88 } 99 89
-1
arch/x86/kvm/vmx/capabilities.h
··· 54 54 55 55 struct vmcs_config { 56 56 int size; 57 - int order; 58 57 u32 basic_cap; 59 58 u32 revision_id; 60 59 u32 pin_based_exec_ctrl;
+2 -2
arch/x86/kvm/vmx/evmcs.c
··· 12 12 13 13 DEFINE_STATIC_KEY_FALSE(enable_evmcs); 14 14 15 - #if IS_ENABLED(CONFIG_HYPERV) 16 - 17 15 #define EVMCS1_OFFSET(x) offsetof(struct hv_enlightened_vmcs, x) 18 16 #define EVMCS1_FIELD(number, name, clean_field)[ROL16(number, 6)] = \ 19 17 {EVMCS1_OFFSET(name), clean_field} ··· 294 296 }; 295 297 const unsigned int nr_evmcs_1_fields = ARRAY_SIZE(vmcs_field_to_evmcs_1); 296 298 299 + #if IS_ENABLED(CONFIG_HYPERV) 297 300 __init void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf) 298 301 { 299 302 vmcs_conf->pin_based_exec_ctrl &= ~EVMCS1_UNSUPPORTED_PINCTRL; ··· 361 362 case MSR_IA32_VMX_PROCBASED_CTLS2: 362 363 ctl_high &= ~EVMCS1_UNSUPPORTED_2NDEXEC; 363 364 break; 365 + case MSR_IA32_VMX_TRUE_PINBASED_CTLS: 364 366 case MSR_IA32_VMX_PINBASED_CTLS: 365 367 ctl_high &= ~EVMCS1_UNSUPPORTED_PINCTRL; 366 368 break;
+39 -9
arch/x86/kvm/vmx/evmcs.h
··· 59 59 SECONDARY_EXEC_SHADOW_VMCS | \ 60 60 SECONDARY_EXEC_TSC_SCALING | \ 61 61 SECONDARY_EXEC_PAUSE_LOOP_EXITING) 62 - #define EVMCS1_UNSUPPORTED_VMEXIT_CTRL (VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL) 62 + #define EVMCS1_UNSUPPORTED_VMEXIT_CTRL \ 63 + (VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL | \ 64 + VM_EXIT_SAVE_VMX_PREEMPTION_TIMER) 63 65 #define EVMCS1_UNSUPPORTED_VMENTRY_CTRL (VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL) 64 66 #define EVMCS1_UNSUPPORTED_VMFUNC (VMX_VMFUNC_EPTP_SWITCHING) 65 - 66 - #if IS_ENABLED(CONFIG_HYPERV) 67 67 68 68 struct evmcs_field { 69 69 u16 offset; ··· 73 73 extern const struct evmcs_field vmcs_field_to_evmcs_1[]; 74 74 extern const unsigned int nr_evmcs_1_fields; 75 75 76 - static __always_inline int get_evmcs_offset(unsigned long field, 77 - u16 *clean_field) 76 + static __always_inline int evmcs_field_offset(unsigned long field, 77 + u16 *clean_field) 78 78 { 79 79 unsigned int index = ROL16(field, 6); 80 80 const struct evmcs_field *evmcs_field; 81 81 82 - if (unlikely(index >= nr_evmcs_1_fields)) { 83 - WARN_ONCE(1, "KVM: accessing unsupported EVMCS field %lx\n", 84 - field); 82 + if (unlikely(index >= nr_evmcs_1_fields)) 85 83 return -ENOENT; 86 - } 87 84 88 85 evmcs_field = &vmcs_field_to_evmcs_1[index]; 86 + 87 + /* 88 + * Use offset=0 to detect holes in eVMCS. This offset belongs to 89 + * 'revision_id' but this field has no encoding and is supposed to 90 + * be accessed directly. 91 + */ 92 + if (unlikely(!evmcs_field->offset)) 93 + return -ENOENT; 89 94 90 95 if (clean_field) 91 96 *clean_field = evmcs_field->clean_field; 92 97 93 98 return evmcs_field->offset; 99 + } 100 + 101 + static inline u64 evmcs_read_any(struct hv_enlightened_vmcs *evmcs, 102 + unsigned long field, u16 offset) 103 + { 104 + /* 105 + * vmcs12_read_any() doesn't care whether the supplied structure 106 + * is 'struct vmcs12' or 'struct hv_enlightened_vmcs' as it takes 107 + * the exact offset of the required field, use it for convenience 108 + * here. 109 + */ 110 + return vmcs12_read_any((void *)evmcs, field, offset); 111 + } 112 + 113 + #if IS_ENABLED(CONFIG_HYPERV) 114 + 115 + static __always_inline int get_evmcs_offset(unsigned long field, 116 + u16 *clean_field) 117 + { 118 + int offset = evmcs_field_offset(field, clean_field); 119 + 120 + WARN_ONCE(offset < 0, "KVM: accessing unsupported EVMCS field %lx\n", 121 + field); 122 + 123 + return offset; 94 124 } 95 125 96 126 static __always_inline void evmcs_write64(unsigned long field, u64 value)
+54 -28
arch/x86/kvm/vmx/nested.c
··· 7 7 #include <asm/mmu_context.h> 8 8 9 9 #include "cpuid.h" 10 + #include "evmcs.h" 10 11 #include "hyperv.h" 11 12 #include "mmu.h" 12 13 #include "nested.h" ··· 4852 4851 struct loaded_vmcs *loaded_vmcs = vmx->loaded_vmcs; 4853 4852 4854 4853 /* 4855 - * We should allocate a shadow vmcs for vmcs01 only when L1 4856 - * executes VMXON and free it when L1 executes VMXOFF. 4857 - * As it is invalid to execute VMXON twice, we shouldn't reach 4858 - * here when vmcs01 already have an allocated shadow vmcs. 4854 + * KVM allocates a shadow VMCS only when L1 executes VMXON and frees it 4855 + * when L1 executes VMXOFF or the vCPU is forced out of nested 4856 + * operation. VMXON faults if the CPU is already post-VMXON, so it 4857 + * should be impossible to already have an allocated shadow VMCS. KVM 4858 + * doesn't support virtualization of VMCS shadowing, so vmcs01 should 4859 + * always be the loaded VMCS. 4859 4860 */ 4860 - WARN_ON(loaded_vmcs == &vmx->vmcs01 && loaded_vmcs->shadow_vmcs); 4861 + if (WARN_ON(loaded_vmcs != &vmx->vmcs01 || loaded_vmcs->shadow_vmcs)) 4862 + return loaded_vmcs->shadow_vmcs; 4861 4863 4862 - if (!loaded_vmcs->shadow_vmcs) { 4863 - loaded_vmcs->shadow_vmcs = alloc_vmcs(true); 4864 - if (loaded_vmcs->shadow_vmcs) 4865 - vmcs_clear(loaded_vmcs->shadow_vmcs); 4866 - } 4864 + loaded_vmcs->shadow_vmcs = alloc_vmcs(true); 4865 + if (loaded_vmcs->shadow_vmcs) 4866 + vmcs_clear(loaded_vmcs->shadow_vmcs); 4867 + 4867 4868 return loaded_vmcs->shadow_vmcs; 4868 4869 } 4869 4870 ··· 5102 5099 if (!nested_vmx_check_permission(vcpu)) 5103 5100 return 1; 5104 5101 5105 - /* 5106 - * In VMX non-root operation, when the VMCS-link pointer is INVALID_GPA, 5107 - * any VMREAD sets the ALU flags for VMfailInvalid. 5108 - */ 5109 - if (vmx->nested.current_vmptr == INVALID_GPA || 5110 - (is_guest_mode(vcpu) && 5111 - get_vmcs12(vcpu)->vmcs_link_pointer == INVALID_GPA)) 5112 - return nested_vmx_failInvalid(vcpu); 5113 - 5114 5102 /* Decode instruction info and find the field to read */ 5115 5103 field = kvm_register_read(vcpu, (((instr_info) >> 28) & 0xf)); 5116 5104 5117 - offset = vmcs_field_to_offset(field); 5118 - if (offset < 0) 5119 - return nested_vmx_fail(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT); 5105 + if (!evmptr_is_valid(vmx->nested.hv_evmcs_vmptr)) { 5106 + /* 5107 + * In VMX non-root operation, when the VMCS-link pointer is INVALID_GPA, 5108 + * any VMREAD sets the ALU flags for VMfailInvalid. 5109 + */ 5110 + if (vmx->nested.current_vmptr == INVALID_GPA || 5111 + (is_guest_mode(vcpu) && 5112 + get_vmcs12(vcpu)->vmcs_link_pointer == INVALID_GPA)) 5113 + return nested_vmx_failInvalid(vcpu); 5120 5114 5121 - if (!is_guest_mode(vcpu) && is_vmcs12_ext_field(field)) 5122 - copy_vmcs02_to_vmcs12_rare(vcpu, vmcs12); 5115 + offset = get_vmcs12_field_offset(field); 5116 + if (offset < 0) 5117 + return nested_vmx_fail(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT); 5123 5118 5124 - /* Read the field, zero-extended to a u64 value */ 5125 - value = vmcs12_read_any(vmcs12, field, offset); 5119 + if (!is_guest_mode(vcpu) && is_vmcs12_ext_field(field)) 5120 + copy_vmcs02_to_vmcs12_rare(vcpu, vmcs12); 5121 + 5122 + /* Read the field, zero-extended to a u64 value */ 5123 + value = vmcs12_read_any(vmcs12, field, offset); 5124 + } else { 5125 + /* 5126 + * Hyper-V TLFS (as of 6.0b) explicitly states, that while an 5127 + * enlightened VMCS is active VMREAD/VMWRITE instructions are 5128 + * unsupported. Unfortunately, certain versions of Windows 11 5129 + * don't comply with this requirement which is not enforced in 5130 + * genuine Hyper-V. Allow VMREAD from an enlightened VMCS as a 5131 + * workaround, as misbehaving guests will panic on VM-Fail. 5132 + * Note, enlightened VMCS is incompatible with shadow VMCS so 5133 + * all VMREADs from L2 should go to L1. 5134 + */ 5135 + if (WARN_ON_ONCE(is_guest_mode(vcpu))) 5136 + return nested_vmx_failInvalid(vcpu); 5137 + 5138 + offset = evmcs_field_offset(field, NULL); 5139 + if (offset < 0) 5140 + return nested_vmx_fail(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT); 5141 + 5142 + /* Read the field, zero-extended to a u64 value */ 5143 + value = evmcs_read_any(vmx->nested.hv_evmcs, field, offset); 5144 + } 5126 5145 5127 5146 /* 5128 5147 * Now copy part of this value to register or memory, as requested. ··· 5239 5214 5240 5215 field = kvm_register_read(vcpu, (((instr_info) >> 28) & 0xf)); 5241 5216 5242 - offset = vmcs_field_to_offset(field); 5217 + offset = get_vmcs12_field_offset(field); 5243 5218 if (offset < 0) 5244 5219 return nested_vmx_fail(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT); 5245 5220 ··· 6487 6462 max_idx = 0; 6488 6463 for (i = 0; i < nr_vmcs12_fields; i++) { 6489 6464 /* The vmcs12 table is very, very sparsely populated. */ 6490 - if (!vmcs_field_to_offset_table[i]) 6465 + if (!vmcs12_field_offsets[i]) 6491 6466 continue; 6492 6467 6493 6468 idx = vmcs_field_index(VMCS12_IDX_TO_ENC(i)); ··· 6796 6771 } 6797 6772 6798 6773 struct kvm_x86_nested_ops vmx_nested_ops = { 6774 + .leave_nested = vmx_leave_nested, 6799 6775 .check_events = vmx_check_nested_events, 6800 6776 .hv_timer_pending = nested_vmx_preemption_timer_pending, 6801 6777 .triple_fault = nested_vmx_triple_fault,
+2 -2
arch/x86/kvm/vmx/vmcs12.c
··· 8 8 FIELD(number, name), \ 9 9 [ROL16(number##_HIGH, 6)] = VMCS12_OFFSET(name) + sizeof(u32) 10 10 11 - const unsigned short vmcs_field_to_offset_table[] = { 11 + const unsigned short vmcs12_field_offsets[] = { 12 12 FIELD(VIRTUAL_PROCESSOR_ID, virtual_processor_id), 13 13 FIELD(POSTED_INTR_NV, posted_intr_nv), 14 14 FIELD(GUEST_ES_SELECTOR, guest_es_selector), ··· 151 151 FIELD(HOST_RSP, host_rsp), 152 152 FIELD(HOST_RIP, host_rip), 153 153 }; 154 - const unsigned int nr_vmcs12_fields = ARRAY_SIZE(vmcs_field_to_offset_table); 154 + const unsigned int nr_vmcs12_fields = ARRAY_SIZE(vmcs12_field_offsets);
+3 -3
arch/x86/kvm/vmx/vmcs12.h
··· 361 361 CHECK_OFFSET(guest_pml_index, 996); 362 362 } 363 363 364 - extern const unsigned short vmcs_field_to_offset_table[]; 364 + extern const unsigned short vmcs12_field_offsets[]; 365 365 extern const unsigned int nr_vmcs12_fields; 366 366 367 - static inline short vmcs_field_to_offset(unsigned long field) 367 + static inline short get_vmcs12_field_offset(unsigned long field) 368 368 { 369 369 unsigned short offset; 370 370 unsigned int index; ··· 377 377 return -ENOENT; 378 378 379 379 index = array_index_nospec(index, nr_vmcs12_fields); 380 - offset = vmcs_field_to_offset_table[index]; 380 + offset = vmcs12_field_offsets[index]; 381 381 if (offset == 0) 382 382 return -ENOENT; 383 383 return offset;
+38 -9
arch/x86/kvm/vmx/vmx.c
··· 1487 1487 return 0; 1488 1488 } 1489 1489 1490 - static bool vmx_can_emulate_instruction(struct kvm_vcpu *vcpu, void *insn, int insn_len) 1490 + static bool vmx_can_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type, 1491 + void *insn, int insn_len) 1491 1492 { 1492 1493 /* 1493 1494 * Emulation of instructions in SGX enclaves is impossible as RIP does 1494 - * not point tthe failing instruction, and even if it did, the code 1495 + * not point at the failing instruction, and even if it did, the code 1495 1496 * stream is inaccessible. Inject #UD instead of exiting to userspace 1496 1497 * so that guest userspace can't DoS the guest simply by triggering 1497 1498 * emulation (enclaves are CPL3 only). ··· 2604 2603 return -EIO; 2605 2604 2606 2605 vmcs_conf->size = vmx_msr_high & 0x1fff; 2607 - vmcs_conf->order = get_order(vmcs_conf->size); 2608 2606 vmcs_conf->basic_cap = vmx_msr_high & ~0x1fff; 2609 2607 2610 2608 vmcs_conf->revision_id = vmx_msr_low; ··· 2628 2628 struct page *pages; 2629 2629 struct vmcs *vmcs; 2630 2630 2631 - pages = __alloc_pages_node(node, flags, vmcs_config.order); 2631 + pages = __alloc_pages_node(node, flags, 0); 2632 2632 if (!pages) 2633 2633 return NULL; 2634 2634 vmcs = page_address(pages); ··· 2647 2647 2648 2648 void free_vmcs(struct vmcs *vmcs) 2649 2649 { 2650 - free_pages((unsigned long)vmcs, vmcs_config.order); 2650 + free_page((unsigned long)vmcs); 2651 2651 } 2652 2652 2653 2653 /* ··· 4094 4094 vmcs_write32(HOST_IA32_SYSENTER_CS, low32); 4095 4095 4096 4096 /* 4097 - * If 32-bit syscall is enabled, vmx_vcpu_load_vcms rewrites 4098 - * HOST_IA32_SYSENTER_ESP. 4097 + * SYSENTER is used for 32-bit system calls on either 32-bit or 4098 + * 64-bit kernels. It is always zero If neither is allowed, otherwise 4099 + * vmx_vcpu_load_vmcs loads it with the per-CPU entry stack (and may 4100 + * have already done so!). 4099 4101 */ 4100 - vmcs_writel(HOST_IA32_SYSENTER_ESP, 0); 4102 + if (!IS_ENABLED(CONFIG_IA32_EMULATION) && !IS_ENABLED(CONFIG_X86_32)) 4103 + vmcs_writel(HOST_IA32_SYSENTER_ESP, 0); 4104 + 4101 4105 rdmsrl(MSR_IA32_SYSENTER_EIP, tmpl); 4102 4106 vmcs_writel(HOST_IA32_SYSENTER_EIP, tmpl); /* 22.2.3 */ 4103 4107 ··· 4905 4901 dr6 = vmx_get_exit_qual(vcpu); 4906 4902 if (!(vcpu->guest_debug & 4907 4903 (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) { 4904 + /* 4905 + * If the #DB was due to ICEBP, a.k.a. INT1, skip the 4906 + * instruction. ICEBP generates a trap-like #DB, but 4907 + * despite its interception control being tied to #DB, 4908 + * is an instruction intercept, i.e. the VM-Exit occurs 4909 + * on the ICEBP itself. Note, skipping ICEBP also 4910 + * clears STI and MOVSS blocking. 4911 + * 4912 + * For all other #DBs, set vmcs.PENDING_DBG_EXCEPTIONS.BS 4913 + * if single-step is enabled in RFLAGS and STI or MOVSS 4914 + * blocking is active, as the CPU doesn't set the bit 4915 + * on VM-Exit due to #DB interception. VM-Entry has a 4916 + * consistency check that a single-step #DB is pending 4917 + * in this scenario as the previous instruction cannot 4918 + * have toggled RFLAGS.TF 0=>1 (because STI and POP/MOV 4919 + * don't modify RFLAGS), therefore the one instruction 4920 + * delay when activating single-step breakpoints must 4921 + * have already expired. Note, the CPU sets/clears BS 4922 + * as appropriate for all other VM-Exits types. 4923 + */ 4908 4924 if (is_icebp(intr_info)) 4909 4925 WARN_ON(!skip_emulated_instruction(vcpu)); 4926 + else if ((vmx_get_rflags(vcpu) & X86_EFLAGS_TF) && 4927 + (vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 4928 + (GUEST_INTR_STATE_STI | GUEST_INTR_STATE_MOV_SS))) 4929 + vmcs_writel(GUEST_PENDING_DBG_EXCEPTIONS, 4930 + vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS) | DR6_BS); 4910 4931 4911 4932 kvm_queue_exception_p(vcpu, DB_VECTOR, dr6); 4912 4933 return 1; ··· 5426 5397 { 5427 5398 gpa_t gpa; 5428 5399 5429 - if (!vmx_can_emulate_instruction(vcpu, NULL, 0)) 5400 + if (!vmx_can_emulate_instruction(vcpu, EMULTYPE_PF, NULL, 0)) 5430 5401 return 1; 5431 5402 5432 5403 /*
+81 -13
arch/x86/kvm/x86.c
··· 3535 3535 if (data & ~supported_xss) 3536 3536 return 1; 3537 3537 vcpu->arch.ia32_xss = data; 3538 + kvm_update_cpuid_runtime(vcpu); 3538 3539 break; 3539 3540 case MSR_SMI_COUNT: 3540 3541 if (!msr_info->host_initiated) ··· 4230 4229 case KVM_CAP_SREGS2: 4231 4230 case KVM_CAP_EXIT_ON_EMULATION_FAILURE: 4232 4231 case KVM_CAP_VCPU_ATTRIBUTES: 4232 + case KVM_CAP_SYS_ATTRIBUTES: 4233 4233 r = 1; 4234 4234 break; 4235 4235 case KVM_CAP_EXIT_HYPERCALL: ··· 4333 4331 break; 4334 4332 } 4335 4333 return r; 4334 + } 4336 4335 4336 + static inline void __user *kvm_get_attr_addr(struct kvm_device_attr *attr) 4337 + { 4338 + void __user *uaddr = (void __user*)(unsigned long)attr->addr; 4339 + 4340 + if ((u64)(unsigned long)uaddr != attr->addr) 4341 + return ERR_PTR(-EFAULT); 4342 + return uaddr; 4343 + } 4344 + 4345 + static int kvm_x86_dev_get_attr(struct kvm_device_attr *attr) 4346 + { 4347 + u64 __user *uaddr = kvm_get_attr_addr(attr); 4348 + 4349 + if (attr->group) 4350 + return -ENXIO; 4351 + 4352 + if (IS_ERR(uaddr)) 4353 + return PTR_ERR(uaddr); 4354 + 4355 + switch (attr->attr) { 4356 + case KVM_X86_XCOMP_GUEST_SUPP: 4357 + if (put_user(supported_xcr0, uaddr)) 4358 + return -EFAULT; 4359 + return 0; 4360 + default: 4361 + return -ENXIO; 4362 + break; 4363 + } 4364 + } 4365 + 4366 + static int kvm_x86_dev_has_attr(struct kvm_device_attr *attr) 4367 + { 4368 + if (attr->group) 4369 + return -ENXIO; 4370 + 4371 + switch (attr->attr) { 4372 + case KVM_X86_XCOMP_GUEST_SUPP: 4373 + return 0; 4374 + default: 4375 + return -ENXIO; 4376 + } 4337 4377 } 4338 4378 4339 4379 long kvm_arch_dev_ioctl(struct file *filp, ··· 4466 4422 case KVM_GET_SUPPORTED_HV_CPUID: 4467 4423 r = kvm_ioctl_get_supported_hv_cpuid(NULL, argp); 4468 4424 break; 4425 + case KVM_GET_DEVICE_ATTR: { 4426 + struct kvm_device_attr attr; 4427 + r = -EFAULT; 4428 + if (copy_from_user(&attr, (void __user *)arg, sizeof(attr))) 4429 + break; 4430 + r = kvm_x86_dev_get_attr(&attr); 4431 + break; 4432 + } 4433 + case KVM_HAS_DEVICE_ATTR: { 4434 + struct kvm_device_attr attr; 4435 + r = -EFAULT; 4436 + if (copy_from_user(&attr, (void __user *)arg, sizeof(attr))) 4437 + break; 4438 + r = kvm_x86_dev_has_attr(&attr); 4439 + break; 4440 + } 4469 4441 default: 4470 4442 r = -EINVAL; 4471 4443 break; ··· 4920 4860 vcpu->arch.apic->sipi_vector = events->sipi_vector; 4921 4861 4922 4862 if (events->flags & KVM_VCPUEVENT_VALID_SMM) { 4923 - if (!!(vcpu->arch.hflags & HF_SMM_MASK) != events->smi.smm) 4863 + if (!!(vcpu->arch.hflags & HF_SMM_MASK) != events->smi.smm) { 4864 + kvm_x86_ops.nested_ops->leave_nested(vcpu); 4924 4865 kvm_smm_changed(vcpu, events->smi.smm); 4866 + } 4925 4867 4926 4868 vcpu->arch.smi_pending = events->smi.pending; 4927 4869 ··· 5084 5022 static int kvm_arch_tsc_get_attr(struct kvm_vcpu *vcpu, 5085 5023 struct kvm_device_attr *attr) 5086 5024 { 5087 - u64 __user *uaddr = (u64 __user *)(unsigned long)attr->addr; 5025 + u64 __user *uaddr = kvm_get_attr_addr(attr); 5088 5026 int r; 5089 5027 5090 - if ((u64)(unsigned long)uaddr != attr->addr) 5091 - return -EFAULT; 5028 + if (IS_ERR(uaddr)) 5029 + return PTR_ERR(uaddr); 5092 5030 5093 5031 switch (attr->attr) { 5094 5032 case KVM_VCPU_TSC_OFFSET: ··· 5107 5045 static int kvm_arch_tsc_set_attr(struct kvm_vcpu *vcpu, 5108 5046 struct kvm_device_attr *attr) 5109 5047 { 5110 - u64 __user *uaddr = (u64 __user *)(unsigned long)attr->addr; 5048 + u64 __user *uaddr = kvm_get_attr_addr(attr); 5111 5049 struct kvm *kvm = vcpu->kvm; 5112 5050 int r; 5113 5051 5114 - if ((u64)(unsigned long)uaddr != attr->addr) 5115 - return -EFAULT; 5052 + if (IS_ERR(uaddr)) 5053 + return PTR_ERR(uaddr); 5116 5054 5117 5055 switch (attr->attr) { 5118 5056 case KVM_VCPU_TSC_OFFSET: { ··· 6872 6810 } 6873 6811 EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system); 6874 6812 6813 + static int kvm_can_emulate_insn(struct kvm_vcpu *vcpu, int emul_type, 6814 + void *insn, int insn_len) 6815 + { 6816 + return static_call(kvm_x86_can_emulate_instruction)(vcpu, emul_type, 6817 + insn, insn_len); 6818 + } 6819 + 6875 6820 int handle_ud(struct kvm_vcpu *vcpu) 6876 6821 { 6877 6822 static const char kvm_emulate_prefix[] = { __KVM_EMULATE_PREFIX }; ··· 6886 6817 char sig[5]; /* ud2; .ascii "kvm" */ 6887 6818 struct x86_exception e; 6888 6819 6889 - if (unlikely(!static_call(kvm_x86_can_emulate_instruction)(vcpu, NULL, 0))) 6820 + if (unlikely(!kvm_can_emulate_insn(vcpu, emul_type, NULL, 0))) 6890 6821 return 1; 6891 6822 6892 6823 if (force_emulation_prefix && ··· 8262 8193 bool writeback = true; 8263 8194 bool write_fault_to_spt; 8264 8195 8265 - if (unlikely(!static_call(kvm_x86_can_emulate_instruction)(vcpu, insn, insn_len))) 8196 + if (unlikely(!kvm_can_emulate_insn(vcpu, emulation_type, insn, insn_len))) 8266 8197 return 1; 8267 8198 8268 8199 vcpu->arch.l1tf_flush_l1d = true; ··· 9775 9706 kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); 9776 9707 } 9777 9708 9778 - void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) 9709 + static void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) 9779 9710 { 9780 9711 if (!lapic_in_kernel(vcpu)) 9781 9712 return; ··· 11278 11209 11279 11210 vcpu->arch.msr_misc_features_enables = 0; 11280 11211 11281 - vcpu->arch.xcr0 = XFEATURE_MASK_FP; 11212 + __kvm_set_xcr(vcpu, 0, XFEATURE_MASK_FP); 11213 + __kvm_set_msr(vcpu, MSR_IA32_XSS, 0, true); 11282 11214 } 11283 11215 11284 11216 /* All GPRs except RDX (handled below) are zeroed on RESET/INIT. */ ··· 11295 11225 */ 11296 11226 cpuid_0x1 = kvm_find_cpuid_entry(vcpu, 1, 0); 11297 11227 kvm_rdx_write(vcpu, cpuid_0x1 ? cpuid_0x1->eax : 0x600); 11298 - 11299 - vcpu->arch.ia32_xss = 0; 11300 11228 11301 11229 static_call(kvm_x86_vcpu_reset)(vcpu, init_event); 11302 11230
+2 -8
arch/x86/kvm/xen.c
··· 316 316 "\tnotq %0\n" 317 317 "\t" LOCK_PREFIX "andq %0, %2\n" 318 318 "2:\n" 319 - "\t.section .fixup,\"ax\"\n" 320 - "3:\tjmp\t2b\n" 321 - "\t.previous\n" 322 - _ASM_EXTABLE_UA(1b, 3b) 319 + _ASM_EXTABLE_UA(1b, 2b) 323 320 : "=r" (evtchn_pending_sel), 324 321 "+m" (vi->evtchn_pending_sel), 325 322 "+m" (v->arch.xen.evtchn_pending_sel) ··· 332 335 "\tnotl %0\n" 333 336 "\t" LOCK_PREFIX "andl %0, %2\n" 334 337 "2:\n" 335 - "\t.section .fixup,\"ax\"\n" 336 - "3:\tjmp\t2b\n" 337 - "\t.previous\n" 338 - _ASM_EXTABLE_UA(1b, 3b) 338 + _ASM_EXTABLE_UA(1b, 2b) 339 339 : "=r" (evtchn_pending_sel32), 340 340 "+m" (vi->evtchn_pending_sel), 341 341 "+m" (v->arch.xen.evtchn_pending_sel)
+2 -2
arch/x86/pci/fixup.c
··· 353 353 } 354 354 } 355 355 } 356 - DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, 357 - PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video); 356 + DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_ANY_ID, PCI_ANY_ID, 357 + PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video); 358 358 359 359 360 360 static const struct dmi_system_id msi_k8t_dmi_table[] = {
+19 -6
block/blk-core.c
··· 1061 1061 } 1062 1062 1063 1063 static unsigned long __part_start_io_acct(struct block_device *part, 1064 - unsigned int sectors, unsigned int op) 1064 + unsigned int sectors, unsigned int op, 1065 + unsigned long start_time) 1065 1066 { 1066 1067 const int sgrp = op_stat_group(op); 1067 - unsigned long now = READ_ONCE(jiffies); 1068 1068 1069 1069 part_stat_lock(); 1070 - update_io_ticks(part, now, false); 1070 + update_io_ticks(part, start_time, false); 1071 1071 part_stat_inc(part, ios[sgrp]); 1072 1072 part_stat_add(part, sectors[sgrp], sectors); 1073 1073 part_stat_local_inc(part, in_flight[op_is_write(op)]); 1074 1074 part_stat_unlock(); 1075 1075 1076 - return now; 1076 + return start_time; 1077 1077 } 1078 + 1079 + /** 1080 + * bio_start_io_acct_time - start I/O accounting for bio based drivers 1081 + * @bio: bio to start account for 1082 + * @start_time: start time that should be passed back to bio_end_io_acct(). 1083 + */ 1084 + void bio_start_io_acct_time(struct bio *bio, unsigned long start_time) 1085 + { 1086 + __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), 1087 + bio_op(bio), start_time); 1088 + } 1089 + EXPORT_SYMBOL_GPL(bio_start_io_acct_time); 1078 1090 1079 1091 /** 1080 1092 * bio_start_io_acct - start I/O accounting for bio based drivers ··· 1096 1084 */ 1097 1085 unsigned long bio_start_io_acct(struct bio *bio) 1098 1086 { 1099 - return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), bio_op(bio)); 1087 + return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), 1088 + bio_op(bio), jiffies); 1100 1089 } 1101 1090 EXPORT_SYMBOL_GPL(bio_start_io_acct); 1102 1091 1103 1092 unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors, 1104 1093 unsigned int op) 1105 1094 { 1106 - return __part_start_io_acct(disk->part0, sectors, op); 1095 + return __part_start_io_acct(disk->part0, sectors, op, jiffies); 1107 1096 } 1108 1097 EXPORT_SYMBOL(disk_start_io_acct); 1109 1098
+1 -1
block/blk-ia-ranges.c
··· 144 144 &q->kobj, "%s", "independent_access_ranges"); 145 145 if (ret) { 146 146 q->ia_ranges = NULL; 147 - kfree(iars); 147 + kobject_put(&iars->kobj); 148 148 return ret; 149 149 } 150 150
+2
block/blk-mq.c
··· 2922 2922 */ 2923 2923 blk_mq_run_dispatch_ops(rq->q, 2924 2924 ret = blk_mq_request_issue_directly(rq, true)); 2925 + if (ret) 2926 + blk_account_io_done(rq, ktime_get_ns()); 2925 2927 return ret; 2926 2928 } 2927 2929 EXPORT_SYMBOL_GPL(blk_insert_cloned_request);
+2
drivers/ata/pata_platform.c
··· 128 128 ap = host->ports[0]; 129 129 130 130 ap->ops = devm_kzalloc(dev, sizeof(*ap->ops), GFP_KERNEL); 131 + if (!ap->ops) 132 + return -ENOMEM; 131 133 ap->ops->inherits = &ata_sff_port_ops; 132 134 ap->ops->cable_detect = ata_cable_unknown; 133 135 ap->ops->set_mode = pata_platform_set_mode;
+1 -1
drivers/connector/cn_proc.c
··· 358 358 * other namespaces. 359 359 */ 360 360 if ((current_user_ns() != &init_user_ns) || 361 - (task_active_pid_ns(current) != &init_pid_ns)) 361 + !task_is_in_init_pid_ns(current)) 362 362 return; 363 363 364 364 /* Can only change if privileged. */
+6 -9
drivers/counter/counter-core.c
··· 90 90 int err; 91 91 92 92 ch = kzalloc(sizeof(*ch) + sizeof_priv, GFP_KERNEL); 93 - if (!ch) { 94 - err = -ENOMEM; 95 - goto err_alloc_ch; 96 - } 93 + if (!ch) 94 + return NULL; 97 95 98 96 counter = &ch->counter; 99 97 dev = &counter->dev; ··· 121 123 err_ida_alloc: 122 124 123 125 kfree(ch); 124 - err_alloc_ch: 125 126 126 - return ERR_PTR(err); 127 + return NULL; 127 128 } 128 129 EXPORT_SYMBOL_GPL(counter_alloc); 129 130 ··· 205 208 int err; 206 209 207 210 counter = counter_alloc(sizeof_priv); 208 - if (IS_ERR(counter)) 209 - return counter; 211 + if (!counter) 212 + return NULL; 210 213 211 214 err = devm_add_action_or_reset(dev, devm_counter_put, counter); 212 215 if (err < 0) 213 - return ERR_PTR(err); 216 + return NULL; 214 217 215 218 return counter; 216 219 }
+7
drivers/firmware/efi/efi.c
··· 722 722 systab_hdr->revision >> 16, 723 723 systab_hdr->revision & 0xffff, 724 724 vendor); 725 + 726 + if (IS_ENABLED(CONFIG_X86_64) && 727 + systab_hdr->revision > EFI_1_10_SYSTEM_TABLE_REVISION && 728 + !strcmp(vendor, "Apple")) { 729 + pr_info("Apple Mac detected, using EFI v1.10 runtime services only\n"); 730 + efi.runtime_version = EFI_1_10_SYSTEM_TABLE_REVISION; 731 + } 725 732 } 726 733 727 734 static __initdata char memory_type_name[][13] = {
+3 -3
drivers/firmware/efi/libstub/arm64-stub.c
··· 119 119 if (image->image_base != _text) 120 120 efi_err("FIRMWARE BUG: efi_loaded_image_t::image_base has bogus value\n"); 121 121 122 - if (!IS_ALIGNED((u64)_text, EFI_KIMG_ALIGN)) 123 - efi_err("FIRMWARE BUG: kernel image not aligned on %ldk boundary\n", 124 - EFI_KIMG_ALIGN >> 10); 122 + if (!IS_ALIGNED((u64)_text, SEGMENT_ALIGN)) 123 + efi_err("FIRMWARE BUG: kernel image not aligned on %dk boundary\n", 124 + SEGMENT_ALIGN >> 10); 125 125 126 126 kernel_size = _edata - _text; 127 127 kernel_memsize = kernel_size + (_end - _edata);
+1 -1
drivers/gpio/gpio-sim.c
··· 816 816 817 817 properties[prop_idx++] = PROPERTY_ENTRY_U32("ngpios", bank->num_lines); 818 818 819 - if (bank->label) 819 + if (bank->label && (strlen(bank->label) > 0)) 820 820 properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label", 821 821 bank->label); 822 822
+81
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 1525 1525 0x99A0, 1526 1526 0x99A2, 1527 1527 0x99A4, 1528 + /* radeon secondary ids */ 1529 + 0x3171, 1530 + 0x3e70, 1531 + 0x4164, 1532 + 0x4165, 1533 + 0x4166, 1534 + 0x4168, 1535 + 0x4170, 1536 + 0x4171, 1537 + 0x4172, 1538 + 0x4173, 1539 + 0x496e, 1540 + 0x4a69, 1541 + 0x4a6a, 1542 + 0x4a6b, 1543 + 0x4a70, 1544 + 0x4a74, 1545 + 0x4b69, 1546 + 0x4b6b, 1547 + 0x4b6c, 1548 + 0x4c6e, 1549 + 0x4e64, 1550 + 0x4e65, 1551 + 0x4e66, 1552 + 0x4e67, 1553 + 0x4e68, 1554 + 0x4e69, 1555 + 0x4e6a, 1556 + 0x4e71, 1557 + 0x4f73, 1558 + 0x5569, 1559 + 0x556b, 1560 + 0x556d, 1561 + 0x556f, 1562 + 0x5571, 1563 + 0x5854, 1564 + 0x5874, 1565 + 0x5940, 1566 + 0x5941, 1567 + 0x5b72, 1568 + 0x5b73, 1569 + 0x5b74, 1570 + 0x5b75, 1571 + 0x5d44, 1572 + 0x5d45, 1573 + 0x5d6d, 1574 + 0x5d6f, 1575 + 0x5d72, 1576 + 0x5d77, 1577 + 0x5e6b, 1578 + 0x5e6d, 1579 + 0x7120, 1580 + 0x7124, 1581 + 0x7129, 1582 + 0x712e, 1583 + 0x712f, 1584 + 0x7162, 1585 + 0x7163, 1586 + 0x7166, 1587 + 0x7167, 1588 + 0x7172, 1589 + 0x7173, 1590 + 0x71a0, 1591 + 0x71a1, 1592 + 0x71a3, 1593 + 0x71a7, 1594 + 0x71bb, 1595 + 0x71e0, 1596 + 0x71e1, 1597 + 0x71e2, 1598 + 0x71e6, 1599 + 0x71e7, 1600 + 0x71f2, 1601 + 0x7269, 1602 + 0x726b, 1603 + 0x726e, 1604 + 0x72a0, 1605 + 0x72a8, 1606 + 0x72b1, 1607 + 0x72b3, 1608 + 0x793f, 1528 1609 }; 1529 1610 1530 1611 static const struct pci_device_id pciidlist[] = {
+2 -2
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
··· 2033 2033 kfree(surface_type); 2034 2034 free_tiling_mode: 2035 2035 kfree(tiling_mode); 2036 - free_yclk: 2037 - kfree(yclk); 2038 2036 free_sclk: 2039 2037 kfree(sclk); 2038 + free_yclk: 2039 + kfree(yclk); 2040 2040 } 2041 2041 2042 2042 /*******************************************************************************
-1
drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c
··· 503 503 //input[in_idx].dout.output_standard; 504 504 505 505 /*todo: soc->sr_enter_plus_exit_time??*/ 506 - dlg_sys_param->t_srx_delay_us = dc->dcn_ip->dcfclk_cstate_latency / v->dcf_clk_deep_sleep; 507 506 508 507 dml1_rq_dlg_get_rq_params(dml, rq_param, &input->pipe.src); 509 508 dml1_extract_rq_regs(dml, rq_regs, rq_param);
+27 -13
drivers/gpu/drm/amd/display/dc/core/dc.c
··· 1404 1404 status->timing_sync_info.master = false; 1405 1405 1406 1406 } 1407 - /* remove any other unblanked pipes as they have already been synced */ 1408 - for (j = j + 1; j < group_size; j++) { 1409 - bool is_blanked; 1410 1407 1411 - if (pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked) 1412 - is_blanked = 1413 - pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked(pipe_set[j]->stream_res.opp); 1414 - else 1415 - is_blanked = 1416 - pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg); 1417 - if (!is_blanked) { 1418 - group_size--; 1419 - pipe_set[j] = pipe_set[group_size]; 1420 - j--; 1408 + /* remove any other pipes that are already been synced */ 1409 + if (dc->config.use_pipe_ctx_sync_logic) { 1410 + /* check pipe's syncd to decide which pipe to be removed */ 1411 + for (j = 1; j < group_size; j++) { 1412 + if (pipe_set[j]->pipe_idx_syncd == pipe_set[0]->pipe_idx_syncd) { 1413 + group_size--; 1414 + pipe_set[j] = pipe_set[group_size]; 1415 + j--; 1416 + } else 1417 + /* link slave pipe's syncd with master pipe */ 1418 + pipe_set[j]->pipe_idx_syncd = pipe_set[0]->pipe_idx_syncd; 1419 + } 1420 + } else { 1421 + for (j = j + 1; j < group_size; j++) { 1422 + bool is_blanked; 1423 + 1424 + if (pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked) 1425 + is_blanked = 1426 + pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked(pipe_set[j]->stream_res.opp); 1427 + else 1428 + is_blanked = 1429 + pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg); 1430 + if (!is_blanked) { 1431 + group_size--; 1432 + pipe_set[j] = pipe_set[group_size]; 1433 + j--; 1434 + } 1421 1435 } 1422 1436 } 1423 1437
+54
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
··· 3217 3217 } 3218 3218 #endif 3219 3219 3220 + void reset_syncd_pipes_from_disabled_pipes(struct dc *dc, 3221 + struct dc_state *context) 3222 + { 3223 + int i, j; 3224 + struct pipe_ctx *pipe_ctx_old, *pipe_ctx, *pipe_ctx_syncd; 3225 + 3226 + /* If pipe backend is reset, need to reset pipe syncd status */ 3227 + for (i = 0; i < dc->res_pool->pipe_count; i++) { 3228 + pipe_ctx_old = &dc->current_state->res_ctx.pipe_ctx[i]; 3229 + pipe_ctx = &context->res_ctx.pipe_ctx[i]; 3230 + 3231 + if (!pipe_ctx_old->stream) 3232 + continue; 3233 + 3234 + if (pipe_ctx_old->top_pipe || pipe_ctx_old->prev_odm_pipe) 3235 + continue; 3236 + 3237 + if (!pipe_ctx->stream || 3238 + pipe_need_reprogram(pipe_ctx_old, pipe_ctx)) { 3239 + 3240 + /* Reset all the syncd pipes from the disabled pipe */ 3241 + for (j = 0; j < dc->res_pool->pipe_count; j++) { 3242 + pipe_ctx_syncd = &context->res_ctx.pipe_ctx[j]; 3243 + if ((GET_PIPE_SYNCD_FROM_PIPE(pipe_ctx_syncd) == pipe_ctx_old->pipe_idx) || 3244 + !IS_PIPE_SYNCD_VALID(pipe_ctx_syncd)) 3245 + SET_PIPE_SYNCD_TO_PIPE(pipe_ctx_syncd, j); 3246 + } 3247 + } 3248 + } 3249 + } 3250 + 3251 + void check_syncd_pipes_for_disabled_master_pipe(struct dc *dc, 3252 + struct dc_state *context, 3253 + uint8_t disabled_master_pipe_idx) 3254 + { 3255 + int i; 3256 + struct pipe_ctx *pipe_ctx, *pipe_ctx_check; 3257 + 3258 + pipe_ctx = &context->res_ctx.pipe_ctx[disabled_master_pipe_idx]; 3259 + if ((GET_PIPE_SYNCD_FROM_PIPE(pipe_ctx) != disabled_master_pipe_idx) || 3260 + !IS_PIPE_SYNCD_VALID(pipe_ctx)) 3261 + SET_PIPE_SYNCD_TO_PIPE(pipe_ctx, disabled_master_pipe_idx); 3262 + 3263 + /* for the pipe disabled, check if any slave pipe exists and assert */ 3264 + for (i = 0; i < dc->res_pool->pipe_count; i++) { 3265 + pipe_ctx_check = &context->res_ctx.pipe_ctx[i]; 3266 + 3267 + if ((GET_PIPE_SYNCD_FROM_PIPE(pipe_ctx_check) == disabled_master_pipe_idx) && 3268 + IS_PIPE_SYNCD_VALID(pipe_ctx_check) && (i != disabled_master_pipe_idx)) 3269 + DC_ERR("DC: Failure: pipe_idx[%d] syncd with disabled master pipe_idx[%d]\n", 3270 + i, disabled_master_pipe_idx); 3271 + } 3272 + } 3273 + 3220 3274 uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter transmitter) 3221 3275 { 3222 3276 /* TODO - get transmitter to phy idx mapping from DMUB */
+1
drivers/gpu/drm/amd/display/dc/dc.h
··· 344 344 uint8_t vblank_alignment_max_frame_time_diff; 345 345 bool is_asymmetric_memory; 346 346 bool is_single_rank_dimm; 347 + bool use_pipe_ctx_sync_logic; 347 348 }; 348 349 349 350 enum visual_confirm {
+9 -1
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
··· 1566 1566 &pipe_ctx->stream->audio_info); 1567 1567 } 1568 1568 1569 + /* make sure no pipes syncd to the pipe being enabled */ 1570 + if (!pipe_ctx->stream->apply_seamless_boot_optimization && dc->config.use_pipe_ctx_sync_logic) 1571 + check_syncd_pipes_for_disabled_master_pipe(dc, context, pipe_ctx->pipe_idx); 1572 + 1569 1573 #if defined(CONFIG_DRM_AMD_DC_DCN) 1570 1574 /* DCN3.1 FPGA Workaround 1571 1575 * Need to enable HPO DP Stream Encoder before setting OTG master enable. ··· 1608 1604 pipe_ctx->stream_res.stream_enc, 1609 1605 pipe_ctx->stream_res.tg->inst); 1610 1606 1611 - if (dc_is_dp_signal(pipe_ctx->stream->signal) && 1607 + if (dc_is_embedded_signal(pipe_ctx->stream->signal) && 1612 1608 pipe_ctx->stream_res.stream_enc->funcs->reset_fifo) 1613 1609 pipe_ctx->stream_res.stream_enc->funcs->reset_fifo( 1614 1610 pipe_ctx->stream_res.stream_enc); ··· 2300 2296 struct dc_bios *dcb = dc->ctx->dc_bios; 2301 2297 enum dc_status status; 2302 2298 int i; 2299 + 2300 + /* reset syncd pipes from disabled pipes */ 2301 + if (dc->config.use_pipe_ctx_sync_logic) 2302 + reset_syncd_pipes_from_disabled_pipes(dc, context); 2303 2303 2304 2304 /* Reset old context */ 2305 2305 /* look up the targets that have been removed since last commit */
+2 -2
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
··· 1878 1878 dc->res_pool->funcs->update_soc_for_wm_a(dc, context); 1879 1879 pipe_cnt = dc->res_pool->funcs->populate_dml_pipes(dc, context, pipes, fast_validate); 1880 1880 1881 - DC_FP_START(); 1882 1881 if (!pipe_cnt) { 1883 1882 out = true; 1884 1883 goto validate_out; ··· 2103 2104 out = false; 2104 2105 2105 2106 validate_out: 2106 - DC_FP_END(); 2107 2107 return out; 2108 2108 } 2109 2109 ··· 2304 2306 2305 2307 BW_VAL_TRACE_COUNT(); 2306 2308 2309 + DC_FP_START(); 2307 2310 out = dcn30_internal_validate_bw(dc, context, pipes, &pipe_cnt, &vlevel, fast_validate); 2311 + DC_FP_END(); 2308 2312 2309 2313 if (pipe_cnt == 0) 2310 2314 goto validate_out;
+12 -1
drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
··· 686 686 .disable_clock_gate = true, 687 687 .disable_pplib_clock_request = true, 688 688 .disable_pplib_wm_range = true, 689 - .pipe_split_policy = MPC_SPLIT_DYNAMIC, 689 + .pipe_split_policy = MPC_SPLIT_AVOID, 690 690 .force_single_disp_pipe_split = false, 691 691 .disable_dcc = DCC_ENABLE, 692 692 .vsr_support = true, ··· 1378 1378 1379 1379 /* Notify PP Lib/SMU which Watermarks to use for which clock ranges */ 1380 1380 pp_smu->nv_funcs.set_wm_ranges(&pp_smu->nv_funcs.pp_smu, &ranges); 1381 + } 1382 + 1383 + static void dcn301_calculate_wm_and_dlg( 1384 + struct dc *dc, struct dc_state *context, 1385 + display_e2e_pipe_params_st *pipes, 1386 + int pipe_cnt, 1387 + int vlevel) 1388 + { 1389 + DC_FP_START(); 1390 + dcn301_calculate_wm_and_dlg_fp(dc, context, pipes, pipe_cnt, vlevel); 1391 + DC_FP_END(); 1381 1392 } 1382 1393 1383 1394 static struct resource_funcs dcn301_res_pool_funcs = {
+3
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
··· 2260 2260 dc->caps.color.mpc.ogam_rom_caps.hlg = 0; 2261 2261 dc->caps.color.mpc.ocsc = 1; 2262 2262 2263 + /* Use pipe context based otg sync logic */ 2264 + dc->config.use_pipe_ctx_sync_logic = true; 2265 + 2263 2266 /* read VBIOS LTTPR caps */ 2264 2267 { 2265 2268 if (ctx->dc_bios->funcs->get_lttpr_caps) {
-2
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
··· 1576 1576 dlg_sys_param.total_flip_bytes = get_total_immediate_flip_bytes(mode_lib, 1577 1577 e2e_pipe_param, 1578 1578 num_pipes); 1579 - dlg_sys_param.t_srx_delay_us = mode_lib->ip.dcfclk_cstate_latency 1580 - / dlg_sys_param.deepsleep_dcfclk_mhz; // TODO: Deprecated 1581 1579 1582 1580 print__dlg_sys_params_st(mode_lib, &dlg_sys_param); 1583 1581
-2
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20v2.c
··· 1577 1577 dlg_sys_param.total_flip_bytes = get_total_immediate_flip_bytes(mode_lib, 1578 1578 e2e_pipe_param, 1579 1579 num_pipes); 1580 - dlg_sys_param.t_srx_delay_us = mode_lib->ip.dcfclk_cstate_latency 1581 - / dlg_sys_param.deepsleep_dcfclk_mhz; // TODO: Deprecated 1582 1580 1583 1581 print__dlg_sys_params_st(mode_lib, &dlg_sys_param); 1584 1582
-2
drivers/gpu/drm/amd/display/dc/dml/dcn21/display_rq_dlg_calc_21.c
··· 1688 1688 mode_lib, 1689 1689 e2e_pipe_param, 1690 1690 num_pipes); 1691 - dlg_sys_param.t_srx_delay_us = mode_lib->ip.dcfclk_cstate_latency 1692 - / dlg_sys_param.deepsleep_dcfclk_mhz; // TODO: Deprecated 1693 1691 1694 1692 print__dlg_sys_params_st(mode_lib, &dlg_sys_param); 1695 1693
-2
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_rq_dlg_calc_30.c
··· 1858 1858 dlg_sys_param.total_flip_bytes = get_total_immediate_flip_bytes(mode_lib, 1859 1859 e2e_pipe_param, 1860 1860 num_pipes); 1861 - dlg_sys_param.t_srx_delay_us = mode_lib->ip.dcfclk_cstate_latency 1862 - / dlg_sys_param.deepsleep_dcfclk_mhz; // TODO: Deprecated 1863 1861 1864 1862 print__dlg_sys_params_st(mode_lib, &dlg_sys_param); 1865 1863
+1 -1
drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c
··· 327 327 dcn3_01_soc.sr_exit_time_us = bb_info.dram_sr_exit_latency_100ns * 10; 328 328 } 329 329 330 - void dcn301_calculate_wm_and_dlg(struct dc *dc, 330 + void dcn301_calculate_wm_and_dlg_fp(struct dc *dc, 331 331 struct dc_state *context, 332 332 display_e2e_pipe_params_st *pipes, 333 333 int pipe_cnt,
+1 -1
drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.h
··· 34 34 35 35 void dcn301_fpu_init_soc_bounding_box(struct bp_soc_bb_info bb_info); 36 36 37 - void dcn301_calculate_wm_and_dlg(struct dc *dc, 37 + void dcn301_calculate_wm_and_dlg_fp(struct dc *dc, 38 38 struct dc_state *context, 39 39 display_e2e_pipe_params_st *pipes, 40 40 int pipe_cnt,
-1
drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h
··· 546 546 double t_sr_wm_us; 547 547 double t_extra_us; 548 548 double mem_trip_us; 549 - double t_srx_delay_us; 550 549 double deepsleep_dcfclk_mhz; 551 550 double total_flip_bw; 552 551 unsigned int total_flip_bytes;
-3
drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_helpers.c
··· 142 142 dml_print("DML_RQ_DLG_CALC: t_sr_wm_us = %3.2f\n", dlg_sys_param->t_sr_wm_us); 143 143 dml_print("DML_RQ_DLG_CALC: t_extra_us = %3.2f\n", dlg_sys_param->t_extra_us); 144 144 dml_print( 145 - "DML_RQ_DLG_CALC: t_srx_delay_us = %3.2f\n", 146 - dlg_sys_param->t_srx_delay_us); 147 - dml_print( 148 145 "DML_RQ_DLG_CALC: deepsleep_dcfclk_mhz = %3.2f\n", 149 146 dlg_sys_param->deepsleep_dcfclk_mhz); 150 147 dml_print(
-4
drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c
··· 1331 1331 if (dual_plane) 1332 1332 DTRACE("DLG: %s: swath_height_c = %d", __func__, swath_height_c); 1333 1333 1334 - DTRACE( 1335 - "DLG: %s: t_srx_delay_us = %3.2f", 1336 - __func__, 1337 - (double) dlg_sys_param->t_srx_delay_us); 1338 1334 DTRACE("DLG: %s: line_time_in_us = %3.2f", __func__, (double) line_time_in_us); 1339 1335 DTRACE("DLG: %s: vupdate_offset = %d", __func__, vupdate_offset); 1340 1336 DTRACE("DLG: %s: vupdate_width = %d", __func__, vupdate_width);
+1
drivers/gpu/drm/amd/display/dc/inc/core_types.h
··· 382 382 struct pll_settings pll_settings; 383 383 384 384 uint8_t pipe_idx; 385 + uint8_t pipe_idx_syncd; 385 386 386 387 struct pipe_ctx *top_pipe; 387 388 struct pipe_ctx *bottom_pipe;
+11
drivers/gpu/drm/amd/display/dc/inc/resource.h
··· 34 34 #define MEMORY_TYPE_HBM 2 35 35 36 36 37 + #define IS_PIPE_SYNCD_VALID(pipe) ((((pipe)->pipe_idx_syncd) & 0x80)?1:0) 38 + #define GET_PIPE_SYNCD_FROM_PIPE(pipe) ((pipe)->pipe_idx_syncd & 0x7F) 39 + #define SET_PIPE_SYNCD_TO_PIPE(pipe, pipe_syncd) ((pipe)->pipe_idx_syncd = (0x80 | pipe_syncd)) 40 + 37 41 enum dce_version resource_parse_asic_id( 38 42 struct hw_asic_id asic_id); 39 43 ··· 211 207 const struct resource_pool *pool, 212 208 const struct dc_link *link); 213 209 #endif 210 + 211 + void reset_syncd_pipes_from_disabled_pipes(struct dc *dc, 212 + struct dc_state *context); 213 + 214 + void check_syncd_pipes_for_disabled_master_pipe(struct dc *dc, 215 + struct dc_state *context, 216 + uint8_t disabled_master_pipe_idx); 214 217 215 218 uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter transmitter); 216 219
-2
drivers/gpu/drm/ast/ast_tables.h
··· 282 282 }; 283 283 284 284 static const struct ast_vbios_enhtable res_1600x900[] = { 285 - {1800, 1600, 24, 80, 1000, 900, 1, 3, VCLK108, /* 60Hz */ 286 - (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 3, 0x3A }, 287 285 {1760, 1600, 48, 32, 926, 900, 3, 5, VCLK97_75, /* 60Hz CVT RB */ 288 286 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | 289 287 AST2500PreCatchCRT), 60, 1, 0x3A },
+8 -4
drivers/gpu/drm/drm_atomic.c
··· 1327 1327 1328 1328 drm_dbg_atomic(dev, "checking %p\n", state); 1329 1329 1330 - for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) 1331 - requested_crtc |= drm_crtc_mask(crtc); 1330 + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { 1331 + if (new_crtc_state->enable) 1332 + requested_crtc |= drm_crtc_mask(crtc); 1333 + } 1332 1334 1333 1335 for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { 1334 1336 ret = drm_atomic_plane_check(old_plane_state, new_plane_state); ··· 1379 1377 } 1380 1378 } 1381 1379 1382 - for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) 1383 - affected_crtc |= drm_crtc_mask(crtc); 1380 + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { 1381 + if (new_crtc_state->enable) 1382 + affected_crtc |= drm_crtc_mask(crtc); 1383 + } 1384 1384 1385 1385 /* 1386 1386 * For commits that allow modesets drivers can add other CRTCs to the
+12
drivers/gpu/drm/drm_panel_orientation_quirks.c
··· 115 115 .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, 116 116 }; 117 117 118 + static const struct drm_dmi_panel_orientation_data lcd1600x2560_leftside_up = { 119 + .width = 1600, 120 + .height = 2560, 121 + .orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP, 122 + }; 123 + 118 124 static const struct dmi_system_id orientation_data[] = { 119 125 { /* Acer One 10 (S1003) */ 120 126 .matches = { ··· 281 275 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Default string"), 282 276 }, 283 277 .driver_data = (void *)&onegx1_pro, 278 + }, { /* OneXPlayer */ 279 + .matches = { 280 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ONE-NETBOOK TECHNOLOGY CO., LTD."), 281 + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ONE XPLAYER"), 282 + }, 283 + .driver_data = (void *)&lcd1600x2560_leftside_up, 284 284 }, { /* Samsung GalaxyBook 10.6 */ 285 285 .matches = { 286 286 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
+3
drivers/gpu/drm/drm_privacy_screen_x86.c
··· 33 33 unsigned long long output; 34 34 acpi_status status; 35 35 36 + if (acpi_disabled) 37 + return false; 38 + 36 39 /* Get embedded-controller handle */ 37 40 status = acpi_get_devices("PNP0C09", acpi_set_handle, NULL, &ec_handle); 38 41 if (ACPI_FAILURE(status) || !ec_handle)
+2 -2
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
··· 469 469 return -EINVAL; 470 470 } 471 471 472 - if (args->stream_size > SZ_64K || args->nr_relocs > SZ_64K || 473 - args->nr_bos > SZ_64K || args->nr_pmrs > 128) { 472 + if (args->stream_size > SZ_128K || args->nr_relocs > SZ_128K || 473 + args->nr_bos > SZ_128K || args->nr_pmrs > 128) { 474 474 DRM_ERROR("submit arguments out of size limits\n"); 475 475 return -EINVAL; 476 476 }
+1
drivers/gpu/drm/i915/gem/i915_gem_object_types.h
··· 311 311 #define I915_BO_READONLY BIT(6) 312 312 #define I915_TILING_QUIRK_BIT 7 /* unknown swizzling; do not release! */ 313 313 #define I915_BO_PROTECTED BIT(8) 314 + #define I915_BO_WAS_BOUND_BIT 9 314 315 /** 315 316 * @mem_flags - Mutable placement-related flags 316 317 *
+10
drivers/gpu/drm/i915/gem/i915_gem_pages.c
··· 10 10 #include "i915_gem_lmem.h" 11 11 #include "i915_gem_mman.h" 12 12 13 + #include "gt/intel_gt.h" 14 + 13 15 void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj, 14 16 struct sg_table *pages, 15 17 unsigned int sg_page_sizes) ··· 222 220 223 221 __i915_gem_object_reset_page_iter(obj); 224 222 obj->mm.page_sizes.phys = obj->mm.page_sizes.sg = 0; 223 + 224 + if (test_and_clear_bit(I915_BO_WAS_BOUND_BIT, &obj->flags)) { 225 + struct drm_i915_private *i915 = to_i915(obj->base.dev); 226 + intel_wakeref_t wakeref; 227 + 228 + with_intel_runtime_pm_if_active(&i915->runtime_pm, wakeref) 229 + intel_gt_invalidate_tlbs(to_gt(i915)); 230 + } 225 231 226 232 return pages; 227 233 }
+108
drivers/gpu/drm/i915/gt/intel_gt.c
··· 29 29 { 30 30 spin_lock_init(&gt->irq_lock); 31 31 32 + mutex_init(&gt->tlb_invalidate_lock); 33 + 32 34 INIT_LIST_HEAD(&gt->closed_vma); 33 35 spin_lock_init(&gt->closed_lock); 34 36 ··· 913 911 drm_printf(p, "available engines: %x\n", info->engine_mask); 914 912 915 913 intel_sseu_dump(&info->sseu, p); 914 + } 915 + 916 + struct reg_and_bit { 917 + i915_reg_t reg; 918 + u32 bit; 919 + }; 920 + 921 + static struct reg_and_bit 922 + get_reg_and_bit(const struct intel_engine_cs *engine, const bool gen8, 923 + const i915_reg_t *regs, const unsigned int num) 924 + { 925 + const unsigned int class = engine->class; 926 + struct reg_and_bit rb = { }; 927 + 928 + if (drm_WARN_ON_ONCE(&engine->i915->drm, 929 + class >= num || !regs[class].reg)) 930 + return rb; 931 + 932 + rb.reg = regs[class]; 933 + if (gen8 && class == VIDEO_DECODE_CLASS) 934 + rb.reg.reg += 4 * engine->instance; /* GEN8_M2TCR */ 935 + else 936 + rb.bit = engine->instance; 937 + 938 + rb.bit = BIT(rb.bit); 939 + 940 + return rb; 941 + } 942 + 943 + void intel_gt_invalidate_tlbs(struct intel_gt *gt) 944 + { 945 + static const i915_reg_t gen8_regs[] = { 946 + [RENDER_CLASS] = GEN8_RTCR, 947 + [VIDEO_DECODE_CLASS] = GEN8_M1TCR, /* , GEN8_M2TCR */ 948 + [VIDEO_ENHANCEMENT_CLASS] = GEN8_VTCR, 949 + [COPY_ENGINE_CLASS] = GEN8_BTCR, 950 + }; 951 + static const i915_reg_t gen12_regs[] = { 952 + [RENDER_CLASS] = GEN12_GFX_TLB_INV_CR, 953 + [VIDEO_DECODE_CLASS] = GEN12_VD_TLB_INV_CR, 954 + [VIDEO_ENHANCEMENT_CLASS] = GEN12_VE_TLB_INV_CR, 955 + [COPY_ENGINE_CLASS] = GEN12_BLT_TLB_INV_CR, 956 + }; 957 + struct drm_i915_private *i915 = gt->i915; 958 + struct intel_uncore *uncore = gt->uncore; 959 + struct intel_engine_cs *engine; 960 + enum intel_engine_id id; 961 + const i915_reg_t *regs; 962 + unsigned int num = 0; 963 + 964 + if (I915_SELFTEST_ONLY(gt->awake == -ENODEV)) 965 + return; 966 + 967 + if (GRAPHICS_VER(i915) == 12) { 968 + regs = gen12_regs; 969 + num = ARRAY_SIZE(gen12_regs); 970 + } else if (GRAPHICS_VER(i915) >= 8 && GRAPHICS_VER(i915) <= 11) { 971 + regs = gen8_regs; 972 + num = ARRAY_SIZE(gen8_regs); 973 + } else if (GRAPHICS_VER(i915) < 8) { 974 + return; 975 + } 976 + 977 + if (drm_WARN_ONCE(&i915->drm, !num, 978 + "Platform does not implement TLB invalidation!")) 979 + return; 980 + 981 + GEM_TRACE("\n"); 982 + 983 + assert_rpm_wakelock_held(&i915->runtime_pm); 984 + 985 + mutex_lock(&gt->tlb_invalidate_lock); 986 + intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL); 987 + 988 + for_each_engine(engine, gt, id) { 989 + /* 990 + * HW architecture suggest typical invalidation time at 40us, 991 + * with pessimistic cases up to 100us and a recommendation to 992 + * cap at 1ms. We go a bit higher just in case. 993 + */ 994 + const unsigned int timeout_us = 100; 995 + const unsigned int timeout_ms = 4; 996 + struct reg_and_bit rb; 997 + 998 + rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num); 999 + if (!i915_mmio_reg_offset(rb.reg)) 1000 + continue; 1001 + 1002 + intel_uncore_write_fw(uncore, rb.reg, rb.bit); 1003 + if (__intel_wait_for_register_fw(uncore, 1004 + rb.reg, rb.bit, 0, 1005 + timeout_us, timeout_ms, 1006 + NULL)) 1007 + drm_err_ratelimited(&gt->i915->drm, 1008 + "%s TLB invalidation did not complete in %ums!\n", 1009 + engine->name, timeout_ms); 1010 + } 1011 + 1012 + /* 1013 + * Use delayed put since a) we mostly expect a flurry of TLB 1014 + * invalidations so it is good to avoid paying the forcewake cost and 1015 + * b) it works around a bug in Icelake which cannot cope with too rapid 1016 + * transitions. 1017 + */ 1018 + intel_uncore_forcewake_put_delayed(uncore, FORCEWAKE_ALL); 1019 + mutex_unlock(&gt->tlb_invalidate_lock); 916 1020 }
+2
drivers/gpu/drm/i915/gt/intel_gt.h
··· 91 91 92 92 void intel_gt_watchdog_work(struct work_struct *work); 93 93 94 + void intel_gt_invalidate_tlbs(struct intel_gt *gt); 95 + 94 96 #endif /* __INTEL_GT_H__ */
+2
drivers/gpu/drm/i915/gt/intel_gt_types.h
··· 73 73 74 74 struct intel_uc uc; 75 75 76 + struct mutex tlb_invalidate_lock; 77 + 76 78 struct i915_wa_list wa_list; 77 79 78 80 struct intel_gt_timelines {
+11
drivers/gpu/drm/i915/i915_reg.h
··· 2721 2721 #define GAMT_CHKN_DISABLE_DYNAMIC_CREDIT_SHARING (1 << 28) 2722 2722 #define GAMT_CHKN_DISABLE_I2M_CYCLE_ON_WR_PORT (1 << 24) 2723 2723 2724 + #define GEN8_RTCR _MMIO(0x4260) 2725 + #define GEN8_M1TCR _MMIO(0x4264) 2726 + #define GEN8_M2TCR _MMIO(0x4268) 2727 + #define GEN8_BTCR _MMIO(0x426c) 2728 + #define GEN8_VTCR _MMIO(0x4270) 2729 + 2724 2730 #if 0 2725 2731 #define PRB0_TAIL _MMIO(0x2030) 2726 2732 #define PRB0_HEAD _MMIO(0x2034) ··· 2824 2818 #define GEN12_FAULT_TLB_DATA1 _MMIO(0xcebc) 2825 2819 #define FAULT_VA_HIGH_BITS (0xf << 0) 2826 2820 #define FAULT_GTT_SEL (1 << 4) 2821 + 2822 + #define GEN12_GFX_TLB_INV_CR _MMIO(0xced8) 2823 + #define GEN12_VD_TLB_INV_CR _MMIO(0xcedc) 2824 + #define GEN12_VE_TLB_INV_CR _MMIO(0xcee0) 2825 + #define GEN12_BLT_TLB_INV_CR _MMIO(0xcee4) 2827 2826 2828 2827 #define GEN12_AUX_ERR_DBG _MMIO(0x43f4) 2829 2828
+3
drivers/gpu/drm/i915/i915_vma.c
··· 457 457 vma->ops->bind_vma(vma->vm, NULL, vma, cache_level, bind_flags); 458 458 } 459 459 460 + if (vma->obj) 461 + set_bit(I915_BO_WAS_BOUND_BIT, &vma->obj->flags); 462 + 460 463 atomic_or(bind_flags, &vma->flags); 461 464 return 0; 462 465 }
+22 -4
drivers/gpu/drm/i915/intel_uncore.c
··· 724 724 } 725 725 726 726 static void __intel_uncore_forcewake_put(struct intel_uncore *uncore, 727 - enum forcewake_domains fw_domains) 727 + enum forcewake_domains fw_domains, 728 + bool delayed) 728 729 { 729 730 struct intel_uncore_forcewake_domain *domain; 730 731 unsigned int tmp; ··· 740 739 continue; 741 740 } 742 741 743 - fw_domains_put(uncore, domain->mask); 742 + if (delayed && 743 + !(domain->uncore->fw_domains_timer & domain->mask)) 744 + fw_domain_arm_timer(domain); 745 + else 746 + fw_domains_put(uncore, domain->mask); 744 747 } 745 748 } 746 749 ··· 765 760 return; 766 761 767 762 spin_lock_irqsave(&uncore->lock, irqflags); 768 - __intel_uncore_forcewake_put(uncore, fw_domains); 763 + __intel_uncore_forcewake_put(uncore, fw_domains, false); 764 + spin_unlock_irqrestore(&uncore->lock, irqflags); 765 + } 766 + 767 + void intel_uncore_forcewake_put_delayed(struct intel_uncore *uncore, 768 + enum forcewake_domains fw_domains) 769 + { 770 + unsigned long irqflags; 771 + 772 + if (!uncore->fw_get_funcs) 773 + return; 774 + 775 + spin_lock_irqsave(&uncore->lock, irqflags); 776 + __intel_uncore_forcewake_put(uncore, fw_domains, true); 769 777 spin_unlock_irqrestore(&uncore->lock, irqflags); 770 778 } 771 779 ··· 820 802 if (!uncore->fw_get_funcs) 821 803 return; 822 804 823 - __intel_uncore_forcewake_put(uncore, fw_domains); 805 + __intel_uncore_forcewake_put(uncore, fw_domains, false); 824 806 } 825 807 826 808 void assert_forcewakes_inactive(struct intel_uncore *uncore)
+2
drivers/gpu/drm/i915/intel_uncore.h
··· 246 246 enum forcewake_domains domains); 247 247 void intel_uncore_forcewake_put(struct intel_uncore *uncore, 248 248 enum forcewake_domains domains); 249 + void intel_uncore_forcewake_put_delayed(struct intel_uncore *uncore, 250 + enum forcewake_domains domains); 249 251 void intel_uncore_forcewake_flush(struct intel_uncore *uncore, 250 252 enum forcewake_domains fw_domains); 251 253
+2
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
··· 1560 1560 for (i = 0; i < gpu->nr_rings; i++) 1561 1561 a6xx_gpu->shadow[i] = 0; 1562 1562 1563 + gpu->suspend_count++; 1564 + 1563 1565 return 0; 1564 1566 } 1565 1567
+18
drivers/gpu/drm/msm/adreno/adreno_device.c
··· 608 608 return gpu->funcs->pm_resume(gpu); 609 609 } 610 610 611 + static int active_submits(struct msm_gpu *gpu) 612 + { 613 + int active_submits; 614 + mutex_lock(&gpu->active_lock); 615 + active_submits = gpu->active_submits; 616 + mutex_unlock(&gpu->active_lock); 617 + return active_submits; 618 + } 619 + 611 620 static int adreno_suspend(struct device *dev) 612 621 { 613 622 struct msm_gpu *gpu = dev_to_gpu(dev); 623 + int remaining; 624 + 625 + remaining = wait_event_timeout(gpu->retire_event, 626 + active_submits(gpu) == 0, 627 + msecs_to_jiffies(1000)); 628 + if (remaining == 0) { 629 + dev_err(dev, "Timeout waiting for GPU to suspend\n"); 630 + return -EBUSY; 631 + } 614 632 615 633 return gpu->funcs->pm_suspend(gpu); 616 634 }
+9 -2
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c
··· 26 26 struct dpu_hw_pcc_cfg *cfg) 27 27 { 28 28 29 - u32 base = ctx->cap->sblk->pcc.base; 29 + u32 base; 30 30 31 - if (!ctx || !base) { 31 + if (!ctx) { 32 + DRM_ERROR("invalid ctx %pK\n", ctx); 33 + return; 34 + } 35 + 36 + base = ctx->cap->sblk->pcc.base; 37 + 38 + if (!base) { 32 39 DRM_ERROR("invalid ctx %pK pcc base 0x%x\n", ctx, base); 33 40 return; 34 41 }
+6 -1
drivers/gpu/drm/msm/dsi/dsi.c
··· 40 40 41 41 of_node_put(phy_node); 42 42 43 - if (!phy_pdev || !msm_dsi->phy) { 43 + if (!phy_pdev) { 44 + DRM_DEV_ERROR(&pdev->dev, "%s: phy driver is not ready\n", __func__); 45 + return -EPROBE_DEFER; 46 + } 47 + if (!msm_dsi->phy) { 48 + put_device(&phy_pdev->dev); 44 49 DRM_DEV_ERROR(&pdev->dev, "%s: phy driver is not ready\n", __func__); 45 50 return -EPROBE_DEFER; 46 51 }
+3 -1
drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
··· 808 808 struct msm_dsi_phy_clk_request *clk_req, 809 809 struct msm_dsi_phy_shared_timings *shared_timings) 810 810 { 811 - struct device *dev = &phy->pdev->dev; 811 + struct device *dev; 812 812 int ret; 813 813 814 814 if (!phy || !phy->cfg->ops.enable) 815 815 return -EINVAL; 816 + 817 + dev = &phy->pdev->dev; 816 818 817 819 ret = dsi_phy_enable_resource(phy); 818 820 if (ret) {
+6 -1
drivers/gpu/drm/msm/hdmi/hdmi.c
··· 97 97 98 98 of_node_put(phy_node); 99 99 100 - if (!phy_pdev || !hdmi->phy) { 100 + if (!phy_pdev) { 101 101 DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n"); 102 + return -EPROBE_DEFER; 103 + } 104 + if (!hdmi->phy) { 105 + DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n"); 106 + put_device(&phy_pdev->dev); 102 107 return -EPROBE_DEFER; 103 108 } 104 109
+1 -4
drivers/gpu/drm/msm/msm_drv.c
··· 461 461 of_node_put(node); 462 462 if (ret) 463 463 return ret; 464 - size = r.end - r.start; 464 + size = r.end - r.start + 1; 465 465 DRM_INFO("using VRAM carveout: %lx@%pa\n", size, &r.start); 466 466 467 467 /* if we have no IOMMU, then we need to use carveout allocator. ··· 510 510 struct msm_drm_private *priv = dev_get_drvdata(dev); 511 511 struct drm_device *ddev; 512 512 struct msm_kms *kms; 513 - struct msm_mdss *mdss; 514 513 int ret, i; 515 514 516 515 ddev = drm_dev_alloc(drv, dev); ··· 519 520 } 520 521 ddev->dev_private = priv; 521 522 priv->dev = ddev; 522 - 523 - mdss = priv->mdss; 524 523 525 524 priv->wq = alloc_ordered_workqueue("msm", 0); 526 525 priv->hangcheck_period = DRM_MSM_HANGCHECK_DEFAULT_PERIOD;
+3
drivers/gpu/drm/msm/msm_gpu.c
··· 703 703 } 704 704 } 705 705 } 706 + 707 + wake_up_all(&gpu->retire_event); 706 708 } 707 709 708 710 static void retire_worker(struct kthread_work *work) ··· 850 848 INIT_LIST_HEAD(&gpu->active_list); 851 849 mutex_init(&gpu->active_lock); 852 850 mutex_init(&gpu->lock); 851 + init_waitqueue_head(&gpu->retire_event); 853 852 kthread_init_work(&gpu->retire_work, retire_worker); 854 853 kthread_init_work(&gpu->recover_work, recover_worker); 855 854 kthread_init_work(&gpu->fault_work, fault_worker);
+3
drivers/gpu/drm/msm/msm_gpu.h
··· 230 230 /* work for handling GPU recovery: */ 231 231 struct kthread_work recover_work; 232 232 233 + /** retire_event: notified when submits are retired: */ 234 + wait_queue_head_t retire_event; 235 + 233 236 /* work for handling active-list retiring: */ 234 237 struct kthread_work retire_work; 235 238
+19 -2
drivers/gpu/drm/msm/msm_gpu_devfreq.c
··· 133 133 CLOCK_MONOTONIC, HRTIMER_MODE_REL); 134 134 } 135 135 136 + static void cancel_idle_work(struct msm_gpu_devfreq *df) 137 + { 138 + hrtimer_cancel(&df->idle_work.timer); 139 + kthread_cancel_work_sync(&df->idle_work.work); 140 + } 141 + 142 + static void cancel_boost_work(struct msm_gpu_devfreq *df) 143 + { 144 + hrtimer_cancel(&df->boost_work.timer); 145 + kthread_cancel_work_sync(&df->boost_work.work); 146 + } 147 + 136 148 void msm_devfreq_cleanup(struct msm_gpu *gpu) 137 149 { 138 150 struct msm_gpu_devfreq *df = &gpu->devfreq; ··· 164 152 165 153 void msm_devfreq_suspend(struct msm_gpu *gpu) 166 154 { 167 - devfreq_suspend_device(gpu->devfreq.devfreq); 155 + struct msm_gpu_devfreq *df = &gpu->devfreq; 156 + 157 + devfreq_suspend_device(df->devfreq); 158 + 159 + cancel_idle_work(df); 160 + cancel_boost_work(df); 168 161 } 169 162 170 163 static void msm_devfreq_boost_work(struct kthread_work *work) ··· 213 196 /* 214 197 * Cancel any pending transition to idle frequency: 215 198 */ 216 - hrtimer_cancel(&df->idle_work.timer); 199 + cancel_idle_work(df); 217 200 218 201 idle_time = ktime_to_ms(ktime_sub(ktime_get(), df->idle_time)); 219 202
+4 -10
drivers/gpu/drm/vc4/vc4_dsi.c
··· 1262 1262 struct mipi_dsi_device *device) 1263 1263 { 1264 1264 struct vc4_dsi *dsi = host_to_dsi(host); 1265 - int ret; 1266 1265 1267 1266 dsi->lanes = device->lanes; 1268 1267 dsi->channel = device->channel; ··· 1296 1297 return 0; 1297 1298 } 1298 1299 1299 - ret = component_add(&dsi->pdev->dev, &vc4_dsi_ops); 1300 - if (ret) { 1301 - mipi_dsi_host_unregister(&dsi->dsi_host); 1302 - return ret; 1303 - } 1304 - 1305 - return 0; 1300 + return component_add(&dsi->pdev->dev, &vc4_dsi_ops); 1306 1301 } 1307 1302 1308 1303 static int vc4_dsi_host_detach(struct mipi_dsi_host *host, 1309 1304 struct mipi_dsi_device *device) 1310 1305 { 1306 + struct vc4_dsi *dsi = host_to_dsi(host); 1307 + 1308 + component_del(&dsi->pdev->dev, &vc4_dsi_ops); 1311 1309 return 0; 1312 1310 } 1313 1311 ··· 1682 1686 struct device *dev = &pdev->dev; 1683 1687 struct vc4_dsi *dsi = dev_get_drvdata(dev); 1684 1688 1685 - component_del(&pdev->dev, &vc4_dsi_ops); 1686 1689 mipi_dsi_host_unregister(&dsi->dsi_host); 1687 - 1688 1690 return 0; 1689 1691 } 1690 1692
+2 -3
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
··· 1140 1140 struct vmw_private *dev_priv, 1141 1141 struct vmw_fence_obj **p_fence, 1142 1142 uint32_t *p_handle); 1143 - extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, 1143 + extern int vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, 1144 1144 struct vmw_fpriv *vmw_fp, 1145 1145 int ret, 1146 1146 struct drm_vmw_fence_rep __user 1147 1147 *user_fence_rep, 1148 1148 struct vmw_fence_obj *fence, 1149 1149 uint32_t fence_handle, 1150 - int32_t out_fence_fd, 1151 - struct sync_file *sync_file); 1150 + int32_t out_fence_fd); 1152 1151 bool vmw_cmd_describe(const void *buf, u32 *size, char const **cmd); 1153 1152 1154 1153 /**
+17 -16
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
··· 3879 3879 * Also if copying fails, user-space will be unable to signal the fence object 3880 3880 * so we wait for it immediately, and then unreference the user-space reference. 3881 3881 */ 3882 - void 3882 + int 3883 3883 vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, 3884 3884 struct vmw_fpriv *vmw_fp, int ret, 3885 3885 struct drm_vmw_fence_rep __user *user_fence_rep, 3886 3886 struct vmw_fence_obj *fence, uint32_t fence_handle, 3887 - int32_t out_fence_fd, struct sync_file *sync_file) 3887 + int32_t out_fence_fd) 3888 3888 { 3889 3889 struct drm_vmw_fence_rep fence_rep; 3890 3890 3891 3891 if (user_fence_rep == NULL) 3892 - return; 3892 + return 0; 3893 3893 3894 3894 memset(&fence_rep, 0, sizeof(fence_rep)); 3895 3895 ··· 3917 3917 * handle. 3918 3918 */ 3919 3919 if (unlikely(ret != 0) && (fence_rep.error == 0)) { 3920 - if (sync_file) 3921 - fput(sync_file->file); 3922 - 3923 - if (fence_rep.fd != -1) { 3924 - put_unused_fd(fence_rep.fd); 3925 - fence_rep.fd = -1; 3926 - } 3927 - 3928 3920 ttm_ref_object_base_unref(vmw_fp->tfile, fence_handle); 3929 3921 VMW_DEBUG_USER("Fence copy error. Syncing.\n"); 3930 3922 (void) vmw_fence_obj_wait(fence, false, false, 3931 3923 VMW_FENCE_WAIT_TIMEOUT); 3932 3924 } 3925 + 3926 + return ret ? -EFAULT : 0; 3933 3927 } 3934 3928 3935 3929 /** ··· 4260 4266 4261 4267 (void) vmw_fence_obj_wait(fence, false, false, 4262 4268 VMW_FENCE_WAIT_TIMEOUT); 4269 + } 4270 + } 4271 + 4272 + ret = vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret, 4273 + user_fence_rep, fence, handle, out_fence_fd); 4274 + 4275 + if (sync_file) { 4276 + if (ret) { 4277 + /* usercopy of fence failed, put the file object */ 4278 + fput(sync_file->file); 4279 + put_unused_fd(out_fence_fd); 4263 4280 } else { 4264 4281 /* Link the fence with the FD created earlier */ 4265 4282 fd_install(out_fence_fd, sync_file->file); 4266 4283 } 4267 4284 } 4268 - 4269 - vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret, 4270 - user_fence_rep, fence, handle, out_fence_fd, 4271 - sync_file); 4272 4285 4273 4286 /* Don't unreference when handing fence out */ 4274 4287 if (unlikely(out_fence != NULL)) { ··· 4294 4293 */ 4295 4294 vmw_validation_unref_lists(&val_ctx); 4296 4295 4297 - return 0; 4296 + return ret; 4298 4297 4299 4298 out_unlock_binding: 4300 4299 mutex_unlock(&dev_priv->binding_mutex);
+1 -1
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
··· 1128 1128 } 1129 1129 1130 1130 vmw_execbuf_copy_fence_user(dev_priv, vmw_fp, 0, user_fence_rep, fence, 1131 - handle, -1, NULL); 1131 + handle, -1); 1132 1132 vmw_fence_obj_unreference(&fence); 1133 1133 return 0; 1134 1134 out_no_create:
+1 -1
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
··· 2501 2501 if (file_priv) 2502 2502 vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), 2503 2503 ret, user_fence_rep, fence, 2504 - handle, -1, NULL); 2504 + handle, -1); 2505 2505 if (out_fence) 2506 2506 *out_fence = fence; 2507 2507 else
+7
drivers/hv/hv_balloon.c
··· 1660 1660 unsigned long t; 1661 1661 int ret; 1662 1662 1663 + /* 1664 + * max_pkt_size should be large enough for one vmbus packet header plus 1665 + * our receive buffer size. Hyper-V sends messages up to 1666 + * HV_HYP_PAGE_SIZE bytes long on balloon channel. 1667 + */ 1668 + dev->channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2; 1669 + 1663 1670 ret = vmbus_open(dev->channel, dm_ring_size, dm_ring_size, NULL, 0, 1664 1671 balloon_onchannelcallback, dev); 1665 1672 if (ret)
+3
drivers/hwmon/adt7470.c
··· 662 662 struct adt7470_data *data = dev_get_drvdata(dev); 663 663 int err; 664 664 665 + if (val <= 0) 666 + return -EINVAL; 667 + 665 668 val = FAN_RPM_TO_PERIOD(val); 666 669 val = clamp_val(val, 1, 65534); 667 670
+11 -10
drivers/hwmon/lm90.c
··· 373 373 .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT 374 374 | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_CRIT, 375 375 .alert_alarms = 0x7c, 376 - .max_convrate = 8, 376 + .max_convrate = 7, 377 377 }, 378 378 [lm86] = { 379 379 .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT ··· 394 394 .max_convrate = 9, 395 395 }, 396 396 [max6646] = { 397 - .flags = LM90_HAVE_CRIT, 397 + .flags = LM90_HAVE_CRIT | LM90_HAVE_BROKEN_ALERT, 398 398 .alert_alarms = 0x7c, 399 399 .max_convrate = 6, 400 400 .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, 401 401 }, 402 402 [max6654] = { 403 + .flags = LM90_HAVE_BROKEN_ALERT, 403 404 .alert_alarms = 0x7c, 404 405 .max_convrate = 7, 405 406 .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, ··· 419 418 }, 420 419 [max6680] = { 421 420 .flags = LM90_HAVE_OFFSET | LM90_HAVE_CRIT 422 - | LM90_HAVE_CRIT_ALRM_SWP, 421 + | LM90_HAVE_CRIT_ALRM_SWP | LM90_HAVE_BROKEN_ALERT, 423 422 .alert_alarms = 0x7c, 424 423 .max_convrate = 7, 425 424 }, ··· 849 848 * Re-enable ALERT# output if it was originally enabled and 850 849 * relevant alarms are all clear 851 850 */ 852 - if (!(data->config_orig & 0x80) && 851 + if ((client->irq || !(data->config_orig & 0x80)) && 853 852 !(data->alarms & data->alert_alarms)) { 854 853 if (data->config & 0x80) { 855 854 dev_dbg(&client->dev, "Re-enabling ALERT#\n"); ··· 1808 1807 1809 1808 if (st & LM90_STATUS_LLOW) 1810 1809 hwmon_notify_event(data->hwmon_dev, hwmon_temp, 1811 - hwmon_temp_min, 0); 1810 + hwmon_temp_min_alarm, 0); 1812 1811 if (st & LM90_STATUS_RLOW) 1813 1812 hwmon_notify_event(data->hwmon_dev, hwmon_temp, 1814 - hwmon_temp_min, 1); 1813 + hwmon_temp_min_alarm, 1); 1815 1814 if (st2 & MAX6696_STATUS2_R2LOW) 1816 1815 hwmon_notify_event(data->hwmon_dev, hwmon_temp, 1817 - hwmon_temp_min, 2); 1816 + hwmon_temp_min_alarm, 2); 1818 1817 if (st & LM90_STATUS_LHIGH) 1819 1818 hwmon_notify_event(data->hwmon_dev, hwmon_temp, 1820 - hwmon_temp_max, 0); 1819 + hwmon_temp_max_alarm, 0); 1821 1820 if (st & LM90_STATUS_RHIGH) 1822 1821 hwmon_notify_event(data->hwmon_dev, hwmon_temp, 1823 - hwmon_temp_max, 1); 1822 + hwmon_temp_max_alarm, 1); 1824 1823 if (st2 & MAX6696_STATUS2_R2HIGH) 1825 1824 hwmon_notify_event(data->hwmon_dev, hwmon_temp, 1826 - hwmon_temp_max, 2); 1825 + hwmon_temp_max_alarm, 2); 1827 1826 1828 1827 return true; 1829 1828 }
+3 -3
drivers/hwmon/nct6775.c
··· 1175 1175 1176 1176 struct nct6775_data { 1177 1177 int addr; /* IO base of hw monitor block */ 1178 - int sioreg; /* SIO register address */ 1178 + struct nct6775_sio_data *sio_data; 1179 1179 enum kinds kind; 1180 1180 const char *name; 1181 1181 ··· 3559 3559 const char *buf, size_t count) 3560 3560 { 3561 3561 struct nct6775_data *data = dev_get_drvdata(dev); 3562 - struct nct6775_sio_data *sio_data = dev_get_platdata(dev); 3562 + struct nct6775_sio_data *sio_data = data->sio_data; 3563 3563 int nr = to_sensor_dev_attr(attr)->index - INTRUSION_ALARM_BASE; 3564 3564 unsigned long val; 3565 3565 u8 reg; ··· 3967 3967 return -ENOMEM; 3968 3968 3969 3969 data->kind = sio_data->kind; 3970 - data->sioreg = sio_data->sioreg; 3970 + data->sio_data = sio_data; 3971 3971 3972 3972 if (sio_data->access == access_direct) { 3973 3973 data->addr = res->start;
+1 -1
drivers/hwmon/pmbus/ir38064.c
··· 62 62 63 63 MODULE_DEVICE_TABLE(i2c, ir38064_id); 64 64 65 - static const struct of_device_id ir38064_of_match[] = { 65 + static const struct of_device_id __maybe_unused ir38064_of_match[] = { 66 66 { .compatible = "infineon,ir38060" }, 67 67 { .compatible = "infineon,ir38064" }, 68 68 { .compatible = "infineon,ir38164" },
-1
drivers/irqchip/irq-apple-aic.c
··· 178 178 struct irq_domain *hw_domain; 179 179 struct irq_domain *ipi_domain; 180 180 int nr_hw; 181 - int ipi_hwirq; 182 181 }; 183 182 184 183 static DEFINE_PER_CPU(uint32_t, aic_fiq_unmasked);
+101 -22
drivers/irqchip/irq-gic-v3-its.c
··· 4856 4856 .resume = its_restore_enable, 4857 4857 }; 4858 4858 4859 + static void __init __iomem *its_map_one(struct resource *res, int *err) 4860 + { 4861 + void __iomem *its_base; 4862 + u32 val; 4863 + 4864 + its_base = ioremap(res->start, SZ_64K); 4865 + if (!its_base) { 4866 + pr_warn("ITS@%pa: Unable to map ITS registers\n", &res->start); 4867 + *err = -ENOMEM; 4868 + return NULL; 4869 + } 4870 + 4871 + val = readl_relaxed(its_base + GITS_PIDR2) & GIC_PIDR2_ARCH_MASK; 4872 + if (val != 0x30 && val != 0x40) { 4873 + pr_warn("ITS@%pa: No ITS detected, giving up\n", &res->start); 4874 + *err = -ENODEV; 4875 + goto out_unmap; 4876 + } 4877 + 4878 + *err = its_force_quiescent(its_base); 4879 + if (*err) { 4880 + pr_warn("ITS@%pa: Failed to quiesce, giving up\n", &res->start); 4881 + goto out_unmap; 4882 + } 4883 + 4884 + return its_base; 4885 + 4886 + out_unmap: 4887 + iounmap(its_base); 4888 + return NULL; 4889 + } 4890 + 4859 4891 static int its_init_domain(struct fwnode_handle *handle, struct its_node *its) 4860 4892 { 4861 4893 struct irq_domain *inner_domain; ··· 4995 4963 { 4996 4964 struct its_node *its; 4997 4965 void __iomem *its_base; 4998 - u32 val, ctlr; 4999 4966 u64 baser, tmp, typer; 5000 4967 struct page *page; 4968 + u32 ctlr; 5001 4969 int err; 5002 4970 5003 - its_base = ioremap(res->start, SZ_64K); 5004 - if (!its_base) { 5005 - pr_warn("ITS@%pa: Unable to map ITS registers\n", &res->start); 5006 - return -ENOMEM; 5007 - } 5008 - 5009 - val = readl_relaxed(its_base + GITS_PIDR2) & GIC_PIDR2_ARCH_MASK; 5010 - if (val != 0x30 && val != 0x40) { 5011 - pr_warn("ITS@%pa: No ITS detected, giving up\n", &res->start); 5012 - err = -ENODEV; 5013 - goto out_unmap; 5014 - } 5015 - 5016 - err = its_force_quiescent(its_base); 5017 - if (err) { 5018 - pr_warn("ITS@%pa: Failed to quiesce, giving up\n", &res->start); 5019 - goto out_unmap; 5020 - } 4971 + its_base = its_map_one(res, &err); 4972 + if (!its_base) 4973 + return err; 5021 4974 5022 4975 pr_info("ITS %pR\n", res); 5023 4976 ··· 5258 5241 5259 5242 out: 5260 5243 /* Last CPU being brought up gets to issue the cleanup */ 5261 - if (cpumask_equal(&cpus_booted_once_mask, cpu_possible_mask)) 5244 + if (!IS_ENABLED(CONFIG_SMP) || 5245 + cpumask_equal(&cpus_booted_once_mask, cpu_possible_mask)) 5262 5246 schedule_work(&rdist_memreserve_cpuhp_cleanup_work); 5263 5247 5264 5248 gic_data_rdist()->flags |= RD_LOCAL_MEMRESERVE_DONE; 5265 5249 return ret; 5250 + } 5251 + 5252 + /* Mark all the BASER registers as invalid before they get reprogrammed */ 5253 + static int __init its_reset_one(struct resource *res) 5254 + { 5255 + void __iomem *its_base; 5256 + int err, i; 5257 + 5258 + its_base = its_map_one(res, &err); 5259 + if (!its_base) 5260 + return err; 5261 + 5262 + for (i = 0; i < GITS_BASER_NR_REGS; i++) 5263 + gits_write_baser(0, its_base + GITS_BASER + (i << 3)); 5264 + 5265 + iounmap(its_base); 5266 + return 0; 5266 5267 } 5267 5268 5268 5269 static const struct of_device_id its_device_id[] = { ··· 5292 5257 { 5293 5258 struct device_node *np; 5294 5259 struct resource res; 5260 + 5261 + /* 5262 + * Make sure *all* the ITS are reset before we probe any, as 5263 + * they may be sharing memory. If any of the ITS fails to 5264 + * reset, don't even try to go any further, as this could 5265 + * result in something even worse. 5266 + */ 5267 + for (np = of_find_matching_node(node, its_device_id); np; 5268 + np = of_find_matching_node(np, its_device_id)) { 5269 + int err; 5270 + 5271 + if (!of_device_is_available(np) || 5272 + !of_property_read_bool(np, "msi-controller") || 5273 + of_address_to_resource(np, 0, &res)) 5274 + continue; 5275 + 5276 + err = its_reset_one(&res); 5277 + if (err) 5278 + return err; 5279 + } 5295 5280 5296 5281 for (np = of_find_matching_node(node, its_device_id); np; 5297 5282 np = of_find_matching_node(np, its_device_id)) { ··· 5475 5420 return err; 5476 5421 } 5477 5422 5423 + static int __init its_acpi_reset(union acpi_subtable_headers *header, 5424 + const unsigned long end) 5425 + { 5426 + struct acpi_madt_generic_translator *its_entry; 5427 + struct resource res; 5428 + 5429 + its_entry = (struct acpi_madt_generic_translator *)header; 5430 + res = (struct resource) { 5431 + .start = its_entry->base_address, 5432 + .end = its_entry->base_address + ACPI_GICV3_ITS_MEM_SIZE - 1, 5433 + .flags = IORESOURCE_MEM, 5434 + }; 5435 + 5436 + return its_reset_one(&res); 5437 + } 5438 + 5478 5439 static void __init its_acpi_probe(void) 5479 5440 { 5480 5441 acpi_table_parse_srat_its(); 5481 - acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, 5482 - gic_acpi_parse_madt_its, 0); 5442 + /* 5443 + * Make sure *all* the ITS are reset before we probe any, as 5444 + * they may be sharing memory. If any of the ITS fails to 5445 + * reset, don't even try to go any further, as this could 5446 + * result in something even worse. 5447 + */ 5448 + if (acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, 5449 + its_acpi_reset, 0) > 0) 5450 + acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, 5451 + gic_acpi_parse_madt_its, 0); 5483 5452 acpi_its_srat_maps_free(); 5484 5453 } 5485 5454 #else
+1 -1
drivers/irqchip/irq-loongson-pch-msi.c
··· 241 241 return 0; 242 242 243 243 err_map: 244 - kfree(priv->msi_map); 244 + bitmap_free(priv->msi_map); 245 245 err_priv: 246 246 kfree(priv); 247 247 return ret;
+12 -6
drivers/irqchip/irq-realtek-rtl.c
··· 62 62 63 63 static int intc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) 64 64 { 65 - irq_set_chip_and_handler(hw, &realtek_ictl_irq, handle_level_irq); 65 + irq_set_chip_and_handler(irq, &realtek_ictl_irq, handle_level_irq); 66 66 67 67 return 0; 68 68 } ··· 76 76 { 77 77 struct irq_chip *chip = irq_desc_get_chip(desc); 78 78 struct irq_domain *domain; 79 - unsigned int pending; 79 + unsigned long pending; 80 + unsigned int soc_int; 80 81 81 82 chained_irq_enter(chip, desc); 82 83 pending = readl(REG(RTL_ICTL_GIMR)) & readl(REG(RTL_ICTL_GISR)); 84 + 83 85 if (unlikely(!pending)) { 84 86 spurious_interrupt(); 85 87 goto out; 86 88 } 89 + 87 90 domain = irq_desc_get_handler_data(desc); 88 - generic_handle_domain_irq(domain, __ffs(pending)); 91 + for_each_set_bit(soc_int, &pending, 32) 92 + generic_handle_domain_irq(domain, soc_int); 89 93 90 94 out: 91 95 chained_irq_exit(chip, desc); ··· 99 95 * SoC interrupts are cascaded to MIPS CPU interrupts according to the 100 96 * interrupt-map in the device tree. Each SoC interrupt gets 4 bits for 101 97 * the CPU interrupt in an Interrupt Routing Register. Max 32 SoC interrupts 102 - * thus go into 4 IRRs. 98 + * thus go into 4 IRRs. A routing value of '0' means the interrupt is left 99 + * disconnected. Routing values {1..15} connect to output lines {0..14}. 103 100 */ 104 101 static int __init map_interrupts(struct device_node *node, struct irq_domain *domain) 105 102 { ··· 139 134 of_node_put(cpu_ictl); 140 135 141 136 cpu_int = be32_to_cpup(imap + 2); 142 - if (cpu_int > 7) 137 + if (cpu_int > 7 || cpu_int < 2) 143 138 return -EINVAL; 144 139 145 140 if (!(mips_irqs_set & BIT(cpu_int))) { ··· 148 143 mips_irqs_set |= BIT(cpu_int); 149 144 } 150 145 151 - regs[(soc_int * 4) / 32] |= cpu_int << (soc_int * 4) % 32; 146 + /* Use routing values (1..6) for CPU interrupts (2..7) */ 147 + regs[(soc_int * 4) / 32] |= (cpu_int - 1) << (soc_int * 4) % 32; 152 148 imap += 3; 153 149 } 154 150
+3 -17
drivers/md/dm.c
··· 489 489 struct mapped_device *md = io->md; 490 490 struct bio *bio = io->orig_bio; 491 491 492 - io->start_time = bio_start_io_acct(bio); 492 + bio_start_io_acct_time(bio, io->start_time); 493 493 if (unlikely(dm_stats_used(&md->stats))) 494 494 dm_stats_account_io(&md->stats, bio_data_dir(bio), 495 495 bio->bi_iter.bi_sector, bio_sectors(bio), ··· 535 535 io->md = md; 536 536 spin_lock_init(&io->endio_lock); 537 537 538 - start_io_acct(io); 538 + io->start_time = jiffies; 539 539 540 540 return io; 541 541 } ··· 1442 1442 ci->sector = bio->bi_iter.bi_sector; 1443 1443 } 1444 1444 1445 - #define __dm_part_stat_sub(part, field, subnd) \ 1446 - (part_stat_get(part, field) -= (subnd)) 1447 - 1448 1445 /* 1449 1446 * Entry point to split a bio into clones and submit them to the targets. 1450 1447 */ ··· 1477 1480 GFP_NOIO, &md->queue->bio_split); 1478 1481 ci.io->orig_bio = b; 1479 1482 1480 - /* 1481 - * Adjust IO stats for each split, otherwise upon queue 1482 - * reentry there will be redundant IO accounting. 1483 - * NOTE: this is a stop-gap fix, a proper fix involves 1484 - * significant refactoring of DM core's bio splitting 1485 - * (by eliminating DM's splitting and just using bio_split) 1486 - */ 1487 - part_stat_lock(); 1488 - __dm_part_stat_sub(dm_disk(md)->part0, 1489 - sectors[op_stat_group(bio_op(bio))], ci.sector_count); 1490 - part_stat_unlock(); 1491 - 1492 1483 bio_chain(b, bio); 1493 1484 trace_block_split(b, bio->bi_iter.bi_sector); 1494 1485 submit_bio_noacct(bio); 1495 1486 } 1496 1487 } 1488 + start_io_acct(ci.io); 1497 1489 1498 1490 /* drop the extra reference count */ 1499 1491 dm_io_dec_pending(ci.io, errno_to_blk_status(error));
+4
drivers/misc/eeprom/at25.c
··· 440 440 return -ENXIO; 441 441 } 442 442 443 + at25 = devm_kzalloc(&spi->dev, sizeof(*at25), GFP_KERNEL); 444 + if (!at25) 445 + return -ENOMEM; 446 + 443 447 mutex_init(&at25->lock); 444 448 at25->spi = spi; 445 449 spi_set_drvdata(spi, at25);
-4
drivers/net/bonding/bond_main.c
··· 4133 4133 4134 4134 fallthrough; 4135 4135 case SIOCGHWTSTAMP: 4136 - rcu_read_lock(); 4137 4136 real_dev = bond_option_active_slave_get_rcu(bond); 4138 - rcu_read_unlock(); 4139 4137 if (!real_dev) 4140 4138 return -EOPNOTSUPP; 4141 4139 ··· 5380 5382 struct net_device *real_dev; 5381 5383 struct phy_device *phydev; 5382 5384 5383 - rcu_read_lock(); 5384 5385 real_dev = bond_option_active_slave_get_rcu(bond); 5385 - rcu_read_unlock(); 5386 5386 if (real_dev) { 5387 5387 ops = real_dev->ethtool_ops; 5388 5388 phydev = real_dev->phydev;
+1
drivers/net/can/flexcan/flexcan-core.c
··· 296 296 static const struct flexcan_devtype_data fsl_mcf5441x_devtype_data = { 297 297 .quirks = FLEXCAN_QUIRK_BROKEN_PERR_STATE | 298 298 FLEXCAN_QUIRK_NR_IRQ_3 | FLEXCAN_QUIRK_NR_MB_16 | 299 + FLEXCAN_QUIRK_SUPPPORT_RX_MAILBOX | 299 300 FLEXCAN_QUIRK_SUPPPORT_RX_FIFO, 300 301 }; 301 302
+1 -1
drivers/net/can/flexcan/flexcan.h
··· 21 21 * Below is some version info we got: 22 22 * SOC Version IP-Version Glitch- [TR]WRN_INT IRQ Err Memory err RTR rece- FD Mode MB 23 23 * Filter? connected? Passive detection ption in MB Supported? 24 - * MCF5441X FlexCAN2 ? no yes no no yes no 16 24 + * MCF5441X FlexCAN2 ? no yes no no no no 16 25 25 * MX25 FlexCAN2 03.00.00.00 no no no no no no 64 26 26 * MX28 FlexCAN2 03.00.04.00 yes yes no no no no 64 27 27 * MX35 FlexCAN2 03.00.00.00 no no no no no no 64
+6
drivers/net/can/m_can/m_can.c
··· 336 336 u32 addr_offset = cdev->mcfg[MRAM_RXF0].off + fgi * RXF0_ELEMENT_SIZE + 337 337 offset; 338 338 339 + if (val_count == 0) 340 + return 0; 341 + 339 342 return cdev->ops->read_fifo(cdev, addr_offset, val, val_count); 340 343 } 341 344 ··· 348 345 { 349 346 u32 addr_offset = cdev->mcfg[MRAM_TXB].off + fpi * TXB_ELEMENT_SIZE + 350 347 offset; 348 + 349 + if (val_count == 0) 350 + return 0; 351 351 352 352 return cdev->ops->write_fifo(cdev, addr_offset, val, val_count); 353 353 }
+1 -1
drivers/net/can/m_can/tcan4x5x-regmap.c
··· 12 12 #define TCAN4X5X_SPI_INSTRUCTION_WRITE (0x61 << 24) 13 13 #define TCAN4X5X_SPI_INSTRUCTION_READ (0x41 << 24) 14 14 15 - #define TCAN4X5X_MAX_REGISTER 0x8ffc 15 + #define TCAN4X5X_MAX_REGISTER 0x87fc 16 16 17 17 static int tcan4x5x_regmap_gather_write(void *context, 18 18 const void *reg, size_t reg_len,
+4 -2
drivers/net/ethernet/3com/typhoon.c
··· 2278 2278 struct net_device *dev; 2279 2279 struct typhoon *tp; 2280 2280 int card_id = (int) ent->driver_data; 2281 + u8 addr[ETH_ALEN] __aligned(4); 2281 2282 void __iomem *ioaddr; 2282 2283 void *shared; 2283 2284 dma_addr_t shared_dma; ··· 2410 2409 goto error_out_reset; 2411 2410 } 2412 2411 2413 - *(__be16 *)&dev->dev_addr[0] = htons(le16_to_cpu(xp_resp[0].parm1)); 2414 - *(__be32 *)&dev->dev_addr[2] = htonl(le32_to_cpu(xp_resp[0].parm2)); 2412 + *(__be16 *)&addr[0] = htons(le16_to_cpu(xp_resp[0].parm1)); 2413 + *(__be32 *)&addr[2] = htonl(le32_to_cpu(xp_resp[0].parm2)); 2414 + eth_hw_addr_set(dev, addr); 2415 2415 2416 2416 if (!is_valid_ether_addr(dev->dev_addr)) { 2417 2417 err_msg = "Could not obtain valid ethernet address, aborting";
+4 -2
drivers/net/ethernet/8390/etherh.c
··· 655 655 struct ei_device *ei_local; 656 656 struct net_device *dev; 657 657 struct etherh_priv *eh; 658 + u8 addr[ETH_ALEN]; 658 659 int ret; 659 660 660 661 ret = ecard_request_resources(ec); ··· 725 724 spin_lock_init(&ei_local->page_lock); 726 725 727 726 if (ec->cid.product == PROD_ANT_ETHERM) { 728 - etherm_addr(dev->dev_addr); 727 + etherm_addr(addr); 729 728 ei_local->reg_offset = etherm_regoffsets; 730 729 } else { 731 - etherh_addr(dev->dev_addr, ec); 730 + etherh_addr(addr, ec); 732 731 ei_local->reg_offset = etherh_regoffsets; 733 732 } 733 + eth_hw_addr_set(dev, addr); 734 734 735 735 ei_local->name = dev->name; 736 736 ei_local->word16 = 1;
+3 -1
drivers/net/ethernet/amd/declance.c
··· 1032 1032 int i, ret; 1033 1033 unsigned long esar_base; 1034 1034 unsigned char *esar; 1035 + u8 addr[ETH_ALEN]; 1035 1036 const char *desc; 1036 1037 1037 1038 if (dec_lance_debug && version_printed++ == 0) ··· 1229 1228 break; 1230 1229 } 1231 1230 for (i = 0; i < 6; i++) 1232 - dev->dev_addr[i] = esar[i * 4]; 1231 + addr[i] = esar[i * 4]; 1232 + eth_hw_addr_set(dev, addr); 1233 1233 1234 1234 printk("%s: %s, addr = %pM, irq = %d\n", 1235 1235 name, desc, dev->dev_addr, dev->irq);
+2 -4
drivers/net/ethernet/aquantia/atlantic/aq_filters.c
··· 826 826 struct aq_hw_s *aq_hw = aq_nic->aq_hw; 827 827 int hweight = 0; 828 828 int err = 0; 829 - int i; 830 829 831 830 if (unlikely(!aq_hw_ops->hw_filter_vlan_set)) 832 831 return -EOPNOTSUPP; ··· 836 837 aq_nic->aq_hw_rx_fltrs.fl2.aq_vlans); 837 838 838 839 if (aq_nic->ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) { 839 - for (i = 0; i < BITS_TO_LONGS(VLAN_N_VID); i++) 840 - hweight += hweight_long(aq_nic->active_vlans[i]); 840 + hweight = bitmap_weight(aq_nic->active_vlans, VLAN_N_VID); 841 841 842 842 err = aq_hw_ops->hw_filter_vlan_ctrl(aq_hw, false); 843 843 if (err) ··· 869 871 struct aq_hw_s *aq_hw = aq_nic->aq_hw; 870 872 int err = 0; 871 873 872 - memset(aq_nic->active_vlans, 0, sizeof(aq_nic->active_vlans)); 874 + bitmap_zero(aq_nic->active_vlans, VLAN_N_VID); 873 875 aq_fvlan_rebuild(aq_nic, aq_nic->active_vlans, 874 876 aq_nic->aq_hw_rx_fltrs.fl2.aq_vlans); 875 877
+1 -3
drivers/net/ethernet/broadcom/sb1250-mac.c
··· 2183 2183 ea_reg >>= 8; 2184 2184 } 2185 2185 2186 - for (i = 0; i < 6; i++) { 2187 - dev->dev_addr[i] = eaddr[i]; 2188 - } 2186 + eth_hw_addr_set(dev, eaddr); 2189 2187 2190 2188 /* 2191 2189 * Initialize context (get pointers to registers and stuff), then
+7 -5
drivers/net/ethernet/freescale/fec_mpc52xx.c
··· 99 99 netif_wake_queue(dev); 100 100 } 101 101 102 - static void mpc52xx_fec_set_paddr(struct net_device *dev, u8 *mac) 102 + static void mpc52xx_fec_set_paddr(struct net_device *dev, const u8 *mac) 103 103 { 104 104 struct mpc52xx_fec_priv *priv = netdev_priv(dev); 105 105 struct mpc52xx_fec __iomem *fec = priv->fec; 106 106 107 - out_be32(&fec->paddr1, *(u32 *)(&mac[0])); 108 - out_be32(&fec->paddr2, (*(u16 *)(&mac[4]) << 16) | FEC_PADDR2_TYPE); 107 + out_be32(&fec->paddr1, *(const u32 *)(&mac[0])); 108 + out_be32(&fec->paddr2, (*(const u16 *)(&mac[4]) << 16) | FEC_PADDR2_TYPE); 109 109 } 110 110 111 111 static int mpc52xx_fec_set_mac_address(struct net_device *dev, void *addr) ··· 893 893 rv = of_get_ethdev_address(np, ndev); 894 894 if (rv) { 895 895 struct mpc52xx_fec __iomem *fec = priv->fec; 896 + u8 addr[ETH_ALEN] __aligned(4); 896 897 897 898 /* 898 899 * If the MAC addresse is not provided via DT then read 899 900 * it back from the controller regs 900 901 */ 901 - *(u32 *)(&ndev->dev_addr[0]) = in_be32(&fec->paddr1); 902 - *(u16 *)(&ndev->dev_addr[4]) = in_be32(&fec->paddr2) >> 16; 902 + *(u32 *)(&addr[0]) = in_be32(&fec->paddr1); 903 + *(u16 *)(&addr[4]) = in_be32(&fec->paddr2) >> 16; 904 + eth_hw_addr_set(ndev, addr); 903 905 } 904 906 905 907 /*
+1 -1
drivers/net/ethernet/google/gve/gve.h
··· 843 843 /* buffers */ 844 844 int gve_alloc_page(struct gve_priv *priv, struct device *dev, 845 845 struct page **page, dma_addr_t *dma, 846 - enum dma_data_direction); 846 + enum dma_data_direction, gfp_t gfp_flags); 847 847 void gve_free_page(struct device *dev, struct page *page, dma_addr_t dma, 848 848 enum dma_data_direction); 849 849 /* tx handling */
+3 -3
drivers/net/ethernet/google/gve/gve_main.c
··· 766 766 767 767 int gve_alloc_page(struct gve_priv *priv, struct device *dev, 768 768 struct page **page, dma_addr_t *dma, 769 - enum dma_data_direction dir) 769 + enum dma_data_direction dir, gfp_t gfp_flags) 770 770 { 771 - *page = alloc_page(GFP_KERNEL); 771 + *page = alloc_page(gfp_flags); 772 772 if (!*page) { 773 773 priv->page_alloc_fail++; 774 774 return -ENOMEM; ··· 811 811 for (i = 0; i < pages; i++) { 812 812 err = gve_alloc_page(priv, &priv->pdev->dev, &qpl->pages[i], 813 813 &qpl->page_buses[i], 814 - gve_qpl_dma_dir(priv, id)); 814 + gve_qpl_dma_dir(priv, id), GFP_KERNEL); 815 815 /* caller handles clean up */ 816 816 if (err) 817 817 return -ENOMEM;
+2 -1
drivers/net/ethernet/google/gve/gve_rx.c
··· 86 86 dma_addr_t dma; 87 87 int err; 88 88 89 - err = gve_alloc_page(priv, dev, &page, &dma, DMA_FROM_DEVICE); 89 + err = gve_alloc_page(priv, dev, &page, &dma, DMA_FROM_DEVICE, 90 + GFP_ATOMIC); 90 91 if (err) 91 92 return err; 92 93
+1 -1
drivers/net/ethernet/google/gve/gve_rx_dqo.c
··· 157 157 int err; 158 158 159 159 err = gve_alloc_page(priv, &priv->pdev->dev, &buf_state->page_info.page, 160 - &buf_state->addr, DMA_FROM_DEVICE); 160 + &buf_state->addr, DMA_FROM_DEVICE, GFP_KERNEL); 161 161 if (err) 162 162 return err; 163 163
+1 -2
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
··· 2043 2043 break; 2044 2044 } 2045 2045 2046 - if (event_cause != HCLGEVF_VECTOR0_EVENT_OTHER) 2047 - hclgevf_enable_vector(&hdev->misc_vector, true); 2046 + hclgevf_enable_vector(&hdev->misc_vector, true); 2048 2047 2049 2048 return IRQ_HANDLED; 2050 2049 }
+3 -1
drivers/net/ethernet/i825xx/ether1.c
··· 986 986 ether1_probe(struct expansion_card *ec, const struct ecard_id *id) 987 987 { 988 988 struct net_device *dev; 989 + u8 addr[ETH_ALEN]; 989 990 int i, ret = 0; 990 991 991 992 ether1_banner(); ··· 1016 1015 } 1017 1016 1018 1017 for (i = 0; i < 6; i++) 1019 - dev->dev_addr[i] = readb(IDPROM_ADDRESS + (i << 2)); 1018 + addr[i] = readb(IDPROM_ADDRESS + (i << 2)); 1019 + eth_hw_addr_set(dev, addr); 1020 1020 1021 1021 if (ether1_init_2(dev)) { 1022 1022 ret = -ENODEV;
+100 -67
drivers/net/ethernet/ibm/ibmvnic.c
··· 2602 2602 struct ibmvnic_rwi *rwi; 2603 2603 unsigned long flags; 2604 2604 u32 reset_state; 2605 + int num_fails = 0; 2605 2606 int rc = 0; 2606 2607 2607 2608 adapter = container_of(work, struct ibmvnic_adapter, ibmvnic_reset); ··· 2656 2655 rc = do_hard_reset(adapter, rwi, reset_state); 2657 2656 rtnl_unlock(); 2658 2657 } 2659 - if (rc) { 2660 - /* give backing device time to settle down */ 2658 + if (rc) 2659 + num_fails++; 2660 + else 2661 + num_fails = 0; 2662 + 2663 + /* If auto-priority-failover is enabled we can get 2664 + * back to back failovers during resets, resulting 2665 + * in at least two failed resets (from high-priority 2666 + * backing device to low-priority one and then back) 2667 + * If resets continue to fail beyond that, give the 2668 + * adapter some time to settle down before retrying. 2669 + */ 2670 + if (num_fails >= 3) { 2661 2671 netdev_dbg(adapter->netdev, 2662 - "[S:%s] Hard reset failed, waiting 60 secs\n", 2663 - adapter_state_to_string(adapter->state)); 2672 + "[S:%s] Hard reset failed %d times, waiting 60 secs\n", 2673 + adapter_state_to_string(adapter->state), 2674 + num_fails); 2664 2675 set_current_state(TASK_UNINTERRUPTIBLE); 2665 2676 schedule_timeout(60 * HZ); 2666 2677 } ··· 3857 3844 struct device *dev = &adapter->vdev->dev; 3858 3845 union ibmvnic_crq crq; 3859 3846 int max_entries; 3847 + int cap_reqs; 3848 + 3849 + /* We send out 6 or 7 REQUEST_CAPABILITY CRQs below (depending on 3850 + * the PROMISC flag). Initialize this count upfront. When the tasklet 3851 + * receives a response to all of these, it will send the next protocol 3852 + * message (QUERY_IP_OFFLOAD). 3853 + */ 3854 + if (!(adapter->netdev->flags & IFF_PROMISC) || 3855 + adapter->promisc_supported) 3856 + cap_reqs = 7; 3857 + else 3858 + cap_reqs = 6; 3860 3859 3861 3860 if (!retry) { 3862 3861 /* Sub-CRQ entries are 32 byte long */ 3863 3862 int entries_page = 4 * PAGE_SIZE / (sizeof(u64) * 4); 3863 + 3864 + atomic_set(&adapter->running_cap_crqs, cap_reqs); 3864 3865 3865 3866 if (adapter->min_tx_entries_per_subcrq > entries_page || 3866 3867 adapter->min_rx_add_entries_per_subcrq > entries_page) { ··· 3936 3909 adapter->opt_rx_comp_queues; 3937 3910 3938 3911 adapter->req_rx_add_queues = adapter->max_rx_add_queues; 3912 + } else { 3913 + atomic_add(cap_reqs, &adapter->running_cap_crqs); 3939 3914 } 3940 - 3941 3915 memset(&crq, 0, sizeof(crq)); 3942 3916 crq.request_capability.first = IBMVNIC_CRQ_CMD; 3943 3917 crq.request_capability.cmd = REQUEST_CAPABILITY; 3944 3918 3945 3919 crq.request_capability.capability = cpu_to_be16(REQ_TX_QUEUES); 3946 3920 crq.request_capability.number = cpu_to_be64(adapter->req_tx_queues); 3947 - atomic_inc(&adapter->running_cap_crqs); 3921 + cap_reqs--; 3948 3922 ibmvnic_send_crq(adapter, &crq); 3949 3923 3950 3924 crq.request_capability.capability = cpu_to_be16(REQ_RX_QUEUES); 3951 3925 crq.request_capability.number = cpu_to_be64(adapter->req_rx_queues); 3952 - atomic_inc(&adapter->running_cap_crqs); 3926 + cap_reqs--; 3953 3927 ibmvnic_send_crq(adapter, &crq); 3954 3928 3955 3929 crq.request_capability.capability = cpu_to_be16(REQ_RX_ADD_QUEUES); 3956 3930 crq.request_capability.number = cpu_to_be64(adapter->req_rx_add_queues); 3957 - atomic_inc(&adapter->running_cap_crqs); 3931 + cap_reqs--; 3958 3932 ibmvnic_send_crq(adapter, &crq); 3959 3933 3960 3934 crq.request_capability.capability = 3961 3935 cpu_to_be16(REQ_TX_ENTRIES_PER_SUBCRQ); 3962 3936 crq.request_capability.number = 3963 3937 cpu_to_be64(adapter->req_tx_entries_per_subcrq); 3964 - atomic_inc(&adapter->running_cap_crqs); 3938 + cap_reqs--; 3965 3939 ibmvnic_send_crq(adapter, &crq); 3966 3940 3967 3941 crq.request_capability.capability = 3968 3942 cpu_to_be16(REQ_RX_ADD_ENTRIES_PER_SUBCRQ); 3969 3943 crq.request_capability.number = 3970 3944 cpu_to_be64(adapter->req_rx_add_entries_per_subcrq); 3971 - atomic_inc(&adapter->running_cap_crqs); 3945 + cap_reqs--; 3972 3946 ibmvnic_send_crq(adapter, &crq); 3973 3947 3974 3948 crq.request_capability.capability = cpu_to_be16(REQ_MTU); 3975 3949 crq.request_capability.number = cpu_to_be64(adapter->req_mtu); 3976 - atomic_inc(&adapter->running_cap_crqs); 3950 + cap_reqs--; 3977 3951 ibmvnic_send_crq(adapter, &crq); 3978 3952 3979 3953 if (adapter->netdev->flags & IFF_PROMISC) { ··· 3982 3954 crq.request_capability.capability = 3983 3955 cpu_to_be16(PROMISC_REQUESTED); 3984 3956 crq.request_capability.number = cpu_to_be64(1); 3985 - atomic_inc(&adapter->running_cap_crqs); 3957 + cap_reqs--; 3986 3958 ibmvnic_send_crq(adapter, &crq); 3987 3959 } 3988 3960 } else { 3989 3961 crq.request_capability.capability = 3990 3962 cpu_to_be16(PROMISC_REQUESTED); 3991 3963 crq.request_capability.number = cpu_to_be64(0); 3992 - atomic_inc(&adapter->running_cap_crqs); 3964 + cap_reqs--; 3993 3965 ibmvnic_send_crq(adapter, &crq); 3994 3966 } 3967 + 3968 + /* Keep at end to catch any discrepancy between expected and actual 3969 + * CRQs sent. 3970 + */ 3971 + WARN_ON(cap_reqs != 0); 3995 3972 } 3996 3973 3997 3974 static int pending_scrq(struct ibmvnic_adapter *adapter, ··· 4390 4357 static void send_query_cap(struct ibmvnic_adapter *adapter) 4391 4358 { 4392 4359 union ibmvnic_crq crq; 4360 + int cap_reqs; 4393 4361 4394 - atomic_set(&adapter->running_cap_crqs, 0); 4362 + /* We send out 25 QUERY_CAPABILITY CRQs below. Initialize this count 4363 + * upfront. When the tasklet receives a response to all of these, it 4364 + * can send out the next protocol messaage (REQUEST_CAPABILITY). 4365 + */ 4366 + cap_reqs = 25; 4367 + 4368 + atomic_set(&adapter->running_cap_crqs, cap_reqs); 4369 + 4395 4370 memset(&crq, 0, sizeof(crq)); 4396 4371 crq.query_capability.first = IBMVNIC_CRQ_CMD; 4397 4372 crq.query_capability.cmd = QUERY_CAPABILITY; 4398 4373 4399 4374 crq.query_capability.capability = cpu_to_be16(MIN_TX_QUEUES); 4400 - atomic_inc(&adapter->running_cap_crqs); 4401 4375 ibmvnic_send_crq(adapter, &crq); 4376 + cap_reqs--; 4402 4377 4403 4378 crq.query_capability.capability = cpu_to_be16(MIN_RX_QUEUES); 4404 - atomic_inc(&adapter->running_cap_crqs); 4405 4379 ibmvnic_send_crq(adapter, &crq); 4380 + cap_reqs--; 4406 4381 4407 4382 crq.query_capability.capability = cpu_to_be16(MIN_RX_ADD_QUEUES); 4408 - atomic_inc(&adapter->running_cap_crqs); 4409 4383 ibmvnic_send_crq(adapter, &crq); 4384 + cap_reqs--; 4410 4385 4411 4386 crq.query_capability.capability = cpu_to_be16(MAX_TX_QUEUES); 4412 - atomic_inc(&adapter->running_cap_crqs); 4413 4387 ibmvnic_send_crq(adapter, &crq); 4388 + cap_reqs--; 4414 4389 4415 4390 crq.query_capability.capability = cpu_to_be16(MAX_RX_QUEUES); 4416 - atomic_inc(&adapter->running_cap_crqs); 4417 4391 ibmvnic_send_crq(adapter, &crq); 4392 + cap_reqs--; 4418 4393 4419 4394 crq.query_capability.capability = cpu_to_be16(MAX_RX_ADD_QUEUES); 4420 - atomic_inc(&adapter->running_cap_crqs); 4421 4395 ibmvnic_send_crq(adapter, &crq); 4396 + cap_reqs--; 4422 4397 4423 4398 crq.query_capability.capability = 4424 4399 cpu_to_be16(MIN_TX_ENTRIES_PER_SUBCRQ); 4425 - atomic_inc(&adapter->running_cap_crqs); 4426 4400 ibmvnic_send_crq(adapter, &crq); 4401 + cap_reqs--; 4427 4402 4428 4403 crq.query_capability.capability = 4429 4404 cpu_to_be16(MIN_RX_ADD_ENTRIES_PER_SUBCRQ); 4430 - atomic_inc(&adapter->running_cap_crqs); 4431 4405 ibmvnic_send_crq(adapter, &crq); 4406 + cap_reqs--; 4432 4407 4433 4408 crq.query_capability.capability = 4434 4409 cpu_to_be16(MAX_TX_ENTRIES_PER_SUBCRQ); 4435 - atomic_inc(&adapter->running_cap_crqs); 4436 4410 ibmvnic_send_crq(adapter, &crq); 4411 + cap_reqs--; 4437 4412 4438 4413 crq.query_capability.capability = 4439 4414 cpu_to_be16(MAX_RX_ADD_ENTRIES_PER_SUBCRQ); 4440 - atomic_inc(&adapter->running_cap_crqs); 4441 4415 ibmvnic_send_crq(adapter, &crq); 4416 + cap_reqs--; 4442 4417 4443 4418 crq.query_capability.capability = cpu_to_be16(TCP_IP_OFFLOAD); 4444 - atomic_inc(&adapter->running_cap_crqs); 4445 4419 ibmvnic_send_crq(adapter, &crq); 4420 + cap_reqs--; 4446 4421 4447 4422 crq.query_capability.capability = cpu_to_be16(PROMISC_SUPPORTED); 4448 - atomic_inc(&adapter->running_cap_crqs); 4449 4423 ibmvnic_send_crq(adapter, &crq); 4424 + cap_reqs--; 4450 4425 4451 4426 crq.query_capability.capability = cpu_to_be16(MIN_MTU); 4452 - atomic_inc(&adapter->running_cap_crqs); 4453 4427 ibmvnic_send_crq(adapter, &crq); 4428 + cap_reqs--; 4454 4429 4455 4430 crq.query_capability.capability = cpu_to_be16(MAX_MTU); 4456 - atomic_inc(&adapter->running_cap_crqs); 4457 4431 ibmvnic_send_crq(adapter, &crq); 4432 + cap_reqs--; 4458 4433 4459 4434 crq.query_capability.capability = cpu_to_be16(MAX_MULTICAST_FILTERS); 4460 - atomic_inc(&adapter->running_cap_crqs); 4461 4435 ibmvnic_send_crq(adapter, &crq); 4436 + cap_reqs--; 4462 4437 4463 4438 crq.query_capability.capability = cpu_to_be16(VLAN_HEADER_INSERTION); 4464 - atomic_inc(&adapter->running_cap_crqs); 4465 4439 ibmvnic_send_crq(adapter, &crq); 4440 + cap_reqs--; 4466 4441 4467 4442 crq.query_capability.capability = cpu_to_be16(RX_VLAN_HEADER_INSERTION); 4468 - atomic_inc(&adapter->running_cap_crqs); 4469 4443 ibmvnic_send_crq(adapter, &crq); 4444 + cap_reqs--; 4470 4445 4471 4446 crq.query_capability.capability = cpu_to_be16(MAX_TX_SG_ENTRIES); 4472 - atomic_inc(&adapter->running_cap_crqs); 4473 4447 ibmvnic_send_crq(adapter, &crq); 4448 + cap_reqs--; 4474 4449 4475 4450 crq.query_capability.capability = cpu_to_be16(RX_SG_SUPPORTED); 4476 - atomic_inc(&adapter->running_cap_crqs); 4477 4451 ibmvnic_send_crq(adapter, &crq); 4452 + cap_reqs--; 4478 4453 4479 4454 crq.query_capability.capability = cpu_to_be16(OPT_TX_COMP_SUB_QUEUES); 4480 - atomic_inc(&adapter->running_cap_crqs); 4481 4455 ibmvnic_send_crq(adapter, &crq); 4456 + cap_reqs--; 4482 4457 4483 4458 crq.query_capability.capability = cpu_to_be16(OPT_RX_COMP_QUEUES); 4484 - atomic_inc(&adapter->running_cap_crqs); 4485 4459 ibmvnic_send_crq(adapter, &crq); 4460 + cap_reqs--; 4486 4461 4487 4462 crq.query_capability.capability = 4488 4463 cpu_to_be16(OPT_RX_BUFADD_Q_PER_RX_COMP_Q); 4489 - atomic_inc(&adapter->running_cap_crqs); 4490 4464 ibmvnic_send_crq(adapter, &crq); 4465 + cap_reqs--; 4491 4466 4492 4467 crq.query_capability.capability = 4493 4468 cpu_to_be16(OPT_TX_ENTRIES_PER_SUBCRQ); 4494 - atomic_inc(&adapter->running_cap_crqs); 4495 4469 ibmvnic_send_crq(adapter, &crq); 4470 + cap_reqs--; 4496 4471 4497 4472 crq.query_capability.capability = 4498 4473 cpu_to_be16(OPT_RXBA_ENTRIES_PER_SUBCRQ); 4499 - atomic_inc(&adapter->running_cap_crqs); 4500 4474 ibmvnic_send_crq(adapter, &crq); 4475 + cap_reqs--; 4501 4476 4502 4477 crq.query_capability.capability = cpu_to_be16(TX_RX_DESC_REQ); 4503 - atomic_inc(&adapter->running_cap_crqs); 4478 + 4504 4479 ibmvnic_send_crq(adapter, &crq); 4480 + cap_reqs--; 4481 + 4482 + /* Keep at end to catch any discrepancy between expected and actual 4483 + * CRQs sent. 4484 + */ 4485 + WARN_ON(cap_reqs != 0); 4505 4486 } 4506 4487 4507 4488 static void send_query_ip_offload(struct ibmvnic_adapter *adapter) ··· 4819 4772 char *name; 4820 4773 4821 4774 atomic_dec(&adapter->running_cap_crqs); 4775 + netdev_dbg(adapter->netdev, "Outstanding request-caps: %d\n", 4776 + atomic_read(&adapter->running_cap_crqs)); 4822 4777 switch (be16_to_cpu(crq->request_capability_rsp.capability)) { 4823 4778 case REQ_TX_QUEUES: 4824 4779 req_value = &adapter->req_tx_queues; ··· 4884 4835 } 4885 4836 4886 4837 /* Done receiving requested capabilities, query IP offload support */ 4887 - if (atomic_read(&adapter->running_cap_crqs) == 0) { 4888 - adapter->wait_capability = false; 4838 + if (atomic_read(&adapter->running_cap_crqs) == 0) 4889 4839 send_query_ip_offload(adapter); 4890 - } 4891 4840 } 4892 4841 4893 4842 static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq, ··· 5183 5136 } 5184 5137 5185 5138 out: 5186 - if (atomic_read(&adapter->running_cap_crqs) == 0) { 5187 - adapter->wait_capability = false; 5139 + if (atomic_read(&adapter->running_cap_crqs) == 0) 5188 5140 send_request_cap(adapter, 0); 5189 - } 5190 5141 } 5191 5142 5192 5143 static int send_query_phys_parms(struct ibmvnic_adapter *adapter) ··· 5480 5435 struct ibmvnic_crq_queue *queue = &adapter->crq; 5481 5436 union ibmvnic_crq *crq; 5482 5437 unsigned long flags; 5483 - bool done = false; 5484 5438 5485 5439 spin_lock_irqsave(&queue->lock, flags); 5486 - while (!done) { 5487 - /* Pull all the valid messages off the CRQ */ 5488 - while ((crq = ibmvnic_next_crq(adapter)) != NULL) { 5489 - /* This barrier makes sure ibmvnic_next_crq()'s 5490 - * crq->generic.first & IBMVNIC_CRQ_CMD_RSP is loaded 5491 - * before ibmvnic_handle_crq()'s 5492 - * switch(gen_crq->first) and switch(gen_crq->cmd). 5493 - */ 5494 - dma_rmb(); 5495 - ibmvnic_handle_crq(crq, adapter); 5496 - crq->generic.first = 0; 5497 - } 5498 5440 5499 - /* remain in tasklet until all 5500 - * capabilities responses are received 5441 + /* Pull all the valid messages off the CRQ */ 5442 + while ((crq = ibmvnic_next_crq(adapter)) != NULL) { 5443 + /* This barrier makes sure ibmvnic_next_crq()'s 5444 + * crq->generic.first & IBMVNIC_CRQ_CMD_RSP is loaded 5445 + * before ibmvnic_handle_crq()'s 5446 + * switch(gen_crq->first) and switch(gen_crq->cmd). 5501 5447 */ 5502 - if (!adapter->wait_capability) 5503 - done = true; 5448 + dma_rmb(); 5449 + ibmvnic_handle_crq(crq, adapter); 5450 + crq->generic.first = 0; 5504 5451 } 5505 - /* if capabilities CRQ's were sent in this tasklet, the following 5506 - * tasklet must wait until all responses are received 5507 - */ 5508 - if (atomic_read(&adapter->running_cap_crqs) != 0) 5509 - adapter->wait_capability = true; 5452 + 5510 5453 spin_unlock_irqrestore(&queue->lock, flags); 5511 5454 } 5512 5455
-1
drivers/net/ethernet/ibm/ibmvnic.h
··· 919 919 int login_rsp_buf_sz; 920 920 921 921 atomic_t running_cap_crqs; 922 - bool wait_capability; 923 922 924 923 struct ibmvnic_sub_crq_queue **tx_scrq ____cacheline_aligned; 925 924 struct ibmvnic_sub_crq_queue **rx_scrq ____cacheline_aligned;
+4 -5
drivers/net/ethernet/intel/i40e/i40e.h
··· 174 174 175 175 struct i40e_lump_tracking { 176 176 u16 num_entries; 177 - u16 search_hint; 178 177 u16 list[0]; 179 178 #define I40E_PILE_VALID_BIT 0x8000 180 179 #define I40E_IWARP_IRQ_PILE_ID (I40E_PILE_VALID_BIT - 2) ··· 847 848 struct rtnl_link_stats64 net_stats_offsets; 848 849 struct i40e_eth_stats eth_stats; 849 850 struct i40e_eth_stats eth_stats_offsets; 850 - u32 tx_restart; 851 - u32 tx_busy; 851 + u64 tx_restart; 852 + u64 tx_busy; 852 853 u64 tx_linearize; 853 854 u64 tx_force_wb; 854 - u32 rx_buf_failed; 855 - u32 rx_page_failed; 855 + u64 rx_buf_failed; 856 + u64 rx_page_failed; 856 857 857 858 /* These are containers of ring pointers, allocated at run-time */ 858 859 struct i40e_ring **rx_rings;
+1 -1
drivers/net/ethernet/intel/i40e/i40e_debugfs.c
··· 240 240 (unsigned long int)vsi->net_stats_offsets.rx_compressed, 241 241 (unsigned long int)vsi->net_stats_offsets.tx_compressed); 242 242 dev_info(&pf->pdev->dev, 243 - " tx_restart = %d, tx_busy = %d, rx_buf_failed = %d, rx_page_failed = %d\n", 243 + " tx_restart = %llu, tx_busy = %llu, rx_buf_failed = %llu, rx_page_failed = %llu\n", 244 244 vsi->tx_restart, vsi->tx_busy, 245 245 vsi->rx_buf_failed, vsi->rx_page_failed); 246 246 rcu_read_lock();
+21 -23
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 196 196 * @id: an owner id to stick on the items assigned 197 197 * 198 198 * Returns the base item index of the lump, or negative for error 199 - * 200 - * The search_hint trick and lack of advanced fit-finding only work 201 - * because we're highly likely to have all the same size lump requests. 202 - * Linear search time and any fragmentation should be minimal. 203 199 **/ 204 200 static int i40e_get_lump(struct i40e_pf *pf, struct i40e_lump_tracking *pile, 205 201 u16 needed, u16 id) ··· 210 214 return -EINVAL; 211 215 } 212 216 213 - /* start the linear search with an imperfect hint */ 214 - i = pile->search_hint; 217 + /* Allocate last queue in the pile for FDIR VSI queue 218 + * so it doesn't fragment the qp_pile 219 + */ 220 + if (pile == pf->qp_pile && pf->vsi[id]->type == I40E_VSI_FDIR) { 221 + if (pile->list[pile->num_entries - 1] & I40E_PILE_VALID_BIT) { 222 + dev_err(&pf->pdev->dev, 223 + "Cannot allocate queue %d for I40E_VSI_FDIR\n", 224 + pile->num_entries - 1); 225 + return -ENOMEM; 226 + } 227 + pile->list[pile->num_entries - 1] = id | I40E_PILE_VALID_BIT; 228 + return pile->num_entries - 1; 229 + } 230 + 231 + i = 0; 215 232 while (i < pile->num_entries) { 216 233 /* skip already allocated entries */ 217 234 if (pile->list[i] & I40E_PILE_VALID_BIT) { ··· 243 234 for (j = 0; j < needed; j++) 244 235 pile->list[i+j] = id | I40E_PILE_VALID_BIT; 245 236 ret = i; 246 - pile->search_hint = i + j; 247 237 break; 248 238 } 249 239 ··· 265 257 { 266 258 int valid_id = (id | I40E_PILE_VALID_BIT); 267 259 int count = 0; 268 - int i; 260 + u16 i; 269 261 270 262 if (!pile || index >= pile->num_entries) 271 263 return -EINVAL; ··· 277 269 count++; 278 270 } 279 271 280 - if (count && index < pile->search_hint) 281 - pile->search_hint = index; 282 272 283 273 return count; 284 274 } ··· 778 772 struct rtnl_link_stats64 *ns; /* netdev stats */ 779 773 struct i40e_eth_stats *oes; 780 774 struct i40e_eth_stats *es; /* device's eth stats */ 781 - u32 tx_restart, tx_busy; 775 + u64 tx_restart, tx_busy; 782 776 struct i40e_ring *p; 783 - u32 rx_page, rx_buf; 777 + u64 rx_page, rx_buf; 784 778 u64 bytes, packets; 785 779 unsigned int start; 786 780 u64 tx_linearize; ··· 10580 10574 } 10581 10575 i40e_get_oem_version(&pf->hw); 10582 10576 10583 - if (test_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state) && 10584 - ((hw->aq.fw_maj_ver == 4 && hw->aq.fw_min_ver <= 33) || 10585 - hw->aq.fw_maj_ver < 4) && hw->mac.type == I40E_MAC_XL710) { 10586 - /* The following delay is necessary for 4.33 firmware and older 10587 - * to recover after EMP reset. 200 ms should suffice but we 10588 - * put here 300 ms to be sure that FW is ready to operate 10589 - * after reset. 10590 - */ 10591 - mdelay(300); 10577 + if (test_and_clear_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state)) { 10578 + /* The following delay is necessary for firmware update. */ 10579 + mdelay(1000); 10592 10580 } 10593 10581 10594 10582 /* re-verify the eeprom if we just had an EMP reset */ ··· 11792 11792 return -ENOMEM; 11793 11793 11794 11794 pf->irq_pile->num_entries = vectors; 11795 - pf->irq_pile->search_hint = 0; 11796 11795 11797 11796 /* track first vector for misc interrupts, ignore return */ 11798 11797 (void)i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT - 1); ··· 12594 12595 goto sw_init_done; 12595 12596 } 12596 12597 pf->qp_pile->num_entries = pf->hw.func_caps.num_tx_qp; 12597 - pf->qp_pile->search_hint = 0; 12598 12598 12599 12599 pf->tx_timeout_recovery_level = 1; 12600 12600
+3
drivers/net/ethernet/intel/i40e/i40e_register.h
··· 413 413 #define I40E_VFINT_DYN_CTLN(_INTVF) (0x00024800 + ((_INTVF) * 4)) /* _i=0...511 */ /* Reset: VFR */ 414 414 #define I40E_VFINT_DYN_CTLN_CLEARPBA_SHIFT 1 415 415 #define I40E_VFINT_DYN_CTLN_CLEARPBA_MASK I40E_MASK(0x1, I40E_VFINT_DYN_CTLN_CLEARPBA_SHIFT) 416 + #define I40E_VFINT_ICR0_ADMINQ_SHIFT 30 417 + #define I40E_VFINT_ICR0_ADMINQ_MASK I40E_MASK(0x1, I40E_VFINT_ICR0_ADMINQ_SHIFT) 418 + #define I40E_VFINT_ICR0_ENA(_VF) (0x0002C000 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: CORER */ 416 419 #define I40E_VPINT_AEQCTL(_VF) (0x0002B800 + ((_VF) * 4)) /* _i=0...127 */ /* Reset: CORER */ 417 420 #define I40E_VPINT_AEQCTL_MSIX_INDX_SHIFT 0 418 421 #define I40E_VPINT_AEQCTL_ITR_INDX_SHIFT 11
+101 -2
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
··· 1377 1377 } 1378 1378 1379 1379 /** 1380 + * i40e_sync_vfr_reset 1381 + * @hw: pointer to hw struct 1382 + * @vf_id: VF identifier 1383 + * 1384 + * Before trigger hardware reset, we need to know if no other process has 1385 + * reserved the hardware for any reset operations. This check is done by 1386 + * examining the status of the RSTAT1 register used to signal the reset. 1387 + **/ 1388 + static int i40e_sync_vfr_reset(struct i40e_hw *hw, int vf_id) 1389 + { 1390 + u32 reg; 1391 + int i; 1392 + 1393 + for (i = 0; i < I40E_VFR_WAIT_COUNT; i++) { 1394 + reg = rd32(hw, I40E_VFINT_ICR0_ENA(vf_id)) & 1395 + I40E_VFINT_ICR0_ADMINQ_MASK; 1396 + if (reg) 1397 + return 0; 1398 + 1399 + usleep_range(100, 200); 1400 + } 1401 + 1402 + return -EAGAIN; 1403 + } 1404 + 1405 + /** 1380 1406 * i40e_trigger_vf_reset 1381 1407 * @vf: pointer to the VF structure 1382 1408 * @flr: VFLR was issued or not ··· 1416 1390 struct i40e_pf *pf = vf->pf; 1417 1391 struct i40e_hw *hw = &pf->hw; 1418 1392 u32 reg, reg_idx, bit_idx; 1393 + bool vf_active; 1394 + u32 radq; 1419 1395 1420 1396 /* warn the VF */ 1421 - clear_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states); 1397 + vf_active = test_and_clear_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states); 1422 1398 1423 1399 /* Disable VF's configuration API during reset. The flag is re-enabled 1424 1400 * in i40e_alloc_vf_res(), when it's safe again to access VF's VSI. ··· 1434 1406 * just need to clean up, so don't hit the VFRTRIG register. 1435 1407 */ 1436 1408 if (!flr) { 1437 - /* reset VF using VPGEN_VFRTRIG reg */ 1409 + /* Sync VFR reset before trigger next one */ 1410 + radq = rd32(hw, I40E_VFINT_ICR0_ENA(vf->vf_id)) & 1411 + I40E_VFINT_ICR0_ADMINQ_MASK; 1412 + if (vf_active && !radq) 1413 + /* waiting for finish reset by virtual driver */ 1414 + if (i40e_sync_vfr_reset(hw, vf->vf_id)) 1415 + dev_info(&pf->pdev->dev, 1416 + "Reset VF %d never finished\n", 1417 + vf->vf_id); 1418 + 1419 + /* Reset VF using VPGEN_VFRTRIG reg. It is also setting 1420 + * in progress state in rstat1 register. 1421 + */ 1438 1422 reg = rd32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id)); 1439 1423 reg |= I40E_VPGEN_VFRTRIG_VFSWR_MASK; 1440 1424 wr32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id), reg); ··· 2658 2618 } 2659 2619 2660 2620 /** 2621 + * i40e_check_enough_queue - find big enough queue number 2622 + * @vf: pointer to the VF info 2623 + * @needed: the number of items needed 2624 + * 2625 + * Returns the base item index of the queue, or negative for error 2626 + **/ 2627 + static int i40e_check_enough_queue(struct i40e_vf *vf, u16 needed) 2628 + { 2629 + unsigned int i, cur_queues, more, pool_size; 2630 + struct i40e_lump_tracking *pile; 2631 + struct i40e_pf *pf = vf->pf; 2632 + struct i40e_vsi *vsi; 2633 + 2634 + vsi = pf->vsi[vf->lan_vsi_idx]; 2635 + cur_queues = vsi->alloc_queue_pairs; 2636 + 2637 + /* if current allocated queues are enough for need */ 2638 + if (cur_queues >= needed) 2639 + return vsi->base_queue; 2640 + 2641 + pile = pf->qp_pile; 2642 + if (cur_queues > 0) { 2643 + /* if the allocated queues are not zero 2644 + * just check if there are enough queues for more 2645 + * behind the allocated queues. 2646 + */ 2647 + more = needed - cur_queues; 2648 + for (i = vsi->base_queue + cur_queues; 2649 + i < pile->num_entries; i++) { 2650 + if (pile->list[i] & I40E_PILE_VALID_BIT) 2651 + break; 2652 + 2653 + if (more-- == 1) 2654 + /* there is enough */ 2655 + return vsi->base_queue; 2656 + } 2657 + } 2658 + 2659 + pool_size = 0; 2660 + for (i = 0; i < pile->num_entries; i++) { 2661 + if (pile->list[i] & I40E_PILE_VALID_BIT) { 2662 + pool_size = 0; 2663 + continue; 2664 + } 2665 + if (needed <= ++pool_size) 2666 + /* there is enough */ 2667 + return i; 2668 + } 2669 + 2670 + return -ENOMEM; 2671 + } 2672 + 2673 + /** 2661 2674 * i40e_vc_request_queues_msg 2662 2675 * @vf: pointer to the VF info 2663 2676 * @msg: pointer to the msg buffer ··· 2744 2651 req_pairs - cur_pairs, 2745 2652 pf->queues_left); 2746 2653 vfres->num_queue_pairs = pf->queues_left + cur_pairs; 2654 + } else if (i40e_check_enough_queue(vf, req_pairs) < 0) { 2655 + dev_warn(&pf->pdev->dev, 2656 + "VF %d requested %d more queues, but there is not enough for it.\n", 2657 + vf->vf_id, 2658 + req_pairs - cur_pairs); 2659 + vfres->num_queue_pairs = cur_pairs; 2747 2660 } else { 2748 2661 /* successful request */ 2749 2662 vf->num_req_queues = req_pairs;
+1
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
··· 19 19 #define I40E_MAX_VF_PROMISC_FLAGS 3 20 20 21 21 #define I40E_VF_STATE_WAIT_COUNT 20 22 + #define I40E_VFR_WAIT_COUNT 100 22 23 23 24 /* Various queue ctrls */ 24 25 enum i40e_queue_ctrl {
+2
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
··· 1570 1570 .mac_enadis_pause_frm = cgx_lmac_enadis_pause_frm, 1571 1571 .mac_pause_frm_config = cgx_lmac_pause_frm_config, 1572 1572 .mac_enadis_ptp_config = cgx_lmac_ptp_config, 1573 + .mac_rx_tx_enable = cgx_lmac_rx_tx_enable, 1574 + .mac_tx_enable = cgx_lmac_tx_enable, 1573 1575 }; 1574 1576 1575 1577 static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+3
drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h
··· 107 107 void (*mac_enadis_ptp_config)(void *cgxd, 108 108 int lmac_id, 109 109 bool enable); 110 + 111 + int (*mac_rx_tx_enable)(void *cgxd, int lmac_id, bool enable); 112 + int (*mac_tx_enable)(void *cgxd, int lmac_id, bool enable); 110 113 }; 111 114 112 115 struct cgx {
+1
drivers/net/ethernet/marvell/octeontx2/af/mbox.h
··· 732 732 NIX_AF_ERR_BANDPROF_INVAL_REQ = -428, 733 733 NIX_AF_ERR_CQ_CTX_WRITE_ERR = -429, 734 734 NIX_AF_ERR_AQ_CTX_RETRY_WRITE = -430, 735 + NIX_AF_ERR_LINK_CREDITS = -431, 735 736 }; 736 737 737 738 /* For NIX RX vtag action */
+35 -35
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h
··· 185 185 NPC_S_KPU2_QINQ, 186 186 NPC_S_KPU2_ETAG, 187 187 NPC_S_KPU2_EXDSA, 188 - NPC_S_KPU2_NGIO, 189 188 NPC_S_KPU2_CPT_CTAG, 190 189 NPC_S_KPU2_CPT_QINQ, 191 190 NPC_S_KPU3_CTAG, ··· 211 212 NPC_S_KPU5_NSH, 212 213 NPC_S_KPU5_CPT_IP, 213 214 NPC_S_KPU5_CPT_IP6, 215 + NPC_S_KPU5_NGIO, 214 216 NPC_S_KPU6_IP6_EXT, 215 217 NPC_S_KPU6_IP6_HOP_DEST, 216 218 NPC_S_KPU6_IP6_ROUT, ··· 1124 1124 NPC_S_KPU1_ETHER, 0xff, 1125 1125 NPC_ETYPE_CTAG, 1126 1126 0xffff, 1127 - NPC_ETYPE_NGIO, 1128 - 0xffff, 1129 - 0x0000, 1130 - 0x0000, 1131 - }, 1132 - { 1133 - NPC_S_KPU1_ETHER, 0xff, 1134 - NPC_ETYPE_CTAG, 1135 - 0xffff, 1136 1127 NPC_ETYPE_CTAG, 1137 1128 0xffff, 1138 1129 0x0000, ··· 1959 1968 }, 1960 1969 { 1961 1970 NPC_S_KPU2_CTAG, 0xff, 1971 + NPC_ETYPE_NGIO, 1972 + 0xffff, 1973 + 0x0000, 1974 + 0x0000, 1975 + 0x0000, 1976 + 0x0000, 1977 + }, 1978 + { 1979 + NPC_S_KPU2_CTAG, 0xff, 1962 1980 NPC_ETYPE_PPPOE, 1963 1981 0xffff, 1964 1982 0x0000, ··· 2744 2744 NPC_S_KPU2_EXDSA, 0xff, 2745 2745 0x0000, 2746 2746 NPC_DSA_EDSA, 2747 - 0x0000, 2748 - 0x0000, 2749 - 0x0000, 2750 - 0x0000, 2751 - }, 2752 - { 2753 - NPC_S_KPU2_NGIO, 0xff, 2754 - 0x0000, 2755 - 0x0000, 2756 2747 0x0000, 2757 2748 0x0000, 2758 2749 0x0000, ··· 5073 5082 }, 5074 5083 { 5075 5084 NPC_S_KPU5_CPT_IP6, 0xff, 5085 + 0x0000, 5086 + 0x0000, 5087 + 0x0000, 5088 + 0x0000, 5089 + 0x0000, 5090 + 0x0000, 5091 + }, 5092 + { 5093 + NPC_S_KPU5_NGIO, 0xff, 5076 5094 0x0000, 5077 5095 0x0000, 5078 5096 0x0000, ··· 8425 8425 { 8426 8426 NPC_ERRLEV_RE, NPC_EC_NOERR, 8427 8427 8, 12, 0, 0, 0, 8428 - NPC_S_KPU2_NGIO, 12, 1, 8429 - NPC_LID_LA, NPC_LT_LA_ETHER, 8430 - 0, 8431 - 0, 0, 0, 0, 8432 - }, 8433 - { 8434 - NPC_ERRLEV_RE, NPC_EC_NOERR, 8435 - 8, 12, 0, 0, 0, 8436 8428 NPC_S_KPU2_CTAG2, 12, 1, 8437 8429 NPC_LID_LA, NPC_LT_LA_ETHER, 8438 8430 NPC_F_LA_U_HAS_TAG | NPC_F_LA_L_WITH_VLAN, ··· 9188 9196 }, 9189 9197 { 9190 9198 NPC_ERRLEV_RE, NPC_EC_NOERR, 9199 + 0, 0, 0, 2, 0, 9200 + NPC_S_KPU5_NGIO, 6, 1, 9201 + NPC_LID_LB, NPC_LT_LB_CTAG, 9202 + 0, 9203 + 0, 0, 0, 0, 9204 + }, 9205 + { 9206 + NPC_ERRLEV_RE, NPC_EC_NOERR, 9191 9207 8, 0, 6, 2, 0, 9192 9208 NPC_S_KPU5_IP, 14, 1, 9193 9209 NPC_LID_LB, NPC_LT_LB_PPPOE, ··· 9888 9888 NPC_S_NA, 0, 1, 9889 9889 NPC_LID_LB, NPC_LT_LB_EXDSA, 9890 9890 NPC_F_LB_U_UNK_ETYPE | NPC_F_LB_L_EXDSA, 9891 - 0, 0, 0, 0, 9892 - }, 9893 - { 9894 - NPC_ERRLEV_RE, NPC_EC_NOERR, 9895 - 0, 0, 0, 0, 1, 9896 - NPC_S_NA, 0, 1, 9897 - NPC_LID_LC, NPC_LT_LC_NGIO, 9898 - 0, 9899 9891 0, 0, 0, 0, 9900 9892 }, 9901 9893 { ··· 11962 11970 0, 0, 0, 0, 1, 11963 11971 NPC_S_NA, 0, 1, 11964 11972 NPC_LID_LC, NPC_LT_LC_IP6, 11973 + 0, 11974 + 0, 0, 0, 0, 11975 + }, 11976 + { 11977 + NPC_ERRLEV_RE, NPC_EC_NOERR, 11978 + 0, 0, 0, 0, 1, 11979 + NPC_S_NA, 0, 1, 11980 + NPC_LID_LC, NPC_LT_LC_NGIO, 11965 11981 0, 11966 11982 0, 0, 0, 0, 11967 11983 },
+50 -14
drivers/net/ethernet/marvell/octeontx2/af/rpm.c
··· 30 30 .mac_enadis_pause_frm = rpm_lmac_enadis_pause_frm, 31 31 .mac_pause_frm_config = rpm_lmac_pause_frm_config, 32 32 .mac_enadis_ptp_config = rpm_lmac_ptp_config, 33 + .mac_rx_tx_enable = rpm_lmac_rx_tx_enable, 34 + .mac_tx_enable = rpm_lmac_tx_enable, 33 35 }; 34 36 35 37 struct mac_ops *rpm_get_mac_ops(void) ··· 54 52 rpm_t *rpm = rpmd; 55 53 56 54 return hweight8(rpm_read(rpm, 0, CGXX_CMRX_RX_LMACS) & 0xFULL); 55 + } 56 + 57 + int rpm_lmac_tx_enable(void *rpmd, int lmac_id, bool enable) 58 + { 59 + rpm_t *rpm = rpmd; 60 + u64 cfg, last; 61 + 62 + if (!is_lmac_valid(rpm, lmac_id)) 63 + return -ENODEV; 64 + 65 + cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); 66 + last = cfg; 67 + if (enable) 68 + cfg |= RPM_TX_EN; 69 + else 70 + cfg &= ~(RPM_TX_EN); 71 + 72 + if (cfg != last) 73 + rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); 74 + return !!(last & RPM_TX_EN); 75 + } 76 + 77 + int rpm_lmac_rx_tx_enable(void *rpmd, int lmac_id, bool enable) 78 + { 79 + rpm_t *rpm = rpmd; 80 + u64 cfg; 81 + 82 + if (!is_lmac_valid(rpm, lmac_id)) 83 + return -ENODEV; 84 + 85 + cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); 86 + if (enable) 87 + cfg |= RPM_RX_EN | RPM_TX_EN; 88 + else 89 + cfg &= ~(RPM_RX_EN | RPM_TX_EN); 90 + rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); 91 + return 0; 57 92 } 58 93 59 94 void rpm_lmac_enadis_rx_pause_fwding(void *rpmd, int lmac_id, bool enable) ··· 291 252 if (!rpm || lmac_id >= rpm->lmac_count) 292 253 return -ENODEV; 293 254 lmac_type = rpm->mac_ops->get_lmac_type(rpm, lmac_id); 294 - if (lmac_type == LMAC_MODE_100G_R) { 295 - cfg = rpm_read(rpm, lmac_id, RPMX_MTI_PCS100X_CONTROL1); 296 255 297 - if (enable) 298 - cfg |= RPMX_MTI_PCS_LBK; 299 - else 300 - cfg &= ~RPMX_MTI_PCS_LBK; 301 - rpm_write(rpm, lmac_id, RPMX_MTI_PCS100X_CONTROL1, cfg); 302 - } else { 303 - cfg = rpm_read(rpm, lmac_id, RPMX_MTI_LPCSX_CONTROL1); 304 - if (enable) 305 - cfg |= RPMX_MTI_PCS_LBK; 306 - else 307 - cfg &= ~RPMX_MTI_PCS_LBK; 308 - rpm_write(rpm, lmac_id, RPMX_MTI_LPCSX_CONTROL1, cfg); 256 + if (lmac_type == LMAC_MODE_QSGMII || lmac_type == LMAC_MODE_SGMII) { 257 + dev_err(&rpm->pdev->dev, "loopback not supported for LPC mode\n"); 258 + return 0; 309 259 } 260 + 261 + cfg = rpm_read(rpm, lmac_id, RPMX_MTI_PCS100X_CONTROL1); 262 + 263 + if (enable) 264 + cfg |= RPMX_MTI_PCS_LBK; 265 + else 266 + cfg &= ~RPMX_MTI_PCS_LBK; 267 + rpm_write(rpm, lmac_id, RPMX_MTI_PCS100X_CONTROL1, cfg); 310 268 311 269 return 0; 312 270 }
+4
drivers/net/ethernet/marvell/octeontx2/af/rpm.h
··· 43 43 #define RPMX_MTI_STAT_DATA_HI_CDC 0x10038 44 44 45 45 #define RPM_LMAC_FWI 0xa 46 + #define RPM_TX_EN BIT_ULL(0) 47 + #define RPM_RX_EN BIT_ULL(1) 46 48 47 49 /* Function Declarations */ 48 50 int rpm_get_nr_lmacs(void *rpmd); ··· 59 57 int rpm_get_tx_stats(void *rpmd, int lmac_id, int idx, u64 *tx_stat); 60 58 int rpm_get_rx_stats(void *rpmd, int lmac_id, int idx, u64 *rx_stat); 61 59 void rpm_lmac_ptp_config(void *rpmd, int lmac_id, bool enable); 60 + int rpm_lmac_rx_tx_enable(void *rpmd, int lmac_id, bool enable); 61 + int rpm_lmac_tx_enable(void *rpmd, int lmac_id, bool enable); 62 62 #endif /* RPM_H */
+5 -2
drivers/net/ethernet/marvell/octeontx2/af/rvu.c
··· 520 520 521 521 rvu_write64(rvu, blkaddr, rst_reg, BIT_ULL(0)); 522 522 err = rvu_poll_reg(rvu, blkaddr, rst_reg, BIT_ULL(63), true); 523 - if (err) 524 - dev_err(rvu->dev, "HW block:%d reset failed\n", blkaddr); 523 + if (err) { 524 + dev_err(rvu->dev, "HW block:%d reset timeout retrying again\n", blkaddr); 525 + while (rvu_poll_reg(rvu, blkaddr, rst_reg, BIT_ULL(63), true) == -EBUSY) 526 + ; 527 + } 525 528 } 526 529 527 530 static void rvu_reset_all_blocks(struct rvu *rvu)
+1
drivers/net/ethernet/marvell/octeontx2/af/rvu.h
··· 806 806 u32 rvu_cgx_get_fifolen(struct rvu *rvu); 807 807 void *rvu_first_cgx_pdata(struct rvu *rvu); 808 808 int cgxlmac_to_pf(struct rvu *rvu, int cgx_id, int lmac_id); 809 + int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable); 809 810 810 811 int npc_get_nixlf_mcam_index(struct npc_mcam *mcam, u16 pcifunc, int nixlf, 811 812 int type);
+12 -2
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
··· 441 441 int rvu_cgx_config_rxtx(struct rvu *rvu, u16 pcifunc, bool start) 442 442 { 443 443 int pf = rvu_get_pf(pcifunc); 444 + struct mac_ops *mac_ops; 444 445 u8 cgx_id, lmac_id; 446 + void *cgxd; 445 447 446 448 if (!is_cgx_config_permitted(rvu, pcifunc)) 447 449 return LMAC_AF_ERR_PERM_DENIED; 448 450 449 451 rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); 452 + cgxd = rvu_cgx_pdata(cgx_id, rvu); 453 + mac_ops = get_mac_ops(cgxd); 450 454 451 - cgx_lmac_rx_tx_enable(rvu_cgx_pdata(cgx_id, rvu), lmac_id, start); 455 + return mac_ops->mac_rx_tx_enable(cgxd, lmac_id, start); 456 + } 452 457 453 - return 0; 458 + int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable) 459 + { 460 + struct mac_ops *mac_ops; 461 + 462 + mac_ops = get_mac_ops(cgxd); 463 + return mac_ops->mac_tx_enable(cgxd, lmac_id, enable); 454 464 } 455 465 456 466 void rvu_cgx_disable_dmac_entries(struct rvu *rvu, u16 pcifunc)
+2
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
··· 1224 1224 seq_printf(m, "W3: head_offset\t\t\t%d\nW3: smenq_next_sqb_vld\t\t%d\n\n", 1225 1225 sq_ctx->head_offset, sq_ctx->smenq_next_sqb_vld); 1226 1226 1227 + seq_printf(m, "W3: smq_next_sq_vld\t\t%d\nW3: smq_pend\t\t\t%d\n", 1228 + sq_ctx->smq_next_sq_vld, sq_ctx->smq_pend); 1227 1229 seq_printf(m, "W4: next_sqb \t\t\t%llx\n\n", sq_ctx->next_sqb); 1228 1230 seq_printf(m, "W5: tail_sqb \t\t\t%llx\n\n", sq_ctx->tail_sqb); 1229 1231 seq_printf(m, "W6: smenq_sqb \t\t\t%llx\n\n", sq_ctx->smenq_sqb);
+10 -10
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
··· 512 512 cfg = rvu_read64(rvu, blkaddr, NIX_AF_CONST); 513 513 lmac_chan_cnt = cfg & 0xFF; 514 514 515 - cfg = rvu_read64(rvu, blkaddr, NIX_AF_CONST1); 516 - sdp_chan_cnt = cfg & 0xFFF; 517 - 518 515 cgx_bpid_cnt = hw->cgx_links * lmac_chan_cnt; 519 516 lbk_bpid_cnt = hw->lbk_links * ((cfg >> 16) & 0xFF); 517 + 518 + cfg = rvu_read64(rvu, blkaddr, NIX_AF_CONST1); 519 + sdp_chan_cnt = cfg & 0xFFF; 520 520 sdp_bpid_cnt = hw->sdp_links * sdp_chan_cnt; 521 521 522 522 pfvf = rvu_get_pfvf(rvu, req->hdr.pcifunc); ··· 2068 2068 /* enable cgx tx if disabled */ 2069 2069 if (is_pf_cgxmapped(rvu, pf)) { 2070 2070 rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); 2071 - restore_tx_en = !cgx_lmac_tx_enable(rvu_cgx_pdata(cgx_id, rvu), 2072 - lmac_id, true); 2071 + restore_tx_en = !rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), 2072 + lmac_id, true); 2073 2073 } 2074 2074 2075 2075 cfg = rvu_read64(rvu, blkaddr, NIX_AF_SMQX_CFG(smq)); ··· 2092 2092 rvu_cgx_enadis_rx_bp(rvu, pf, true); 2093 2093 /* restore cgx tx state */ 2094 2094 if (restore_tx_en) 2095 - cgx_lmac_tx_enable(rvu_cgx_pdata(cgx_id, rvu), lmac_id, false); 2095 + rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), lmac_id, false); 2096 2096 return err; 2097 2097 } 2098 2098 ··· 3878 3878 /* Enable cgx tx if disabled for credits to be back */ 3879 3879 if (is_pf_cgxmapped(rvu, pf)) { 3880 3880 rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); 3881 - restore_tx_en = !cgx_lmac_tx_enable(rvu_cgx_pdata(cgx_id, rvu), 3881 + restore_tx_en = !rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), 3882 3882 lmac_id, true); 3883 3883 } 3884 3884 ··· 3891 3891 NIX_AF_TL1X_SW_XOFF(schq), BIT_ULL(0)); 3892 3892 } 3893 3893 3894 - rc = -EBUSY; 3895 - poll_tmo = jiffies + usecs_to_jiffies(10000); 3894 + rc = NIX_AF_ERR_LINK_CREDITS; 3895 + poll_tmo = jiffies + usecs_to_jiffies(200000); 3896 3896 /* Wait for credits to return */ 3897 3897 do { 3898 3898 if (time_after(jiffies, poll_tmo)) ··· 3918 3918 3919 3919 /* Restore state of cgx tx */ 3920 3920 if (restore_tx_en) 3921 - cgx_lmac_tx_enable(rvu_cgx_pdata(cgx_id, rvu), lmac_id, false); 3921 + rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), lmac_id, false); 3922 3922 3923 3923 mutex_unlock(&rvu->rsrc_lock); 3924 3924 return rc;
+19 -3
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
··· 402 402 int blkaddr, int index, struct mcam_entry *entry, 403 403 bool *enable) 404 404 { 405 + struct rvu_npc_mcam_rule *rule; 405 406 u16 owner, target_func; 406 407 struct rvu_pfvf *pfvf; 407 408 u64 rx_action; ··· 423 422 if (!(is_nixlf_attached(rvu, target_func) && 424 423 test_bit(NIXLF_INITIALIZED, &pfvf->flags))) 425 424 *enable = false; 425 + 426 + /* fix up not needed for the rules added by user(ntuple filters) */ 427 + list_for_each_entry(rule, &mcam->mcam_rules, list) { 428 + if (rule->entry == index) 429 + return; 430 + } 426 431 427 432 /* copy VF default entry action to the VF mcam entry */ 428 433 rx_action = npc_get_default_entry_action(rvu, mcam, blkaddr, ··· 496 489 } 497 490 498 491 /* PF installing VF rule */ 499 - if (intf == NIX_INTF_RX && actindex < mcam->bmap_entries) 500 - npc_fixup_vf_rule(rvu, mcam, blkaddr, index, entry, &enable); 492 + if (is_npc_intf_rx(intf) && actindex < mcam->bmap_entries) 493 + npc_fixup_vf_rule(rvu, mcam, blkaddr, actindex, entry, &enable); 501 494 502 495 /* Set 'action' */ 503 496 rvu_write64(rvu, blkaddr, ··· 923 916 int blkaddr, u16 pcifunc, u64 rx_action) 924 917 { 925 918 int actindex, index, bank, entry; 926 - bool enable; 919 + struct rvu_npc_mcam_rule *rule; 920 + bool enable, update; 927 921 928 922 if (!(pcifunc & RVU_PFVF_FUNC_MASK)) 929 923 return; ··· 932 924 mutex_lock(&mcam->lock); 933 925 for (index = 0; index < mcam->bmap_entries; index++) { 934 926 if (mcam->entry2target_pffunc[index] == pcifunc) { 927 + update = true; 928 + /* update not needed for the rules added via ntuple filters */ 929 + list_for_each_entry(rule, &mcam->mcam_rules, list) { 930 + if (rule->entry == index) 931 + update = false; 932 + } 933 + if (!update) 934 + continue; 935 935 bank = npc_get_bank(mcam, index); 936 936 actindex = index; 937 937 entry = index & (mcam->banksize - 1);
+12 -8
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
··· 1098 1098 write_req.cntr = rule->cntr; 1099 1099 } 1100 1100 1101 - err = rvu_mbox_handler_npc_mcam_write_entry(rvu, &write_req, 1102 - &write_rsp); 1103 - if (err) { 1104 - rvu_mcam_remove_counter_from_rule(rvu, owner, rule); 1105 - if (new) 1106 - kfree(rule); 1107 - return err; 1108 - } 1109 1101 /* update rule */ 1110 1102 memcpy(&rule->packet, &dummy.packet, sizeof(rule->packet)); 1111 1103 memcpy(&rule->mask, &dummy.mask, sizeof(rule->mask)); ··· 1123 1131 rvu_mcam_add_rule(mcam, rule); 1124 1132 if (req->default_rule) 1125 1133 pfvf->def_ucast_rule = rule; 1134 + 1135 + /* write to mcam entry registers */ 1136 + err = rvu_mbox_handler_npc_mcam_write_entry(rvu, &write_req, 1137 + &write_rsp); 1138 + if (err) { 1139 + rvu_mcam_remove_counter_from_rule(rvu, owner, rule); 1140 + if (new) { 1141 + list_del(&rule->list); 1142 + kfree(rule); 1143 + } 1144 + return err; 1145 + } 1126 1146 1127 1147 /* VF's MAC address is being changed via PF */ 1128 1148 if (pf_set_vfs_mac) {
+1
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
··· 603 603 size++; 604 604 tar_addr |= ((size - 1) & 0x7) << 4; 605 605 } 606 + dma_wmb(); 606 607 memcpy((u64 *)lmt_info->lmt_addr, ptrs, sizeof(u64) * num_ptrs); 607 608 /* Perform LMTST flush */ 608 609 cn10k_lmt_flush(val, tar_addr);
+6 -1
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
··· 394 394 dst_mdev->msg_size = mbox_hdr->msg_size; 395 395 dst_mdev->num_msgs = num_msgs; 396 396 err = otx2_sync_mbox_msg(dst_mbox); 397 - if (err) { 397 + /* Error code -EIO indicate there is a communication failure 398 + * to the AF. Rest of the error codes indicate that AF processed 399 + * VF messages and set the error codes in response messages 400 + * (if any) so simply forward responses to VF. 401 + */ 402 + if (err == -EIO) { 398 403 dev_warn(pf->dev, 399 404 "AF not responding to VF%d messages\n", vf); 400 405 /* restore PF mbase and exit */
+6 -5
drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
··· 40 40 { 41 41 u32 val; 42 42 43 - return readx_poll_timeout(lan966x_mac_get_status, 44 - lan966x, val, 45 - (ANA_MACACCESS_MAC_TABLE_CMD_GET(val)) == 46 - MACACCESS_CMD_IDLE, 47 - TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US); 43 + return readx_poll_timeout_atomic(lan966x_mac_get_status, 44 + lan966x, val, 45 + (ANA_MACACCESS_MAC_TABLE_CMD_GET(val)) == 46 + MACACCESS_CMD_IDLE, 47 + TABLE_UPDATE_SLEEP_US, 48 + TABLE_UPDATE_TIMEOUT_US); 48 49 } 49 50 50 51 static void lan966x_mac_select(struct lan966x *lan966x,
+3 -3
drivers/net/ethernet/microchip/lan966x/lan966x_main.c
··· 182 182 { 183 183 u32 val; 184 184 185 - return readx_poll_timeout(lan966x_port_inj_status, lan966x, val, 186 - QS_INJ_STATUS_FIFO_RDY_GET(val) & BIT(grp), 187 - READL_SLEEP_US, READL_TIMEOUT_US); 185 + return readx_poll_timeout_atomic(lan966x_port_inj_status, lan966x, val, 186 + QS_INJ_STATUS_FIFO_RDY_GET(val) & BIT(grp), 187 + READL_SLEEP_US, READL_TIMEOUT_US); 188 188 } 189 189 190 190 static int lan966x_port_ifh_xmit(struct sk_buff *skb,
+3 -1
drivers/net/ethernet/seeq/ether3.c
··· 749 749 const struct ether3_data *data = id->data; 750 750 struct net_device *dev; 751 751 int bus_type, ret; 752 + u8 addr[ETH_ALEN]; 752 753 753 754 ether3_banner(); 754 755 ··· 777 776 priv(dev)->seeq = priv(dev)->base + data->base_offset; 778 777 dev->irq = ec->irq; 779 778 780 - ether3_addr(dev->dev_addr, ec); 779 + ether3_addr(addr, ec); 780 + eth_hw_addr_set(dev, addr); 781 781 782 782 priv(dev)->dev = dev; 783 783 timer_setup(&priv(dev)->timer, ether3_ledoff, 0);
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
··· 756 756 757 757 if (err) { 758 758 dev_err(priv->device, "EMAC reset timeout\n"); 759 - return -EFAULT; 759 + return err; 760 760 } 761 761 return 0; 762 762 }
+26 -16
drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
··· 22 22 #define ETHER_CLK_SEL_RMII_CLK_EN BIT(2) 23 23 #define ETHER_CLK_SEL_RMII_CLK_RST BIT(3) 24 24 #define ETHER_CLK_SEL_DIV_SEL_2 BIT(4) 25 - #define ETHER_CLK_SEL_DIV_SEL_20 BIT(0) 25 + #define ETHER_CLK_SEL_DIV_SEL_20 0 26 26 #define ETHER_CLK_SEL_FREQ_SEL_125M (BIT(9) | BIT(8)) 27 27 #define ETHER_CLK_SEL_FREQ_SEL_50M BIT(9) 28 28 #define ETHER_CLK_SEL_FREQ_SEL_25M BIT(8) 29 29 #define ETHER_CLK_SEL_FREQ_SEL_2P5M 0 30 - #define ETHER_CLK_SEL_TX_CLK_EXT_SEL_IN BIT(0) 30 + #define ETHER_CLK_SEL_TX_CLK_EXT_SEL_IN 0 31 31 #define ETHER_CLK_SEL_TX_CLK_EXT_SEL_TXC BIT(10) 32 32 #define ETHER_CLK_SEL_TX_CLK_EXT_SEL_DIV BIT(11) 33 - #define ETHER_CLK_SEL_RX_CLK_EXT_SEL_IN BIT(0) 33 + #define ETHER_CLK_SEL_RX_CLK_EXT_SEL_IN 0 34 34 #define ETHER_CLK_SEL_RX_CLK_EXT_SEL_RXC BIT(12) 35 35 #define ETHER_CLK_SEL_RX_CLK_EXT_SEL_DIV BIT(13) 36 - #define ETHER_CLK_SEL_TX_CLK_O_TX_I BIT(0) 36 + #define ETHER_CLK_SEL_TX_CLK_O_TX_I 0 37 37 #define ETHER_CLK_SEL_TX_CLK_O_RMII_I BIT(14) 38 38 #define ETHER_CLK_SEL_TX_O_E_N_IN BIT(15) 39 - #define ETHER_CLK_SEL_RMII_CLK_SEL_IN BIT(0) 39 + #define ETHER_CLK_SEL_RMII_CLK_SEL_IN 0 40 40 #define ETHER_CLK_SEL_RMII_CLK_SEL_RX_C BIT(16) 41 41 42 42 #define ETHER_CLK_SEL_RX_TX_CLK_EN (ETHER_CLK_SEL_RX_CLK_EN | ETHER_CLK_SEL_TX_CLK_EN) ··· 96 96 val |= ETHER_CLK_SEL_TX_O_E_N_IN; 97 97 writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 98 98 99 + /* Set Clock-Mux, Start clock, Set TX_O direction */ 99 100 switch (dwmac->phy_intf_sel) { 100 101 case ETHER_CONFIG_INTF_RGMII: 101 102 val = clk_sel_val | ETHER_CLK_SEL_RX_CLK_EXT_SEL_RXC; 103 + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 104 + 105 + val |= ETHER_CLK_SEL_RX_TX_CLK_EN; 106 + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 107 + 108 + val &= ~ETHER_CLK_SEL_TX_O_E_N_IN; 109 + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 102 110 break; 103 111 case ETHER_CONFIG_INTF_RMII: 104 112 val = clk_sel_val | ETHER_CLK_SEL_RX_CLK_EXT_SEL_DIV | 105 - ETHER_CLK_SEL_TX_CLK_EXT_SEL_TXC | ETHER_CLK_SEL_TX_O_E_N_IN | 113 + ETHER_CLK_SEL_TX_CLK_EXT_SEL_DIV | ETHER_CLK_SEL_TX_O_E_N_IN | 106 114 ETHER_CLK_SEL_RMII_CLK_SEL_RX_C; 115 + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 116 + 117 + val |= ETHER_CLK_SEL_RMII_CLK_RST; 118 + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 119 + 120 + val |= ETHER_CLK_SEL_RMII_CLK_EN | ETHER_CLK_SEL_RX_TX_CLK_EN; 121 + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 107 122 break; 108 123 case ETHER_CONFIG_INTF_MII: 109 124 default: 110 125 val = clk_sel_val | ETHER_CLK_SEL_RX_CLK_EXT_SEL_RXC | 111 - ETHER_CLK_SEL_TX_CLK_EXT_SEL_DIV | ETHER_CLK_SEL_TX_O_E_N_IN | 112 - ETHER_CLK_SEL_RMII_CLK_EN; 126 + ETHER_CLK_SEL_TX_CLK_EXT_SEL_TXC | ETHER_CLK_SEL_TX_O_E_N_IN; 127 + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 128 + 129 + val |= ETHER_CLK_SEL_RX_TX_CLK_EN; 130 + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 113 131 break; 114 132 } 115 - 116 - /* Start clock */ 117 - writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 118 - val |= ETHER_CLK_SEL_RX_TX_CLK_EN; 119 - writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 120 - 121 - val &= ~ETHER_CLK_SEL_TX_O_E_N_IN; 122 - writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); 123 133 124 134 spin_unlock_irqrestore(&dwmac->lock, flags); 125 135 }
-2
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 194 194 u32 tx_coal_timer[MTL_MAX_TX_QUEUES]; 195 195 u32 rx_coal_frames[MTL_MAX_TX_QUEUES]; 196 196 197 - int tx_coalesce; 198 197 int hwts_tx_en; 199 198 bool tx_path_in_lpi_mode; 200 199 bool tso; ··· 228 229 unsigned int flow_ctrl; 229 230 unsigned int pause; 230 231 struct mii_bus *mii; 231 - int mii_irq[PHY_MAX_ADDR]; 232 232 233 233 struct phylink_config phylink_config; 234 234 struct phylink *phylink;
+19 -17
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 402 402 * Description: this function is to verify and enter in LPI mode in case of 403 403 * EEE. 404 404 */ 405 - static void stmmac_enable_eee_mode(struct stmmac_priv *priv) 405 + static int stmmac_enable_eee_mode(struct stmmac_priv *priv) 406 406 { 407 407 u32 tx_cnt = priv->plat->tx_queues_to_use; 408 408 u32 queue; ··· 412 412 struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; 413 413 414 414 if (tx_q->dirty_tx != tx_q->cur_tx) 415 - return; /* still unfinished work */ 415 + return -EBUSY; /* still unfinished work */ 416 416 } 417 417 418 418 /* Check and enter in LPI mode */ 419 419 if (!priv->tx_path_in_lpi_mode) 420 420 stmmac_set_eee_mode(priv, priv->hw, 421 421 priv->plat->en_tx_lpi_clockgating); 422 + return 0; 422 423 } 423 424 424 425 /** ··· 451 450 { 452 451 struct stmmac_priv *priv = from_timer(priv, t, eee_ctrl_timer); 453 452 454 - stmmac_enable_eee_mode(priv); 455 - mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(priv->tx_lpi_timer)); 453 + if (stmmac_enable_eee_mode(priv)) 454 + mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(priv->tx_lpi_timer)); 456 455 } 457 456 458 457 /** ··· 890 889 bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac; 891 890 int ret; 892 891 892 + if (priv->plat->ptp_clk_freq_config) 893 + priv->plat->ptp_clk_freq_config(priv); 894 + 893 895 ret = stmmac_init_tstamp_counter(priv, STMMAC_HWTS_ACTIVE); 894 896 if (ret) 895 897 return ret; ··· 914 910 915 911 priv->hwts_tx_en = 0; 916 912 priv->hwts_rx_en = 0; 917 - 918 - stmmac_ptp_register(priv); 919 913 920 914 return 0; 921 915 } ··· 2649 2647 2650 2648 if (priv->eee_enabled && !priv->tx_path_in_lpi_mode && 2651 2649 priv->eee_sw_timer_en) { 2652 - stmmac_enable_eee_mode(priv); 2653 - mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(priv->tx_lpi_timer)); 2650 + if (stmmac_enable_eee_mode(priv)) 2651 + mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(priv->tx_lpi_timer)); 2654 2652 } 2655 2653 2656 2654 /* We still have pending packets, let's call for a new scheduling */ ··· 3240 3238 /** 3241 3239 * stmmac_hw_setup - setup mac in a usable state. 3242 3240 * @dev : pointer to the device structure. 3243 - * @init_ptp: initialize PTP if set 3241 + * @ptp_register: register PTP if set 3244 3242 * Description: 3245 3243 * this is the main function to setup the HW in a usable state because the 3246 3244 * dma engine is reset, the core registers are configured (e.g. AXI, ··· 3250 3248 * 0 on success and an appropriate (-)ve integer as defined in errno.h 3251 3249 * file on failure. 3252 3250 */ 3253 - static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) 3251 + static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) 3254 3252 { 3255 3253 struct stmmac_priv *priv = netdev_priv(dev); 3256 3254 u32 rx_cnt = priv->plat->rx_queues_to_use; ··· 3307 3305 3308 3306 stmmac_mmc_setup(priv); 3309 3307 3310 - if (init_ptp) { 3311 - ret = stmmac_init_ptp(priv); 3312 - if (ret == -EOPNOTSUPP) 3313 - netdev_warn(priv->dev, "PTP not supported by HW\n"); 3314 - else if (ret) 3315 - netdev_warn(priv->dev, "PTP init failed\n"); 3316 - } 3308 + ret = stmmac_init_ptp(priv); 3309 + if (ret == -EOPNOTSUPP) 3310 + netdev_warn(priv->dev, "PTP not supported by HW\n"); 3311 + else if (ret) 3312 + netdev_warn(priv->dev, "PTP init failed\n"); 3313 + else if (ptp_register) 3314 + stmmac_ptp_register(priv); 3317 3315 3318 3316 priv->eee_tw_timer = STMMAC_DEFAULT_TWT_LS; 3319 3317
-3
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
··· 297 297 { 298 298 int i; 299 299 300 - if (priv->plat->ptp_clk_freq_config) 301 - priv->plat->ptp_clk_freq_config(priv); 302 - 303 300 for (i = 0; i < priv->dma_cap.pps_out_num; i++) { 304 301 if (i >= STMMAC_PPS_MAX) 305 302 break;
+1 -1
drivers/net/ethernet/ti/cpsw_priv.c
··· 1146 1146 static struct page_pool *cpsw_create_page_pool(struct cpsw_common *cpsw, 1147 1147 int size) 1148 1148 { 1149 - struct page_pool_params pp_params; 1149 + struct page_pool_params pp_params = {}; 1150 1150 struct page_pool *pool; 1151 1151 1152 1152 pp_params.order = 0;
+18 -17
drivers/net/ethernet/tundra/tsi108_eth.c
··· 1091 1091 struct tsi108_prv_data *data = netdev_priv(dev); 1092 1092 u32 word1 = TSI_READ(TSI108_MAC_ADDR1); 1093 1093 u32 word2 = TSI_READ(TSI108_MAC_ADDR2); 1094 + u8 addr[ETH_ALEN]; 1094 1095 1095 1096 /* Note that the octets are reversed from what the manual says, 1096 1097 * producing an even weirder ordering... 1097 1098 */ 1098 1099 if (word2 == 0 && word1 == 0) { 1099 - dev->dev_addr[0] = 0x00; 1100 - dev->dev_addr[1] = 0x06; 1101 - dev->dev_addr[2] = 0xd2; 1102 - dev->dev_addr[3] = 0x00; 1103 - dev->dev_addr[4] = 0x00; 1100 + addr[0] = 0x00; 1101 + addr[1] = 0x06; 1102 + addr[2] = 0xd2; 1103 + addr[3] = 0x00; 1104 + addr[4] = 0x00; 1104 1105 if (0x8 == data->phy) 1105 - dev->dev_addr[5] = 0x01; 1106 + addr[5] = 0x01; 1106 1107 else 1107 - dev->dev_addr[5] = 0x02; 1108 + addr[5] = 0x02; 1109 + eth_hw_addr_set(dev, addr); 1108 1110 1109 1111 word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24); 1110 1112 ··· 1116 1114 TSI_WRITE(TSI108_MAC_ADDR1, word1); 1117 1115 TSI_WRITE(TSI108_MAC_ADDR2, word2); 1118 1116 } else { 1119 - dev->dev_addr[0] = (word2 >> 16) & 0xff; 1120 - dev->dev_addr[1] = (word2 >> 24) & 0xff; 1121 - dev->dev_addr[2] = (word1 >> 0) & 0xff; 1122 - dev->dev_addr[3] = (word1 >> 8) & 0xff; 1123 - dev->dev_addr[4] = (word1 >> 16) & 0xff; 1124 - dev->dev_addr[5] = (word1 >> 24) & 0xff; 1117 + addr[0] = (word2 >> 16) & 0xff; 1118 + addr[1] = (word2 >> 24) & 0xff; 1119 + addr[2] = (word1 >> 0) & 0xff; 1120 + addr[3] = (word1 >> 8) & 0xff; 1121 + addr[4] = (word1 >> 16) & 0xff; 1122 + addr[5] = (word1 >> 24) & 0xff; 1123 + eth_hw_addr_set(dev, addr); 1125 1124 } 1126 1125 1127 1126 if (!is_valid_ether_addr(dev->dev_addr)) { ··· 1139 1136 { 1140 1137 struct tsi108_prv_data *data = netdev_priv(dev); 1141 1138 u32 word1, word2; 1142 - int i; 1143 1139 1144 1140 if (!is_valid_ether_addr(addr)) 1145 1141 return -EADDRNOTAVAIL; 1146 1142 1147 - for (i = 0; i < 6; i++) 1148 - /* +2 is for the offset of the HW addr type */ 1149 - dev->dev_addr[i] = ((unsigned char *)addr)[i + 2]; 1143 + /* +2 is for the offset of the HW addr type */ 1144 + eth_hw_addr_set(dev, ((unsigned char *)addr) + 2); 1150 1145 1151 1146 word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24); 1152 1147
+1 -3
drivers/net/hamradio/yam.c
··· 950 950 ym = memdup_user(data, sizeof(struct yamdrv_ioctl_mcs)); 951 951 if (IS_ERR(ym)) 952 952 return PTR_ERR(ym); 953 - if (ym->cmd != SIOCYAMSMCS) 954 - return -EINVAL; 955 - if (ym->bitrate > YAM_MAXBITRATE) { 953 + if (ym->cmd != SIOCYAMSMCS || ym->bitrate > YAM_MAXBITRATE) { 956 954 kfree(ym); 957 955 return -EINVAL; 958 956 }
+1
drivers/net/phy/broadcom.c
··· 854 854 .phy_id_mask = 0xfffffff0, 855 855 .name = "Broadcom BCM54616S", 856 856 /* PHY_GBIT_FEATURES */ 857 + .soft_reset = genphy_soft_reset, 857 858 .config_init = bcm54xx_config_init, 858 859 .config_aneg = bcm54616s_config_aneg, 859 860 .config_intr = bcm_phy_config_intr,
+3 -3
drivers/net/phy/phy_device.c
··· 1746 1746 phy_driver_is_genphy_10g(phydev)) 1747 1747 device_release_driver(&phydev->mdio.dev); 1748 1748 1749 + /* Assert the reset signal */ 1750 + phy_device_reset(phydev, 1); 1751 + 1749 1752 /* 1750 1753 * The phydev might go away on the put_device() below, so avoid 1751 1754 * a use-after-free bug by reading the underlying bus first. ··· 1760 1757 ndev_owner = dev->dev.parent->driver->owner; 1761 1758 if (ndev_owner != bus->owner) 1762 1759 module_put(bus->owner); 1763 - 1764 - /* Assert the reset signal */ 1765 - phy_device_reset(phydev, 1); 1766 1760 } 1767 1761 EXPORT_SYMBOL(phy_detach); 1768 1762
+5
drivers/net/phy/sfp-bus.c
··· 651 651 else if (ret < 0) 652 652 return ERR_PTR(ret); 653 653 654 + if (!fwnode_device_is_available(ref.fwnode)) { 655 + fwnode_handle_put(ref.fwnode); 656 + return NULL; 657 + } 658 + 654 659 bus = sfp_bus_get(ref.fwnode); 655 660 fwnode_handle_put(ref.fwnode); 656 661 if (!bus)
+1 -2
drivers/nvme/host/fabrics.c
··· 1092 1092 static int nvmf_dev_show(struct seq_file *seq_file, void *private) 1093 1093 { 1094 1094 struct nvme_ctrl *ctrl; 1095 - int ret = 0; 1096 1095 1097 1096 mutex_lock(&nvmf_dev_mutex); 1098 1097 ctrl = seq_file->private; ··· 1105 1106 1106 1107 out_unlock: 1107 1108 mutex_unlock(&nvmf_dev_mutex); 1108 - return ret; 1109 + return 0; 1109 1110 } 1110 1111 1111 1112 static int nvmf_dev_open(struct inode *inode, struct file *file)
+2 -1
drivers/nvme/host/pci.c
··· 3391 3391 NVME_QUIRK_DEALLOCATE_ZEROES, }, 3392 3392 { PCI_VDEVICE(INTEL, 0x0a54), /* Intel P4500/P4600 */ 3393 3393 .driver_data = NVME_QUIRK_STRIPE_SIZE | 3394 - NVME_QUIRK_DEALLOCATE_ZEROES, }, 3394 + NVME_QUIRK_DEALLOCATE_ZEROES | 3395 + NVME_QUIRK_IGNORE_DEV_SUBNQN, }, 3395 3396 { PCI_VDEVICE(INTEL, 0x0a55), /* Dell Express Flash P4600 */ 3396 3397 .driver_data = NVME_QUIRK_STRIPE_SIZE | 3397 3398 NVME_QUIRK_DEALLOCATE_ZEROES, },
+1 -10
drivers/pci/controller/pcie-mt7621.c
··· 109 109 writel_relaxed(val, pcie->base + reg); 110 110 } 111 111 112 - static inline void pcie_rmw(struct mt7621_pcie *pcie, u32 reg, u32 clr, u32 set) 113 - { 114 - u32 val = readl_relaxed(pcie->base + reg); 115 - 116 - val &= ~clr; 117 - val |= set; 118 - writel_relaxed(val, pcie->base + reg); 119 - } 120 - 121 112 static inline u32 pcie_port_read(struct mt7621_pcie_port *port, u32 reg) 122 113 { 123 114 return readl_relaxed(port->base + reg); ··· 548 557 .remove = mt7621_pcie_remove, 549 558 .driver = { 550 559 .name = "mt7621-pci", 551 - .of_match_table = of_match_ptr(mt7621_pcie_ids), 560 + .of_match_table = mt7621_pcie_ids, 552 561 }, 553 562 }; 554 563 builtin_platform_driver(mt7621_pcie_driver);
+2 -2
drivers/pci/msi/irqdomain.c
··· 28 28 msi_domain_free_irqs_descs_locked(domain, &dev->dev); 29 29 else 30 30 pci_msi_legacy_teardown_msi_irqs(dev); 31 + msi_free_msi_descs(&dev->dev); 31 32 } 32 33 33 34 /** ··· 172 171 if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) 173 172 pci_msi_domain_update_chip_ops(info); 174 173 175 - info->flags |= MSI_FLAG_ACTIVATE_EARLY | MSI_FLAG_DEV_SYSFS | 176 - MSI_FLAG_FREE_MSI_DESCS; 174 + info->flags |= MSI_FLAG_ACTIVATE_EARLY | MSI_FLAG_DEV_SYSFS; 177 175 if (IS_ENABLED(CONFIG_GENERIC_IRQ_RESERVATION_MODE)) 178 176 info->flags |= MSI_FLAG_MUST_REACTIVATE; 179 177
-1
drivers/pci/msi/legacy.c
··· 77 77 { 78 78 msi_device_destroy_sysfs(&dev->dev); 79 79 arch_teardown_msi_irqs(dev); 80 - msi_free_msi_descs(&dev->dev); 81 80 }
+4
drivers/remoteproc/Kconfig
··· 180 180 depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n 181 181 depends on QCOM_SYSMON || QCOM_SYSMON=n 182 182 depends on RPMSG_QCOM_GLINK || RPMSG_QCOM_GLINK=n 183 + depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n 183 184 select MFD_SYSCON 184 185 select QCOM_PIL_INFO 185 186 select QCOM_MDT_LOADER ··· 200 199 depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n 201 200 depends on QCOM_SYSMON || QCOM_SYSMON=n 202 201 depends on RPMSG_QCOM_GLINK || RPMSG_QCOM_GLINK=n 202 + depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n 203 203 select MFD_SYSCON 204 204 select QCOM_MDT_LOADER 205 205 select QCOM_PIL_INFO ··· 220 218 depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n 221 219 depends on QCOM_SYSMON || QCOM_SYSMON=n 222 220 depends on RPMSG_QCOM_GLINK || RPMSG_QCOM_GLINK=n 221 + depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n 223 222 select MFD_SYSCON 224 223 select QCOM_PIL_INFO 225 224 select QCOM_MDT_LOADER ··· 242 239 depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n 243 240 depends on QCOM_SYSMON || QCOM_SYSMON=n 244 241 depends on RPMSG_QCOM_GLINK || RPMSG_QCOM_GLINK=n 242 + depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n 245 243 select MFD_SYSCON 246 244 select QCOM_MDT_LOADER 247 245 select QCOM_PIL_INFO
+1
drivers/remoteproc/qcom_q6v5.c
··· 10 10 #include <linux/platform_device.h> 11 11 #include <linux/interrupt.h> 12 12 #include <linux/module.h> 13 + #include <linux/soc/qcom/qcom_aoss.h> 13 14 #include <linux/soc/qcom/smem.h> 14 15 #include <linux/soc/qcom/smem_state.h> 15 16 #include <linux/remoteproc.h>
+4 -18
drivers/rpmsg/rpmsg_char.c
··· 93 93 /* wake up any blocked readers */ 94 94 wake_up_interruptible(&eptdev->readq); 95 95 96 - device_del(&eptdev->dev); 96 + cdev_device_del(&eptdev->cdev, &eptdev->dev); 97 97 put_device(&eptdev->dev); 98 98 99 99 return 0; ··· 336 336 337 337 ida_simple_remove(&rpmsg_ept_ida, dev->id); 338 338 ida_simple_remove(&rpmsg_minor_ida, MINOR(eptdev->dev.devt)); 339 - cdev_del(&eptdev->cdev); 340 339 kfree(eptdev); 341 340 } 342 341 ··· 380 381 dev->id = ret; 381 382 dev_set_name(dev, "rpmsg%d", ret); 382 383 383 - ret = cdev_add(&eptdev->cdev, dev->devt, 1); 384 + ret = cdev_device_add(&eptdev->cdev, &eptdev->dev); 384 385 if (ret) 385 386 goto free_ept_ida; 386 387 387 388 /* We can now rely on the release function for cleanup */ 388 389 dev->release = rpmsg_eptdev_release_device; 389 - 390 - ret = device_add(dev); 391 - if (ret) { 392 - dev_err(dev, "device_add failed: %d\n", ret); 393 - put_device(dev); 394 - } 395 390 396 391 return ret; 397 392 ··· 455 462 456 463 ida_simple_remove(&rpmsg_ctrl_ida, dev->id); 457 464 ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); 458 - cdev_del(&ctrldev->cdev); 459 465 kfree(ctrldev); 460 466 } 461 467 ··· 489 497 dev->id = ret; 490 498 dev_set_name(&ctrldev->dev, "rpmsg_ctrl%d", ret); 491 499 492 - ret = cdev_add(&ctrldev->cdev, dev->devt, 1); 500 + ret = cdev_device_add(&ctrldev->cdev, &ctrldev->dev); 493 501 if (ret) 494 502 goto free_ctrl_ida; 495 503 496 504 /* We can now rely on the release function for cleanup */ 497 505 dev->release = rpmsg_ctrldev_release_device; 498 - 499 - ret = device_add(dev); 500 - if (ret) { 501 - dev_err(&rpdev->dev, "device_add failed: %d\n", ret); 502 - put_device(dev); 503 - } 504 506 505 507 dev_set_drvdata(&rpdev->dev, ctrldev); 506 508 ··· 521 535 if (ret) 522 536 dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret); 523 537 524 - device_del(&ctrldev->dev); 538 + cdev_device_del(&ctrldev->cdev, &ctrldev->dev); 525 539 put_device(&ctrldev->dev); 526 540 } 527 541
+12 -1
drivers/s390/scsi/zfcp_fc.c
··· 521 521 goto out; 522 522 } 523 523 524 + /* re-init to undo drop from zfcp_fc_adisc() */ 525 + port->d_id = ntoh24(adisc_resp->adisc_port_id); 524 526 /* port is good, unblock rport without going through erp */ 525 527 zfcp_scsi_schedule_rport_register(port); 526 528 out: ··· 536 534 struct zfcp_fc_req *fc_req; 537 535 struct zfcp_adapter *adapter = port->adapter; 538 536 struct Scsi_Host *shost = adapter->scsi_host; 537 + u32 d_id; 539 538 int ret; 540 539 541 540 fc_req = kmem_cache_zalloc(zfcp_fc_req_cache, GFP_ATOMIC); ··· 561 558 fc_req->u.adisc.req.adisc_cmd = ELS_ADISC; 562 559 hton24(fc_req->u.adisc.req.adisc_port_id, fc_host_port_id(shost)); 563 560 564 - ret = zfcp_fsf_send_els(adapter, port->d_id, &fc_req->ct_els, 561 + d_id = port->d_id; /* remember as destination for send els below */ 562 + /* 563 + * Force fresh GID_PN lookup on next port recovery. 564 + * Must happen after request setup and before sending request, 565 + * to prevent race with port->d_id re-init in zfcp_fc_adisc_handler(). 566 + */ 567 + port->d_id = 0; 568 + 569 + ret = zfcp_fsf_send_els(adapter, d_id, &fc_req->ct_els, 565 570 ZFCP_FC_CTELS_TMO); 566 571 if (ret) 567 572 kmem_cache_free(zfcp_fc_req_cache, fc_req);
-4
drivers/scsi/3w-sas.c
··· 1567 1567 pci_try_set_mwi(pdev); 1568 1568 1569 1569 retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 1570 - if (retval) 1571 - retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); 1572 1570 if (retval) { 1573 1571 TW_PRINTK(host, TW_DRIVER, 0x18, "Failed to set dma mask"); 1574 1572 retval = -ENODEV; ··· 1784 1786 pci_try_set_mwi(pdev); 1785 1787 1786 1788 retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 1787 - if (retval) 1788 - retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); 1789 1789 if (retval) { 1790 1790 TW_PRINTK(host, TW_DRIVER, 0x25, "Failed to set dma mask during resume"); 1791 1791 retval = -ENODEV;
-1
drivers/scsi/53c700.c
··· 1507 1507 struct scsi_cmnd *SCp = hostdata->cmd; 1508 1508 1509 1509 handled = 1; 1510 - SCp = hostdata->cmd; 1511 1510 1512 1511 if(istat & SCSI_INT_PENDING) { 1513 1512 udelay(10);
-6
drivers/scsi/bfa/bfad.c
··· 732 732 pci_set_master(pdev); 733 733 734 734 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 735 - if (rc) 736 - rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); 737 - 738 735 if (rc) { 739 736 rc = -ENODEV; 740 737 printk(KERN_ERR "dma_set_mask_and_coherent fail %p\n", pdev); ··· 1556 1559 pci_set_master(pdev); 1557 1560 1558 1561 rc = dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(64)); 1559 - if (rc) 1560 - rc = dma_set_mask_and_coherent(&bfad->pcidev->dev, 1561 - DMA_BIT_MASK(32)); 1562 1562 if (rc) 1563 1563 goto out_disable_device; 1564 1564
+5 -15
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
··· 82 82 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba); 83 83 static struct fc_lport *bnx2fc_if_create(struct bnx2fc_interface *interface, 84 84 struct device *parent, int npiv); 85 - static void bnx2fc_destroy_work(struct work_struct *work); 85 + static void bnx2fc_port_destroy(struct fcoe_port *port); 86 86 87 87 static struct bnx2fc_hba *bnx2fc_hba_lookup(struct net_device *phys_dev); 88 88 static struct bnx2fc_interface *bnx2fc_interface_lookup(struct net_device ··· 907 907 __bnx2fc_destroy(interface); 908 908 } 909 909 mutex_unlock(&bnx2fc_dev_lock); 910 - 911 - /* Ensure ALL destroy work has been completed before return */ 912 - flush_workqueue(bnx2fc_wq); 913 910 return; 914 911 915 912 default: ··· 1212 1215 mutex_unlock(&n_port->lp_mutex); 1213 1216 bnx2fc_free_vport(interface->hba, port->lport); 1214 1217 bnx2fc_port_shutdown(port->lport); 1218 + bnx2fc_port_destroy(port); 1215 1219 bnx2fc_interface_put(interface); 1216 - queue_work(bnx2fc_wq, &port->destroy_work); 1217 1220 return 0; 1218 1221 } 1219 1222 ··· 1522 1525 port->lport = lport; 1523 1526 port->priv = interface; 1524 1527 port->get_netdev = bnx2fc_netdev; 1525 - INIT_WORK(&port->destroy_work, bnx2fc_destroy_work); 1526 1528 1527 1529 /* Configure fcoe_port */ 1528 1530 rc = bnx2fc_lport_config(lport); ··· 1649 1653 bnx2fc_interface_cleanup(interface); 1650 1654 bnx2fc_stop(interface); 1651 1655 list_del(&interface->list); 1656 + bnx2fc_port_destroy(port); 1652 1657 bnx2fc_interface_put(interface); 1653 - queue_work(bnx2fc_wq, &port->destroy_work); 1654 1658 } 1655 1659 1656 1660 /** ··· 1690 1694 return rc; 1691 1695 } 1692 1696 1693 - static void bnx2fc_destroy_work(struct work_struct *work) 1697 + static void bnx2fc_port_destroy(struct fcoe_port *port) 1694 1698 { 1695 - struct fcoe_port *port; 1696 1699 struct fc_lport *lport; 1697 1700 1698 - port = container_of(work, struct fcoe_port, destroy_work); 1699 1701 lport = port->lport; 1700 - 1701 - BNX2FC_HBA_DBG(lport, "Entered bnx2fc_destroy_work\n"); 1702 + BNX2FC_HBA_DBG(lport, "Entered %s, destroying lport %p\n", __func__, lport); 1702 1703 1703 1704 bnx2fc_if_destroy(lport); 1704 1705 } ··· 2548 2555 if (interface->hba == hba) 2549 2556 __bnx2fc_destroy(interface); 2550 2557 mutex_unlock(&bnx2fc_dev_lock); 2551 - 2552 - /* Ensure ALL destroy work has been completed before return */ 2553 - flush_workqueue(bnx2fc_wq); 2554 2558 2555 2559 bnx2fc_ulp_stop(hba); 2556 2560 /* unregister cnic device */
+2 -6
drivers/scsi/elx/libefc/efc_els.c
··· 46 46 47 47 efc = node->efc; 48 48 49 - spin_lock_irqsave(&node->els_ios_lock, flags); 50 - 51 49 if (!node->els_io_enabled) { 52 50 efc_log_err(efc, "els io alloc disabled\n"); 53 - spin_unlock_irqrestore(&node->els_ios_lock, flags); 54 51 return NULL; 55 52 } 56 53 57 54 els = mempool_alloc(efc->els_io_pool, GFP_ATOMIC); 58 55 if (!els) { 59 56 atomic_add_return(1, &efc->els_io_alloc_failed_count); 60 - spin_unlock_irqrestore(&node->els_ios_lock, flags); 61 57 return NULL; 62 58 } 63 59 ··· 70 74 &els->io.req.phys, GFP_KERNEL); 71 75 if (!els->io.req.virt) { 72 76 mempool_free(els, efc->els_io_pool); 73 - spin_unlock_irqrestore(&node->els_ios_lock, flags); 74 77 return NULL; 75 78 } 76 79 ··· 89 94 90 95 /* add els structure to ELS IO list */ 91 96 INIT_LIST_HEAD(&els->list_entry); 97 + spin_lock_irqsave(&node->els_ios_lock, flags); 92 98 list_add_tail(&els->list_entry, &node->els_ios_list); 99 + spin_unlock_irqrestore(&node->els_ios_lock, flags); 93 100 } 94 101 95 - spin_unlock_irqrestore(&node->els_ios_lock, flags); 96 102 return els; 97 103 } 98 104
-3
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 2666 2666 goto err_out; 2667 2667 2668 2668 error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); 2669 - if (error) 2670 - error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); 2671 - 2672 2669 if (error) { 2673 2670 dev_err(dev, "No usable DMA addressing method\n"); 2674 2671 goto err_out;
-2
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 4695 4695 goto err_out; 4696 4696 4697 4697 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 4698 - if (rc) 4699 - rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); 4700 4698 if (rc) { 4701 4699 dev_err(dev, "No usable DMA addressing method\n"); 4702 4700 rc = -ENODEV;
+2 -1
drivers/scsi/myrs.c
··· 2267 2267 myrs_unmap(cs); 2268 2268 2269 2269 if (cs->mmio_base) { 2270 - cs->disable_intr(cs); 2270 + if (cs->disable_intr) 2271 + cs->disable_intr(cs); 2271 2272 iounmap(cs->mmio_base); 2272 2273 cs->mmio_base = NULL; 2273 2274 }
+14 -2
drivers/scsi/pm8001/pm80xx_hwi.c
··· 4151 4151 u32 ret = MPI_IO_STATUS_FAIL; 4152 4152 u32 regval; 4153 4153 4154 + /* 4155 + * Fatal errors are programmed to be signalled in irq vector 4156 + * pm8001_ha->max_q_num - 1 through pm8001_ha->main_cfg_tbl.pm80xx_tbl. 4157 + * fatal_err_interrupt 4158 + */ 4154 4159 if (vec == (pm8001_ha->max_q_num - 1)) { 4160 + u32 mipsall_ready; 4161 + 4162 + if (pm8001_ha->chip_id == chip_8008 || 4163 + pm8001_ha->chip_id == chip_8009) 4164 + mipsall_ready = SCRATCH_PAD_MIPSALL_READY_8PORT; 4165 + else 4166 + mipsall_ready = SCRATCH_PAD_MIPSALL_READY_16PORT; 4167 + 4155 4168 regval = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); 4156 - if ((regval & SCRATCH_PAD_MIPSALL_READY) != 4157 - SCRATCH_PAD_MIPSALL_READY) { 4169 + if ((regval & mipsall_ready) != mipsall_ready) { 4158 4170 pm8001_ha->controller_fatal_error = true; 4159 4171 pm8001_dbg(pm8001_ha, FAIL, 4160 4172 "Firmware Fatal error! Regval:0x%x\n",
+5 -1
drivers/scsi/pm8001/pm80xx_hwi.h
··· 1405 1405 #define SCRATCH_PAD_BOOT_LOAD_SUCCESS 0x0 1406 1406 #define SCRATCH_PAD_IOP0_READY 0xC00 1407 1407 #define SCRATCH_PAD_IOP1_READY 0x3000 1408 - #define SCRATCH_PAD_MIPSALL_READY (SCRATCH_PAD_IOP1_READY | \ 1408 + #define SCRATCH_PAD_MIPSALL_READY_16PORT (SCRATCH_PAD_IOP1_READY | \ 1409 1409 SCRATCH_PAD_IOP0_READY | \ 1410 + SCRATCH_PAD_ILA_READY | \ 1411 + SCRATCH_PAD_RAAE_READY) 1412 + #define SCRATCH_PAD_MIPSALL_READY_8PORT (SCRATCH_PAD_IOP0_READY | \ 1413 + SCRATCH_PAD_ILA_READY | \ 1410 1414 SCRATCH_PAD_RAAE_READY) 1411 1415 1412 1416 /* boot loader state */
+1
drivers/scsi/qedf/qedf_io.c
··· 2250 2250 io_req->tm_flags == FCP_TMF_TGT_RESET) { 2251 2251 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); 2252 2252 io_req->sc_cmd = NULL; 2253 + kref_put(&io_req->refcount, qedf_release_cmd); 2253 2254 complete(&io_req->tm_done); 2254 2255 } 2255 2256
+5 -2
drivers/scsi/qedf/qedf_main.c
··· 911 911 struct qed_link_output if_link; 912 912 913 913 if (lport->vport) { 914 - QEDF_ERR(NULL, "Cannot issue host reset on NPIV port.\n"); 914 + printk_ratelimited("Cannot issue host reset on NPIV port.\n"); 915 915 return; 916 916 } 917 917 ··· 1864 1864 vport_qedf->cmd_mgr = base_qedf->cmd_mgr; 1865 1865 init_completion(&vport_qedf->flogi_compl); 1866 1866 INIT_LIST_HEAD(&vport_qedf->fcports); 1867 + INIT_DELAYED_WORK(&vport_qedf->stag_work, qedf_stag_change_work); 1867 1868 1868 1869 rc = qedf_vport_libfc_config(vport, vn_port); 1869 1870 if (rc) { ··· 3981 3980 struct qedf_ctx *qedf = 3982 3981 container_of(work, struct qedf_ctx, stag_work.work); 3983 3982 3984 - QEDF_ERR(&qedf->dbg_ctx, "Performing software context reset.\n"); 3983 + printk_ratelimited("[%s]:[%s:%d]:%d: Performing software context reset.", 3984 + dev_name(&qedf->pdev->dev), __func__, __LINE__, 3985 + qedf->dbg_ctx.host_no); 3985 3986 qedf_ctx_soft_reset(qedf->lport); 3986 3987 } 3987 3988
+7
drivers/scsi/ufs/ufshcd-pltfrm.c
··· 92 92 clki->min_freq = clkfreq[i]; 93 93 clki->max_freq = clkfreq[i+1]; 94 94 clki->name = devm_kstrdup(dev, name, GFP_KERNEL); 95 + if (!clki->name) { 96 + ret = -ENOMEM; 97 + goto out; 98 + } 99 + 95 100 if (!strcmp(name, "ref_clk")) 96 101 clki->keep_link_active = true; 97 102 dev_dbg(dev, "%s: min %u max %u name %s\n", "freq-table-hz", ··· 132 127 return -ENOMEM; 133 128 134 129 vreg->name = devm_kstrdup(dev, name, GFP_KERNEL); 130 + if (!vreg->name) 131 + return -ENOMEM; 135 132 136 133 snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name); 137 134 if (of_property_read_u32(np, prop_name, &vreg->max_uA)) {
+6 -3
drivers/scsi/ufs/ufshcd.c
··· 8613 8613 * @pwr_mode: device power mode to set 8614 8614 * 8615 8615 * Returns 0 if requested power mode is set successfully 8616 - * Returns non-zero if failed to set the requested power mode 8616 + * Returns < 0 if failed to set the requested power mode 8617 8617 */ 8618 8618 static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, 8619 8619 enum ufs_dev_pwr_mode pwr_mode) ··· 8667 8667 sdev_printk(KERN_WARNING, sdp, 8668 8668 "START_STOP failed for power mode: %d, result %x\n", 8669 8669 pwr_mode, ret); 8670 - if (ret > 0 && scsi_sense_valid(&sshdr)) 8671 - scsi_print_sense_hdr(sdp, NULL, &sshdr); 8670 + if (ret > 0) { 8671 + if (scsi_sense_valid(&sshdr)) 8672 + scsi_print_sense_hdr(sdp, NULL, &sshdr); 8673 + ret = -EIO; 8674 + } 8672 8675 } 8673 8676 8674 8677 if (!ret)
+2 -1
drivers/scsi/ufs/ufshci.h
··· 142 142 #define INT_FATAL_ERRORS (DEVICE_FATAL_ERROR |\ 143 143 CONTROLLER_FATAL_ERROR |\ 144 144 SYSTEM_BUS_FATAL_ERROR |\ 145 - CRYPTO_ENGINE_FATAL_ERROR) 145 + CRYPTO_ENGINE_FATAL_ERROR |\ 146 + UIC_LINK_LOST) 146 147 147 148 /* HCS - Host Controller Status 30h */ 148 149 #define DEVICE_PRESENT 0x1
+3
drivers/target/iscsi/iscsi_target_tpg.c
··· 443 443 break; 444 444 } 445 445 spin_unlock(&tpg->tpg_np_lock); 446 + 447 + if (match) 448 + break; 446 449 } 447 450 spin_unlock(&tiqn->tiqn_tpg_lock); 448 451
+3 -1
drivers/tty/n_gsm.c
··· 322 322 #define GSM1_ESCAPE_BITS 0x20 323 323 #define XON 0x11 324 324 #define XOFF 0x13 325 + #define ISO_IEC_646_MASK 0x7F 325 326 326 327 static const struct tty_port_operations gsm_port_ops; 327 328 ··· 532 531 int olen = 0; 533 532 while (len--) { 534 533 if (*input == GSM1_SOF || *input == GSM1_ESCAPE 535 - || *input == XON || *input == XOFF) { 534 + || (*input & ISO_IEC_646_MASK) == XON 535 + || (*input & ISO_IEC_646_MASK) == XOFF) { 536 536 *output++ = GSM1_ESCAPE; 537 537 *output++ = *input++ ^ GSM1_ESCAPE_BITS; 538 538 olen++;
+26 -14
drivers/tty/rpmsg_tty.c
··· 50 50 static int rpmsg_tty_install(struct tty_driver *driver, struct tty_struct *tty) 51 51 { 52 52 struct rpmsg_tty_port *cport = idr_find(&tty_idr, tty->index); 53 + struct tty_port *port; 53 54 54 55 tty->driver_data = cport; 55 56 56 - return tty_port_install(&cport->port, driver, tty); 57 + port = tty_port_get(&cport->port); 58 + return tty_port_install(port, driver, tty); 59 + } 60 + 61 + static void rpmsg_tty_cleanup(struct tty_struct *tty) 62 + { 63 + tty_port_put(tty->port); 57 64 } 58 65 59 66 static int rpmsg_tty_open(struct tty_struct *tty, struct file *filp) ··· 113 106 return size; 114 107 } 115 108 109 + static void rpmsg_tty_hangup(struct tty_struct *tty) 110 + { 111 + tty_port_hangup(tty->port); 112 + } 113 + 116 114 static const struct tty_operations rpmsg_tty_ops = { 117 115 .install = rpmsg_tty_install, 118 116 .open = rpmsg_tty_open, 119 117 .close = rpmsg_tty_close, 120 118 .write = rpmsg_tty_write, 121 119 .write_room = rpmsg_tty_write_room, 120 + .hangup = rpmsg_tty_hangup, 121 + .cleanup = rpmsg_tty_cleanup, 122 122 }; 123 123 124 124 static struct rpmsg_tty_port *rpmsg_tty_alloc_cport(void) ··· 151 137 return cport; 152 138 } 153 139 154 - static void rpmsg_tty_release_cport(struct rpmsg_tty_port *cport) 140 + static void rpmsg_tty_destruct_port(struct tty_port *port) 155 141 { 142 + struct rpmsg_tty_port *cport = container_of(port, struct rpmsg_tty_port, port); 143 + 156 144 mutex_lock(&idr_lock); 157 145 idr_remove(&tty_idr, cport->id); 158 146 mutex_unlock(&idr_lock); ··· 162 146 kfree(cport); 163 147 } 164 148 165 - static const struct tty_port_operations rpmsg_tty_port_ops = { }; 149 + static const struct tty_port_operations rpmsg_tty_port_ops = { 150 + .destruct = rpmsg_tty_destruct_port, 151 + }; 152 + 166 153 167 154 static int rpmsg_tty_probe(struct rpmsg_device *rpdev) 168 155 { ··· 185 166 cport->id, dev); 186 167 if (IS_ERR(tty_dev)) { 187 168 ret = dev_err_probe(dev, PTR_ERR(tty_dev), "Failed to register tty port\n"); 188 - goto err_destroy; 169 + tty_port_put(&cport->port); 170 + return ret; 189 171 } 190 172 191 173 cport->rpdev = rpdev; ··· 197 177 rpdev->src, rpdev->dst, cport->id); 198 178 199 179 return 0; 200 - 201 - err_destroy: 202 - tty_port_destroy(&cport->port); 203 - rpmsg_tty_release_cport(cport); 204 - 205 - return ret; 206 180 } 207 181 208 182 static void rpmsg_tty_remove(struct rpmsg_device *rpdev) ··· 206 192 dev_dbg(&rpdev->dev, "Removing rpmsg tty device %d\n", cport->id); 207 193 208 194 /* User hang up to release the tty */ 209 - if (tty_port_initialized(&cport->port)) 210 - tty_port_tty_hangup(&cport->port, false); 195 + tty_port_tty_hangup(&cport->port, false); 211 196 212 197 tty_unregister_device(rpmsg_tty_driver, cport->id); 213 198 214 - tty_port_destroy(&cport->port); 215 - rpmsg_tty_release_cport(cport); 199 + tty_port_put(&cport->port); 216 200 } 217 201 218 202 static struct rpmsg_device_id rpmsg_driver_tty_id_table[] = {
+10 -1
drivers/tty/serial/8250/8250_of.c
··· 83 83 port->mapsize = resource_size(&resource); 84 84 85 85 /* Check for shifted address mapping */ 86 - if (of_property_read_u32(np, "reg-offset", &prop) == 0) 86 + if (of_property_read_u32(np, "reg-offset", &prop) == 0) { 87 + if (prop >= port->mapsize) { 88 + dev_warn(&ofdev->dev, "reg-offset %u exceeds region size %pa\n", 89 + prop, &port->mapsize); 90 + ret = -EINVAL; 91 + goto err_unprepare; 92 + } 93 + 87 94 port->mapbase += prop; 95 + port->mapsize -= prop; 96 + } 88 97 89 98 port->iotype = UPIO_MEM; 90 99 if (of_property_read_u32(np, "reg-io-width", &prop) == 0) {
+98 -2
drivers/tty/serial/8250/8250_pci.c
··· 4779 4779 { PCI_VENDOR_ID_INTASHIELD, PCI_DEVICE_ID_INTASHIELD_IS400, 4780 4780 PCI_ANY_ID, PCI_ANY_ID, 0, 0, /* 135a.0dc0 */ 4781 4781 pbn_b2_4_115200 }, 4782 + /* Brainboxes Devices */ 4782 4783 /* 4783 - * BrainBoxes UC-260 4784 + * Brainboxes UC-101 4785 + */ 4786 + { PCI_VENDOR_ID_INTASHIELD, 0x0BA1, 4787 + PCI_ANY_ID, PCI_ANY_ID, 4788 + 0, 0, 4789 + pbn_b2_2_115200 }, 4790 + /* 4791 + * Brainboxes UC-235/246 4792 + */ 4793 + { PCI_VENDOR_ID_INTASHIELD, 0x0AA1, 4794 + PCI_ANY_ID, PCI_ANY_ID, 4795 + 0, 0, 4796 + pbn_b2_1_115200 }, 4797 + /* 4798 + * Brainboxes UC-257 4799 + */ 4800 + { PCI_VENDOR_ID_INTASHIELD, 0x0861, 4801 + PCI_ANY_ID, PCI_ANY_ID, 4802 + 0, 0, 4803 + pbn_b2_2_115200 }, 4804 + /* 4805 + * Brainboxes UC-260/271/701/756 4784 4806 */ 4785 4807 { PCI_VENDOR_ID_INTASHIELD, 0x0D21, 4786 4808 PCI_ANY_ID, PCI_ANY_ID, ··· 4810 4788 pbn_b2_4_115200 }, 4811 4789 { PCI_VENDOR_ID_INTASHIELD, 0x0E34, 4812 4790 PCI_ANY_ID, PCI_ANY_ID, 4813 - PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00, 4791 + PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00, 4792 + pbn_b2_4_115200 }, 4793 + /* 4794 + * Brainboxes UC-268 4795 + */ 4796 + { PCI_VENDOR_ID_INTASHIELD, 0x0841, 4797 + PCI_ANY_ID, PCI_ANY_ID, 4798 + 0, 0, 4799 + pbn_b2_4_115200 }, 4800 + /* 4801 + * Brainboxes UC-275/279 4802 + */ 4803 + { PCI_VENDOR_ID_INTASHIELD, 0x0881, 4804 + PCI_ANY_ID, PCI_ANY_ID, 4805 + 0, 0, 4806 + pbn_b2_8_115200 }, 4807 + /* 4808 + * Brainboxes UC-302 4809 + */ 4810 + { PCI_VENDOR_ID_INTASHIELD, 0x08E1, 4811 + PCI_ANY_ID, PCI_ANY_ID, 4812 + 0, 0, 4813 + pbn_b2_2_115200 }, 4814 + /* 4815 + * Brainboxes UC-310 4816 + */ 4817 + { PCI_VENDOR_ID_INTASHIELD, 0x08C1, 4818 + PCI_ANY_ID, PCI_ANY_ID, 4819 + 0, 0, 4820 + pbn_b2_2_115200 }, 4821 + /* 4822 + * Brainboxes UC-313 4823 + */ 4824 + { PCI_VENDOR_ID_INTASHIELD, 0x08A3, 4825 + PCI_ANY_ID, PCI_ANY_ID, 4826 + 0, 0, 4827 + pbn_b2_2_115200 }, 4828 + /* 4829 + * Brainboxes UC-320/324 4830 + */ 4831 + { PCI_VENDOR_ID_INTASHIELD, 0x0A61, 4832 + PCI_ANY_ID, PCI_ANY_ID, 4833 + 0, 0, 4834 + pbn_b2_1_115200 }, 4835 + /* 4836 + * Brainboxes UC-346 4837 + */ 4838 + { PCI_VENDOR_ID_INTASHIELD, 0x0B02, 4839 + PCI_ANY_ID, PCI_ANY_ID, 4840 + 0, 0, 4841 + pbn_b2_4_115200 }, 4842 + /* 4843 + * Brainboxes UC-357 4844 + */ 4845 + { PCI_VENDOR_ID_INTASHIELD, 0x0A81, 4846 + PCI_ANY_ID, PCI_ANY_ID, 4847 + 0, 0, 4848 + pbn_b2_2_115200 }, 4849 + { PCI_VENDOR_ID_INTASHIELD, 0x0A83, 4850 + PCI_ANY_ID, PCI_ANY_ID, 4851 + 0, 0, 4852 + pbn_b2_2_115200 }, 4853 + /* 4854 + * Brainboxes UC-368 4855 + */ 4856 + { PCI_VENDOR_ID_INTASHIELD, 0x0C41, 4857 + PCI_ANY_ID, PCI_ANY_ID, 4858 + 0, 0, 4859 + pbn_b2_4_115200 }, 4860 + /* 4861 + * Brainboxes UC-420/431 4862 + */ 4863 + { PCI_VENDOR_ID_INTASHIELD, 0x0921, 4864 + PCI_ANY_ID, PCI_ANY_ID, 4865 + 0, 0, 4814 4866 pbn_b2_4_115200 }, 4815 4867 /* 4816 4868 * Perle PCI-RAS cards
+6 -55
drivers/tty/serial/8250/8250_port.c
··· 2056 2056 serial8250_rpm_put(up); 2057 2057 } 2058 2058 2059 - static void wait_for_lsr(struct uart_8250_port *up, int bits) 2059 + /* 2060 + * Wait for transmitter & holding register to empty 2061 + */ 2062 + static void wait_for_xmitr(struct uart_8250_port *up, int bits) 2060 2063 { 2061 2064 unsigned int status, tmout = 10000; 2062 2065 ··· 2076 2073 udelay(1); 2077 2074 touch_nmi_watchdog(); 2078 2075 } 2079 - } 2080 - 2081 - /* 2082 - * Wait for transmitter & holding register to empty 2083 - */ 2084 - static void wait_for_xmitr(struct uart_8250_port *up, int bits) 2085 - { 2086 - unsigned int tmout; 2087 - 2088 - wait_for_lsr(up, bits); 2089 2076 2090 2077 /* Wait up to 1s for flow control if necessary */ 2091 2078 if (up->port.flags & UPF_CONS_FLOW) { ··· 3326 3333 } 3327 3334 3328 3335 /* 3329 - * Print a string to the serial port using the device FIFO 3330 - * 3331 - * It sends fifosize bytes and then waits for the fifo 3332 - * to get empty. 3333 - */ 3334 - static void serial8250_console_fifo_write(struct uart_8250_port *up, 3335 - const char *s, unsigned int count) 3336 - { 3337 - int i; 3338 - const char *end = s + count; 3339 - unsigned int fifosize = up->port.fifosize; 3340 - bool cr_sent = false; 3341 - 3342 - while (s != end) { 3343 - wait_for_lsr(up, UART_LSR_THRE); 3344 - 3345 - for (i = 0; i < fifosize && s != end; ++i) { 3346 - if (*s == '\n' && !cr_sent) { 3347 - serial_out(up, UART_TX, '\r'); 3348 - cr_sent = true; 3349 - } else { 3350 - serial_out(up, UART_TX, *s++); 3351 - cr_sent = false; 3352 - } 3353 - } 3354 - } 3355 - } 3356 - 3357 - /* 3358 3336 * Print a string to the serial port trying not to disturb 3359 3337 * any possible real use of the port... 3360 3338 * ··· 3340 3376 struct uart_8250_em485 *em485 = up->em485; 3341 3377 struct uart_port *port = &up->port; 3342 3378 unsigned long flags; 3343 - unsigned int ier, use_fifo; 3379 + unsigned int ier; 3344 3380 int locked = 1; 3345 3381 3346 3382 touch_nmi_watchdog(); ··· 3372 3408 mdelay(port->rs485.delay_rts_before_send); 3373 3409 } 3374 3410 3375 - use_fifo = (up->capabilities & UART_CAP_FIFO) && 3376 - port->fifosize > 1 && 3377 - (serial_port_in(port, UART_FCR) & UART_FCR_ENABLE_FIFO) && 3378 - /* 3379 - * After we put a data in the fifo, the controller will send 3380 - * it regardless of the CTS state. Therefore, only use fifo 3381 - * if we don't use control flow. 3382 - */ 3383 - !(up->port.flags & UPF_CONS_FLOW); 3384 - 3385 - if (likely(use_fifo)) 3386 - serial8250_console_fifo_write(up, s, count); 3387 - else 3388 - uart_console_write(port, s, count, serial8250_console_putchar); 3411 + uart_console_write(port, s, count, serial8250_console_putchar); 3389 3412 3390 3413 /* 3391 3414 * Finally, wait for transmitter to become empty
+1 -10
drivers/tty/serial/amba-pl011.c
··· 1582 1582 container_of(port, struct uart_amba_port, port); 1583 1583 unsigned int cr; 1584 1584 1585 - if (port->rs485.flags & SER_RS485_ENABLED) 1586 - mctrl &= ~TIOCM_RTS; 1587 - 1588 1585 cr = pl011_read(uap, REG_CR); 1589 1586 1590 1587 #define TIOCMBIT(tiocmbit, uartbit) \ ··· 1805 1808 cr &= UART011_CR_RTS | UART011_CR_DTR; 1806 1809 cr |= UART01x_CR_UARTEN | UART011_CR_RXE; 1807 1810 1808 - if (port->rs485.flags & SER_RS485_ENABLED) { 1809 - if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) 1810 - cr &= ~UART011_CR_RTS; 1811 - else 1812 - cr |= UART011_CR_RTS; 1813 - } else { 1811 + if (!(port->rs485.flags & SER_RS485_ENABLED)) 1814 1812 cr |= UART011_CR_TXE; 1815 - } 1816 1813 1817 1814 pl011_write(cr, uap, REG_CR); 1818 1815
+12 -22
drivers/tty/serial/serial_core.c
··· 144 144 unsigned long flags; 145 145 unsigned int old; 146 146 147 + if (port->rs485.flags & SER_RS485_ENABLED) { 148 + set &= ~TIOCM_RTS; 149 + clear &= ~TIOCM_RTS; 150 + } 151 + 147 152 spin_lock_irqsave(&port->lock, flags); 148 153 old = port->mctrl; 149 154 port->mctrl = (old & ~clear) | set; ··· 162 157 163 158 static void uart_port_dtr_rts(struct uart_port *uport, int raise) 164 159 { 165 - int rs485_on = uport->rs485_config && 166 - (uport->rs485.flags & SER_RS485_ENABLED); 167 - int RTS_after_send = !!(uport->rs485.flags & SER_RS485_RTS_AFTER_SEND); 168 - 169 - if (raise) { 170 - if (rs485_on && RTS_after_send) { 171 - uart_set_mctrl(uport, TIOCM_DTR); 172 - uart_clear_mctrl(uport, TIOCM_RTS); 173 - } else { 174 - uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS); 175 - } 176 - } else { 177 - unsigned int clear = TIOCM_DTR; 178 - 179 - clear |= (!rs485_on || RTS_after_send) ? TIOCM_RTS : 0; 180 - uart_clear_mctrl(uport, clear); 181 - } 160 + if (raise) 161 + uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS); 162 + else 163 + uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS); 182 164 } 183 165 184 166 /* ··· 1067 1075 goto out; 1068 1076 1069 1077 if (!tty_io_error(tty)) { 1070 - if (uport->rs485.flags & SER_RS485_ENABLED) { 1071 - set &= ~TIOCM_RTS; 1072 - clear &= ~TIOCM_RTS; 1073 - } 1074 - 1075 1078 uart_update_mctrl(uport, set, clear); 1076 1079 ret = 0; 1077 1080 } ··· 2377 2390 */ 2378 2391 spin_lock_irqsave(&port->lock, flags); 2379 2392 port->mctrl &= TIOCM_DTR; 2393 + if (port->rs485.flags & SER_RS485_ENABLED && 2394 + !(port->rs485.flags & SER_RS485_RTS_AFTER_SEND)) 2395 + port->mctrl |= TIOCM_RTS; 2380 2396 port->ops->set_mctrl(port, port->mctrl); 2381 2397 spin_unlock_irqrestore(&port->lock, flags); 2382 2398
+13 -1
drivers/tty/serial/stm32-usart.c
··· 550 550 struct stm32_port *stm32_port = to_stm32_port(port); 551 551 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 552 552 struct circ_buf *xmit = &port->state->xmit; 553 + u32 isr; 554 + int ret; 553 555 554 556 if (port->x_char) { 555 557 if (stm32_usart_tx_dma_started(stm32_port) && 556 558 stm32_usart_tx_dma_enabled(stm32_port)) 557 559 stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 560 + 561 + /* Check that TDR is empty before filling FIFO */ 562 + ret = 563 + readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, 564 + isr, 565 + (isr & USART_SR_TXE), 566 + 10, 1000); 567 + if (ret) 568 + dev_warn(port->dev, "1 character may be erased\n"); 569 + 558 570 writel_relaxed(port->x_char, port->membase + ofs->tdr); 559 571 port->x_char = 0; 560 572 port->icount.tx++; ··· 742 730 struct serial_rs485 *rs485conf = &port->rs485; 743 731 struct circ_buf *xmit = &port->state->xmit; 744 732 745 - if (uart_circ_empty(xmit)) 733 + if (uart_circ_empty(xmit) && !port->x_char) 746 734 return; 747 735 748 736 if (rs485conf->flags & SER_RS485_ENABLED) {
+3 -3
drivers/usb/cdns3/drd.c
··· 483 483 /* Indicate the cdns3 core was power lost before */ 484 484 bool cdns_power_is_lost(struct cdns *cdns) 485 485 { 486 - if (cdns->version == CDNS3_CONTROLLER_V1) { 487 - if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0))) 486 + if (cdns->version == CDNS3_CONTROLLER_V0) { 487 + if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0))) 488 488 return true; 489 489 } else { 490 - if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0))) 490 + if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0))) 491 491 return true; 492 492 } 493 493 return false;
+5 -2
drivers/usb/common/ulpi.c
··· 39 39 struct ulpi *ulpi = to_ulpi_dev(dev); 40 40 const struct ulpi_device_id *id; 41 41 42 - /* Some ULPI devices don't have a vendor id so rely on OF match */ 43 - if (ulpi->id.vendor == 0) 42 + /* 43 + * Some ULPI devices don't have a vendor id 44 + * or provide an id_table so rely on OF match. 45 + */ 46 + if (ulpi->id.vendor == 0 || !drv->id_table) 44 47 return of_driver_match_device(dev, driver); 45 48 46 49 for (id = drv->id_table; id->vendor; id++)
+14
drivers/usb/core/hcd.c
··· 1563 1563 urb->hcpriv = NULL; 1564 1564 INIT_LIST_HEAD(&urb->urb_list); 1565 1565 atomic_dec(&urb->use_count); 1566 + /* 1567 + * Order the write of urb->use_count above before the read 1568 + * of urb->reject below. Pairs with the memory barriers in 1569 + * usb_kill_urb() and usb_poison_urb(). 1570 + */ 1571 + smp_mb__after_atomic(); 1572 + 1566 1573 atomic_dec(&urb->dev->urbnum); 1567 1574 if (atomic_read(&urb->reject)) 1568 1575 wake_up(&usb_kill_urb_queue); ··· 1672 1665 1673 1666 usb_anchor_resume_wakeups(anchor); 1674 1667 atomic_dec(&urb->use_count); 1668 + /* 1669 + * Order the write of urb->use_count above before the read 1670 + * of urb->reject below. Pairs with the memory barriers in 1671 + * usb_kill_urb() and usb_poison_urb(). 1672 + */ 1673 + smp_mb__after_atomic(); 1674 + 1675 1675 if (unlikely(atomic_read(&urb->reject))) 1676 1676 wake_up(&usb_kill_urb_queue); 1677 1677 usb_put_urb(urb);
+12
drivers/usb/core/urb.c
··· 715 715 if (!(urb && urb->dev && urb->ep)) 716 716 return; 717 717 atomic_inc(&urb->reject); 718 + /* 719 + * Order the write of urb->reject above before the read 720 + * of urb->use_count below. Pairs with the barriers in 721 + * __usb_hcd_giveback_urb() and usb_hcd_submit_urb(). 722 + */ 723 + smp_mb__after_atomic(); 718 724 719 725 usb_hcd_unlink_urb(urb, -ENOENT); 720 726 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); ··· 762 756 if (!urb) 763 757 return; 764 758 atomic_inc(&urb->reject); 759 + /* 760 + * Order the write of urb->reject above before the read 761 + * of urb->use_count below. Pairs with the barriers in 762 + * __usb_hcd_giveback_urb() and usb_hcd_submit_urb(). 763 + */ 764 + smp_mb__after_atomic(); 765 765 766 766 if (!urb->dev || !urb->ep) 767 767 return;
+1 -1
drivers/usb/dwc2/gadget.c
··· 5097 5097 hsotg->gadget.speed = USB_SPEED_UNKNOWN; 5098 5098 spin_unlock_irqrestore(&hsotg->lock, flags); 5099 5099 5100 - for (ep = 0; ep < hsotg->num_of_eps; ep++) { 5100 + for (ep = 1; ep < hsotg->num_of_eps; ep++) { 5101 5101 if (hsotg->eps_in[ep]) 5102 5102 dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); 5103 5103 if (hsotg->eps_out[ep])
+18 -5
drivers/usb/dwc3/dwc3-xilinx.c
··· 102 102 int ret; 103 103 u32 reg; 104 104 105 - usb3_phy = devm_phy_get(dev, "usb3-phy"); 106 - if (PTR_ERR(usb3_phy) == -EPROBE_DEFER) { 107 - ret = -EPROBE_DEFER; 105 + usb3_phy = devm_phy_optional_get(dev, "usb3-phy"); 106 + if (IS_ERR(usb3_phy)) { 107 + ret = PTR_ERR(usb3_phy); 108 + dev_err_probe(dev, ret, 109 + "failed to get USB3 PHY\n"); 108 110 goto err; 109 - } else if (IS_ERR(usb3_phy)) { 110 - usb3_phy = NULL; 111 111 } 112 + 113 + /* 114 + * The following core resets are not required unless a USB3 PHY 115 + * is used, and the subsequent register settings are not required 116 + * unless a core reset is performed (they should be set properly 117 + * by the first-stage boot loader, but may be reverted by a core 118 + * reset). They may also break the configuration if USB3 is actually 119 + * in use but the usb3-phy entry is missing from the device tree. 120 + * Therefore, skip these operations in this case. 121 + */ 122 + if (!usb3_phy) 123 + goto skip_usb3_phy; 112 124 113 125 crst = devm_reset_control_get_exclusive(dev, "usb_crst"); 114 126 if (IS_ERR(crst)) { ··· 200 188 goto err; 201 189 } 202 190 191 + skip_usb3_phy: 203 192 /* 204 193 * This routes the USB DMA traffic to go through FPD path instead 205 194 * of reaching DDR directly. This traffic routing is needed to
+1
drivers/usb/gadget/function/f_sourcesink.c
··· 584 584 585 585 if (is_iso) { 586 586 switch (speed) { 587 + case USB_SPEED_SUPER_PLUS: 587 588 case USB_SPEED_SUPER: 588 589 size = ss->isoc_maxpacket * 589 590 (ss->isoc_mult + 1) *
+1 -1
drivers/usb/gadget/udc/at91_udc.c
··· 1895 1895 at91_vbus_irq, 0, driver_name, udc); 1896 1896 if (retval) { 1897 1897 DBG("request vbus irq %d failed\n", 1898 - udc->board.vbus_pin); 1898 + desc_to_gpio(udc->board.vbus_pin)); 1899 1899 goto err_unprepare_iclk; 1900 1900 } 1901 1901 }
+3
drivers/usb/host/xhci-plat.c
··· 430 430 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 431 431 int ret; 432 432 433 + if (pm_runtime_suspended(dev)) 434 + pm_runtime_resume(dev); 435 + 433 436 ret = xhci_priv_suspend_quirk(hcd); 434 437 if (ret) 435 438 return ret;
+10
drivers/usb/storage/unusual_devs.h
··· 2301 2301 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, 2302 2302 US_FL_SCM_MULT_TARG ), 2303 2303 2304 + /* 2305 + * Reported by DocMAX <mail@vacharakis.de> 2306 + * and Thomas Weißschuh <linux@weissschuh.net> 2307 + */ 2308 + UNUSUAL_DEV( 0x2109, 0x0715, 0x9999, 0x9999, 2309 + "VIA Labs, Inc.", 2310 + "VL817 SATA Bridge", 2311 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2312 + US_FL_IGNORE_UAS), 2313 + 2304 2314 UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001, 2305 2315 "ST", 2306 2316 "2A",
+7 -1
drivers/usb/typec/port-mapper.c
··· 56 56 { 57 57 struct each_port_arg arg = { .port = con, .match = NULL }; 58 58 59 + if (!has_acpi_companion(&con->dev)) 60 + return 0; 61 + 59 62 bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match); 63 + if (!arg.match) 64 + return 0; 60 65 61 66 /* 62 67 * REVISIT: Now each connector can have only a single component master. ··· 79 74 80 75 void typec_unlink_ports(struct typec_port *con) 81 76 { 82 - component_master_del(&con->dev, &typec_aggregate_ops); 77 + if (has_acpi_companion(&con->dev)) 78 + component_master_del(&con->dev, &typec_aggregate_ops); 83 79 }
+26
drivers/usb/typec/tcpm/tcpci.c
··· 75 75 static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) 76 76 { 77 77 struct tcpci *tcpci = tcpc_to_tcpci(tcpc); 78 + bool vconn_pres; 79 + enum typec_cc_polarity polarity = TYPEC_POLARITY_CC1; 78 80 unsigned int reg; 79 81 int ret; 82 + 83 + ret = regmap_read(tcpci->regmap, TCPC_POWER_STATUS, &reg); 84 + if (ret < 0) 85 + return ret; 86 + 87 + vconn_pres = !!(reg & TCPC_POWER_STATUS_VCONN_PRES); 88 + if (vconn_pres) { 89 + ret = regmap_read(tcpci->regmap, TCPC_TCPC_CTRL, &reg); 90 + if (ret < 0) 91 + return ret; 92 + 93 + if (reg & TCPC_TCPC_CTRL_ORIENTATION) 94 + polarity = TYPEC_POLARITY_CC2; 95 + } 80 96 81 97 switch (cc) { 82 98 case TYPEC_CC_RA: ··· 126 110 reg = (TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT) | 127 111 (TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT); 128 112 break; 113 + } 114 + 115 + if (vconn_pres) { 116 + if (polarity == TYPEC_POLARITY_CC2) { 117 + reg &= ~(TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT); 118 + reg |= (TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT); 119 + } else { 120 + reg &= ~(TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT); 121 + reg |= (TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT); 122 + } 129 123 } 130 124 131 125 ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
+1
drivers/usb/typec/tcpm/tcpci.h
··· 98 98 #define TCPC_POWER_STATUS_SOURCING_VBUS BIT(4) 99 99 #define TCPC_POWER_STATUS_VBUS_DET BIT(3) 100 100 #define TCPC_POWER_STATUS_VBUS_PRES BIT(2) 101 + #define TCPC_POWER_STATUS_VCONN_PRES BIT(1) 101 102 #define TCPC_POWER_STATUS_SINKING_VBUS BIT(0) 102 103 103 104 #define TCPC_FAULT_STATUS 0x1f
+6 -1
drivers/usb/typec/tcpm/tcpm.c
··· 5156 5156 case SNK_TRYWAIT_DEBOUNCE: 5157 5157 break; 5158 5158 case SNK_ATTACH_WAIT: 5159 - tcpm_set_state(port, SNK_UNATTACHED, 0); 5159 + case SNK_DEBOUNCED: 5160 + /* Do nothing, as TCPM is still waiting for vbus to reaach VSAFE5V to connect */ 5160 5161 break; 5161 5162 5162 5163 case SNK_NEGOTIATE_CAPABILITIES: ··· 5263 5262 case PR_SWAP_SNK_SRC_SINK_OFF: 5264 5263 case PR_SWAP_SNK_SRC_SOURCE_ON: 5265 5264 /* Do nothing, vsafe0v is expected during transition */ 5265 + break; 5266 + case SNK_ATTACH_WAIT: 5267 + case SNK_DEBOUNCED: 5268 + /*Do nothing, still waiting for VSAFE5V for connect */ 5266 5269 break; 5267 5270 default: 5268 5271 if (port->pwr_role == TYPEC_SINK && port->auto_vbus_discharge_enabled)
+1 -1
drivers/usb/typec/ucsi/ucsi_ccg.c
··· 325 325 if (status < 0) 326 326 return status; 327 327 328 - if (!data) 328 + if (!(data & DEV_INT)) 329 329 return 0; 330 330 331 331 status = ccg_write(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));
+3 -13
drivers/video/fbdev/hyperv_fb.c
··· 287 287 288 288 static uint screen_width = HVFB_WIDTH; 289 289 static uint screen_height = HVFB_HEIGHT; 290 - static uint screen_width_max = HVFB_WIDTH; 291 - static uint screen_height_max = HVFB_HEIGHT; 292 290 static uint screen_depth; 293 291 static uint screen_fb_size; 294 292 static uint dio_fb_size; /* FB size for deferred IO */ ··· 580 582 int ret = 0; 581 583 unsigned long t; 582 584 u8 index; 583 - int i; 584 585 585 586 memset(msg, 0, sizeof(struct synthvid_msg)); 586 587 msg->vid_hdr.type = SYNTHVID_RESOLUTION_REQUEST; ··· 608 611 pr_err("Invalid resolution index: %d\n", index); 609 612 ret = -ENODEV; 610 613 goto out; 611 - } 612 - 613 - for (i = 0; i < msg->resolution_resp.resolution_count; i++) { 614 - screen_width_max = max_t(unsigned int, screen_width_max, 615 - msg->resolution_resp.supported_resolution[i].width); 616 - screen_height_max = max_t(unsigned int, screen_height_max, 617 - msg->resolution_resp.supported_resolution[i].height); 618 614 } 619 615 620 616 screen_width = ··· 931 941 932 942 if (x < HVFB_WIDTH_MIN || y < HVFB_HEIGHT_MIN || 933 943 (synthvid_ver_ge(par->synthvid_version, SYNTHVID_VERSION_WIN10) && 934 - (x > screen_width_max || y > screen_height_max)) || 944 + (x * y * screen_depth / 8 > screen_fb_size)) || 935 945 (par->synthvid_version == SYNTHVID_VERSION_WIN8 && 936 946 x * y * screen_depth / 8 > SYNTHVID_FB_SIZE_WIN8) || 937 947 (par->synthvid_version == SYNTHVID_VERSION_WIN7 && ··· 1184 1194 } 1185 1195 1186 1196 hvfb_get_option(info); 1187 - pr_info("Screen resolution: %dx%d, Color depth: %d\n", 1188 - screen_width, screen_height, screen_depth); 1197 + pr_info("Screen resolution: %dx%d, Color depth: %d, Frame buffer size: %d\n", 1198 + screen_width, screen_height, screen_depth, screen_fb_size); 1189 1199 1190 1200 ret = hvfb_getmem(hdev, info); 1191 1201 if (ret) {
+4 -4
fs/binfmt_misc.c
··· 817 817 }; 818 818 MODULE_ALIAS_FS("binfmt_misc"); 819 819 820 + static struct ctl_table_header *binfmt_misc_header; 821 + 820 822 static int __init init_misc_binfmt(void) 821 823 { 822 824 int err = register_filesystem(&bm_fs_type); 823 825 if (!err) 824 826 insert_binfmt(&misc_format); 825 - if (!register_sysctl_mount_point("fs/binfmt_misc")) { 826 - pr_warn("Failed to create fs/binfmt_misc sysctl mount point"); 827 - return -ENOMEM; 828 - } 827 + binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc"); 829 828 return 0; 830 829 } 831 830 832 831 static void __exit exit_misc_binfmt(void) 833 832 { 833 + unregister_sysctl_table(binfmt_misc_header); 834 834 unregister_binfmt(&misc_format); 835 835 unregister_filesystem(&bm_fs_type); 836 836 }
+77 -13
fs/btrfs/ioctl.c
··· 1214 1214 goto next; 1215 1215 1216 1216 /* 1217 + * Our start offset might be in the middle of an existing extent 1218 + * map, so take that into account. 1219 + */ 1220 + range_len = em->len - (cur - em->start); 1221 + /* 1222 + * If this range of the extent map is already flagged for delalloc, 1223 + * skip it, because: 1224 + * 1225 + * 1) We could deadlock later, when trying to reserve space for 1226 + * delalloc, because in case we can't immediately reserve space 1227 + * the flusher can start delalloc and wait for the respective 1228 + * ordered extents to complete. The deadlock would happen 1229 + * because we do the space reservation while holding the range 1230 + * locked, and starting writeback, or finishing an ordered 1231 + * extent, requires locking the range; 1232 + * 1233 + * 2) If there's delalloc there, it means there's dirty pages for 1234 + * which writeback has not started yet (we clean the delalloc 1235 + * flag when starting writeback and after creating an ordered 1236 + * extent). If we mark pages in an adjacent range for defrag, 1237 + * then we will have a larger contiguous range for delalloc, 1238 + * very likely resulting in a larger extent after writeback is 1239 + * triggered (except in a case of free space fragmentation). 1240 + */ 1241 + if (test_range_bit(&inode->io_tree, cur, cur + range_len - 1, 1242 + EXTENT_DELALLOC, 0, NULL)) 1243 + goto next; 1244 + 1245 + /* 1217 1246 * For do_compress case, we want to compress all valid file 1218 1247 * extents, thus no @extent_thresh or mergeable check. 1219 1248 */ ··· 1250 1221 goto add; 1251 1222 1252 1223 /* Skip too large extent */ 1253 - if (em->len >= extent_thresh) 1224 + if (range_len >= extent_thresh) 1254 1225 goto next; 1255 1226 1256 1227 next_mergeable = defrag_check_next_extent(&inode->vfs_inode, em, ··· 1471 1442 list_for_each_entry(entry, &target_list, list) { 1472 1443 u32 range_len = entry->len; 1473 1444 1474 - /* Reached the limit */ 1475 - if (max_sectors && max_sectors == *sectors_defragged) 1445 + /* Reached or beyond the limit */ 1446 + if (max_sectors && *sectors_defragged >= max_sectors) { 1447 + ret = 1; 1476 1448 break; 1449 + } 1477 1450 1478 1451 if (max_sectors) 1479 1452 range_len = min_t(u32, range_len, ··· 1496 1465 extent_thresh, newer_than, do_compress); 1497 1466 if (ret < 0) 1498 1467 break; 1499 - *sectors_defragged += range_len; 1468 + *sectors_defragged += range_len >> 1469 + inode->root->fs_info->sectorsize_bits; 1500 1470 } 1501 1471 out: 1502 1472 list_for_each_entry_safe(entry, tmp, &target_list, list) { ··· 1516 1484 * @newer_than: minimum transid to defrag 1517 1485 * @max_to_defrag: max number of sectors to be defragged, if 0, the whole inode 1518 1486 * will be defragged. 1487 + * 1488 + * Return <0 for error. 1489 + * Return >=0 for the number of sectors defragged, and range->start will be updated 1490 + * to indicate the file offset where next defrag should be started at. 1491 + * (Mostly for autodefrag, which sets @max_to_defrag thus we may exit early without 1492 + * defragging all the range). 1519 1493 */ 1520 1494 int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra, 1521 1495 struct btrfs_ioctl_defrag_range_args *range, ··· 1537 1499 int compress_type = BTRFS_COMPRESS_ZLIB; 1538 1500 int ret = 0; 1539 1501 u32 extent_thresh = range->extent_thresh; 1502 + pgoff_t start_index; 1540 1503 1541 1504 if (isize == 0) 1542 1505 return 0; ··· 1557 1518 1558 1519 if (range->start + range->len > range->start) { 1559 1520 /* Got a specific range */ 1560 - last_byte = min(isize, range->start + range->len) - 1; 1521 + last_byte = min(isize, range->start + range->len); 1561 1522 } else { 1562 1523 /* Defrag until file end */ 1563 - last_byte = isize - 1; 1524 + last_byte = isize; 1564 1525 } 1526 + 1527 + /* Align the range */ 1528 + cur = round_down(range->start, fs_info->sectorsize); 1529 + last_byte = round_up(last_byte, fs_info->sectorsize) - 1; 1565 1530 1566 1531 /* 1567 1532 * If we were not given a ra, allocate a readahead context. As ··· 1579 1536 file_ra_state_init(ra, inode->i_mapping); 1580 1537 } 1581 1538 1582 - /* Align the range */ 1583 - cur = round_down(range->start, fs_info->sectorsize); 1584 - last_byte = round_up(last_byte, fs_info->sectorsize) - 1; 1539 + /* 1540 + * Make writeback start from the beginning of the range, so that the 1541 + * defrag range can be written sequentially. 1542 + */ 1543 + start_index = cur >> PAGE_SHIFT; 1544 + if (start_index < inode->i_mapping->writeback_index) 1545 + inode->i_mapping->writeback_index = start_index; 1585 1546 1586 1547 while (cur < last_byte) { 1548 + const unsigned long prev_sectors_defragged = sectors_defragged; 1587 1549 u64 cluster_end; 1588 1550 1589 1551 /* The cluster size 256K should always be page aligned */ 1590 1552 BUILD_BUG_ON(!IS_ALIGNED(CLUSTER_SIZE, PAGE_SIZE)); 1553 + 1554 + if (btrfs_defrag_cancelled(fs_info)) { 1555 + ret = -EAGAIN; 1556 + break; 1557 + } 1591 1558 1592 1559 /* We want the cluster end at page boundary when possible */ 1593 1560 cluster_end = (((cur >> PAGE_SHIFT) + ··· 1620 1567 cluster_end + 1 - cur, extent_thresh, 1621 1568 newer_than, do_compress, 1622 1569 &sectors_defragged, max_to_defrag); 1570 + 1571 + if (sectors_defragged > prev_sectors_defragged) 1572 + balance_dirty_pages_ratelimited(inode->i_mapping); 1573 + 1623 1574 btrfs_inode_unlock(inode, 0); 1624 1575 if (ret < 0) 1625 1576 break; 1626 1577 cur = cluster_end + 1; 1578 + if (ret > 0) { 1579 + ret = 0; 1580 + break; 1581 + } 1627 1582 } 1628 1583 1629 1584 if (ra_allocated) 1630 1585 kfree(ra); 1586 + /* 1587 + * Update range.start for autodefrag, this will indicate where to start 1588 + * in next run. 1589 + */ 1590 + range->start = cur; 1631 1591 if (sectors_defragged) { 1632 1592 /* 1633 1593 * We have defragged some sectors, for compression case they ··· 3152 3086 btrfs_inode_lock(inode, 0); 3153 3087 err = btrfs_delete_subvolume(dir, dentry); 3154 3088 btrfs_inode_unlock(inode, 0); 3155 - if (!err) { 3156 - fsnotify_rmdir(dir, dentry); 3157 - d_delete(dentry); 3158 - } 3089 + if (!err) 3090 + d_delete_notify(dir, dentry); 3159 3091 3160 3092 out_dput: 3161 3093 dput(dentry);
+37 -18
fs/ceph/caps.c
··· 2218 2218 struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; 2219 2219 struct ceph_inode_info *ci = ceph_inode(inode); 2220 2220 struct ceph_mds_request *req1 = NULL, *req2 = NULL; 2221 + unsigned int max_sessions; 2221 2222 int ret, err = 0; 2222 2223 2223 2224 spin_lock(&ci->i_unsafe_lock); ··· 2237 2236 spin_unlock(&ci->i_unsafe_lock); 2238 2237 2239 2238 /* 2239 + * The mdsc->max_sessions is unlikely to be changed 2240 + * mostly, here we will retry it by reallocating the 2241 + * sessions array memory to get rid of the mdsc->mutex 2242 + * lock. 2243 + */ 2244 + retry: 2245 + max_sessions = mdsc->max_sessions; 2246 + 2247 + /* 2240 2248 * Trigger to flush the journal logs in all the relevant MDSes 2241 2249 * manually, or in the worst case we must wait at most 5 seconds 2242 2250 * to wait the journal logs to be flushed by the MDSes periodically. 2243 2251 */ 2244 - if (req1 || req2) { 2252 + if ((req1 || req2) && likely(max_sessions)) { 2245 2253 struct ceph_mds_session **sessions = NULL; 2246 2254 struct ceph_mds_session *s; 2247 2255 struct ceph_mds_request *req; 2248 - unsigned int max; 2249 2256 int i; 2250 2257 2251 - /* 2252 - * The mdsc->max_sessions is unlikely to be changed 2253 - * mostly, here we will retry it by reallocating the 2254 - * sessions arrary memory to get rid of the mdsc->mutex 2255 - * lock. 2256 - */ 2257 - retry: 2258 - max = mdsc->max_sessions; 2259 - sessions = krealloc(sessions, max * sizeof(s), __GFP_ZERO); 2260 - if (!sessions) 2261 - return -ENOMEM; 2258 + sessions = kzalloc(max_sessions * sizeof(s), GFP_KERNEL); 2259 + if (!sessions) { 2260 + err = -ENOMEM; 2261 + goto out; 2262 + } 2262 2263 2263 2264 spin_lock(&ci->i_unsafe_lock); 2264 2265 if (req1) { 2265 2266 list_for_each_entry(req, &ci->i_unsafe_dirops, 2266 2267 r_unsafe_dir_item) { 2267 2268 s = req->r_session; 2268 - if (unlikely(s->s_mds >= max)) { 2269 + if (unlikely(s->s_mds >= max_sessions)) { 2269 2270 spin_unlock(&ci->i_unsafe_lock); 2271 + for (i = 0; i < max_sessions; i++) { 2272 + s = sessions[i]; 2273 + if (s) 2274 + ceph_put_mds_session(s); 2275 + } 2276 + kfree(sessions); 2270 2277 goto retry; 2271 2278 } 2272 2279 if (!sessions[s->s_mds]) { ··· 2287 2278 list_for_each_entry(req, &ci->i_unsafe_iops, 2288 2279 r_unsafe_target_item) { 2289 2280 s = req->r_session; 2290 - if (unlikely(s->s_mds >= max)) { 2281 + if (unlikely(s->s_mds >= max_sessions)) { 2291 2282 spin_unlock(&ci->i_unsafe_lock); 2283 + for (i = 0; i < max_sessions; i++) { 2284 + s = sessions[i]; 2285 + if (s) 2286 + ceph_put_mds_session(s); 2287 + } 2288 + kfree(sessions); 2292 2289 goto retry; 2293 2290 } 2294 2291 if (!sessions[s->s_mds]) { ··· 2315 2300 spin_unlock(&ci->i_ceph_lock); 2316 2301 2317 2302 /* send flush mdlog request to MDSes */ 2318 - for (i = 0; i < max; i++) { 2303 + for (i = 0; i < max_sessions; i++) { 2319 2304 s = sessions[i]; 2320 2305 if (s) { 2321 2306 send_flush_mdlog(s); ··· 2332 2317 ceph_timeout_jiffies(req1->r_timeout)); 2333 2318 if (ret) 2334 2319 err = -EIO; 2335 - ceph_mdsc_put_request(req1); 2336 2320 } 2337 2321 if (req2) { 2338 2322 ret = !wait_for_completion_timeout(&req2->r_safe_completion, 2339 2323 ceph_timeout_jiffies(req2->r_timeout)); 2340 2324 if (ret) 2341 2325 err = -EIO; 2342 - ceph_mdsc_put_request(req2); 2343 2326 } 2327 + 2328 + out: 2329 + if (req1) 2330 + ceph_mdsc_put_request(req1); 2331 + if (req2) 2332 + ceph_mdsc_put_request(req2); 2344 2333 return err; 2345 2334 } 2346 2335
+9
fs/ceph/file.c
··· 583 583 struct ceph_inode_info *ci = ceph_inode(dir); 584 584 struct inode *inode; 585 585 struct timespec64 now; 586 + struct ceph_string *pool_ns; 586 587 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb); 587 588 struct ceph_vino vino = { .ino = req->r_deleg_ino, 588 589 .snap = CEPH_NOSNAP }; ··· 633 632 in.max_size = cpu_to_le64(lo->stripe_unit); 634 633 635 634 ceph_file_layout_to_legacy(lo, &in.layout); 635 + /* lo is private, so pool_ns can't change */ 636 + pool_ns = rcu_dereference_raw(lo->pool_ns); 637 + if (pool_ns) { 638 + iinfo.pool_ns_len = pool_ns->len; 639 + iinfo.pool_ns_data = pool_ns->str; 640 + } 636 641 637 642 down_read(&mdsc->snap_rwsem); 638 643 ret = ceph_fill_inode(inode, NULL, &iinfo, NULL, req->r_session, ··· 757 750 restore_deleg_ino(dir, req->r_deleg_ino); 758 751 ceph_mdsc_put_request(req); 759 752 try_async = false; 753 + ceph_put_string(rcu_dereference_raw(lo.pool_ns)); 760 754 goto retry; 761 755 } 756 + ceph_put_string(rcu_dereference_raw(lo.pool_ns)); 762 757 goto out_req; 763 758 } 764 759 }
+3 -3
fs/configfs/dir.c
··· 1780 1780 configfs_detach_group(&group->cg_item); 1781 1781 d_inode(dentry)->i_flags |= S_DEAD; 1782 1782 dont_mount(dentry); 1783 + d_drop(dentry); 1783 1784 fsnotify_rmdir(d_inode(parent), dentry); 1784 - d_delete(dentry); 1785 1785 inode_unlock(d_inode(parent)); 1786 1786 1787 1787 dput(dentry); ··· 1922 1922 configfs_detach_group(&group->cg_item); 1923 1923 d_inode(dentry)->i_flags |= S_DEAD; 1924 1924 dont_mount(dentry); 1925 - fsnotify_rmdir(d_inode(root), dentry); 1926 1925 inode_unlock(d_inode(dentry)); 1927 1926 1928 - d_delete(dentry); 1927 + d_drop(dentry); 1928 + fsnotify_rmdir(d_inode(root), dentry); 1929 1929 1930 1930 inode_unlock(d_inode(root)); 1931 1931
+1 -1
fs/devpts/inode.c
··· 621 621 622 622 dentry->d_fsdata = NULL; 623 623 drop_nlink(dentry->d_inode); 624 - fsnotify_unlink(d_inode(dentry->d_parent), dentry); 625 624 d_drop(dentry); 625 + fsnotify_unlink(d_inode(dentry->d_parent), dentry); 626 626 dput(dentry); /* d_alloc_name() in devpts_pty_new() */ 627 627 } 628 628
+8 -3
fs/io_uring.c
··· 7822 7822 struct io_ring_ctx *ctx = node->rsrc_data->ctx; 7823 7823 unsigned long flags; 7824 7824 bool first_add = false; 7825 + unsigned long delay = HZ; 7825 7826 7826 7827 spin_lock_irqsave(&ctx->rsrc_ref_lock, flags); 7827 7828 node->done = true; 7829 + 7830 + /* if we are mid-quiesce then do not delay */ 7831 + if (node->rsrc_data->quiesce) 7832 + delay = 0; 7828 7833 7829 7834 while (!list_empty(&ctx->rsrc_ref_list)) { 7830 7835 node = list_first_entry(&ctx->rsrc_ref_list, ··· 7843 7838 spin_unlock_irqrestore(&ctx->rsrc_ref_lock, flags); 7844 7839 7845 7840 if (first_add) 7846 - mod_delayed_work(system_wq, &ctx->rsrc_put_work, HZ); 7841 + mod_delayed_work(system_wq, &ctx->rsrc_put_work, delay); 7847 7842 } 7848 7843 7849 - static struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx) 7844 + static struct io_rsrc_node *io_rsrc_node_alloc(void) 7850 7845 { 7851 7846 struct io_rsrc_node *ref_node; 7852 7847 ··· 7897 7892 { 7898 7893 if (ctx->rsrc_backup_node) 7899 7894 return 0; 7900 - ctx->rsrc_backup_node = io_rsrc_node_alloc(ctx); 7895 + ctx->rsrc_backup_node = io_rsrc_node_alloc(); 7901 7896 return ctx->rsrc_backup_node ? 0 : -ENOMEM; 7902 7897 } 7903 7898
+2
fs/jbd2/journal.c
··· 2972 2972 jbd_unlock_bh_journal_head(bh); 2973 2973 return jh; 2974 2974 } 2975 + EXPORT_SYMBOL(jbd2_journal_grab_journal_head); 2975 2976 2976 2977 static void __journal_remove_journal_head(struct buffer_head *bh) 2977 2978 { ··· 3025 3024 jbd_unlock_bh_journal_head(bh); 3026 3025 } 3027 3026 } 3027 + EXPORT_SYMBOL(jbd2_journal_put_journal_head); 3028 3028 3029 3029 /* 3030 3030 * Initialize jbd inode head
+5 -5
fs/namei.c
··· 4024 4024 dentry->d_inode->i_flags |= S_DEAD; 4025 4025 dont_mount(dentry); 4026 4026 detach_mounts(dentry); 4027 - fsnotify_rmdir(dir, dentry); 4028 4027 4029 4028 out: 4030 4029 inode_unlock(dentry->d_inode); 4031 4030 dput(dentry); 4032 4031 if (!error) 4033 - d_delete(dentry); 4032 + d_delete_notify(dir, dentry); 4034 4033 return error; 4035 4034 } 4036 4035 EXPORT_SYMBOL(vfs_rmdir); ··· 4151 4152 if (!error) { 4152 4153 dont_mount(dentry); 4153 4154 detach_mounts(dentry); 4154 - fsnotify_unlink(dir, dentry); 4155 4155 } 4156 4156 } 4157 4157 } ··· 4158 4160 inode_unlock(target); 4159 4161 4160 4162 /* We don't d_delete() NFS sillyrenamed files--they still exist. */ 4161 - if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) { 4163 + if (!error && dentry->d_flags & DCACHE_NFSFS_RENAMED) { 4164 + fsnotify_unlink(dir, dentry); 4165 + } else if (!error) { 4162 4166 fsnotify_link_count(target); 4163 - d_delete(dentry); 4167 + d_delete_notify(dir, dentry); 4164 4168 } 4165 4169 4166 4170 return error;
+1 -1
fs/nfs/callback.h
··· 170 170 }; 171 171 172 172 struct cb_devicenotifyargs { 173 - int ndevs; 173 + uint32_t ndevs; 174 174 struct cb_devicenotifyitem *devs; 175 175 }; 176 176
+1 -1
fs/nfs/callback_proc.c
··· 358 358 struct cb_process_state *cps) 359 359 { 360 360 struct cb_devicenotifyargs *args = argp; 361 - int i; 361 + uint32_t i; 362 362 __be32 res = 0; 363 363 struct nfs_client *clp = cps->clp; 364 364 struct nfs_server *server = NULL;
+9 -9
fs/nfs/callback_xdr.c
··· 258 258 void *argp) 259 259 { 260 260 struct cb_devicenotifyargs *args = argp; 261 + uint32_t tmp, n, i; 261 262 __be32 *p; 262 263 __be32 status = 0; 263 - u32 tmp; 264 - int n, i; 265 - args->ndevs = 0; 266 264 267 265 /* Num of device notifications */ 268 266 p = xdr_inline_decode(xdr, sizeof(uint32_t)); ··· 269 271 goto out; 270 272 } 271 273 n = ntohl(*p++); 272 - if (n <= 0) 274 + if (n == 0) 273 275 goto out; 274 276 if (n > ULONG_MAX / sizeof(*args->devs)) { 275 277 status = htonl(NFS4ERR_BADXDR); ··· 328 330 dev->cbd_immediate = 0; 329 331 } 330 332 331 - args->ndevs++; 332 - 333 333 dprintk("%s: type %d layout 0x%x immediate %d\n", 334 334 __func__, dev->cbd_notify_type, dev->cbd_layout_type, 335 335 dev->cbd_immediate); 336 336 } 337 + args->ndevs = n; 338 + dprintk("%s: ndevs %d\n", __func__, args->ndevs); 339 + return 0; 340 + err: 341 + kfree(args->devs); 337 342 out: 343 + args->devs = NULL; 344 + args->ndevs = 0; 338 345 dprintk("%s: status %d ndevs %d\n", 339 346 __func__, ntohl(status), args->ndevs); 340 347 return status; 341 - err: 342 - kfree(args->devs); 343 - goto out; 344 348 } 345 349 346 350 static __be32 decode_sessionid(struct xdr_stream *xdr,
+7
fs/nfs/client.c
··· 856 856 server->namelen = pathinfo.max_namelen; 857 857 } 858 858 859 + if (clp->rpc_ops->discover_trunking != NULL && 860 + (server->caps & NFS_CAP_FS_LOCATIONS)) { 861 + error = clp->rpc_ops->discover_trunking(server, mntfh); 862 + if (error < 0) 863 + return error; 864 + } 865 + 859 866 return 0; 860 867 } 861 868
+118 -28
fs/nfs/dir.c
··· 1325 1325 EXPORT_SYMBOL_GPL(nfs_clear_verifier_delegated); 1326 1326 #endif /* IS_ENABLED(CONFIG_NFS_V4) */ 1327 1327 1328 + static int nfs_dentry_verify_change(struct inode *dir, struct dentry *dentry) 1329 + { 1330 + if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE) && 1331 + d_really_is_negative(dentry)) 1332 + return dentry->d_time == inode_peek_iversion_raw(dir); 1333 + return nfs_verify_change_attribute(dir, dentry->d_time); 1334 + } 1335 + 1328 1336 /* 1329 1337 * A check for whether or not the parent directory has changed. 1330 1338 * In the case it has, we assume that the dentries are untrustworthy ··· 1346 1338 return 1; 1347 1339 if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONE) 1348 1340 return 0; 1349 - if (!nfs_verify_change_attribute(dir, dentry->d_time)) 1341 + if (!nfs_dentry_verify_change(dir, dentry)) 1350 1342 return 0; 1351 1343 /* Revalidate nfsi->cache_change_attribute before we declare a match */ 1352 1344 if (nfs_mapping_need_revalidate_inode(dir)) { ··· 1355 1347 if (__nfs_revalidate_inode(NFS_SERVER(dir), dir) < 0) 1356 1348 return 0; 1357 1349 } 1358 - if (!nfs_verify_change_attribute(dir, dentry->d_time)) 1350 + if (!nfs_dentry_verify_change(dir, dentry)) 1359 1351 return 0; 1360 1352 return 1; 1361 1353 } ··· 1444 1436 if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET)) 1445 1437 return 0; 1446 1438 if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) 1439 + return 1; 1440 + /* Case insensitive server? Revalidate negative dentries */ 1441 + if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE)) 1447 1442 return 1; 1448 1443 return !nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU); 1449 1444 } ··· 1548 1537 * If the lookup failed despite the dentry change attribute being 1549 1538 * a match, then we should revalidate the directory cache. 1550 1539 */ 1551 - if (!ret && nfs_verify_change_attribute(dir, dentry->d_time)) 1540 + if (!ret && nfs_dentry_verify_change(dir, dentry)) 1552 1541 nfs_mark_dir_for_revalidate(dir); 1553 1542 return nfs_lookup_revalidate_done(dir, dentry, inode, ret); 1554 1543 } ··· 1787 1776 dir_verifier = nfs_save_change_attribute(dir); 1788 1777 trace_nfs_lookup_enter(dir, dentry, flags); 1789 1778 error = NFS_PROTO(dir)->lookup(dir, dentry, fhandle, fattr); 1790 - if (error == -ENOENT) 1779 + if (error == -ENOENT) { 1780 + if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE)) 1781 + dir_verifier = inode_peek_iversion_raw(dir); 1791 1782 goto no_entry; 1783 + } 1792 1784 if (error < 0) { 1793 1785 res = ERR_PTR(error); 1794 1786 goto out; ··· 1819 1805 return res; 1820 1806 } 1821 1807 EXPORT_SYMBOL_GPL(nfs_lookup); 1808 + 1809 + void nfs_d_prune_case_insensitive_aliases(struct inode *inode) 1810 + { 1811 + /* Case insensitive server? Revalidate dentries */ 1812 + if (inode && nfs_server_capable(inode, NFS_CAP_CASE_INSENSITIVE)) 1813 + d_prune_aliases(inode); 1814 + } 1815 + EXPORT_SYMBOL_GPL(nfs_d_prune_case_insensitive_aliases); 1822 1816 1823 1817 #if IS_ENABLED(CONFIG_NFS_V4) 1824 1818 static int nfs4_lookup_revalidate(struct dentry *, unsigned int); ··· 1889 1867 struct iattr attr = { .ia_valid = ATTR_OPEN }; 1890 1868 struct inode *inode; 1891 1869 unsigned int lookup_flags = 0; 1870 + unsigned long dir_verifier; 1892 1871 bool switched = false; 1893 1872 int created = 0; 1894 1873 int err; ··· 1963 1940 switch (err) { 1964 1941 case -ENOENT: 1965 1942 d_splice_alias(NULL, dentry); 1966 - nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1943 + if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE)) 1944 + dir_verifier = inode_peek_iversion_raw(dir); 1945 + else 1946 + dir_verifier = nfs_save_change_attribute(dir); 1947 + nfs_set_verifier(dentry, dir_verifier); 1967 1948 break; 1968 1949 case -EISDIR: 1969 1950 case -ENOTDIR: ··· 1995 1968 1996 1969 no_open: 1997 1970 res = nfs_lookup(dir, dentry, lookup_flags); 1971 + if (!res) { 1972 + inode = d_inode(dentry); 1973 + if ((lookup_flags & LOOKUP_DIRECTORY) && inode && 1974 + !S_ISDIR(inode->i_mode)) 1975 + res = ERR_PTR(-ENOTDIR); 1976 + else if (inode && S_ISREG(inode->i_mode)) 1977 + res = ERR_PTR(-EOPENSTALE); 1978 + } else if (!IS_ERR(res)) { 1979 + inode = d_inode(res); 1980 + if ((lookup_flags & LOOKUP_DIRECTORY) && inode && 1981 + !S_ISDIR(inode->i_mode)) { 1982 + dput(res); 1983 + res = ERR_PTR(-ENOTDIR); 1984 + } else if (inode && S_ISREG(inode->i_mode)) { 1985 + dput(res); 1986 + res = ERR_PTR(-EOPENSTALE); 1987 + } 1988 + } 1998 1989 if (switched) { 1999 1990 d_lookup_done(dentry); 2000 1991 if (!res) ··· 2231 2186 switch (error) { 2232 2187 case -ENOENT: 2233 2188 d_delete(dentry); 2234 - fallthrough; 2189 + nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 2190 + break; 2235 2191 case 0: 2192 + nfs_d_prune_case_insensitive_aliases(d_inode(dentry)); 2236 2193 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 2237 2194 } 2238 2195 } ··· 2427 2380 2428 2381 trace_nfs_link_enter(inode, dir, dentry); 2429 2382 d_drop(dentry); 2383 + if (S_ISREG(inode->i_mode)) 2384 + nfs_sync_inode(inode); 2430 2385 error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); 2431 2386 if (error == 0) { 2432 2387 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); ··· 2518 2469 } 2519 2470 } 2520 2471 2472 + if (S_ISREG(old_inode->i_mode)) 2473 + nfs_sync_inode(old_inode); 2521 2474 task = nfs_async_rename(old_dir, new_dir, old_dentry, new_dentry, NULL); 2522 2475 if (IS_ERR(task)) { 2523 2476 error = PTR_ERR(task); ··· 2580 2529 2581 2530 static void nfs_access_free_entry(struct nfs_access_entry *entry) 2582 2531 { 2583 - put_cred(entry->cred); 2532 + put_group_info(entry->group_info); 2584 2533 kfree_rcu(entry, rcu_head); 2585 2534 smp_mb__before_atomic(); 2586 2535 atomic_long_dec(&nfs_access_nr_entries); ··· 2706 2655 } 2707 2656 EXPORT_SYMBOL_GPL(nfs_access_zap_cache); 2708 2657 2658 + static int access_cmp(const struct cred *a, const struct nfs_access_entry *b) 2659 + { 2660 + struct group_info *ga, *gb; 2661 + int g; 2662 + 2663 + if (uid_lt(a->fsuid, b->fsuid)) 2664 + return -1; 2665 + if (uid_gt(a->fsuid, b->fsuid)) 2666 + return 1; 2667 + 2668 + if (gid_lt(a->fsgid, b->fsgid)) 2669 + return -1; 2670 + if (gid_gt(a->fsgid, b->fsgid)) 2671 + return 1; 2672 + 2673 + ga = a->group_info; 2674 + gb = b->group_info; 2675 + if (ga == gb) 2676 + return 0; 2677 + if (ga == NULL) 2678 + return -1; 2679 + if (gb == NULL) 2680 + return 1; 2681 + if (ga->ngroups < gb->ngroups) 2682 + return -1; 2683 + if (ga->ngroups > gb->ngroups) 2684 + return 1; 2685 + 2686 + for (g = 0; g < ga->ngroups; g++) { 2687 + if (gid_lt(ga->gid[g], gb->gid[g])) 2688 + return -1; 2689 + if (gid_gt(ga->gid[g], gb->gid[g])) 2690 + return 1; 2691 + } 2692 + return 0; 2693 + } 2694 + 2709 2695 static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, const struct cred *cred) 2710 2696 { 2711 2697 struct rb_node *n = NFS_I(inode)->access_cache.rb_node; ··· 2750 2662 while (n != NULL) { 2751 2663 struct nfs_access_entry *entry = 2752 2664 rb_entry(n, struct nfs_access_entry, rb_node); 2753 - int cmp = cred_fscmp(cred, entry->cred); 2665 + int cmp = access_cmp(cred, entry); 2754 2666 2755 2667 if (cmp < 0) 2756 2668 n = n->rb_left; ··· 2762 2674 return NULL; 2763 2675 } 2764 2676 2765 - static int nfs_access_get_cached_locked(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res, bool may_block) 2677 + static int nfs_access_get_cached_locked(struct inode *inode, const struct cred *cred, u32 *mask, bool may_block) 2766 2678 { 2767 2679 struct nfs_inode *nfsi = NFS_I(inode); 2768 2680 struct nfs_access_entry *cache; ··· 2792 2704 spin_lock(&inode->i_lock); 2793 2705 retry = false; 2794 2706 } 2795 - res->cred = cache->cred; 2796 - res->mask = cache->mask; 2707 + *mask = cache->mask; 2797 2708 list_move_tail(&cache->lru, &nfsi->access_cache_entry_lru); 2798 2709 err = 0; 2799 2710 out: ··· 2804 2717 return -ENOENT; 2805 2718 } 2806 2719 2807 - static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res) 2720 + static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cred, u32 *mask) 2808 2721 { 2809 2722 /* Only check the most recently returned cache entry, 2810 2723 * but do it without locking. ··· 2820 2733 lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru)); 2821 2734 cache = list_entry(lh, struct nfs_access_entry, lru); 2822 2735 if (lh == &nfsi->access_cache_entry_lru || 2823 - cred_fscmp(cred, cache->cred) != 0) 2736 + access_cmp(cred, cache) != 0) 2824 2737 cache = NULL; 2825 2738 if (cache == NULL) 2826 2739 goto out; 2827 2740 if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS)) 2828 2741 goto out; 2829 - res->cred = cache->cred; 2830 - res->mask = cache->mask; 2742 + *mask = cache->mask; 2831 2743 err = 0; 2832 2744 out: 2833 2745 rcu_read_unlock(); 2834 2746 return err; 2835 2747 } 2836 2748 2837 - int nfs_access_get_cached(struct inode *inode, const struct cred *cred, struct 2838 - nfs_access_entry *res, bool may_block) 2749 + int nfs_access_get_cached(struct inode *inode, const struct cred *cred, 2750 + u32 *mask, bool may_block) 2839 2751 { 2840 2752 int status; 2841 2753 2842 - status = nfs_access_get_cached_rcu(inode, cred, res); 2754 + status = nfs_access_get_cached_rcu(inode, cred, mask); 2843 2755 if (status != 0) 2844 - status = nfs_access_get_cached_locked(inode, cred, res, 2756 + status = nfs_access_get_cached_locked(inode, cred, mask, 2845 2757 may_block); 2846 2758 2847 2759 return status; 2848 2760 } 2849 2761 EXPORT_SYMBOL_GPL(nfs_access_get_cached); 2850 2762 2851 - static void nfs_access_add_rbtree(struct inode *inode, struct nfs_access_entry *set) 2763 + static void nfs_access_add_rbtree(struct inode *inode, 2764 + struct nfs_access_entry *set, 2765 + const struct cred *cred) 2852 2766 { 2853 2767 struct nfs_inode *nfsi = NFS_I(inode); 2854 2768 struct rb_root *root_node = &nfsi->access_cache; ··· 2862 2774 while (*p != NULL) { 2863 2775 parent = *p; 2864 2776 entry = rb_entry(parent, struct nfs_access_entry, rb_node); 2865 - cmp = cred_fscmp(set->cred, entry->cred); 2777 + cmp = access_cmp(cred, entry); 2866 2778 2867 2779 if (cmp < 0) 2868 2780 p = &parent->rb_left; ··· 2884 2796 nfs_access_free_entry(entry); 2885 2797 } 2886 2798 2887 - void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set) 2799 + void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set, 2800 + const struct cred *cred) 2888 2801 { 2889 2802 struct nfs_access_entry *cache = kmalloc(sizeof(*cache), GFP_KERNEL); 2890 2803 if (cache == NULL) 2891 2804 return; 2892 2805 RB_CLEAR_NODE(&cache->rb_node); 2893 - cache->cred = get_cred(set->cred); 2806 + cache->fsuid = cred->fsuid; 2807 + cache->fsgid = cred->fsgid; 2808 + cache->group_info = get_group_info(cred->group_info); 2894 2809 cache->mask = set->mask; 2895 2810 2896 2811 /* The above field assignments must be visible ··· 2901 2810 * use rcu_assign_pointer, so just force the memory barrier. 2902 2811 */ 2903 2812 smp_wmb(); 2904 - nfs_access_add_rbtree(inode, cache); 2813 + nfs_access_add_rbtree(inode, cache, cred); 2905 2814 2906 2815 /* Update accounting */ 2907 2816 smp_mb__before_atomic(); ··· 2966 2875 2967 2876 trace_nfs_access_enter(inode); 2968 2877 2969 - status = nfs_access_get_cached(inode, cred, &cache, may_block); 2878 + status = nfs_access_get_cached(inode, cred, &cache.mask, may_block); 2970 2879 if (status == 0) 2971 2880 goto out_cached; 2972 2881 ··· 2986 2895 cache.mask |= NFS_ACCESS_DELETE | NFS_ACCESS_LOOKUP; 2987 2896 else 2988 2897 cache.mask |= NFS_ACCESS_EXECUTE; 2989 - cache.cred = cred; 2990 - status = NFS_PROTO(inode)->access(inode, &cache); 2898 + status = NFS_PROTO(inode)->access(inode, &cache, cred); 2991 2899 if (status != 0) { 2992 2900 if (status == -ESTALE) { 2993 2901 if (!S_ISDIR(inode->i_mode)) ··· 2996 2906 } 2997 2907 goto out; 2998 2908 } 2999 - nfs_access_add_cache(inode, &cache); 2909 + nfs_access_add_cache(inode, &cache, cred); 3000 2910 out_cached: 3001 2911 cache_mask = nfs_access_calc_mask(cache.mask, inode->i_mode); 3002 2912 if ((mask & ~cache_mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) != 0)
+1 -1
fs/nfs/filelayout/filelayout.h
··· 51 51 u32 stripe_count; 52 52 u8 *stripe_indices; 53 53 u32 ds_num; 54 - struct nfs4_pnfs_ds *ds_list[1]; 54 + struct nfs4_pnfs_ds *ds_list[]; 55 55 }; 56 56 57 57 struct nfs4_filelayout_segment {
+1 -3
fs/nfs/filelayout/filelayoutdev.c
··· 136 136 goto out_err_free_stripe_indices; 137 137 } 138 138 139 - dsaddr = kzalloc(sizeof(*dsaddr) + 140 - (sizeof(struct nfs4_pnfs_ds *) * (num - 1)), 141 - gfp_flags); 139 + dsaddr = kzalloc(struct_size(dsaddr, ds_list, num), gfp_flags); 142 140 if (!dsaddr) 143 141 goto out_err_free_stripe_indices; 144 142
+1
fs/nfs/internal.h
··· 373 373 extern unsigned long nfs_access_cache_scan(struct shrinker *shrink, 374 374 struct shrink_control *sc); 375 375 struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int); 376 + void nfs_d_prune_case_insensitive_aliases(struct inode *inode); 376 377 int nfs_create(struct user_namespace *, struct inode *, struct dentry *, 377 378 umode_t, bool); 378 379 int nfs_mkdir(struct user_namespace *, struct inode *, struct dentry *,
+3 -2
fs/nfs/nfs3proc.c
··· 220 220 task_flags); 221 221 } 222 222 223 - static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) 223 + static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry, 224 + const struct cred *cred) 224 225 { 225 226 struct nfs3_accessargs arg = { 226 227 .fh = NFS_FH(inode), ··· 232 231 .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS], 233 232 .rpc_argp = &arg, 234 233 .rpc_resp = &res, 235 - .rpc_cred = entry->cred, 234 + .rpc_cred = cred, 236 235 }; 237 236 int status = -ENOMEM; 238 237
+8 -5
fs/nfs/nfs42proc.c
··· 46 46 { 47 47 struct inode *inode = file_inode(filep); 48 48 struct nfs_server *server = NFS_SERVER(inode); 49 - u32 bitmask[3]; 49 + u32 bitmask[NFS_BITMASK_SZ]; 50 50 struct nfs42_falloc_args args = { 51 51 .falloc_fh = NFS_FH(inode), 52 52 .falloc_offset = offset, ··· 69 69 return status; 70 70 } 71 71 72 - memcpy(bitmask, server->cache_consistency_bitmask, sizeof(bitmask)); 73 - if (server->attr_bitmask[1] & FATTR4_WORD1_SPACE_USED) 74 - bitmask[1] |= FATTR4_WORD1_SPACE_USED; 72 + nfs4_bitmask_set(bitmask, server->cache_consistency_bitmask, inode, 73 + NFS_INO_INVALID_BLOCKS); 75 74 76 75 res.falloc_fattr = nfs_alloc_fattr(); 77 76 if (!res.falloc_fattr) ··· 1043 1044 struct inode *src_inode = file_inode(src_f); 1044 1045 struct inode *dst_inode = file_inode(dst_f); 1045 1046 struct nfs_server *server = NFS_SERVER(dst_inode); 1047 + __u32 dst_bitmask[NFS_BITMASK_SZ]; 1046 1048 struct nfs42_clone_args args = { 1047 1049 .src_fh = NFS_FH(src_inode), 1048 1050 .dst_fh = NFS_FH(dst_inode), 1049 1051 .src_offset = src_offset, 1050 1052 .dst_offset = dst_offset, 1051 1053 .count = count, 1052 - .dst_bitmask = server->cache_consistency_bitmask, 1054 + .dst_bitmask = dst_bitmask, 1053 1055 }; 1054 1056 struct nfs42_clone_res res = { 1055 1057 .server = server, ··· 1078 1078 res.dst_fattr = nfs_alloc_fattr(); 1079 1079 if (!res.dst_fattr) 1080 1080 return -ENOMEM; 1081 + 1082 + nfs4_bitmask_set(dst_bitmask, server->cache_consistency_bitmask, 1083 + dst_inode, NFS_INO_INVALID_BLOCKS); 1081 1084 1082 1085 status = nfs4_call_sync(server->client, server, msg, 1083 1086 &args.seq_args, &res.seq_res, 0);
+9 -5
fs/nfs/nfs4_fs.h
··· 260 260 }; 261 261 262 262 struct nfs4_mig_recovery_ops { 263 - int (*get_locations)(struct inode *, struct nfs4_fs_locations *, 264 - struct page *, const struct cred *); 263 + int (*get_locations)(struct nfs_server *, struct nfs_fh *, 264 + struct nfs4_fs_locations *, struct page *, const struct cred *); 265 265 int (*fsid_present)(struct inode *, const struct cred *); 266 266 }; 267 267 ··· 280 280 int nfs4_submount(struct fs_context *, struct nfs_server *); 281 281 int nfs4_replace_transport(struct nfs_server *server, 282 282 const struct nfs4_fs_locations *locations); 283 - 283 + size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa, 284 + size_t salen, struct net *net, int port); 284 285 /* nfs4proc.c */ 285 286 extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *); 286 287 extern int nfs4_async_handle_error(struct rpc_task *task, ··· 303 302 extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); 304 303 extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *, 305 304 struct nfs4_fs_locations *, struct page *); 306 - extern int nfs4_proc_get_locations(struct inode *, struct nfs4_fs_locations *, 307 - struct page *page, const struct cred *); 305 + extern int nfs4_proc_get_locations(struct nfs_server *, struct nfs_fh *, 306 + struct nfs4_fs_locations *, 307 + struct page *page, const struct cred *); 308 308 extern int nfs4_proc_fsid_present(struct inode *, const struct cred *); 309 309 extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, 310 310 struct dentry *, ··· 317 315 const struct nfs_open_context *ctx, 318 316 const struct nfs_lock_context *l_ctx, 319 317 fmode_t fmode); 318 + extern void nfs4_bitmask_set(__u32 bitmask[], const __u32 src[], 319 + struct inode *inode, unsigned long cache_validity); 320 320 extern int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, 321 321 struct nfs_fattr *fattr, struct inode *inode); 322 322 extern int update_open_stateid(struct nfs4_state *state,
+4 -1
fs/nfs/nfs4client.c
··· 1343 1343 } 1344 1344 nfs_put_client(clp); 1345 1345 1346 - if (server->nfs_client->cl_hostname == NULL) 1346 + if (server->nfs_client->cl_hostname == NULL) { 1347 1347 server->nfs_client->cl_hostname = kstrdup(hostname, GFP_KERNEL); 1348 + if (server->nfs_client->cl_hostname == NULL) 1349 + return -ENOMEM; 1350 + } 1348 1351 nfs_server_insert_lists(server); 1349 1352 1350 1353 return nfs_probe_server(server, NFS_FH(d_inode(server->super->s_root)));
+12 -7
fs/nfs/nfs4namespace.c
··· 164 164 return 0; 165 165 } 166 166 167 - static size_t nfs_parse_server_name(char *string, size_t len, 168 - struct sockaddr *sa, size_t salen, struct net *net) 167 + size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa, 168 + size_t salen, struct net *net, int port) 169 169 { 170 170 ssize_t ret; 171 171 172 172 ret = rpc_pton(net, string, len, sa, salen); 173 173 if (ret == 0) { 174 - ret = nfs_dns_resolve_name(net, string, len, sa, salen); 175 - if (ret < 0) 176 - ret = 0; 174 + ret = rpc_uaddr2sockaddr(net, string, len, sa, salen); 175 + if (ret == 0) { 176 + ret = nfs_dns_resolve_name(net, string, len, sa, salen); 177 + if (ret < 0) 178 + ret = 0; 179 + } 180 + } else if (port) { 181 + rpc_set_port(sa, port); 177 182 } 178 183 return ret; 179 184 } ··· 333 328 nfs_parse_server_name(buf->data, buf->len, 334 329 &ctx->nfs_server.address, 335 330 sizeof(ctx->nfs_server._address), 336 - fc->net_ns); 331 + fc->net_ns, 0); 337 332 if (ctx->nfs_server.addrlen == 0) 338 333 continue; 339 334 ··· 501 496 continue; 502 497 503 498 salen = nfs_parse_server_name(buf->data, buf->len, 504 - sap, addr_bufsize, net); 499 + sap, addr_bufsize, net, 0); 505 500 if (salen == 0) 506 501 continue; 507 502 rpc_set_port(sap, NFS_PORT);
+156 -41
fs/nfs/nfs4proc.c
··· 108 108 static int nfs41_free_stateid(struct nfs_server *, const nfs4_stateid *, 109 109 const struct cred *, bool); 110 110 #endif 111 - static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], 112 - const __u32 *src, struct inode *inode, 113 - struct nfs_server *server, 114 - struct nfs4_label *label); 115 111 116 112 #ifdef CONFIG_NFS_V4_SECURITY_LABEL 117 113 static inline struct nfs4_label * ··· 2649 2653 } else if ((fmode & FMODE_READ) && !opendata->file_created) 2650 2654 mask = NFS4_ACCESS_READ; 2651 2655 2652 - cache.cred = cred; 2653 2656 nfs_access_set_mask(&cache, opendata->o_res.access_result); 2654 - nfs_access_add_cache(state->inode, &cache); 2657 + nfs_access_add_cache(state->inode, &cache, cred); 2655 2658 2656 2659 flags = NFS4_ACCESS_READ | NFS4_ACCESS_EXECUTE | NFS4_ACCESS_LOOKUP; 2657 2660 if ((mask & ~cache.mask & flags) == 0) ··· 3665 3670 if (!nfs4_have_delegation(inode, FMODE_READ)) { 3666 3671 nfs4_bitmask_set(calldata->arg.bitmask_store, 3667 3672 server->cache_consistency_bitmask, 3668 - inode, server, NULL); 3673 + inode, 0); 3669 3674 calldata->arg.bitmask = calldata->arg.bitmask_store; 3670 3675 } else 3671 3676 calldata->arg.bitmask = NULL; ··· 3836 3841 FATTR4_WORD0_FH_EXPIRE_TYPE | 3837 3842 FATTR4_WORD0_LINK_SUPPORT | 3838 3843 FATTR4_WORD0_SYMLINK_SUPPORT | 3839 - FATTR4_WORD0_ACLSUPPORT; 3844 + FATTR4_WORD0_ACLSUPPORT | 3845 + FATTR4_WORD0_CASE_INSENSITIVE | 3846 + FATTR4_WORD0_CASE_PRESERVING; 3840 3847 if (minorversion) 3841 3848 bitmask[2] = FATTR4_WORD2_SUPPATTR_EXCLCREAT; 3842 3849 ··· 3867 3870 server->caps |= NFS_CAP_HARDLINKS; 3868 3871 if (res.has_symlinks != 0) 3869 3872 server->caps |= NFS_CAP_SYMLINKS; 3873 + if (res.case_insensitive) 3874 + server->caps |= NFS_CAP_CASE_INSENSITIVE; 3875 + if (res.case_preserving) 3876 + server->caps |= NFS_CAP_CASE_PRESERVING; 3870 3877 #ifdef CONFIG_NFS_V4_SECURITY_LABEL 3871 3878 if (res.attr_bitmask[2] & FATTR4_WORD2_SECURITY_LABEL) 3872 3879 server->caps |= NFS_CAP_SECURITY_LABEL; 3873 3880 #endif 3881 + if (res.attr_bitmask[0] & FATTR4_WORD0_FS_LOCATIONS) 3882 + server->caps |= NFS_CAP_FS_LOCATIONS; 3874 3883 if (!(res.attr_bitmask[0] & FATTR4_WORD0_FILEID)) 3875 3884 server->fattr_valid &= ~NFS_ATTR_FATTR_FILEID; 3876 3885 if (!(res.attr_bitmask[1] & FATTR4_WORD1_MODE)) ··· 3932 3929 _nfs4_server_capabilities(server, fhandle), 3933 3930 &exception); 3934 3931 } while (exception.retry); 3932 + return err; 3933 + } 3934 + 3935 + static void test_fs_location_for_trunking(struct nfs4_fs_location *location, 3936 + struct nfs_client *clp, 3937 + struct nfs_server *server) 3938 + { 3939 + int i; 3940 + 3941 + for (i = 0; i < location->nservers; i++) { 3942 + struct nfs4_string *srv_loc = &location->servers[i]; 3943 + struct sockaddr addr; 3944 + size_t addrlen; 3945 + struct xprt_create xprt_args = { 3946 + .ident = 0, 3947 + .net = clp->cl_net, 3948 + }; 3949 + struct nfs4_add_xprt_data xprtdata = { 3950 + .clp = clp, 3951 + }; 3952 + struct rpc_add_xprt_test rpcdata = { 3953 + .add_xprt_test = clp->cl_mvops->session_trunk, 3954 + .data = &xprtdata, 3955 + }; 3956 + char *servername = NULL; 3957 + 3958 + if (!srv_loc->len) 3959 + continue; 3960 + 3961 + addrlen = nfs_parse_server_name(srv_loc->data, srv_loc->len, 3962 + &addr, sizeof(addr), 3963 + clp->cl_net, server->port); 3964 + if (!addrlen) 3965 + return; 3966 + xprt_args.dstaddr = &addr; 3967 + xprt_args.addrlen = addrlen; 3968 + servername = kmalloc(srv_loc->len + 1, GFP_KERNEL); 3969 + if (!servername) 3970 + return; 3971 + memcpy(servername, srv_loc->data, srv_loc->len); 3972 + servername[srv_loc->len] = '\0'; 3973 + xprt_args.servername = servername; 3974 + 3975 + xprtdata.cred = nfs4_get_clid_cred(clp); 3976 + rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args, 3977 + rpc_clnt_setup_test_and_add_xprt, 3978 + &rpcdata); 3979 + if (xprtdata.cred) 3980 + put_cred(xprtdata.cred); 3981 + kfree(servername); 3982 + } 3983 + } 3984 + 3985 + static int _nfs4_discover_trunking(struct nfs_server *server, 3986 + struct nfs_fh *fhandle) 3987 + { 3988 + struct nfs4_fs_locations *locations = NULL; 3989 + struct page *page; 3990 + const struct cred *cred; 3991 + struct nfs_client *clp = server->nfs_client; 3992 + const struct nfs4_state_maintenance_ops *ops = 3993 + clp->cl_mvops->state_renewal_ops; 3994 + int status = -ENOMEM, i; 3995 + 3996 + cred = ops->get_state_renewal_cred(clp); 3997 + if (cred == NULL) { 3998 + cred = nfs4_get_clid_cred(clp); 3999 + if (cred == NULL) 4000 + return -ENOKEY; 4001 + } 4002 + 4003 + page = alloc_page(GFP_KERNEL); 4004 + locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL); 4005 + if (page == NULL || locations == NULL) 4006 + goto out; 4007 + 4008 + status = nfs4_proc_get_locations(server, fhandle, locations, page, 4009 + cred); 4010 + if (status) 4011 + goto out; 4012 + 4013 + for (i = 0; i < locations->nlocations; i++) 4014 + test_fs_location_for_trunking(&locations->locations[i], clp, 4015 + server); 4016 + out: 4017 + if (page) 4018 + __free_page(page); 4019 + kfree(locations); 4020 + return status; 4021 + } 4022 + 4023 + static int nfs4_discover_trunking(struct nfs_server *server, 4024 + struct nfs_fh *fhandle) 4025 + { 4026 + struct nfs4_exception exception = { 4027 + .interruptible = true, 4028 + }; 4029 + struct nfs_client *clp = server->nfs_client; 4030 + int err = 0; 4031 + 4032 + if (!nfs4_has_session(clp)) 4033 + goto out; 4034 + do { 4035 + err = nfs4_handle_exception(server, 4036 + _nfs4_discover_trunking(server, fhandle), 4037 + &exception); 4038 + } while (exception.retry); 4039 + out: 3935 4040 return err; 3936 4041 } 3937 4042 ··· 4552 4441 return err; 4553 4442 } 4554 4443 4555 - static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) 4444 + static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry, 4445 + const struct cred *cred) 4556 4446 { 4557 4447 struct nfs_server *server = NFS_SERVER(inode); 4558 4448 struct nfs4_accessargs args = { ··· 4567 4455 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_ACCESS], 4568 4456 .rpc_argp = &args, 4569 4457 .rpc_resp = &res, 4570 - .rpc_cred = entry->cred, 4458 + .rpc_cred = cred, 4571 4459 }; 4572 4460 int status = 0; 4573 4461 ··· 4587 4475 return status; 4588 4476 } 4589 4477 4590 - static int nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) 4478 + static int nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry, 4479 + const struct cred *cred) 4591 4480 { 4592 4481 struct nfs4_exception exception = { 4593 4482 .interruptible = true, 4594 4483 }; 4595 4484 int err; 4596 4485 do { 4597 - err = _nfs4_proc_access(inode, entry); 4486 + err = _nfs4_proc_access(inode, entry, cred); 4598 4487 trace_nfs4_access(inode, err); 4599 4488 err = nfs4_handle_exception(NFS_SERVER(inode), err, 4600 4489 &exception); ··· 4776 4663 4777 4664 nfs_fattr_init(res->dir_attr); 4778 4665 4779 - if (inode) 4666 + if (inode) { 4780 4667 nfs4_inode_return_delegation(inode); 4668 + nfs_d_prune_case_insensitive_aliases(inode); 4669 + } 4781 4670 } 4782 4671 4783 4672 static void nfs4_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data) ··· 4845 4730 return 0; 4846 4731 4847 4732 if (task->tk_status == 0) { 4733 + nfs_d_prune_case_insensitive_aliases(d_inode(data->old_dentry)); 4848 4734 if (new_dir != old_dir) { 4849 4735 /* Note: If we moved a directory, nlink will change */ 4850 4736 nfs4_update_changeattr(old_dir, &res->old_cinfo, ··· 5538 5422 return nfs4_have_delegation(hdr->inode, FMODE_READ) == 0; 5539 5423 } 5540 5424 5541 - static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src, 5542 - struct inode *inode, struct nfs_server *server, 5543 - struct nfs4_label *label) 5425 + void nfs4_bitmask_set(__u32 bitmask[], const __u32 src[], 5426 + struct inode *inode, unsigned long cache_validity) 5544 5427 { 5545 - unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity); 5428 + struct nfs_server *server = NFS_SERVER(inode); 5546 5429 unsigned int i; 5547 5430 5548 5431 memcpy(bitmask, src, sizeof(*bitmask) * NFS4_BITMASK_SZ); 5432 + cache_validity |= READ_ONCE(NFS_I(inode)->cache_validity); 5549 5433 5550 5434 if (cache_validity & NFS_INO_INVALID_CHANGE) 5551 5435 bitmask[0] |= FATTR4_WORD0_CHANGE; ··· 5557 5441 bitmask[1] |= FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP; 5558 5442 if (cache_validity & NFS_INO_INVALID_NLINK) 5559 5443 bitmask[1] |= FATTR4_WORD1_NUMLINKS; 5560 - if (label && label->len && cache_validity & NFS_INO_INVALID_LABEL) 5561 - bitmask[2] |= FATTR4_WORD2_SECURITY_LABEL; 5562 5444 if (cache_validity & NFS_INO_INVALID_CTIME) 5563 5445 bitmask[1] |= FATTR4_WORD1_TIME_METADATA; 5564 5446 if (cache_validity & NFS_INO_INVALID_MTIME) ··· 5583 5469 } else { 5584 5470 nfs4_bitmask_set(hdr->args.bitmask_store, 5585 5471 server->cache_consistency_bitmask, 5586 - hdr->inode, server, NULL); 5472 + hdr->inode, NFS_INO_INVALID_BLOCKS); 5587 5473 hdr->args.bitmask = hdr->args.bitmask_store; 5588 5474 } 5589 5475 ··· 6621 6507 data->args.fhandle = &data->fh; 6622 6508 data->args.stateid = &data->stateid; 6623 6509 nfs4_bitmask_set(data->args.bitmask_store, 6624 - server->cache_consistency_bitmask, inode, server, 6625 - NULL); 6510 + server->cache_consistency_bitmask, inode, 0); 6626 6511 data->args.bitmask = data->args.bitmask_store; 6627 6512 nfs_copy_fh(&data->fh, NFS_FH(inode)); 6628 6513 nfs4_stateid_copy(&data->stateid, stateid); ··· 7724 7611 const char *key, const void *buf, 7725 7612 size_t buflen, int flags) 7726 7613 { 7727 - struct nfs_access_entry cache; 7614 + u32 mask; 7728 7615 int ret; 7729 7616 7730 7617 if (!nfs_server_capable(inode, NFS_CAP_XATTR)) ··· 7739 7626 * do a cached access check for the XA* flags to possibly avoid 7740 7627 * doing an RPC and getting EACCES back. 7741 7628 */ 7742 - if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) { 7743 - if (!(cache.mask & NFS_ACCESS_XAWRITE)) 7629 + if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) { 7630 + if (!(mask & NFS_ACCESS_XAWRITE)) 7744 7631 return -EACCES; 7745 7632 } 7746 7633 ··· 7761 7648 struct dentry *unused, struct inode *inode, 7762 7649 const char *key, void *buf, size_t buflen) 7763 7650 { 7764 - struct nfs_access_entry cache; 7651 + u32 mask; 7765 7652 ssize_t ret; 7766 7653 7767 7654 if (!nfs_server_capable(inode, NFS_CAP_XATTR)) 7768 7655 return -EOPNOTSUPP; 7769 7656 7770 - if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) { 7771 - if (!(cache.mask & NFS_ACCESS_XAREAD)) 7657 + if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) { 7658 + if (!(mask & NFS_ACCESS_XAREAD)) 7772 7659 return -EACCES; 7773 7660 } 7774 7661 ··· 7793 7680 ssize_t ret, size; 7794 7681 char *buf; 7795 7682 size_t buflen; 7796 - struct nfs_access_entry cache; 7683 + u32 mask; 7797 7684 7798 7685 if (!nfs_server_capable(inode, NFS_CAP_XATTR)) 7799 7686 return 0; 7800 7687 7801 - if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) { 7802 - if (!(cache.mask & NFS_ACCESS_XALIST)) 7688 + if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) { 7689 + if (!(mask & NFS_ACCESS_XALIST)) 7803 7690 return 0; 7804 7691 } 7805 7692 ··· 7931 7818 * appended to this compound to identify the client ID which is 7932 7819 * performing recovery. 7933 7820 */ 7934 - static int _nfs40_proc_get_locations(struct inode *inode, 7821 + static int _nfs40_proc_get_locations(struct nfs_server *server, 7822 + struct nfs_fh *fhandle, 7935 7823 struct nfs4_fs_locations *locations, 7936 7824 struct page *page, const struct cred *cred) 7937 7825 { 7938 - struct nfs_server *server = NFS_SERVER(inode); 7939 7826 struct rpc_clnt *clnt = server->client; 7940 7827 u32 bitmask[2] = { 7941 7828 [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS, 7942 7829 }; 7943 7830 struct nfs4_fs_locations_arg args = { 7944 7831 .clientid = server->nfs_client->cl_clientid, 7945 - .fh = NFS_FH(inode), 7832 + .fh = fhandle, 7946 7833 .page = page, 7947 7834 .bitmask = bitmask, 7948 7835 .migration = 1, /* skip LOOKUP */ ··· 7988 7875 * When the client supports GETATTR(fs_locations_info), it can 7989 7876 * be plumbed in here. 7990 7877 */ 7991 - static int _nfs41_proc_get_locations(struct inode *inode, 7878 + static int _nfs41_proc_get_locations(struct nfs_server *server, 7879 + struct nfs_fh *fhandle, 7992 7880 struct nfs4_fs_locations *locations, 7993 7881 struct page *page, const struct cred *cred) 7994 7882 { 7995 - struct nfs_server *server = NFS_SERVER(inode); 7996 7883 struct rpc_clnt *clnt = server->client; 7997 7884 u32 bitmask[2] = { 7998 7885 [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS, 7999 7886 }; 8000 7887 struct nfs4_fs_locations_arg args = { 8001 - .fh = NFS_FH(inode), 7888 + .fh = fhandle, 8002 7889 .page = page, 8003 7890 .bitmask = bitmask, 8004 7891 .migration = 1, /* skip LOOKUP */ ··· 8047 7934 * -NFS4ERR_LEASE_MOVED is returned if the server still has leases 8048 7935 * from this client that require migration recovery. 8049 7936 */ 8050 - int nfs4_proc_get_locations(struct inode *inode, 7937 + int nfs4_proc_get_locations(struct nfs_server *server, 7938 + struct nfs_fh *fhandle, 8051 7939 struct nfs4_fs_locations *locations, 8052 7940 struct page *page, const struct cred *cred) 8053 7941 { 8054 - struct nfs_server *server = NFS_SERVER(inode); 8055 7942 struct nfs_client *clp = server->nfs_client; 8056 7943 const struct nfs4_mig_recovery_ops *ops = 8057 7944 clp->cl_mvops->mig_recovery_ops; ··· 8064 7951 (unsigned long long)server->fsid.major, 8065 7952 (unsigned long long)server->fsid.minor, 8066 7953 clp->cl_hostname); 8067 - nfs_display_fhandle(NFS_FH(inode), __func__); 7954 + nfs_display_fhandle(fhandle, __func__); 8068 7955 8069 7956 do { 8070 - status = ops->get_locations(inode, locations, page, cred); 7957 + status = ops->get_locations(server, fhandle, locations, page, 7958 + cred); 8071 7959 if (status != -NFS4ERR_DELAY) 8072 7960 break; 8073 7961 nfs4_handle_exception(server, status, &exception); ··· 10537 10423 .free_client = nfs4_free_client, 10538 10424 .create_server = nfs4_create_server, 10539 10425 .clone_server = nfs_clone_server, 10426 + .discover_trunking = nfs4_discover_trunking, 10540 10427 }; 10541 10428 10542 10429 static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {
+5 -1
fs/nfs/nfs4state.c
··· 2098 2098 } 2099 2099 2100 2100 inode = d_inode(server->super->s_root); 2101 - result = nfs4_proc_get_locations(inode, locations, page, cred); 2101 + result = nfs4_proc_get_locations(server, NFS_FH(inode), locations, 2102 + page, cred); 2102 2103 if (result) { 2103 2104 dprintk("<-- %s: failed to retrieve fs_locations: %d\n", 2104 2105 __func__, result); ··· 2107 2106 } 2108 2107 2109 2108 result = -NFS4ERR_NXIO; 2109 + if (!locations->nlocations) 2110 + goto out; 2111 + 2110 2112 if (!(locations->fattr.valid & NFS_ATTR_FATTR_V4_LOCATIONS)) { 2111 2113 dprintk("<-- %s: No fs_locations data, migration skipped\n", 2112 2114 __func__);
+44 -5
fs/nfs/nfs4xdr.c
··· 3533 3533 return 0; 3534 3534 } 3535 3535 3536 + static int decode_attr_case_insensitive(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) 3537 + { 3538 + __be32 *p; 3539 + 3540 + *res = 0; 3541 + if (unlikely(bitmap[0] & (FATTR4_WORD0_CASE_INSENSITIVE - 1U))) 3542 + return -EIO; 3543 + if (likely(bitmap[0] & FATTR4_WORD0_CASE_INSENSITIVE)) { 3544 + p = xdr_inline_decode(xdr, 4); 3545 + if (unlikely(!p)) 3546 + return -EIO; 3547 + *res = be32_to_cpup(p); 3548 + bitmap[0] &= ~FATTR4_WORD0_CASE_INSENSITIVE; 3549 + } 3550 + dprintk("%s: case_insensitive=%s\n", __func__, *res == 0 ? "false" : "true"); 3551 + return 0; 3552 + } 3553 + 3554 + static int decode_attr_case_preserving(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) 3555 + { 3556 + __be32 *p; 3557 + 3558 + *res = 0; 3559 + if (unlikely(bitmap[0] & (FATTR4_WORD0_CASE_PRESERVING - 1U))) 3560 + return -EIO; 3561 + if (likely(bitmap[0] & FATTR4_WORD0_CASE_PRESERVING)) { 3562 + p = xdr_inline_decode(xdr, 4); 3563 + if (unlikely(!p)) 3564 + return -EIO; 3565 + *res = be32_to_cpup(p); 3566 + bitmap[0] &= ~FATTR4_WORD0_CASE_PRESERVING; 3567 + } 3568 + dprintk("%s: case_preserving=%s\n", __func__, *res == 0 ? "false" : "true"); 3569 + return 0; 3570 + } 3571 + 3536 3572 static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) 3537 3573 { 3538 3574 __be32 *p; ··· 3732 3696 if (unlikely(!p)) 3733 3697 goto out_eio; 3734 3698 n = be32_to_cpup(p); 3735 - if (n <= 0) 3736 - goto out_eio; 3737 3699 for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { 3738 3700 u32 m; 3739 3701 struct nfs4_fs_location *loc; ··· 4234 4200 } else 4235 4201 printk(KERN_WARNING "%s: label too long (%u)!\n", 4236 4202 __func__, len); 4203 + if (label && label->label) 4204 + dprintk("%s: label=%.*s, len=%d, PI=%d, LFS=%d\n", 4205 + __func__, label->len, (char *)label->label, 4206 + label->len, label->pi, label->lfs); 4237 4207 } 4238 - if (label && label->label) 4239 - dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, 4240 - (char *)label->label, label->len, label->pi, label->lfs); 4241 4208 return status; 4242 4209 } 4243 4210 ··· 4446 4411 if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) 4447 4412 goto xdr_error; 4448 4413 if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) 4414 + goto xdr_error; 4415 + if ((status = decode_attr_case_insensitive(xdr, bitmap, &res->case_insensitive)) != 0) 4416 + goto xdr_error; 4417 + if ((status = decode_attr_case_preserving(xdr, bitmap, &res->case_preserving)) != 0) 4449 4418 goto xdr_error; 4450 4419 if ((status = decode_attr_exclcreat_supported(xdr, bitmap, 4451 4420 res->exclcreat_bitmask)) != 0)
+2 -1
fs/nfs/sysfs.c
··· 142 142 &nfs_netns_client_id.attr, 143 143 NULL, 144 144 }; 145 + ATTRIBUTE_GROUPS(nfs_netns_client); 145 146 146 147 static struct kobj_type nfs_netns_client_type = { 147 148 .release = nfs_netns_client_release, 148 - .default_attrs = nfs_netns_client_attrs, 149 + .default_groups = nfs_netns_client_groups, 149 150 .sysfs_ops = &kobj_sysfs_ops, 150 151 .namespace = nfs_netns_client_namespace, 151 152 };
+3 -2
fs/nfsd/nfsctl.c
··· 1247 1247 clear_ncl(d_inode(dentry)); 1248 1248 dget(dentry); 1249 1249 ret = simple_unlink(dir, dentry); 1250 - d_delete(dentry); 1250 + d_drop(dentry); 1251 + fsnotify_unlink(dir, dentry); 1251 1252 dput(dentry); 1252 1253 WARN_ON_ONCE(ret); 1253 1254 } ··· 1339 1338 dget(dentry); 1340 1339 ret = simple_rmdir(dir, dentry); 1341 1340 WARN_ON_ONCE(ret); 1341 + d_drop(dentry); 1342 1342 fsnotify_rmdir(dir, dentry); 1343 - d_delete(dentry); 1344 1343 dput(dentry); 1345 1344 inode_unlock(dir); 1346 1345 }
-3
fs/notify/fanotify/fanotify_user.c
··· 158 158 struct fanotify_event *event) 159 159 { 160 160 size_t event_len = FAN_EVENT_METADATA_LEN; 161 - struct fanotify_info *info; 162 161 int fh_len; 163 162 int dot_len = 0; 164 163 ··· 166 167 167 168 if (fanotify_is_error_event(event->mask)) 168 169 event_len += FANOTIFY_ERROR_INFO_LEN; 169 - 170 - info = fanotify_event_info(event); 171 170 172 171 if (fanotify_event_has_any_dir_fh(event)) { 173 172 event_len += fanotify_dir_name_info_len(event);
+1 -12
fs/ocfs2/stackglue.c
··· 661 661 { } 662 662 }; 663 663 664 - static struct ctl_table ocfs2_mod_table[] = { 665 - { 666 - .procname = "nm", 667 - .data = NULL, 668 - .maxlen = 0, 669 - .mode = 0555, 670 - .child = ocfs2_nm_table 671 - }, 672 - { } 673 - }; 674 - 675 664 static struct ctl_table_header *ocfs2_table_header; 676 665 677 666 /* ··· 671 682 { 672 683 strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB); 673 684 674 - ocfs2_table_header = register_sysctl("fs/ocfs2", ocfs2_mod_table); 685 + ocfs2_table_header = register_sysctl("fs/ocfs2/nm", ocfs2_nm_table); 675 686 if (!ocfs2_table_header) { 676 687 printk(KERN_ERR 677 688 "ocfs2 stack glue: unable to register sysctl\n");
+11 -14
fs/ocfs2/suballoc.c
··· 1251 1251 { 1252 1252 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; 1253 1253 struct journal_head *jh; 1254 - int ret = 1; 1254 + int ret; 1255 1255 1256 1256 if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap)) 1257 1257 return 0; 1258 1258 1259 - if (!buffer_jbd(bg_bh)) 1259 + jh = jbd2_journal_grab_journal_head(bg_bh); 1260 + if (!jh) 1260 1261 return 1; 1261 1262 1262 - jbd_lock_bh_journal_head(bg_bh); 1263 - if (buffer_jbd(bg_bh)) { 1264 - jh = bh2jh(bg_bh); 1265 - spin_lock(&jh->b_state_lock); 1266 - bg = (struct ocfs2_group_desc *) jh->b_committed_data; 1267 - if (bg) 1268 - ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap); 1269 - else 1270 - ret = 1; 1271 - spin_unlock(&jh->b_state_lock); 1272 - } 1273 - jbd_unlock_bh_journal_head(bg_bh); 1263 + spin_lock(&jh->b_state_lock); 1264 + bg = (struct ocfs2_group_desc *) jh->b_committed_data; 1265 + if (bg) 1266 + ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap); 1267 + else 1268 + ret = 1; 1269 + spin_unlock(&jh->b_state_lock); 1270 + jbd2_journal_put_journal_head(jh); 1274 1271 1275 1272 return ret; 1276 1273 }
+4 -5
fs/udf/inode.c
··· 258 258 char *kaddr; 259 259 struct udf_inode_info *iinfo = UDF_I(inode); 260 260 int err; 261 - struct writeback_control udf_wbc = { 262 - .sync_mode = WB_SYNC_NONE, 263 - .nr_to_write = 1, 264 - }; 265 261 266 262 WARN_ON_ONCE(!inode_is_locked(inode)); 267 263 if (!iinfo->i_lenAlloc) { ··· 301 305 iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG; 302 306 /* from now on we have normal address_space methods */ 303 307 inode->i_data.a_ops = &udf_aops; 308 + set_page_dirty(page); 309 + unlock_page(page); 304 310 up_write(&iinfo->i_data_sem); 305 - err = inode->i_data.a_ops->writepage(page, &udf_wbc); 311 + err = filemap_fdatawrite(inode->i_mapping); 306 312 if (err) { 307 313 /* Restore everything back so that we don't lose data... */ 308 314 lock_page(page); ··· 315 317 unlock_page(page); 316 318 iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; 317 319 inode->i_data.a_ops = &udf_adinicb_aops; 320 + iinfo->i_lenAlloc = inode->i_size; 318 321 up_write(&iinfo->i_data_sem); 319 322 } 320 323 put_page(page);
+1
include/linux/blkdev.h
··· 1258 1258 void disk_end_io_acct(struct gendisk *disk, unsigned int op, 1259 1259 unsigned long start_time); 1260 1260 1261 + void bio_start_io_acct_time(struct bio *bio, unsigned long start_time); 1261 1262 unsigned long bio_start_io_acct(struct bio *bio); 1262 1263 void bio_end_io_acct_remapped(struct bio *bio, unsigned long start_time, 1263 1264 struct block_device *orig_bdev);
+1 -1
include/linux/ethtool.h
··· 111 111 enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity; 112 112 enum ethtool_link_ext_substate_cable_issue cable_issue; 113 113 enum ethtool_link_ext_substate_module module; 114 - u8 __link_ext_substate; 114 + u32 __link_ext_substate; 115 115 }; 116 116 }; 117 117
+43 -6
include/linux/fsnotify.h
··· 225 225 } 226 226 227 227 /* 228 + * fsnotify_delete - @dentry was unlinked and unhashed 229 + * 230 + * Caller must make sure that dentry->d_name is stable. 231 + * 232 + * Note: unlike fsnotify_unlink(), we have to pass also the unlinked inode 233 + * as this may be called after d_delete() and old_dentry may be negative. 234 + */ 235 + static inline void fsnotify_delete(struct inode *dir, struct inode *inode, 236 + struct dentry *dentry) 237 + { 238 + __u32 mask = FS_DELETE; 239 + 240 + if (S_ISDIR(inode->i_mode)) 241 + mask |= FS_ISDIR; 242 + 243 + fsnotify_name(mask, inode, FSNOTIFY_EVENT_INODE, dir, &dentry->d_name, 244 + 0); 245 + } 246 + 247 + /** 248 + * d_delete_notify - delete a dentry and call fsnotify_delete() 249 + * @dentry: The dentry to delete 250 + * 251 + * This helper is used to guaranty that the unlinked inode cannot be found 252 + * by lookup of this name after fsnotify_delete() event has been delivered. 253 + */ 254 + static inline void d_delete_notify(struct inode *dir, struct dentry *dentry) 255 + { 256 + struct inode *inode = d_inode(dentry); 257 + 258 + ihold(inode); 259 + d_delete(dentry); 260 + fsnotify_delete(dir, inode, dentry); 261 + iput(inode); 262 + } 263 + 264 + /* 228 265 * fsnotify_unlink - 'name' was unlinked 229 266 * 230 267 * Caller must make sure that dentry->d_name is stable. 231 268 */ 232 269 static inline void fsnotify_unlink(struct inode *dir, struct dentry *dentry) 233 270 { 234 - /* Expected to be called before d_delete() */ 235 - WARN_ON_ONCE(d_is_negative(dentry)); 271 + if (WARN_ON_ONCE(d_is_negative(dentry))) 272 + return; 236 273 237 - fsnotify_dirent(dir, dentry, FS_DELETE); 274 + fsnotify_delete(dir, d_inode(dentry), dentry); 238 275 } 239 276 240 277 /* ··· 295 258 */ 296 259 static inline void fsnotify_rmdir(struct inode *dir, struct dentry *dentry) 297 260 { 298 - /* Expected to be called before d_delete() */ 299 - WARN_ON_ONCE(d_is_negative(dentry)); 261 + if (WARN_ON_ONCE(d_is_negative(dentry))) 262 + return; 300 263 301 - fsnotify_dirent(dir, dentry, FS_DELETE | FS_ISDIR); 264 + fsnotify_delete(dir, d_inode(dentry), dentry); 302 265 } 303 266 304 267 /*
+1 -1
include/linux/lsm_hook_defs.h
··· 80 80 unsigned long *set_kern_flags) 81 81 LSM_HOOK(int, 0, move_mount, const struct path *from_path, 82 82 const struct path *to_path) 83 - LSM_HOOK(int, 0, dentry_init_security, struct dentry *dentry, 83 + LSM_HOOK(int, -EOPNOTSUPP, dentry_init_security, struct dentry *dentry, 84 84 int mode, const struct qstr *name, const char **xattr_name, 85 85 void **ctx, u32 *ctxlen) 86 86 LSM_HOOK(int, 0, dentry_create_files_as, struct dentry *dentry, int mode,
+12 -5
include/linux/mm.h
··· 1506 1506 1507 1507 static inline void page_kasan_tag_set(struct page *page, u8 tag) 1508 1508 { 1509 - if (kasan_enabled()) { 1510 - tag ^= 0xff; 1511 - page->flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); 1512 - page->flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; 1513 - } 1509 + unsigned long old_flags, flags; 1510 + 1511 + if (!kasan_enabled()) 1512 + return; 1513 + 1514 + tag ^= 0xff; 1515 + old_flags = READ_ONCE(page->flags); 1516 + do { 1517 + flags = old_flags; 1518 + flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); 1519 + flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; 1520 + } while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags))); 1514 1521 } 1515 1522 1516 1523 static inline void page_kasan_tag_reset(struct page *page)
+1
include/linux/mm_types.h
··· 261 261 static_assert(offsetof(struct page, pg) == offsetof(struct folio, fl)) 262 262 FOLIO_MATCH(flags, flags); 263 263 FOLIO_MATCH(lru, lru); 264 + FOLIO_MATCH(mapping, mapping); 264 265 FOLIO_MATCH(compound_head, lru); 265 266 FOLIO_MATCH(index, index); 266 267 FOLIO_MATCH(private, private);
+1
include/linux/netdevice.h
··· 2548 2548 struct net_device *); 2549 2549 bool (*id_match)(struct packet_type *ptype, 2550 2550 struct sock *sk); 2551 + struct net *af_packet_net; 2551 2552 void *af_packet_priv; 2552 2553 struct list_head list; 2553 2554 };
+6 -4
include/linux/nfs_fs.h
··· 61 61 struct nfs_access_entry { 62 62 struct rb_node rb_node; 63 63 struct list_head lru; 64 - const struct cred * cred; 64 + kuid_t fsuid; 65 + kgid_t fsgid; 66 + struct group_info *group_info; 65 67 __u32 mask; 66 68 struct rcu_head rcu_head; 67 69 }; ··· 397 395 extern int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fattr *fattr); 398 396 extern int nfs_getattr(struct user_namespace *, const struct path *, 399 397 struct kstat *, u32, unsigned int); 400 - extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *); 398 + extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *, const struct cred *); 401 399 extern void nfs_access_set_mask(struct nfs_access_entry *, u32); 402 400 extern int nfs_permission(struct user_namespace *, struct inode *, int); 403 401 extern int nfs_open(struct inode *, struct file *); ··· 534 532 struct nfs_fattr *fattr); 535 533 extern int nfs_may_open(struct inode *inode, const struct cred *cred, int openflags); 536 534 extern void nfs_access_zap_cache(struct inode *inode); 537 - extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res, 538 - bool may_block); 535 + extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred, 536 + u32 *mask, bool may_block); 539 537 540 538 /* 541 539 * linux/fs/nfs/symlink.c
+3 -1
include/linux/nfs_fs_sb.h
··· 266 266 #define NFS_CAP_ACLS (1U << 3) 267 267 #define NFS_CAP_ATOMIC_OPEN (1U << 4) 268 268 #define NFS_CAP_LGOPEN (1U << 5) 269 + #define NFS_CAP_CASE_INSENSITIVE (1U << 6) 270 + #define NFS_CAP_CASE_PRESERVING (1U << 7) 269 271 #define NFS_CAP_POSIX_LOCK (1U << 14) 270 272 #define NFS_CAP_UIDGID_NOMAP (1U << 15) 271 273 #define NFS_CAP_STATEID_NFSV41 (1U << 16) ··· 284 282 #define NFS_CAP_COPY_NOTIFY (1U << 27) 285 283 #define NFS_CAP_XATTR (1U << 28) 286 284 #define NFS_CAP_READ_PLUS (1U << 29) 287 - 285 + #define NFS_CAP_FS_LOCATIONS (1U << 30) 288 286 #endif
+4 -1
include/linux/nfs_xdr.h
··· 1194 1194 u32 has_links; 1195 1195 u32 has_symlinks; 1196 1196 u32 fh_expire_type; 1197 + u32 case_insensitive; 1198 + u32 case_preserving; 1197 1199 }; 1198 1200 1199 1201 #define NFS4_PATHNAME_MAXCOMPONENTS 512 ··· 1739 1737 struct nfs_fh *, struct nfs_fattr *); 1740 1738 int (*lookupp) (struct inode *, struct nfs_fh *, 1741 1739 struct nfs_fattr *); 1742 - int (*access) (struct inode *, struct nfs_access_entry *); 1740 + int (*access) (struct inode *, struct nfs_access_entry *, const struct cred *); 1743 1741 int (*readlink)(struct inode *, struct page *, unsigned int, 1744 1742 unsigned int); 1745 1743 int (*create) (struct inode *, struct dentry *, ··· 1797 1795 struct nfs_server *(*create_server)(struct fs_context *); 1798 1796 struct nfs_server *(*clone_server)(struct nfs_server *, struct nfs_fh *, 1799 1797 struct nfs_fattr *, rpc_authflavor_t); 1798 + int (*discover_trunking)(struct nfs_server *, struct nfs_fh *); 1800 1799 }; 1801 1800 1802 1801 /*
+3 -12
include/linux/perf_event.h
··· 693 693 u64 total_time_running; 694 694 u64 tstamp; 695 695 696 - /* 697 - * timestamp shadows the actual context timing but it can 698 - * be safely used in NMI interrupt context. It reflects the 699 - * context time as it was when the event was last scheduled in, 700 - * or when ctx_sched_in failed to schedule the event because we 701 - * run out of PMC. 702 - * 703 - * ctx_time already accounts for ctx->timestamp. Therefore to 704 - * compute ctx_time for a sample, simply add perf_clock(). 705 - */ 706 - u64 shadow_ctx_time; 707 - 708 696 struct perf_event_attr attr; 709 697 u16 header_size; 710 698 u16 id_header_size; ··· 840 852 */ 841 853 u64 time; 842 854 u64 timestamp; 855 + u64 timeoffset; 843 856 844 857 /* 845 858 * These fields let us detect when two contexts have both ··· 923 934 struct perf_cgroup_info { 924 935 u64 time; 925 936 u64 timestamp; 937 + u64 timeoffset; 938 + int active; 926 939 }; 927 940 928 941 struct perf_cgroup {
+5
include/linux/pid_namespace.h
··· 86 86 void pidhash_init(void); 87 87 void pid_idr_init(void); 88 88 89 + static inline bool task_is_in_init_pid_ns(struct task_struct *tsk) 90 + { 91 + return task_active_pid_ns(tsk) == &init_pid_ns; 92 + } 93 + 89 94 #endif /* _LINUX_PID_NS_H */
+6 -7
include/linux/psi.h
··· 25 25 void psi_memstall_leave(unsigned long *flags); 26 26 27 27 int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res); 28 + struct psi_trigger *psi_trigger_create(struct psi_group *group, 29 + char *buf, size_t nbytes, enum psi_res res); 30 + void psi_trigger_destroy(struct psi_trigger *t); 31 + 32 + __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file, 33 + poll_table *wait); 28 34 29 35 #ifdef CONFIG_CGROUPS 30 36 int psi_cgroup_alloc(struct cgroup *cgrp); 31 37 void psi_cgroup_free(struct cgroup *cgrp); 32 38 void cgroup_move_task(struct task_struct *p, struct css_set *to); 33 - 34 - struct psi_trigger *psi_trigger_create(struct psi_group *group, 35 - char *buf, size_t nbytes, enum psi_res res); 36 - void psi_trigger_replace(void **trigger_ptr, struct psi_trigger *t); 37 - 38 - __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file, 39 - poll_table *wait); 40 39 #endif 41 40 42 41 #else /* CONFIG_PSI */
-3
include/linux/psi_types.h
··· 141 141 * events to one per window 142 142 */ 143 143 u64 last_event_time; 144 - 145 - /* Refcounting to prevent premature destruction */ 146 - struct kref refcount; 147 144 }; 148 145 149 146 struct psi_group {
+1 -1
include/linux/quota.h
··· 91 91 * 92 92 * When there is no mapping defined for the user-namespace, type, 93 93 * qid tuple an invalid kqid is returned. Callers are expected to 94 - * test for and handle handle invalid kqids being returned. 94 + * test for and handle invalid kqids being returned. 95 95 * Invalid kqids may be tested for using qid_valid(). 96 96 */ 97 97 static inline struct kqid make_kqid(struct user_namespace *from,
-4
include/linux/sched.h
··· 619 619 * task has to wait for a replenishment to be performed at the 620 620 * next firing of dl_timer. 621 621 * 622 - * @dl_boosted tells if we are boosted due to DI. If so we are 623 - * outside bandwidth enforcement mechanism (but only until we 624 - * exit the critical section); 625 - * 626 622 * @dl_yielded tells if task gave up the CPU before consuming 627 623 * all its available runtime during the last job. 628 624 *
+1 -1
include/linux/skbuff.h
··· 318 318 SKB_DROP_REASON_NO_SOCKET, 319 319 SKB_DROP_REASON_PKT_TOO_SMALL, 320 320 SKB_DROP_REASON_TCP_CSUM, 321 - SKB_DROP_REASON_TCP_FILTER, 321 + SKB_DROP_REASON_SOCKET_FILTER, 322 322 SKB_DROP_REASON_UDP_CSUM, 323 323 SKB_DROP_REASON_MAX, 324 324 };
+1 -10
include/linux/suspend.h
··· 430 430 431 431 #ifdef CONFIG_HIBERNATION 432 432 /* kernel/power/snapshot.c */ 433 - extern void __register_nosave_region(unsigned long b, unsigned long e, int km); 434 - static inline void __init register_nosave_region(unsigned long b, unsigned long e) 435 - { 436 - __register_nosave_region(b, e, 0); 437 - } 438 - static inline void __init register_nosave_region_late(unsigned long b, unsigned long e) 439 - { 440 - __register_nosave_region(b, e, 1); 441 - } 433 + extern void register_nosave_region(unsigned long b, unsigned long e); 442 434 extern int swsusp_page_is_forbidden(struct page *); 443 435 extern void swsusp_set_page_free(struct page *); 444 436 extern void swsusp_unset_page_free(struct page *); ··· 450 458 int hibernate_quiet_exec(int (*func)(void *data), void *data); 451 459 #else /* CONFIG_HIBERNATION */ 452 460 static inline void register_nosave_region(unsigned long b, unsigned long e) {} 453 - static inline void register_nosave_region_late(unsigned long b, unsigned long e) {} 454 461 static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } 455 462 static inline void swsusp_set_page_free(struct page *p) {} 456 463 static inline void swsusp_unset_page_free(struct page *p) {}
+1 -1
include/linux/sysctl.h
··· 265 265 return NULL; 266 266 } 267 267 268 - static inline struct sysctl_header *register_sysctl_mount_point(const char *path) 268 + static inline struct ctl_table_header *register_sysctl_mount_point(const char *path) 269 269 { 270 270 return NULL; 271 271 }
+6
include/linux/usb/role.h
··· 92 92 static inline void usb_role_switch_put(struct usb_role_switch *sw) { } 93 93 94 94 static inline struct usb_role_switch * 95 + usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode) 96 + { 97 + return NULL; 98 + } 99 + 100 + static inline struct usb_role_switch * 95 101 usb_role_switch_register(struct device *parent, 96 102 const struct usb_role_switch_desc *desc) 97 103 {
+2
include/net/addrconf.h
··· 6 6 #define RTR_SOLICITATION_INTERVAL (4*HZ) 7 7 #define RTR_SOLICITATION_MAX_INTERVAL (3600*HZ) /* 1 hour */ 8 8 9 + #define MIN_VALID_LIFETIME (2*3600) /* 2 hours */ 10 + 9 11 #define TEMP_VALID_LIFETIME (7*86400) 10 12 #define TEMP_PREFERRED_LIFETIME (86400) 11 13 #define REGEN_MAX_RETRY (3)
+1 -1
include/net/bonding.h
··· 346 346 347 347 static inline struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond) 348 348 { 349 - struct slave *slave = rcu_dereference(bond->curr_active_slave); 349 + struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); 350 350 351 351 return bond_uses_primary(bond) && slave ? slave->dev : NULL; 352 352 }
+10 -11
include/net/ip.h
··· 525 525 { 526 526 struct iphdr *iph = ip_hdr(skb); 527 527 528 + /* We had many attacks based on IPID, use the private 529 + * generator as much as we can. 530 + */ 531 + if (sk && inet_sk(sk)->inet_daddr) { 532 + iph->id = htons(inet_sk(sk)->inet_id); 533 + inet_sk(sk)->inet_id += segs; 534 + return; 535 + } 528 536 if ((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) { 529 - /* This is only to work around buggy Windows95/2000 530 - * VJ compression implementations. If the ID field 531 - * does not change, they drop every other packet in 532 - * a TCP stream using header compression. 533 - */ 534 - if (sk && inet_sk(sk)->inet_daddr) { 535 - iph->id = htons(inet_sk(sk)->inet_id); 536 - inet_sk(sk)->inet_id += segs; 537 - } else { 538 - iph->id = 0; 539 - } 537 + iph->id = 0; 540 538 } else { 539 + /* Unfortunately we need the big hammer to get a suitable IPID */ 541 540 __ip_select_ident(net, iph, segs); 542 541 } 543 542 }
+1 -1
include/net/ip6_fib.h
··· 282 282 fn = rcu_dereference(f6i->fib6_node); 283 283 284 284 if (fn) { 285 - *cookie = fn->fn_sernum; 285 + *cookie = READ_ONCE(fn->fn_sernum); 286 286 /* pairs with smp_wmb() in __fib6_update_sernum_upto_root() */ 287 287 smp_rmb(); 288 288 status = true;
+1 -1
include/net/route.h
··· 370 370 { 371 371 struct neighbour *neigh; 372 372 373 - neigh = __ipv4_neigh_lookup_noref(dev, daddr); 373 + neigh = __ipv4_neigh_lookup_noref(dev, (__force u32)daddr); 374 374 if (unlikely(!neigh)) 375 375 neigh = __neigh_create(&arp_tbl, &daddr, dev, false); 376 376
+4
include/net/tcp.h
··· 1369 1369 1370 1370 bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb); 1371 1371 1372 + #ifdef CONFIG_INET 1372 1373 void __sk_defer_free_flush(struct sock *sk); 1373 1374 1374 1375 static inline void sk_defer_free_flush(struct sock *sk) ··· 1378 1377 return; 1379 1378 __sk_defer_free_flush(sk); 1380 1379 } 1380 + #else 1381 + static inline void sk_defer_free_flush(struct sock *sk) {} 1382 + #endif 1381 1383 1382 1384 int tcp_filter(struct sock *sk, struct sk_buff *skb); 1383 1385 void tcp_set_state(struct sock *sk, int state);
+1 -1
include/trace/events/skb.h
··· 14 14 EM(SKB_DROP_REASON_NO_SOCKET, NO_SOCKET) \ 15 15 EM(SKB_DROP_REASON_PKT_TOO_SMALL, PKT_TOO_SMALL) \ 16 16 EM(SKB_DROP_REASON_TCP_CSUM, TCP_CSUM) \ 17 - EM(SKB_DROP_REASON_TCP_FILTER, TCP_FILTER) \ 17 + EM(SKB_DROP_REASON_SOCKET_FILTER, SOCKET_FILTER) \ 18 18 EM(SKB_DROP_REASON_UDP_CSUM, UDP_CSUM) \ 19 19 EMe(SKB_DROP_REASON_MAX, MAX) 20 20
+45 -25
include/trace/events/sunrpc.h
··· 794 794 795 795 RPC_SHOW_SOCK 796 796 797 + 798 + #include <trace/events/net_probe_common.h> 799 + 797 800 /* 798 801 * Now redefine the EM() and EMe() macros to map the enums to the strings 799 802 * that will be printed in the output. ··· 819 816 __field(unsigned int, socket_state) 820 817 __field(unsigned int, sock_state) 821 818 __field(unsigned long long, ino) 822 - __string(dstaddr, 823 - xprt->address_strings[RPC_DISPLAY_ADDR]) 824 - __string(dstport, 825 - xprt->address_strings[RPC_DISPLAY_PORT]) 819 + __array(__u8, saddr, sizeof(struct sockaddr_in6)) 820 + __array(__u8, daddr, sizeof(struct sockaddr_in6)) 826 821 ), 827 822 828 823 TP_fast_assign( 829 824 struct inode *inode = SOCK_INODE(socket); 825 + const struct sock *sk = socket->sk; 826 + const struct inet_sock *inet = inet_sk(sk); 827 + 828 + memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 829 + memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 830 + 831 + TP_STORE_ADDR_PORTS(__entry, inet, sk); 832 + 830 833 __entry->socket_state = socket->state; 831 834 __entry->sock_state = socket->sk->sk_state; 832 835 __entry->ino = (unsigned long long)inode->i_ino; 833 - __assign_str(dstaddr, 834 - xprt->address_strings[RPC_DISPLAY_ADDR]); 835 - __assign_str(dstport, 836 - xprt->address_strings[RPC_DISPLAY_PORT]); 836 + 837 837 ), 838 838 839 839 TP_printk( 840 - "socket:[%llu] dstaddr=%s/%s " 840 + "socket:[%llu] srcaddr=%pISpc dstaddr=%pISpc " 841 841 "state=%u (%s) sk_state=%u (%s)", 842 - __entry->ino, __get_str(dstaddr), __get_str(dstport), 842 + __entry->ino, 843 + __entry->saddr, 844 + __entry->daddr, 843 845 __entry->socket_state, 844 846 rpc_show_socket_state(__entry->socket_state), 845 847 __entry->sock_state, ··· 874 866 __field(unsigned int, socket_state) 875 867 __field(unsigned int, sock_state) 876 868 __field(unsigned long long, ino) 877 - __string(dstaddr, 878 - xprt->address_strings[RPC_DISPLAY_ADDR]) 879 - __string(dstport, 880 - xprt->address_strings[RPC_DISPLAY_PORT]) 869 + __array(__u8, saddr, sizeof(struct sockaddr_in6)) 870 + __array(__u8, daddr, sizeof(struct sockaddr_in6)) 881 871 ), 882 872 883 873 TP_fast_assign( 884 874 struct inode *inode = SOCK_INODE(socket); 875 + const struct sock *sk = socket->sk; 876 + const struct inet_sock *inet = inet_sk(sk); 877 + 878 + memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 879 + memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 880 + 881 + TP_STORE_ADDR_PORTS(__entry, inet, sk); 882 + 885 883 __entry->socket_state = socket->state; 886 884 __entry->sock_state = socket->sk->sk_state; 887 885 __entry->ino = (unsigned long long)inode->i_ino; 888 886 __entry->error = error; 889 - __assign_str(dstaddr, 890 - xprt->address_strings[RPC_DISPLAY_ADDR]); 891 - __assign_str(dstport, 892 - xprt->address_strings[RPC_DISPLAY_PORT]); 893 887 ), 894 888 895 889 TP_printk( 896 - "error=%d socket:[%llu] dstaddr=%s/%s " 890 + "error=%d socket:[%llu] srcaddr=%pISpc dstaddr=%pISpc " 897 891 "state=%u (%s) sk_state=%u (%s)", 898 892 __entry->error, 899 - __entry->ino, __get_str(dstaddr), __get_str(dstport), 893 + __entry->ino, 894 + __entry->saddr, 895 + __entry->daddr, 900 896 __entry->socket_state, 901 897 rpc_show_socket_state(__entry->socket_state), 902 898 __entry->sock_state, ··· 965 953 { BIT(XPRT_REMOVE), "REMOVE" }, \ 966 954 { BIT(XPRT_CONGESTED), "CONGESTED" }, \ 967 955 { BIT(XPRT_CWND_WAIT), "CWND_WAIT" }, \ 968 - { BIT(XPRT_WRITE_SPACE), "WRITE_SPACE" }) 956 + { BIT(XPRT_WRITE_SPACE), "WRITE_SPACE" }, \ 957 + { BIT(XPRT_SND_IS_COOKIE), "SND_IS_COOKIE" }) 969 958 970 959 DECLARE_EVENT_CLASS(rpc_xprt_lifetime_class, 971 960 TP_PROTO( ··· 1163 1150 __entry->task_id = -1; 1164 1151 __entry->client_id = -1; 1165 1152 } 1166 - __entry->snd_task_id = xprt->snd_task ? 1167 - xprt->snd_task->tk_pid : -1; 1153 + if (xprt->snd_task && 1154 + !test_bit(XPRT_SND_IS_COOKIE, &xprt->state)) 1155 + __entry->snd_task_id = xprt->snd_task->tk_pid; 1156 + else 1157 + __entry->snd_task_id = -1; 1168 1158 ), 1169 1159 1170 1160 TP_printk(SUNRPC_TRACE_TASK_SPECIFIER ··· 1212 1196 __entry->task_id = -1; 1213 1197 __entry->client_id = -1; 1214 1198 } 1215 - __entry->snd_task_id = xprt->snd_task ? 1216 - xprt->snd_task->tk_pid : -1; 1199 + if (xprt->snd_task && 1200 + !test_bit(XPRT_SND_IS_COOKIE, &xprt->state)) 1201 + __entry->snd_task_id = xprt->snd_task->tk_pid; 1202 + else 1203 + __entry->snd_task_id = -1; 1204 + 1217 1205 __entry->cong = xprt->cong; 1218 1206 __entry->cwnd = xprt->cwnd; 1219 1207 __entry->wait = test_bit(XPRT_CWND_WAIT, &xprt->state);
+3 -2
include/trace/perf.h
··· 23 23 24 24 #undef __get_rel_dynamic_array 25 25 #define __get_rel_dynamic_array(field) \ 26 - ((void *)(&__entry->__rel_loc_##field) + \ 27 - sizeof(__entry->__rel_loc_##field) + \ 26 + ((void *)__entry + \ 27 + offsetof(typeof(*__entry), __rel_loc_##field) + \ 28 + sizeof(__entry->__rel_loc_##field) + \ 28 29 (__entry->__rel_loc_##field & 0xffff)) 29 30 30 31 #undef __get_rel_dynamic_array_len
+5 -4
include/trace/trace_events.h
··· 128 128 struct trace_event_raw_##name { \ 129 129 struct trace_entry ent; \ 130 130 tstruct \ 131 - char __data[0]; \ 131 + char __data[]; \ 132 132 }; \ 133 133 \ 134 134 static struct trace_event_class event_class_##name; ··· 318 318 #define __get_str(field) ((char *)__get_dynamic_array(field)) 319 319 320 320 #undef __get_rel_dynamic_array 321 - #define __get_rel_dynamic_array(field) \ 322 - ((void *)(&__entry->__rel_loc_##field) + \ 323 - sizeof(__entry->__rel_loc_##field) + \ 321 + #define __get_rel_dynamic_array(field) \ 322 + ((void *)__entry + \ 323 + offsetof(typeof(*__entry), __rel_loc_##field) + \ 324 + sizeof(__entry->__rel_loc_##field) + \ 324 325 (__entry->__rel_loc_##field & 0xffff)) 325 326 326 327 #undef __get_rel_dynamic_array_len
+35
include/uapi/linux/cyclades.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 + 3 + #ifndef _UAPI_LINUX_CYCLADES_H 4 + #define _UAPI_LINUX_CYCLADES_H 5 + 6 + #warning "Support for features provided by this header has been removed" 7 + #warning "Please consider updating your code" 8 + 9 + struct cyclades_monitor { 10 + unsigned long int_count; 11 + unsigned long char_count; 12 + unsigned long char_max; 13 + unsigned long char_last; 14 + }; 15 + 16 + #define CYGETMON 0x435901 17 + #define CYGETTHRESH 0x435902 18 + #define CYSETTHRESH 0x435903 19 + #define CYGETDEFTHRESH 0x435904 20 + #define CYSETDEFTHRESH 0x435905 21 + #define CYGETTIMEOUT 0x435906 22 + #define CYSETTIMEOUT 0x435907 23 + #define CYGETDEFTIMEOUT 0x435908 24 + #define CYSETDEFTIMEOUT 0x435909 25 + #define CYSETRFLOW 0x43590a 26 + #define CYGETRFLOW 0x43590b 27 + #define CYSETRTSDTR_INV 0x43590c 28 + #define CYGETRTSDTR_INV 0x43590d 29 + #define CYZSETPOLLCYCLE 0x43590e 30 + #define CYZGETPOLLCYCLE 0x43590f 31 + #define CYGETCD1400VER 0x435910 32 + #define CYSETWAIT 0x435912 33 + #define CYGETWAIT 0x435913 34 + 35 + #endif /* _UAPI_LINUX_CYCLADES_H */
+1
include/uapi/linux/kvm.h
··· 1133 1133 #define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206 1134 1134 #define KVM_CAP_VM_GPA_BITS 207 1135 1135 #define KVM_CAP_XSAVE2 208 1136 + #define KVM_CAP_SYS_ATTRIBUTES 209 1136 1137 1137 1138 #ifdef KVM_CAP_IRQ_ROUTING 1138 1139
+3 -2
kernel/bpf/stackmap.c
··· 472 472 u32, size, u64, flags) 473 473 { 474 474 struct pt_regs *regs; 475 - long res; 475 + long res = -EINVAL; 476 476 477 477 if (!try_get_task_stack(task)) 478 478 return -EFAULT; 479 479 480 480 regs = task_pt_regs(task); 481 - res = __bpf_get_stack(regs, task, NULL, buf, size, flags); 481 + if (regs) 482 + res = __bpf_get_stack(regs, task, NULL, buf, size, flags); 482 483 put_task_stack(task); 483 484 484 485 return res;
+8 -3
kernel/cgroup/cgroup.c
··· 3643 3643 cgroup_get(cgrp); 3644 3644 cgroup_kn_unlock(of->kn); 3645 3645 3646 + /* Allow only one trigger per file descriptor */ 3647 + if (ctx->psi.trigger) { 3648 + cgroup_put(cgrp); 3649 + return -EBUSY; 3650 + } 3651 + 3646 3652 psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; 3647 3653 new = psi_trigger_create(psi, buf, nbytes, res); 3648 3654 if (IS_ERR(new)) { ··· 3656 3650 return PTR_ERR(new); 3657 3651 } 3658 3652 3659 - psi_trigger_replace(&ctx->psi.trigger, new); 3660 - 3653 + smp_store_release(&ctx->psi.trigger, new); 3661 3654 cgroup_put(cgrp); 3662 3655 3663 3656 return nbytes; ··· 3695 3690 { 3696 3691 struct cgroup_file_ctx *ctx = of->priv; 3697 3692 3698 - psi_trigger_replace(&ctx->psi.trigger, NULL); 3693 + psi_trigger_destroy(ctx->psi.trigger); 3699 3694 } 3700 3695 3701 3696 bool cgroup_psi_enabled(void)
+167 -106
kernel/events/core.c
··· 674 674 WRITE_ONCE(event->state, state); 675 675 } 676 676 677 + /* 678 + * UP store-release, load-acquire 679 + */ 680 + 681 + #define __store_release(ptr, val) \ 682 + do { \ 683 + barrier(); \ 684 + WRITE_ONCE(*(ptr), (val)); \ 685 + } while (0) 686 + 687 + #define __load_acquire(ptr) \ 688 + ({ \ 689 + __unqual_scalar_typeof(*(ptr)) ___p = READ_ONCE(*(ptr)); \ 690 + barrier(); \ 691 + ___p; \ 692 + }) 693 + 677 694 #ifdef CONFIG_CGROUP_PERF 678 695 679 696 static inline bool ··· 736 719 return t->time; 737 720 } 738 721 739 - static inline void __update_cgrp_time(struct perf_cgroup *cgrp) 722 + static inline u64 perf_cgroup_event_time_now(struct perf_event *event, u64 now) 740 723 { 741 - struct perf_cgroup_info *info; 742 - u64 now; 724 + struct perf_cgroup_info *t; 743 725 744 - now = perf_clock(); 745 - 746 - info = this_cpu_ptr(cgrp->info); 747 - 748 - info->time += now - info->timestamp; 749 - info->timestamp = now; 726 + t = per_cpu_ptr(event->cgrp->info, event->cpu); 727 + if (!__load_acquire(&t->active)) 728 + return t->time; 729 + now += READ_ONCE(t->timeoffset); 730 + return now; 750 731 } 751 732 752 - static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx) 733 + static inline void __update_cgrp_time(struct perf_cgroup_info *info, u64 now, bool adv) 734 + { 735 + if (adv) 736 + info->time += now - info->timestamp; 737 + info->timestamp = now; 738 + /* 739 + * see update_context_time() 740 + */ 741 + WRITE_ONCE(info->timeoffset, info->time - info->timestamp); 742 + } 743 + 744 + static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx, bool final) 753 745 { 754 746 struct perf_cgroup *cgrp = cpuctx->cgrp; 755 747 struct cgroup_subsys_state *css; 748 + struct perf_cgroup_info *info; 756 749 757 750 if (cgrp) { 751 + u64 now = perf_clock(); 752 + 758 753 for (css = &cgrp->css; css; css = css->parent) { 759 754 cgrp = container_of(css, struct perf_cgroup, css); 760 - __update_cgrp_time(cgrp); 755 + info = this_cpu_ptr(cgrp->info); 756 + 757 + __update_cgrp_time(info, now, true); 758 + if (final) 759 + __store_release(&info->active, 0); 761 760 } 762 761 } 763 762 } 764 763 765 764 static inline void update_cgrp_time_from_event(struct perf_event *event) 766 765 { 766 + struct perf_cgroup_info *info; 767 767 struct perf_cgroup *cgrp; 768 768 769 769 /* ··· 794 760 /* 795 761 * Do not update time when cgroup is not active 796 762 */ 797 - if (cgroup_is_descendant(cgrp->css.cgroup, event->cgrp->css.cgroup)) 798 - __update_cgrp_time(event->cgrp); 763 + if (cgroup_is_descendant(cgrp->css.cgroup, event->cgrp->css.cgroup)) { 764 + info = this_cpu_ptr(event->cgrp->info); 765 + __update_cgrp_time(info, perf_clock(), true); 766 + } 799 767 } 800 768 801 769 static inline void ··· 821 785 for (css = &cgrp->css; css; css = css->parent) { 822 786 cgrp = container_of(css, struct perf_cgroup, css); 823 787 info = this_cpu_ptr(cgrp->info); 824 - info->timestamp = ctx->timestamp; 788 + __update_cgrp_time(info, ctx->timestamp, false); 789 + __store_release(&info->active, 1); 825 790 } 826 791 } 827 792 ··· 1019 982 } 1020 983 1021 984 static inline void 1022 - perf_cgroup_set_shadow_time(struct perf_event *event, u64 now) 1023 - { 1024 - struct perf_cgroup_info *t; 1025 - t = per_cpu_ptr(event->cgrp->info, event->cpu); 1026 - event->shadow_ctx_time = now - t->timestamp; 1027 - } 1028 - 1029 - static inline void 1030 985 perf_cgroup_event_enable(struct perf_event *event, struct perf_event_context *ctx) 1031 986 { 1032 987 struct perf_cpu_context *cpuctx; ··· 1095 1066 { 1096 1067 } 1097 1068 1098 - static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx) 1069 + static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx, 1070 + bool final) 1099 1071 { 1100 1072 } 1101 1073 ··· 1128 1098 { 1129 1099 } 1130 1100 1131 - static inline void 1132 - perf_cgroup_set_shadow_time(struct perf_event *event, u64 now) 1101 + static inline u64 perf_cgroup_event_time(struct perf_event *event) 1133 1102 { 1103 + return 0; 1134 1104 } 1135 1105 1136 - static inline u64 perf_cgroup_event_time(struct perf_event *event) 1106 + static inline u64 perf_cgroup_event_time_now(struct perf_event *event, u64 now) 1137 1107 { 1138 1108 return 0; 1139 1109 } ··· 1555 1525 /* 1556 1526 * Update the record of the current time in a context. 1557 1527 */ 1558 - static void update_context_time(struct perf_event_context *ctx) 1528 + static void __update_context_time(struct perf_event_context *ctx, bool adv) 1559 1529 { 1560 1530 u64 now = perf_clock(); 1561 1531 1562 - ctx->time += now - ctx->timestamp; 1532 + if (adv) 1533 + ctx->time += now - ctx->timestamp; 1563 1534 ctx->timestamp = now; 1535 + 1536 + /* 1537 + * The above: time' = time + (now - timestamp), can be re-arranged 1538 + * into: time` = now + (time - timestamp), which gives a single value 1539 + * offset to compute future time without locks on. 1540 + * 1541 + * See perf_event_time_now(), which can be used from NMI context where 1542 + * it's (obviously) not possible to acquire ctx->lock in order to read 1543 + * both the above values in a consistent manner. 1544 + */ 1545 + WRITE_ONCE(ctx->timeoffset, ctx->time - ctx->timestamp); 1546 + } 1547 + 1548 + static void update_context_time(struct perf_event_context *ctx) 1549 + { 1550 + __update_context_time(ctx, true); 1564 1551 } 1565 1552 1566 1553 static u64 perf_event_time(struct perf_event *event) 1567 1554 { 1568 1555 struct perf_event_context *ctx = event->ctx; 1569 1556 1557 + if (unlikely(!ctx)) 1558 + return 0; 1559 + 1570 1560 if (is_cgroup_event(event)) 1571 1561 return perf_cgroup_event_time(event); 1572 1562 1573 - return ctx ? ctx->time : 0; 1563 + return ctx->time; 1564 + } 1565 + 1566 + static u64 perf_event_time_now(struct perf_event *event, u64 now) 1567 + { 1568 + struct perf_event_context *ctx = event->ctx; 1569 + 1570 + if (unlikely(!ctx)) 1571 + return 0; 1572 + 1573 + if (is_cgroup_event(event)) 1574 + return perf_cgroup_event_time_now(event, now); 1575 + 1576 + if (!(__load_acquire(&ctx->is_active) & EVENT_TIME)) 1577 + return ctx->time; 1578 + 1579 + now += READ_ONCE(ctx->timeoffset); 1580 + return now; 1574 1581 } 1575 1582 1576 1583 static enum event_type_t get_event_type(struct perf_event *event) ··· 2417 2350 2418 2351 if (ctx->is_active & EVENT_TIME) { 2419 2352 update_context_time(ctx); 2420 - update_cgrp_time_from_cpuctx(cpuctx); 2353 + update_cgrp_time_from_cpuctx(cpuctx, false); 2421 2354 } 2422 2355 2423 2356 event_sched_out(event, cpuctx, ctx); ··· 2428 2361 list_del_event(event, ctx); 2429 2362 2430 2363 if (!ctx->nr_events && ctx->is_active) { 2364 + if (ctx == &cpuctx->ctx) 2365 + update_cgrp_time_from_cpuctx(cpuctx, true); 2366 + 2431 2367 ctx->is_active = 0; 2432 2368 ctx->rotate_necessary = 0; 2433 2369 if (ctx->task) { ··· 2462 2392 * event_function_call() user. 2463 2393 */ 2464 2394 raw_spin_lock_irq(&ctx->lock); 2465 - if (!ctx->is_active) { 2395 + /* 2396 + * Cgroup events are per-cpu events, and must IPI because of 2397 + * cgrp_cpuctx_list. 2398 + */ 2399 + if (!ctx->is_active && !is_cgroup_event(event)) { 2466 2400 __perf_remove_from_context(event, __get_cpu_context(ctx), 2467 2401 ctx, (void *)flags); 2468 2402 raw_spin_unlock_irq(&ctx->lock); ··· 2556 2482 irq_work_queue(&event->pending); 2557 2483 } 2558 2484 2559 - static void perf_set_shadow_time(struct perf_event *event, 2560 - struct perf_event_context *ctx) 2561 - { 2562 - /* 2563 - * use the correct time source for the time snapshot 2564 - * 2565 - * We could get by without this by leveraging the 2566 - * fact that to get to this function, the caller 2567 - * has most likely already called update_context_time() 2568 - * and update_cgrp_time_xx() and thus both timestamp 2569 - * are identical (or very close). Given that tstamp is, 2570 - * already adjusted for cgroup, we could say that: 2571 - * tstamp - ctx->timestamp 2572 - * is equivalent to 2573 - * tstamp - cgrp->timestamp. 2574 - * 2575 - * Then, in perf_output_read(), the calculation would 2576 - * work with no changes because: 2577 - * - event is guaranteed scheduled in 2578 - * - no scheduled out in between 2579 - * - thus the timestamp would be the same 2580 - * 2581 - * But this is a bit hairy. 2582 - * 2583 - * So instead, we have an explicit cgroup call to remain 2584 - * within the time source all along. We believe it 2585 - * is cleaner and simpler to understand. 2586 - */ 2587 - if (is_cgroup_event(event)) 2588 - perf_cgroup_set_shadow_time(event, event->tstamp); 2589 - else 2590 - event->shadow_ctx_time = event->tstamp - ctx->timestamp; 2591 - } 2592 - 2593 2485 #define MAX_INTERRUPTS (~0ULL) 2594 2486 2595 2487 static void perf_log_throttle(struct perf_event *event, int enable); ··· 2595 2555 } 2596 2556 2597 2557 perf_pmu_disable(event->pmu); 2598 - 2599 - perf_set_shadow_time(event, ctx); 2600 2558 2601 2559 perf_log_itrace_start(event); 2602 2560 ··· 2899 2861 * perf_event_attr::disabled events will not run and can be initialized 2900 2862 * without IPI. Except when this is the first event for the context, in 2901 2863 * that case we need the magic of the IPI to set ctx->is_active. 2864 + * Similarly, cgroup events for the context also needs the IPI to 2865 + * manipulate the cgrp_cpuctx_list. 2902 2866 * 2903 2867 * The IOC_ENABLE that is sure to follow the creation of a disabled 2904 2868 * event will issue the IPI and reprogram the hardware. 2905 2869 */ 2906 - if (__perf_effective_state(event) == PERF_EVENT_STATE_OFF && ctx->nr_events) { 2870 + if (__perf_effective_state(event) == PERF_EVENT_STATE_OFF && 2871 + ctx->nr_events && !is_cgroup_event(event)) { 2907 2872 raw_spin_lock_irq(&ctx->lock); 2908 2873 if (ctx->task == TASK_TOMBSTONE) { 2909 2874 raw_spin_unlock_irq(&ctx->lock); ··· 3292 3251 return; 3293 3252 } 3294 3253 3295 - ctx->is_active &= ~event_type; 3296 - if (!(ctx->is_active & EVENT_ALL)) 3297 - ctx->is_active = 0; 3298 - 3299 - if (ctx->task) { 3300 - WARN_ON_ONCE(cpuctx->task_ctx != ctx); 3301 - if (!ctx->is_active) 3302 - cpuctx->task_ctx = NULL; 3303 - } 3304 - 3305 3254 /* 3306 3255 * Always update time if it was set; not only when it changes. 3307 3256 * Otherwise we can 'forget' to update time for any but the last ··· 3305 3274 if (is_active & EVENT_TIME) { 3306 3275 /* update (and stop) ctx time */ 3307 3276 update_context_time(ctx); 3308 - update_cgrp_time_from_cpuctx(cpuctx); 3277 + update_cgrp_time_from_cpuctx(cpuctx, ctx == &cpuctx->ctx); 3278 + /* 3279 + * CPU-release for the below ->is_active store, 3280 + * see __load_acquire() in perf_event_time_now() 3281 + */ 3282 + barrier(); 3283 + } 3284 + 3285 + ctx->is_active &= ~event_type; 3286 + if (!(ctx->is_active & EVENT_ALL)) 3287 + ctx->is_active = 0; 3288 + 3289 + if (ctx->task) { 3290 + WARN_ON_ONCE(cpuctx->task_ctx != ctx); 3291 + if (!ctx->is_active) 3292 + cpuctx->task_ctx = NULL; 3309 3293 } 3310 3294 3311 3295 is_active ^= ctx->is_active; /* changed bits */ ··· 3757 3711 return 0; 3758 3712 } 3759 3713 3714 + /* 3715 + * Because the userpage is strictly per-event (there is no concept of context, 3716 + * so there cannot be a context indirection), every userpage must be updated 3717 + * when context time starts :-( 3718 + * 3719 + * IOW, we must not miss EVENT_TIME edges. 3720 + */ 3760 3721 static inline bool event_update_userpage(struct perf_event *event) 3761 3722 { 3762 3723 if (likely(!atomic_read(&event->mmap_count))) 3763 3724 return false; 3764 3725 3765 3726 perf_event_update_time(event); 3766 - perf_set_shadow_time(event, event->ctx); 3767 3727 perf_event_update_userpage(event); 3768 3728 3769 3729 return true; ··· 3853 3801 struct task_struct *task) 3854 3802 { 3855 3803 int is_active = ctx->is_active; 3856 - u64 now; 3857 3804 3858 3805 lockdep_assert_held(&ctx->lock); 3859 3806 3860 3807 if (likely(!ctx->nr_events)) 3861 3808 return; 3809 + 3810 + if (is_active ^ EVENT_TIME) { 3811 + /* start ctx time */ 3812 + __update_context_time(ctx, false); 3813 + perf_cgroup_set_timestamp(task, ctx); 3814 + /* 3815 + * CPU-release for the below ->is_active store, 3816 + * see __load_acquire() in perf_event_time_now() 3817 + */ 3818 + barrier(); 3819 + } 3862 3820 3863 3821 ctx->is_active |= (event_type | EVENT_TIME); 3864 3822 if (ctx->task) { ··· 3879 3817 } 3880 3818 3881 3819 is_active ^= ctx->is_active; /* changed bits */ 3882 - 3883 - if (is_active & EVENT_TIME) { 3884 - /* start ctx time */ 3885 - now = perf_clock(); 3886 - ctx->timestamp = now; 3887 - perf_cgroup_set_timestamp(task, ctx); 3888 - } 3889 3820 3890 3821 /* 3891 3822 * First go through the list and put on any pinned groups ··· 4473 4418 return local64_read(&event->count) + atomic64_read(&event->child_count); 4474 4419 } 4475 4420 4421 + static void calc_timer_values(struct perf_event *event, 4422 + u64 *now, 4423 + u64 *enabled, 4424 + u64 *running) 4425 + { 4426 + u64 ctx_time; 4427 + 4428 + *now = perf_clock(); 4429 + ctx_time = perf_event_time_now(event, *now); 4430 + __perf_update_times(event, ctx_time, enabled, running); 4431 + } 4432 + 4476 4433 /* 4477 4434 * NMI-safe method to read a local event, that is an event that 4478 4435 * is: ··· 4544 4477 4545 4478 *value = local64_read(&event->count); 4546 4479 if (enabled || running) { 4547 - u64 now = event->shadow_ctx_time + perf_clock(); 4548 - u64 __enabled, __running; 4480 + u64 __enabled, __running, __now;; 4549 4481 4550 - __perf_update_times(event, now, &__enabled, &__running); 4482 + calc_timer_values(event, &__now, &__enabled, &__running); 4551 4483 if (enabled) 4552 4484 *enabled = __enabled; 4553 4485 if (running) ··· 5868 5802 return event->pmu->event_idx(event); 5869 5803 } 5870 5804 5871 - static void calc_timer_values(struct perf_event *event, 5872 - u64 *now, 5873 - u64 *enabled, 5874 - u64 *running) 5875 - { 5876 - u64 ctx_time; 5877 - 5878 - *now = perf_clock(); 5879 - ctx_time = event->shadow_ctx_time + *now; 5880 - __perf_update_times(event, ctx_time, enabled, running); 5881 - } 5882 - 5883 5805 static void perf_event_init_userpage(struct perf_event *event) 5884 5806 { 5885 5807 struct perf_event_mmap_page *userpg; ··· 5992 5938 struct perf_buffer *old_rb = NULL; 5993 5939 unsigned long flags; 5994 5940 5941 + WARN_ON_ONCE(event->parent); 5942 + 5995 5943 if (event->rb) { 5996 5944 /* 5997 5945 * Should be impossible, we set this when removing ··· 6051 5995 { 6052 5996 struct perf_buffer *rb; 6053 5997 5998 + if (event->parent) 5999 + event = event->parent; 6000 + 6054 6001 rcu_read_lock(); 6055 6002 rb = rcu_dereference(event->rb); 6056 6003 if (rb) { ··· 6066 6007 struct perf_buffer *ring_buffer_get(struct perf_event *event) 6067 6008 { 6068 6009 struct perf_buffer *rb; 6010 + 6011 + if (event->parent) 6012 + event = event->parent; 6069 6013 6070 6014 rcu_read_lock(); 6071 6015 rb = rcu_dereference(event->rb); ··· 6415 6353 ring_buffer_attach(event, rb); 6416 6354 6417 6355 perf_event_update_time(event); 6418 - perf_set_shadow_time(event, event->ctx); 6419 6356 perf_event_init_userpage(event); 6420 6357 perf_event_update_userpage(event); 6421 6358 } else { ··· 6778 6717 if (WARN_ON_ONCE(READ_ONCE(sampler->oncpu) != smp_processor_id())) 6779 6718 goto out; 6780 6719 6781 - rb = ring_buffer_get(sampler->parent ? sampler->parent : sampler); 6720 + rb = ring_buffer_get(sampler); 6782 6721 if (!rb) 6783 6722 goto out; 6784 6723 ··· 6844 6783 if (WARN_ON_ONCE(!sampler || !data->aux_size)) 6845 6784 return; 6846 6785 6847 - rb = ring_buffer_get(sampler->parent ? sampler->parent : sampler); 6786 + rb = ring_buffer_get(sampler); 6848 6787 if (!rb) 6849 6788 return; 6850 6789
+7 -14
kernel/power/snapshot.c
··· 978 978 * Register a range of page frames the contents of which should not be saved 979 979 * during hibernation (to be used in the early initialization code). 980 980 */ 981 - void __init __register_nosave_region(unsigned long start_pfn, 982 - unsigned long end_pfn, int use_kmalloc) 981 + void __init register_nosave_region(unsigned long start_pfn, unsigned long end_pfn) 983 982 { 984 983 struct nosave_region *region; 985 984 ··· 994 995 goto Report; 995 996 } 996 997 } 997 - if (use_kmalloc) { 998 - /* During init, this shouldn't fail */ 999 - region = kmalloc(sizeof(struct nosave_region), GFP_KERNEL); 1000 - BUG_ON(!region); 1001 - } else { 1002 - /* This allocation cannot fail */ 1003 - region = memblock_alloc(sizeof(struct nosave_region), 1004 - SMP_CACHE_BYTES); 1005 - if (!region) 1006 - panic("%s: Failed to allocate %zu bytes\n", __func__, 1007 - sizeof(struct nosave_region)); 1008 - } 998 + /* This allocation cannot fail */ 999 + region = memblock_alloc(sizeof(struct nosave_region), 1000 + SMP_CACHE_BYTES); 1001 + if (!region) 1002 + panic("%s: Failed to allocate %zu bytes\n", __func__, 1003 + sizeof(struct nosave_region)); 1009 1004 region->start_pfn = start_pfn; 1010 1005 region->end_pfn = end_pfn; 1011 1006 list_add_tail(&region->list, &nosave_regions);
+4 -7
kernel/power/wakelock.c
··· 39 39 { 40 40 struct rb_node *node; 41 41 struct wakelock *wl; 42 - char *str = buf; 43 - char *end = buf + PAGE_SIZE; 42 + int len = 0; 44 43 45 44 mutex_lock(&wakelocks_lock); 46 45 47 46 for (node = rb_first(&wakelocks_tree); node; node = rb_next(node)) { 48 47 wl = rb_entry(node, struct wakelock, node); 49 48 if (wl->ws->active == show_active) 50 - str += scnprintf(str, end - str, "%s ", wl->name); 49 + len += sysfs_emit_at(buf, len, "%s ", wl->name); 51 50 } 52 - if (str > buf) 53 - str--; 54 51 55 - str += scnprintf(str, end - str, "\n"); 52 + len += sysfs_emit_at(buf, len, "\n"); 56 53 57 54 mutex_unlock(&wakelocks_lock); 58 - return (str - buf); 55 + return len; 59 56 } 60 57 61 58 #if CONFIG_PM_WAKELOCKS_LIMIT > 0
+8 -4
kernel/rcu/tasks.h
··· 123 123 .call_func = call, \ 124 124 .rtpcpu = &rt_name ## __percpu, \ 125 125 .name = n, \ 126 - .percpu_enqueue_shift = ilog2(CONFIG_NR_CPUS), \ 126 + .percpu_enqueue_shift = ilog2(CONFIG_NR_CPUS) + 1, \ 127 127 .percpu_enqueue_lim = 1, \ 128 128 .percpu_dequeue_lim = 1, \ 129 129 .barrier_q_mutex = __MUTEX_INITIALIZER(rt_name.barrier_q_mutex), \ ··· 216 216 int cpu; 217 217 unsigned long flags; 218 218 int lim; 219 + int shift; 219 220 220 221 raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags); 221 222 if (rcu_task_enqueue_lim < 0) { ··· 230 229 231 230 if (lim > nr_cpu_ids) 232 231 lim = nr_cpu_ids; 233 - WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids / lim)); 232 + shift = ilog2(nr_cpu_ids / lim); 233 + if (((nr_cpu_ids - 1) >> shift) >= lim) 234 + shift++; 235 + WRITE_ONCE(rtp->percpu_enqueue_shift, shift); 234 236 WRITE_ONCE(rtp->percpu_dequeue_lim, lim); 235 237 smp_store_release(&rtp->percpu_enqueue_lim, lim); 236 238 for_each_possible_cpu(cpu) { ··· 302 298 if (unlikely(needadjust)) { 303 299 raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags); 304 300 if (rtp->percpu_enqueue_lim != nr_cpu_ids) { 305 - WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids)); 301 + WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids) + 1); 306 302 WRITE_ONCE(rtp->percpu_dequeue_lim, nr_cpu_ids); 307 303 smp_store_release(&rtp->percpu_enqueue_lim, nr_cpu_ids); 308 304 pr_info("Switching %s to per-CPU callback queuing.\n", rtp->name); ··· 417 413 if (rcu_task_cb_adjust && ncbs <= rcu_task_collapse_lim) { 418 414 raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags); 419 415 if (rtp->percpu_enqueue_lim > 1) { 420 - WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids)); 416 + WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids) + 1); 421 417 smp_store_release(&rtp->percpu_enqueue_lim, 1); 422 418 rtp->percpu_dequeue_gpseq = get_state_synchronize_rcu(); 423 419 pr_info("Starting switch %s to CPU-0 callback queuing.\n", rtp->name);
+4 -11
kernel/sched/core.c
··· 5822 5822 } 5823 5823 5824 5824 if (schedstat_enabled() && rq->core->core_forceidle_count) { 5825 - if (cookie) 5826 - rq->core->core_forceidle_start = rq_clock(rq->core); 5825 + rq->core->core_forceidle_start = rq_clock(rq->core); 5827 5826 rq->core->core_forceidle_occupation = occ; 5828 5827 } 5829 5828 ··· 8218 8219 8219 8220 if (spin_needbreak(lock) || resched) { 8220 8221 spin_unlock(lock); 8221 - if (resched) 8222 - preempt_schedule_common(); 8223 - else 8222 + if (!_cond_resched()) 8224 8223 cpu_relax(); 8225 8224 ret = 1; 8226 8225 spin_lock(lock); ··· 8236 8239 8237 8240 if (rwlock_needbreak(lock) || resched) { 8238 8241 read_unlock(lock); 8239 - if (resched) 8240 - preempt_schedule_common(); 8241 - else 8242 + if (!_cond_resched()) 8242 8243 cpu_relax(); 8243 8244 ret = 1; 8244 8245 read_lock(lock); ··· 8254 8259 8255 8260 if (rwlock_needbreak(lock) || resched) { 8256 8261 write_unlock(lock); 8257 - if (resched) 8258 - preempt_schedule_common(); 8259 - else 8262 + if (!_cond_resched()) 8260 8263 cpu_relax(); 8261 8264 ret = 1; 8262 8265 write_lock(lock);
+1 -1
kernel/sched/core_sched.c
··· 277 277 rq_i = cpu_rq(i); 278 278 p = rq_i->core_pick ?: rq_i->curr; 279 279 280 - if (!p->core_cookie) 280 + if (p == rq_i->idle) 281 281 continue; 282 282 283 283 __schedstat_add(p->stats.core_forceidle_sum, delta);
+77 -41
kernel/sched/fair.c
··· 3028 3028 static inline void 3029 3029 dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) 3030 3030 { 3031 - u32 divider = get_pelt_divider(&se->avg); 3032 3031 sub_positive(&cfs_rq->avg.load_avg, se->avg.load_avg); 3033 - cfs_rq->avg.load_sum = cfs_rq->avg.load_avg * divider; 3032 + sub_positive(&cfs_rq->avg.load_sum, se_weight(se) * se->avg.load_sum); 3033 + /* See update_cfs_rq_load_avg() */ 3034 + cfs_rq->avg.load_sum = max_t(u32, cfs_rq->avg.load_sum, 3035 + cfs_rq->avg.load_avg * PELT_MIN_DIVIDER); 3034 3036 } 3035 3037 #else 3036 3038 static inline void ··· 3383 3381 se->avg.last_update_time = n_last_update_time; 3384 3382 } 3385 3383 3386 - 3387 3384 /* 3388 3385 * When on migration a sched_entity joins/leaves the PELT hierarchy, we need to 3389 3386 * propagate its contribution. The key to this propagation is the invariant ··· 3450 3449 * XXX: only do this for the part of runnable > running ? 3451 3450 * 3452 3451 */ 3453 - 3454 3452 static inline void 3455 3453 update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) 3456 3454 { 3457 - long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; 3458 - u32 divider; 3455 + long delta_sum, delta_avg = gcfs_rq->avg.util_avg - se->avg.util_avg; 3456 + u32 new_sum, divider; 3459 3457 3460 3458 /* Nothing to update */ 3461 - if (!delta) 3459 + if (!delta_avg) 3462 3460 return; 3463 3461 3464 3462 /* ··· 3466 3466 */ 3467 3467 divider = get_pelt_divider(&cfs_rq->avg); 3468 3468 3469 + 3469 3470 /* Set new sched_entity's utilization */ 3470 3471 se->avg.util_avg = gcfs_rq->avg.util_avg; 3471 - se->avg.util_sum = se->avg.util_avg * divider; 3472 + new_sum = se->avg.util_avg * divider; 3473 + delta_sum = (long)new_sum - (long)se->avg.util_sum; 3474 + se->avg.util_sum = new_sum; 3472 3475 3473 3476 /* Update parent cfs_rq utilization */ 3474 - add_positive(&cfs_rq->avg.util_avg, delta); 3475 - cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider; 3477 + add_positive(&cfs_rq->avg.util_avg, delta_avg); 3478 + add_positive(&cfs_rq->avg.util_sum, delta_sum); 3479 + 3480 + /* See update_cfs_rq_load_avg() */ 3481 + cfs_rq->avg.util_sum = max_t(u32, cfs_rq->avg.util_sum, 3482 + cfs_rq->avg.util_avg * PELT_MIN_DIVIDER); 3476 3483 } 3477 3484 3478 3485 static inline void 3479 3486 update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) 3480 3487 { 3481 - long delta = gcfs_rq->avg.runnable_avg - se->avg.runnable_avg; 3482 - u32 divider; 3488 + long delta_sum, delta_avg = gcfs_rq->avg.runnable_avg - se->avg.runnable_avg; 3489 + u32 new_sum, divider; 3483 3490 3484 3491 /* Nothing to update */ 3485 - if (!delta) 3492 + if (!delta_avg) 3486 3493 return; 3487 3494 3488 3495 /* ··· 3500 3493 3501 3494 /* Set new sched_entity's runnable */ 3502 3495 se->avg.runnable_avg = gcfs_rq->avg.runnable_avg; 3503 - se->avg.runnable_sum = se->avg.runnable_avg * divider; 3496 + new_sum = se->avg.runnable_avg * divider; 3497 + delta_sum = (long)new_sum - (long)se->avg.runnable_sum; 3498 + se->avg.runnable_sum = new_sum; 3504 3499 3505 3500 /* Update parent cfs_rq runnable */ 3506 - add_positive(&cfs_rq->avg.runnable_avg, delta); 3507 - cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider; 3501 + add_positive(&cfs_rq->avg.runnable_avg, delta_avg); 3502 + add_positive(&cfs_rq->avg.runnable_sum, delta_sum); 3503 + /* See update_cfs_rq_load_avg() */ 3504 + cfs_rq->avg.runnable_sum = max_t(u32, cfs_rq->avg.runnable_sum, 3505 + cfs_rq->avg.runnable_avg * PELT_MIN_DIVIDER); 3508 3506 } 3509 3507 3510 3508 static inline void 3511 3509 update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) 3512 3510 { 3513 - long delta, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum; 3511 + long delta_avg, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum; 3514 3512 unsigned long load_avg; 3515 3513 u64 load_sum = 0; 3514 + s64 delta_sum; 3516 3515 u32 divider; 3517 3516 3518 3517 if (!runnable_sum) ··· 3545 3532 * assuming all tasks are equally runnable. 3546 3533 */ 3547 3534 if (scale_load_down(gcfs_rq->load.weight)) { 3548 - load_sum = div_s64(gcfs_rq->avg.load_sum, 3535 + load_sum = div_u64(gcfs_rq->avg.load_sum, 3549 3536 scale_load_down(gcfs_rq->load.weight)); 3550 3537 } 3551 3538 ··· 3562 3549 running_sum = se->avg.util_sum >> SCHED_CAPACITY_SHIFT; 3563 3550 runnable_sum = max(runnable_sum, running_sum); 3564 3551 3565 - load_sum = (s64)se_weight(se) * runnable_sum; 3566 - load_avg = div_s64(load_sum, divider); 3552 + load_sum = se_weight(se) * runnable_sum; 3553 + load_avg = div_u64(load_sum, divider); 3567 3554 3568 - se->avg.load_sum = runnable_sum; 3569 - 3570 - delta = load_avg - se->avg.load_avg; 3571 - if (!delta) 3555 + delta_avg = load_avg - se->avg.load_avg; 3556 + if (!delta_avg) 3572 3557 return; 3573 3558 3574 - se->avg.load_avg = load_avg; 3559 + delta_sum = load_sum - (s64)se_weight(se) * se->avg.load_sum; 3575 3560 3576 - add_positive(&cfs_rq->avg.load_avg, delta); 3577 - cfs_rq->avg.load_sum = cfs_rq->avg.load_avg * divider; 3561 + se->avg.load_sum = runnable_sum; 3562 + se->avg.load_avg = load_avg; 3563 + add_positive(&cfs_rq->avg.load_avg, delta_avg); 3564 + add_positive(&cfs_rq->avg.load_sum, delta_sum); 3565 + /* See update_cfs_rq_load_avg() */ 3566 + cfs_rq->avg.load_sum = max_t(u32, cfs_rq->avg.load_sum, 3567 + cfs_rq->avg.load_avg * PELT_MIN_DIVIDER); 3578 3568 } 3579 3569 3580 3570 static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum) ··· 3668 3652 * 3669 3653 * cfs_rq->avg is used for task_h_load() and update_cfs_share() for example. 3670 3654 * 3671 - * Returns true if the load decayed or we removed load. 3655 + * Return: true if the load decayed or we removed load. 3672 3656 * 3673 3657 * Since both these conditions indicate a changed cfs_rq->avg.load we should 3674 3658 * call update_tg_load_avg() when this function returns true. ··· 3693 3677 3694 3678 r = removed_load; 3695 3679 sub_positive(&sa->load_avg, r); 3696 - sa->load_sum = sa->load_avg * divider; 3680 + sub_positive(&sa->load_sum, r * divider); 3681 + /* See sa->util_sum below */ 3682 + sa->load_sum = max_t(u32, sa->load_sum, sa->load_avg * PELT_MIN_DIVIDER); 3697 3683 3698 3684 r = removed_util; 3699 3685 sub_positive(&sa->util_avg, r); 3700 - sa->util_sum = sa->util_avg * divider; 3686 + sub_positive(&sa->util_sum, r * divider); 3687 + /* 3688 + * Because of rounding, se->util_sum might ends up being +1 more than 3689 + * cfs->util_sum. Although this is not a problem by itself, detaching 3690 + * a lot of tasks with the rounding problem between 2 updates of 3691 + * util_avg (~1ms) can make cfs->util_sum becoming null whereas 3692 + * cfs_util_avg is not. 3693 + * Check that util_sum is still above its lower bound for the new 3694 + * util_avg. Given that period_contrib might have moved since the last 3695 + * sync, we are only sure that util_sum must be above or equal to 3696 + * util_avg * minimum possible divider 3697 + */ 3698 + sa->util_sum = max_t(u32, sa->util_sum, sa->util_avg * PELT_MIN_DIVIDER); 3701 3699 3702 3700 r = removed_runnable; 3703 3701 sub_positive(&sa->runnable_avg, r); 3704 - sa->runnable_sum = sa->runnable_avg * divider; 3702 + sub_positive(&sa->runnable_sum, r * divider); 3703 + /* See sa->util_sum above */ 3704 + sa->runnable_sum = max_t(u32, sa->runnable_sum, 3705 + sa->runnable_avg * PELT_MIN_DIVIDER); 3705 3706 3706 3707 /* 3707 3708 * removed_runnable is the unweighted version of removed_load so we ··· 3805 3772 */ 3806 3773 static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) 3807 3774 { 3808 - /* 3809 - * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. 3810 - * See ___update_load_avg() for details. 3811 - */ 3812 - u32 divider = get_pelt_divider(&cfs_rq->avg); 3813 - 3814 3775 dequeue_load_avg(cfs_rq, se); 3815 3776 sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); 3816 - cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider; 3777 + sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum); 3778 + /* See update_cfs_rq_load_avg() */ 3779 + cfs_rq->avg.util_sum = max_t(u32, cfs_rq->avg.util_sum, 3780 + cfs_rq->avg.util_avg * PELT_MIN_DIVIDER); 3781 + 3817 3782 sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg); 3818 - cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider; 3783 + sub_positive(&cfs_rq->avg.runnable_sum, se->avg.runnable_sum); 3784 + /* See update_cfs_rq_load_avg() */ 3785 + cfs_rq->avg.runnable_sum = max_t(u32, cfs_rq->avg.runnable_sum, 3786 + cfs_rq->avg.runnable_avg * PELT_MIN_DIVIDER); 3819 3787 3820 3788 add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum); 3821 3789 ··· 8573 8539 * 8574 8540 * If @sg does not have SMT siblings, only pull tasks if all of the SMT siblings 8575 8541 * of @dst_cpu are idle and @sg has lower priority. 8542 + * 8543 + * Return: true if @dst_cpu can pull tasks, false otherwise. 8576 8544 */ 8577 8545 static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds, 8578 8546 struct sg_lb_stats *sgs, ··· 8650 8614 /** 8651 8615 * update_sg_lb_stats - Update sched_group's statistics for load balancing. 8652 8616 * @env: The load balancing environment. 8617 + * @sds: Load-balancing data with statistics of the local group. 8653 8618 * @group: sched_group whose statistics are to be updated. 8654 8619 * @sgs: variable to hold the statistics for this group. 8655 8620 * @sg_status: Holds flag indicating the status of the sched_group ··· 9458 9421 /** 9459 9422 * find_busiest_group - Returns the busiest group within the sched_domain 9460 9423 * if there is an imbalance. 9424 + * @env: The load balancing environment. 9461 9425 * 9462 9426 * Also calculates the amount of runnable load which should be moved 9463 9427 * to restore balance. 9464 - * 9465 - * @env: The load balancing environment. 9466 9428 * 9467 9429 * Return: - The busiest group if imbalance exists. 9468 9430 */
+5 -4
kernel/sched/membarrier.c
··· 147 147 #endif 148 148 149 149 #ifdef CONFIG_RSEQ 150 - #define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ_BITMASK \ 150 + #define MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK \ 151 151 (MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ \ 152 - | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ_BITMASK) 152 + | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ) 153 153 #else 154 - #define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ_BITMASK 0 154 + #define MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK 0 155 155 #endif 156 156 157 157 #define MEMBARRIER_CMD_BITMASK \ ··· 159 159 | MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED \ 160 160 | MEMBARRIER_CMD_PRIVATE_EXPEDITED \ 161 161 | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED \ 162 - | MEMBARRIER_PRIVATE_EXPEDITED_SYNC_CORE_BITMASK) 162 + | MEMBARRIER_PRIVATE_EXPEDITED_SYNC_CORE_BITMASK \ 163 + | MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK) 163 164 164 165 static void ipi_mb(void *info) 165 166 {
+3 -1
kernel/sched/pelt.h
··· 37 37 } 38 38 #endif 39 39 40 + #define PELT_MIN_DIVIDER (LOAD_AVG_MAX - 1024) 41 + 40 42 static inline u32 get_pelt_divider(struct sched_avg *avg) 41 43 { 42 - return LOAD_AVG_MAX - 1024 + avg->period_contrib; 44 + return PELT_MIN_DIVIDER + avg->period_contrib; 43 45 } 44 46 45 47 static inline void cfs_se_util_change(struct sched_avg *avg)
+70 -75
kernel/sched/psi.c
··· 1082 1082 return 0; 1083 1083 } 1084 1084 1085 - static int psi_io_show(struct seq_file *m, void *v) 1086 - { 1087 - return psi_show(m, &psi_system, PSI_IO); 1088 - } 1089 - 1090 - static int psi_memory_show(struct seq_file *m, void *v) 1091 - { 1092 - return psi_show(m, &psi_system, PSI_MEM); 1093 - } 1094 - 1095 - static int psi_cpu_show(struct seq_file *m, void *v) 1096 - { 1097 - return psi_show(m, &psi_system, PSI_CPU); 1098 - } 1099 - 1100 - static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *)) 1101 - { 1102 - if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE)) 1103 - return -EPERM; 1104 - 1105 - return single_open(file, psi_show, NULL); 1106 - } 1107 - 1108 - static int psi_io_open(struct inode *inode, struct file *file) 1109 - { 1110 - return psi_open(file, psi_io_show); 1111 - } 1112 - 1113 - static int psi_memory_open(struct inode *inode, struct file *file) 1114 - { 1115 - return psi_open(file, psi_memory_show); 1116 - } 1117 - 1118 - static int psi_cpu_open(struct inode *inode, struct file *file) 1119 - { 1120 - return psi_open(file, psi_cpu_show); 1121 - } 1122 - 1123 1085 struct psi_trigger *psi_trigger_create(struct psi_group *group, 1124 1086 char *buf, size_t nbytes, enum psi_res res) 1125 1087 { ··· 1124 1162 t->event = 0; 1125 1163 t->last_event_time = 0; 1126 1164 init_waitqueue_head(&t->event_wait); 1127 - kref_init(&t->refcount); 1128 1165 1129 1166 mutex_lock(&group->trigger_lock); 1130 1167 ··· 1152 1191 return t; 1153 1192 } 1154 1193 1155 - static void psi_trigger_destroy(struct kref *ref) 1194 + void psi_trigger_destroy(struct psi_trigger *t) 1156 1195 { 1157 - struct psi_trigger *t = container_of(ref, struct psi_trigger, refcount); 1158 - struct psi_group *group = t->group; 1196 + struct psi_group *group; 1159 1197 struct task_struct *task_to_destroy = NULL; 1160 1198 1161 - if (static_branch_likely(&psi_disabled)) 1199 + /* 1200 + * We do not check psi_disabled since it might have been disabled after 1201 + * the trigger got created. 1202 + */ 1203 + if (!t) 1162 1204 return; 1163 1205 1206 + group = t->group; 1164 1207 /* 1165 1208 * Wakeup waiters to stop polling. Can happen if cgroup is deleted 1166 1209 * from under a polling process. ··· 1200 1235 mutex_unlock(&group->trigger_lock); 1201 1236 1202 1237 /* 1203 - * Wait for both *trigger_ptr from psi_trigger_replace and 1204 - * poll_task RCUs to complete their read-side critical sections 1205 - * before destroying the trigger and optionally the poll_task 1238 + * Wait for psi_schedule_poll_work RCU to complete its read-side 1239 + * critical section before destroying the trigger and optionally the 1240 + * poll_task. 1206 1241 */ 1207 1242 synchronize_rcu(); 1208 1243 /* ··· 1219 1254 kfree(t); 1220 1255 } 1221 1256 1222 - void psi_trigger_replace(void **trigger_ptr, struct psi_trigger *new) 1223 - { 1224 - struct psi_trigger *old = *trigger_ptr; 1225 - 1226 - if (static_branch_likely(&psi_disabled)) 1227 - return; 1228 - 1229 - rcu_assign_pointer(*trigger_ptr, new); 1230 - if (old) 1231 - kref_put(&old->refcount, psi_trigger_destroy); 1232 - } 1233 - 1234 1257 __poll_t psi_trigger_poll(void **trigger_ptr, 1235 1258 struct file *file, poll_table *wait) 1236 1259 { ··· 1228 1275 if (static_branch_likely(&psi_disabled)) 1229 1276 return DEFAULT_POLLMASK | EPOLLERR | EPOLLPRI; 1230 1277 1231 - rcu_read_lock(); 1232 - 1233 - t = rcu_dereference(*(void __rcu __force **)trigger_ptr); 1234 - if (!t) { 1235 - rcu_read_unlock(); 1278 + t = smp_load_acquire(trigger_ptr); 1279 + if (!t) 1236 1280 return DEFAULT_POLLMASK | EPOLLERR | EPOLLPRI; 1237 - } 1238 - kref_get(&t->refcount); 1239 - 1240 - rcu_read_unlock(); 1241 1281 1242 1282 poll_wait(file, &t->event_wait, wait); 1243 1283 1244 1284 if (cmpxchg(&t->event, 1, 0) == 1) 1245 1285 ret |= EPOLLPRI; 1246 1286 1247 - kref_put(&t->refcount, psi_trigger_destroy); 1248 - 1249 1287 return ret; 1288 + } 1289 + 1290 + #ifdef CONFIG_PROC_FS 1291 + static int psi_io_show(struct seq_file *m, void *v) 1292 + { 1293 + return psi_show(m, &psi_system, PSI_IO); 1294 + } 1295 + 1296 + static int psi_memory_show(struct seq_file *m, void *v) 1297 + { 1298 + return psi_show(m, &psi_system, PSI_MEM); 1299 + } 1300 + 1301 + static int psi_cpu_show(struct seq_file *m, void *v) 1302 + { 1303 + return psi_show(m, &psi_system, PSI_CPU); 1304 + } 1305 + 1306 + static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *)) 1307 + { 1308 + if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE)) 1309 + return -EPERM; 1310 + 1311 + return single_open(file, psi_show, NULL); 1312 + } 1313 + 1314 + static int psi_io_open(struct inode *inode, struct file *file) 1315 + { 1316 + return psi_open(file, psi_io_show); 1317 + } 1318 + 1319 + static int psi_memory_open(struct inode *inode, struct file *file) 1320 + { 1321 + return psi_open(file, psi_memory_show); 1322 + } 1323 + 1324 + static int psi_cpu_open(struct inode *inode, struct file *file) 1325 + { 1326 + return psi_open(file, psi_cpu_show); 1250 1327 } 1251 1328 1252 1329 static ssize_t psi_write(struct file *file, const char __user *user_buf, ··· 1299 1316 1300 1317 buf[buf_size - 1] = '\0'; 1301 1318 1302 - new = psi_trigger_create(&psi_system, buf, nbytes, res); 1303 - if (IS_ERR(new)) 1304 - return PTR_ERR(new); 1305 - 1306 1319 seq = file->private_data; 1320 + 1307 1321 /* Take seq->lock to protect seq->private from concurrent writes */ 1308 1322 mutex_lock(&seq->lock); 1309 - psi_trigger_replace(&seq->private, new); 1323 + 1324 + /* Allow only one trigger per file descriptor */ 1325 + if (seq->private) { 1326 + mutex_unlock(&seq->lock); 1327 + return -EBUSY; 1328 + } 1329 + 1330 + new = psi_trigger_create(&psi_system, buf, nbytes, res); 1331 + if (IS_ERR(new)) { 1332 + mutex_unlock(&seq->lock); 1333 + return PTR_ERR(new); 1334 + } 1335 + 1336 + smp_store_release(&seq->private, new); 1310 1337 mutex_unlock(&seq->lock); 1311 1338 1312 1339 return nbytes; ··· 1351 1358 { 1352 1359 struct seq_file *seq = file->private_data; 1353 1360 1354 - psi_trigger_replace(&seq->private, NULL); 1361 + psi_trigger_destroy(seq->private); 1355 1362 return single_release(inode, file); 1356 1363 } 1357 1364 ··· 1393 1400 return 0; 1394 1401 } 1395 1402 module_init(psi_proc_init); 1403 + 1404 + #endif /* CONFIG_PROC_FS */
+7 -1
kernel/trace/Kconfig
··· 70 70 help 71 71 C version of recordmcount available? 72 72 73 + config HAVE_BUILDTIME_MCOUNT_SORT 74 + bool 75 + help 76 + An architecture selects this if it sorts the mcount_loc section 77 + at build time. 78 + 73 79 config BUILDTIME_MCOUNT_SORT 74 80 bool 75 81 default y 76 - depends on BUILDTIME_TABLE_SORT && !S390 82 + depends on HAVE_BUILDTIME_MCOUNT_SORT && DYNAMIC_FTRACE 77 83 help 78 84 Sort the mcount_loc section at build time. 79 85
+2 -1
kernel/trace/trace.c
··· 7740 7740 err = kzalloc(sizeof(*err), GFP_KERNEL); 7741 7741 if (!err) 7742 7742 err = ERR_PTR(-ENOMEM); 7743 - tr->n_err_log_entries++; 7743 + else 7744 + tr->n_err_log_entries++; 7744 7745 7745 7746 return err; 7746 7747 }
+8 -2
kernel/trace/trace_events_hist.c
··· 2503 2503 (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); 2504 2504 expr->fn = hist_field_unary_minus; 2505 2505 expr->operands[0] = operand1; 2506 + expr->size = operand1->size; 2507 + expr->is_signed = operand1->is_signed; 2506 2508 expr->operator = FIELD_OP_UNARY_MINUS; 2507 2509 expr->name = expr_str(expr, 0); 2508 2510 expr->type = kstrdup_const(operand1->type, GFP_KERNEL); ··· 2721 2719 2722 2720 /* The operand sizes should be the same, so just pick one */ 2723 2721 expr->size = operand1->size; 2722 + expr->is_signed = operand1->is_signed; 2724 2723 2725 2724 expr->operator = field_op; 2726 2725 expr->type = kstrdup_const(operand1->type, GFP_KERNEL); ··· 3938 3935 3939 3936 var_ref_idx = find_var_ref_idx(hist_data, var_ref); 3940 3937 if (WARN_ON(var_ref_idx < 0)) { 3938 + kfree(p); 3941 3939 ret = var_ref_idx; 3942 3940 goto err; 3943 3941 } ··· 6167 6163 6168 6164 lockdep_assert_held(&event_mutex); 6169 6165 6170 - if (glob && strlen(glob)) { 6166 + WARN_ON(!glob); 6167 + 6168 + if (strlen(glob)) { 6171 6169 hist_err_clear(); 6172 6170 last_cmd_set(file, param); 6173 6171 } ··· 6202 6196 continue; 6203 6197 } 6204 6198 break; 6205 - } while (p); 6199 + } while (1); 6206 6200 6207 6201 if (!p) 6208 6202 param = NULL;
+2
kernel/ucount.c
··· 190 190 kfree(new); 191 191 } else { 192 192 hlist_add_head(&new->node, hashent); 193 + get_user_ns(new->ns); 193 194 spin_unlock_irq(&ucounts_lock); 194 195 return new; 195 196 } ··· 211 210 if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) { 212 211 hlist_del_init(&ucounts->node); 213 212 spin_unlock_irqrestore(&ucounts_lock, flags); 213 + put_user_ns(ucounts->ns); 214 214 kfree(ucounts); 215 215 } 216 216 }
+6 -2
lib/sbitmap.c
··· 488 488 unsigned int users) 489 489 { 490 490 unsigned int wake_batch; 491 + unsigned int min_batch; 492 + unsigned int depth = (sbq->sb.depth + users - 1) / users; 491 493 492 - wake_batch = clamp_val((sbq->sb.depth + users - 1) / 493 - users, 4, SBQ_WAKE_BATCH); 494 + min_batch = sbq->sb.depth >= (4 * SBQ_WAIT_QUEUES) ? 4 : 1; 495 + 496 + wake_batch = clamp_val(depth / SBQ_WAIT_QUEUES, 497 + min_batch, SBQ_WAKE_BATCH); 494 498 __sbitmap_queue_update_wake_batch(sbq, wake_batch); 495 499 } 496 500 EXPORT_SYMBOL_GPL(sbitmap_queue_recalculate_wake_batch);
+5
lib/test_kasan.c
··· 492 492 ptr = kmalloc(size, GFP_KERNEL); 493 493 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); 494 494 495 + OPTIMIZER_HIDE_VAR(ptr); 495 496 OPTIMIZER_HIDE_VAR(size); 496 497 KUNIT_EXPECT_KASAN_FAIL(test, 497 498 memset(ptr, 0, size + KASAN_GRANULE_SIZE)); ··· 516 515 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); 517 516 518 517 memset((char *)ptr, 0, 64); 518 + OPTIMIZER_HIDE_VAR(ptr); 519 519 OPTIMIZER_HIDE_VAR(invalid_size); 520 520 KUNIT_EXPECT_KASAN_FAIL(test, 521 521 memmove((char *)ptr, (char *)ptr + 4, invalid_size)); ··· 533 531 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); 534 532 535 533 memset((char *)ptr, 0, 64); 534 + OPTIMIZER_HIDE_VAR(ptr); 536 535 KUNIT_EXPECT_KASAN_FAIL(test, 537 536 memmove((char *)ptr, (char *)ptr + 4, invalid_size)); 538 537 kfree(ptr); ··· 896 893 ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); 897 894 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); 898 895 896 + OPTIMIZER_HIDE_VAR(ptr); 899 897 OPTIMIZER_HIDE_VAR(size); 900 898 KUNIT_EXPECT_KASAN_FAIL(test, 901 899 kasan_ptr_result = memchr(ptr, '1', size + 1)); ··· 923 919 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); 924 920 memset(arr, 0, sizeof(arr)); 925 921 922 + OPTIMIZER_HIDE_VAR(ptr); 926 923 OPTIMIZER_HIDE_VAR(size); 927 924 KUNIT_EXPECT_KASAN_FAIL(test, 928 925 kasan_int_result = memcmp(ptr, arr, size+1));
+6
mm/memory-failure.c
··· 1596 1596 } 1597 1597 1598 1598 /* 1599 + * Pages instantiated by device-dax (not filesystem-dax) 1600 + * may be compound pages. 1601 + */ 1602 + page = compound_head(page); 1603 + 1604 + /* 1599 1605 * Prevent the inode from being freed while we are interrogating 1600 1606 * the address_space, typically this would be handled by 1601 1607 * lock_page(), but dax pages do not use the page lock. This
+5 -4
net/bridge/br_vlan.c
··· 560 560 !br_opt_get(br, BROPT_VLAN_STATS_ENABLED)) { 561 561 if (*state == BR_STATE_FORWARDING) { 562 562 *state = br_vlan_get_pvid_state(vg); 563 - return br_vlan_state_allowed(*state, true); 564 - } else { 565 - return true; 563 + if (!br_vlan_state_allowed(*state, true)) 564 + goto drop; 566 565 } 566 + return true; 567 567 } 568 568 } 569 569 v = br_vlan_find(vg, *vid); ··· 2020 2020 goto out_err; 2021 2021 } 2022 2022 err = br_vlan_dump_dev(dev, skb, cb, dump_flags); 2023 - if (err && err != -EMSGSIZE) 2023 + /* if the dump completed without an error we return 0 here */ 2024 + if (err != -EMSGSIZE) 2024 2025 goto out_err; 2025 2026 } else { 2026 2027 for_each_netdev_rcu(net, dev) {
+34 -4
net/core/net-procfs.c
··· 190 190 .show = softnet_seq_show, 191 191 }; 192 192 193 - static void *ptype_get_idx(loff_t pos) 193 + static void *ptype_get_idx(struct seq_file *seq, loff_t pos) 194 194 { 195 + struct list_head *ptype_list = NULL; 195 196 struct packet_type *pt = NULL; 197 + struct net_device *dev; 196 198 loff_t i = 0; 197 199 int t; 200 + 201 + for_each_netdev_rcu(seq_file_net(seq), dev) { 202 + ptype_list = &dev->ptype_all; 203 + list_for_each_entry_rcu(pt, ptype_list, list) { 204 + if (i == pos) 205 + return pt; 206 + ++i; 207 + } 208 + } 198 209 199 210 list_for_each_entry_rcu(pt, &ptype_all, list) { 200 211 if (i == pos) ··· 227 216 __acquires(RCU) 228 217 { 229 218 rcu_read_lock(); 230 - return *pos ? ptype_get_idx(*pos - 1) : SEQ_START_TOKEN; 219 + return *pos ? ptype_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; 231 220 } 232 221 233 222 static void *ptype_seq_next(struct seq_file *seq, void *v, loff_t *pos) 234 223 { 224 + struct net_device *dev; 235 225 struct packet_type *pt; 236 226 struct list_head *nxt; 237 227 int hash; 238 228 239 229 ++*pos; 240 230 if (v == SEQ_START_TOKEN) 241 - return ptype_get_idx(0); 231 + return ptype_get_idx(seq, 0); 242 232 243 233 pt = v; 244 234 nxt = pt->list.next; 235 + if (pt->dev) { 236 + if (nxt != &pt->dev->ptype_all) 237 + goto found; 238 + 239 + dev = pt->dev; 240 + for_each_netdev_continue_rcu(seq_file_net(seq), dev) { 241 + if (!list_empty(&dev->ptype_all)) { 242 + nxt = dev->ptype_all.next; 243 + goto found; 244 + } 245 + } 246 + 247 + nxt = ptype_all.next; 248 + goto ptype_all; 249 + } 250 + 245 251 if (pt->type == htons(ETH_P_ALL)) { 252 + ptype_all: 246 253 if (nxt != &ptype_all) 247 254 goto found; 248 255 hash = 0; ··· 289 260 290 261 if (v == SEQ_START_TOKEN) 291 262 seq_puts(seq, "Type Device Function\n"); 292 - else if (pt->dev == NULL || dev_net(pt->dev) == seq_file_net(seq)) { 263 + else if ((!pt->af_packet_net || net_eq(pt->af_packet_net, seq_file_net(seq))) && 264 + (!pt->dev || net_eq(dev_net(pt->dev), seq_file_net(seq)))) { 293 265 if (pt->type == htons(ETH_P_ALL)) 294 266 seq_puts(seq, "ALL "); 295 267 else
+21 -5
net/ipv4/ip_output.c
··· 162 162 iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr); 163 163 iph->saddr = saddr; 164 164 iph->protocol = sk->sk_protocol; 165 - if (ip_dont_fragment(sk, &rt->dst)) { 165 + /* Do not bother generating IPID for small packets (eg SYNACK) */ 166 + if (skb->len <= IPV4_MIN_MTU || ip_dont_fragment(sk, &rt->dst)) { 166 167 iph->frag_off = htons(IP_DF); 167 168 iph->id = 0; 168 169 } else { 169 170 iph->frag_off = 0; 170 - __ip_select_ident(net, iph, 1); 171 + /* TCP packets here are SYNACK with fat IPv4/TCP options. 172 + * Avoid using the hashed IP ident generator. 173 + */ 174 + if (sk->sk_protocol == IPPROTO_TCP) 175 + iph->id = (__force __be16)prandom_u32(); 176 + else 177 + __ip_select_ident(net, iph, 1); 171 178 } 172 179 173 180 if (opt && opt->opt.optlen) { ··· 832 825 /* Everything is OK. Generate! */ 833 826 ip_fraglist_init(skb, iph, hlen, &iter); 834 827 835 - if (iter.frag) 836 - ip_options_fragment(iter.frag); 837 - 838 828 for (;;) { 839 829 /* Prepare header of the next frame, 840 830 * before previous one went down. */ 841 831 if (iter.frag) { 832 + bool first_frag = (iter.offset == 0); 833 + 842 834 IPCB(iter.frag)->flags = IPCB(skb)->flags; 843 835 ip_fraglist_prepare(skb, &iter); 836 + if (first_frag && IPCB(skb)->opt.optlen) { 837 + /* ipcb->opt is not populated for frags 838 + * coming from __ip_make_skb(), 839 + * ip_options_fragment() needs optlen 840 + */ 841 + IPCB(iter.frag)->opt.optlen = 842 + IPCB(skb)->opt.optlen; 843 + ip_options_fragment(iter.frag); 844 + ip_send_check(iter.iph); 845 + } 844 846 } 845 847 846 848 skb->tstamp = tstamp;
+2 -1
net/ipv4/ping.c
··· 220 220 continue; 221 221 } 222 222 223 - if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif) 223 + if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif && 224 + sk->sk_bound_dev_if != inet_sdif(skb)) 224 225 continue; 225 226 226 227 sock_hold(sk);
+4 -1
net/ipv4/raw.c
··· 722 722 int ret = -EINVAL; 723 723 int chk_addr_ret; 724 724 725 + lock_sock(sk); 725 726 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in)) 726 727 goto out; 727 728 ··· 742 741 inet->inet_saddr = 0; /* Use device */ 743 742 sk_dst_reset(sk); 744 743 ret = 0; 745 - out: return ret; 744 + out: 745 + release_sock(sk); 746 + return ret; 746 747 } 747 748 748 749 /*
+1
net/ipv4/tcp.c
··· 842 842 } 843 843 844 844 release_sock(sk); 845 + sk_defer_free_flush(sk); 845 846 846 847 if (spliced) 847 848 return spliced;
+1 -1
net/ipv4/tcp_ipv4.c
··· 2095 2095 nf_reset_ct(skb); 2096 2096 2097 2097 if (tcp_filter(sk, skb)) { 2098 - drop_reason = SKB_DROP_REASON_TCP_FILTER; 2098 + drop_reason = SKB_DROP_REASON_SOCKET_FILTER; 2099 2099 goto discard_and_relse; 2100 2100 } 2101 2101 th = (const struct tcphdr *)skb->data;
+20 -7
net/ipv6/addrconf.c
··· 2589 2589 __u32 valid_lft, u32 prefered_lft) 2590 2590 { 2591 2591 struct inet6_ifaddr *ifp = ipv6_get_ifaddr(net, addr, dev, 1); 2592 - int create = 0; 2592 + int create = 0, update_lft = 0; 2593 2593 2594 2594 if (!ifp && valid_lft) { 2595 2595 int max_addresses = in6_dev->cnf.max_addresses; ··· 2633 2633 unsigned long now; 2634 2634 u32 stored_lft; 2635 2635 2636 - /* Update lifetime (RFC4862 5.5.3 e) 2637 - * We deviate from RFC4862 by honoring all Valid Lifetimes to 2638 - * improve the reaction of SLAAC to renumbering events 2639 - * (draft-gont-6man-slaac-renum-06, Section 4.2) 2640 - */ 2636 + /* update lifetime (RFC2462 5.5.3 e) */ 2641 2637 spin_lock_bh(&ifp->lock); 2642 2638 now = jiffies; 2643 2639 if (ifp->valid_lft > (now - ifp->tstamp) / HZ) 2644 2640 stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ; 2645 2641 else 2646 2642 stored_lft = 0; 2647 - 2648 2643 if (!create && stored_lft) { 2644 + const u32 minimum_lft = min_t(u32, 2645 + stored_lft, MIN_VALID_LIFETIME); 2646 + valid_lft = max(valid_lft, minimum_lft); 2647 + 2648 + /* RFC4862 Section 5.5.3e: 2649 + * "Note that the preferred lifetime of the 2650 + * corresponding address is always reset to 2651 + * the Preferred Lifetime in the received 2652 + * Prefix Information option, regardless of 2653 + * whether the valid lifetime is also reset or 2654 + * ignored." 2655 + * 2656 + * So we should always update prefered_lft here. 2657 + */ 2658 + update_lft = 1; 2659 + } 2660 + 2661 + if (update_lft) { 2649 2662 ifp->valid_lft = valid_lft; 2650 2663 ifp->prefered_lft = prefered_lft; 2651 2664 ifp->tstamp = now;
+13 -10
net/ipv6/ip6_fib.c
··· 112 112 fn = rcu_dereference_protected(f6i->fib6_node, 113 113 lockdep_is_held(&f6i->fib6_table->tb6_lock)); 114 114 if (fn) 115 - fn->fn_sernum = fib6_new_sernum(net); 115 + WRITE_ONCE(fn->fn_sernum, fib6_new_sernum(net)); 116 116 } 117 117 118 118 /* ··· 590 590 spin_unlock_bh(&table->tb6_lock); 591 591 if (res > 0) { 592 592 cb->args[4] = 1; 593 - cb->args[5] = w->root->fn_sernum; 593 + cb->args[5] = READ_ONCE(w->root->fn_sernum); 594 594 } 595 595 } else { 596 - if (cb->args[5] != w->root->fn_sernum) { 596 + int sernum = READ_ONCE(w->root->fn_sernum); 597 + if (cb->args[5] != sernum) { 597 598 /* Begin at the root if the tree changed */ 598 - cb->args[5] = w->root->fn_sernum; 599 + cb->args[5] = sernum; 599 600 w->state = FWS_INIT; 600 601 w->node = w->root; 601 602 w->skip = w->count; ··· 1346 1345 /* paired with smp_rmb() in fib6_get_cookie_safe() */ 1347 1346 smp_wmb(); 1348 1347 while (fn) { 1349 - fn->fn_sernum = sernum; 1348 + WRITE_ONCE(fn->fn_sernum, sernum); 1350 1349 fn = rcu_dereference_protected(fn->parent, 1351 1350 lockdep_is_held(&rt->fib6_table->tb6_lock)); 1352 1351 } ··· 2175 2174 }; 2176 2175 2177 2176 if (c->sernum != FIB6_NO_SERNUM_CHANGE && 2178 - w->node->fn_sernum != c->sernum) 2179 - w->node->fn_sernum = c->sernum; 2177 + READ_ONCE(w->node->fn_sernum) != c->sernum) 2178 + WRITE_ONCE(w->node->fn_sernum, c->sernum); 2180 2179 2181 2180 if (!c->func) { 2182 2181 WARN_ON_ONCE(c->sernum == FIB6_NO_SERNUM_CHANGE); ··· 2544 2543 iter->w.state = FWS_INIT; 2545 2544 iter->w.node = iter->w.root; 2546 2545 iter->w.args = iter; 2547 - iter->sernum = iter->w.root->fn_sernum; 2546 + iter->sernum = READ_ONCE(iter->w.root->fn_sernum); 2548 2547 INIT_LIST_HEAD(&iter->w.lh); 2549 2548 fib6_walker_link(net, &iter->w); 2550 2549 } ··· 2572 2571 2573 2572 static void ipv6_route_check_sernum(struct ipv6_route_iter *iter) 2574 2573 { 2575 - if (iter->sernum != iter->w.root->fn_sernum) { 2576 - iter->sernum = iter->w.root->fn_sernum; 2574 + int sernum = READ_ONCE(iter->w.root->fn_sernum); 2575 + 2576 + if (iter->sernum != sernum) { 2577 + iter->sernum = sernum; 2577 2578 iter->w.state = FWS_INIT; 2578 2579 iter->w.node = iter->w.root; 2579 2580 WARN_ON(iter->w.skip);
+4 -4
net/ipv6/ip6_tunnel.c
··· 1036 1036 1037 1037 if (unlikely(!ipv6_chk_addr_and_flags(net, laddr, ldev, false, 1038 1038 0, IFA_F_TENTATIVE))) 1039 - pr_warn("%s xmit: Local address not yet configured!\n", 1040 - p->name); 1039 + pr_warn_ratelimited("%s xmit: Local address not yet configured!\n", 1040 + p->name); 1041 1041 else if (!(p->flags & IP6_TNL_F_ALLOW_LOCAL_REMOTE) && 1042 1042 !ipv6_addr_is_multicast(raddr) && 1043 1043 unlikely(ipv6_chk_addr_and_flags(net, raddr, ldev, 1044 1044 true, 0, IFA_F_TENTATIVE))) 1045 - pr_warn("%s xmit: Routing loop! Remote address found on this node!\n", 1046 - p->name); 1045 + pr_warn_ratelimited("%s xmit: Routing loop! Remote address found on this node!\n", 1046 + p->name); 1047 1047 else 1048 1048 ret = 1; 1049 1049 rcu_read_unlock();
+1 -1
net/ipv6/route.c
··· 2802 2802 if (from) { 2803 2803 fn = rcu_dereference(from->fib6_node); 2804 2804 if (fn && (rt->rt6i_flags & RTF_DEFAULT)) 2805 - fn->fn_sernum = -1; 2805 + WRITE_ONCE(fn->fn_sernum, -1); 2806 2806 } 2807 2807 } 2808 2808 rcu_read_unlock();
+28 -11
net/mptcp/pm_netlink.c
··· 478 478 return NULL; 479 479 } 480 480 481 + static struct mptcp_pm_addr_entry * 482 + __lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info, 483 + bool lookup_by_id) 484 + { 485 + struct mptcp_pm_addr_entry *entry; 486 + 487 + list_for_each_entry(entry, &pernet->local_addr_list, list) { 488 + if ((!lookup_by_id && addresses_equal(&entry->addr, info, true)) || 489 + (lookup_by_id && entry->addr.id == info->id)) 490 + return entry; 491 + } 492 + return NULL; 493 + } 494 + 481 495 static int 482 496 lookup_id_by_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *addr) 483 497 { ··· 791 777 removed = true; 792 778 __MPTCP_INC_STATS(sock_net(sk), rm_type); 793 779 } 794 - __set_bit(rm_list->ids[1], msk->pm.id_avail_bitmap); 780 + __set_bit(rm_list->ids[i], msk->pm.id_avail_bitmap); 795 781 if (!removed) 796 782 continue; 797 783 ··· 1777 1763 return -EOPNOTSUPP; 1778 1764 } 1779 1765 1780 - list_for_each_entry(entry, &pernet->local_addr_list, list) { 1781 - if ((!lookup_by_id && addresses_equal(&entry->addr, &addr.addr, true)) || 1782 - (lookup_by_id && entry->addr.id == addr.addr.id)) { 1783 - mptcp_nl_addr_backup(net, &entry->addr, bkup); 1784 - 1785 - if (bkup) 1786 - entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP; 1787 - else 1788 - entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP; 1789 - } 1766 + spin_lock_bh(&pernet->lock); 1767 + entry = __lookup_addr(pernet, &addr.addr, lookup_by_id); 1768 + if (!entry) { 1769 + spin_unlock_bh(&pernet->lock); 1770 + return -EINVAL; 1790 1771 } 1791 1772 1773 + if (bkup) 1774 + entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP; 1775 + else 1776 + entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP; 1777 + addr = *entry; 1778 + spin_unlock_bh(&pernet->lock); 1779 + 1780 + mptcp_nl_addr_backup(net, &addr.addr, bkup); 1792 1781 return 0; 1793 1782 } 1794 1783
+3 -3
net/mptcp/protocol.h
··· 408 408 struct mptcp_subflow_context { 409 409 struct list_head node;/* conn_list of subflows */ 410 410 411 - char reset_start[0]; 411 + struct_group(reset, 412 412 413 413 unsigned long avg_pacing_rate; /* protected by msk socket lock */ 414 414 u64 local_key; ··· 458 458 459 459 long delegated_status; 460 460 461 - char reset_end[0]; 461 + ); 462 462 463 463 struct list_head delegated_node; /* link into delegated_action, protected by local BH */ 464 464 ··· 494 494 static inline void 495 495 mptcp_subflow_ctx_reset(struct mptcp_subflow_context *subflow) 496 496 { 497 - memset(subflow->reset_start, 0, subflow->reset_end - subflow->reset_start); 497 + memset(&subflow->reset, 0, sizeof(subflow->reset)); 498 498 subflow->request_mptcp = 1; 499 499 } 500 500
+5 -3
net/netfilter/nf_conntrack_core.c
··· 1924 1924 pr_debug("nf_conntrack_in: Can't track with proto module\n"); 1925 1925 nf_ct_put(ct); 1926 1926 skb->_nfct = 0; 1927 - NF_CT_STAT_INC_ATOMIC(state->net, invalid); 1928 - if (ret == -NF_DROP) 1929 - NF_CT_STAT_INC_ATOMIC(state->net, drop); 1930 1927 /* Special case: TCP tracker reports an attempt to reopen a 1931 1928 * closed/aborted connection. We have to go back and create a 1932 1929 * fresh conntrack. 1933 1930 */ 1934 1931 if (ret == -NF_REPEAT) 1935 1932 goto repeat; 1933 + 1934 + NF_CT_STAT_INC_ATOMIC(state->net, invalid); 1935 + if (ret == -NF_DROP) 1936 + NF_CT_STAT_INC_ATOMIC(state->net, drop); 1937 + 1936 1938 ret = -ret; 1937 1939 goto out; 1938 1940 }
+3 -2
net/netfilter/nf_conntrack_netbios_ns.c
··· 20 20 #include <net/netfilter/nf_conntrack_helper.h> 21 21 #include <net/netfilter/nf_conntrack_expect.h> 22 22 23 + #define HELPER_NAME "netbios-ns" 23 24 #define NMBD_PORT 137 24 25 25 26 MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); 26 27 MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper"); 27 28 MODULE_LICENSE("GPL"); 28 29 MODULE_ALIAS("ip_conntrack_netbios_ns"); 29 - MODULE_ALIAS_NFCT_HELPER("netbios_ns"); 30 + MODULE_ALIAS_NFCT_HELPER(HELPER_NAME); 30 31 31 32 static unsigned int timeout __read_mostly = 3; 32 33 module_param(timeout, uint, 0400); ··· 45 44 } 46 45 47 46 static struct nf_conntrack_helper helper __read_mostly = { 48 - .name = "netbios-ns", 47 + .name = HELPER_NAME, 49 48 .tuple.src.l3num = NFPROTO_IPV4, 50 49 .tuple.src.u.udp.port = cpu_to_be16(NMBD_PORT), 51 50 .tuple.dst.protonum = IPPROTO_UDP,
+1 -3
net/netfilter/nf_tables_api.c
··· 8264 8264 void *data, *data_boundary; 8265 8265 struct nft_rule_dp *prule; 8266 8266 struct nft_rule *rule; 8267 - int i; 8268 8267 8269 8268 /* already handled or inactive chain? */ 8270 8269 if (chain->blob_next || !nft_is_active_next(net, chain)) 8271 8270 return 0; 8272 8271 8273 8272 rule = list_entry(&chain->rules, struct nft_rule, list); 8274 - i = 0; 8275 8273 8276 8274 data_size = 0; 8277 8275 list_for_each_entry_continue(rule, &chain->rules, list) { ··· 8299 8301 return -ENOMEM; 8300 8302 8301 8303 size = 0; 8302 - track.last = last; 8304 + track.last = nft_expr_last(rule); 8303 8305 nft_rule_for_each_expr(expr, last, rule) { 8304 8306 track.cur = expr; 8305 8307
+10 -1
net/netfilter/nft_connlimit.c
··· 62 62 { 63 63 bool invert = false; 64 64 u32 flags, limit; 65 + int err; 65 66 66 67 if (!tb[NFTA_CONNLIMIT_COUNT]) 67 68 return -EINVAL; ··· 85 84 priv->limit = limit; 86 85 priv->invert = invert; 87 86 88 - return nf_ct_netns_get(ctx->net, ctx->family); 87 + err = nf_ct_netns_get(ctx->net, ctx->family); 88 + if (err < 0) 89 + goto err_netns; 90 + 91 + return 0; 92 + err_netns: 93 + kfree(priv->list); 94 + 95 + return err; 89 96 } 90 97 91 98 static void nft_connlimit_do_destroy(const struct nft_ctx *ctx,
+2
net/packet/af_packet.c
··· 1774 1774 match->prot_hook.dev = po->prot_hook.dev; 1775 1775 match->prot_hook.func = packet_rcv_fanout; 1776 1776 match->prot_hook.af_packet_priv = match; 1777 + match->prot_hook.af_packet_net = read_pnet(&match->net); 1777 1778 match->prot_hook.id_match = match_fanout_group; 1778 1779 match->max_num_members = args->max_num_members; 1779 1780 list_add(&match->list, &fanout_list); ··· 3354 3353 po->prot_hook.func = packet_rcv_spkt; 3355 3354 3356 3355 po->prot_hook.af_packet_priv = sk; 3356 + po->prot_hook.af_packet_net = sock_net(sk); 3357 3357 3358 3358 if (proto) { 3359 3359 po->prot_hook.type = proto;
+3 -5
net/rxrpc/call_event.c
··· 157 157 static void rxrpc_resend(struct rxrpc_call *call, unsigned long now_j) 158 158 { 159 159 struct sk_buff *skb; 160 - unsigned long resend_at, rto_j; 160 + unsigned long resend_at; 161 161 rxrpc_seq_t cursor, seq, top; 162 162 ktime_t now, max_age, oldest, ack_ts; 163 163 int ix; ··· 165 165 166 166 _enter("{%d,%d}", call->tx_hard_ack, call->tx_top); 167 167 168 - rto_j = call->peer->rto_j; 169 - 170 168 now = ktime_get_real(); 171 - max_age = ktime_sub(now, jiffies_to_usecs(rto_j)); 169 + max_age = ktime_sub(now, jiffies_to_usecs(call->peer->rto_j)); 172 170 173 171 spin_lock_bh(&call->lock); 174 172 ··· 211 213 } 212 214 213 215 resend_at = nsecs_to_jiffies(ktime_to_ns(ktime_sub(now, oldest))); 214 - resend_at += jiffies + rto_j; 216 + resend_at += jiffies + rxrpc_get_rto_backoff(call->peer, retrans); 215 217 WRITE_ONCE(call->resend_at, resend_at); 216 218 217 219 if (unacked)
+1 -1
net/rxrpc/output.c
··· 468 468 if (call->peer->rtt_count > 1) { 469 469 unsigned long nowj = jiffies, ack_lost_at; 470 470 471 - ack_lost_at = rxrpc_get_rto_backoff(call->peer, retrans); 471 + ack_lost_at = rxrpc_get_rto_backoff(call->peer, false); 472 472 ack_lost_at += nowj; 473 473 WRITE_ONCE(call->ack_lost_at, ack_lost_at); 474 474 rxrpc_reduce_call_timer(call, ack_lost_at, nowj,
+1 -1
net/sched/sch_api.c
··· 1204 1204 1205 1205 err = -ENOENT; 1206 1206 if (!ops) { 1207 - NL_SET_ERR_MSG(extack, "Specified qdisc not found"); 1207 + NL_SET_ERR_MSG(extack, "Specified qdisc kind is unknown"); 1208 1208 goto err_out; 1209 1209 } 1210 1210
+20
net/sched/sch_htb.c
··· 1810 1810 if (!hopt->rate.rate || !hopt->ceil.rate) 1811 1811 goto failure; 1812 1812 1813 + if (q->offload) { 1814 + /* Options not supported by the offload. */ 1815 + if (hopt->rate.overhead || hopt->ceil.overhead) { 1816 + NL_SET_ERR_MSG(extack, "HTB offload doesn't support the overhead parameter"); 1817 + goto failure; 1818 + } 1819 + if (hopt->rate.mpu || hopt->ceil.mpu) { 1820 + NL_SET_ERR_MSG(extack, "HTB offload doesn't support the mpu parameter"); 1821 + goto failure; 1822 + } 1823 + if (hopt->quantum) { 1824 + NL_SET_ERR_MSG(extack, "HTB offload doesn't support the quantum parameter"); 1825 + goto failure; 1826 + } 1827 + if (hopt->prio) { 1828 + NL_SET_ERR_MSG(extack, "HTB offload doesn't support the prio parameter"); 1829 + goto failure; 1830 + } 1831 + } 1832 + 1813 1833 /* Keeping backward compatible with rate_table based iproute2 tc */ 1814 1834 if (hopt->rate.linklayer == TC_LINKLAYER_UNAWARE) 1815 1835 qdisc_put_rtab(qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB],
+51 -12
net/smc/af_smc.c
··· 566 566 mutex_unlock(&net->smc.mutex_fback_rsn); 567 567 } 568 568 569 - static void smc_switch_to_fallback(struct smc_sock *smc, int reason_code) 569 + static int smc_switch_to_fallback(struct smc_sock *smc, int reason_code) 570 570 { 571 571 wait_queue_head_t *smc_wait = sk_sleep(&smc->sk); 572 - wait_queue_head_t *clc_wait = sk_sleep(smc->clcsock->sk); 572 + wait_queue_head_t *clc_wait; 573 573 unsigned long flags; 574 574 575 + mutex_lock(&smc->clcsock_release_lock); 576 + if (!smc->clcsock) { 577 + mutex_unlock(&smc->clcsock_release_lock); 578 + return -EBADF; 579 + } 575 580 smc->use_fallback = true; 576 581 smc->fallback_rsn = reason_code; 577 582 smc_stat_fallback(smc); ··· 591 586 * smc socket->wq, which should be removed 592 587 * to clcsocket->wq during the fallback. 593 588 */ 589 + clc_wait = sk_sleep(smc->clcsock->sk); 594 590 spin_lock_irqsave(&smc_wait->lock, flags); 595 591 spin_lock_nested(&clc_wait->lock, SINGLE_DEPTH_NESTING); 596 592 list_splice_init(&smc_wait->head, &clc_wait->head); 597 593 spin_unlock(&clc_wait->lock); 598 594 spin_unlock_irqrestore(&smc_wait->lock, flags); 599 595 } 596 + mutex_unlock(&smc->clcsock_release_lock); 597 + return 0; 600 598 } 601 599 602 600 /* fall back during connect */ 603 601 static int smc_connect_fallback(struct smc_sock *smc, int reason_code) 604 602 { 605 - smc_switch_to_fallback(smc, reason_code); 603 + struct net *net = sock_net(&smc->sk); 604 + int rc = 0; 605 + 606 + rc = smc_switch_to_fallback(smc, reason_code); 607 + if (rc) { /* fallback fails */ 608 + this_cpu_inc(net->smc.smc_stats->clnt_hshake_err_cnt); 609 + if (smc->sk.sk_state == SMC_INIT) 610 + sock_put(&smc->sk); /* passive closing */ 611 + return rc; 612 + } 606 613 smc_copy_sock_settings_to_clc(smc); 607 614 smc->connect_nonblock = 0; 608 615 if (smc->sk.sk_state == SMC_INIT) ··· 1535 1518 { 1536 1519 /* RDMA setup failed, switch back to TCP */ 1537 1520 smc_conn_abort(new_smc, local_first); 1538 - if (reason_code < 0) { /* error, no fallback possible */ 1521 + if (reason_code < 0 || 1522 + smc_switch_to_fallback(new_smc, reason_code)) { 1523 + /* error, no fallback possible */ 1539 1524 smc_listen_out_err(new_smc); 1540 1525 return; 1541 1526 } 1542 - smc_switch_to_fallback(new_smc, reason_code); 1543 1527 if (reason_code && reason_code != SMC_CLC_DECL_PEERDECL) { 1544 1528 if (smc_clc_send_decline(new_smc, reason_code, version) < 0) { 1545 1529 smc_listen_out_err(new_smc); ··· 1982 1964 1983 1965 /* check if peer is smc capable */ 1984 1966 if (!tcp_sk(newclcsock->sk)->syn_smc) { 1985 - smc_switch_to_fallback(new_smc, SMC_CLC_DECL_PEERNOSMC); 1986 - smc_listen_out_connected(new_smc); 1967 + rc = smc_switch_to_fallback(new_smc, SMC_CLC_DECL_PEERNOSMC); 1968 + if (rc) 1969 + smc_listen_out_err(new_smc); 1970 + else 1971 + smc_listen_out_connected(new_smc); 1987 1972 return; 1988 1973 } 1989 1974 ··· 2275 2254 2276 2255 if (msg->msg_flags & MSG_FASTOPEN) { 2277 2256 if (sk->sk_state == SMC_INIT && !smc->connect_nonblock) { 2278 - smc_switch_to_fallback(smc, SMC_CLC_DECL_OPTUNSUPP); 2257 + rc = smc_switch_to_fallback(smc, SMC_CLC_DECL_OPTUNSUPP); 2258 + if (rc) 2259 + goto out; 2279 2260 } else { 2280 2261 rc = -EINVAL; 2281 2262 goto out; ··· 2470 2447 /* generic setsockopts reaching us here always apply to the 2471 2448 * CLC socket 2472 2449 */ 2450 + mutex_lock(&smc->clcsock_release_lock); 2451 + if (!smc->clcsock) { 2452 + mutex_unlock(&smc->clcsock_release_lock); 2453 + return -EBADF; 2454 + } 2473 2455 if (unlikely(!smc->clcsock->ops->setsockopt)) 2474 2456 rc = -EOPNOTSUPP; 2475 2457 else ··· 2484 2456 sk->sk_err = smc->clcsock->sk->sk_err; 2485 2457 sk_error_report(sk); 2486 2458 } 2459 + mutex_unlock(&smc->clcsock_release_lock); 2487 2460 2488 2461 if (optlen < sizeof(int)) 2489 2462 return -EINVAL; ··· 2501 2472 case TCP_FASTOPEN_NO_COOKIE: 2502 2473 /* option not supported by SMC */ 2503 2474 if (sk->sk_state == SMC_INIT && !smc->connect_nonblock) { 2504 - smc_switch_to_fallback(smc, SMC_CLC_DECL_OPTUNSUPP); 2475 + rc = smc_switch_to_fallback(smc, SMC_CLC_DECL_OPTUNSUPP); 2505 2476 } else { 2506 2477 rc = -EINVAL; 2507 2478 } ··· 2544 2515 char __user *optval, int __user *optlen) 2545 2516 { 2546 2517 struct smc_sock *smc; 2518 + int rc; 2547 2519 2548 2520 smc = smc_sk(sock->sk); 2521 + mutex_lock(&smc->clcsock_release_lock); 2522 + if (!smc->clcsock) { 2523 + mutex_unlock(&smc->clcsock_release_lock); 2524 + return -EBADF; 2525 + } 2549 2526 /* socket options apply to the CLC socket */ 2550 - if (unlikely(!smc->clcsock->ops->getsockopt)) 2527 + if (unlikely(!smc->clcsock->ops->getsockopt)) { 2528 + mutex_unlock(&smc->clcsock_release_lock); 2551 2529 return -EOPNOTSUPP; 2552 - return smc->clcsock->ops->getsockopt(smc->clcsock, level, optname, 2553 - optval, optlen); 2530 + } 2531 + rc = smc->clcsock->ops->getsockopt(smc->clcsock, level, optname, 2532 + optval, optlen); 2533 + mutex_unlock(&smc->clcsock_release_lock); 2534 + return rc; 2554 2535 } 2555 2536 2556 2537 static int smc_ioctl(struct socket *sock, unsigned int cmd,
+2 -4
net/sunrpc/auth_gss/gss_generic_token.c
··· 222 222 if (ret) 223 223 return ret; 224 224 225 - if (!ret) { 226 - *buf_in = buf; 227 - *body_size = toksize; 228 - } 225 + *buf_in = buf; 226 + *body_size = toksize; 229 227 230 228 return ret; 231 229 }
+4 -1
net/sunrpc/clnt.c
··· 2900 2900 unsigned long connect_timeout; 2901 2901 unsigned long reconnect_timeout; 2902 2902 unsigned char resvport, reuseport; 2903 - int ret = 0; 2903 + int ret = 0, ident; 2904 2904 2905 2905 rcu_read_lock(); 2906 2906 xps = xprt_switch_get(rcu_dereference(clnt->cl_xpi.xpi_xpswitch)); ··· 2914 2914 reuseport = xprt->reuseport; 2915 2915 connect_timeout = xprt->connect_timeout; 2916 2916 reconnect_timeout = xprt->max_reconnect_timeout; 2917 + ident = xprt->xprt_class->ident; 2917 2918 rcu_read_unlock(); 2918 2919 2920 + if (!xprtargs->ident) 2921 + xprtargs->ident = ident; 2919 2922 xprt = xprt_create_transport(xprtargs); 2920 2923 if (IS_ERR(xprt)) { 2921 2924 ret = PTR_ERR(xprt);
+2 -2
net/sunrpc/rpc_pipe.c
··· 600 600 601 601 dget(dentry); 602 602 ret = simple_rmdir(dir, dentry); 603 + d_drop(dentry); 603 604 if (!ret) 604 605 fsnotify_rmdir(dir, dentry); 605 - d_delete(dentry); 606 606 dput(dentry); 607 607 return ret; 608 608 } ··· 613 613 614 614 dget(dentry); 615 615 ret = simple_unlink(dir, dentry); 616 + d_drop(dentry); 616 617 if (!ret) 617 618 fsnotify_unlink(dir, dentry); 618 - d_delete(dentry); 619 619 dput(dentry); 620 620 return ret; 621 621 }
+27 -20
net/sunrpc/sysfs.c
··· 295 295 online = 1; 296 296 else if (!strncmp(buf, "remove", 6)) 297 297 remove = 1; 298 - else 299 - return -EINVAL; 298 + else { 299 + count = -EINVAL; 300 + goto out_put; 301 + } 300 302 301 303 if (wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE)) { 302 304 count = -EINTR; ··· 309 307 goto release_tasks; 310 308 } 311 309 if (offline) { 312 - set_bit(XPRT_OFFLINE, &xprt->state); 313 - spin_lock(&xps->xps_lock); 314 - xps->xps_nactive--; 315 - spin_unlock(&xps->xps_lock); 310 + if (!test_and_set_bit(XPRT_OFFLINE, &xprt->state)) { 311 + spin_lock(&xps->xps_lock); 312 + xps->xps_nactive--; 313 + spin_unlock(&xps->xps_lock); 314 + } 316 315 } else if (online) { 317 - clear_bit(XPRT_OFFLINE, &xprt->state); 318 - spin_lock(&xps->xps_lock); 319 - xps->xps_nactive++; 320 - spin_unlock(&xps->xps_lock); 316 + if (test_and_clear_bit(XPRT_OFFLINE, &xprt->state)) { 317 + spin_lock(&xps->xps_lock); 318 + xps->xps_nactive++; 319 + spin_unlock(&xps->xps_lock); 320 + } 321 321 } else if (remove) { 322 322 if (test_bit(XPRT_OFFLINE, &xprt->state)) { 323 - set_bit(XPRT_REMOVE, &xprt->state); 324 - xprt_force_disconnect(xprt); 325 - if (test_bit(XPRT_CONNECTED, &xprt->state)) { 326 - if (!xprt->sending.qlen && 327 - !xprt->pending.qlen && 328 - !xprt->backlog.qlen && 329 - !atomic_long_read(&xprt->queuelen)) 330 - rpc_xprt_switch_remove_xprt(xps, xprt); 323 + if (!test_and_set_bit(XPRT_REMOVE, &xprt->state)) { 324 + xprt_force_disconnect(xprt); 325 + if (test_bit(XPRT_CONNECTED, &xprt->state)) { 326 + if (!xprt->sending.qlen && 327 + !xprt->pending.qlen && 328 + !xprt->backlog.qlen && 329 + !atomic_long_read(&xprt->queuelen)) 330 + rpc_xprt_switch_remove_xprt(xps, xprt); 331 + } 331 332 } 332 333 } else { 333 334 count = -EINVAL; ··· 427 422 &rpc_sysfs_xprt_change_state.attr, 428 423 NULL, 429 424 }; 425 + ATTRIBUTE_GROUPS(rpc_sysfs_xprt); 430 426 431 427 static struct kobj_attribute rpc_sysfs_xprt_switch_info = 432 428 __ATTR(xprt_switch_info, 0444, rpc_sysfs_xprt_switch_info_show, NULL); ··· 436 430 &rpc_sysfs_xprt_switch_info.attr, 437 431 NULL, 438 432 }; 433 + ATTRIBUTE_GROUPS(rpc_sysfs_xprt_switch); 439 434 440 435 static struct kobj_type rpc_sysfs_client_type = { 441 436 .release = rpc_sysfs_client_release, ··· 446 439 447 440 static struct kobj_type rpc_sysfs_xprt_switch_type = { 448 441 .release = rpc_sysfs_xprt_switch_release, 449 - .default_attrs = rpc_sysfs_xprt_switch_attrs, 442 + .default_groups = rpc_sysfs_xprt_switch_groups, 450 443 .sysfs_ops = &kobj_sysfs_ops, 451 444 .namespace = rpc_sysfs_xprt_switch_namespace, 452 445 }; 453 446 454 447 static struct kobj_type rpc_sysfs_xprt_type = { 455 448 .release = rpc_sysfs_xprt_release, 456 - .default_attrs = rpc_sysfs_xprt_attrs, 449 + .default_groups = rpc_sysfs_xprt_groups, 457 450 .sysfs_ops = &kobj_sysfs_ops, 458 451 .namespace = rpc_sysfs_xprt_namespace, 459 452 };
-4
net/sunrpc/xprtrdma/backchannel.c
··· 13 13 #include "xprt_rdma.h" 14 14 #include <trace/events/rpcrdma.h> 15 15 16 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 17 - # define RPCDBG_FACILITY RPCDBG_TRANS 18 - #endif 19 - 20 16 #undef RPCRDMA_BACKCHANNEL_DEBUG 21 17 22 18 /**
-4
net/sunrpc/xprtrdma/frwr_ops.c
··· 45 45 #include "xprt_rdma.h" 46 46 #include <trace/events/rpcrdma.h> 47 47 48 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 49 - # define RPCDBG_FACILITY RPCDBG_TRANS 50 - #endif 51 - 52 48 static void frwr_cid_init(struct rpcrdma_ep *ep, 53 49 struct rpcrdma_mr *mr) 54 50 {
-4
net/sunrpc/xprtrdma/rpc_rdma.c
··· 54 54 #include "xprt_rdma.h" 55 55 #include <trace/events/rpcrdma.h> 56 56 57 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 58 - # define RPCDBG_FACILITY RPCDBG_TRANS 59 - #endif 60 - 61 57 /* Returns size of largest RPC-over-RDMA header in a Call message 62 58 * 63 59 * The largest Call header contains a full-size Read list and a
-4
net/sunrpc/xprtrdma/transport.c
··· 60 60 #include "xprt_rdma.h" 61 61 #include <trace/events/rpcrdma.h> 62 62 63 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 64 - # define RPCDBG_FACILITY RPCDBG_TRANS 65 - #endif 66 - 67 63 /* 68 64 * tunables 69 65 */
-23
net/sunrpc/xprtrdma/verbs.c
··· 63 63 #include "xprt_rdma.h" 64 64 #include <trace/events/rpcrdma.h> 65 65 66 - /* 67 - * Globals/Macros 68 - */ 69 - 70 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 71 - # define RPCDBG_FACILITY RPCDBG_TRANS 72 - #endif 73 - 74 - /* 75 - * internal functions 76 - */ 77 66 static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt); 78 67 static void rpcrdma_sendctxs_destroy(struct rpcrdma_xprt *r_xprt); 79 68 static void rpcrdma_sendctx_put_locked(struct rpcrdma_xprt *r_xprt, ··· 263 274 ep->re_connect_status = -ENETUNREACH; 264 275 goto wake_connect_worker; 265 276 case RDMA_CM_EVENT_REJECTED: 266 - dprintk("rpcrdma: connection to %pISpc rejected: %s\n", 267 - sap, rdma_reject_msg(id, event->status)); 268 277 ep->re_connect_status = -ECONNREFUSED; 269 278 if (event->status == IB_CM_REJ_STALE_CONN) 270 279 ep->re_connect_status = -ENOTCONN; ··· 278 291 break; 279 292 } 280 293 281 - dprintk("RPC: %s: %pISpc on %s/frwr: %s\n", __func__, sap, 282 - ep->re_id->device->name, rdma_event_msg(event->event)); 283 294 return 0; 284 295 } 285 296 ··· 403 418 ep->re_attr.sq_sig_type = IB_SIGNAL_REQ_WR; 404 419 ep->re_attr.qp_type = IB_QPT_RC; 405 420 ep->re_attr.port_num = ~0; 406 - 407 - dprintk("RPC: %s: requested max: dtos: send %d recv %d; " 408 - "iovs: send %d recv %d\n", 409 - __func__, 410 - ep->re_attr.cap.max_send_wr, 411 - ep->re_attr.cap.max_recv_wr, 412 - ep->re_attr.cap.max_send_sge, 413 - ep->re_attr.cap.max_recv_sge); 414 421 415 422 ep->re_send_batch = ep->re_max_requests >> 3; 416 423 ep->re_send_count = ep->re_send_batch;
+1 -1
net/sunrpc/xprtsock.c
··· 1910 1910 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); 1911 1911 int ret; 1912 1912 1913 - if (RPC_IS_ASYNC(task)) { 1913 + if (RPC_IS_ASYNC(task)) { 1914 1914 /* 1915 1915 * We want the AF_LOCAL connect to be resolved in the 1916 1916 * filesystem namespace of the process making the rpc
+1 -1
scripts/Makefile
··· 25 25 HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED 26 26 endif 27 27 28 - ifdef CONFIG_DYNAMIC_FTRACE 28 + ifdef CONFIG_BUILDTIME_MCOUNT_SORT 29 29 HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED 30 30 endif 31 31
+13 -2
security/security.c
··· 1048 1048 const char **xattr_name, void **ctx, 1049 1049 u32 *ctxlen) 1050 1050 { 1051 - return call_int_hook(dentry_init_security, -EOPNOTSUPP, dentry, mode, 1052 - name, xattr_name, ctx, ctxlen); 1051 + struct security_hook_list *hp; 1052 + int rc; 1053 + 1054 + /* 1055 + * Only one module will provide a security context. 1056 + */ 1057 + hlist_for_each_entry(hp, &security_hook_heads.dentry_init_security, list) { 1058 + rc = hp->hook.dentry_init_security(dentry, mode, name, 1059 + xattr_name, ctx, ctxlen); 1060 + if (rc != LSM_RET_DEFAULT(dentry_init_security)) 1061 + return rc; 1062 + } 1063 + return LSM_RET_DEFAULT(dentry_init_security); 1053 1064 } 1054 1065 EXPORT_SYMBOL(security_dentry_init_security); 1055 1066
+3
tools/arch/x86/include/uapi/asm/kvm.h
··· 452 452 453 453 #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001 454 454 455 + /* attributes for system fd (group 0) */ 456 + #define KVM_X86_XCOMP_GUEST_SUPP 0 457 + 455 458 struct kvm_vmx_nested_state_data { 456 459 __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; 457 460 __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
+1 -1
tools/bpf/runqslower/runqslower.bpf.c
··· 68 68 */ 69 69 struct task_struct *prev = (struct task_struct *)ctx[1]; 70 70 struct task_struct *next = (struct task_struct *)ctx[2]; 71 - struct event event = {}; 71 + struct runq_event event = {}; 72 72 u64 *tsp, delta_us; 73 73 long state; 74 74 u32 pid;
+1 -1
tools/bpf/runqslower/runqslower.c
··· 100 100 101 101 void handle_event(void *ctx, int cpu, void *data, __u32 data_sz) 102 102 { 103 - const struct event *e = data; 103 + const struct runq_event *e = data; 104 104 struct tm *tm; 105 105 char ts[32]; 106 106 time_t t;
+1 -1
tools/bpf/runqslower/runqslower.h
··· 4 4 5 5 #define TASK_COMM_LEN 16 6 6 7 - struct event { 7 + struct runq_event { 8 8 char task[TASK_COMM_LEN]; 9 9 __u64 delta_us; 10 10 pid_t pid;
+1
tools/include/uapi/linux/kvm.h
··· 1133 1133 #define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206 1134 1134 #define KVM_CAP_VM_GPA_BITS 207 1135 1135 #define KVM_CAP_XSAVE2 208 1136 + #define KVM_CAP_SYS_ATTRIBUTES 209 1136 1137 1137 1138 #ifdef KVM_CAP_IRQ_ROUTING 1138 1139
+2 -1
tools/testing/scatterlist/linux/mm.h
··· 74 74 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ 75 75 x, y) 76 76 77 - #define preemptible() (1) 77 + #define pagefault_disabled() (0) 78 78 79 79 static inline void *kmap(struct page *page) 80 80 { ··· 127 127 #define kmemleak_free(a) 128 128 129 129 #define PageSlab(p) (0) 130 + #define flush_dcache_page(p) 130 131 131 132 #define MAX_ERRNO 4095 132 133
+9 -2
tools/testing/selftests/arm64/fp/sve-ptrace.c
··· 261 261 } 262 262 263 263 ksft_test_result((sve->flags & SVE_PT_REGS_MASK) == SVE_PT_REGS_FPSIMD, 264 - "Set FPSIMD registers via %s\n", type->name); 264 + "Got FPSIMD registers via %s\n", type->name); 265 265 if ((sve->flags & SVE_PT_REGS_MASK) != SVE_PT_REGS_FPSIMD) 266 266 goto out; 267 267 ··· 557 557 } 558 558 559 559 /* prctl() flags */ 560 - ptrace_set_get_inherit(child, &vec_types[i]); 560 + if (getauxval(vec_types[i].hwcap_type) & vec_types[i].hwcap) { 561 + ptrace_set_get_inherit(child, &vec_types[i]); 562 + } else { 563 + ksft_test_result_skip("%s SVE_PT_VL_INHERIT set\n", 564 + vec_types[i].name); 565 + ksft_test_result_skip("%s SVE_PT_VL_INHERIT cleared\n", 566 + vec_types[i].name); 567 + } 561 568 562 569 /* Step through every possible VQ */ 563 570 for (vq = SVE_VQ_MIN; vq <= SVE_VQ_MAX; vq++) {
+1
tools/testing/selftests/kvm/Makefile
··· 85 85 TEST_GEN_PROGS_x86_64 += x86_64/vmx_pi_mmio_test 86 86 TEST_GEN_PROGS_x86_64 += x86_64/sev_migrate_tests 87 87 TEST_GEN_PROGS_x86_64 += x86_64/amx_test 88 + TEST_GEN_PROGS_x86_64 += access_tracking_perf_test 88 89 TEST_GEN_PROGS_x86_64 += demand_paging_test 89 90 TEST_GEN_PROGS_x86_64 += dirty_log_test 90 91 TEST_GEN_PROGS_x86_64 += dirty_log_perf_test
-1
tools/testing/selftests/kvm/include/kvm_util_base.h
··· 345 345 * guest_code - The vCPU's entry point 346 346 */ 347 347 void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code); 348 - void vm_xsave_req_perm(void); 349 348 350 349 bool vm_is_unrestricted_guest(struct kvm_vm *vm); 351 350
+1
tools/testing/selftests/kvm/include/x86_64/processor.h
··· 458 458 struct kvm_cpuid2 *kvm_get_supported_hv_cpuid(void); 459 459 void vcpu_set_hv_cpuid(struct kvm_vm *vm, uint32_t vcpuid); 460 460 struct kvm_cpuid2 *vcpu_get_supported_hv_cpuid(struct kvm_vm *vm, uint32_t vcpuid); 461 + void vm_xsave_req_perm(int bit); 461 462 462 463 enum x86_page_size { 463 464 X86_PAGE_SIZE_4K = 0,
-7
tools/testing/selftests/kvm/lib/kvm_util.c
··· 393 393 struct kvm_vm *vm; 394 394 int i; 395 395 396 - #ifdef __x86_64__ 397 - /* 398 - * Permission needs to be requested before KVM_SET_CPUID2. 399 - */ 400 - vm_xsave_req_perm(); 401 - #endif 402 - 403 396 /* Force slot0 memory size not small than DEFAULT_GUEST_PHY_PAGES */ 404 397 if (slot0_mem_pages < DEFAULT_GUEST_PHY_PAGES) 405 398 slot0_mem_pages = DEFAULT_GUEST_PHY_PAGES;
+21 -6
tools/testing/selftests/kvm/lib/x86_64/processor.c
··· 665 665 return !!(eax & CPUID_XFD_BIT); 666 666 } 667 667 668 - void vm_xsave_req_perm(void) 668 + void vm_xsave_req_perm(int bit) 669 669 { 670 - unsigned long bitmask; 670 + int kvm_fd; 671 + u64 bitmask; 671 672 long rc; 673 + struct kvm_device_attr attr = { 674 + .group = 0, 675 + .attr = KVM_X86_XCOMP_GUEST_SUPP, 676 + .addr = (unsigned long) &bitmask 677 + }; 678 + 679 + kvm_fd = open_kvm_dev_path_or_exit(); 680 + rc = ioctl(kvm_fd, KVM_GET_DEVICE_ATTR, &attr); 681 + close(kvm_fd); 682 + if (rc == -1 && (errno == ENXIO || errno == EINVAL)) 683 + exit(KSFT_SKIP); 684 + TEST_ASSERT(rc == 0, "KVM_GET_DEVICE_ATTR(0, KVM_X86_XCOMP_GUEST_SUPP) error: %ld", rc); 685 + if (!(bitmask & (1ULL << bit))) 686 + exit(KSFT_SKIP); 672 687 673 688 if (!is_xfd_supported()) 674 - return; 689 + exit(KSFT_SKIP); 675 690 676 - rc = syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_GUEST_PERM, 677 - XSTATE_XTILE_DATA_BIT); 691 + rc = syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_GUEST_PERM, bit); 692 + 678 693 /* 679 694 * The older kernel version(<5.15) can't support 680 695 * ARCH_REQ_XCOMP_GUEST_PERM and directly return. ··· 699 684 700 685 rc = syscall(SYS_arch_prctl, ARCH_GET_XCOMP_GUEST_PERM, &bitmask); 701 686 TEST_ASSERT(rc == 0, "prctl(ARCH_GET_XCOMP_GUEST_PERM) error: %ld", rc); 702 - TEST_ASSERT(bitmask & XFEATURE_XTILE_MASK, 687 + TEST_ASSERT(bitmask & (1ULL << bit), 703 688 "prctl(ARCH_REQ_XCOMP_GUEST_PERM) failure bitmask=0x%lx", 704 689 bitmask); 705 690 }
+2
tools/testing/selftests/kvm/x86_64/amx_test.c
··· 329 329 u32 amx_offset; 330 330 int stage, ret; 331 331 332 + vm_xsave_req_perm(XSTATE_XTILE_DATA_BIT); 333 + 332 334 /* Create VM */ 333 335 vm = vm_create_default(VCPU_ID, 0, guest_code); 334 336
-1
tools/testing/selftests/kvm/x86_64/smm_test.c
··· 105 105 106 106 if (cpu_has_svm()) { 107 107 run_guest(svm->vmcb, svm->vmcb_gpa); 108 - svm->vmcb->save.rip += 3; 109 108 run_guest(svm->vmcb, svm->vmcb_gpa); 110 109 } else { 111 110 vmlaunch();
+1 -4
tools/testing/selftests/net/ioam6_parser.c
··· 240 240 *p += sizeof(__u32); 241 241 } 242 242 243 - if (ioam6h->type.bit6) { 244 - if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff) 245 - return 1; 243 + if (ioam6h->type.bit6) 246 244 *p += sizeof(__u32); 247 - } 248 245 249 246 if (ioam6h->type.bit7) { 250 247 if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+3 -2
tools/testing/selftests/net/mptcp/mptcp_join.sh
··· 75 75 76 76 # let $ns2 reach any $ns1 address from any interface 77 77 ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i 78 + ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i 78 79 done 79 80 } 80 81 ··· 1477 1476 reset 1478 1477 ip netns exec $ns1 ./pm_nl_ctl limits 0 1 1479 1478 ip netns exec $ns2 ./pm_nl_ctl limits 0 1 1480 - ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow 1479 + ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 dev ns2eth3 flags subflow 1481 1480 run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow 1482 1481 chk_join_nr "single subflow IPv6" 1 1 1 1483 1482 ··· 1512 1511 ip netns exec $ns1 ./pm_nl_ctl limits 0 2 1513 1512 ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal 1514 1513 ip netns exec $ns2 ./pm_nl_ctl limits 1 2 1515 - ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow 1514 + ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 dev ns2eth3 flags subflow 1516 1515 run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow 1517 1516 chk_join_nr "remove subflow and signal IPv6" 2 2 2 1518 1517 chk_add_nr 1 1
+14 -4
tools/tracing/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 include ../scripts/Makefile.include 3 3 4 - all: latency 4 + all: latency rtla 5 5 6 - clean: latency_clean 6 + clean: latency_clean rtla_clean 7 7 8 - install: latency_install 8 + install: latency_install rtla_install 9 9 10 10 latency: 11 11 $(call descend,latency) ··· 16 16 latency_clean: 17 17 $(call descend,latency,clean) 18 18 19 - .PHONY: all install clean latency latency_install latency_clean 19 + rtla: 20 + $(call descend,rtla) 21 + 22 + rtla_install: 23 + $(call descend,rtla,install) 24 + 25 + rtla_clean: 26 + $(call descend,rtla,clean) 27 + 28 + .PHONY: all install clean latency latency_install latency_clean \ 29 + rtla rtla_install rtla_clean
+1 -1
tools/tracing/rtla/Makefile
··· 59 59 .PHONY: all 60 60 all: rtla 61 61 62 - rtla: $(OBJ) doc 62 + rtla: $(OBJ) 63 63 $(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS) 64 64 65 65 static: $(OBJ)
+1
usr/include/Makefile
··· 28 28 no-header-test += linux/android/binder.h 29 29 no-header-test += linux/android/binderfs.h 30 30 no-header-test += linux/coda.h 31 + no-header-test += linux/cyclades.h 31 32 no-header-test += linux/errqueue.h 32 33 no-header-test += linux/fsmap.h 33 34 no-header-test += linux/hdlc/ioctl.h
+4 -4
virt/kvm/eventfd.c
··· 463 463 idx = srcu_read_lock(&kvm->irq_srcu); 464 464 gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin); 465 465 if (gsi != -1) 466 - hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list, 467 - link) 466 + hlist_for_each_entry_srcu(kian, &kvm->irq_ack_notifier_list, 467 + link, srcu_read_lock_held(&kvm->irq_srcu)) 468 468 if (kian->gsi == gsi) { 469 469 srcu_read_unlock(&kvm->irq_srcu, idx); 470 470 return true; ··· 480 480 { 481 481 struct kvm_irq_ack_notifier *kian; 482 482 483 - hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list, 484 - link) 483 + hlist_for_each_entry_srcu(kian, &kvm->irq_ack_notifier_list, 484 + link, srcu_read_lock_held(&kvm->irq_srcu)) 485 485 if (kian->gsi == gsi) 486 486 kian->irq_acked(kian); 487 487 }
+3 -5
virt/kvm/kvm_main.c
··· 2248 2248 2249 2249 return NULL; 2250 2250 } 2251 - EXPORT_SYMBOL_GPL(kvm_vcpu_gfn_to_memslot); 2252 2251 2253 2252 bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn) 2254 2253 { ··· 2462 2463 } 2463 2464 2464 2465 static int hva_to_pfn_remapped(struct vm_area_struct *vma, 2465 - unsigned long addr, bool *async, 2466 - bool write_fault, bool *writable, 2467 - kvm_pfn_t *p_pfn) 2466 + unsigned long addr, bool write_fault, 2467 + bool *writable, kvm_pfn_t *p_pfn) 2468 2468 { 2469 2469 kvm_pfn_t pfn; 2470 2470 pte_t *ptep; ··· 2573 2575 if (vma == NULL) 2574 2576 pfn = KVM_PFN_ERR_FAULT; 2575 2577 else if (vma->vm_flags & (VM_IO | VM_PFNMAP)) { 2576 - r = hva_to_pfn_remapped(vma, addr, async, write_fault, writable, &pfn); 2578 + r = hva_to_pfn_remapped(vma, addr, write_fault, writable, &pfn); 2577 2579 if (r == -EAGAIN) 2578 2580 goto retry; 2579 2581 if (r < 0)