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

Merge remote-tracking branch 'torvalds/master' into perf/core

To pick up fixes from perf/urgent to allow perf/core to be used for new
development.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+6639 -2537
+14 -3
Documentation/admin-guide/sysctl/kernel.rst
··· 1458 1458 ========================= 1459 1459 1460 1460 Writing 1 to this entry will disable unprivileged calls to ``bpf()``; 1461 - once disabled, calling ``bpf()`` without ``CAP_SYS_ADMIN`` will return 1462 - ``-EPERM``. 1461 + once disabled, calling ``bpf()`` without ``CAP_SYS_ADMIN`` or ``CAP_BPF`` 1462 + will return ``-EPERM``. Once set to 1, this can't be cleared from the 1463 + running kernel anymore. 1463 1464 1464 - Once set, this can't be cleared. 1465 + Writing 2 to this entry will also disable unprivileged calls to ``bpf()``, 1466 + however, an admin can still change this setting later on, if needed, by 1467 + writing 0 or 1 to this entry. 1465 1468 1469 + If ``BPF_UNPRIV_DEFAULT_OFF`` is enabled in the kernel config, then this 1470 + entry will default to 2 instead of 0. 1471 + 1472 + = ============================================================= 1473 + 0 Unprivileged calls to ``bpf()`` are enabled 1474 + 1 Unprivileged calls to ``bpf()`` are disabled without recovery 1475 + 2 Unprivileged calls to ``bpf()`` are disabled 1476 + = ============================================================= 1466 1477 1467 1478 watchdog 1468 1479 ========
+7
Documentation/devicetree/bindings/i2c/i2c-mpc.yaml
··· 46 46 description: | 47 47 I2C bus timeout in microseconds 48 48 49 + fsl,i2c-erratum-a004447: 50 + $ref: /schemas/types.yaml#/definitions/flag 51 + description: | 52 + Indicates the presence of QorIQ erratum A-004447, which 53 + says that the standard i2c recovery scheme mechanism does 54 + not work and an alternate implementation is needed. 55 + 49 56 required: 50 57 - compatible 51 58 - reg
+1 -1
Documentation/devicetree/bindings/net/renesas,ether.yaml
··· 10 10 - $ref: ethernet-controller.yaml# 11 11 12 12 maintainers: 13 - - Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> 13 + - Sergei Shtylyov <sergei.shtylyov@gmail.com> 14 14 15 15 properties: 16 16 compatible:
+2
Documentation/driver-api/usb/usb.rst
··· 123 123 In addition, some functions useful for creating debugging output are 124 124 defined in ``drivers/usb/common/debug.c``. 125 125 126 + .. _usb_header: 127 + 126 128 Host-Side Data Types and Macros 127 129 =============================== 128 130
+8 -8
Documentation/userspace-api/seccomp_filter.rst
··· 250 250 seccomp notification fd to receive a ``struct seccomp_notif``, which contains 251 251 five members: the input length of the structure, a unique-per-filter ``id``, 252 252 the ``pid`` of the task which triggered this request (which may be 0 if the 253 - task is in a pid ns not visible from the listener's pid namespace), a ``flags`` 254 - member which for now only has ``SECCOMP_NOTIF_FLAG_SIGNALED``, representing 255 - whether or not the notification is a result of a non-fatal signal, and the 256 - ``data`` passed to seccomp. Userspace can then make a decision based on this 257 - information about what to do, and ``ioctl(SECCOMP_IOCTL_NOTIF_SEND)`` a 258 - response, indicating what should be returned to userspace. The ``id`` member of 259 - ``struct seccomp_notif_resp`` should be the same ``id`` as in ``struct 260 - seccomp_notif``. 253 + task is in a pid ns not visible from the listener's pid namespace). The 254 + notification also contains the ``data`` passed to seccomp, and a filters flag. 255 + The structure should be zeroed out prior to calling the ioctl. 256 + 257 + Userspace can then make a decision based on this information about what to do, 258 + and ``ioctl(SECCOMP_IOCTL_NOTIF_SEND)`` a response, indicating what should be 259 + returned to userspace. The ``id`` member of ``struct seccomp_notif_resp`` should 260 + be the same ``id`` as in ``struct seccomp_notif``. 261 261 262 262 It is worth noting that ``struct seccomp_data`` contains the values of register 263 263 arguments to the syscall, but does not contain pointers to memory. The task's
+5 -3
Documentation/virt/kvm/vcpu-requests.rst
··· 118 118 necessary to inform each VCPU to completely refresh the tables. This 119 119 request is used for that. 120 120 121 - KVM_REQ_PENDING_TIMER 121 + KVM_REQ_UNBLOCK 122 122 123 - This request may be made from a timer handler run on the host on behalf 124 - of a VCPU. It informs the VCPU thread to inject a timer interrupt. 123 + This request informs the vCPU to exit kvm_vcpu_block. It is used for 124 + example from timer handlers that run on the host on behalf of a vCPU, 125 + or in order to update the interrupt routing and ensure that assigned 126 + devices will wake up the vCPU. 125 127 126 128 KVM_REQ_UNHALT 127 129
+19 -8
MAINTAINERS
··· 4138 4138 F: Documentation/devicetree/bindings/arm/cavium-thunder2.txt 4139 4139 F: arch/arm64/boot/dts/cavium/thunder2-99xx* 4140 4140 4141 + CBS/ETF/TAPRIO QDISCS 4142 + M: Vinicius Costa Gomes <vinicius.gomes@intel.com> 4143 + S: Maintained 4144 + L: netdev@vger.kernel.org 4145 + F: net/sched/sch_cbs.c 4146 + F: net/sched/sch_etf.c 4147 + F: net/sched/sch_taprio.c 4148 + 4141 4149 CC2520 IEEE-802.15.4 RADIO DRIVER 4142 4150 M: Varka Bhadram <varkabhadram@gmail.com> 4143 4151 L: linux-wpan@vger.kernel.org ··· 5577 5569 5578 5570 DPAA2 ETHERNET DRIVER 5579 5571 M: Ioana Ciornei <ioana.ciornei@nxp.com> 5580 - M: Ioana Radulescu <ruxandra.radulescu@nxp.com> 5581 5572 L: netdev@vger.kernel.org 5582 5573 S: Maintained 5583 5574 F: Documentation/networking/device_drivers/ethernet/freescale/dpaa2/ethernet-driver.rst ··· 6945 6938 FANOTIFY 6946 6939 M: Jan Kara <jack@suse.cz> 6947 6940 R: Amir Goldstein <amir73il@gmail.com> 6941 + R: Matthew Bobrowski <repnop@google.com> 6948 6942 L: linux-fsdevel@vger.kernel.org 6949 6943 S: Maintained 6950 6944 F: fs/notify/fanotify/ ··· 12689 12681 F: include/linux/mfd/ntxec.h 12690 12682 12691 12683 NETRONOME ETHERNET DRIVERS 12692 - M: Simon Horman <simon.horman@netronome.com> 12684 + M: Simon Horman <simon.horman@corigine.com> 12693 12685 R: Jakub Kicinski <kuba@kernel.org> 12694 - L: oss-drivers@netronome.com 12686 + L: oss-drivers@corigine.com 12695 12687 S: Maintained 12696 12688 F: drivers/net/ethernet/netronome/ 12697 12689 ··· 12718 12710 M: Jakub Kicinski <kuba@kernel.org> 12719 12711 L: netdev@vger.kernel.org 12720 12712 S: Maintained 12721 - W: http://www.linuxfoundation.org/en/Net 12722 12713 Q: https://patchwork.kernel.org/project/netdevbpf/list/ 12723 12714 T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git 12724 12715 T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git ··· 12762 12755 M: Jakub Kicinski <kuba@kernel.org> 12763 12756 L: netdev@vger.kernel.org 12764 12757 S: Maintained 12765 - W: http://www.linuxfoundation.org/en/Net 12766 12758 Q: https://patchwork.kernel.org/project/netdevbpf/list/ 12767 12759 B: mailto:netdev@vger.kernel.org 12768 12760 T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git ··· 12903 12897 F: net/ipv4/nexthop.c 12904 12898 12905 12899 NFC SUBSYSTEM 12900 + M: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 12901 + L: linux-nfc@lists.01.org (moderated for non-subscribers) 12906 12902 L: netdev@vger.kernel.org 12907 - S: Orphan 12903 + S: Maintained 12908 12904 F: Documentation/devicetree/bindings/net/nfc/ 12909 12905 F: drivers/nfc/ 12910 12906 F: include/linux/platform_data/nfcmrvl.h ··· 13214 13206 F: sound/soc/codecs/tfa9879* 13215 13207 13216 13208 NXP-NCI NFC DRIVER 13217 - M: Clément Perrochaud <clement.perrochaud@effinnov.com> 13218 13209 R: Charles Gorand <charles.gorand@effinnov.com> 13219 13210 L: linux-nfc@lists.01.org (moderated for non-subscribers) 13220 13211 S: Supported ··· 14325 14318 M: Dennis Zhou <dennis@kernel.org> 14326 14319 M: Tejun Heo <tj@kernel.org> 14327 14320 M: Christoph Lameter <cl@linux.com> 14321 + L: linux-mm@kvack.org 14328 14322 S: Maintained 14329 14323 T: git git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu.git 14330 14324 F: arch/*/include/asm/percpu.h 14331 14325 F: include/linux/percpu*.h 14326 + F: lib/percpu*.c 14332 14327 F: mm/percpu*.c 14333 14328 14334 14329 PER-TASK DELAY ACCOUNTING ··· 15954 15945 M: Julian Wiedmann <jwi@linux.ibm.com> 15955 15946 M: Karsten Graul <kgraul@linux.ibm.com> 15956 15947 L: linux-s390@vger.kernel.org 15948 + L: netdev@vger.kernel.org 15957 15949 S: Supported 15958 15950 W: http://www.ibm.com/developerworks/linux/linux390/ 15959 15951 F: drivers/s390/net/*iucv* ··· 15965 15955 M: Julian Wiedmann <jwi@linux.ibm.com> 15966 15956 M: Karsten Graul <kgraul@linux.ibm.com> 15967 15957 L: linux-s390@vger.kernel.org 15958 + L: netdev@vger.kernel.org 15968 15959 S: Supported 15969 15960 W: http://www.ibm.com/developerworks/linux/linux390/ 15970 15961 F: drivers/s390/net/ ··· 17679 17668 L: linux-i2c@vger.kernel.org 17680 17669 S: Maintained 17681 17670 F: drivers/i2c/busses/i2c-designware-* 17682 - F: include/linux/platform_data/i2c-designware.h 17683 17671 17684 17672 SYNOPSYS DESIGNWARE MMC/SD/SDIO DRIVER 17685 17673 M: Jaehoon Chung <jh80.chung@samsung.com> ··· 20014 20004 F: drivers/xen/*swiotlb* 20015 20005 20016 20006 XFS FILESYSTEM 20007 + C: irc://irc.oftc.net/xfs 20017 20008 M: Darrick J. Wong <djwong@kernel.org> 20018 20009 M: linux-xfs@vger.kernel.org 20019 20010 L: linux-xfs@vger.kernel.org
+6 -1
Makefile
··· 2 2 VERSION = 5 3 3 PATCHLEVEL = 13 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc3 5 + EXTRAVERSION = -rc4 6 6 NAME = Frozen Wasteland 7 7 8 8 # *DOCUMENTATION* ··· 928 928 929 929 # Limit inlining across translation units to reduce binary size 930 930 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5 931 + 932 + # Check for frame size exceeding threshold during prolog/epilog insertion. 933 + ifneq ($(CONFIG_FRAME_WARN),0) 934 + KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN) 935 + endif 931 936 endif 932 937 933 938 ifdef CONFIG_LTO
+1 -2
arch/arm64/Kbuild
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 - obj-y += kernel/ mm/ 3 - obj-$(CONFIG_NET) += net/ 2 + obj-y += kernel/ mm/ net/ 4 3 obj-$(CONFIG_KVM) += kvm/ 5 4 obj-$(CONFIG_XEN) += xen/ 6 5 obj-$(CONFIG_CRYPTO) += crypto/
+1 -1
arch/arm64/include/asm/barrier.h
··· 74 74 * This insanity brought to you by speculative system register reads, 75 75 * out-of-order memory accesses, sequence locks and Thomas Gleixner. 76 76 * 77 - * http://lists.infradead.org/pipermail/linux-arm-kernel/2019-February/631195.html 77 + * https://lore.kernel.org/r/alpine.DEB.2.21.1902081950260.1662@nanos.tec.linutronix.de/ 78 78 */ 79 79 #define arch_counter_enforce_ordering(val) do { \ 80 80 u64 tmp, _val = (val); \
+3
arch/arm64/include/asm/kvm_asm.h
··· 63 63 #define __KVM_HOST_SMCCC_FUNC___pkvm_cpu_set_vector 18 64 64 #define __KVM_HOST_SMCCC_FUNC___pkvm_prot_finalize 19 65 65 #define __KVM_HOST_SMCCC_FUNC___pkvm_mark_hyp 20 66 + #define __KVM_HOST_SMCCC_FUNC___kvm_adjust_pc 21 66 67 67 68 #ifndef __ASSEMBLY__ 68 69 ··· 201 200 extern void __kvm_timer_set_cntvoff(u64 cntvoff); 202 201 203 202 extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu); 203 + 204 + extern void __kvm_adjust_pc(struct kvm_vcpu *vcpu); 204 205 205 206 extern u64 __vgic_v3_get_gic_config(void); 206 207 extern u64 __vgic_v3_read_vmcr(void);
+5
arch/arm64/include/asm/kvm_emulate.h
··· 463 463 vcpu->arch.flags |= KVM_ARM64_INCREMENT_PC; 464 464 } 465 465 466 + static inline bool vcpu_has_feature(struct kvm_vcpu *vcpu, int feature) 467 + { 468 + return test_bit(feature, vcpu->arch.features); 469 + } 470 + 466 471 #endif /* __ARM64_KVM_EMULATE_H__ */
+17 -3
arch/arm64/kvm/arm.c
··· 720 720 return ret; 721 721 } 722 722 723 - if (run->immediate_exit) 724 - return -EINTR; 725 - 726 723 vcpu_load(vcpu); 724 + 725 + if (run->immediate_exit) { 726 + ret = -EINTR; 727 + goto out; 728 + } 727 729 728 730 kvm_sigset_activate(vcpu); 729 731 ··· 898 896 } 899 897 900 898 kvm_sigset_deactivate(vcpu); 899 + 900 + out: 901 + /* 902 + * In the unlikely event that we are returning to userspace 903 + * with pending exceptions or PC adjustment, commit these 904 + * adjustments in order to give userspace a consistent view of 905 + * the vcpu state. Note that this relies on __kvm_adjust_pc() 906 + * being preempt-safe on VHE. 907 + */ 908 + if (unlikely(vcpu->arch.flags & (KVM_ARM64_PENDING_EXCEPTION | 909 + KVM_ARM64_INCREMENT_PC))) 910 + kvm_call_hyp(__kvm_adjust_pc, vcpu); 901 911 902 912 vcpu_put(vcpu); 903 913 return ret;
+17 -1
arch/arm64/kvm/hyp/exception.c
··· 296 296 *vcpu_pc(vcpu) = vect_offset; 297 297 } 298 298 299 - void kvm_inject_exception(struct kvm_vcpu *vcpu) 299 + static void kvm_inject_exception(struct kvm_vcpu *vcpu) 300 300 { 301 301 if (vcpu_el1_is_32bit(vcpu)) { 302 302 switch (vcpu->arch.flags & KVM_ARM64_EXCEPT_MASK) { ··· 327 327 */ 328 328 break; 329 329 } 330 + } 331 + } 332 + 333 + /* 334 + * Adjust the guest PC (and potentially exception state) depending on 335 + * flags provided by the emulation code. 336 + */ 337 + void __kvm_adjust_pc(struct kvm_vcpu *vcpu) 338 + { 339 + if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) { 340 + kvm_inject_exception(vcpu); 341 + vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION | 342 + KVM_ARM64_EXCEPT_MASK); 343 + } else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) { 344 + kvm_skip_instr(vcpu); 345 + vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC; 330 346 } 331 347 }
-18
arch/arm64/kvm/hyp/include/hyp/adjust_pc.h
··· 13 13 #include <asm/kvm_emulate.h> 14 14 #include <asm/kvm_host.h> 15 15 16 - void kvm_inject_exception(struct kvm_vcpu *vcpu); 17 - 18 16 static inline void kvm_skip_instr(struct kvm_vcpu *vcpu) 19 17 { 20 18 if (vcpu_mode_is_32bit(vcpu)) { ··· 39 41 40 42 write_sysreg_el2(vcpu_gp_regs(vcpu)->pstate, SYS_SPSR); 41 43 write_sysreg_el2(*vcpu_pc(vcpu), SYS_ELR); 42 - } 43 - 44 - /* 45 - * Adjust the guest PC on entry, depending on flags provided by EL1 46 - * for the purpose of emulation (MMIO, sysreg) or exception injection. 47 - */ 48 - static inline void __adjust_pc(struct kvm_vcpu *vcpu) 49 - { 50 - if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) { 51 - kvm_inject_exception(vcpu); 52 - vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION | 53 - KVM_ARM64_EXCEPT_MASK); 54 - } else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) { 55 - kvm_skip_instr(vcpu); 56 - vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC; 57 - } 58 44 } 59 45 60 46 /*
+8
arch/arm64/kvm/hyp/nvhe/hyp-main.c
··· 28 28 cpu_reg(host_ctxt, 1) = __kvm_vcpu_run(kern_hyp_va(vcpu)); 29 29 } 30 30 31 + static void handle___kvm_adjust_pc(struct kvm_cpu_context *host_ctxt) 32 + { 33 + DECLARE_REG(struct kvm_vcpu *, vcpu, host_ctxt, 1); 34 + 35 + __kvm_adjust_pc(kern_hyp_va(vcpu)); 36 + } 37 + 31 38 static void handle___kvm_flush_vm_context(struct kvm_cpu_context *host_ctxt) 32 39 { 33 40 __kvm_flush_vm_context(); ··· 177 170 178 171 static const hcall_t host_hcall[] = { 179 172 HANDLE_FUNC(__kvm_vcpu_run), 173 + HANDLE_FUNC(__kvm_adjust_pc), 180 174 HANDLE_FUNC(__kvm_flush_vm_context), 181 175 HANDLE_FUNC(__kvm_tlb_flush_vmid_ipa), 182 176 HANDLE_FUNC(__kvm_tlb_flush_vmid),
+2 -2
arch/arm64/kvm/hyp/nvhe/mem_protect.c
··· 23 23 extern unsigned long hyp_nr_cpus; 24 24 struct host_kvm host_kvm; 25 25 26 - struct hyp_pool host_s2_mem; 27 - struct hyp_pool host_s2_dev; 26 + static struct hyp_pool host_s2_mem; 27 + static struct hyp_pool host_s2_dev; 28 28 29 29 /* 30 30 * Copies of the host's CPU features registers holding sanitized values.
+1 -1
arch/arm64/kvm/hyp/nvhe/setup.c
··· 17 17 #include <nvhe/trap_handler.h> 18 18 19 19 struct hyp_pool hpool; 20 - struct kvm_pgtable_mm_ops pkvm_pgtable_mm_ops; 21 20 unsigned long hyp_nr_cpus; 22 21 23 22 #define hyp_percpu_size ((unsigned long)__per_cpu_end - \ ··· 26 27 static void *hyp_pgt_base; 27 28 static void *host_s2_mem_pgt_base; 28 29 static void *host_s2_dev_pgt_base; 30 + static struct kvm_pgtable_mm_ops pkvm_pgtable_mm_ops; 29 31 30 32 static int divide_memory_pool(void *virt, unsigned long size) 31 33 {
+1 -2
arch/arm64/kvm/hyp/nvhe/switch.c
··· 4 4 * Author: Marc Zyngier <marc.zyngier@arm.com> 5 5 */ 6 6 7 - #include <hyp/adjust_pc.h> 8 7 #include <hyp/switch.h> 9 8 #include <hyp/sysreg-sr.h> 10 9 ··· 200 201 */ 201 202 __debug_save_host_buffers_nvhe(vcpu); 202 203 203 - __adjust_pc(vcpu); 204 + __kvm_adjust_pc(vcpu); 204 205 205 206 /* 206 207 * We must restore the 32-bit state before the sysregs, thanks
+1 -2
arch/arm64/kvm/hyp/vhe/switch.c
··· 4 4 * Author: Marc Zyngier <marc.zyngier@arm.com> 5 5 */ 6 6 7 - #include <hyp/adjust_pc.h> 8 7 #include <hyp/switch.h> 9 8 10 9 #include <linux/arm-smccc.h> ··· 131 132 __load_guest_stage2(vcpu->arch.hw_mmu); 132 133 __activate_traps(vcpu); 133 134 134 - __adjust_pc(vcpu); 135 + __kvm_adjust_pc(vcpu); 135 136 136 137 sysreg_restore_guest_state_vhe(guest_ctxt); 137 138 __debug_switch_to_guest(vcpu);
+6 -6
arch/arm64/kvm/mmu.c
··· 1156 1156 bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range) 1157 1157 { 1158 1158 if (!kvm->arch.mmu.pgt) 1159 - return 0; 1159 + return false; 1160 1160 1161 1161 __unmap_stage2_range(&kvm->arch.mmu, range->start << PAGE_SHIFT, 1162 1162 (range->end - range->start) << PAGE_SHIFT, 1163 1163 range->may_block); 1164 1164 1165 - return 0; 1165 + return false; 1166 1166 } 1167 1167 1168 1168 bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range) ··· 1170 1170 kvm_pfn_t pfn = pte_pfn(range->pte); 1171 1171 1172 1172 if (!kvm->arch.mmu.pgt) 1173 - return 0; 1173 + return false; 1174 1174 1175 1175 WARN_ON(range->end - range->start != 1); 1176 1176 ··· 1190 1190 PAGE_SIZE, __pfn_to_phys(pfn), 1191 1191 KVM_PGTABLE_PROT_R, NULL); 1192 1192 1193 - return 0; 1193 + return false; 1194 1194 } 1195 1195 1196 1196 bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range) ··· 1200 1200 pte_t pte; 1201 1201 1202 1202 if (!kvm->arch.mmu.pgt) 1203 - return 0; 1203 + return false; 1204 1204 1205 1205 WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE); 1206 1206 ··· 1213 1213 bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range) 1214 1214 { 1215 1215 if (!kvm->arch.mmu.pgt) 1216 - return 0; 1216 + return false; 1217 1217 1218 1218 return kvm_pgtable_stage2_is_young(kvm->arch.mmu.pgt, 1219 1219 range->start << PAGE_SHIFT);
+24 -4
arch/arm64/kvm/reset.c
··· 166 166 return 0; 167 167 } 168 168 169 + static bool vcpu_allowed_register_width(struct kvm_vcpu *vcpu) 170 + { 171 + struct kvm_vcpu *tmp; 172 + bool is32bit; 173 + int i; 174 + 175 + is32bit = vcpu_has_feature(vcpu, KVM_ARM_VCPU_EL1_32BIT); 176 + if (!cpus_have_const_cap(ARM64_HAS_32BIT_EL1) && is32bit) 177 + return false; 178 + 179 + /* Check that the vcpus are either all 32bit or all 64bit */ 180 + kvm_for_each_vcpu(i, tmp, vcpu->kvm) { 181 + if (vcpu_has_feature(tmp, KVM_ARM_VCPU_EL1_32BIT) != is32bit) 182 + return false; 183 + } 184 + 185 + return true; 186 + } 187 + 169 188 /** 170 189 * kvm_reset_vcpu - sets core registers and sys_regs to reset value 171 190 * @vcpu: The VCPU pointer ··· 236 217 } 237 218 } 238 219 220 + if (!vcpu_allowed_register_width(vcpu)) { 221 + ret = -EINVAL; 222 + goto out; 223 + } 224 + 239 225 switch (vcpu->arch.target) { 240 226 default: 241 227 if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { 242 - if (!cpus_have_const_cap(ARM64_HAS_32BIT_EL1)) { 243 - ret = -EINVAL; 244 - goto out; 245 - } 246 228 pstate = VCPU_RESET_PSTATE_SVC; 247 229 } else { 248 230 pstate = VCPU_RESET_PSTATE_EL1;
+21 -21
arch/arm64/kvm/sys_regs.c
··· 399 399 struct sys_reg_params *p, 400 400 const struct sys_reg_desc *rd) 401 401 { 402 - u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg]; 402 + u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm]; 403 403 404 404 if (p->is_write) 405 405 reg_to_dbg(vcpu, p, rd, dbg_reg); 406 406 else 407 407 dbg_to_reg(vcpu, p, rd, dbg_reg); 408 408 409 - trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg); 409 + trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg); 410 410 411 411 return true; 412 412 } ··· 414 414 static int set_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, 415 415 const struct kvm_one_reg *reg, void __user *uaddr) 416 416 { 417 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg]; 417 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm]; 418 418 419 419 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0) 420 420 return -EFAULT; ··· 424 424 static int get_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, 425 425 const struct kvm_one_reg *reg, void __user *uaddr) 426 426 { 427 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg]; 427 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm]; 428 428 429 429 if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0) 430 430 return -EFAULT; ··· 434 434 static void reset_bvr(struct kvm_vcpu *vcpu, 435 435 const struct sys_reg_desc *rd) 436 436 { 437 - vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg] = rd->val; 437 + vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm] = rd->val; 438 438 } 439 439 440 440 static bool trap_bcr(struct kvm_vcpu *vcpu, 441 441 struct sys_reg_params *p, 442 442 const struct sys_reg_desc *rd) 443 443 { 444 - u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg]; 444 + u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm]; 445 445 446 446 if (p->is_write) 447 447 reg_to_dbg(vcpu, p, rd, dbg_reg); 448 448 else 449 449 dbg_to_reg(vcpu, p, rd, dbg_reg); 450 450 451 - trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg); 451 + trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg); 452 452 453 453 return true; 454 454 } ··· 456 456 static int set_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, 457 457 const struct kvm_one_reg *reg, void __user *uaddr) 458 458 { 459 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg]; 459 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm]; 460 460 461 461 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0) 462 462 return -EFAULT; ··· 467 467 static int get_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, 468 468 const struct kvm_one_reg *reg, void __user *uaddr) 469 469 { 470 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg]; 470 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm]; 471 471 472 472 if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0) 473 473 return -EFAULT; ··· 477 477 static void reset_bcr(struct kvm_vcpu *vcpu, 478 478 const struct sys_reg_desc *rd) 479 479 { 480 - vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg] = rd->val; 480 + vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm] = rd->val; 481 481 } 482 482 483 483 static bool trap_wvr(struct kvm_vcpu *vcpu, 484 484 struct sys_reg_params *p, 485 485 const struct sys_reg_desc *rd) 486 486 { 487 - u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg]; 487 + u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm]; 488 488 489 489 if (p->is_write) 490 490 reg_to_dbg(vcpu, p, rd, dbg_reg); 491 491 else 492 492 dbg_to_reg(vcpu, p, rd, dbg_reg); 493 493 494 - trace_trap_reg(__func__, rd->reg, p->is_write, 495 - vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg]); 494 + trace_trap_reg(__func__, rd->CRm, p->is_write, 495 + vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm]); 496 496 497 497 return true; 498 498 } ··· 500 500 static int set_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, 501 501 const struct kvm_one_reg *reg, void __user *uaddr) 502 502 { 503 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg]; 503 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm]; 504 504 505 505 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0) 506 506 return -EFAULT; ··· 510 510 static int get_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, 511 511 const struct kvm_one_reg *reg, void __user *uaddr) 512 512 { 513 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg]; 513 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm]; 514 514 515 515 if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0) 516 516 return -EFAULT; ··· 520 520 static void reset_wvr(struct kvm_vcpu *vcpu, 521 521 const struct sys_reg_desc *rd) 522 522 { 523 - vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg] = rd->val; 523 + vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm] = rd->val; 524 524 } 525 525 526 526 static bool trap_wcr(struct kvm_vcpu *vcpu, 527 527 struct sys_reg_params *p, 528 528 const struct sys_reg_desc *rd) 529 529 { 530 - u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg]; 530 + u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm]; 531 531 532 532 if (p->is_write) 533 533 reg_to_dbg(vcpu, p, rd, dbg_reg); 534 534 else 535 535 dbg_to_reg(vcpu, p, rd, dbg_reg); 536 536 537 - trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg); 537 + trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg); 538 538 539 539 return true; 540 540 } ··· 542 542 static int set_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, 543 543 const struct kvm_one_reg *reg, void __user *uaddr) 544 544 { 545 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg]; 545 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm]; 546 546 547 547 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0) 548 548 return -EFAULT; ··· 552 552 static int get_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, 553 553 const struct kvm_one_reg *reg, void __user *uaddr) 554 554 { 555 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg]; 555 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm]; 556 556 557 557 if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0) 558 558 return -EFAULT; ··· 562 562 static void reset_wcr(struct kvm_vcpu *vcpu, 563 563 const struct sys_reg_desc *rd) 564 564 { 565 - vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg] = rd->val; 565 + vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm] = rd->val; 566 566 } 567 567 568 568 static void reset_amair_el1(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
+2 -1
arch/arm64/mm/mmu.c
··· 515 515 */ 516 516 BUILD_BUG_ON(pgd_index(direct_map_end - 1) == pgd_index(direct_map_end)); 517 517 518 - if (rodata_full || crash_mem_map || debug_pagealloc_enabled()) 518 + if (rodata_full || crash_mem_map || debug_pagealloc_enabled() || 519 + IS_ENABLED(CONFIG_KFENCE)) 519 520 flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; 520 521 521 522 /*
+1
arch/mips/alchemy/board-xxs1500.c
··· 18 18 #include <asm/reboot.h> 19 19 #include <asm/setup.h> 20 20 #include <asm/mach-au1x00/au1000.h> 21 + #include <asm/mach-au1x00/gpio-au1000.h> 21 22 #include <prom.h> 22 23 23 24 const char *get_system_type(void)
+5
arch/mips/include/asm/mips-boards/launch.h
··· 3 3 * 4 4 */ 5 5 6 + #ifndef _ASM_MIPS_BOARDS_LAUNCH_H 7 + #define _ASM_MIPS_BOARDS_LAUNCH_H 8 + 6 9 #ifndef _ASSEMBLER_ 7 10 8 11 struct cpulaunch { ··· 37 34 38 35 /* Polling period in count cycles for secondary CPU's */ 39 36 #define LAUNCHPERIOD 10000 37 + 38 + #endif /* _ASM_MIPS_BOARDS_LAUNCH_H */
+6 -6
arch/mips/lib/mips-atomic.c
··· 37 37 */ 38 38 notrace void arch_local_irq_disable(void) 39 39 { 40 - preempt_disable(); 40 + preempt_disable_notrace(); 41 41 42 42 __asm__ __volatile__( 43 43 " .set push \n" ··· 53 53 : /* no inputs */ 54 54 : "memory"); 55 55 56 - preempt_enable(); 56 + preempt_enable_notrace(); 57 57 } 58 58 EXPORT_SYMBOL(arch_local_irq_disable); 59 59 ··· 61 61 { 62 62 unsigned long flags; 63 63 64 - preempt_disable(); 64 + preempt_disable_notrace(); 65 65 66 66 __asm__ __volatile__( 67 67 " .set push \n" ··· 78 78 : /* no inputs */ 79 79 : "memory"); 80 80 81 - preempt_enable(); 81 + preempt_enable_notrace(); 82 82 83 83 return flags; 84 84 } ··· 88 88 { 89 89 unsigned long __tmp1; 90 90 91 - preempt_disable(); 91 + preempt_disable_notrace(); 92 92 93 93 __asm__ __volatile__( 94 94 " .set push \n" ··· 106 106 : "0" (flags) 107 107 : "memory"); 108 108 109 - preempt_enable(); 109 + preempt_enable_notrace(); 110 110 } 111 111 EXPORT_SYMBOL(arch_local_irq_restore); 112 112
+2
arch/mips/ralink/of.c
··· 8 8 9 9 #include <linux/io.h> 10 10 #include <linux/clk.h> 11 + #include <linux/export.h> 11 12 #include <linux/init.h> 12 13 #include <linux/sizes.h> 13 14 #include <linux/of_fdt.h> ··· 26 25 27 26 __iomem void *rt_sysc_membase; 28 27 __iomem void *rt_memc_membase; 28 + EXPORT_SYMBOL_GPL(rt_sysc_membase); 29 29 30 30 __iomem void *plat_of_remap_node(const char *node) 31 31 {
+8
arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
··· 122 122 }; 123 123 124 124 /include/ "pq3-i2c-0.dtsi" 125 + i2c@3000 { 126 + fsl,i2c-erratum-a004447; 127 + }; 128 + 125 129 /include/ "pq3-i2c-1.dtsi" 130 + i2c@3100 { 131 + fsl,i2c-erratum-a004447; 132 + }; 133 + 126 134 /include/ "pq3-duart-0.dtsi" 127 135 /include/ "pq3-espi-0.dtsi" 128 136 spi0: spi@7000 {
+16
arch/powerpc/boot/dts/fsl/p2041si-post.dtsi
··· 371 371 }; 372 372 373 373 /include/ "qoriq-i2c-0.dtsi" 374 + i2c@118000 { 375 + fsl,i2c-erratum-a004447; 376 + }; 377 + 378 + i2c@118100 { 379 + fsl,i2c-erratum-a004447; 380 + }; 381 + 374 382 /include/ "qoriq-i2c-1.dtsi" 383 + i2c@119000 { 384 + fsl,i2c-erratum-a004447; 385 + }; 386 + 387 + i2c@119100 { 388 + fsl,i2c-erratum-a004447; 389 + }; 390 + 375 391 /include/ "qoriq-duart-0.dtsi" 376 392 /include/ "qoriq-duart-1.dtsi" 377 393 /include/ "qoriq-gpio-0.dtsi"
+1
arch/powerpc/include/asm/kvm_host.h
··· 51 51 /* PPC-specific vcpu->requests bit members */ 52 52 #define KVM_REQ_WATCHDOG KVM_ARCH_REQ(0) 53 53 #define KVM_REQ_EPR_EXIT KVM_ARCH_REQ(1) 54 + #define KVM_REQ_PENDING_TIMER KVM_ARCH_REQ(2) 54 55 55 56 #include <linux/mmu_notifier.h> 56 57
+1 -1
arch/powerpc/kvm/book3s_hv.c
··· 3936 3936 break; 3937 3937 } 3938 3938 cur = ktime_get(); 3939 - } while (single_task_running() && ktime_before(cur, stop)); 3939 + } while (kvm_vcpu_can_poll(cur, stop)); 3940 3940 3941 3941 spin_lock(&vc->lock); 3942 3942 vc->vcore_state = VCORE_INACTIVE;
+1
arch/riscv/Kconfig
··· 34 34 select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX 35 35 select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT 36 36 select ARCH_SUPPORTS_HUGETLBFS if MMU 37 + select ARCH_USE_MEMTEST 37 38 select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU 38 39 select ARCH_WANT_FRAME_POINTERS 39 40 select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
+2 -2
arch/riscv/include/asm/kexec.h
··· 42 42 unsigned long fdt_addr; 43 43 }; 44 44 45 - const extern unsigned char riscv_kexec_relocate[]; 46 - const extern unsigned int riscv_kexec_relocate_size; 45 + extern const unsigned char riscv_kexec_relocate[]; 46 + extern const unsigned int riscv_kexec_relocate_size; 47 47 48 48 typedef void (*riscv_kexec_method)(unsigned long first_ind_entry, 49 49 unsigned long jump_addr,
+6 -5
arch/riscv/kernel/machine_kexec.c
··· 14 14 #include <asm/set_memory.h> /* For set_memory_x() */ 15 15 #include <linux/compiler.h> /* For unreachable() */ 16 16 #include <linux/cpu.h> /* For cpu_down() */ 17 + #include <linux/reboot.h> 17 18 18 - /** 19 + /* 19 20 * kexec_image_info - Print received image details 20 21 */ 21 22 static void ··· 40 39 } 41 40 } 42 41 43 - /** 42 + /* 44 43 * machine_kexec_prepare - Initialize kexec 45 44 * 46 45 * This function is called from do_kexec_load, when the user has ··· 101 100 } 102 101 103 102 104 - /** 103 + /* 105 104 * machine_kexec_cleanup - Cleanup any leftovers from 106 105 * machine_kexec_prepare 107 106 * ··· 136 135 #endif 137 136 } 138 137 139 - /** 138 + /* 140 139 * machine_crash_shutdown - Prepare to kexec after a kernel crash 141 140 * 142 141 * This function is called by crash_kexec just before machine_kexec ··· 152 151 pr_info("Starting crashdump kernel...\n"); 153 152 } 154 153 155 - /** 154 + /* 156 155 * machine_kexec - Jump to the loaded kimage 157 156 * 158 157 * This function is called by kernel_kexec which is called by the
+2
arch/riscv/kernel/probes/kprobes.c
··· 84 84 return 0; 85 85 } 86 86 87 + #ifdef CONFIG_MMU 87 88 void *alloc_insn_page(void) 88 89 { 89 90 return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END, ··· 92 91 VM_FLUSH_RESET_PERMS, NUMA_NO_NODE, 93 92 __builtin_return_address(0)); 94 93 } 94 + #endif 95 95 96 96 /* install breakpoint in text */ 97 97 void __kprobes arch_arm_kprobe(struct kprobe *p)
+7 -7
arch/riscv/kernel/stacktrace.c
··· 27 27 fp = frame_pointer(regs); 28 28 sp = user_stack_pointer(regs); 29 29 pc = instruction_pointer(regs); 30 - } else if (task == NULL || task == current) { 31 - fp = (unsigned long)__builtin_frame_address(0); 32 - sp = sp_in_global; 33 - pc = (unsigned long)walk_stackframe; 30 + } else if (task == current) { 31 + fp = (unsigned long)__builtin_frame_address(1); 32 + sp = (unsigned long)__builtin_frame_address(0); 33 + pc = (unsigned long)__builtin_return_address(0); 34 34 } else { 35 35 /* task blocked in __switch_to */ 36 36 fp = task->thread.s[0]; ··· 106 106 return true; 107 107 } 108 108 109 - void dump_backtrace(struct pt_regs *regs, struct task_struct *task, 109 + noinline void dump_backtrace(struct pt_regs *regs, struct task_struct *task, 110 110 const char *loglvl) 111 111 { 112 - pr_cont("%sCall Trace:\n", loglvl); 113 112 walk_stackframe(task, regs, print_trace_address, (void *)loglvl); 114 113 } 115 114 116 115 void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl) 117 116 { 117 + pr_cont("%sCall Trace:\n", loglvl); 118 118 dump_backtrace(NULL, task, loglvl); 119 119 } 120 120 ··· 139 139 140 140 #ifdef CONFIG_STACKTRACE 141 141 142 - void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, 142 + noinline void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, 143 143 struct task_struct *task, struct pt_regs *regs) 144 144 { 145 145 walk_stackframe(task, regs, consume_entry, cookie);
+1
arch/x86/include/asm/kvm-x86-ops.h
··· 99 99 KVM_X86_OP_NULL(vcpu_blocking) 100 100 KVM_X86_OP_NULL(vcpu_unblocking) 101 101 KVM_X86_OP_NULL(update_pi_irte) 102 + KVM_X86_OP_NULL(start_assignment) 102 103 KVM_X86_OP_NULL(apicv_post_state_restore) 103 104 KVM_X86_OP_NULL(dy_apicv_has_pending_interrupt) 104 105 KVM_X86_OP_NULL(set_hv_timer)
+1
arch/x86/include/asm/kvm_host.h
··· 1352 1352 1353 1353 int (*update_pi_irte)(struct kvm *kvm, unsigned int host_irq, 1354 1354 uint32_t guest_irq, bool set); 1355 + void (*start_assignment)(struct kvm *kvm); 1355 1356 void (*apicv_post_state_restore)(struct kvm_vcpu *vcpu); 1356 1357 bool (*dy_apicv_has_pending_interrupt)(struct kvm_vcpu *vcpu); 1357 1358
+3 -2
arch/x86/kvm/emulate.c
··· 5111 5111 return rc; 5112 5112 } 5113 5113 5114 - int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) 5114 + int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len, int emulation_type) 5115 5115 { 5116 5116 int rc = X86EMUL_CONTINUE; 5117 5117 int mode = ctxt->mode; ··· 5322 5322 5323 5323 ctxt->execute = opcode.u.execute; 5324 5324 5325 - if (unlikely(ctxt->ud) && likely(!(ctxt->d & EmulateOnUD))) 5325 + if (unlikely(emulation_type & EMULTYPE_TRAP_UD) && 5326 + likely(!(ctxt->d & EmulateOnUD))) 5326 5327 return EMULATION_FAILED; 5327 5328 5328 5329 if (unlikely(ctxt->d &
+8
arch/x86/kvm/hyperv.c
··· 1172 1172 { 1173 1173 struct kvm_hv *hv = to_kvm_hv(kvm); 1174 1174 u64 gfn; 1175 + int idx; 1175 1176 1176 1177 if (hv->hv_tsc_page_status == HV_TSC_PAGE_BROKEN || 1177 1178 hv->hv_tsc_page_status == HV_TSC_PAGE_UNSET || ··· 1191 1190 gfn = hv->hv_tsc_page >> HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT; 1192 1191 1193 1192 hv->tsc_ref.tsc_sequence = 0; 1193 + 1194 + /* 1195 + * Take the srcu lock as memslots will be accessed to check the gfn 1196 + * cache generation against the memslots generation. 1197 + */ 1198 + idx = srcu_read_lock(&kvm->srcu); 1194 1199 if (kvm_write_guest(kvm, gfn_to_gpa(gfn), 1195 1200 &hv->tsc_ref, sizeof(hv->tsc_ref.tsc_sequence))) 1196 1201 hv->hv_tsc_page_status = HV_TSC_PAGE_BROKEN; 1202 + srcu_read_unlock(&kvm->srcu, idx); 1197 1203 1198 1204 out_unlock: 1199 1205 mutex_unlock(&hv->hv_lock);
+1 -2
arch/x86/kvm/kvm_emulate.h
··· 314 314 int interruptibility; 315 315 316 316 bool perm_ok; /* do not check permissions if true */ 317 - bool ud; /* inject an #UD if host doesn't support insn */ 318 317 bool tf; /* TF value before instruction (after for syscall/sysret) */ 319 318 320 319 bool have_exception; ··· 490 491 #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64 491 492 #endif 492 493 493 - int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len); 494 + int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len, int emulation_type); 494 495 bool x86_page_table_writing_insn(struct x86_emulate_ctxt *ctxt); 495 496 #define EMULATION_FAILED -1 496 497 #define EMULATION_OK 0
+12 -4
arch/x86/kvm/lapic.c
··· 1598 1598 guest_tsc = kvm_read_l1_tsc(vcpu, rdtsc()); 1599 1599 apic->lapic_timer.advance_expire_delta = guest_tsc - tsc_deadline; 1600 1600 1601 + if (lapic_timer_advance_dynamic) { 1602 + adjust_lapic_timer_advance(vcpu, apic->lapic_timer.advance_expire_delta); 1603 + /* 1604 + * If the timer fired early, reread the TSC to account for the 1605 + * overhead of the above adjustment to avoid waiting longer 1606 + * than is necessary. 1607 + */ 1608 + if (guest_tsc < tsc_deadline) 1609 + guest_tsc = kvm_read_l1_tsc(vcpu, rdtsc()); 1610 + } 1611 + 1601 1612 if (guest_tsc < tsc_deadline) 1602 1613 __wait_lapic_expire(vcpu, tsc_deadline - guest_tsc); 1603 - 1604 - if (lapic_timer_advance_dynamic) 1605 - adjust_lapic_timer_advance(vcpu, apic->lapic_timer.advance_expire_delta); 1606 1614 } 1607 1615 1608 1616 void kvm_wait_lapic_expire(struct kvm_vcpu *vcpu) ··· 1669 1661 } 1670 1662 1671 1663 atomic_inc(&apic->lapic_timer.pending); 1672 - kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu); 1664 + kvm_make_request(KVM_REQ_UNBLOCK, vcpu); 1673 1665 if (from_timer_fn) 1674 1666 kvm_vcpu_kick(vcpu); 1675 1667 }
+3 -3
arch/x86/kvm/mmu/tdp_mmu.c
··· 1192 1192 } 1193 1193 1194 1194 /* 1195 - * Remove write access from all the SPTEs mapping GFNs [start, end). If 1196 - * skip_4k is set, SPTEs that map 4k pages, will not be write-protected. 1197 - * Returns true if an SPTE has been changed and the TLBs need to be flushed. 1195 + * Remove write access from all SPTEs at or above min_level that map GFNs 1196 + * [start, end). Returns true if an SPTE has been changed and the TLBs need to 1197 + * be flushed. 1198 1198 */ 1199 1199 static bool wrprot_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root, 1200 1200 gfn_t start, gfn_t end, int min_level)
+2 -4
arch/x86/kvm/svm/avic.c
··· 28 28 #include "svm.h" 29 29 30 30 /* enable / disable AVIC */ 31 - int avic; 32 - #ifdef CONFIG_X86_LOCAL_APIC 33 - module_param(avic, int, S_IRUGO); 34 - #endif 31 + bool avic; 32 + module_param(avic, bool, S_IRUGO); 35 33 36 34 #define SVM_AVIC_DOORBELL 0xc001011b 37 35
+1 -3
arch/x86/kvm/svm/svm.c
··· 1010 1010 } 1011 1011 1012 1012 if (avic) { 1013 - if (!npt_enabled || 1014 - !boot_cpu_has(X86_FEATURE_AVIC) || 1015 - !IS_ENABLED(CONFIG_X86_LOCAL_APIC)) { 1013 + if (!npt_enabled || !boot_cpu_has(X86_FEATURE_AVIC)) { 1016 1014 avic = false; 1017 1015 } else { 1018 1016 pr_info("AVIC enabled\n");
+1 -1
arch/x86/kvm/svm/svm.h
··· 480 480 481 481 #define VMCB_AVIC_APIC_BAR_MASK 0xFFFFFFFFFF000ULL 482 482 483 - extern int avic; 483 + extern bool avic; 484 484 485 485 static inline void avic_update_vapic_bar(struct vcpu_svm *svm, u64 data) 486 486 {
+1 -2
arch/x86/kvm/vmx/capabilities.h
··· 90 90 91 91 static inline bool cpu_has_vmx_posted_intr(void) 92 92 { 93 - return IS_ENABLED(CONFIG_X86_LOCAL_APIC) && 94 - vmcs_config.pin_based_exec_ctrl & PIN_BASED_POSTED_INTR; 93 + return vmcs_config.pin_based_exec_ctrl & PIN_BASED_POSTED_INTR; 95 94 } 96 95 97 96 static inline bool cpu_has_load_ia32_efer(void)
+14
arch/x86/kvm/vmx/posted_intr.c
··· 238 238 239 239 240 240 /* 241 + * Bail out of the block loop if the VM has an assigned 242 + * device, but the blocking vCPU didn't reconfigure the 243 + * PI.NV to the wakeup vector, i.e. the assigned device 244 + * came along after the initial check in pi_pre_block(). 245 + */ 246 + void vmx_pi_start_assignment(struct kvm *kvm) 247 + { 248 + if (!irq_remapping_cap(IRQ_POSTING_CAP)) 249 + return; 250 + 251 + kvm_make_all_cpus_request(kvm, KVM_REQ_UNBLOCK); 252 + } 253 + 254 + /* 241 255 * pi_update_irte - set IRTE for Posted-Interrupts 242 256 * 243 257 * @kvm: kvm
+1
arch/x86/kvm/vmx/posted_intr.h
··· 95 95 bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu); 96 96 int pi_update_irte(struct kvm *kvm, unsigned int host_irq, uint32_t guest_irq, 97 97 bool set); 98 + void vmx_pi_start_assignment(struct kvm *kvm); 98 99 99 100 #endif /* __KVM_X86_VMX_POSTED_INTR_H */
+3 -3
arch/x86/kvm/vmx/vmx.c
··· 4843 4843 struct vcpu_vmx *vmx = to_vmx(vcpu); 4844 4844 struct kvm_run *kvm_run = vcpu->run; 4845 4845 u32 intr_info, ex_no, error_code; 4846 - unsigned long cr2, rip, dr6; 4846 + unsigned long cr2, dr6; 4847 4847 u32 vect_info; 4848 4848 4849 4849 vect_info = vmx->idt_vectoring_info; ··· 4933 4933 vmx->vcpu.arch.event_exit_inst_len = 4934 4934 vmcs_read32(VM_EXIT_INSTRUCTION_LEN); 4935 4935 kvm_run->exit_reason = KVM_EXIT_DEBUG; 4936 - rip = kvm_rip_read(vcpu); 4937 - kvm_run->debug.arch.pc = vmcs_readl(GUEST_CS_BASE) + rip; 4936 + kvm_run->debug.arch.pc = kvm_get_linear_rip(vcpu); 4938 4937 kvm_run->debug.arch.exception = ex_no; 4939 4938 break; 4940 4939 case AC_VECTOR: ··· 7720 7721 .nested_ops = &vmx_nested_ops, 7721 7722 7722 7723 .update_pi_irte = pi_update_irte, 7724 + .start_assignment = vmx_pi_start_assignment, 7723 7725 7724 7726 #ifdef CONFIG_X86_64 7725 7727 .set_hv_timer = vmx_set_hv_timer,
+15 -12
arch/x86/kvm/x86.c
··· 3105 3105 st->preempted & KVM_VCPU_FLUSH_TLB); 3106 3106 if (xchg(&st->preempted, 0) & KVM_VCPU_FLUSH_TLB) 3107 3107 kvm_vcpu_flush_tlb_guest(vcpu); 3108 + } else { 3109 + st->preempted = 0; 3108 3110 } 3109 3111 3110 3112 vcpu->arch.st.preempted = 0; ··· 7228 7226 BUILD_BUG_ON(HF_SMM_MASK != X86EMUL_SMM_MASK); 7229 7227 BUILD_BUG_ON(HF_SMM_INSIDE_NMI_MASK != X86EMUL_SMM_INSIDE_NMI_MASK); 7230 7228 7229 + ctxt->interruptibility = 0; 7230 + ctxt->have_exception = false; 7231 + ctxt->exception.vector = -1; 7232 + ctxt->perm_ok = false; 7233 + 7231 7234 init_decode_cache(ctxt); 7232 7235 vcpu->arch.emulate_regs_need_sync_from_vcpu = false; 7233 7236 } ··· 7568 7561 kvm_vcpu_check_breakpoint(vcpu, &r)) 7569 7562 return r; 7570 7563 7571 - ctxt->interruptibility = 0; 7572 - ctxt->have_exception = false; 7573 - ctxt->exception.vector = -1; 7574 - ctxt->perm_ok = false; 7575 - 7576 - ctxt->ud = emulation_type & EMULTYPE_TRAP_UD; 7577 - 7578 - r = x86_decode_insn(ctxt, insn, insn_len); 7564 + r = x86_decode_insn(ctxt, insn, insn_len, emulation_type); 7579 7565 7580 7566 trace_kvm_emulate_insn_start(vcpu); 7581 7567 ++vcpu->stat.insn_emulation; ··· 8359 8359 struct kvm_apic_map *map; 8360 8360 8361 8361 vcpu->stat.directed_yield_attempted++; 8362 + 8363 + if (single_task_running()) 8364 + goto no_yield; 8362 8365 8363 8366 rcu_read_lock(); 8364 8367 map = rcu_dereference(vcpu->kvm->arch.apic_map); ··· 9499 9496 if (r <= 0) 9500 9497 break; 9501 9498 9502 - kvm_clear_request(KVM_REQ_PENDING_TIMER, vcpu); 9499 + kvm_clear_request(KVM_REQ_UNBLOCK, vcpu); 9503 9500 if (kvm_cpu_has_pending_timer(vcpu)) 9504 9501 kvm_inject_pending_timer_irqs(vcpu); 9505 9502 ··· 10118 10115 kvm_update_dr7(vcpu); 10119 10116 10120 10117 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) 10121 - vcpu->arch.singlestep_rip = kvm_rip_read(vcpu) + 10122 - get_segment_base(vcpu, VCPU_SREG_CS); 10118 + vcpu->arch.singlestep_rip = kvm_get_linear_rip(vcpu); 10123 10119 10124 10120 /* 10125 10121 * Trigger an rflags update that will inject or remove the trace ··· 11501 11499 11502 11500 void kvm_arch_start_assignment(struct kvm *kvm) 11503 11501 { 11504 - atomic_inc(&kvm->arch.assigned_device_count); 11502 + if (atomic_inc_return(&kvm->arch.assigned_device_count) == 1) 11503 + static_call_cond(kvm_x86_start_assignment)(kvm); 11505 11504 } 11506 11505 EXPORT_SYMBOL_GPL(kvm_arch_start_assignment); 11507 11506
+1
drivers/acpi/acpi_apd.c
··· 226 226 { "AMDI0010", APD_ADDR(wt_i2c_desc) }, 227 227 { "AMD0020", APD_ADDR(cz_uart_desc) }, 228 228 { "AMDI0020", APD_ADDR(cz_uart_desc) }, 229 + { "AMDI0022", APD_ADDR(cz_uart_desc) }, 229 230 { "AMD0030", }, 230 231 { "AMD0040", APD_ADDR(fch_misc_desc)}, 231 232 { "HYGO0010", APD_ADDR(wt_i2c_desc) },
+2 -2
drivers/acpi/internal.h
··· 134 134 void acpi_power_resources_list_free(struct list_head *list); 135 135 int acpi_extract_power_resources(union acpi_object *package, unsigned int start, 136 136 struct list_head *list); 137 - int acpi_add_power_resource(acpi_handle handle); 137 + struct acpi_device *acpi_add_power_resource(acpi_handle handle); 138 138 void acpi_power_add_remove_device(struct acpi_device *adev, bool add); 139 139 int acpi_power_wakeup_list_init(struct list_head *list, int *system_level); 140 140 int acpi_device_sleep_wake(struct acpi_device *dev, ··· 142 142 int acpi_power_get_inferred_state(struct acpi_device *device, int *state); 143 143 int acpi_power_on_resources(struct acpi_device *device, int state); 144 144 int acpi_power_transition(struct acpi_device *device, int state); 145 - void acpi_turn_off_unused_power_resources(void); 145 + void acpi_turn_off_unused_power_resources(bool init); 146 146 147 147 /* -------------------------------------------------------------------------- 148 148 Device Power Management
+46 -13
drivers/acpi/power.c
··· 52 52 u32 system_level; 53 53 u32 order; 54 54 unsigned int ref_count; 55 + unsigned int users; 55 56 bool wakeup_enabled; 56 57 struct mutex resource_lock; 57 58 struct list_head dependents; ··· 148 147 149 148 for (i = start; i < package->package.count; i++) { 150 149 union acpi_object *element = &package->package.elements[i]; 150 + struct acpi_device *rdev; 151 151 acpi_handle rhandle; 152 152 153 153 if (element->type != ACPI_TYPE_LOCAL_REFERENCE) { ··· 165 163 if (acpi_power_resource_is_dup(package, start, i)) 166 164 continue; 167 165 168 - err = acpi_add_power_resource(rhandle); 169 - if (err) 166 + rdev = acpi_add_power_resource(rhandle); 167 + if (!rdev) { 168 + err = -ENODEV; 170 169 break; 171 - 170 + } 172 171 err = acpi_power_resources_list_add(rhandle, list); 173 172 if (err) 174 173 break; 174 + 175 + to_power_resource(rdev)->users++; 175 176 } 176 177 if (err) 177 178 acpi_power_resources_list_free(list); ··· 912 907 mutex_unlock(&power_resource_list_lock); 913 908 } 914 909 915 - int acpi_add_power_resource(acpi_handle handle) 910 + struct acpi_device *acpi_add_power_resource(acpi_handle handle) 916 911 { 917 912 struct acpi_power_resource *resource; 918 913 struct acpi_device *device = NULL; ··· 923 918 924 919 acpi_bus_get_device(handle, &device); 925 920 if (device) 926 - return 0; 921 + return device; 927 922 928 923 resource = kzalloc(sizeof(*resource), GFP_KERNEL); 929 924 if (!resource) 930 - return -ENOMEM; 925 + return NULL; 931 926 932 927 device = &resource->device; 933 928 acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER); ··· 964 959 965 960 acpi_power_add_resource_to_list(resource); 966 961 acpi_device_add_finalize(device); 967 - return 0; 962 + return device; 968 963 969 964 err: 970 965 acpi_release_power_resource(&device->dev); 971 - return result; 966 + return NULL; 972 967 } 973 968 974 969 #ifdef CONFIG_ACPI_SLEEP ··· 1002 997 } 1003 998 #endif 1004 999 1005 - void acpi_turn_off_unused_power_resources(void) 1000 + static void acpi_power_turn_off_if_unused(struct acpi_power_resource *resource, 1001 + bool init) 1002 + { 1003 + if (resource->ref_count > 0) 1004 + return; 1005 + 1006 + if (init) { 1007 + if (resource->users > 0) 1008 + return; 1009 + } else { 1010 + int result, state; 1011 + 1012 + result = acpi_power_get_state(resource->device.handle, &state); 1013 + if (result || state == ACPI_POWER_RESOURCE_STATE_OFF) 1014 + return; 1015 + } 1016 + 1017 + dev_info(&resource->device.dev, "Turning OFF\n"); 1018 + __acpi_power_off(resource); 1019 + } 1020 + 1021 + /** 1022 + * acpi_turn_off_unused_power_resources - Turn off power resources not in use. 1023 + * @init: Control switch. 1024 + * 1025 + * If @ainit is set, unconditionally turn off all of the ACPI power resources 1026 + * without any users. 1027 + * 1028 + * Otherwise, turn off all ACPI power resources without active references (that 1029 + * is, the ones that should be "off" at the moment) that are "on". 1030 + */ 1031 + void acpi_turn_off_unused_power_resources(bool init) 1006 1032 { 1007 1033 struct acpi_power_resource *resource; 1008 1034 ··· 1042 1006 list_for_each_entry_reverse(resource, &acpi_power_resource_list, list_node) { 1043 1007 mutex_lock(&resource->resource_lock); 1044 1008 1045 - if (!resource->ref_count) { 1046 - dev_info(&resource->device.dev, "Turning OFF\n"); 1047 - __acpi_power_off(resource); 1048 - } 1009 + acpi_power_turn_off_if_unused(resource, init); 1049 1010 1050 1011 mutex_unlock(&resource->resource_lock); 1051 1012 }
+1 -1
drivers/acpi/scan.c
··· 2360 2360 } 2361 2361 } 2362 2362 2363 - acpi_turn_off_unused_power_resources(); 2363 + acpi_turn_off_unused_power_resources(true); 2364 2364 2365 2365 acpi_scan_initialized = true; 2366 2366
+1 -1
drivers/acpi/sleep.c
··· 504 504 */ 505 505 static void acpi_pm_end(void) 506 506 { 507 - acpi_turn_off_unused_power_resources(); 507 + acpi_turn_off_unused_power_resources(false); 508 508 acpi_scan_lock_release(); 509 509 /* 510 510 * This is necessary in case acpi_pm_finish() is not called during a
+36 -32
drivers/base/core.c
··· 194 194 { 195 195 return srcu_read_lock_held(&device_links_srcu); 196 196 } 197 + 198 + static void device_link_synchronize_removal(void) 199 + { 200 + synchronize_srcu(&device_links_srcu); 201 + } 202 + 203 + static void device_link_remove_from_lists(struct device_link *link) 204 + { 205 + list_del_rcu(&link->s_node); 206 + list_del_rcu(&link->c_node); 207 + } 197 208 #else /* !CONFIG_SRCU */ 198 209 static DECLARE_RWSEM(device_links_lock); 199 210 ··· 235 224 return lockdep_is_held(&device_links_lock); 236 225 } 237 226 #endif 227 + 228 + static inline void device_link_synchronize_removal(void) 229 + { 230 + } 231 + 232 + static void device_link_remove_from_lists(struct device_link *link) 233 + { 234 + list_del(&link->s_node); 235 + list_del(&link->c_node); 236 + } 238 237 #endif /* !CONFIG_SRCU */ 239 238 240 239 static bool device_is_ancestor(struct device *dev, struct device *target) ··· 466 445 }; 467 446 ATTRIBUTE_GROUPS(devlink); 468 447 469 - static void device_link_free(struct device_link *link) 448 + static void device_link_release_fn(struct work_struct *work) 470 449 { 450 + struct device_link *link = container_of(work, struct device_link, rm_work); 451 + 452 + /* Ensure that all references to the link object have been dropped. */ 453 + device_link_synchronize_removal(); 454 + 471 455 while (refcount_dec_not_one(&link->rpm_active)) 472 456 pm_runtime_put(link->supplier); 473 457 ··· 481 455 kfree(link); 482 456 } 483 457 484 - #ifdef CONFIG_SRCU 485 - static void __device_link_free_srcu(struct rcu_head *rhead) 486 - { 487 - device_link_free(container_of(rhead, struct device_link, rcu_head)); 488 - } 489 - 490 458 static void devlink_dev_release(struct device *dev) 491 459 { 492 460 struct device_link *link = to_devlink(dev); 493 461 494 - call_srcu(&device_links_srcu, &link->rcu_head, __device_link_free_srcu); 462 + INIT_WORK(&link->rm_work, device_link_release_fn); 463 + /* 464 + * It may take a while to complete this work because of the SRCU 465 + * synchronization in device_link_release_fn() and if the consumer or 466 + * supplier devices get deleted when it runs, so put it into the "long" 467 + * workqueue. 468 + */ 469 + queue_work(system_long_wq, &link->rm_work); 495 470 } 496 - #else 497 - static void devlink_dev_release(struct device *dev) 498 - { 499 - device_link_free(to_devlink(dev)); 500 - } 501 - #endif 502 471 503 472 static struct class devlink_class = { 504 473 .name = "devlink", ··· 867 846 } 868 847 EXPORT_SYMBOL_GPL(device_link_add); 869 848 870 - #ifdef CONFIG_SRCU 871 849 static void __device_link_del(struct kref *kref) 872 850 { 873 851 struct device_link *link = container_of(kref, struct device_link, kref); ··· 876 856 877 857 pm_runtime_drop_link(link); 878 858 879 - list_del_rcu(&link->s_node); 880 - list_del_rcu(&link->c_node); 859 + device_link_remove_from_lists(link); 881 860 device_unregister(&link->link_dev); 882 861 } 883 - #else /* !CONFIG_SRCU */ 884 - static void __device_link_del(struct kref *kref) 885 - { 886 - struct device_link *link = container_of(kref, struct device_link, kref); 887 - 888 - dev_info(link->consumer, "Dropping the link to %s\n", 889 - dev_name(link->supplier)); 890 - 891 - pm_runtime_drop_link(link); 892 - 893 - list_del(&link->s_node); 894 - list_del(&link->c_node); 895 - device_unregister(&link->link_dev); 896 - } 897 - #endif /* !CONFIG_SRCU */ 898 862 899 863 static void device_link_put_kref(struct device_link *link) 900 864 {
+6 -6
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c
··· 156 156 mmSDMA0_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL; 157 157 break; 158 158 case 1: 159 - sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA1, 0, 159 + sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA0, 0, 160 160 mmSDMA1_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL; 161 161 break; 162 162 case 2: 163 - sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA2, 0, 164 - mmSDMA2_RLC0_RB_CNTL) - mmSDMA2_RLC0_RB_CNTL; 163 + sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA0, 0, 164 + mmSDMA2_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL; 165 165 break; 166 166 case 3: 167 - sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA3, 0, 168 - mmSDMA3_RLC0_RB_CNTL) - mmSDMA2_RLC0_RB_CNTL; 167 + sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA0, 0, 168 + mmSDMA3_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL; 169 169 break; 170 170 } 171 171 ··· 450 450 engine_id, queue_id); 451 451 uint32_t i = 0, reg; 452 452 #undef HQD_N_REGS 453 - #define HQD_N_REGS (19+6+7+10) 453 + #define HQD_N_REGS (19+6+7+12) 454 454 455 455 *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL); 456 456 if (*dump == NULL)
+2
drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
··· 172 172 { 173 173 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 174 174 175 + cancel_delayed_work_sync(&adev->vcn.idle_work); 176 + 175 177 if (adev->jpeg.cur_state != AMD_PG_STATE_GATE && 176 178 RREG32_SOC15(JPEG, 0, mmUVD_JRBC_STATUS)) 177 179 jpeg_v2_0_set_powergating_state(adev, AMD_PG_STATE_GATE);
+2 -2
drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
··· 187 187 static int jpeg_v2_5_hw_fini(void *handle) 188 188 { 189 189 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 190 - struct amdgpu_ring *ring; 191 190 int i; 191 + 192 + cancel_delayed_work_sync(&adev->vcn.idle_work); 192 193 193 194 for (i = 0; i < adev->jpeg.num_jpeg_inst; ++i) { 194 195 if (adev->jpeg.harvest_config & (1 << i)) 195 196 continue; 196 197 197 - ring = &adev->jpeg.inst[i].ring_dec; 198 198 if (adev->jpeg.cur_state != AMD_PG_STATE_GATE && 199 199 RREG32_SOC15(JPEG, i, mmUVD_JRBC_STATUS)) 200 200 jpeg_v2_5_set_powergating_state(adev, AMD_PG_STATE_GATE);
+2 -2
drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
··· 159 159 static int jpeg_v3_0_hw_fini(void *handle) 160 160 { 161 161 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 162 - struct amdgpu_ring *ring; 163 162 164 - ring = &adev->jpeg.inst->ring_dec; 163 + cancel_delayed_work_sync(&adev->vcn.idle_work); 164 + 165 165 if (adev->jpeg.cur_state != AMD_PG_STATE_GATE && 166 166 RREG32_SOC15(JPEG, 0, mmUVD_JRBC_STATUS)) 167 167 jpeg_v3_0_set_powergating_state(adev, AMD_PG_STATE_GATE);
+5 -1
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
··· 231 231 { 232 232 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 233 233 234 + cancel_delayed_work_sync(&adev->vcn.idle_work); 235 + 234 236 if ((adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) || 235 - RREG32_SOC15(VCN, 0, mmUVD_STATUS)) 237 + (adev->vcn.cur_state != AMD_PG_STATE_GATE && 238 + RREG32_SOC15(VCN, 0, mmUVD_STATUS))) { 236 239 vcn_v1_0_set_powergating_state(adev, AMD_PG_STATE_GATE); 240 + } 237 241 238 242 return 0; 239 243 }
+2
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
··· 262 262 { 263 263 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 264 264 265 + cancel_delayed_work_sync(&adev->vcn.idle_work); 266 + 265 267 if ((adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) || 266 268 (adev->vcn.cur_state != AMD_PG_STATE_GATE && 267 269 RREG32_SOC15(VCN, 0, mmUVD_STATUS)))
+2
drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
··· 321 321 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 322 322 int i; 323 323 324 + cancel_delayed_work_sync(&adev->vcn.idle_work); 325 + 324 326 for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { 325 327 if (adev->vcn.harvest_config & (1 << i)) 326 328 continue;
+2 -3
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
··· 372 372 static int vcn_v3_0_hw_fini(void *handle) 373 373 { 374 374 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 375 - struct amdgpu_ring *ring; 376 375 int i; 376 + 377 + cancel_delayed_work_sync(&adev->vcn.idle_work); 377 378 378 379 for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { 379 380 if (adev->vcn.harvest_config & (1 << i)) 380 381 continue; 381 - 382 - ring = &adev->vcn.inst[i].ring_dec; 383 382 384 383 if (!amdgpu_sriov_vf(adev)) { 385 384 if ((adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) ||
+9
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
··· 2925 2925 2926 2926 static int navi10_enable_mgpu_fan_boost(struct smu_context *smu) 2927 2927 { 2928 + struct smu_table_context *table_context = &smu->smu_table; 2929 + PPTable_t *smc_pptable = table_context->driver_pptable; 2928 2930 struct amdgpu_device *adev = smu->adev; 2929 2931 uint32_t param = 0; 2930 2932 2931 2933 /* Navi12 does not support this */ 2932 2934 if (adev->asic_type == CHIP_NAVI12) 2935 + return 0; 2936 + 2937 + /* 2938 + * Skip the MGpuFanBoost setting for those ASICs 2939 + * which do not support it 2940 + */ 2941 + if (!smc_pptable->MGpuFanBoostLimitRpm) 2933 2942 return 0; 2934 2943 2935 2944 /* Workaround for WS SKU */
+10
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
··· 3027 3027 3028 3028 static int sienna_cichlid_enable_mgpu_fan_boost(struct smu_context *smu) 3029 3029 { 3030 + struct smu_table_context *table_context = &smu->smu_table; 3031 + PPTable_t *smc_pptable = table_context->driver_pptable; 3032 + 3033 + /* 3034 + * Skip the MGpuFanBoost setting for those ASICs 3035 + * which do not support it 3036 + */ 3037 + if (!smc_pptable->MGpuFanBoostLimitRpm) 3038 + return 0; 3039 + 3030 3040 return smu_cmn_send_smc_msg_with_param(smu, 3031 3041 SMU_MSG_SetMGpuFanBoostLimitRpm, 3032 3042 0,
+5 -4
drivers/gpu/drm/meson/meson_drv.c
··· 485 485 static void meson_drv_shutdown(struct platform_device *pdev) 486 486 { 487 487 struct meson_drm *priv = dev_get_drvdata(&pdev->dev); 488 - struct drm_device *drm = priv->drm; 489 488 490 - DRM_DEBUG_DRIVER("\n"); 491 - drm_kms_helper_poll_fini(drm); 492 - drm_atomic_helper_shutdown(drm); 489 + if (!priv) 490 + return; 491 + 492 + drm_kms_helper_poll_fini(priv->drm); 493 + drm_atomic_helper_shutdown(priv->drm); 493 494 } 494 495 495 496 static int meson_drv_probe(struct platform_device *pdev)
+1 -1
drivers/gpu/drm/ttm/ttm_device.c
··· 145 145 list_for_each_entry(bo, &man->lru[j], lru) { 146 146 uint32_t num_pages; 147 147 148 - if (!bo->ttm || 148 + if (!bo->ttm || !ttm_tt_is_populated(bo->ttm) || 149 149 bo->ttm->page_flags & TTM_PAGE_FLAG_SG || 150 150 bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED) 151 151 continue;
+1 -1
drivers/i2c/busses/Kconfig
··· 647 647 648 648 config I2C_HISI 649 649 tristate "HiSilicon I2C controller" 650 - depends on ARM64 || COMPILE_TEST 650 + depends on (ARM64 && ACPI) || COMPILE_TEST 651 651 help 652 652 Say Y here if you want to have Hisilicon I2C controller support 653 653 available on the Kunpeng Server.
+1 -1
drivers/i2c/busses/i2c-ali1563.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 - /** 2 + /* 3 3 * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge 4 4 * 5 5 * Copyright (C) 2004 Patrick Mochel
+1 -1
drivers/i2c/busses/i2c-cadence.c
··· 144 144 }; 145 145 146 146 /** 147 - * enum cdns_i2c_slave_mode - Slave state when I2C is operating in slave mode 147 + * enum cdns_i2c_slave_state - Slave state when I2C is operating in slave mode 148 148 * 149 149 * @CDNS_I2C_SLAVE_STATE_IDLE: I2C slave idle 150 150 * @CDNS_I2C_SLAVE_STATE_SEND: I2C slave sending data to master
+1 -1
drivers/i2c/busses/i2c-designware-master.c
··· 165 165 } 166 166 167 167 /** 168 - * i2c_dw_init() - Initialize the designware I2C master hardware 168 + * i2c_dw_init_master() - Initialize the designware I2C master hardware 169 169 * @dev: device private data 170 170 * 171 171 * This functions configures and enables the I2C master.
+2 -1
drivers/i2c/busses/i2c-eg20t.c
··· 148 148 149 149 /** 150 150 * struct adapter_info - This structure holds the adapter information for the 151 - PCH i2c controller 151 + * PCH i2c controller 152 152 * @pch_data: stores a list of i2c_algo_pch_data 153 153 * @pch_i2c_suspended: specifies whether the system is suspended or not 154 154 * perhaps with more lines and words. ··· 358 358 /** 359 359 * pch_i2c_writebytes() - write data to I2C bus in normal mode 360 360 * @i2c_adap: Pointer to the struct i2c_adapter. 361 + * @msgs: Pointer to the i2c message structure. 361 362 * @last: specifies whether last message or not. 362 363 * In the case of compound mode it will be 1 for last message, 363 364 * otherwise 0.
+2 -4
drivers/i2c/busses/i2c-i801.c
··· 395 395 dev_err(&priv->pci_dev->dev, "Transaction timeout\n"); 396 396 /* try to stop the current command */ 397 397 dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n"); 398 - outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, 399 - SMBHSTCNT(priv)); 398 + outb_p(SMBHSTCNT_KILL, SMBHSTCNT(priv)); 400 399 usleep_range(1000, 2000); 401 - outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL), 402 - SMBHSTCNT(priv)); 400 + outb_p(0, SMBHSTCNT(priv)); 403 401 404 402 /* Check if it worked */ 405 403 status = inb_p(SMBHSTSTS(priv));
-1
drivers/i2c/busses/i2c-icy.c
··· 123 123 { 124 124 struct icy_i2c *i2c; 125 125 struct i2c_algo_pcf_data *algo_data; 126 - struct fwnode_handle *new_fwnode; 127 126 struct i2c_board_info ltc2990_info = { 128 127 .type = "ltc2990", 129 128 .swnode = &icy_ltc2990_node,
+79 -2
drivers/i2c/busses/i2c-mpc.c
··· 19 19 20 20 #include <linux/clk.h> 21 21 #include <linux/io.h> 22 + #include <linux/iopoll.h> 22 23 #include <linux/fsl_devices.h> 23 24 #include <linux/i2c.h> 24 25 #include <linux/interrupt.h> ··· 46 45 #define CCR_MTX 0x10 47 46 #define CCR_TXAK 0x08 48 47 #define CCR_RSTA 0x04 48 + #define CCR_RSVD 0x02 49 49 50 50 #define CSR_MCF 0x80 51 51 #define CSR_MAAS 0x40 ··· 99 97 u32 block; 100 98 int rc; 101 99 int expect_rxack; 102 - 100 + bool has_errata_A004447; 103 101 }; 104 102 105 103 struct mpc_i2c_divider { ··· 135 133 readb(i2c->base + MPC_I2C_DR); 136 134 writeccr(i2c, CCR_MEN); 137 135 udelay(delay_val << 1); 136 + } 137 + } 138 + 139 + static int i2c_mpc_wait_sr(struct mpc_i2c *i2c, int mask) 140 + { 141 + void __iomem *addr = i2c->base + MPC_I2C_SR; 142 + u8 val; 143 + 144 + return readb_poll_timeout(addr, val, val & mask, 0, 100); 145 + } 146 + 147 + /* 148 + * Workaround for Erratum A004447. From the P2040CE Rev Q 149 + * 150 + * 1. Set up the frequency divider and sampling rate. 151 + * 2. I2CCR - a0h 152 + * 3. Poll for I2CSR[MBB] to get set. 153 + * 4. If I2CSR[MAL] is set (an indication that SDA is stuck low), then go to 154 + * step 5. If MAL is not set, then go to step 13. 155 + * 5. I2CCR - 00h 156 + * 6. I2CCR - 22h 157 + * 7. I2CCR - a2h 158 + * 8. Poll for I2CSR[MBB] to get set. 159 + * 9. Issue read to I2CDR. 160 + * 10. Poll for I2CSR[MIF] to be set. 161 + * 11. I2CCR - 82h 162 + * 12. Workaround complete. Skip the next steps. 163 + * 13. Issue read to I2CDR. 164 + * 14. Poll for I2CSR[MIF] to be set. 165 + * 15. I2CCR - 80h 166 + */ 167 + static void mpc_i2c_fixup_A004447(struct mpc_i2c *i2c) 168 + { 169 + int ret; 170 + u32 val; 171 + 172 + writeccr(i2c, CCR_MEN | CCR_MSTA); 173 + ret = i2c_mpc_wait_sr(i2c, CSR_MBB); 174 + if (ret) { 175 + dev_err(i2c->dev, "timeout waiting for CSR_MBB\n"); 176 + return; 177 + } 178 + 179 + val = readb(i2c->base + MPC_I2C_SR); 180 + 181 + if (val & CSR_MAL) { 182 + writeccr(i2c, 0x00); 183 + writeccr(i2c, CCR_MSTA | CCR_RSVD); 184 + writeccr(i2c, CCR_MEN | CCR_MSTA | CCR_RSVD); 185 + ret = i2c_mpc_wait_sr(i2c, CSR_MBB); 186 + if (ret) { 187 + dev_err(i2c->dev, "timeout waiting for CSR_MBB\n"); 188 + return; 189 + } 190 + val = readb(i2c->base + MPC_I2C_DR); 191 + ret = i2c_mpc_wait_sr(i2c, CSR_MIF); 192 + if (ret) { 193 + dev_err(i2c->dev, "timeout waiting for CSR_MIF\n"); 194 + return; 195 + } 196 + writeccr(i2c, CCR_MEN | CCR_RSVD); 197 + } else { 198 + val = readb(i2c->base + MPC_I2C_DR); 199 + ret = i2c_mpc_wait_sr(i2c, CSR_MIF); 200 + if (ret) { 201 + dev_err(i2c->dev, "timeout waiting for CSR_MIF\n"); 202 + return; 203 + } 204 + writeccr(i2c, CCR_MEN); 138 205 } 139 206 } 140 207 ··· 741 670 { 742 671 struct mpc_i2c *i2c = i2c_get_adapdata(adap); 743 672 744 - mpc_i2c_fixup(i2c); 673 + if (i2c->has_errata_A004447) 674 + mpc_i2c_fixup_A004447(i2c); 675 + else 676 + mpc_i2c_fixup(i2c); 745 677 746 678 return 0; 747 679 } ··· 840 766 mpc_ops.timeout = 5; 841 767 } 842 768 dev_info(i2c->dev, "timeout %u us\n", mpc_ops.timeout * 1000000 / HZ); 769 + 770 + if (of_property_read_bool(op->dev.of_node, "fsl,i2c-erratum-a004447")) 771 + i2c->has_errata_A004447 = true; 843 772 844 773 i2c->adap = mpc_ops; 845 774 scnprintf(i2c->adap.name, sizeof(i2c->adap.name),
+5
drivers/i2c/busses/i2c-mt65xx.c
··· 479 479 static void mtk_i2c_init_hw(struct mtk_i2c *i2c) 480 480 { 481 481 u16 control_reg; 482 + u16 intr_stat_reg; 483 + 484 + mtk_i2c_writew(i2c, I2C_CHN_CLR_FLAG, OFFSET_START); 485 + intr_stat_reg = mtk_i2c_readw(i2c, OFFSET_INTR_STAT); 486 + mtk_i2c_writew(i2c, intr_stat_reg, OFFSET_INTR_STAT); 482 487 483 488 if (i2c->dev_comp->apdma_sync) { 484 489 writel(I2C_DMA_WARM_RST, i2c->pdmabase + OFFSET_RST);
+1 -1
drivers/i2c/busses/i2c-nomadik.c
··· 159 159 * @clk_freq: clock frequency for the operation mode 160 160 * @tft: Tx FIFO Threshold in bytes 161 161 * @rft: Rx FIFO Threshold in bytes 162 - * @timeout Slave response timeout (ms) 162 + * @timeout: Slave response timeout (ms) 163 163 * @sm: speed mode 164 164 * @stop: stop condition. 165 165 * @xfer_complete: acknowledge completion for a I2C message.
+4 -4
drivers/i2c/busses/i2c-ocores.c
··· 250 250 } 251 251 252 252 /** 253 - * Process timeout event 253 + * ocores_process_timeout() - Process timeout event 254 254 * @i2c: ocores I2C device instance 255 255 */ 256 256 static void ocores_process_timeout(struct ocores_i2c *i2c) ··· 264 264 } 265 265 266 266 /** 267 - * Wait until something change in a given register 267 + * ocores_wait() - Wait until something change in a given register 268 268 * @i2c: ocores I2C device instance 269 269 * @reg: register to query 270 270 * @mask: bitmask to apply on register value ··· 296 296 } 297 297 298 298 /** 299 - * Wait until is possible to process some data 299 + * ocores_poll_wait() - Wait until is possible to process some data 300 300 * @i2c: ocores I2C device instance 301 301 * 302 302 * Used when the device is in polling mode (interrupts disabled). ··· 334 334 } 335 335 336 336 /** 337 - * It handles an IRQ-less transfer 337 + * ocores_process_polling() - It handles an IRQ-less transfer 338 338 * @i2c: ocores I2C device instance 339 339 * 340 340 * Even if IRQ are disabled, the I2C OpenCore IP behavior is exactly the same
+4 -4
drivers/i2c/busses/i2c-pnx.c
··· 138 138 /** 139 139 * i2c_pnx_start - start a device 140 140 * @slave_addr: slave address 141 - * @adap: pointer to adapter structure 141 + * @alg_data: pointer to local driver data structure 142 142 * 143 143 * Generate a START signal in the desired mode. 144 144 */ ··· 194 194 195 195 /** 196 196 * i2c_pnx_stop - stop a device 197 - * @adap: pointer to I2C adapter structure 197 + * @alg_data: pointer to local driver data structure 198 198 * 199 199 * Generate a STOP signal to terminate the master transaction. 200 200 */ ··· 223 223 224 224 /** 225 225 * i2c_pnx_master_xmit - transmit data to slave 226 - * @adap: pointer to I2C adapter structure 226 + * @alg_data: pointer to local driver data structure 227 227 * 228 228 * Sends one byte of data to the slave 229 229 */ ··· 293 293 294 294 /** 295 295 * i2c_pnx_master_rcv - receive data from slave 296 - * @adap: pointer to I2C adapter structure 296 + * @alg_data: pointer to local driver data structure 297 297 * 298 298 * Reads one byte data from the slave 299 299 */
+1 -1
drivers/i2c/busses/i2c-qcom-geni.c
··· 100 100 [GP_IRQ0] = {-EIO, "Unknown I2C err GP_IRQ0"}, 101 101 [NACK] = {-ENXIO, "NACK: slv unresponsive, check its power/reset-ln"}, 102 102 [GP_IRQ2] = {-EIO, "Unknown I2C err GP IRQ2"}, 103 - [BUS_PROTO] = {-EPROTO, "Bus proto err, noisy/unepxected start/stop"}, 103 + [BUS_PROTO] = {-EPROTO, "Bus proto err, noisy/unexpected start/stop"}, 104 104 [ARB_LOST] = {-EAGAIN, "Bus arbitration lost, clock line undriveable"}, 105 105 [GP_IRQ5] = {-EIO, "Unknown I2C err GP IRQ5"}, 106 106 [GENI_OVERRUN] = {-EIO, "Cmd overrun, check GENI cmd-state machine"},
+3
drivers/i2c/busses/i2c-s3c2410.c
··· 480 480 * forces us to send a new START 481 481 * when we change direction 482 482 */ 483 + dev_dbg(i2c->dev, 484 + "missing START before write->read\n"); 483 485 s3c24xx_i2c_stop(i2c, -EINVAL); 486 + break; 484 487 } 485 488 486 489 goto retry_write;
+1 -1
drivers/i2c/busses/i2c-sh_mobile.c
··· 807 807 static const struct of_device_id sh_mobile_i2c_dt_ids[] = { 808 808 { .compatible = "renesas,iic-r8a73a4", .data = &fast_clock_dt_config }, 809 809 { .compatible = "renesas,iic-r8a7740", .data = &r8a7740_dt_config }, 810 - { .compatible = "renesas,iic-r8a774c0", .data = &fast_clock_dt_config }, 810 + { .compatible = "renesas,iic-r8a774c0", .data = &v2_freq_calc_dt_config }, 811 811 { .compatible = "renesas,iic-r8a7790", .data = &v2_freq_calc_dt_config }, 812 812 { .compatible = "renesas,iic-r8a7791", .data = &v2_freq_calc_dt_config }, 813 813 { .compatible = "renesas,iic-r8a7792", .data = &v2_freq_calc_dt_config },
+2 -2
drivers/i2c/busses/i2c-st.c
··· 524 524 } 525 525 526 526 /** 527 - * st_i2c_handle_write() - Handle FIFO enmpty interrupt in case of read 527 + * st_i2c_handle_read() - Handle FIFO empty interrupt in case of read 528 528 * @i2c_dev: Controller's private data 529 529 */ 530 530 static void st_i2c_handle_read(struct st_i2c_dev *i2c_dev) ··· 558 558 } 559 559 560 560 /** 561 - * st_i2c_isr() - Interrupt routine 561 + * st_i2c_isr_thread() - Interrupt routine 562 562 * @irq: interrupt number 563 563 * @data: Controller's private data 564 564 */
+1 -1
drivers/i2c/busses/i2c-stm32f4.c
··· 313 313 } 314 314 315 315 /** 316 - * stm32f4_i2c_write_ byte() - Write a byte in the data register 316 + * stm32f4_i2c_write_byte() - Write a byte in the data register 317 317 * @i2c_dev: Controller's private data 318 318 * @byte: Data to write in the register 319 319 */
+2 -2
drivers/i2c/muxes/i2c-arb-gpio-challenge.c
··· 34 34 }; 35 35 36 36 37 - /** 37 + /* 38 38 * i2c_arbitrator_select - claim the I2C bus 39 39 * 40 40 * Use the GPIO-based signalling protocol; return -EBUSY if we fail. ··· 77 77 return -EBUSY; 78 78 } 79 79 80 - /** 80 + /* 81 81 * i2c_arbitrator_deselect - release the I2C bus 82 82 * 83 83 * Release the I2C bus using the GPIO-based signalling protocol.
+20 -16
drivers/iio/adc/ad7124.c
··· 771 771 if (ret) 772 772 goto err; 773 773 774 + if (channel >= indio_dev->num_channels) { 775 + dev_err(indio_dev->dev.parent, 776 + "Channel index >= number of channels\n"); 777 + ret = -EINVAL; 778 + goto err; 779 + } 780 + 774 781 ret = of_property_read_u32_array(child, "diff-channels", 775 782 ain, 2); 776 783 if (ret) ··· 857 850 return ret; 858 851 } 859 852 853 + static void ad7124_reg_disable(void *r) 854 + { 855 + regulator_disable(r); 856 + } 857 + 860 858 static int ad7124_probe(struct spi_device *spi) 861 859 { 862 860 const struct ad7124_chip_info *info; ··· 907 895 ret = regulator_enable(st->vref[i]); 908 896 if (ret) 909 897 return ret; 898 + 899 + ret = devm_add_action_or_reset(&spi->dev, ad7124_reg_disable, 900 + st->vref[i]); 901 + if (ret) 902 + return ret; 910 903 } 911 904 912 905 st->mclk = devm_clk_get(&spi->dev, "mclk"); 913 - if (IS_ERR(st->mclk)) { 914 - ret = PTR_ERR(st->mclk); 915 - goto error_regulator_disable; 916 - } 906 + if (IS_ERR(st->mclk)) 907 + return PTR_ERR(st->mclk); 917 908 918 909 ret = clk_prepare_enable(st->mclk); 919 910 if (ret < 0) 920 - goto error_regulator_disable; 911 + return ret; 921 912 922 913 ret = ad7124_soft_reset(st); 923 914 if (ret < 0) ··· 950 935 ad_sd_cleanup_buffer_and_trigger(indio_dev); 951 936 error_clk_disable_unprepare: 952 937 clk_disable_unprepare(st->mclk); 953 - error_regulator_disable: 954 - for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) { 955 - if (!IS_ERR_OR_NULL(st->vref[i])) 956 - regulator_disable(st->vref[i]); 957 - } 958 938 959 939 return ret; 960 940 } ··· 958 948 { 959 949 struct iio_dev *indio_dev = spi_get_drvdata(spi); 960 950 struct ad7124_state *st = iio_priv(indio_dev); 961 - int i; 962 951 963 952 iio_device_unregister(indio_dev); 964 953 ad_sd_cleanup_buffer_and_trigger(indio_dev); 965 954 clk_disable_unprepare(st->mclk); 966 - 967 - for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) { 968 - if (!IS_ERR_OR_NULL(st->vref[i])) 969 - regulator_disable(st->vref[i]); 970 - } 971 955 972 956 return 0; 973 957 }
+10 -9
drivers/iio/adc/ad7192.c
··· 912 912 { 913 913 struct ad7192_state *st; 914 914 struct iio_dev *indio_dev; 915 - int ret, voltage_uv = 0; 915 + int ret; 916 916 917 917 if (!spi->irq) { 918 918 dev_err(&spi->dev, "no IRQ?\n"); ··· 949 949 goto error_disable_avdd; 950 950 } 951 951 952 - voltage_uv = regulator_get_voltage(st->avdd); 953 - 954 - if (voltage_uv > 0) { 955 - st->int_vref_mv = voltage_uv / 1000; 956 - } else { 957 - ret = voltage_uv; 952 + ret = regulator_get_voltage(st->avdd); 953 + if (ret < 0) { 958 954 dev_err(&spi->dev, "Device tree error, reference voltage undefined\n"); 959 955 goto error_disable_avdd; 960 956 } 957 + st->int_vref_mv = ret / 1000; 961 958 962 959 spi_set_drvdata(spi, indio_dev); 963 960 st->chip_info = of_device_get_match_data(&spi->dev); ··· 1011 1014 return 0; 1012 1015 1013 1016 error_disable_clk: 1014 - clk_disable_unprepare(st->mclk); 1017 + if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 || 1018 + st->clock_sel == AD7192_CLK_EXT_MCLK2) 1019 + clk_disable_unprepare(st->mclk); 1015 1020 error_remove_trigger: 1016 1021 ad_sd_cleanup_buffer_and_trigger(indio_dev); 1017 1022 error_disable_dvdd: ··· 1030 1031 struct ad7192_state *st = iio_priv(indio_dev); 1031 1032 1032 1033 iio_device_unregister(indio_dev); 1033 - clk_disable_unprepare(st->mclk); 1034 + if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 || 1035 + st->clock_sel == AD7192_CLK_EXT_MCLK2) 1036 + clk_disable_unprepare(st->mclk); 1034 1037 ad_sd_cleanup_buffer_and_trigger(indio_dev); 1035 1038 1036 1039 regulator_disable(st->dvdd);
+6 -2
drivers/iio/adc/ad7768-1.c
··· 167 167 * transfer buffers to live in their own cache lines. 168 168 */ 169 169 union { 170 + struct { 171 + __be32 chan; 172 + s64 timestamp; 173 + } scan; 170 174 __be32 d32; 171 175 u8 d8[2]; 172 176 } data ____cacheline_aligned; ··· 473 469 474 470 mutex_lock(&st->lock); 475 471 476 - ret = spi_read(st->spi, &st->data.d32, 3); 472 + ret = spi_read(st->spi, &st->data.scan.chan, 3); 477 473 if (ret < 0) 478 474 goto err_unlock; 479 475 480 - iio_push_to_buffers_with_timestamp(indio_dev, &st->data.d32, 476 + iio_push_to_buffers_with_timestamp(indio_dev, &st->data.scan, 481 477 iio_get_time_ns(indio_dev)); 482 478 483 479 iio_trigger_notify_done(indio_dev->trig);
+1
drivers/iio/adc/ad7793.c
··· 279 279 id &= AD7793_ID_MASK; 280 280 281 281 if (id != st->chip_info->id) { 282 + ret = -ENODEV; 282 283 dev_err(&st->sd.spi->dev, "device ID query failed\n"); 283 284 goto out; 284 285 }
+3 -1
drivers/iio/adc/ad7923.c
··· 59 59 /* 60 60 * DMA (thus cache coherency maintenance) requires the 61 61 * transfer buffers to live in their own cache lines. 62 + * Ensure rx_buf can be directly used in iio_push_to_buffers_with_timetamp 63 + * Length = 8 channels + 4 extra for 8 byte timestamp 62 64 */ 63 - __be16 rx_buf[4] ____cacheline_aligned; 65 + __be16 rx_buf[12] ____cacheline_aligned; 64 66 __be16 tx_buf[4]; 65 67 }; 66 68
+11 -5
drivers/iio/dac/ad5770r.c
··· 524 524 device_for_each_child_node(&st->spi->dev, child) { 525 525 ret = fwnode_property_read_u32(child, "num", &num); 526 526 if (ret) 527 - return ret; 528 - if (num >= AD5770R_MAX_CHANNELS) 529 - return -EINVAL; 527 + goto err_child_out; 528 + if (num >= AD5770R_MAX_CHANNELS) { 529 + ret = -EINVAL; 530 + goto err_child_out; 531 + } 530 532 531 533 ret = fwnode_property_read_u32_array(child, 532 534 "adi,range-microamp", 533 535 tmp, 2); 534 536 if (ret) 535 - return ret; 537 + goto err_child_out; 536 538 537 539 min = tmp[0] / 1000; 538 540 max = tmp[1] / 1000; 539 541 ret = ad5770r_store_output_range(st, min, max, num); 540 542 if (ret) 541 - return ret; 543 + goto err_child_out; 542 544 } 543 545 546 + return 0; 547 + 548 + err_child_out: 549 + fwnode_handle_put(child); 544 550 return ret; 545 551 } 546 552
+2
drivers/iio/gyro/fxas21002c_core.c
··· 399 399 ret = regmap_field_read(data->regmap_fields[F_TEMP], &temp); 400 400 if (ret < 0) { 401 401 dev_err(dev, "failed to read temp: %d\n", ret); 402 + fxas21002c_pm_put(data); 402 403 goto data_unlock; 403 404 } 404 405 ··· 433 432 &axis_be, sizeof(axis_be)); 434 433 if (ret < 0) { 435 434 dev_err(dev, "failed to read axis: %d: %d\n", index, ret); 435 + fxas21002c_pm_put(data); 436 436 goto data_unlock; 437 437 } 438 438
+2 -2
drivers/infiniband/hw/mlx5/mr.c
··· 743 743 ent->xlt = (1 << ent->order) * sizeof(struct mlx5_mtt) / 744 744 MLX5_IB_UMR_OCTOWORD; 745 745 ent->access_mode = MLX5_MKC_ACCESS_MODE_MTT; 746 - if ((dev->mdev->profile->mask & MLX5_PROF_MASK_MR_CACHE) && 746 + if ((dev->mdev->profile.mask & MLX5_PROF_MASK_MR_CACHE) && 747 747 !dev->is_rep && mlx5_core_is_pf(dev->mdev) && 748 748 mlx5_ib_can_load_pas_with_umr(dev, 0)) 749 - ent->limit = dev->mdev->profile->mr_cache[i].limit; 749 + ent->limit = dev->mdev->profile.mr_cache[i].limit; 750 750 else 751 751 ent->limit = 0; 752 752 spin_lock_irq(&ent->lock);
+3 -1
drivers/interconnect/qcom/bcm-voter.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * Copyright (c) 2020, The Linux Foundation. All rights reserved. 3 + * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. 4 4 */ 5 5 6 6 #include <asm/div64.h> ··· 205 205 } 206 206 mutex_unlock(&bcm_voter_lock); 207 207 208 + of_node_put(node); 208 209 return voter; 209 210 } 210 211 EXPORT_SYMBOL_GPL(of_bcm_voter_get); ··· 363 362 { .compatible = "qcom,bcm-voter" }, 364 363 { } 365 364 }; 365 + MODULE_DEVICE_TABLE(of, bcm_voter_of_match); 366 366 367 367 static struct platform_driver qcom_icc_bcm_voter_driver = { 368 368 .probe = qcom_icc_bcm_voter_probe,
+3 -1
drivers/iommu/amd/iommu.c
··· 884 884 * The msb-bit must be clear on the address. Just set all the 885 885 * lower bits. 886 886 */ 887 - address |= 1ull << (msb_diff - 1); 887 + address |= (1ull << msb_diff) - 1; 888 888 } 889 889 890 890 /* Clear bits 11:0 */ ··· 1714 1714 domain = iommu_get_domain_for_dev(dev); 1715 1715 if (domain->type == IOMMU_DOMAIN_DMA) 1716 1716 iommu_setup_dma_ops(dev, IOVA_START_PFN << PAGE_SHIFT, 0); 1717 + else 1718 + set_dma_ops(dev, NULL); 1717 1719 } 1718 1720 1719 1721 static void amd_iommu_release_device(struct device *dev)
+3 -1
drivers/iommu/intel/dmar.c
··· 1142 1142 1143 1143 err = iommu_device_register(&iommu->iommu, &intel_iommu_ops, NULL); 1144 1144 if (err) 1145 - goto err_unmap; 1145 + goto err_sysfs; 1146 1146 } 1147 1147 1148 1148 drhd->iommu = iommu; ··· 1150 1150 1151 1151 return 0; 1152 1152 1153 + err_sysfs: 1154 + iommu_device_sysfs_remove(&iommu->iommu); 1153 1155 err_unmap: 1154 1156 unmap_iommu(iommu); 1155 1157 error_free_seq_id:
+7 -2
drivers/iommu/intel/iommu.c
··· 2525 2525 struct device *dev, 2526 2526 u32 pasid) 2527 2527 { 2528 - int flags = PASID_FLAG_SUPERVISOR_MODE; 2529 2528 struct dma_pte *pgd = domain->pgd; 2530 2529 int agaw, level; 2530 + int flags = 0; 2531 2531 2532 2532 /* 2533 2533 * Skip top levels of page tables for iommu which has ··· 2543 2543 if (level != 4 && level != 5) 2544 2544 return -EINVAL; 2545 2545 2546 - flags |= (level == 5) ? PASID_FLAG_FL5LP : 0; 2546 + if (pasid != PASID_RID2PASID) 2547 + flags |= PASID_FLAG_SUPERVISOR_MODE; 2548 + if (level == 5) 2549 + flags |= PASID_FLAG_FL5LP; 2547 2550 2548 2551 if (domain->domain.type == IOMMU_DOMAIN_UNMANAGED) 2549 2552 flags |= PASID_FLAG_PAGE_SNOOP; ··· 4609 4606 4610 4607 if (!sinfo) { 4611 4608 sinfo = kzalloc(sizeof(*sinfo), GFP_ATOMIC); 4609 + if (!sinfo) 4610 + return -ENOMEM; 4612 4611 sinfo->domain = domain; 4613 4612 sinfo->pdev = dev; 4614 4613 list_add(&sinfo->link_phys, &info->subdevices);
+2 -1
drivers/iommu/intel/pasid.c
··· 699 699 * Since it is a second level only translation setup, we should 700 700 * set SRE bit as well (addresses are expected to be GPAs). 701 701 */ 702 - pasid_set_sre(pte); 702 + if (pasid != PASID_RID2PASID) 703 + pasid_set_sre(pte); 703 704 pasid_set_present(pte); 704 705 pasid_flush_caches(iommu, pte, pasid, did); 705 706
+1
drivers/iommu/virtio-iommu.c
··· 1136 1136 { VIRTIO_ID_IOMMU, VIRTIO_DEV_ANY_ID }, 1137 1137 { 0 }, 1138 1138 }; 1139 + MODULE_DEVICE_TABLE(virtio, id_table); 1139 1140 1140 1141 static struct virtio_driver virtio_iommu_drv = { 1141 1142 .driver.name = KBUILD_MODNAME,
-1
drivers/isdn/hardware/mISDN/netjet.c
··· 1100 1100 card->typ = NETJET_S_TJ300; 1101 1101 1102 1102 card->base = pci_resource_start(pdev, 0); 1103 - card->irq = pdev->irq; 1104 1103 pci_set_drvdata(pdev, card); 1105 1104 err = setup_instance(card); 1106 1105 if (err)
+2 -1
drivers/md/dm-snap.c
··· 859 859 860 860 if (o) 861 861 list_for_each_entry(snap, &o->snapshots, list) 862 - chunk_size = min(chunk_size, snap->store->chunk_size); 862 + chunk_size = min_not_zero(chunk_size, 863 + snap->store->chunk_size); 863 864 864 865 return (uint32_t) chunk_size; 865 866 }
+1 -1
drivers/md/dm-verity-verify-sig.c
··· 15 15 #define DM_VERITY_VERIFY_ERR(s) DM_VERITY_ROOT_HASH_VERIFICATION " " s 16 16 17 17 static bool require_signatures; 18 - module_param(require_signatures, bool, false); 18 + module_param(require_signatures, bool, 0444); 19 19 MODULE_PARM_DESC(require_signatures, 20 20 "Verify the roothash of dm-verity hash tree"); 21 21
-2
drivers/md/raid5.c
··· 5311 5311 unsigned int chunk_sectors; 5312 5312 unsigned int bio_sectors = bio_sectors(bio); 5313 5313 5314 - WARN_ON_ONCE(bio->bi_bdev->bd_partno); 5315 - 5316 5314 chunk_sectors = min(conf->chunk_sectors, conf->prev_chunk_sectors); 5317 5315 return chunk_sectors >= 5318 5316 ((sector & (chunk_sectors - 1)) + bio_sectors);
+2 -1
drivers/misc/kgdbts.c
··· 101 101 printk(KERN_INFO a); \ 102 102 } while (0) 103 103 #define v2printk(a...) do { \ 104 - if (verbose > 1) \ 104 + if (verbose > 1) { \ 105 105 printk(KERN_INFO a); \ 106 + } \ 106 107 touch_nmi_watchdog(); \ 107 108 } while (0) 108 109 #define eprintk(a...) do { \
+3
drivers/misc/mei/interrupt.c
··· 277 277 return ret; 278 278 } 279 279 280 + pm_runtime_mark_last_busy(dev->dev); 281 + pm_request_autosuspend(dev->dev); 282 + 280 283 list_move_tail(&cb->list, &cl->rd_pending); 281 284 282 285 return 0;
+11 -1
drivers/mtd/nand/raw/cs553x_nand.c
··· 18 18 #include <linux/module.h> 19 19 #include <linux/delay.h> 20 20 #include <linux/mtd/mtd.h> 21 + #include <linux/mtd/nand-ecc-sw-hamming.h> 21 22 #include <linux/mtd/rawnand.h> 22 23 #include <linux/mtd/partitions.h> 23 24 #include <linux/iopoll.h> ··· 241 240 return 0; 242 241 } 243 242 243 + static int cs553x_ecc_correct(struct nand_chip *chip, 244 + unsigned char *buf, 245 + unsigned char *read_ecc, 246 + unsigned char *calc_ecc) 247 + { 248 + return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc, 249 + chip->ecc.size, false); 250 + } 251 + 244 252 static struct cs553x_nand_controller *controllers[4]; 245 253 246 254 static int cs553x_attach_chip(struct nand_chip *chip) ··· 261 251 chip->ecc.bytes = 3; 262 252 chip->ecc.hwctl = cs_enable_hwecc; 263 253 chip->ecc.calculate = cs_calculate_ecc; 264 - chip->ecc.correct = rawnand_sw_hamming_correct; 254 + chip->ecc.correct = cs553x_ecc_correct; 265 255 chip->ecc.strength = 1; 266 256 267 257 return 0;
+11 -1
drivers/mtd/nand/raw/fsmc_nand.c
··· 25 25 #include <linux/sched.h> 26 26 #include <linux/types.h> 27 27 #include <linux/mtd/mtd.h> 28 + #include <linux/mtd/nand-ecc-sw-hamming.h> 28 29 #include <linux/mtd/rawnand.h> 29 30 #include <linux/platform_device.h> 30 31 #include <linux/of.h> ··· 431 430 ecc[2] = ecc_tmp >> 16; 432 431 433 432 return 0; 433 + } 434 + 435 + static int fsmc_correct_ecc1(struct nand_chip *chip, 436 + unsigned char *buf, 437 + unsigned char *read_ecc, 438 + unsigned char *calc_ecc) 439 + { 440 + return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc, 441 + chip->ecc.size, false); 434 442 } 435 443 436 444 /* Count the number of 0's in buff upto a max of max_bits */ ··· 927 917 case NAND_ECC_ENGINE_TYPE_ON_HOST: 928 918 dev_info(host->dev, "Using 1-bit HW ECC scheme\n"); 929 919 nand->ecc.calculate = fsmc_read_hwecc_ecc1; 930 - nand->ecc.correct = rawnand_sw_hamming_correct; 920 + nand->ecc.correct = fsmc_correct_ecc1; 931 921 nand->ecc.hwctl = fsmc_enable_hwecc; 932 922 nand->ecc.bytes = 3; 933 923 nand->ecc.strength = 1;
+14 -1
drivers/mtd/nand/raw/lpc32xx_slc.c
··· 27 27 #include <linux/of.h> 28 28 #include <linux/of_gpio.h> 29 29 #include <linux/mtd/lpc32xx_slc.h> 30 + #include <linux/mtd/nand-ecc-sw-hamming.h> 30 31 31 32 #define LPC32XX_MODNAME "lpc32xx-nand" 32 33 ··· 343 342 * and write operations, so it doesn't need to be calculated here. 344 343 */ 345 344 return 0; 345 + } 346 + 347 + /* 348 + * Corrects the data 349 + */ 350 + static int lpc32xx_nand_ecc_correct(struct nand_chip *chip, 351 + unsigned char *buf, 352 + unsigned char *read_ecc, 353 + unsigned char *calc_ecc) 354 + { 355 + return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc, 356 + chip->ecc.size, false); 346 357 } 347 358 348 359 /* ··· 815 802 chip->ecc.write_oob = lpc32xx_nand_write_oob_syndrome; 816 803 chip->ecc.read_oob = lpc32xx_nand_read_oob_syndrome; 817 804 chip->ecc.calculate = lpc32xx_nand_ecc_calculate; 818 - chip->ecc.correct = rawnand_sw_hamming_correct; 805 + chip->ecc.correct = lpc32xx_nand_ecc_correct; 819 806 chip->ecc.hwctl = lpc32xx_nand_ecc_enable; 820 807 821 808 /*
+11 -1
drivers/mtd/nand/raw/ndfc.c
··· 22 22 #include <linux/mtd/ndfc.h> 23 23 #include <linux/slab.h> 24 24 #include <linux/mtd/mtd.h> 25 + #include <linux/mtd/nand-ecc-sw-hamming.h> 25 26 #include <linux/of_address.h> 26 27 #include <linux/of_platform.h> 27 28 #include <asm/io.h> ··· 101 100 return 0; 102 101 } 103 102 103 + static int ndfc_correct_ecc(struct nand_chip *chip, 104 + unsigned char *buf, 105 + unsigned char *read_ecc, 106 + unsigned char *calc_ecc) 107 + { 108 + return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc, 109 + chip->ecc.size, false); 110 + } 111 + 104 112 /* 105 113 * Speedups for buffer read/write/verify 106 114 * ··· 155 145 chip->controller = &ndfc->ndfc_control; 156 146 chip->legacy.read_buf = ndfc_read_buf; 157 147 chip->legacy.write_buf = ndfc_write_buf; 158 - chip->ecc.correct = rawnand_sw_hamming_correct; 148 + chip->ecc.correct = ndfc_correct_ecc; 159 149 chip->ecc.hwctl = ndfc_enable_hwecc; 160 150 chip->ecc.calculate = ndfc_calculate_ecc; 161 151 chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
+11 -1
drivers/mtd/nand/raw/sharpsl.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/delay.h> 13 13 #include <linux/mtd/mtd.h> 14 + #include <linux/mtd/nand-ecc-sw-hamming.h> 14 15 #include <linux/mtd/rawnand.h> 15 16 #include <linux/mtd/partitions.h> 16 17 #include <linux/mtd/sharpsl.h> ··· 97 96 return readb(sharpsl->io + ECCCNTR) != 0; 98 97 } 99 98 99 + static int sharpsl_nand_correct_ecc(struct nand_chip *chip, 100 + unsigned char *buf, 101 + unsigned char *read_ecc, 102 + unsigned char *calc_ecc) 103 + { 104 + return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc, 105 + chip->ecc.size, false); 106 + } 107 + 100 108 static int sharpsl_attach_chip(struct nand_chip *chip) 101 109 { 102 110 if (chip->ecc.engine_type != NAND_ECC_ENGINE_TYPE_ON_HOST) ··· 116 106 chip->ecc.strength = 1; 117 107 chip->ecc.hwctl = sharpsl_nand_enable_hwecc; 118 108 chip->ecc.calculate = sharpsl_nand_calculate_ecc; 119 - chip->ecc.correct = rawnand_sw_hamming_correct; 109 + chip->ecc.correct = sharpsl_nand_correct_ecc; 120 110 121 111 return 0; 122 112 }
+5 -3
drivers/mtd/nand/raw/tmio_nand.c
··· 34 34 #include <linux/interrupt.h> 35 35 #include <linux/ioport.h> 36 36 #include <linux/mtd/mtd.h> 37 + #include <linux/mtd/nand-ecc-sw-hamming.h> 37 38 #include <linux/mtd/rawnand.h> 38 39 #include <linux/mtd/partitions.h> 39 40 #include <linux/slab.h> ··· 293 292 int r0, r1; 294 293 295 294 /* assume ecc.size = 512 and ecc.bytes = 6 */ 296 - r0 = rawnand_sw_hamming_correct(chip, buf, read_ecc, calc_ecc); 295 + r0 = ecc_sw_hamming_correct(buf, read_ecc, calc_ecc, 296 + chip->ecc.size, false); 297 297 if (r0 < 0) 298 298 return r0; 299 - r1 = rawnand_sw_hamming_correct(chip, buf + 256, read_ecc + 3, 300 - calc_ecc + 3); 299 + r1 = ecc_sw_hamming_correct(buf + 256, read_ecc + 3, calc_ecc + 3, 300 + chip->ecc.size, false); 301 301 if (r1 < 0) 302 302 return r1; 303 303 return r0 + r1;
+3 -2
drivers/mtd/nand/raw/txx9ndfmc.c
··· 13 13 #include <linux/platform_device.h> 14 14 #include <linux/delay.h> 15 15 #include <linux/mtd/mtd.h> 16 + #include <linux/mtd/nand-ecc-sw-hamming.h> 16 17 #include <linux/mtd/rawnand.h> 17 18 #include <linux/mtd/partitions.h> 18 19 #include <linux/io.h> ··· 194 193 int stat; 195 194 196 195 for (eccsize = chip->ecc.size; eccsize > 0; eccsize -= 256) { 197 - stat = rawnand_sw_hamming_correct(chip, buf, read_ecc, 198 - calc_ecc); 196 + stat = ecc_sw_hamming_correct(buf, read_ecc, calc_ecc, 197 + chip->ecc.size, false); 199 198 if (stat < 0) 200 199 return stat; 201 200 corrected += stat;
+14 -12
drivers/mtd/parsers/ofpart_core.c
··· 57 57 if (!mtd_node) 58 58 return 0; 59 59 60 - ofpart_node = of_get_child_by_name(mtd_node, "partitions"); 61 - if (!ofpart_node && !master->parent) { 62 - /* 63 - * We might get here even when ofpart isn't used at all (e.g., 64 - * when using another parser), so don't be louder than 65 - * KERN_DEBUG 66 - */ 67 - pr_debug("%s: 'partitions' subnode not found on %pOF. Trying to parse direct subnodes as partitions.\n", 68 - master->name, mtd_node); 60 + if (!master->parent) { /* Master */ 61 + ofpart_node = of_get_child_by_name(mtd_node, "partitions"); 62 + if (!ofpart_node) { 63 + /* 64 + * We might get here even when ofpart isn't used at all (e.g., 65 + * when using another parser), so don't be louder than 66 + * KERN_DEBUG 67 + */ 68 + pr_debug("%s: 'partitions' subnode not found on %pOF. Trying to parse direct subnodes as partitions.\n", 69 + master->name, mtd_node); 70 + ofpart_node = mtd_node; 71 + dedicated = false; 72 + } 73 + } else { /* Partition */ 69 74 ofpart_node = mtd_node; 70 - dedicated = false; 71 75 } 72 - if (!ofpart_node) 73 - return 0; 74 76 75 77 of_id = of_match_node(parse_ofpart_match_table, ofpart_node); 76 78 if (dedicated && !of_id) {
+2 -2
drivers/net/appletalk/cops.c
··· 327 327 break; 328 328 } 329 329 330 + dev->base_addr = ioaddr; 331 + 330 332 /* Reserve any actual interrupt. */ 331 333 if (dev->irq) { 332 334 retval = request_irq(dev->irq, cops_interrupt, 0, dev->name, dev); 333 335 if (retval) 334 336 goto err_out; 335 337 } 336 - 337 - dev->base_addr = ioaddr; 338 338 339 339 lp = netdev_priv(dev); 340 340 spin_lock_init(&lp->lock);
+1 -1
drivers/net/bonding/bond_main.c
··· 1526 1526 1527 1527 slave->bond = bond; 1528 1528 slave->dev = slave_dev; 1529 + INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); 1529 1530 1530 1531 if (bond_kobj_init(slave)) 1531 1532 return NULL; ··· 1539 1538 return NULL; 1540 1539 } 1541 1540 } 1542 - INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); 1543 1541 1544 1542 return slave; 1545 1543 }
+2 -3
drivers/net/dsa/bcm_sf2.c
··· 821 821 bcm_sf2_sw_mac_link_set(ds, port, interface, true); 822 822 823 823 if (port != core_readl(priv, CORE_IMP0_PRT_ID)) { 824 - u32 reg_rgmii_ctrl; 824 + u32 reg_rgmii_ctrl = 0; 825 825 u32 reg, offset; 826 - 827 - reg_rgmii_ctrl = bcm_sf2_reg_rgmii_cntrl(priv, port); 828 826 829 827 if (priv->type == BCM4908_DEVICE_ID || 830 828 priv->type == BCM7445_DEVICE_ID) ··· 834 836 interface == PHY_INTERFACE_MODE_RGMII_TXID || 835 837 interface == PHY_INTERFACE_MODE_MII || 836 838 interface == PHY_INTERFACE_MODE_REVMII) { 839 + reg_rgmii_ctrl = bcm_sf2_reg_rgmii_cntrl(priv, port); 837 840 reg = reg_readl(priv, reg_rgmii_ctrl); 838 841 reg &= ~(RX_PAUSE_EN | TX_PAUSE_EN); 839 842
+1
drivers/net/dsa/microchip/ksz9477.c
··· 1530 1530 .num_statics = 16, 1531 1531 .cpu_ports = 0x7F, /* can be configured as cpu port */ 1532 1532 .port_cnt = 7, /* total physical port count */ 1533 + .phy_errata_9477 = true, 1533 1534 }, 1534 1535 }; 1535 1536
-8
drivers/net/dsa/mt7530.c
··· 1262 1262 { 1263 1263 struct mt7530_priv *priv = ds->priv; 1264 1264 1265 - /* The real fabric path would be decided on the membership in the 1266 - * entry of VLAN table. PCR_MATRIX set up here with ALL_MEMBERS 1267 - * means potential VLAN can be consisting of certain subset of all 1268 - * ports. 1269 - */ 1270 - mt7530_rmw(priv, MT7530_PCR_P(port), 1271 - PCR_MATRIX_MASK, PCR_MATRIX(MT7530_ALL_MEMBERS)); 1272 - 1273 1265 /* Trapped into security mode allows packet forwarding through VLAN 1274 1266 * table lookup. CPU port is set to fallback mode to let untagged 1275 1267 * frames pass through.
+10 -5
drivers/net/dsa/ocelot/felix_vsc9959.c
··· 1227 1227 if (taprio->num_entries > VSC9959_TAS_GCL_ENTRY_MAX) 1228 1228 return -ERANGE; 1229 1229 1230 - /* Set port num and disable ALWAYS_GUARD_BAND_SCH_Q, which means set 1231 - * guard band to be implemented for nonschedule queues to schedule 1232 - * queues transition. 1230 + /* Enable guard band. The switch will schedule frames without taking 1231 + * their length into account. Thus we'll always need to enable the 1232 + * guard band which reserves the time of a maximum sized frame at the 1233 + * end of the time window. 1234 + * 1235 + * Although the ALWAYS_GUARD_BAND_SCH_Q bit is global for all ports, we 1236 + * need to set PORT_NUM, because subsequent writes to PARAM_CFG_REG_n 1237 + * operate on the port number. 1233 1238 */ 1234 - ocelot_rmw(ocelot, 1235 - QSYS_TAS_PARAM_CFG_CTRL_PORT_NUM(port), 1239 + ocelot_rmw(ocelot, QSYS_TAS_PARAM_CFG_CTRL_PORT_NUM(port) | 1240 + QSYS_TAS_PARAM_CFG_CTRL_ALWAYS_GUARD_BAND_SCH_Q, 1236 1241 QSYS_TAS_PARAM_CFG_CTRL_PORT_NUM_M | 1237 1242 QSYS_TAS_PARAM_CFG_CTRL_ALWAYS_GUARD_BAND_SCH_Q, 1238 1243 QSYS_TAS_PARAM_CFG_CTRL);
+19 -4
drivers/net/dsa/sja1105/sja1105_dynamic_config.c
··· 167 167 SJA1105_HOSTCMD_INVALIDATE = 4, 168 168 }; 169 169 170 + /* Command and entry overlap */ 170 171 static void 171 - sja1105_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd, 172 - enum packing_op op) 172 + sja1105et_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd, 173 + enum packing_op op) 173 174 { 174 175 const int size = SJA1105_SIZE_DYN_CMD; 175 176 ··· 178 177 sja1105_packing(buf, &cmd->errors, 30, 30, size, op); 179 178 sja1105_packing(buf, &cmd->rdwrset, 29, 29, size, op); 180 179 sja1105_packing(buf, &cmd->index, 9, 0, size, op); 180 + } 181 + 182 + /* Command and entry are separate */ 183 + static void 184 + sja1105pqrs_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd, 185 + enum packing_op op) 186 + { 187 + u8 *p = buf + SJA1105_SIZE_VL_LOOKUP_ENTRY; 188 + const int size = SJA1105_SIZE_DYN_CMD; 189 + 190 + sja1105_packing(p, &cmd->valid, 31, 31, size, op); 191 + sja1105_packing(p, &cmd->errors, 30, 30, size, op); 192 + sja1105_packing(p, &cmd->rdwrset, 29, 29, size, op); 193 + sja1105_packing(p, &cmd->index, 9, 0, size, op); 181 194 } 182 195 183 196 static size_t sja1105et_vl_lookup_entry_packing(void *buf, void *entry_ptr, ··· 656 641 const struct sja1105_dynamic_table_ops sja1105et_dyn_ops[BLK_IDX_MAX_DYN] = { 657 642 [BLK_IDX_VL_LOOKUP] = { 658 643 .entry_packing = sja1105et_vl_lookup_entry_packing, 659 - .cmd_packing = sja1105_vl_lookup_cmd_packing, 644 + .cmd_packing = sja1105et_vl_lookup_cmd_packing, 660 645 .access = OP_WRITE, 661 646 .max_entry_count = SJA1105_MAX_VL_LOOKUP_COUNT, 662 647 .packed_size = SJA1105ET_SIZE_VL_LOOKUP_DYN_CMD, ··· 740 725 const struct sja1105_dynamic_table_ops sja1105pqrs_dyn_ops[BLK_IDX_MAX_DYN] = { 741 726 [BLK_IDX_VL_LOOKUP] = { 742 727 .entry_packing = sja1105_vl_lookup_entry_packing, 743 - .cmd_packing = sja1105_vl_lookup_cmd_packing, 728 + .cmd_packing = sja1105pqrs_vl_lookup_cmd_packing, 744 729 .access = (OP_READ | OP_WRITE), 745 730 .max_entry_count = SJA1105_MAX_VL_LOOKUP_COUNT, 746 731 .packed_size = SJA1105PQRS_SIZE_VL_LOOKUP_DYN_CMD,
+51 -23
drivers/net/dsa/sja1105/sja1105_main.c
··· 26 26 #include "sja1105_tas.h" 27 27 28 28 #define SJA1105_UNKNOWN_MULTICAST 0x010000000000ull 29 + #define SJA1105_DEFAULT_VLAN (VLAN_N_VID - 1) 29 30 30 31 static const struct dsa_switch_ops sja1105_switch_ops; 31 32 ··· 208 207 default: 209 208 dev_err(dev, "Unsupported PHY mode %s!\n", 210 209 phy_modes(ports[i].phy_mode)); 210 + return -EINVAL; 211 211 } 212 212 213 213 /* Even though the SerDes port is able to drive SGMII autoneg ··· 323 321 return 0; 324 322 } 325 323 324 + /* Set up a default VLAN for untagged traffic injected from the CPU 325 + * using management routes (e.g. STP, PTP) as opposed to tag_8021q. 326 + * All DT-defined ports are members of this VLAN, and there are no 327 + * restrictions on forwarding (since the CPU selects the destination). 328 + * Frames from this VLAN will always be transmitted as untagged, and 329 + * neither the bridge nor the 8021q module cannot create this VLAN ID. 330 + */ 326 331 static int sja1105_init_static_vlan(struct sja1105_private *priv) 327 332 { 328 333 struct sja1105_table *table; ··· 339 330 .vmemb_port = 0, 340 331 .vlan_bc = 0, 341 332 .tag_port = 0, 342 - .vlanid = 1, 333 + .vlanid = SJA1105_DEFAULT_VLAN, 343 334 }; 344 335 struct dsa_switch *ds = priv->ds; 345 336 int port; 346 337 347 338 table = &priv->static_config.tables[BLK_IDX_VLAN_LOOKUP]; 348 339 349 - /* The static VLAN table will only contain the initial pvid of 1. 350 - * All other VLANs are to be configured through dynamic entries, 351 - * and kept in the static configuration table as backing memory. 352 - */ 353 340 if (table->entry_count) { 354 341 kfree(table->entries); 355 342 table->entry_count = 0; ··· 358 353 359 354 table->entry_count = 1; 360 355 361 - /* VLAN 1: all DT-defined ports are members; no restrictions on 362 - * forwarding; always transmit as untagged. 363 - */ 364 356 for (port = 0; port < ds->num_ports; port++) { 365 357 struct sja1105_bridge_vlan *v; 366 358 ··· 368 366 pvid.vlan_bc |= BIT(port); 369 367 pvid.tag_port &= ~BIT(port); 370 368 371 - /* Let traffic that don't need dsa_8021q (e.g. STP, PTP) be 372 - * transmitted as untagged. 373 - */ 374 369 v = kzalloc(sizeof(*v), GFP_KERNEL); 375 370 if (!v) 376 371 return -ENOMEM; 377 372 378 373 v->port = port; 379 - v->vid = 1; 374 + v->vid = SJA1105_DEFAULT_VLAN; 380 375 v->untagged = true; 381 376 if (dsa_is_cpu_port(ds, port)) 382 377 v->pvid = true; ··· 2816 2817 bool pvid = flags & BRIDGE_VLAN_INFO_PVID; 2817 2818 struct sja1105_bridge_vlan *v; 2818 2819 2819 - list_for_each_entry(v, vlan_list, list) 2820 - if (v->port == port && v->vid == vid && 2821 - v->untagged == untagged && v->pvid == pvid) 2820 + list_for_each_entry(v, vlan_list, list) { 2821 + if (v->port == port && v->vid == vid) { 2822 2822 /* Already added */ 2823 - return 0; 2823 + if (v->untagged == untagged && v->pvid == pvid) 2824 + /* Nothing changed */ 2825 + return 0; 2826 + 2827 + /* It's the same VLAN, but some of the flags changed 2828 + * and the user did not bother to delete it first. 2829 + * Update it and trigger sja1105_build_vlan_table. 2830 + */ 2831 + v->untagged = untagged; 2832 + v->pvid = pvid; 2833 + return 1; 2834 + } 2835 + } 2824 2836 2825 2837 v = kzalloc(sizeof(*v), GFP_KERNEL); 2826 2838 if (!v) { ··· 2986 2976 rc = sja1105_static_config_load(priv, ports); 2987 2977 if (rc < 0) { 2988 2978 dev_err(ds->dev, "Failed to load static config: %d\n", rc); 2989 - return rc; 2979 + goto out_ptp_clock_unregister; 2990 2980 } 2991 2981 /* Configure the CGU (PHY link modes and speeds) */ 2992 2982 rc = sja1105_clocking_setup(priv); 2993 2983 if (rc < 0) { 2994 2984 dev_err(ds->dev, "Failed to configure MII clocking: %d\n", rc); 2995 - return rc; 2985 + goto out_static_config_free; 2996 2986 } 2997 2987 /* On SJA1105, VLAN filtering per se is always enabled in hardware. 2998 2988 * The only thing we can do to disable it is lie about what the 802.1Q ··· 3013 3003 3014 3004 rc = sja1105_devlink_setup(ds); 3015 3005 if (rc < 0) 3016 - return rc; 3006 + goto out_static_config_free; 3017 3007 3018 3008 /* The DSA/switchdev model brings up switch ports in standalone mode by 3019 3009 * default, and that means vlan_filtering is 0 since they're not under ··· 3022 3012 rtnl_lock(); 3023 3013 rc = sja1105_setup_8021q_tagging(ds, true); 3024 3014 rtnl_unlock(); 3015 + if (rc) 3016 + goto out_devlink_teardown; 3017 + 3018 + return 0; 3019 + 3020 + out_devlink_teardown: 3021 + sja1105_devlink_teardown(ds); 3022 + out_ptp_clock_unregister: 3023 + sja1105_ptp_clock_unregister(ds); 3024 + out_static_config_free: 3025 + sja1105_static_config_free(&priv->static_config); 3025 3026 3026 3027 return rc; 3027 3028 } ··· 3667 3646 priv->cbs = devm_kcalloc(dev, priv->info->num_cbs_shapers, 3668 3647 sizeof(struct sja1105_cbs_entry), 3669 3648 GFP_KERNEL); 3670 - if (!priv->cbs) 3671 - return -ENOMEM; 3649 + if (!priv->cbs) { 3650 + rc = -ENOMEM; 3651 + goto out_unregister_switch; 3652 + } 3672 3653 } 3673 3654 3674 3655 /* Connections between dsa_port and sja1105_port */ ··· 3695 3672 dev_err(ds->dev, 3696 3673 "failed to create deferred xmit thread: %d\n", 3697 3674 rc); 3698 - goto out; 3675 + goto out_destroy_workers; 3699 3676 } 3700 3677 skb_queue_head_init(&sp->xmit_queue); 3701 3678 sp->xmit_tpid = ETH_P_SJA1105; ··· 3705 3682 } 3706 3683 3707 3684 return 0; 3708 - out: 3685 + 3686 + out_destroy_workers: 3709 3687 while (port-- > 0) { 3710 3688 struct sja1105_port *sp = &priv->ports[port]; 3711 3689 ··· 3715 3691 3716 3692 kthread_destroy_worker(sp->xmit_worker); 3717 3693 } 3694 + 3695 + out_unregister_switch: 3696 + dsa_unregister_switch(ds); 3697 + 3718 3698 return rc; 3719 3699 } 3720 3700
+1 -1
drivers/net/ethernet/broadcom/bnx2.c
··· 8247 8247 BNX2_WR(bp, PCI_COMMAND, reg); 8248 8248 } else if ((BNX2_CHIP_ID(bp) == BNX2_CHIP_ID_5706_A1) && 8249 8249 !(bp->flags & BNX2_FLAG_PCIX)) { 8250 - 8251 8250 dev_err(&pdev->dev, 8252 8251 "5706 A1 can only be used in a PCIX bus, aborting\n"); 8252 + rc = -EPERM; 8253 8253 goto err_out_unmap; 8254 8254 } 8255 8255
+3 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
··· 1223 1223 goto failed; 1224 1224 1225 1225 /* SR-IOV capability was enabled but there are no VFs*/ 1226 - if (iov->total == 0) 1226 + if (iov->total == 0) { 1227 + err = -EINVAL; 1227 1228 goto failed; 1229 + } 1228 1230 1229 1231 iov->nr_virtfn = min_t(u16, iov->total, num_vfs_param); 1230 1232
+110 -28
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 282 282 { 283 283 return (idx == NETXTREME_C_VF || idx == NETXTREME_E_VF || 284 284 idx == NETXTREME_S_VF || idx == NETXTREME_C_VF_HV || 285 - idx == NETXTREME_E_VF_HV || idx == NETXTREME_E_P5_VF); 285 + idx == NETXTREME_E_VF_HV || idx == NETXTREME_E_P5_VF || 286 + idx == NETXTREME_E_P5_VF_HV); 286 287 } 287 288 288 289 #define DB_CP_REARM_FLAGS (DB_KEY_CP | DB_IDX_VALID) ··· 6933 6932 static void bnxt_hwrm_set_pg_attr(struct bnxt_ring_mem_info *rmem, u8 *pg_attr, 6934 6933 __le64 *pg_dir) 6935 6934 { 6936 - u8 pg_size = 0; 6937 - 6938 6935 if (!rmem->nr_pages) 6939 6936 return; 6940 6937 6941 - if (BNXT_PAGE_SHIFT == 13) 6942 - pg_size = 1 << 4; 6943 - else if (BNXT_PAGE_SIZE == 16) 6944 - pg_size = 2 << 4; 6945 - 6946 - *pg_attr = pg_size; 6938 + BNXT_SET_CTX_PAGE_ATTR(*pg_attr); 6947 6939 if (rmem->depth >= 1) { 6948 6940 if (rmem->depth == 2) 6949 6941 *pg_attr |= 2; ··· 10779 10785 return rc; 10780 10786 } 10781 10787 10788 + static bool bnxt_exthdr_check(struct bnxt *bp, struct sk_buff *skb, int nw_off, 10789 + u8 **nextp) 10790 + { 10791 + struct ipv6hdr *ip6h = (struct ipv6hdr *)(skb->data + nw_off); 10792 + int hdr_count = 0; 10793 + u8 *nexthdr; 10794 + int start; 10795 + 10796 + /* Check that there are at most 2 IPv6 extension headers, no 10797 + * fragment header, and each is <= 64 bytes. 10798 + */ 10799 + start = nw_off + sizeof(*ip6h); 10800 + nexthdr = &ip6h->nexthdr; 10801 + while (ipv6_ext_hdr(*nexthdr)) { 10802 + struct ipv6_opt_hdr *hp; 10803 + int hdrlen; 10804 + 10805 + if (hdr_count >= 3 || *nexthdr == NEXTHDR_NONE || 10806 + *nexthdr == NEXTHDR_FRAGMENT) 10807 + return false; 10808 + hp = __skb_header_pointer(NULL, start, sizeof(*hp), skb->data, 10809 + skb_headlen(skb), NULL); 10810 + if (!hp) 10811 + return false; 10812 + if (*nexthdr == NEXTHDR_AUTH) 10813 + hdrlen = ipv6_authlen(hp); 10814 + else 10815 + hdrlen = ipv6_optlen(hp); 10816 + 10817 + if (hdrlen > 64) 10818 + return false; 10819 + nexthdr = &hp->nexthdr; 10820 + start += hdrlen; 10821 + hdr_count++; 10822 + } 10823 + if (nextp) { 10824 + /* Caller will check inner protocol */ 10825 + if (skb->encapsulation) { 10826 + *nextp = nexthdr; 10827 + return true; 10828 + } 10829 + *nextp = NULL; 10830 + } 10831 + /* Only support TCP/UDP for non-tunneled ipv6 and inner ipv6 */ 10832 + return *nexthdr == IPPROTO_TCP || *nexthdr == IPPROTO_UDP; 10833 + } 10834 + 10835 + /* For UDP, we can only handle 1 Vxlan port and 1 Geneve port. */ 10836 + static bool bnxt_udp_tunl_check(struct bnxt *bp, struct sk_buff *skb) 10837 + { 10838 + struct udphdr *uh = udp_hdr(skb); 10839 + __be16 udp_port = uh->dest; 10840 + 10841 + if (udp_port != bp->vxlan_port && udp_port != bp->nge_port) 10842 + return false; 10843 + if (skb->inner_protocol_type == ENCAP_TYPE_ETHER) { 10844 + struct ethhdr *eh = inner_eth_hdr(skb); 10845 + 10846 + switch (eh->h_proto) { 10847 + case htons(ETH_P_IP): 10848 + return true; 10849 + case htons(ETH_P_IPV6): 10850 + return bnxt_exthdr_check(bp, skb, 10851 + skb_inner_network_offset(skb), 10852 + NULL); 10853 + } 10854 + } 10855 + return false; 10856 + } 10857 + 10858 + static bool bnxt_tunl_check(struct bnxt *bp, struct sk_buff *skb, u8 l4_proto) 10859 + { 10860 + switch (l4_proto) { 10861 + case IPPROTO_UDP: 10862 + return bnxt_udp_tunl_check(bp, skb); 10863 + case IPPROTO_IPIP: 10864 + return true; 10865 + case IPPROTO_GRE: { 10866 + switch (skb->inner_protocol) { 10867 + default: 10868 + return false; 10869 + case htons(ETH_P_IP): 10870 + return true; 10871 + case htons(ETH_P_IPV6): 10872 + fallthrough; 10873 + } 10874 + } 10875 + case IPPROTO_IPV6: 10876 + /* Check ext headers of inner ipv6 */ 10877 + return bnxt_exthdr_check(bp, skb, skb_inner_network_offset(skb), 10878 + NULL); 10879 + } 10880 + return false; 10881 + } 10882 + 10782 10883 static netdev_features_t bnxt_features_check(struct sk_buff *skb, 10783 10884 struct net_device *dev, 10784 10885 netdev_features_t features) 10785 10886 { 10786 - struct bnxt *bp; 10787 - __be16 udp_port; 10788 - u8 l4_proto = 0; 10887 + struct bnxt *bp = netdev_priv(dev); 10888 + u8 *l4_proto; 10789 10889 10790 10890 features = vlan_features_check(skb, features); 10791 - if (!skb->encapsulation) 10792 - return features; 10793 - 10794 10891 switch (vlan_get_protocol(skb)) { 10795 10892 case htons(ETH_P_IP): 10796 - l4_proto = ip_hdr(skb)->protocol; 10893 + if (!skb->encapsulation) 10894 + return features; 10895 + l4_proto = &ip_hdr(skb)->protocol; 10896 + if (bnxt_tunl_check(bp, skb, *l4_proto)) 10897 + return features; 10797 10898 break; 10798 10899 case htons(ETH_P_IPV6): 10799 - l4_proto = ipv6_hdr(skb)->nexthdr; 10900 + if (!bnxt_exthdr_check(bp, skb, skb_network_offset(skb), 10901 + &l4_proto)) 10902 + break; 10903 + if (!l4_proto || bnxt_tunl_check(bp, skb, *l4_proto)) 10904 + return features; 10800 10905 break; 10801 - default: 10802 - return features; 10803 10906 } 10804 - 10805 - if (l4_proto != IPPROTO_UDP) 10806 - return features; 10807 - 10808 - bp = netdev_priv(dev); 10809 - /* For UDP, we can only handle 1 Vxlan port and 1 Geneve port. */ 10810 - udp_port = udp_hdr(skb)->dest; 10811 - if (udp_port == bp->vxlan_port || udp_port == bp->nge_port) 10812 - return features; 10813 10907 return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); 10814 10908 } 10815 10909
+10
drivers/net/ethernet/broadcom/bnxt/bnxt.h
··· 1457 1457 1458 1458 #define BNXT_BACKING_STORE_CFG_LEGACY_LEN 256 1459 1459 1460 + #define BNXT_SET_CTX_PAGE_ATTR(attr) \ 1461 + do { \ 1462 + if (BNXT_PAGE_SIZE == 0x2000) \ 1463 + attr = FUNC_BACKING_STORE_CFG_REQ_SRQ_PG_SIZE_PG_8K; \ 1464 + else if (BNXT_PAGE_SIZE == 0x10000) \ 1465 + attr = FUNC_BACKING_STORE_CFG_REQ_QPC_PG_SIZE_PG_64K; \ 1466 + else \ 1467 + attr = FUNC_BACKING_STORE_CFG_REQ_QPC_PG_SIZE_PG_4K; \ 1468 + } while (0) 1469 + 1460 1470 struct bnxt_ctx_mem_info { 1461 1471 u32 qp_max_entries; 1462 1472 u16 qp_min_qp1_entries;
+3
drivers/net/ethernet/cadence/macb_main.c
··· 2867 2867 struct gem_stats *hwstat = &bp->hw_stats.gem; 2868 2868 struct net_device_stats *nstat = &bp->dev->stats; 2869 2869 2870 + if (!netif_running(bp->dev)) 2871 + return nstat; 2872 + 2870 2873 gem_update_stats(bp); 2871 2874 2872 2875 nstat->rx_errors = (hwstat->rx_frame_check_sequence_errors +
+1 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
··· 1042 1042 cxgb4_del_filter(dev, f->tid, &f->fs); 1043 1043 } 1044 1044 1045 - sb = t4_read_reg(adapter, LE_DB_SRVR_START_INDEX_A); 1045 + sb = adapter->tids.stid_base; 1046 1046 for (i = 0; i < sb; i++) { 1047 1047 f = (struct filter_entry *)adapter->tids.tid_tab[i]; 1048 1048
+1 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
··· 6480 6480 6481 6481 adap->uld[CXGB4_ULD_KTLS].tlsdev_ops->tls_dev_del(netdev, tls_ctx, 6482 6482 direction); 6483 - cxgb4_set_ktls_feature(adap, FW_PARAMS_PARAM_DEV_KTLS_HW_DISABLE); 6484 6483 6485 6484 out_unlock: 6485 + cxgb4_set_ktls_feature(adap, FW_PARAMS_PARAM_DEV_KTLS_HW_DISABLE); 6486 6486 mutex_unlock(&uld_mutex); 6487 6487 } 6488 6488
+79 -1
drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
··· 59 59 } 60 60 61 61 static int chcr_init_tcb_fields(struct chcr_ktls_info *tx_info); 62 + static void clear_conn_resources(struct chcr_ktls_info *tx_info); 62 63 /* 63 64 * chcr_ktls_save_keys: calculate and save crypto keys. 64 65 * @tx_info - driver specific tls info. ··· 365 364 chcr_get_ktls_tx_context(tls_ctx); 366 365 struct chcr_ktls_info *tx_info = tx_ctx->chcr_info; 367 366 struct ch_ktls_port_stats_debug *port_stats; 367 + struct chcr_ktls_uld_ctx *u_ctx; 368 368 369 369 if (!tx_info) 370 370 return; 371 371 372 + u_ctx = tx_info->adap->uld[CXGB4_ULD_KTLS].handle; 373 + if (u_ctx && u_ctx->detach) 374 + return; 372 375 /* clear l2t entry */ 373 376 if (tx_info->l2te) 374 377 cxgb4_l2t_release(tx_info->l2te); ··· 389 384 if (tx_info->tid != -1) { 390 385 cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan, 391 386 tx_info->tid, tx_info->ip_family); 387 + 388 + xa_erase(&u_ctx->tid_list, tx_info->tid); 392 389 } 393 390 394 391 port_stats = &tx_info->adap->ch_ktls_stats.ktls_port[tx_info->port_id]; ··· 418 411 struct tls_context *tls_ctx = tls_get_ctx(sk); 419 412 struct ch_ktls_port_stats_debug *port_stats; 420 413 struct chcr_ktls_ofld_ctx_tx *tx_ctx; 414 + struct chcr_ktls_uld_ctx *u_ctx; 421 415 struct chcr_ktls_info *tx_info; 422 416 struct dst_entry *dst; 423 417 struct adapter *adap; ··· 433 425 adap = pi->adapter; 434 426 port_stats = &adap->ch_ktls_stats.ktls_port[pi->port_id]; 435 427 atomic64_inc(&port_stats->ktls_tx_connection_open); 428 + u_ctx = adap->uld[CXGB4_ULD_KTLS].handle; 436 429 437 430 if (direction == TLS_OFFLOAD_CTX_DIR_RX) { 438 431 pr_err("not expecting for RX direction\n"); ··· 441 432 } 442 433 443 434 if (tx_ctx->chcr_info) 435 + goto out; 436 + 437 + if (u_ctx && u_ctx->detach) 444 438 goto out; 445 439 446 440 tx_info = kvzalloc(sizeof(*tx_info), GFP_KERNEL); ··· 581 569 cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan, 582 570 tx_info->tid, tx_info->ip_family); 583 571 572 + xa_erase(&u_ctx->tid_list, tx_info->tid); 573 + 584 574 put_module: 585 575 /* release module refcount */ 586 576 module_put(THIS_MODULE); ··· 647 633 { 648 634 const struct cpl_act_open_rpl *p = (void *)input; 649 635 struct chcr_ktls_info *tx_info = NULL; 636 + struct chcr_ktls_ofld_ctx_tx *tx_ctx; 637 + struct chcr_ktls_uld_ctx *u_ctx; 650 638 unsigned int atid, tid, status; 639 + struct tls_context *tls_ctx; 651 640 struct tid_info *t; 641 + int ret = 0; 652 642 653 643 tid = GET_TID(p); 654 644 status = AOPEN_STATUS_G(ntohl(p->atid_status)); ··· 684 666 if (!status) { 685 667 tx_info->tid = tid; 686 668 cxgb4_insert_tid(t, tx_info, tx_info->tid, tx_info->ip_family); 669 + /* Adding tid */ 670 + tls_ctx = tls_get_ctx(tx_info->sk); 671 + tx_ctx = chcr_get_ktls_tx_context(tls_ctx); 672 + u_ctx = adap->uld[CXGB4_ULD_KTLS].handle; 673 + if (u_ctx) { 674 + ret = xa_insert_bh(&u_ctx->tid_list, tid, tx_ctx, 675 + GFP_NOWAIT); 676 + if (ret < 0) { 677 + pr_err("%s: Failed to allocate tid XA entry = %d\n", 678 + __func__, tx_info->tid); 679 + tx_info->open_state = CH_KTLS_OPEN_FAILURE; 680 + goto out; 681 + } 682 + } 687 683 tx_info->open_state = CH_KTLS_OPEN_SUCCESS; 688 684 } else { 689 685 tx_info->open_state = CH_KTLS_OPEN_FAILURE; 690 686 } 687 + out: 691 688 spin_unlock(&tx_info->lock); 692 689 693 690 complete(&tx_info->completion); 694 - return 0; 691 + return ret; 695 692 } 696 693 697 694 /* ··· 2123 2090 goto out; 2124 2091 } 2125 2092 u_ctx->lldi = *lldi; 2093 + u_ctx->detach = false; 2094 + xa_init_flags(&u_ctx->tid_list, XA_FLAGS_LOCK_BH); 2126 2095 out: 2127 2096 return u_ctx; 2128 2097 } ··· 2158 2123 return 0; 2159 2124 } 2160 2125 2126 + static void clear_conn_resources(struct chcr_ktls_info *tx_info) 2127 + { 2128 + /* clear l2t entry */ 2129 + if (tx_info->l2te) 2130 + cxgb4_l2t_release(tx_info->l2te); 2131 + 2132 + #if IS_ENABLED(CONFIG_IPV6) 2133 + /* clear clip entry */ 2134 + if (tx_info->ip_family == AF_INET6) 2135 + cxgb4_clip_release(tx_info->netdev, (const u32 *) 2136 + &tx_info->sk->sk_v6_rcv_saddr, 2137 + 1); 2138 + #endif 2139 + 2140 + /* clear tid */ 2141 + if (tx_info->tid != -1) 2142 + cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan, 2143 + tx_info->tid, tx_info->ip_family); 2144 + } 2145 + 2146 + static void ch_ktls_reset_all_conn(struct chcr_ktls_uld_ctx *u_ctx) 2147 + { 2148 + struct ch_ktls_port_stats_debug *port_stats; 2149 + struct chcr_ktls_ofld_ctx_tx *tx_ctx; 2150 + struct chcr_ktls_info *tx_info; 2151 + unsigned long index; 2152 + 2153 + xa_for_each(&u_ctx->tid_list, index, tx_ctx) { 2154 + tx_info = tx_ctx->chcr_info; 2155 + clear_conn_resources(tx_info); 2156 + port_stats = &tx_info->adap->ch_ktls_stats.ktls_port[tx_info->port_id]; 2157 + atomic64_inc(&port_stats->ktls_tx_connection_close); 2158 + kvfree(tx_info); 2159 + tx_ctx->chcr_info = NULL; 2160 + /* release module refcount */ 2161 + module_put(THIS_MODULE); 2162 + } 2163 + } 2164 + 2161 2165 static int chcr_ktls_uld_state_change(void *handle, enum cxgb4_state new_state) 2162 2166 { 2163 2167 struct chcr_ktls_uld_ctx *u_ctx = handle; ··· 2213 2139 case CXGB4_STATE_DETACH: 2214 2140 pr_info("%s: Down\n", pci_name(u_ctx->lldi.pdev)); 2215 2141 mutex_lock(&dev_mutex); 2142 + u_ctx->detach = true; 2216 2143 list_del(&u_ctx->entry); 2144 + ch_ktls_reset_all_conn(u_ctx); 2145 + xa_destroy(&u_ctx->tid_list); 2217 2146 mutex_unlock(&dev_mutex); 2218 2147 break; 2219 2148 default: ··· 2255 2178 adap = pci_get_drvdata(u_ctx->lldi.pdev); 2256 2179 memset(&adap->ch_ktls_stats, 0, sizeof(adap->ch_ktls_stats)); 2257 2180 list_del(&u_ctx->entry); 2181 + xa_destroy(&u_ctx->tid_list); 2258 2182 kfree(u_ctx); 2259 2183 } 2260 2184 mutex_unlock(&dev_mutex);
+2
drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.h
··· 75 75 struct chcr_ktls_uld_ctx { 76 76 struct list_head entry; 77 77 struct cxgb4_lld_info lldi; 78 + struct xarray tid_list; 79 + bool detach; 78 80 }; 79 81 80 82 static inline struct chcr_ktls_ofld_ctx_tx *
+4 -2
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c
··· 1564 1564 cerr = put_cmsg(msg, SOL_TLS, TLS_GET_RECORD_TYPE, 1565 1565 sizeof(thdr->type), &thdr->type); 1566 1566 1567 - if (cerr && thdr->type != TLS_RECORD_TYPE_DATA) 1568 - return -EIO; 1567 + if (cerr && thdr->type != TLS_RECORD_TYPE_DATA) { 1568 + copied = -EIO; 1569 + break; 1570 + } 1569 1571 /* don't send tls header, skip copy */ 1570 1572 goto skip_copy; 1571 1573 }
+19 -5
drivers/net/ethernet/freescale/fec_main.c
··· 1662 1662 } 1663 1663 1664 1664 /* ------------------------------------------------------------------------- */ 1665 - static void fec_get_mac(struct net_device *ndev) 1665 + static int fec_get_mac(struct net_device *ndev) 1666 1666 { 1667 1667 struct fec_enet_private *fep = netdev_priv(ndev); 1668 1668 unsigned char *iap, tmpaddr[ETH_ALEN]; ··· 1685 1685 ret = of_get_mac_address(np, tmpaddr); 1686 1686 if (!ret) 1687 1687 iap = tmpaddr; 1688 + else if (ret == -EPROBE_DEFER) 1689 + return ret; 1688 1690 } 1689 1691 } 1690 1692 ··· 1725 1723 eth_hw_addr_random(ndev); 1726 1724 dev_info(&fep->pdev->dev, "Using random MAC address: %pM\n", 1727 1725 ndev->dev_addr); 1728 - return; 1726 + return 0; 1729 1727 } 1730 1728 1731 1729 memcpy(ndev->dev_addr, iap, ETH_ALEN); ··· 1733 1731 /* Adjust MAC if using macaddr */ 1734 1732 if (iap == macaddr) 1735 1733 ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->dev_id; 1734 + 1735 + return 0; 1736 1736 } 1737 1737 1738 1738 /* ------------------------------------------------------------------------- */ ··· 3294 3290 return ret; 3295 3291 } 3296 3292 3297 - fec_enet_alloc_queue(ndev); 3293 + ret = fec_enet_alloc_queue(ndev); 3294 + if (ret) 3295 + return ret; 3298 3296 3299 3297 bd_size = (fep->total_tx_ring_size + fep->total_rx_ring_size) * dsize; 3300 3298 ··· 3304 3298 cbd_base = dmam_alloc_coherent(&fep->pdev->dev, bd_size, &bd_dma, 3305 3299 GFP_KERNEL); 3306 3300 if (!cbd_base) { 3307 - return -ENOMEM; 3301 + ret = -ENOMEM; 3302 + goto free_queue_mem; 3308 3303 } 3309 3304 3310 3305 /* Get the Ethernet address */ 3311 - fec_get_mac(ndev); 3306 + ret = fec_get_mac(ndev); 3307 + if (ret) 3308 + goto free_queue_mem; 3309 + 3312 3310 /* make sure MAC we just acquired is programmed into the hw */ 3313 3311 fec_set_mac_address(ndev, NULL); 3314 3312 ··· 3386 3376 fec_enet_update_ethtool_stats(ndev); 3387 3377 3388 3378 return 0; 3379 + 3380 + free_queue_mem: 3381 + fec_enet_free_queue(ndev); 3382 + return ret; 3389 3383 } 3390 3384 3391 3385 #ifdef CONFIG_OF
+12 -9
drivers/net/ethernet/google/gve/gve_main.c
··· 180 180 /* Double check we have no extra work. 181 181 * Ensure unmask synchronizes with checking for work. 182 182 */ 183 - dma_rmb(); 183 + mb(); 184 184 if (block->tx) 185 185 reschedule |= gve_tx_poll(block, -1); 186 186 if (block->rx) ··· 220 220 int vecs_left = new_num_ntfy_blks % 2; 221 221 222 222 priv->num_ntfy_blks = new_num_ntfy_blks; 223 + priv->mgmt_msix_idx = priv->num_ntfy_blks; 223 224 priv->tx_cfg.max_queues = min_t(int, priv->tx_cfg.max_queues, 224 225 vecs_per_type); 225 226 priv->rx_cfg.max_queues = min_t(int, priv->rx_cfg.max_queues, ··· 301 300 { 302 301 int i; 303 302 304 - /* Free the irqs */ 305 - for (i = 0; i < priv->num_ntfy_blks; i++) { 306 - struct gve_notify_block *block = &priv->ntfy_blocks[i]; 307 - int msix_idx = i; 303 + if (priv->msix_vectors) { 304 + /* Free the irqs */ 305 + for (i = 0; i < priv->num_ntfy_blks; i++) { 306 + struct gve_notify_block *block = &priv->ntfy_blocks[i]; 307 + int msix_idx = i; 308 308 309 - irq_set_affinity_hint(priv->msix_vectors[msix_idx].vector, 310 - NULL); 311 - free_irq(priv->msix_vectors[msix_idx].vector, block); 309 + irq_set_affinity_hint(priv->msix_vectors[msix_idx].vector, 310 + NULL); 311 + free_irq(priv->msix_vectors[msix_idx].vector, block); 312 + } 313 + free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv); 312 314 } 313 315 dma_free_coherent(&priv->pdev->dev, 314 316 priv->num_ntfy_blks * sizeof(*priv->ntfy_blocks), 315 317 priv->ntfy_blocks, priv->ntfy_block_bus); 316 318 priv->ntfy_blocks = NULL; 317 - free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv); 318 319 pci_disable_msix(priv->pdev); 319 320 kvfree(priv->msix_vectors); 320 321 priv->msix_vectors = NULL;
+7 -3
drivers/net/ethernet/google/gve/gve_tx.c
··· 212 212 tx->dev = &priv->pdev->dev; 213 213 if (!tx->raw_addressing) { 214 214 tx->tx_fifo.qpl = gve_assign_tx_qpl(priv); 215 - 215 + if (!tx->tx_fifo.qpl) 216 + goto abort_with_desc; 216 217 /* map Tx FIFO */ 217 218 if (gve_tx_fifo_init(priv, &tx->tx_fifo)) 218 - goto abort_with_desc; 219 + goto abort_with_qpl; 219 220 } 220 221 221 222 tx->q_resources = ··· 237 236 abort_with_fifo: 238 237 if (!tx->raw_addressing) 239 238 gve_tx_fifo_release(priv, &tx->tx_fifo); 239 + abort_with_qpl: 240 + if (!tx->raw_addressing) 241 + gve_unassign_qpl(priv, tx->tx_fifo.qpl->id); 240 242 abort_with_desc: 241 243 dma_free_coherent(hdev, bytes, tx->desc, tx->bus); 242 244 tx->desc = NULL; ··· 593 589 struct gve_tx_ring *tx; 594 590 int nsegs; 595 591 596 - WARN(skb_get_queue_mapping(skb) > priv->tx_cfg.num_queues, 592 + WARN(skb_get_queue_mapping(skb) >= priv->tx_cfg.num_queues, 597 593 "skb queue index out of range"); 598 594 tx = &priv->tx[skb_get_queue_mapping(skb)]; 599 595 if (unlikely(gve_maybe_stop_tx(tx, skb))) {
+3 -3
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
··· 192 192 } 193 193 194 194 /** 195 - *hns_nic_set_link_settings - implement ethtool set link ksettings 195 + *hns_nic_set_link_ksettings - implement ethtool set link ksettings 196 196 *@net_dev: net_device 197 197 *@cmd: ethtool_link_ksettings 198 198 *retuen 0 - success , negative --fail ··· 827 827 } 828 828 829 829 /** 830 - * get_ethtool_stats - get detail statistics. 830 + * hns_get_ethtool_stats - get detail statistics. 831 831 * @netdev: net device 832 832 * @stats: statistics info. 833 833 * @data: statistics data. ··· 885 885 } 886 886 887 887 /** 888 - * get_strings: Return a set of strings that describe the requested objects 888 + * hns_get_strings: Return a set of strings that describe the requested objects 889 889 * @netdev: net device 890 890 * @stringset: string set ID. 891 891 * @data: objects data.
+51 -59
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
··· 264 264 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev); 265 265 struct hns3_enet_coalesce *tx_coal = &tqp_vector->tx_group.coal; 266 266 struct hns3_enet_coalesce *rx_coal = &tqp_vector->rx_group.coal; 267 + struct hns3_enet_coalesce *ptx_coal = &priv->tx_coal; 268 + struct hns3_enet_coalesce *prx_coal = &priv->rx_coal; 267 269 268 - /* initialize the configuration for interrupt coalescing. 269 - * 1. GL (Interrupt Gap Limiter) 270 - * 2. RL (Interrupt Rate Limiter) 271 - * 3. QL (Interrupt Quantity Limiter) 272 - * 273 - * Default: enable interrupt coalescing self-adaptive and GL 274 - */ 275 - tx_coal->adapt_enable = 1; 276 - rx_coal->adapt_enable = 1; 270 + tx_coal->adapt_enable = ptx_coal->adapt_enable; 271 + rx_coal->adapt_enable = prx_coal->adapt_enable; 277 272 278 - tx_coal->int_gl = HNS3_INT_GL_50K; 279 - rx_coal->int_gl = HNS3_INT_GL_50K; 273 + tx_coal->int_gl = ptx_coal->int_gl; 274 + rx_coal->int_gl = prx_coal->int_gl; 280 275 281 - rx_coal->flow_level = HNS3_FLOW_LOW; 282 - tx_coal->flow_level = HNS3_FLOW_LOW; 276 + rx_coal->flow_level = prx_coal->flow_level; 277 + tx_coal->flow_level = ptx_coal->flow_level; 283 278 284 279 /* device version above V3(include V3), GL can configure 1us 285 280 * unit, so uses 1us unit. ··· 289 294 rx_coal->ql_enable = 1; 290 295 tx_coal->int_ql_max = ae_dev->dev_specs.int_ql_max; 291 296 rx_coal->int_ql_max = ae_dev->dev_specs.int_ql_max; 292 - tx_coal->int_ql = HNS3_INT_QL_DEFAULT_CFG; 293 - rx_coal->int_ql = HNS3_INT_QL_DEFAULT_CFG; 297 + tx_coal->int_ql = ptx_coal->int_ql; 298 + rx_coal->int_ql = prx_coal->int_ql; 294 299 } 295 300 } 296 301 ··· 841 846 l4.udp->dest == htons(4790)))) 842 847 return false; 843 848 844 - skb_checksum_help(skb); 845 - 846 849 return true; 847 850 } 848 851 ··· 917 924 /* the stack computes the IP header already, 918 925 * driver calculate l4 checksum when not TSO. 919 926 */ 920 - skb_checksum_help(skb); 921 - return 0; 927 + return skb_checksum_help(skb); 922 928 } 923 929 924 930 hns3_set_outer_l2l3l4(skb, ol4_proto, ol_type_vlan_len_msec); ··· 962 970 break; 963 971 case IPPROTO_UDP: 964 972 if (hns3_tunnel_csum_bug(skb)) 965 - break; 973 + return skb_checksum_help(skb); 966 974 967 975 hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L4CS_B, 1); 968 976 hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L4T_S, ··· 987 995 /* the stack computes the IP header already, 988 996 * driver calculate l4 checksum when not TSO. 989 997 */ 990 - skb_checksum_help(skb); 991 - return 0; 998 + return skb_checksum_help(skb); 992 999 } 993 1000 994 1001 return 0; ··· 3835 3844 return ret; 3836 3845 } 3837 3846 3847 + static void hns3_nic_init_coal_cfg(struct hns3_nic_priv *priv) 3848 + { 3849 + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev); 3850 + struct hns3_enet_coalesce *tx_coal = &priv->tx_coal; 3851 + struct hns3_enet_coalesce *rx_coal = &priv->rx_coal; 3852 + 3853 + /* initialize the configuration for interrupt coalescing. 3854 + * 1. GL (Interrupt Gap Limiter) 3855 + * 2. RL (Interrupt Rate Limiter) 3856 + * 3. QL (Interrupt Quantity Limiter) 3857 + * 3858 + * Default: enable interrupt coalescing self-adaptive and GL 3859 + */ 3860 + tx_coal->adapt_enable = 1; 3861 + rx_coal->adapt_enable = 1; 3862 + 3863 + tx_coal->int_gl = HNS3_INT_GL_50K; 3864 + rx_coal->int_gl = HNS3_INT_GL_50K; 3865 + 3866 + rx_coal->flow_level = HNS3_FLOW_LOW; 3867 + tx_coal->flow_level = HNS3_FLOW_LOW; 3868 + 3869 + if (ae_dev->dev_specs.int_ql_max) { 3870 + tx_coal->int_ql = HNS3_INT_QL_DEFAULT_CFG; 3871 + rx_coal->int_ql = HNS3_INT_QL_DEFAULT_CFG; 3872 + } 3873 + } 3874 + 3838 3875 static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv) 3839 3876 { 3840 3877 struct hnae3_handle *h = priv->ae_handle; ··· 4314 4295 goto out_get_ring_cfg; 4315 4296 } 4316 4297 4298 + hns3_nic_init_coal_cfg(priv); 4299 + 4317 4300 ret = hns3_nic_alloc_vector_data(priv); 4318 4301 if (ret) { 4319 4302 ret = -ENOMEM; ··· 4337 4316 ret = hns3_init_phy(netdev); 4338 4317 if (ret) 4339 4318 goto out_init_phy; 4340 - 4341 - ret = register_netdev(netdev); 4342 - if (ret) { 4343 - dev_err(priv->dev, "probe register netdev fail!\n"); 4344 - goto out_reg_netdev_fail; 4345 - } 4346 4319 4347 4320 /* the device can work without cpu rmap, only aRFS needs it */ 4348 4321 ret = hns3_set_rx_cpu_rmap(netdev); ··· 4370 4355 if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) 4371 4356 set_bit(HNAE3_PFLAG_LIMIT_PROMISC, &handle->supported_pflags); 4372 4357 4358 + ret = register_netdev(netdev); 4359 + if (ret) { 4360 + dev_err(priv->dev, "probe register netdev fail!\n"); 4361 + goto out_reg_netdev_fail; 4362 + } 4363 + 4373 4364 if (netif_msg_drv(handle)) 4374 4365 hns3_info_show(priv); 4375 4366 4376 4367 return ret; 4377 4368 4369 + out_reg_netdev_fail: 4370 + hns3_dbg_uninit(handle); 4378 4371 out_client_start: 4379 4372 hns3_free_rx_cpu_rmap(netdev); 4380 4373 hns3_nic_uninit_irq(priv); 4381 4374 out_init_irq_fail: 4382 - unregister_netdev(netdev); 4383 - out_reg_netdev_fail: 4384 4375 hns3_uninit_phy(netdev); 4385 4376 out_init_phy: 4386 4377 hns3_uninit_all_ring(priv); ··· 4592 4571 return 0; 4593 4572 } 4594 4573 4595 - static void hns3_store_coal(struct hns3_nic_priv *priv) 4596 - { 4597 - /* ethtool only support setting and querying one coal 4598 - * configuration for now, so save the vector 0' coal 4599 - * configuration here in order to restore it. 4600 - */ 4601 - memcpy(&priv->tx_coal, &priv->tqp_vector[0].tx_group.coal, 4602 - sizeof(struct hns3_enet_coalesce)); 4603 - memcpy(&priv->rx_coal, &priv->tqp_vector[0].rx_group.coal, 4604 - sizeof(struct hns3_enet_coalesce)); 4605 - } 4606 - 4607 - static void hns3_restore_coal(struct hns3_nic_priv *priv) 4608 - { 4609 - u16 vector_num = priv->vector_num; 4610 - int i; 4611 - 4612 - for (i = 0; i < vector_num; i++) { 4613 - memcpy(&priv->tqp_vector[i].tx_group.coal, &priv->tx_coal, 4614 - sizeof(struct hns3_enet_coalesce)); 4615 - memcpy(&priv->tqp_vector[i].rx_group.coal, &priv->rx_coal, 4616 - sizeof(struct hns3_enet_coalesce)); 4617 - } 4618 - } 4619 - 4620 4574 static int hns3_reset_notify_down_enet(struct hnae3_handle *handle) 4621 4575 { 4622 4576 struct hnae3_knic_private_info *kinfo = &handle->kinfo; ··· 4649 4653 ret = hns3_nic_alloc_vector_data(priv); 4650 4654 if (ret) 4651 4655 goto err_put_ring; 4652 - 4653 - hns3_restore_coal(priv); 4654 4656 4655 4657 ret = hns3_nic_init_vector_data(priv); 4656 4658 if (ret) ··· 4714 4720 hns3_reset_tx_queue(priv->ae_handle); 4715 4721 4716 4722 hns3_nic_uninit_vector_data(priv); 4717 - 4718 - hns3_store_coal(priv); 4719 4723 4720 4724 hns3_nic_dealloc_vector_data(priv); 4721 4725
+23 -41
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
··· 1134 1134 h->ae_algo->ops->get_channels(h, ch); 1135 1135 } 1136 1136 1137 - static int hns3_get_coalesce_per_queue(struct net_device *netdev, u32 queue, 1138 - struct ethtool_coalesce *cmd) 1137 + static int hns3_get_coalesce(struct net_device *netdev, 1138 + struct ethtool_coalesce *cmd) 1139 1139 { 1140 - struct hns3_enet_tqp_vector *tx_vector, *rx_vector; 1141 1140 struct hns3_nic_priv *priv = netdev_priv(netdev); 1141 + struct hns3_enet_coalesce *tx_coal = &priv->tx_coal; 1142 + struct hns3_enet_coalesce *rx_coal = &priv->rx_coal; 1142 1143 struct hnae3_handle *h = priv->ae_handle; 1143 - u16 queue_num = h->kinfo.num_tqps; 1144 1144 1145 1145 if (hns3_nic_resetting(netdev)) 1146 1146 return -EBUSY; 1147 1147 1148 - if (queue >= queue_num) { 1149 - netdev_err(netdev, 1150 - "Invalid queue value %u! Queue max id=%u\n", 1151 - queue, queue_num - 1); 1152 - return -EINVAL; 1153 - } 1148 + cmd->use_adaptive_tx_coalesce = tx_coal->adapt_enable; 1149 + cmd->use_adaptive_rx_coalesce = rx_coal->adapt_enable; 1154 1150 1155 - tx_vector = priv->ring[queue].tqp_vector; 1156 - rx_vector = priv->ring[queue_num + queue].tqp_vector; 1157 - 1158 - cmd->use_adaptive_tx_coalesce = 1159 - tx_vector->tx_group.coal.adapt_enable; 1160 - cmd->use_adaptive_rx_coalesce = 1161 - rx_vector->rx_group.coal.adapt_enable; 1162 - 1163 - cmd->tx_coalesce_usecs = tx_vector->tx_group.coal.int_gl; 1164 - cmd->rx_coalesce_usecs = rx_vector->rx_group.coal.int_gl; 1151 + cmd->tx_coalesce_usecs = tx_coal->int_gl; 1152 + cmd->rx_coalesce_usecs = rx_coal->int_gl; 1165 1153 1166 1154 cmd->tx_coalesce_usecs_high = h->kinfo.int_rl_setting; 1167 1155 cmd->rx_coalesce_usecs_high = h->kinfo.int_rl_setting; 1168 1156 1169 - cmd->tx_max_coalesced_frames = tx_vector->tx_group.coal.int_ql; 1170 - cmd->rx_max_coalesced_frames = rx_vector->rx_group.coal.int_ql; 1157 + cmd->tx_max_coalesced_frames = tx_coal->int_ql; 1158 + cmd->rx_max_coalesced_frames = rx_coal->int_ql; 1171 1159 1172 1160 return 0; 1173 - } 1174 - 1175 - static int hns3_get_coalesce(struct net_device *netdev, 1176 - struct ethtool_coalesce *cmd) 1177 - { 1178 - return hns3_get_coalesce_per_queue(netdev, 0, cmd); 1179 1161 } 1180 1162 1181 1163 static int hns3_check_gl_coalesce_para(struct net_device *netdev, ··· 1274 1292 return ret; 1275 1293 } 1276 1294 1277 - ret = hns3_check_ql_coalesce_param(netdev, cmd); 1278 - if (ret) 1279 - return ret; 1280 - 1281 - if (cmd->use_adaptive_tx_coalesce == 1 || 1282 - cmd->use_adaptive_rx_coalesce == 1) { 1283 - netdev_info(netdev, 1284 - "adaptive-tx=%u and adaptive-rx=%u, tx_usecs or rx_usecs will changed dynamically.\n", 1285 - cmd->use_adaptive_tx_coalesce, 1286 - cmd->use_adaptive_rx_coalesce); 1287 - } 1288 - 1289 - return 0; 1295 + return hns3_check_ql_coalesce_param(netdev, cmd); 1290 1296 } 1291 1297 1292 1298 static void hns3_set_coalesce_per_queue(struct net_device *netdev, ··· 1320 1350 struct ethtool_coalesce *cmd) 1321 1351 { 1322 1352 struct hnae3_handle *h = hns3_get_handle(netdev); 1353 + struct hns3_nic_priv *priv = netdev_priv(netdev); 1354 + struct hns3_enet_coalesce *tx_coal = &priv->tx_coal; 1355 + struct hns3_enet_coalesce *rx_coal = &priv->rx_coal; 1323 1356 u16 queue_num = h->kinfo.num_tqps; 1324 1357 int ret; 1325 1358 int i; ··· 1336 1363 1337 1364 h->kinfo.int_rl_setting = 1338 1365 hns3_rl_round_down(cmd->rx_coalesce_usecs_high); 1366 + 1367 + tx_coal->adapt_enable = cmd->use_adaptive_tx_coalesce; 1368 + rx_coal->adapt_enable = cmd->use_adaptive_rx_coalesce; 1369 + 1370 + tx_coal->int_gl = cmd->tx_coalesce_usecs; 1371 + rx_coal->int_gl = cmd->rx_coalesce_usecs; 1372 + 1373 + tx_coal->int_ql = cmd->tx_max_coalesced_frames; 1374 + rx_coal->int_ql = cmd->rx_max_coalesced_frames; 1339 1375 1340 1376 for (i = 0; i < queue_num; i++) 1341 1377 hns3_set_coalesce_per_queue(netdev, cmd, i);
+3 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
··· 710 710 unsigned int flag; 711 711 int ret = 0; 712 712 713 - memset(&resp_msg, 0, sizeof(resp_msg)); 714 713 /* handle all the mailbox requests in the queue */ 715 714 while (!hclge_cmd_crq_empty(&hdev->hw)) { 716 715 if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state)) { ··· 736 737 vport = &hdev->vport[req->mbx_src_vfid]; 737 738 738 739 trace_hclge_pf_mbx_get(hdev, req); 740 + 741 + /* clear the resp_msg before processing every mailbox message */ 742 + memset(&resp_msg, 0, sizeof(resp_msg)); 739 743 740 744 switch (req->msg.code) { 741 745 case HCLGE_MBX_MAP_RING_TO_VECTOR:
+7 -9
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
··· 467 467 return err; 468 468 } 469 469 470 - static s32 ixgbe_set_vf_lpe(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf) 470 + static int ixgbe_set_vf_lpe(struct ixgbe_adapter *adapter, u32 max_frame, u32 vf) 471 471 { 472 472 struct ixgbe_hw *hw = &adapter->hw; 473 - int max_frame = msgbuf[1]; 474 473 u32 max_frs; 474 + 475 + if (max_frame < ETH_MIN_MTU || max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE) { 476 + e_err(drv, "VF max_frame %d out of range\n", max_frame); 477 + return -EINVAL; 478 + } 475 479 476 480 /* 477 481 * For 82599EB we have to keep all PFs and VFs operating with ··· 535 531 e_err(drv, "VF max_frame %d out of range\n", max_frame); 536 532 return err; 537 533 } 538 - } 539 - 540 - /* MTU < 68 is an error and causes problems on some kernels */ 541 - if (max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE) { 542 - e_err(drv, "VF max_frame %d out of range\n", max_frame); 543 - return -EINVAL; 544 534 } 545 535 546 536 /* pull current max frame size from hardware */ ··· 1247 1249 retval = ixgbe_set_vf_vlan_msg(adapter, msgbuf, vf); 1248 1250 break; 1249 1251 case IXGBE_VF_SET_LPE: 1250 - retval = ixgbe_set_vf_lpe(adapter, msgbuf, vf); 1252 + retval = ixgbe_set_vf_lpe(adapter, msgbuf[1], vf); 1251 1253 break; 1252 1254 case IXGBE_VF_SET_MACVLAN: 1253 1255 retval = ixgbe_set_vf_macvlan_msg(adapter, msgbuf, vf);
+6 -6
drivers/net/ethernet/korina.c
··· 1315 1315 lp->tx_irq = platform_get_irq_byname(pdev, "tx"); 1316 1316 1317 1317 p = devm_platform_ioremap_resource_byname(pdev, "emac"); 1318 - if (!p) { 1318 + if (IS_ERR(p)) { 1319 1319 printk(KERN_ERR DRV_NAME ": cannot remap registers\n"); 1320 - return -ENOMEM; 1320 + return PTR_ERR(p); 1321 1321 } 1322 1322 lp->eth_regs = p; 1323 1323 1324 1324 p = devm_platform_ioremap_resource_byname(pdev, "dma_rx"); 1325 - if (!p) { 1325 + if (IS_ERR(p)) { 1326 1326 printk(KERN_ERR DRV_NAME ": cannot remap Rx DMA registers\n"); 1327 - return -ENOMEM; 1327 + return PTR_ERR(p); 1328 1328 } 1329 1329 lp->rx_dma_regs = p; 1330 1330 1331 1331 p = devm_platform_ioremap_resource_byname(pdev, "dma_tx"); 1332 - if (!p) { 1332 + if (IS_ERR(p)) { 1333 1333 printk(KERN_ERR DRV_NAME ": cannot remap Tx DMA registers\n"); 1334 - return -ENOMEM; 1334 + return PTR_ERR(p); 1335 1335 } 1336 1336 lp->tx_dma_regs = p; 1337 1337
+9 -5
drivers/net/ethernet/lantiq_xrx200.c
··· 154 154 155 155 static int xrx200_alloc_skb(struct xrx200_chan *ch) 156 156 { 157 + dma_addr_t mapping; 157 158 int ret = 0; 158 159 159 160 ch->skb[ch->dma.desc] = netdev_alloc_skb_ip_align(ch->priv->net_dev, ··· 164 163 goto skip; 165 164 } 166 165 167 - ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(ch->priv->dev, 168 - ch->skb[ch->dma.desc]->data, XRX200_DMA_DATA_LEN, 169 - DMA_FROM_DEVICE); 170 - if (unlikely(dma_mapping_error(ch->priv->dev, 171 - ch->dma.desc_base[ch->dma.desc].addr))) { 166 + mapping = dma_map_single(ch->priv->dev, ch->skb[ch->dma.desc]->data, 167 + XRX200_DMA_DATA_LEN, DMA_FROM_DEVICE); 168 + if (unlikely(dma_mapping_error(ch->priv->dev, mapping))) { 172 169 dev_kfree_skb_any(ch->skb[ch->dma.desc]); 173 170 ret = -ENOMEM; 174 171 goto skip; 175 172 } 176 173 174 + ch->dma.desc_base[ch->dma.desc].addr = mapping; 175 + /* Make sure the address is written before we give it to HW */ 176 + wmb(); 177 177 skip: 178 178 ch->dma.desc_base[ch->dma.desc].ctl = 179 179 LTQ_DMA_OWN | LTQ_DMA_RX_OFFSET(NET_IP_ALIGN) | ··· 198 196 ch->dma.desc %= LTQ_DESC_NUM; 199 197 200 198 if (ret) { 199 + ch->skb[ch->dma.desc] = skb; 200 + net_dev->stats.rx_dropped++; 201 201 netdev_err(net_dev, "failed to allocate new rx buffer\n"); 202 202 return ret; 203 203 }
+22
drivers/net/ethernet/marvell/mvpp2/mvpp2.h
··· 993 993 994 994 #define MVPP2_DESC_DMA_MASK DMA_BIT_MASK(40) 995 995 996 + /* Buffer header info bits */ 997 + #define MVPP2_B_HDR_INFO_MC_ID_MASK 0xfff 998 + #define MVPP2_B_HDR_INFO_MC_ID(info) ((info) & MVPP2_B_HDR_INFO_MC_ID_MASK) 999 + #define MVPP2_B_HDR_INFO_LAST_OFFS 12 1000 + #define MVPP2_B_HDR_INFO_LAST_MASK BIT(12) 1001 + #define MVPP2_B_HDR_INFO_IS_LAST(info) \ 1002 + (((info) & MVPP2_B_HDR_INFO_LAST_MASK) >> MVPP2_B_HDR_INFO_LAST_OFFS) 1003 + 996 1004 struct mvpp2_tai; 997 1005 998 1006 /* Definitions */ ··· 1008 1000 1009 1001 struct mvpp2_rss_table { 1010 1002 u32 indir[MVPP22_RSS_TABLE_ENTRIES]; 1003 + }; 1004 + 1005 + struct mvpp2_buff_hdr { 1006 + __le32 next_phys_addr; 1007 + __le32 next_dma_addr; 1008 + __le16 byte_count; 1009 + __le16 info; 1010 + __le16 reserved1; /* bm_qset (for future use, BM) */ 1011 + u8 next_phys_addr_high; 1012 + u8 next_dma_addr_high; 1013 + __le16 reserved2; 1014 + __le16 reserved3; 1015 + __le16 reserved4; 1016 + __le16 reserved5; 1011 1017 }; 1012 1018 1013 1019 /* Shared Packet Processor resources */
+45 -9
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
··· 3839 3839 return ret; 3840 3840 } 3841 3841 3842 + static void mvpp2_buff_hdr_pool_put(struct mvpp2_port *port, struct mvpp2_rx_desc *rx_desc, 3843 + int pool, u32 rx_status) 3844 + { 3845 + phys_addr_t phys_addr, phys_addr_next; 3846 + dma_addr_t dma_addr, dma_addr_next; 3847 + struct mvpp2_buff_hdr *buff_hdr; 3848 + 3849 + phys_addr = mvpp2_rxdesc_dma_addr_get(port, rx_desc); 3850 + dma_addr = mvpp2_rxdesc_cookie_get(port, rx_desc); 3851 + 3852 + do { 3853 + buff_hdr = (struct mvpp2_buff_hdr *)phys_to_virt(phys_addr); 3854 + 3855 + phys_addr_next = le32_to_cpu(buff_hdr->next_phys_addr); 3856 + dma_addr_next = le32_to_cpu(buff_hdr->next_dma_addr); 3857 + 3858 + if (port->priv->hw_version >= MVPP22) { 3859 + phys_addr_next |= ((u64)buff_hdr->next_phys_addr_high << 32); 3860 + dma_addr_next |= ((u64)buff_hdr->next_dma_addr_high << 32); 3861 + } 3862 + 3863 + mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr); 3864 + 3865 + phys_addr = phys_addr_next; 3866 + dma_addr = dma_addr_next; 3867 + 3868 + } while (!MVPP2_B_HDR_INFO_IS_LAST(le16_to_cpu(buff_hdr->info))); 3869 + } 3870 + 3842 3871 /* Main rx processing */ 3843 3872 static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi, 3844 3873 int rx_todo, struct mvpp2_rx_queue *rxq) ··· 3914 3885 MVPP2_RXD_BM_POOL_ID_OFFS; 3915 3886 bm_pool = &port->priv->bm_pools[pool]; 3916 3887 3917 - /* In case of an error, release the requested buffer pointer 3918 - * to the Buffer Manager. This request process is controlled 3919 - * by the hardware, and the information about the buffer is 3920 - * comprised by the RX descriptor. 3921 - */ 3922 - if (rx_status & MVPP2_RXD_ERR_SUMMARY) 3923 - goto err_drop_frame; 3924 - 3925 3888 if (port->priv->percpu_pools) { 3926 3889 pp = port->priv->page_pool[pool]; 3927 3890 dma_dir = page_pool_get_dma_dir(pp); ··· 3924 3903 dma_sync_single_for_cpu(dev->dev.parent, dma_addr, 3925 3904 rx_bytes + MVPP2_MH_SIZE, 3926 3905 dma_dir); 3906 + 3907 + /* Buffer header not supported */ 3908 + if (rx_status & MVPP2_RXD_BUF_HDR) 3909 + goto err_drop_frame; 3910 + 3911 + /* In case of an error, release the requested buffer pointer 3912 + * to the Buffer Manager. This request process is controlled 3913 + * by the hardware, and the information about the buffer is 3914 + * comprised by the RX descriptor. 3915 + */ 3916 + if (rx_status & MVPP2_RXD_ERR_SUMMARY) 3917 + goto err_drop_frame; 3927 3918 3928 3919 /* Prefetch header */ 3929 3920 prefetch(data); ··· 4018 3985 dev->stats.rx_errors++; 4019 3986 mvpp2_rx_error(port, rx_desc); 4020 3987 /* Return the buffer to the pool */ 4021 - mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr); 3988 + if (rx_status & MVPP2_RXD_BUF_HDR) 3989 + mvpp2_buff_hdr_pool_put(port, rx_desc, pool, rx_status); 3990 + else 3991 + mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr); 4022 3992 } 4023 3993 4024 3994 rcu_read_unlock();
+4
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
··· 786 786 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP) 787 787 return -EOPNOTSUPP; 788 788 789 + if (*rss_context != ETH_RXFH_CONTEXT_ALLOC && 790 + *rss_context >= MAX_RSS_GROUPS) 791 + return -EINVAL; 792 + 789 793 rss = &pfvf->hw.rss_info; 790 794 791 795 if (!rss->enable) {
+52 -25
drivers/net/ethernet/mediatek/mtk_eth_soc.c
··· 681 681 void mtk_stats_update_mac(struct mtk_mac *mac) 682 682 { 683 683 struct mtk_hw_stats *hw_stats = mac->hw_stats; 684 - unsigned int base = MTK_GDM1_TX_GBCNT; 685 - u64 stats; 686 - 687 - base += hw_stats->reg_offset; 684 + struct mtk_eth *eth = mac->hw; 688 685 689 686 u64_stats_update_begin(&hw_stats->syncp); 690 687 691 - hw_stats->rx_bytes += mtk_r32(mac->hw, base); 692 - stats = mtk_r32(mac->hw, base + 0x04); 693 - if (stats) 694 - hw_stats->rx_bytes += (stats << 32); 695 - hw_stats->rx_packets += mtk_r32(mac->hw, base + 0x08); 696 - hw_stats->rx_overflow += mtk_r32(mac->hw, base + 0x10); 697 - hw_stats->rx_fcs_errors += mtk_r32(mac->hw, base + 0x14); 698 - hw_stats->rx_short_errors += mtk_r32(mac->hw, base + 0x18); 699 - hw_stats->rx_long_errors += mtk_r32(mac->hw, base + 0x1c); 700 - hw_stats->rx_checksum_errors += mtk_r32(mac->hw, base + 0x20); 701 - hw_stats->rx_flow_control_packets += 702 - mtk_r32(mac->hw, base + 0x24); 703 - hw_stats->tx_skip += mtk_r32(mac->hw, base + 0x28); 704 - hw_stats->tx_collisions += mtk_r32(mac->hw, base + 0x2c); 705 - hw_stats->tx_bytes += mtk_r32(mac->hw, base + 0x30); 706 - stats = mtk_r32(mac->hw, base + 0x34); 707 - if (stats) 708 - hw_stats->tx_bytes += (stats << 32); 709 - hw_stats->tx_packets += mtk_r32(mac->hw, base + 0x38); 688 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) { 689 + hw_stats->tx_packets += mtk_r32(mac->hw, MT7628_SDM_TPCNT); 690 + hw_stats->tx_bytes += mtk_r32(mac->hw, MT7628_SDM_TBCNT); 691 + hw_stats->rx_packets += mtk_r32(mac->hw, MT7628_SDM_RPCNT); 692 + hw_stats->rx_bytes += mtk_r32(mac->hw, MT7628_SDM_RBCNT); 693 + hw_stats->rx_checksum_errors += 694 + mtk_r32(mac->hw, MT7628_SDM_CS_ERR); 695 + } else { 696 + unsigned int offs = hw_stats->reg_offset; 697 + u64 stats; 698 + 699 + hw_stats->rx_bytes += mtk_r32(mac->hw, 700 + MTK_GDM1_RX_GBCNT_L + offs); 701 + stats = mtk_r32(mac->hw, MTK_GDM1_RX_GBCNT_H + offs); 702 + if (stats) 703 + hw_stats->rx_bytes += (stats << 32); 704 + hw_stats->rx_packets += 705 + mtk_r32(mac->hw, MTK_GDM1_RX_GPCNT + offs); 706 + hw_stats->rx_overflow += 707 + mtk_r32(mac->hw, MTK_GDM1_RX_OERCNT + offs); 708 + hw_stats->rx_fcs_errors += 709 + mtk_r32(mac->hw, MTK_GDM1_RX_FERCNT + offs); 710 + hw_stats->rx_short_errors += 711 + mtk_r32(mac->hw, MTK_GDM1_RX_SERCNT + offs); 712 + hw_stats->rx_long_errors += 713 + mtk_r32(mac->hw, MTK_GDM1_RX_LENCNT + offs); 714 + hw_stats->rx_checksum_errors += 715 + mtk_r32(mac->hw, MTK_GDM1_RX_CERCNT + offs); 716 + hw_stats->rx_flow_control_packets += 717 + mtk_r32(mac->hw, MTK_GDM1_RX_FCCNT + offs); 718 + hw_stats->tx_skip += 719 + mtk_r32(mac->hw, MTK_GDM1_TX_SKIPCNT + offs); 720 + hw_stats->tx_collisions += 721 + mtk_r32(mac->hw, MTK_GDM1_TX_COLCNT + offs); 722 + hw_stats->tx_bytes += 723 + mtk_r32(mac->hw, MTK_GDM1_TX_GBCNT_L + offs); 724 + stats = mtk_r32(mac->hw, MTK_GDM1_TX_GBCNT_H + offs); 725 + if (stats) 726 + hw_stats->tx_bytes += (stats << 32); 727 + hw_stats->tx_packets += 728 + mtk_r32(mac->hw, MTK_GDM1_TX_GPCNT + offs); 729 + } 730 + 710 731 u64_stats_update_end(&hw_stats->syncp); 711 732 } 712 733 ··· 2444 2423 val |= cur << MTK_PDMA_DELAY_RX_PINT_SHIFT; 2445 2424 2446 2425 mtk_w32(eth, val, MTK_PDMA_DELAY_INT); 2447 - mtk_w32(eth, val, MTK_QDMA_DELAY_INT); 2426 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) 2427 + mtk_w32(eth, val, MTK_QDMA_DELAY_INT); 2448 2428 2449 2429 spin_unlock_bh(&eth->dim_lock); 2450 2430 ··· 2474 2452 val |= cur << MTK_PDMA_DELAY_TX_PINT_SHIFT; 2475 2453 2476 2454 mtk_w32(eth, val, MTK_PDMA_DELAY_INT); 2477 - mtk_w32(eth, val, MTK_QDMA_DELAY_INT); 2455 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) 2456 + mtk_w32(eth, val, MTK_QDMA_DELAY_INT); 2478 2457 2479 2458 spin_unlock_bh(&eth->dim_lock); 2480 2459 ··· 2502 2479 dev_err(eth->dev, "MAC reset failed!\n"); 2503 2480 goto err_disable_pm; 2504 2481 } 2482 + 2483 + /* set interrupt delays based on current Net DIM sample */ 2484 + mtk_dim_rx(&eth->rx_dim.work); 2485 + mtk_dim_tx(&eth->tx_dim.work); 2505 2486 2506 2487 /* disable delay and normal interrupt */ 2507 2488 mtk_tx_irq_disable(eth, ~0);
+22 -2
drivers/net/ethernet/mediatek/mtk_eth_soc.h
··· 278 278 /* QDMA FQ Free Page Buffer Length Register */ 279 279 #define MTK_QDMA_FQ_BLEN 0x1B2C 280 280 281 - /* GMA1 Received Good Byte Count Register */ 282 - #define MTK_GDM1_TX_GBCNT 0x2400 281 + /* GMA1 counter / statics register */ 282 + #define MTK_GDM1_RX_GBCNT_L 0x2400 283 + #define MTK_GDM1_RX_GBCNT_H 0x2404 284 + #define MTK_GDM1_RX_GPCNT 0x2408 285 + #define MTK_GDM1_RX_OERCNT 0x2410 286 + #define MTK_GDM1_RX_FERCNT 0x2414 287 + #define MTK_GDM1_RX_SERCNT 0x2418 288 + #define MTK_GDM1_RX_LENCNT 0x241c 289 + #define MTK_GDM1_RX_CERCNT 0x2420 290 + #define MTK_GDM1_RX_FCCNT 0x2424 291 + #define MTK_GDM1_TX_SKIPCNT 0x2428 292 + #define MTK_GDM1_TX_COLCNT 0x242c 293 + #define MTK_GDM1_TX_GBCNT_L 0x2430 294 + #define MTK_GDM1_TX_GBCNT_H 0x2434 295 + #define MTK_GDM1_TX_GPCNT 0x2438 283 296 #define MTK_STAT_OFFSET 0x40 284 297 285 298 /* QDMA descriptor txd4 */ ··· 514 501 515 502 #define MT7628_SDM_MAC_ADRL (MT7628_SDM_OFFSET + 0x0c) 516 503 #define MT7628_SDM_MAC_ADRH (MT7628_SDM_OFFSET + 0x10) 504 + 505 + /* Counter / stat register */ 506 + #define MT7628_SDM_TPCNT (MT7628_SDM_OFFSET + 0x100) 507 + #define MT7628_SDM_TBCNT (MT7628_SDM_OFFSET + 0x104) 508 + #define MT7628_SDM_RPCNT (MT7628_SDM_OFFSET + 0x108) 509 + #define MT7628_SDM_RBCNT (MT7628_SDM_OFFSET + 0x10c) 510 + #define MT7628_SDM_CS_ERR (MT7628_SDM_OFFSET + 0x110) 517 511 518 512 struct mtk_rx_dma { 519 513 unsigned int rxd1;
+1 -3
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
··· 2027 2027 return ret; 2028 2028 } 2029 2029 2030 - #define MLX4_EEPROM_PAGE_LEN 256 2031 - 2032 2030 static int mlx4_en_get_module_info(struct net_device *dev, 2033 2031 struct ethtool_modinfo *modinfo) 2034 2032 { ··· 2061 2063 break; 2062 2064 case MLX4_MODULE_ID_SFP: 2063 2065 modinfo->type = ETH_MODULE_SFF_8472; 2064 - modinfo->eeprom_len = MLX4_EEPROM_PAGE_LEN; 2066 + modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; 2065 2067 break; 2066 2068 default: 2067 2069 return -EINVAL;
+103 -4
drivers/net/ethernet/mellanox/mlx4/port.c
··· 1973 1973 #define I2C_ADDR_LOW 0x50 1974 1974 #define I2C_ADDR_HIGH 0x51 1975 1975 #define I2C_PAGE_SIZE 256 1976 + #define I2C_HIGH_PAGE_SIZE 128 1976 1977 1977 1978 /* Module Info Data */ 1978 1979 struct mlx4_cable_info { ··· 2027 2026 return "Unknown Error"; 2028 2027 } 2029 2028 2029 + static int mlx4_get_module_id(struct mlx4_dev *dev, u8 port, u8 *module_id) 2030 + { 2031 + struct mlx4_cmd_mailbox *inbox, *outbox; 2032 + struct mlx4_mad_ifc *inmad, *outmad; 2033 + struct mlx4_cable_info *cable_info; 2034 + int ret; 2035 + 2036 + inbox = mlx4_alloc_cmd_mailbox(dev); 2037 + if (IS_ERR(inbox)) 2038 + return PTR_ERR(inbox); 2039 + 2040 + outbox = mlx4_alloc_cmd_mailbox(dev); 2041 + if (IS_ERR(outbox)) { 2042 + mlx4_free_cmd_mailbox(dev, inbox); 2043 + return PTR_ERR(outbox); 2044 + } 2045 + 2046 + inmad = (struct mlx4_mad_ifc *)(inbox->buf); 2047 + outmad = (struct mlx4_mad_ifc *)(outbox->buf); 2048 + 2049 + inmad->method = 0x1; /* Get */ 2050 + inmad->class_version = 0x1; 2051 + inmad->mgmt_class = 0x1; 2052 + inmad->base_version = 0x1; 2053 + inmad->attr_id = cpu_to_be16(0xFF60); /* Module Info */ 2054 + 2055 + cable_info = (struct mlx4_cable_info *)inmad->data; 2056 + cable_info->dev_mem_address = 0; 2057 + cable_info->page_num = 0; 2058 + cable_info->i2c_addr = I2C_ADDR_LOW; 2059 + cable_info->size = cpu_to_be16(1); 2060 + 2061 + ret = mlx4_cmd_box(dev, inbox->dma, outbox->dma, port, 3, 2062 + MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C, 2063 + MLX4_CMD_NATIVE); 2064 + if (ret) 2065 + goto out; 2066 + 2067 + if (be16_to_cpu(outmad->status)) { 2068 + /* Mad returned with bad status */ 2069 + ret = be16_to_cpu(outmad->status); 2070 + mlx4_warn(dev, 2071 + "MLX4_CMD_MAD_IFC Get Module ID attr(%x) port(%d) i2c_addr(%x) offset(%d) size(%d): Response Mad Status(%x) - %s\n", 2072 + 0xFF60, port, I2C_ADDR_LOW, 0, 1, ret, 2073 + cable_info_mad_err_str(ret)); 2074 + ret = -ret; 2075 + goto out; 2076 + } 2077 + cable_info = (struct mlx4_cable_info *)outmad->data; 2078 + *module_id = cable_info->data[0]; 2079 + out: 2080 + mlx4_free_cmd_mailbox(dev, inbox); 2081 + mlx4_free_cmd_mailbox(dev, outbox); 2082 + return ret; 2083 + } 2084 + 2085 + static void mlx4_sfp_eeprom_params_set(u8 *i2c_addr, u8 *page_num, u16 *offset) 2086 + { 2087 + *i2c_addr = I2C_ADDR_LOW; 2088 + *page_num = 0; 2089 + 2090 + if (*offset < I2C_PAGE_SIZE) 2091 + return; 2092 + 2093 + *i2c_addr = I2C_ADDR_HIGH; 2094 + *offset -= I2C_PAGE_SIZE; 2095 + } 2096 + 2097 + static void mlx4_qsfp_eeprom_params_set(u8 *i2c_addr, u8 *page_num, u16 *offset) 2098 + { 2099 + /* Offsets 0-255 belong to page 0. 2100 + * Offsets 256-639 belong to pages 01, 02, 03. 2101 + * For example, offset 400 is page 02: 1 + (400 - 256) / 128 = 2 2102 + */ 2103 + if (*offset < I2C_PAGE_SIZE) 2104 + *page_num = 0; 2105 + else 2106 + *page_num = 1 + (*offset - I2C_PAGE_SIZE) / I2C_HIGH_PAGE_SIZE; 2107 + *i2c_addr = I2C_ADDR_LOW; 2108 + *offset -= *page_num * I2C_HIGH_PAGE_SIZE; 2109 + } 2110 + 2030 2111 /** 2031 2112 * mlx4_get_module_info - Read cable module eeprom data 2032 2113 * @dev: mlx4_dev. ··· 2128 2045 struct mlx4_cmd_mailbox *inbox, *outbox; 2129 2046 struct mlx4_mad_ifc *inmad, *outmad; 2130 2047 struct mlx4_cable_info *cable_info; 2131 - u16 i2c_addr; 2048 + u8 module_id, i2c_addr, page_num; 2132 2049 int ret; 2133 2050 2134 2051 if (size > MODULE_INFO_MAX_READ) 2135 2052 size = MODULE_INFO_MAX_READ; 2053 + 2054 + ret = mlx4_get_module_id(dev, port, &module_id); 2055 + if (ret) 2056 + return ret; 2057 + 2058 + switch (module_id) { 2059 + case MLX4_MODULE_ID_SFP: 2060 + mlx4_sfp_eeprom_params_set(&i2c_addr, &page_num, &offset); 2061 + break; 2062 + case MLX4_MODULE_ID_QSFP: 2063 + case MLX4_MODULE_ID_QSFP_PLUS: 2064 + case MLX4_MODULE_ID_QSFP28: 2065 + mlx4_qsfp_eeprom_params_set(&i2c_addr, &page_num, &offset); 2066 + break; 2067 + default: 2068 + mlx4_err(dev, "Module ID not recognized: %#x\n", module_id); 2069 + return -EINVAL; 2070 + } 2136 2071 2137 2072 inbox = mlx4_alloc_cmd_mailbox(dev); 2138 2073 if (IS_ERR(inbox)) ··· 2177 2076 */ 2178 2077 size -= offset + size - I2C_PAGE_SIZE; 2179 2078 2180 - i2c_addr = I2C_ADDR_LOW; 2181 - 2182 2079 cable_info = (struct mlx4_cable_info *)inmad->data; 2183 2080 cable_info->dev_mem_address = cpu_to_be16(offset); 2184 - cable_info->page_num = 0; 2081 + cable_info->page_num = page_num; 2185 2082 cable_info->i2c_addr = i2c_addr; 2186 2083 cable_info->size = cpu_to_be16(size); 2187 2084
+2
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c
··· 223 223 rpriv = priv->ppriv; 224 224 fwd_vport_num = rpriv->rep->vport; 225 225 lag_dev = netdev_master_upper_dev_get(netdev); 226 + if (!lag_dev) 227 + return; 226 228 227 229 netdev_dbg(netdev, "lag_dev(%s)'s slave vport(%d) is txable(%d)\n", 228 230 lag_dev->name, fwd_vport_num, net_lag_port_dev_txable(netdev));
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
··· 626 626 struct mlx5_eswitch *esw; 627 627 u32 zone_restore_id; 628 628 629 - tc_skb_ext = skb_ext_add(skb, TC_SKB_EXT); 629 + tc_skb_ext = tc_skb_ext_alloc(skb); 630 630 if (!tc_skb_ext) { 631 631 WARN_ON(1); 632 632 return false;
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
··· 1505 1505 1506 1506 fen_info = container_of(info, struct fib_entry_notifier_info, info); 1507 1507 fib_dev = fib_info_nh(fen_info->fi, 0)->fib_nh_dev; 1508 - if (fib_dev->netdev_ops != &mlx5e_netdev_ops || 1508 + if (!fib_dev || fib_dev->netdev_ops != &mlx5e_netdev_ops || 1509 1509 fen_info->dst_len != 32) 1510 1510 return NULL; 1511 1511
+1
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
··· 35 35 #include <linux/ipv6.h> 36 36 #include <linux/tcp.h> 37 37 #include <linux/mlx5/fs.h> 38 + #include <linux/mlx5/mpfs.h> 38 39 #include "en.h" 39 40 #include "en_rep.h" 40 41 #include "lib/mpfs.h"
+13 -3
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 889 889 void mlx5e_activate_rq(struct mlx5e_rq *rq) 890 890 { 891 891 set_bit(MLX5E_RQ_STATE_ENABLED, &rq->state); 892 - if (rq->icosq) 892 + if (rq->icosq) { 893 893 mlx5e_trigger_irq(rq->icosq); 894 - else 894 + } else { 895 + local_bh_disable(); 895 896 napi_schedule(rq->cq.napi); 897 + local_bh_enable(); 898 + } 896 899 } 897 900 898 901 void mlx5e_deactivate_rq(struct mlx5e_rq *rq) ··· 2700 2697 int err; 2701 2698 2702 2699 old_num_txqs = netdev->real_num_tx_queues; 2703 - old_ntc = netdev->num_tc; 2700 + old_ntc = netdev->num_tc ? : 1; 2704 2701 2705 2702 nch = priv->channels.params.num_channels; 2706 2703 ntc = priv->channels.params.num_tc; ··· 5232 5229 rtnl_unlock(); 5233 5230 } 5234 5231 5232 + static void mlx5e_reset_channels(struct net_device *netdev) 5233 + { 5234 + netdev_reset_tc(netdev); 5235 + } 5236 + 5235 5237 int mlx5e_attach_netdev(struct mlx5e_priv *priv) 5236 5238 { 5237 5239 const bool take_rtnl = priv->netdev->reg_state == NETREG_REGISTERED; ··· 5291 5283 profile->cleanup_tx(priv); 5292 5284 5293 5285 out: 5286 + mlx5e_reset_channels(priv->netdev); 5294 5287 set_bit(MLX5E_STATE_DESTROYING, &priv->state); 5295 5288 cancel_work_sync(&priv->update_stats_work); 5296 5289 return err; ··· 5309 5300 5310 5301 profile->cleanup_rx(priv); 5311 5302 profile->cleanup_tx(priv); 5303 + mlx5e_reset_channels(priv->netdev); 5312 5304 cancel_work_sync(&priv->update_stats_work); 5313 5305 } 5314 5306
+22 -6
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 1322 1322 struct netlink_ext_ack *extack) 1323 1323 { 1324 1324 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 1325 - struct net_device *out_dev, *encap_dev = NULL; 1326 1325 struct mlx5e_tc_flow_parse_attr *parse_attr; 1327 1326 struct mlx5_flow_attr *attr = flow->attr; 1328 1327 bool vf_tun = false, encap_valid = true; 1328 + struct net_device *encap_dev = NULL; 1329 1329 struct mlx5_esw_flow_attr *esw_attr; 1330 1330 struct mlx5_fc *counter = NULL; 1331 1331 struct mlx5e_rep_priv *rpriv; ··· 1371 1371 esw_attr = attr->esw_attr; 1372 1372 1373 1373 for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) { 1374 + struct net_device *out_dev; 1374 1375 int mirred_ifindex; 1375 1376 1376 1377 if (!(esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP)) 1377 1378 continue; 1378 1379 1379 1380 mirred_ifindex = parse_attr->mirred_ifindex[out_index]; 1380 - out_dev = __dev_get_by_index(dev_net(priv->netdev), 1381 - mirred_ifindex); 1381 + out_dev = dev_get_by_index(dev_net(priv->netdev), mirred_ifindex); 1382 + if (!out_dev) { 1383 + NL_SET_ERR_MSG_MOD(extack, "Requested mirred device not found"); 1384 + err = -ENODEV; 1385 + goto err_out; 1386 + } 1382 1387 err = mlx5e_attach_encap(priv, flow, out_dev, out_index, 1383 1388 extack, &encap_dev, &encap_valid); 1389 + dev_put(out_dev); 1384 1390 if (err) 1385 1391 goto err_out; 1386 1392 ··· 1397 1391 rpriv = out_priv->ppriv; 1398 1392 esw_attr->dests[out_index].rep = rpriv->rep; 1399 1393 esw_attr->dests[out_index].mdev = out_priv->mdev; 1394 + } 1395 + 1396 + if (vf_tun && esw_attr->out_count > 1) { 1397 + NL_SET_ERR_MSG_MOD(extack, "VF tunnel encap with mirroring is not supported"); 1398 + err = -EOPNOTSUPP; 1399 + goto err_out; 1400 1400 } 1401 1401 1402 1402 err = mlx5_eswitch_add_vlan_action(esw, attr); ··· 3538 3526 if (err) 3539 3527 return err; 3540 3528 3541 - *out_dev = dev_get_by_index_rcu(dev_net(vlan_dev), 3542 - dev_get_iflink(vlan_dev)); 3529 + rcu_read_lock(); 3530 + *out_dev = dev_get_by_index_rcu(dev_net(vlan_dev), dev_get_iflink(vlan_dev)); 3531 + rcu_read_unlock(); 3532 + if (!*out_dev) 3533 + return -ENODEV; 3534 + 3543 3535 if (is_vlan_dev(*out_dev)) 3544 3536 err = add_vlan_push_action(priv, attr, out_dev, action); 3545 3537 ··· 5090 5074 5091 5075 if (mapped_obj.type == MLX5_MAPPED_OBJ_CHAIN) { 5092 5076 chain = mapped_obj.chain; 5093 - tc_skb_ext = skb_ext_add(skb, TC_SKB_EXT); 5077 + tc_skb_ext = tc_skb_ext_alloc(skb); 5094 5078 if (WARN_ON(!tc_skb_ext)) 5095 5079 return false; 5096 5080
+1
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
··· 35 35 #include <linux/mlx5/mlx5_ifc.h> 36 36 #include <linux/mlx5/vport.h> 37 37 #include <linux/mlx5/fs.h> 38 + #include <linux/mlx5/mpfs.h> 38 39 #include "esw/acl/lgcy.h" 39 40 #include "esw/legacy.h" 40 41 #include "mlx5_core.h"
+26 -35
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
··· 65 65 { 66 66 struct mlx5_flow_table_attr ft_attr = {}; 67 67 struct mlx5_flow_namespace *root_ns; 68 - int err; 68 + int err, err2; 69 69 70 70 root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_FDB); 71 71 if (!root_ns) { ··· 76 76 /* As this is the terminating action then the termination table is the 77 77 * same prio as the slow path 78 78 */ 79 - ft_attr.flags = MLX5_FLOW_TABLE_TERMINATION | 79 + ft_attr.flags = MLX5_FLOW_TABLE_TERMINATION | MLX5_FLOW_TABLE_UNMANAGED | 80 80 MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT; 81 - ft_attr.prio = FDB_SLOW_PATH; 81 + ft_attr.prio = FDB_TC_OFFLOAD; 82 82 ft_attr.max_fte = 1; 83 + ft_attr.level = 1; 83 84 ft_attr.autogroup.max_num_groups = 1; 84 85 tt->termtbl = mlx5_create_auto_grouped_flow_table(root_ns, &ft_attr); 85 86 if (IS_ERR(tt->termtbl)) { 86 - esw_warn(dev, "Failed to create termination table (error %d)\n", 87 - IS_ERR(tt->termtbl)); 88 - return -EOPNOTSUPP; 87 + err = PTR_ERR(tt->termtbl); 88 + esw_warn(dev, "Failed to create termination table, err %pe\n", tt->termtbl); 89 + return err; 89 90 } 90 91 91 92 tt->rule = mlx5_add_flow_rules(tt->termtbl, NULL, flow_act, 92 93 &tt->dest, 1); 93 94 if (IS_ERR(tt->rule)) { 94 - esw_warn(dev, "Failed to create termination table rule (error %d)\n", 95 - IS_ERR(tt->rule)); 95 + err = PTR_ERR(tt->rule); 96 + esw_warn(dev, "Failed to create termination table rule, err %pe\n", tt->rule); 96 97 goto add_flow_err; 97 98 } 98 99 return 0; 99 100 100 101 add_flow_err: 101 - err = mlx5_destroy_flow_table(tt->termtbl); 102 - if (err) 103 - esw_warn(dev, "Failed to destroy termination table\n"); 102 + err2 = mlx5_destroy_flow_table(tt->termtbl); 103 + if (err2) 104 + esw_warn(dev, "Failed to destroy termination table, err %d\n", err2); 104 105 105 - return -EOPNOTSUPP; 106 + return err; 106 107 } 107 108 108 109 static struct mlx5_termtbl_handle * ··· 173 172 } 174 173 } 175 174 176 - static bool mlx5_eswitch_termtbl_is_encap_reformat(struct mlx5_pkt_reformat *rt) 177 - { 178 - switch (rt->reformat_type) { 179 - case MLX5_REFORMAT_TYPE_L2_TO_VXLAN: 180 - case MLX5_REFORMAT_TYPE_L2_TO_NVGRE: 181 - case MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL: 182 - case MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL: 183 - return true; 184 - default: 185 - return false; 186 - } 187 - } 188 - 189 175 static void 190 176 mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src, 191 177 struct mlx5_flow_act *dst) ··· 189 201 memcpy(&dst->vlan[1], &src->vlan[1], sizeof(src->vlan[1])); 190 202 memset(&src->vlan[1], 0, sizeof(src->vlan[1])); 191 203 } 192 - } 193 - 194 - if (src->action & MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT && 195 - mlx5_eswitch_termtbl_is_encap_reformat(src->pkt_reformat)) { 196 - src->action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; 197 - dst->action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; 198 - dst->pkt_reformat = src->pkt_reformat; 199 - src->pkt_reformat = NULL; 200 204 } 201 205 } 202 206 ··· 218 238 int i; 219 239 220 240 if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table) || 241 + !MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ignore_flow_level) || 221 242 attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH || 222 243 !mlx5_eswitch_offload_is_uplink_port(esw, spec)) 223 244 return false; ··· 260 279 if (dest[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT) 261 280 continue; 262 281 282 + if (attr->dests[num_vport_dests].flags & MLX5_ESW_DEST_ENCAP) { 283 + term_tbl_act.action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; 284 + term_tbl_act.pkt_reformat = attr->dests[num_vport_dests].pkt_reformat; 285 + } else { 286 + term_tbl_act.action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; 287 + term_tbl_act.pkt_reformat = NULL; 288 + } 289 + 263 290 /* get the terminating table for the action list */ 264 291 tt = mlx5_eswitch_termtbl_get_create(esw, &term_tbl_act, 265 292 &dest[i], attr); 266 293 if (IS_ERR(tt)) { 267 - esw_warn(esw->dev, "Failed to get termination table (error %d)\n", 268 - IS_ERR(tt)); 294 + esw_warn(esw->dev, "Failed to get termination table, err %pe\n", tt); 269 295 goto revert_changes; 270 296 } 271 297 attr->dests[num_vport_dests].termtbl = tt; ··· 289 301 goto revert_changes; 290 302 291 303 /* create the FTE */ 304 + flow_act->action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; 305 + flow_act->pkt_reformat = NULL; 306 + flow_act->flags |= FLOW_ACT_IGNORE_FLOW_LEVEL; 292 307 rule = mlx5_add_flow_rules(fdb, spec, flow_act, dest, num_dest); 293 308 if (IS_ERR(rule)) 294 309 goto revert_changes;
+6
drivers/net/ethernet/mellanox/mlx5/core/lag_mp.c
··· 307 307 struct lag_mp *mp = &ldev->lag_mp; 308 308 int err; 309 309 310 + /* always clear mfi, as it might become stale when a route delete event 311 + * has been missed 312 + */ 313 + mp->mfi = NULL; 314 + 310 315 if (mp->fib_nb.notifier_call) 311 316 return 0; 312 317 ··· 340 335 unregister_fib_notifier(&init_net, &mp->fib_nb); 341 336 destroy_workqueue(mp->wq); 342 337 mp->fib_nb.notifier_call = NULL; 338 + mp->mfi = NULL; 343 339 }
+3
drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c
··· 33 33 #include <linux/etherdevice.h> 34 34 #include <linux/mlx5/driver.h> 35 35 #include <linux/mlx5/mlx5_ifc.h> 36 + #include <linux/mlx5/mpfs.h> 36 37 #include <linux/mlx5/eswitch.h> 37 38 #include "mlx5_core.h" 38 39 #include "lib/mpfs.h" ··· 176 175 mutex_unlock(&mpfs->lock); 177 176 return err; 178 177 } 178 + EXPORT_SYMBOL(mlx5_mpfs_add_mac); 179 179 180 180 int mlx5_mpfs_del_mac(struct mlx5_core_dev *dev, u8 *mac) 181 181 { ··· 208 206 mutex_unlock(&mpfs->lock); 209 207 return err; 210 208 } 209 + EXPORT_SYMBOL(mlx5_mpfs_del_mac);
+1 -4
drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.h
··· 84 84 #ifdef CONFIG_MLX5_MPFS 85 85 int mlx5_mpfs_init(struct mlx5_core_dev *dev); 86 86 void mlx5_mpfs_cleanup(struct mlx5_core_dev *dev); 87 - int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u8 *mac); 88 - int mlx5_mpfs_del_mac(struct mlx5_core_dev *dev, u8 *mac); 89 87 #else /* #ifndef CONFIG_MLX5_MPFS */ 90 88 static inline int mlx5_mpfs_init(struct mlx5_core_dev *dev) { return 0; } 91 89 static inline void mlx5_mpfs_cleanup(struct mlx5_core_dev *dev) {} 92 - static inline int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u8 *mac) { return 0; } 93 - static inline int mlx5_mpfs_del_mac(struct mlx5_core_dev *dev, u8 *mac) { return 0; } 94 90 #endif 91 + 95 92 #endif
+5 -6
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 503 503 504 504 static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx) 505 505 { 506 - struct mlx5_profile *prof = dev->profile; 506 + struct mlx5_profile *prof = &dev->profile; 507 507 void *set_hca_cap; 508 508 int err; 509 509 ··· 524 524 to_fw_pkey_sz(dev, 128)); 525 525 526 526 /* Check log_max_qp from HCA caps to set in current profile */ 527 - if (MLX5_CAP_GEN_MAX(dev, log_max_qp) < profile[prof_sel].log_max_qp) { 527 + if (MLX5_CAP_GEN_MAX(dev, log_max_qp) < prof->log_max_qp) { 528 528 mlx5_core_warn(dev, "log_max_qp value in current profile is %d, changing it to HCA capability limit (%d)\n", 529 - profile[prof_sel].log_max_qp, 529 + prof->log_max_qp, 530 530 MLX5_CAP_GEN_MAX(dev, log_max_qp)); 531 - profile[prof_sel].log_max_qp = MLX5_CAP_GEN_MAX(dev, log_max_qp); 531 + prof->log_max_qp = MLX5_CAP_GEN_MAX(dev, log_max_qp); 532 532 } 533 533 if (prof->mask & MLX5_PROF_MASK_QP_SIZE) 534 534 MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp, ··· 1381 1381 struct mlx5_priv *priv = &dev->priv; 1382 1382 int err; 1383 1383 1384 - dev->profile = &profile[profile_idx]; 1385 - 1384 + memcpy(&dev->profile, &profile[profile_idx], sizeof(dev->profile)); 1386 1385 INIT_LIST_HEAD(&priv->ctx_list); 1387 1386 spin_lock_init(&priv->ctx_lock); 1388 1387 mutex_init(&dev->intf_state_mutex);
+17 -5
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
··· 95 95 int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id, 96 96 int msix_vec_count) 97 97 { 98 - int sz = MLX5_ST_SZ_BYTES(set_hca_cap_in); 98 + int query_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out); 99 + int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in); 100 + void *hca_cap = NULL, *query_cap = NULL, *cap; 99 101 int num_vf_msix, min_msix, max_msix; 100 - void *hca_cap, *cap; 101 102 int ret; 102 103 103 104 num_vf_msix = MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix); ··· 117 116 if (msix_vec_count > max_msix) 118 117 return -EOVERFLOW; 119 118 120 - hca_cap = kzalloc(sz, GFP_KERNEL); 121 - if (!hca_cap) 122 - return -ENOMEM; 119 + query_cap = kzalloc(query_sz, GFP_KERNEL); 120 + hca_cap = kzalloc(set_sz, GFP_KERNEL); 121 + if (!hca_cap || !query_cap) { 122 + ret = -ENOMEM; 123 + goto out; 124 + } 125 + 126 + ret = mlx5_vport_get_other_func_cap(dev, function_id, query_cap); 127 + if (ret) 128 + goto out; 123 129 124 130 cap = MLX5_ADDR_OF(set_hca_cap_in, hca_cap, capability); 131 + memcpy(cap, MLX5_ADDR_OF(query_hca_cap_out, query_cap, capability), 132 + MLX5_UN_SZ_BYTES(hca_cap_union)); 125 133 MLX5_SET(cmd_hca_cap, cap, dynamic_msix_table_size, msix_vec_count); 126 134 127 135 MLX5_SET(set_hca_cap_in, hca_cap, opcode, MLX5_CMD_OP_SET_HCA_CAP); ··· 140 130 MLX5_SET(set_hca_cap_in, hca_cap, op_mod, 141 131 MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1); 142 132 ret = mlx5_cmd_exec_in(dev, set_hca_cap, hca_cap); 133 + out: 143 134 kfree(hca_cap); 135 + kfree(query_cap); 144 136 return ret; 145 137 } 146 138
+11 -7
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c
··· 136 136 switch (hw_state) { 137 137 case MLX5_VHCA_STATE_ACTIVE: 138 138 case MLX5_VHCA_STATE_IN_USE: 139 - case MLX5_VHCA_STATE_TEARDOWN_REQUEST: 140 139 return DEVLINK_PORT_FN_STATE_ACTIVE; 141 140 case MLX5_VHCA_STATE_INVALID: 142 141 case MLX5_VHCA_STATE_ALLOCATED: 142 + case MLX5_VHCA_STATE_TEARDOWN_REQUEST: 143 143 default: 144 144 return DEVLINK_PORT_FN_STATE_INACTIVE; 145 145 } ··· 192 192 return err; 193 193 } 194 194 195 - static int mlx5_sf_activate(struct mlx5_core_dev *dev, struct mlx5_sf *sf) 195 + static int mlx5_sf_activate(struct mlx5_core_dev *dev, struct mlx5_sf *sf, 196 + struct netlink_ext_ack *extack) 196 197 { 197 198 int err; 198 199 199 200 if (mlx5_sf_is_active(sf)) 200 201 return 0; 201 - if (sf->hw_state != MLX5_VHCA_STATE_ALLOCATED) 202 - return -EINVAL; 202 + if (sf->hw_state != MLX5_VHCA_STATE_ALLOCATED) { 203 + NL_SET_ERR_MSG_MOD(extack, "SF is inactivated but it is still attached"); 204 + return -EBUSY; 205 + } 203 206 204 207 err = mlx5_cmd_sf_enable_hca(dev, sf->hw_fn_id); 205 208 if (err) ··· 229 226 230 227 static int mlx5_sf_state_set(struct mlx5_core_dev *dev, struct mlx5_sf_table *table, 231 228 struct mlx5_sf *sf, 232 - enum devlink_port_fn_state state) 229 + enum devlink_port_fn_state state, 230 + struct netlink_ext_ack *extack) 233 231 { 234 232 int err = 0; 235 233 ··· 238 234 if (state == mlx5_sf_to_devlink_state(sf->hw_state)) 239 235 goto out; 240 236 if (state == DEVLINK_PORT_FN_STATE_ACTIVE) 241 - err = mlx5_sf_activate(dev, sf); 237 + err = mlx5_sf_activate(dev, sf, extack); 242 238 else if (state == DEVLINK_PORT_FN_STATE_INACTIVE) 243 239 err = mlx5_sf_deactivate(dev, sf); 244 240 else ··· 269 265 goto out; 270 266 } 271 267 272 - err = mlx5_sf_state_set(dev, table, sf, state); 268 + err = mlx5_sf_state_set(dev, table, sf, state, extack); 273 269 out: 274 270 mlx5_sf_table_put(table); 275 271 return err;
+1 -1
drivers/net/ethernet/microchip/encx24j600.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 - /** 2 + /* 3 3 * Microchip ENCX24J600 ethernet driver 4 4 * 5 5 * Copyright (C) 2015 Gridpoint
+1 -1
drivers/net/ethernet/microchip/encx24j600_hw.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 - /** 2 + /* 3 3 * encx24j600_hw.h: Register definitions 4 4 * 5 5 */
+1
drivers/net/ethernet/pensando/Kconfig
··· 20 20 config IONIC 21 21 tristate "Pensando Ethernet IONIC Support" 22 22 depends on 64BIT && PCI 23 + depends on PTP_1588_CLOCK || !PTP_1588_CLOCK 23 24 select NET_DEVLINK 24 25 select DIMLIB 25 26 help
+1 -1
drivers/net/ethernet/qlogic/qla3xxx.c
··· 114 114 value = readl(&port_regs->CommonRegs.semaphoreReg); 115 115 if ((value & (sem_mask >> 16)) == sem_bits) 116 116 return 0; 117 - ssleep(1); 117 + mdelay(1000); 118 118 } while (--seconds); 119 119 return -1; 120 120 }
+1
drivers/net/ethernet/sfc/nic.c
··· 90 90 efx->pci_dev->irq); 91 91 goto fail1; 92 92 } 93 + efx->irqs_hooked = true; 93 94 return 0; 94 95 } 95 96
+22 -10
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 1196 1196 */ 1197 1197 static int stmmac_init_phy(struct net_device *dev) 1198 1198 { 1199 - struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; 1200 1199 struct stmmac_priv *priv = netdev_priv(dev); 1201 1200 struct device_node *node; 1202 1201 int ret; ··· 1221 1222 ret = phylink_connect_phy(priv->phylink, phydev); 1222 1223 } 1223 1224 1224 - phylink_ethtool_get_wol(priv->phylink, &wol); 1225 - device_set_wakeup_capable(priv->device, !!wol.supported); 1225 + if (!priv->plat->pmt) { 1226 + struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; 1227 + 1228 + phylink_ethtool_get_wol(priv->phylink, &wol); 1229 + device_set_wakeup_capable(priv->device, !!wol.supported); 1230 + } 1226 1231 1227 1232 return ret; 1228 1233 } ··· 5891 5888 struct stmmac_priv *priv = netdev_priv(ndev); 5892 5889 int ret = 0; 5893 5890 5891 + ret = pm_runtime_get_sync(priv->device); 5892 + if (ret < 0) { 5893 + pm_runtime_put_noidle(priv->device); 5894 + return ret; 5895 + } 5896 + 5894 5897 ret = eth_mac_addr(ndev, addr); 5895 5898 if (ret) 5896 - return ret; 5899 + goto set_mac_error; 5897 5900 5898 5901 stmmac_set_umac_addr(priv, priv->hw, ndev->dev_addr, 0); 5902 + 5903 + set_mac_error: 5904 + pm_runtime_put(priv->device); 5899 5905 5900 5906 return ret; 5901 5907 } ··· 6200 6188 bool is_double = false; 6201 6189 int ret; 6202 6190 6203 - ret = pm_runtime_get_sync(priv->device); 6204 - if (ret < 0) { 6205 - pm_runtime_put_noidle(priv->device); 6206 - return ret; 6207 - } 6208 - 6209 6191 if (be16_to_cpu(proto) == ETH_P_8021AD) 6210 6192 is_double = true; 6211 6193 ··· 6224 6218 struct stmmac_priv *priv = netdev_priv(ndev); 6225 6219 bool is_double = false; 6226 6220 int ret; 6221 + 6222 + ret = pm_runtime_get_sync(priv->device); 6223 + if (ret < 0) { 6224 + pm_runtime_put_noidle(priv->device); 6225 + return ret; 6226 + } 6227 6227 6228 6228 if (be16_to_cpu(proto) == ETH_P_8021AD) 6229 6229 is_double = true;
+2 -2
drivers/net/ethernet/ti/netcp_core.c
··· 1350 1350 tx_pipe->dma_queue = knav_queue_open(name, tx_pipe->dma_queue_id, 1351 1351 KNAV_QUEUE_SHARED); 1352 1352 if (IS_ERR(tx_pipe->dma_queue)) { 1353 - dev_err(dev, "Could not open DMA queue for channel \"%s\": %d\n", 1354 - name, ret); 1353 + dev_err(dev, "Could not open DMA queue for channel \"%s\": %pe\n", 1354 + name, tx_pipe->dma_queue); 1355 1355 ret = PTR_ERR(tx_pipe->dma_queue); 1356 1356 goto err; 1357 1357 }
+2
drivers/net/ipa/ipa.h
··· 58 58 * @mem_virt: Virtual address of IPA-local memory space 59 59 * @mem_offset: Offset from @mem_virt used for access to IPA memory 60 60 * @mem_size: Total size (bytes) of memory at @mem_virt 61 + * @mem_count: Number of entries in the mem array 61 62 * @mem: Array of IPA-local memory region descriptors 62 63 * @imem_iova: I/O virtual address of IPA region in IMEM 63 64 * @imem_size: Size of IMEM region ··· 104 103 void *mem_virt; 105 104 u32 mem_offset; 106 105 u32 mem_size; 106 + u32 mem_count; 107 107 const struct ipa_mem *mem; 108 108 109 109 unsigned long imem_iova;
+2 -1
drivers/net/ipa/ipa_mem.c
··· 180 180 * for the region, write "canary" values in the space prior to 181 181 * the region's base address. 182 182 */ 183 - for (mem_id = 0; mem_id < IPA_MEM_COUNT; mem_id++) { 183 + for (mem_id = 0; mem_id < ipa->mem_count; mem_id++) { 184 184 const struct ipa_mem *mem = &ipa->mem[mem_id]; 185 185 u16 canary_count; 186 186 __le32 *canary; ··· 487 487 ipa->mem_size = resource_size(res); 488 488 489 489 /* The ipa->mem[] array is indexed by enum ipa_mem_id values */ 490 + ipa->mem_count = mem_data->local_count; 490 491 ipa->mem = mem_data->local; 491 492 492 493 ret = ipa_imem_init(ipa, mem_data->imem_addr, mem_data->imem_size);
-2
drivers/net/mdio/mdio-octeon.c
··· 71 71 72 72 return 0; 73 73 fail_register: 74 - mdiobus_free(bus->mii_bus); 75 74 smi_en.u64 = 0; 76 75 oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); 77 76 return err; ··· 84 85 bus = platform_get_drvdata(pdev); 85 86 86 87 mdiobus_unregister(bus->mii_bus); 87 - mdiobus_free(bus->mii_bus); 88 88 smi_en.u64 = 0; 89 89 oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); 90 90 return 0;
-1
drivers/net/mdio/mdio-thunder.c
··· 126 126 continue; 127 127 128 128 mdiobus_unregister(bus->mii_bus); 129 - mdiobus_free(bus->mii_bus); 130 129 oct_mdio_writeq(0, bus->register_base + SMI_EN); 131 130 } 132 131 pci_release_regions(pdev);
+2 -1
drivers/net/phy/mdio_bus.c
··· 607 607 struct mdio_device *mdiodev; 608 608 int i; 609 609 610 - BUG_ON(bus->state != MDIOBUS_REGISTERED); 610 + if (WARN_ON_ONCE(bus->state != MDIOBUS_REGISTERED)) 611 + return; 611 612 bus->state = MDIOBUS_UNREGISTERED; 612 613 613 614 for (i = 0; i < PHY_MAX_ADDR; i++) {
+1 -1
drivers/net/usb/cdc_eem.c
··· 26 26 * for transport over USB using a simpler USB device model than the 27 27 * previous CDC "Ethernet Control Model" (ECM, or "CDC Ethernet"). 28 28 * 29 - * For details, see www.usb.org/developers/devclass_docs/CDC_EEM10.pdf 29 + * For details, see https://usb.org/sites/default/files/CDC_EEM10.pdf 30 30 * 31 31 * This version has been tested with GIGAntIC WuaoW SIM Smart Card on 2.6.24, 32 32 * 2.6.27 and 2.6.30rc2 kernel.
+22 -23
drivers/net/usb/hso.c
··· 1689 1689 spin_unlock_irqrestore(&serial->serial_lock, flags); 1690 1690 1691 1691 return usb_control_msg(serial->parent->usb, 1692 - usb_rcvctrlpipe(serial->parent->usb, 0), 0x22, 1692 + usb_sndctrlpipe(serial->parent->usb, 0), 0x22, 1693 1693 0x21, val, if_num, NULL, 0, 1694 1694 USB_CTRL_SET_TIMEOUT); 1695 1695 } ··· 2436 2436 if (hso_dev->usb_gone) 2437 2437 rv = 0; 2438 2438 else 2439 - rv = usb_control_msg(hso_dev->usb, usb_rcvctrlpipe(hso_dev->usb, 0), 2439 + rv = usb_control_msg(hso_dev->usb, usb_sndctrlpipe(hso_dev->usb, 0), 2440 2440 enabled ? 0x82 : 0x81, 0x40, 0, 0, NULL, 0, 2441 2441 USB_CTRL_SET_TIMEOUT); 2442 2442 mutex_unlock(&hso_dev->mutex); ··· 2618 2618 num_urbs = 2; 2619 2619 serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), 2620 2620 GFP_KERNEL); 2621 + if (!serial->tiocmget) 2622 + goto exit; 2621 2623 serial->tiocmget->serial_state_notification 2622 2624 = kzalloc(sizeof(struct hso_serial_state_notification), 2623 2625 GFP_KERNEL); 2624 - /* it isn't going to break our heart if serial->tiocmget 2625 - * allocation fails don't bother checking this. 2626 - */ 2627 - if (serial->tiocmget && serial->tiocmget->serial_state_notification) { 2628 - tiocmget = serial->tiocmget; 2629 - tiocmget->endp = hso_get_ep(interface, 2630 - USB_ENDPOINT_XFER_INT, 2631 - USB_DIR_IN); 2632 - if (!tiocmget->endp) { 2633 - dev_err(&interface->dev, "Failed to find INT IN ep\n"); 2634 - goto exit; 2635 - } 2636 - 2637 - tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL); 2638 - if (tiocmget->urb) { 2639 - mutex_init(&tiocmget->mutex); 2640 - init_waitqueue_head(&tiocmget->waitq); 2641 - } else 2642 - hso_free_tiomget(serial); 2626 + if (!serial->tiocmget->serial_state_notification) 2627 + goto exit; 2628 + tiocmget = serial->tiocmget; 2629 + tiocmget->endp = hso_get_ep(interface, 2630 + USB_ENDPOINT_XFER_INT, 2631 + USB_DIR_IN); 2632 + if (!tiocmget->endp) { 2633 + dev_err(&interface->dev, "Failed to find INT IN ep\n"); 2634 + goto exit; 2643 2635 } 2644 - } 2645 - else 2636 + 2637 + tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL); 2638 + if (!tiocmget->urb) 2639 + goto exit; 2640 + 2641 + mutex_init(&tiocmget->mutex); 2642 + init_waitqueue_head(&tiocmget->waitq); 2643 + } else { 2646 2644 num_urbs = 1; 2645 + } 2647 2646 2648 2647 if (hso_serial_common_create(serial, num_urbs, BULK_URB_RX_SIZE, 2649 2648 BULK_URB_TX_SIZE))
+1
drivers/net/usb/lan78xx.c
··· 1645 1645 .get_strings = lan78xx_get_strings, 1646 1646 .get_wol = lan78xx_get_wol, 1647 1647 .set_wol = lan78xx_set_wol, 1648 + .get_ts_info = ethtool_op_get_ts_info, 1648 1649 .get_eee = lan78xx_get_eee, 1649 1650 .set_eee = lan78xx_set_eee, 1650 1651 .get_pauseparam = lan78xx_get_pause,
+37 -5
drivers/net/usb/r8152.c
··· 8107 8107 tp->coalesce = 15000; /* 15 us */ 8108 8108 } 8109 8109 8110 + static bool rtl_check_vendor_ok(struct usb_interface *intf) 8111 + { 8112 + struct usb_host_interface *alt = intf->cur_altsetting; 8113 + struct usb_endpoint_descriptor *in, *out, *intr; 8114 + 8115 + if (usb_find_common_endpoints(alt, &in, &out, &intr, NULL) < 0) { 8116 + dev_err(&intf->dev, "Expected endpoints are not found\n"); 8117 + return false; 8118 + } 8119 + 8120 + /* Check Rx endpoint address */ 8121 + if (usb_endpoint_num(in) != 1) { 8122 + dev_err(&intf->dev, "Invalid Rx endpoint address\n"); 8123 + return false; 8124 + } 8125 + 8126 + /* Check Tx endpoint address */ 8127 + if (usb_endpoint_num(out) != 2) { 8128 + dev_err(&intf->dev, "Invalid Tx endpoint address\n"); 8129 + return false; 8130 + } 8131 + 8132 + /* Check interrupt endpoint address */ 8133 + if (usb_endpoint_num(intr) != 3) { 8134 + dev_err(&intf->dev, "Invalid interrupt endpoint address\n"); 8135 + return false; 8136 + } 8137 + 8138 + return true; 8139 + } 8140 + 8110 8141 static bool rtl_vendor_mode(struct usb_interface *intf) 8111 8142 { 8112 8143 struct usb_host_interface *alt = intf->cur_altsetting; ··· 8146 8115 int i, num_configs; 8147 8116 8148 8117 if (alt->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) 8149 - return true; 8118 + return rtl_check_vendor_ok(intf); 8150 8119 8151 8120 /* The vendor mode is not always config #1, so to find it out. */ 8152 8121 udev = interface_to_usbdev(intf); 8153 8122 c = udev->config; 8154 8123 num_configs = udev->descriptor.bNumConfigurations; 8124 + if (num_configs < 2) 8125 + return false; 8126 + 8155 8127 for (i = 0; i < num_configs; (i++, c++)) { 8156 8128 struct usb_interface_descriptor *desc = NULL; 8157 8129 ··· 8169 8135 } 8170 8136 } 8171 8137 8172 - WARN_ON_ONCE(i == num_configs); 8138 + if (i == num_configs) 8139 + dev_err(&intf->dev, "Unexpected Device\n"); 8173 8140 8174 8141 return false; 8175 8142 } ··· 9414 9379 return -ENODEV; 9415 9380 9416 9381 if (!rtl_vendor_mode(intf)) 9417 - return -ENODEV; 9418 - 9419 - if (intf->cur_altsetting->desc.bNumEndpoints < 3) 9420 9382 return -ENODEV; 9421 9383 9422 9384 usb_reset_device(udev);
+6 -2
drivers/net/usb/smsc75xx.c
··· 1483 1483 ret = smsc75xx_wait_ready(dev, 0); 1484 1484 if (ret < 0) { 1485 1485 netdev_warn(dev->net, "device not ready in smsc75xx_bind\n"); 1486 - return ret; 1486 + goto err; 1487 1487 } 1488 1488 1489 1489 smsc75xx_init_mac_address(dev); ··· 1492 1492 ret = smsc75xx_reset(dev); 1493 1493 if (ret < 0) { 1494 1494 netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret); 1495 - return ret; 1495 + goto err; 1496 1496 } 1497 1497 1498 1498 dev->net->netdev_ops = &smsc75xx_netdev_ops; ··· 1502 1502 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; 1503 1503 dev->net->max_mtu = MAX_SINGLE_PACKET_SIZE; 1504 1504 return 0; 1505 + 1506 + err: 1507 + kfree(pdata); 1508 + return ret; 1505 1509 } 1506 1510 1507 1511 static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
+1
drivers/net/wireless/ath/ath10k/htt.h
··· 845 845 846 846 #define ATH10K_HTT_TXRX_PEER_SECURITY_MAX 2 847 847 #define ATH10K_TXRX_NUM_EXT_TIDS 19 848 + #define ATH10K_TXRX_NON_QOS_TID 16 848 849 849 850 enum htt_security_flags { 850 851 #define HTT_SECURITY_TYPE_MASK 0x7F
+191 -10
drivers/net/wireless/ath/ath10k/htt_rx.c
··· 1746 1746 msdu->ip_summed = ath10k_htt_rx_get_csum_state(msdu); 1747 1747 } 1748 1748 1749 + static u64 ath10k_htt_rx_h_get_pn(struct ath10k *ar, struct sk_buff *skb, 1750 + u16 offset, 1751 + enum htt_rx_mpdu_encrypt_type enctype) 1752 + { 1753 + struct ieee80211_hdr *hdr; 1754 + u64 pn = 0; 1755 + u8 *ehdr; 1756 + 1757 + hdr = (struct ieee80211_hdr *)(skb->data + offset); 1758 + ehdr = skb->data + offset + ieee80211_hdrlen(hdr->frame_control); 1759 + 1760 + if (enctype == HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2) { 1761 + pn = ehdr[0]; 1762 + pn |= (u64)ehdr[1] << 8; 1763 + pn |= (u64)ehdr[4] << 16; 1764 + pn |= (u64)ehdr[5] << 24; 1765 + pn |= (u64)ehdr[6] << 32; 1766 + pn |= (u64)ehdr[7] << 40; 1767 + } 1768 + return pn; 1769 + } 1770 + 1771 + static bool ath10k_htt_rx_h_frag_multicast_check(struct ath10k *ar, 1772 + struct sk_buff *skb, 1773 + u16 offset) 1774 + { 1775 + struct ieee80211_hdr *hdr; 1776 + 1777 + hdr = (struct ieee80211_hdr *)(skb->data + offset); 1778 + return !is_multicast_ether_addr(hdr->addr1); 1779 + } 1780 + 1781 + static bool ath10k_htt_rx_h_frag_pn_check(struct ath10k *ar, 1782 + struct sk_buff *skb, 1783 + u16 peer_id, 1784 + u16 offset, 1785 + enum htt_rx_mpdu_encrypt_type enctype) 1786 + { 1787 + struct ath10k_peer *peer; 1788 + union htt_rx_pn_t *last_pn, new_pn = {0}; 1789 + struct ieee80211_hdr *hdr; 1790 + bool more_frags; 1791 + u8 tid, frag_number; 1792 + u32 seq; 1793 + 1794 + peer = ath10k_peer_find_by_id(ar, peer_id); 1795 + if (!peer) { 1796 + ath10k_dbg(ar, ATH10K_DBG_HTT, "invalid peer for frag pn check\n"); 1797 + return false; 1798 + } 1799 + 1800 + hdr = (struct ieee80211_hdr *)(skb->data + offset); 1801 + if (ieee80211_is_data_qos(hdr->frame_control)) 1802 + tid = ieee80211_get_tid(hdr); 1803 + else 1804 + tid = ATH10K_TXRX_NON_QOS_TID; 1805 + 1806 + last_pn = &peer->frag_tids_last_pn[tid]; 1807 + new_pn.pn48 = ath10k_htt_rx_h_get_pn(ar, skb, offset, enctype); 1808 + more_frags = ieee80211_has_morefrags(hdr->frame_control); 1809 + frag_number = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG; 1810 + seq = (__le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4; 1811 + 1812 + if (frag_number == 0) { 1813 + last_pn->pn48 = new_pn.pn48; 1814 + peer->frag_tids_seq[tid] = seq; 1815 + } else { 1816 + if (seq != peer->frag_tids_seq[tid]) 1817 + return false; 1818 + 1819 + if (new_pn.pn48 != last_pn->pn48 + 1) 1820 + return false; 1821 + 1822 + last_pn->pn48 = new_pn.pn48; 1823 + } 1824 + 1825 + return true; 1826 + } 1827 + 1749 1828 static void ath10k_htt_rx_h_mpdu(struct ath10k *ar, 1750 1829 struct sk_buff_head *amsdu, 1751 1830 struct ieee80211_rx_status *status, 1752 1831 bool fill_crypt_header, 1753 1832 u8 *rx_hdr, 1754 - enum ath10k_pkt_rx_err *err) 1833 + enum ath10k_pkt_rx_err *err, 1834 + u16 peer_id, 1835 + bool frag) 1755 1836 { 1756 1837 struct sk_buff *first; 1757 1838 struct sk_buff *last; 1758 - struct sk_buff *msdu; 1839 + struct sk_buff *msdu, *temp; 1759 1840 struct htt_rx_desc *rxd; 1760 1841 struct ieee80211_hdr *hdr; 1761 1842 enum htt_rx_mpdu_encrypt_type enctype; ··· 1849 1768 bool is_decrypted; 1850 1769 bool is_mgmt; 1851 1770 u32 attention; 1771 + bool frag_pn_check = true, multicast_check = true; 1852 1772 1853 1773 if (skb_queue_empty(amsdu)) 1854 1774 return; ··· 1948 1866 } 1949 1867 1950 1868 skb_queue_walk(amsdu, msdu) { 1869 + if (frag && !fill_crypt_header && is_decrypted && 1870 + enctype == HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2) 1871 + frag_pn_check = ath10k_htt_rx_h_frag_pn_check(ar, 1872 + msdu, 1873 + peer_id, 1874 + 0, 1875 + enctype); 1876 + 1877 + if (frag) 1878 + multicast_check = ath10k_htt_rx_h_frag_multicast_check(ar, 1879 + msdu, 1880 + 0); 1881 + 1882 + if (!frag_pn_check || !multicast_check) { 1883 + /* Discard the fragment with invalid PN or multicast DA 1884 + */ 1885 + temp = msdu->prev; 1886 + __skb_unlink(msdu, amsdu); 1887 + dev_kfree_skb_any(msdu); 1888 + msdu = temp; 1889 + frag_pn_check = true; 1890 + multicast_check = true; 1891 + continue; 1892 + } 1893 + 1951 1894 ath10k_htt_rx_h_csum_offload(msdu); 1895 + 1896 + if (frag && !fill_crypt_header && 1897 + enctype == HTT_RX_MPDU_ENCRYPT_TKIP_WPA) 1898 + status->flag &= ~RX_FLAG_MMIC_STRIPPED; 1899 + 1952 1900 ath10k_htt_rx_h_undecap(ar, msdu, status, first_hdr, enctype, 1953 1901 is_decrypted); 1954 1902 ··· 1996 1884 1997 1885 hdr = (void *)msdu->data; 1998 1886 hdr->frame_control &= ~__cpu_to_le16(IEEE80211_FCTL_PROTECTED); 1887 + 1888 + if (frag && !fill_crypt_header && 1889 + enctype == HTT_RX_MPDU_ENCRYPT_TKIP_WPA) 1890 + status->flag &= ~RX_FLAG_IV_STRIPPED & 1891 + ~RX_FLAG_MMIC_STRIPPED; 1999 1892 } 2000 1893 } 2001 1894 ··· 2108 1991 ath10k_unchain_msdu(amsdu, unchain_cnt); 2109 1992 } 2110 1993 1994 + static bool ath10k_htt_rx_validate_amsdu(struct ath10k *ar, 1995 + struct sk_buff_head *amsdu) 1996 + { 1997 + u8 *subframe_hdr; 1998 + struct sk_buff *first; 1999 + bool is_first, is_last; 2000 + struct htt_rx_desc *rxd; 2001 + struct ieee80211_hdr *hdr; 2002 + size_t hdr_len, crypto_len; 2003 + enum htt_rx_mpdu_encrypt_type enctype; 2004 + int bytes_aligned = ar->hw_params.decap_align_bytes; 2005 + 2006 + first = skb_peek(amsdu); 2007 + 2008 + rxd = (void *)first->data - sizeof(*rxd); 2009 + hdr = (void *)rxd->rx_hdr_status; 2010 + 2011 + is_first = !!(rxd->msdu_end.common.info0 & 2012 + __cpu_to_le32(RX_MSDU_END_INFO0_FIRST_MSDU)); 2013 + is_last = !!(rxd->msdu_end.common.info0 & 2014 + __cpu_to_le32(RX_MSDU_END_INFO0_LAST_MSDU)); 2015 + 2016 + /* Return in case of non-aggregated msdu */ 2017 + if (is_first && is_last) 2018 + return true; 2019 + 2020 + /* First msdu flag is not set for the first msdu of the list */ 2021 + if (!is_first) 2022 + return false; 2023 + 2024 + enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0), 2025 + RX_MPDU_START_INFO0_ENCRYPT_TYPE); 2026 + 2027 + hdr_len = ieee80211_hdrlen(hdr->frame_control); 2028 + crypto_len = ath10k_htt_rx_crypto_param_len(ar, enctype); 2029 + 2030 + subframe_hdr = (u8 *)hdr + round_up(hdr_len, bytes_aligned) + 2031 + crypto_len; 2032 + 2033 + /* Validate if the amsdu has a proper first subframe. 2034 + * There are chances a single msdu can be received as amsdu when 2035 + * the unauthenticated amsdu flag of a QoS header 2036 + * gets flipped in non-SPP AMSDU's, in such cases the first 2037 + * subframe has llc/snap header in place of a valid da. 2038 + * return false if the da matches rfc1042 pattern 2039 + */ 2040 + if (ether_addr_equal(subframe_hdr, rfc1042_header)) 2041 + return false; 2042 + 2043 + return true; 2044 + } 2045 + 2111 2046 static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar, 2112 2047 struct sk_buff_head *amsdu, 2113 2048 struct ieee80211_rx_status *rx_status) 2114 2049 { 2115 - /* FIXME: It might be a good idea to do some fuzzy-testing to drop 2116 - * invalid/dangerous frames. 2117 - */ 2118 - 2119 2050 if (!rx_status->freq) { 2120 2051 ath10k_dbg(ar, ATH10K_DBG_HTT, "no channel configured; ignoring frame(s)!\n"); 2121 2052 return false; ··· 2171 2006 2172 2007 if (test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) { 2173 2008 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx cac running\n"); 2009 + return false; 2010 + } 2011 + 2012 + if (!ath10k_htt_rx_validate_amsdu(ar, amsdu)) { 2013 + ath10k_dbg(ar, ATH10K_DBG_HTT, "invalid amsdu received\n"); 2174 2014 return false; 2175 2015 } 2176 2016 ··· 2241 2071 ath10k_htt_rx_h_unchain(ar, &amsdu, &drop_cnt, &unchain_cnt); 2242 2072 2243 2073 ath10k_htt_rx_h_filter(ar, &amsdu, rx_status, &drop_cnt_filter); 2244 - ath10k_htt_rx_h_mpdu(ar, &amsdu, rx_status, true, first_hdr, &err); 2074 + ath10k_htt_rx_h_mpdu(ar, &amsdu, rx_status, true, first_hdr, &err, 0, 2075 + false); 2245 2076 msdus_to_queue = skb_queue_len(&amsdu); 2246 2077 ath10k_htt_rx_h_enqueue(ar, &amsdu, rx_status); 2247 2078 ··· 2374 2203 mpdu_ranges = htt_rx_ind_get_mpdu_ranges_hl(rx); 2375 2204 fw_desc = &rx->fw_desc; 2376 2205 rx_desc_len = fw_desc->len; 2206 + 2207 + if (fw_desc->u.bits.discard) { 2208 + ath10k_dbg(ar, ATH10K_DBG_HTT, "htt discard mpdu\n"); 2209 + goto err; 2210 + } 2377 2211 2378 2212 /* I have not yet seen any case where num_mpdu_ranges > 1. 2379 2213 * qcacld does not seem handle that case either, so we introduce the ··· 2685 2509 rx_desc = (struct htt_hl_rx_desc *)(skb->data + tot_hdr_len); 2686 2510 rx_desc_info = __le32_to_cpu(rx_desc->info); 2687 2511 2512 + hdr = (struct ieee80211_hdr *)((u8 *)rx_desc + rx_hl->fw_desc.len); 2513 + 2514 + if (is_multicast_ether_addr(hdr->addr1)) { 2515 + /* Discard the fragment with multicast DA */ 2516 + goto err; 2517 + } 2518 + 2688 2519 if (!MS(rx_desc_info, HTT_RX_DESC_HL_INFO_ENCRYPTED)) { 2689 2520 spin_unlock_bh(&ar->data_lock); 2690 2521 return ath10k_htt_rx_proc_rx_ind_hl(htt, &resp->rx_ind_hl, skb, 2691 2522 HTT_RX_NON_PN_CHECK, 2692 2523 HTT_RX_NON_TKIP_MIC); 2693 2524 } 2694 - 2695 - hdr = (struct ieee80211_hdr *)((u8 *)rx_desc + rx_hl->fw_desc.len); 2696 2525 2697 2526 if (ieee80211_has_retry(hdr->frame_control)) 2698 2527 goto err; ··· 3208 3027 ath10k_htt_rx_h_ppdu(ar, &amsdu, status, vdev_id); 3209 3028 ath10k_htt_rx_h_filter(ar, &amsdu, status, NULL); 3210 3029 ath10k_htt_rx_h_mpdu(ar, &amsdu, status, false, NULL, 3211 - NULL); 3030 + NULL, peer_id, frag); 3212 3031 ath10k_htt_rx_h_enqueue(ar, &amsdu, status); 3213 3032 break; 3214 3033 case -EAGAIN:
+13 -1
drivers/net/wireless/ath/ath10k/rx_desc.h
··· 1282 1282 #define FW_RX_DESC_UDP (1 << 6) 1283 1283 1284 1284 struct fw_rx_desc_hl { 1285 - u8 info0; 1285 + union { 1286 + struct { 1287 + u8 discard:1, 1288 + forward:1, 1289 + any_err:1, 1290 + dup_err:1, 1291 + reserved:1, 1292 + inspect:1, 1293 + extension:2; 1294 + } bits; 1295 + u8 info0; 1296 + } u; 1297 + 1286 1298 u8 version; 1287 1299 u8 len; 1288 1300 u8 flags;
+34
drivers/net/wireless/ath/ath11k/dp_rx.c
··· 260 260 ab->hw_params.hw_ops->rx_desc_set_msdu_len(desc, len); 261 261 } 262 262 263 + static bool ath11k_dp_rx_h_attn_is_mcbc(struct ath11k_base *ab, 264 + struct hal_rx_desc *desc) 265 + { 266 + struct rx_attention *attn = ath11k_dp_rx_get_attention(ab, desc); 267 + 268 + return ath11k_dp_rx_h_msdu_end_first_msdu(ab, desc) && 269 + (!!FIELD_GET(RX_ATTENTION_INFO1_MCAST_BCAST, 270 + __le32_to_cpu(attn->info1))); 271 + } 272 + 263 273 static void ath11k_dp_service_mon_ring(struct timer_list *t) 264 274 { 265 275 struct ath11k_base *ab = from_timer(ab, t, mon_reap_timer); ··· 860 850 rx_tid->last_frag_no = 0; 861 851 rx_tid->rx_frag_bitmap = 0; 862 852 __skb_queue_purge(&rx_tid->rx_frags); 853 + } 854 + 855 + void ath11k_peer_frags_flush(struct ath11k *ar, struct ath11k_peer *peer) 856 + { 857 + struct dp_rx_tid *rx_tid; 858 + int i; 859 + 860 + lockdep_assert_held(&ar->ab->base_lock); 861 + 862 + for (i = 0; i <= IEEE80211_NUM_TIDS; i++) { 863 + rx_tid = &peer->rx_tid[i]; 864 + 865 + spin_unlock_bh(&ar->ab->base_lock); 866 + del_timer_sync(&rx_tid->frag_timer); 867 + spin_lock_bh(&ar->ab->base_lock); 868 + 869 + ath11k_dp_rx_frags_cleanup(rx_tid, true); 870 + } 863 871 } 864 872 865 873 void ath11k_peer_rx_tid_cleanup(struct ath11k *ar, struct ath11k_peer *peer) ··· 3478 3450 u8 tid; 3479 3451 int ret = 0; 3480 3452 bool more_frags; 3453 + bool is_mcbc; 3481 3454 3482 3455 rx_desc = (struct hal_rx_desc *)msdu->data; 3483 3456 peer_id = ath11k_dp_rx_h_mpdu_start_peer_id(ar->ab, rx_desc); ··· 3486 3457 seqno = ath11k_dp_rx_h_mpdu_start_seq_no(ar->ab, rx_desc); 3487 3458 frag_no = ath11k_dp_rx_h_mpdu_start_frag_no(ar->ab, msdu); 3488 3459 more_frags = ath11k_dp_rx_h_mpdu_start_more_frags(ar->ab, msdu); 3460 + is_mcbc = ath11k_dp_rx_h_attn_is_mcbc(ar->ab, rx_desc); 3461 + 3462 + /* Multicast/Broadcast fragments are not expected */ 3463 + if (is_mcbc) 3464 + return -EINVAL; 3489 3465 3490 3466 if (!ath11k_dp_rx_h_mpdu_start_seq_ctrl_valid(ar->ab, rx_desc) || 3491 3467 !ath11k_dp_rx_h_mpdu_start_fc_valid(ar->ab, rx_desc) ||
+1
drivers/net/wireless/ath/ath11k/dp_rx.h
··· 49 49 const u8 *peer_addr, 50 50 enum set_key_cmd key_cmd, 51 51 struct ieee80211_key_conf *key); 52 + void ath11k_peer_frags_flush(struct ath11k *ar, struct ath11k_peer *peer); 52 53 void ath11k_peer_rx_tid_cleanup(struct ath11k *ar, struct ath11k_peer *peer); 53 54 void ath11k_peer_rx_tid_delete(struct ath11k *ar, 54 55 struct ath11k_peer *peer, u8 tid);
+6
drivers/net/wireless/ath/ath11k/mac.c
··· 2779 2779 */ 2780 2780 spin_lock_bh(&ab->base_lock); 2781 2781 peer = ath11k_peer_find(ab, arvif->vdev_id, peer_addr); 2782 + 2783 + /* flush the fragments cache during key (re)install to 2784 + * ensure all frags in the new frag list belong to the same key. 2785 + */ 2786 + if (peer && cmd == SET_KEY) 2787 + ath11k_peer_frags_flush(ar, peer); 2782 2788 spin_unlock_bh(&ab->base_lock); 2783 2789 2784 2790 if (!peer) {
+1 -1
drivers/nfc/nfcmrvl/fw_dnld.h
··· 1 - /** 1 + /* 2 2 * Marvell NFC driver: Firmware downloader 3 3 * 4 4 * Copyright (C) 2015, Marvell International Ltd.
+1 -1
drivers/nfc/nfcmrvl/i2c.c
··· 1 - /** 1 + /* 2 2 * Marvell NFC-over-I2C driver: I2C interface related functions 3 3 * 4 4 * Copyright (C) 2015, Marvell International Ltd.
+1 -1
drivers/nfc/nfcmrvl/nfcmrvl.h
··· 1 - /** 1 + /* 2 2 * Marvell NFC driver 3 3 * 4 4 * Copyright (C) 2014-2015, Marvell International Ltd.
+1 -1
drivers/nfc/nfcmrvl/spi.c
··· 1 - /** 1 + /* 2 2 * Marvell NFC-over-SPI driver: SPI interface related functions 3 3 * 4 4 * Copyright (C) 2015, Marvell International Ltd.
+1 -1
drivers/nfc/nfcmrvl/uart.c
··· 1 - /** 1 + /* 2 2 * Marvell NFC-over-UART driver 3 3 * 4 4 * Copyright (C) 2015, Marvell International Ltd.
+1 -1
drivers/nfc/nfcmrvl/usb.c
··· 1 - /** 1 + /* 2 2 * Marvell NFC-over-USB driver: USB interface related functions 3 3 * 4 4 * Copyright (C) 2014, Marvell International Ltd.
+2 -1
drivers/nvme/host/Kconfig
··· 71 71 config NVME_TCP 72 72 tristate "NVM Express over Fabrics TCP host driver" 73 73 depends on INET 74 - depends on BLK_DEV_NVME 74 + depends on BLOCK 75 + select NVME_CORE 75 76 select NVME_FABRICS 76 77 select CRYPTO 77 78 select CRYPTO_CRC32C
+3 -1
drivers/nvme/host/core.c
··· 3485 3485 cdev_init(cdev, fops); 3486 3486 cdev->owner = owner; 3487 3487 ret = cdev_device_add(cdev, cdev_device); 3488 - if (ret) 3488 + if (ret) { 3489 + put_device(cdev_device); 3489 3490 ida_simple_remove(&nvme_ns_chr_minor_ida, minor); 3491 + } 3490 3492 return ret; 3491 3493 } 3492 3494
+5
drivers/nvme/host/fabrics.c
··· 336 336 cmd->connect.recfmt); 337 337 break; 338 338 339 + case NVME_SC_HOST_PATH_ERROR: 340 + dev_err(ctrl->device, 341 + "Connect command failed: host path error\n"); 342 + break; 343 + 339 344 default: 340 345 dev_err(ctrl->device, 341 346 "Connect command failed, error wo/DNR bit: %d\n",
+17 -8
drivers/nvme/host/fc.c
··· 3107 3107 if (ctrl->ctrl.icdoff) { 3108 3108 dev_err(ctrl->ctrl.device, "icdoff %d is not supported!\n", 3109 3109 ctrl->ctrl.icdoff); 3110 + ret = NVME_SC_INVALID_FIELD | NVME_SC_DNR; 3110 3111 goto out_disconnect_admin_queue; 3111 3112 } 3112 3113 ··· 3115 3114 if (!(ctrl->ctrl.sgls & ((1 << 0) | (1 << 1)))) { 3116 3115 dev_err(ctrl->ctrl.device, 3117 3116 "Mandatory sgls are not supported!\n"); 3117 + ret = NVME_SC_INVALID_FIELD | NVME_SC_DNR; 3118 3118 goto out_disconnect_admin_queue; 3119 3119 } 3120 3120 ··· 3282 3280 if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) 3283 3281 return; 3284 3282 3285 - if (portptr->port_state == FC_OBJSTATE_ONLINE) 3283 + if (portptr->port_state == FC_OBJSTATE_ONLINE) { 3286 3284 dev_info(ctrl->ctrl.device, 3287 3285 "NVME-FC{%d}: reset: Reconnect attempt failed (%d)\n", 3288 3286 ctrl->cnum, status); 3289 - else if (time_after_eq(jiffies, rport->dev_loss_end)) 3287 + if (status > 0 && (status & NVME_SC_DNR)) 3288 + recon = false; 3289 + } else if (time_after_eq(jiffies, rport->dev_loss_end)) 3290 3290 recon = false; 3291 3291 3292 3292 if (recon && nvmf_should_reconnect(&ctrl->ctrl)) { ··· 3302 3298 3303 3299 queue_delayed_work(nvme_wq, &ctrl->connect_work, recon_delay); 3304 3300 } else { 3305 - if (portptr->port_state == FC_OBJSTATE_ONLINE) 3306 - dev_warn(ctrl->ctrl.device, 3307 - "NVME-FC{%d}: Max reconnect attempts (%d) " 3308 - "reached.\n", 3309 - ctrl->cnum, ctrl->ctrl.nr_reconnects); 3310 - else 3301 + if (portptr->port_state == FC_OBJSTATE_ONLINE) { 3302 + if (status > 0 && (status & NVME_SC_DNR)) 3303 + dev_warn(ctrl->ctrl.device, 3304 + "NVME-FC{%d}: reconnect failure\n", 3305 + ctrl->cnum); 3306 + else 3307 + dev_warn(ctrl->ctrl.device, 3308 + "NVME-FC{%d}: Max reconnect attempts " 3309 + "(%d) reached.\n", 3310 + ctrl->cnum, ctrl->ctrl.nr_reconnects); 3311 + } else 3311 3312 dev_warn(ctrl->ctrl.device, 3312 3313 "NVME-FC{%d}: dev_loss_tmo (%d) expired " 3313 3314 "while waiting for remoteport connectivity.\n",
+11 -4
drivers/nvme/target/core.c
··· 388 388 { 389 389 struct nvmet_ctrl *ctrl = container_of(to_delayed_work(work), 390 390 struct nvmet_ctrl, ka_work); 391 - bool cmd_seen = ctrl->cmd_seen; 391 + bool reset_tbkas = ctrl->reset_tbkas; 392 392 393 - ctrl->cmd_seen = false; 394 - if (cmd_seen) { 393 + ctrl->reset_tbkas = false; 394 + if (reset_tbkas) { 395 395 pr_debug("ctrl %d reschedule traffic based keep-alive timer\n", 396 396 ctrl->cntlid); 397 397 schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); ··· 804 804 percpu_ref_exit(&sq->ref); 805 805 806 806 if (ctrl) { 807 + /* 808 + * The teardown flow may take some time, and the host may not 809 + * send us keep-alive during this period, hence reset the 810 + * traffic based keep-alive timer so we don't trigger a 811 + * controller teardown as a result of a keep-alive expiration. 812 + */ 813 + ctrl->reset_tbkas = true; 807 814 nvmet_ctrl_put(ctrl); 808 815 sq->ctrl = NULL; /* allows reusing the queue later */ 809 816 } ··· 959 952 } 960 953 961 954 if (sq->ctrl) 962 - sq->ctrl->cmd_seen = true; 955 + sq->ctrl->reset_tbkas = true; 963 956 964 957 return true; 965 958
+1 -1
drivers/nvme/target/nvmet.h
··· 167 167 struct nvmet_subsys *subsys; 168 168 struct nvmet_sq **sqs; 169 169 170 - bool cmd_seen; 170 + bool reset_tbkas; 171 171 172 172 struct mutex lock; 173 173 u64 cap;
+1 -1
drivers/nvme/target/tcp.c
··· 550 550 * nvmet_req_init is completed. 551 551 */ 552 552 if (queue->rcv_state == NVMET_TCP_RECV_PDU && 553 - len && len < cmd->req.port->inline_data_size && 553 + len && len <= cmd->req.port->inline_data_size && 554 554 nvme_is_write(cmd->req.cmd)) 555 555 return; 556 556 }
+3 -1
drivers/ptp/ptp_ocp.c
··· 324 324 if (!bp->base) { 325 325 dev_err(&pdev->dev, "io_remap bar0\n"); 326 326 err = -ENOMEM; 327 - goto out; 327 + goto out_release_regions; 328 328 } 329 329 bp->reg = bp->base + OCP_REGISTER_OFFSET; 330 330 bp->tod = bp->base + TOD_REGISTER_OFFSET; ··· 347 347 return 0; 348 348 349 349 out: 350 + pci_iounmap(pdev, bp->base); 351 + out_release_regions: 350 352 pci_release_regions(pdev); 351 353 out_disable: 352 354 pci_disable_device(pdev);
+7 -1
drivers/s390/block/dasd_diag.c
··· 642 642 blk_queue_segment_boundary(q, PAGE_SIZE - 1); 643 643 } 644 644 645 + static int dasd_diag_pe_handler(struct dasd_device *device, 646 + __u8 tbvpm, __u8 fcsecpm) 647 + { 648 + return dasd_generic_verify_path(device, tbvpm); 649 + } 650 + 645 651 static struct dasd_discipline dasd_diag_discipline = { 646 652 .owner = THIS_MODULE, 647 653 .name = "DIAG", 648 654 .ebcname = "DIAG", 649 655 .check_device = dasd_diag_check_device, 650 - .verify_path = dasd_generic_verify_path, 656 + .pe_handler = dasd_diag_pe_handler, 651 657 .fill_geometry = dasd_diag_fill_geometry, 652 658 .setup_blk_queue = dasd_diag_setup_blk_queue, 653 659 .start_IO = dasd_start_diag,
+7 -1
drivers/s390/block/dasd_fba.c
··· 794 794 blk_queue_flag_set(QUEUE_FLAG_DISCARD, q); 795 795 } 796 796 797 + static int dasd_fba_pe_handler(struct dasd_device *device, 798 + __u8 tbvpm, __u8 fcsecpm) 799 + { 800 + return dasd_generic_verify_path(device, tbvpm); 801 + } 802 + 797 803 static struct dasd_discipline dasd_fba_discipline = { 798 804 .owner = THIS_MODULE, 799 805 .name = "FBA ", 800 806 .ebcname = "FBA ", 801 807 .check_device = dasd_fba_check_characteristics, 802 808 .do_analysis = dasd_fba_do_analysis, 803 - .verify_path = dasd_generic_verify_path, 809 + .pe_handler = dasd_fba_pe_handler, 804 810 .setup_blk_queue = dasd_fba_setup_blk_queue, 805 811 .fill_geometry = dasd_fba_fill_geometry, 806 812 .start_IO = dasd_start_IO,
-1
drivers/s390/block/dasd_int.h
··· 297 297 * e.g. verify that new path is compatible with the current 298 298 * configuration. 299 299 */ 300 - int (*verify_path)(struct dasd_device *, __u8); 301 300 int (*pe_handler)(struct dasd_device *, __u8, __u8); 302 301 303 302 /*
+4
drivers/s390/cio/vfio_ccw_cp.c
··· 638 638 static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 1); 639 639 int ret; 640 640 641 + /* this is an error in the caller */ 642 + if (cp->initialized) 643 + return -EBUSY; 644 + 641 645 /* 642 646 * We only support prefetching the channel program. We assume all channel 643 647 * programs executed by supported guests likewise support prefetching.
+10 -2
drivers/s390/cio/vfio_ccw_drv.c
··· 86 86 struct vfio_ccw_private *private; 87 87 struct irb *irb; 88 88 bool is_final; 89 + bool cp_is_finished = false; 89 90 90 91 private = container_of(work, struct vfio_ccw_private, io_work); 91 92 irb = &private->irb; ··· 95 94 (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)); 96 95 if (scsw_is_solicited(&irb->scsw)) { 97 96 cp_update_scsw(&private->cp, &irb->scsw); 98 - if (is_final && private->state == VFIO_CCW_STATE_CP_PENDING) 97 + if (is_final && private->state == VFIO_CCW_STATE_CP_PENDING) { 99 98 cp_free(&private->cp); 99 + cp_is_finished = true; 100 + } 100 101 } 101 102 mutex_lock(&private->io_mutex); 102 103 memcpy(private->io_region->irb_area, irb, sizeof(*irb)); 103 104 mutex_unlock(&private->io_mutex); 104 105 105 - if (private->mdev && is_final) 106 + /* 107 + * Reset to IDLE only if processing of a channel program 108 + * has finished. Do not overwrite a possible processing 109 + * state if the final interrupt was for HSCH or CSCH. 110 + */ 111 + if (private->mdev && cp_is_finished) 106 112 private->state = VFIO_CCW_STATE_IDLE; 107 113 108 114 if (private->io_trigger)
+1
drivers/s390/cio/vfio_ccw_fsm.c
··· 318 318 } 319 319 320 320 err_out: 321 + private->state = VFIO_CCW_STATE_IDLE; 321 322 trace_vfio_ccw_fsm_io_request(scsw->cmd.fctl, schid, 322 323 io_region->ret_code, errstr); 323 324 }
-2
drivers/s390/cio/vfio_ccw_ops.c
··· 279 279 } 280 280 281 281 vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_IO_REQ); 282 - if (region->ret_code != 0) 283 - private->state = VFIO_CCW_STATE_IDLE; 284 282 ret = (region->ret_code != 0) ? region->ret_code : count; 285 283 286 284 out_unlock:
-1
drivers/scsi/aic7xxx/aicasm/aicasm_gram.y
··· 58 58 #include "aicasm_symbol.h" 59 59 #include "aicasm_insformat.h" 60 60 61 - int yylineno; 62 61 char *yyfilename; 63 62 char stock_prefix[] = "aic_"; 64 63 char *prefix = stock_prefix;
+1 -1
drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h
··· 108 108 regex_t arg_regex; 109 109 char *replacement_text; 110 110 }; 111 - STAILQ_HEAD(macro_arg_list, macro_arg) args; 111 + STAILQ_HEAD(macro_arg_list, macro_arg); 112 112 113 113 struct macro_info { 114 114 struct macro_arg_list args;
+11
drivers/scsi/aic7xxx/scsi_message.h
··· 3 3 * $FreeBSD: src/sys/cam/scsi/scsi_message.h,v 1.2 2000/05/01 20:21:29 peter Exp $ 4 4 */ 5 5 6 + /* Messages (1 byte) */ /* I/T (M)andatory or (O)ptional */ 7 + #define MSG_SAVEDATAPOINTER 0x02 /* O/O */ 8 + #define MSG_RESTOREPOINTERS 0x03 /* O/O */ 9 + #define MSG_DISCONNECT 0x04 /* O/O */ 10 + #define MSG_MESSAGE_REJECT 0x07 /* M/M */ 11 + #define MSG_NOOP 0x08 /* M/M */ 12 + 13 + /* Messages (2 byte) */ 14 + #define MSG_SIMPLE_Q_TAG 0x20 /* O/O */ 15 + #define MSG_IGN_WIDE_RESIDUE 0x23 /* O/O */ 16 + 6 17 /* Identify message */ /* M/M */ 7 18 #define MSG_IDENTIFYFLAG 0x80 8 19 #define MSG_IDENTIFY_DISCFLAG 0x40
+1
drivers/scsi/bnx2fc/bnx2fc_io.c
··· 1220 1220 was a result from the ABTS request rather than the CLEANUP 1221 1221 request */ 1222 1222 set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags); 1223 + rc = FAILED; 1223 1224 goto done; 1224 1225 } 1225 1226
+4 -4
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 4811 4811 { 4812 4812 int i; 4813 4813 4814 - free_irq(pci_irq_vector(pdev, 1), hisi_hba); 4815 - free_irq(pci_irq_vector(pdev, 2), hisi_hba); 4816 - free_irq(pci_irq_vector(pdev, 11), hisi_hba); 4814 + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 1), hisi_hba); 4815 + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 2), hisi_hba); 4816 + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 11), hisi_hba); 4817 4817 for (i = 0; i < hisi_hba->cq_nvecs; i++) { 4818 4818 struct hisi_sas_cq *cq = &hisi_hba->cq[i]; 4819 4819 int nr = hisi_sas_intr_conv ? 16 : 16 + i; 4820 4820 4821 - free_irq(pci_irq_vector(pdev, nr), cq); 4821 + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, nr), cq); 4822 4822 } 4823 4823 pci_free_irq_vectors(pdev); 4824 4824 }
+2 -2
drivers/scsi/libsas/sas_port.c
··· 25 25 26 26 static void sas_resume_port(struct asd_sas_phy *phy) 27 27 { 28 - struct domain_device *dev; 28 + struct domain_device *dev, *n; 29 29 struct asd_sas_port *port = phy->port; 30 30 struct sas_ha_struct *sas_ha = phy->ha; 31 31 struct sas_internal *si = to_sas_internal(sas_ha->core.shost->transportt); ··· 44 44 * 1/ presume every device came back 45 45 * 2/ force the next revalidation to check all expander phys 46 46 */ 47 - list_for_each_entry(dev, &port->dev_list, dev_list_node) { 47 + list_for_each_entry_safe(dev, n, &port->dev_list, dev_list_node) { 48 48 int i, rc; 49 49 50 50 rc = sas_notify_lldd_dev_found(dev);
+2
drivers/scsi/qla2xxx/qla_target.c
··· 1563 1563 return; 1564 1564 } 1565 1565 1566 + mutex_lock(&tgt->ha->optrom_mutex); 1566 1567 mutex_lock(&vha->vha_tgt.tgt_mutex); 1567 1568 tgt->tgt_stop = 0; 1568 1569 tgt->tgt_stopped = 1; 1569 1570 mutex_unlock(&vha->vha_tgt.tgt_mutex); 1571 + mutex_unlock(&tgt->ha->optrom_mutex); 1570 1572 1571 1573 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00c, "Stop of tgt %p finished\n", 1572 1574 tgt);
+7 -1
drivers/scsi/vmw_pvscsi.c
··· 585 585 case BTSTAT_SUCCESS: 586 586 case BTSTAT_LINKED_COMMAND_COMPLETED: 587 587 case BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG: 588 - /* If everything went fine, let's move on.. */ 588 + /* 589 + * Commands like INQUIRY may transfer less data than 590 + * requested by the initiator via bufflen. Set residual 591 + * count to make upper layer aware of the actual amount 592 + * of data returned. 593 + */ 594 + scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen); 589 595 cmd->result = (DID_OK << 16); 590 596 break; 591 597
+10 -2
drivers/soundwire/qcom.c
··· 1150 1150 1151 1151 ret = of_property_read_u8_array(np, "qcom,ports-block-pack-mode", 1152 1152 bp_mode, nports); 1153 - if (ret) 1154 - return ret; 1153 + if (ret) { 1154 + u32 version; 1155 + 1156 + ctrl->reg_read(ctrl, SWRM_COMP_HW_VERSION, &version); 1157 + 1158 + if (version <= 0x01030000) 1159 + memset(bp_mode, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); 1160 + else 1161 + return ret; 1162 + } 1155 1163 1156 1164 memset(hstart, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); 1157 1165 of_property_read_u8_array(np, "qcom,ports-hstart", hstart, nports);
+2 -2
drivers/staging/emxx_udc/emxx_udc.c
··· 2064 2064 struct nbu2ss_ep *ep, 2065 2065 int status) 2066 2066 { 2067 - struct nbu2ss_req *req; 2067 + struct nbu2ss_req *req, *n; 2068 2068 2069 2069 /* Endpoint Disable */ 2070 2070 _nbu2ss_epn_exit(udc, ep); ··· 2076 2076 return 0; 2077 2077 2078 2078 /* called with irqs blocked */ 2079 - list_for_each_entry(req, &ep->queue, queue) { 2079 + list_for_each_entry_safe(req, n, &ep->queue, queue) { 2080 2080 _nbu2ss_ep_done(ep, req, status); 2081 2081 } 2082 2082
-1
drivers/staging/iio/cdc/ad7746.c
··· 700 700 indio_dev->num_channels = ARRAY_SIZE(ad7746_channels); 701 701 else 702 702 indio_dev->num_channels = ARRAY_SIZE(ad7746_channels) - 2; 703 - indio_dev->num_channels = ARRAY_SIZE(ad7746_channels); 704 703 indio_dev->modes = INDIO_DIRECT_MODE; 705 704 706 705 if (pdata) {
+2 -2
drivers/target/target_core_iblock.c
··· 204 204 struct iblock_dev_plug *ib_dev_plug; 205 205 206 206 /* 207 - * Each se_device has a per cpu work this can be run from. Wwe 207 + * Each se_device has a per cpu work this can be run from. We 208 208 * shouldn't have multiple threads on the same cpu calling this 209 209 * at the same time. 210 210 */ 211 - ib_dev_plug = &ib_dev->ibd_plug[smp_processor_id()]; 211 + ib_dev_plug = &ib_dev->ibd_plug[raw_smp_processor_id()]; 212 212 if (test_and_set_bit(IBD_PLUGF_PLUGGED, &ib_dev_plug->flags)) 213 213 return NULL; 214 214
+1 -1
drivers/target/target_core_transport.c
··· 1416 1416 cmd->orig_fe_lun = unpacked_lun; 1417 1417 1418 1418 if (!(cmd->se_cmd_flags & SCF_USE_CPUID)) 1419 - cmd->cpuid = smp_processor_id(); 1419 + cmd->cpuid = raw_smp_processor_id(); 1420 1420 1421 1421 cmd->state_active = false; 1422 1422 }
+7 -5
drivers/target/target_core_user.c
··· 516 516 dpi = dbi * udev->data_pages_per_blk; 517 517 /* Count the number of already allocated pages */ 518 518 xas_set(&xas, dpi); 519 + rcu_read_lock(); 519 520 for (cnt = 0; xas_next(&xas) && cnt < page_cnt;) 520 521 cnt++; 522 + rcu_read_unlock(); 521 523 522 524 for (i = cnt; i < page_cnt; i++) { 523 525 /* try to get new page from the mm */ ··· 701 699 struct scatterlist *sg, unsigned int sg_nents, 702 700 struct iovec **iov, size_t data_len) 703 701 { 704 - XA_STATE(xas, &udev->data_pages, 0); 705 702 /* start value of dbi + 1 must not be a valid dbi */ 706 703 int dbi = -2; 707 704 size_t page_remaining, cp_len; 708 - int page_cnt, page_inx; 705 + int page_cnt, page_inx, dpi; 709 706 struct sg_mapping_iter sg_iter; 710 707 unsigned int sg_flags; 711 708 struct page *page; ··· 727 726 if (page_cnt > udev->data_pages_per_blk) 728 727 page_cnt = udev->data_pages_per_blk; 729 728 730 - xas_set(&xas, dbi * udev->data_pages_per_blk); 731 - for (page_inx = 0; page_inx < page_cnt && data_len; page_inx++) { 732 - page = xas_next(&xas); 729 + dpi = dbi * udev->data_pages_per_blk; 730 + for (page_inx = 0; page_inx < page_cnt && data_len; 731 + page_inx++, dpi++) { 732 + page = xa_load(&udev->data_pages, dpi); 733 733 734 734 if (direction == TCMU_DATA_AREA_TO_SG) 735 735 flush_dcache_page(page);
+4
drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
··· 237 237 if (ACPI_FAILURE(status)) 238 238 trip_cnt = 0; 239 239 else { 240 + int i; 241 + 240 242 int34x_thermal_zone->aux_trips = 241 243 kcalloc(trip_cnt, 242 244 sizeof(*int34x_thermal_zone->aux_trips), ··· 249 247 } 250 248 trip_mask = BIT(trip_cnt) - 1; 251 249 int34x_thermal_zone->aux_trip_nr = trip_cnt; 250 + for (i = 0; i < trip_cnt; ++i) 251 + int34x_thermal_zone->aux_trips[i] = THERMAL_TEMP_INVALID; 252 252 } 253 253 254 254 trip_cnt = int340x_thermal_read_trips(int34x_thermal_zone);
+1 -1
drivers/thermal/intel/x86_pkg_temp_thermal.c
··· 166 166 if (thres_reg_value) 167 167 *temp = zonedev->tj_max - thres_reg_value * 1000; 168 168 else 169 - *temp = 0; 169 + *temp = THERMAL_TEMP_INVALID; 170 170 pr_debug("sys_get_trip_temp %d\n", *temp); 171 171 172 172 return 0;
+1 -1
drivers/thermal/qcom/qcom-spmi-adc-tm5.c
··· 441 441 442 442 if (args.args_count != 1 || args.args[0] >= ADC5_MAX_CHANNEL) { 443 443 dev_err(dev, "%s: invalid ADC channel number %d\n", name, chan); 444 - return ret; 444 + return -EINVAL; 445 445 } 446 446 channel->adc_channel = args.args[0]; 447 447
+1 -1
drivers/thermal/ti-soc-thermal/ti-bandgap.c
··· 770 770 } 771 771 772 772 /** 773 - * ti_bandgap_alert_init() - setup and initialize talert handling 773 + * ti_bandgap_talert_init() - setup and initialize talert handling 774 774 * @bgp: pointer to struct ti_bandgap 775 775 * @pdev: pointer to device struct platform_device 776 776 *
+6 -5
drivers/thunderbolt/dma_port.c
··· 366 366 void *buf, size_t size) 367 367 { 368 368 unsigned int retries = DMA_PORT_RETRIES; 369 - unsigned int offset; 370 - 371 - offset = address & 3; 372 - address = address & ~3; 373 369 374 370 do { 375 - u32 nbytes = min_t(u32, size, MAIL_DATA_DWORDS * 4); 371 + unsigned int offset; 372 + size_t nbytes; 376 373 int ret; 374 + 375 + offset = address & 3; 376 + nbytes = min_t(size_t, size + offset, MAIL_DATA_DWORDS * 4); 377 377 378 378 ret = dma_port_flash_read_block(dma, address, dma->buf, 379 379 ALIGN(nbytes, 4)); ··· 386 386 return ret; 387 387 } 388 388 389 + nbytes -= offset; 389 390 memcpy(buf, dma->buf + offset, nbytes); 390 391 391 392 size -= nbytes;
+5 -4
drivers/thunderbolt/usb4.c
··· 68 68 unsigned int retries = USB4_DATA_RETRIES; 69 69 unsigned int offset; 70 70 71 - offset = address & 3; 72 - address = address & ~3; 73 - 74 71 do { 75 - size_t nbytes = min_t(size_t, size, USB4_DATA_DWORDS * 4); 76 72 unsigned int dwaddress, dwords; 77 73 u8 data[USB4_DATA_DWORDS * 4]; 74 + size_t nbytes; 78 75 int ret; 76 + 77 + offset = address & 3; 78 + nbytes = min_t(size_t, size + offset, USB4_DATA_DWORDS * 4); 79 79 80 80 dwaddress = address / 4; 81 81 dwords = ALIGN(nbytes, 4) / 4; ··· 87 87 return ret; 88 88 } 89 89 90 + nbytes -= offset; 90 91 memcpy(buf, data + offset, nbytes); 91 92 92 93 size -= nbytes;
+17 -15
drivers/tty/serial/8250/8250.h
··· 7 7 * Copyright (C) 2001 Russell King. 8 8 */ 9 9 10 + #include <linux/bits.h> 10 11 #include <linux/serial_8250.h> 11 12 #include <linux/serial_reg.h> 12 13 #include <linux/dmaengine.h> ··· 71 70 unsigned int flags; 72 71 }; 73 72 74 - #define UART_CAP_FIFO (1 << 8) /* UART has FIFO */ 75 - #define UART_CAP_EFR (1 << 9) /* UART has EFR */ 76 - #define UART_CAP_SLEEP (1 << 10) /* UART has IER sleep */ 77 - #define UART_CAP_AFE (1 << 11) /* MCR-based hw flow control */ 78 - #define UART_CAP_UUE (1 << 12) /* UART needs IER bit 6 set (Xscale) */ 79 - #define UART_CAP_RTOIE (1 << 13) /* UART needs IER bit 4 set (Xscale, Tegra) */ 80 - #define UART_CAP_HFIFO (1 << 14) /* UART has a "hidden" FIFO */ 81 - #define UART_CAP_RPM (1 << 15) /* Runtime PM is active while idle */ 82 - #define UART_CAP_IRDA (1 << 16) /* UART supports IrDA line discipline */ 83 - #define UART_CAP_MINI (1 << 17) /* Mini UART on BCM283X family lacks: 73 + #define UART_CAP_FIFO BIT(8) /* UART has FIFO */ 74 + #define UART_CAP_EFR BIT(9) /* UART has EFR */ 75 + #define UART_CAP_SLEEP BIT(10) /* UART has IER sleep */ 76 + #define UART_CAP_AFE BIT(11) /* MCR-based hw flow control */ 77 + #define UART_CAP_UUE BIT(12) /* UART needs IER bit 6 set (Xscale) */ 78 + #define UART_CAP_RTOIE BIT(13) /* UART needs IER bit 4 set (Xscale, Tegra) */ 79 + #define UART_CAP_HFIFO BIT(14) /* UART has a "hidden" FIFO */ 80 + #define UART_CAP_RPM BIT(15) /* Runtime PM is active while idle */ 81 + #define UART_CAP_IRDA BIT(16) /* UART supports IrDA line discipline */ 82 + #define UART_CAP_MINI BIT(17) /* Mini UART on BCM283X family lacks: 84 83 * STOP PARITY EPAR SPAR WLEN5 WLEN6 85 84 */ 86 85 87 - #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */ 88 - #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ 89 - #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */ 90 - #define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */ 91 - #define UART_BUG_PARITY (1 << 4) /* UART mishandles parity if FIFO enabled */ 86 + #define UART_BUG_QUOT BIT(0) /* UART has buggy quot LSB */ 87 + #define UART_BUG_TXEN BIT(1) /* UART has buggy TX IIR status */ 88 + #define UART_BUG_NOMSR BIT(2) /* UART has buggy MSR status bits (Au1x00) */ 89 + #define UART_BUG_THRE BIT(3) /* UART has buggy THRE reassertion */ 90 + #define UART_BUG_PARITY BIT(4) /* UART mishandles parity if FIFO enabled */ 91 + #define UART_BUG_TXRACE BIT(5) /* UART Tx fails to set remote DR */ 92 92 93 93 94 94 #ifdef CONFIG_SERIAL_8250_SHARE_IRQ
+1
drivers/tty/serial/8250/8250_aspeed_vuart.c
··· 437 437 port.port.status = UPSTAT_SYNC_FIFO; 438 438 port.port.dev = &pdev->dev; 439 439 port.port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); 440 + port.bugs |= UART_BUG_TXRACE; 440 441 441 442 rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); 442 443 if (rc < 0)
+1
drivers/tty/serial/8250/8250_dw.c
··· 714 714 { "APMC0D08", 0}, 715 715 { "AMD0020", 0 }, 716 716 { "AMDI0020", 0 }, 717 + { "AMDI0022", 0 }, 717 718 { "BRCM2032", 0 }, 718 719 { "HISI0031", 0 }, 719 720 { },
+35 -12
drivers/tty/serial/8250/8250_pci.c
··· 56 56 int line[]; 57 57 }; 58 58 59 + #define PCI_DEVICE_ID_HPE_PCI_SERIAL 0x37e 60 + 59 61 static const struct pci_device_id pci_use_msi[] = { 60 62 { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900, 61 63 0xA000, 0x1000) }, ··· 65 63 0xA000, 0x1000) }, 66 64 { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9922, 67 65 0xA000, 0x1000) }, 66 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_HP_3PAR, PCI_DEVICE_ID_HPE_PCI_SERIAL, 67 + PCI_ANY_ID, PCI_ANY_ID) }, 68 68 { } 69 69 }; 70 70 ··· 1999 1995 .subvendor = PCI_ANY_ID, 2000 1996 .subdevice = PCI_ANY_ID, 2001 1997 .init = pci_hp_diva_init, 1998 + .setup = pci_hp_diva_setup, 1999 + }, 2000 + /* 2001 + * HPE PCI serial device 2002 + */ 2003 + { 2004 + .vendor = PCI_VENDOR_ID_HP_3PAR, 2005 + .device = PCI_DEVICE_ID_HPE_PCI_SERIAL, 2006 + .subvendor = PCI_ANY_ID, 2007 + .subdevice = PCI_ANY_ID, 2002 2008 .setup = pci_hp_diva_setup, 2003 2009 }, 2004 2010 /* ··· 3958 3944 uart.port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ; 3959 3945 uart.port.uartclk = board->base_baud * 16; 3960 3946 3961 - if (pci_match_id(pci_use_msi, dev)) { 3962 - dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n"); 3963 - pci_set_master(dev); 3964 - rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES); 3947 + if (board->flags & FL_NOIRQ) { 3948 + uart.port.irq = 0; 3965 3949 } else { 3966 - dev_dbg(&dev->dev, "Using legacy interrupts\n"); 3967 - rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY); 3968 - } 3969 - if (rc < 0) { 3970 - kfree(priv); 3971 - priv = ERR_PTR(rc); 3972 - goto err_deinit; 3950 + if (pci_match_id(pci_use_msi, dev)) { 3951 + dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n"); 3952 + pci_set_master(dev); 3953 + rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES); 3954 + } else { 3955 + dev_dbg(&dev->dev, "Using legacy interrupts\n"); 3956 + rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY); 3957 + } 3958 + if (rc < 0) { 3959 + kfree(priv); 3960 + priv = ERR_PTR(rc); 3961 + goto err_deinit; 3962 + } 3963 + 3964 + uart.port.irq = pci_irq_vector(dev, 0); 3973 3965 } 3974 3966 3975 - uart.port.irq = pci_irq_vector(dev, 0); 3976 3967 uart.port.dev = &dev->dev; 3977 3968 3978 3969 for (i = 0; i < nr_ports; i++) { ··· 4992 4973 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_DIVA_AUX, 4993 4974 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4994 4975 pbn_b2_1_115200 }, 4976 + /* HPE PCI serial device */ 4977 + { PCI_VENDOR_ID_HP_3PAR, PCI_DEVICE_ID_HPE_PCI_SERIAL, 4978 + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4979 + pbn_b1_1_115200 }, 4995 4980 4996 4981 { PCI_VENDOR_ID_DCI, PCI_DEVICE_ID_DCI_PCCOM2, 4997 4982 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+12
drivers/tty/serial/8250/8250_port.c
··· 1809 1809 count = up->tx_loadsz; 1810 1810 do { 1811 1811 serial_out(up, UART_TX, xmit->buf[xmit->tail]); 1812 + if (up->bugs & UART_BUG_TXRACE) { 1813 + /* 1814 + * The Aspeed BMC virtual UARTs have a bug where data 1815 + * may get stuck in the BMC's Tx FIFO from bursts of 1816 + * writes on the APB interface. 1817 + * 1818 + * Delay back-to-back writes by a read cycle to avoid 1819 + * stalling the VUART. Read a register that won't have 1820 + * side-effects and discard the result. 1821 + */ 1822 + serial_in(up, UART_SCR); 1823 + } 1812 1824 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 1813 1825 port->icount.tx++; 1814 1826 if (uart_circ_empty(xmit))
+17 -35
drivers/tty/serial/rp2.c
··· 195 195 void __iomem *bar0; 196 196 void __iomem *bar1; 197 197 spinlock_t card_lock; 198 - struct completion fw_loaded; 199 198 }; 200 199 201 200 #define RP_ID(prod) PCI_VDEVICE(RP, (prod)) ··· 661 662 card->initialized_ports = 0; 662 663 } 663 664 664 - static void rp2_fw_cb(const struct firmware *fw, void *context) 665 + static int rp2_load_firmware(struct rp2_card *card, const struct firmware *fw) 665 666 { 666 - struct rp2_card *card = context; 667 667 resource_size_t phys_base; 668 - int i, rc = -ENOENT; 669 - 670 - if (!fw) { 671 - dev_err(&card->pdev->dev, "cannot find '%s' firmware image\n", 672 - RP2_FW_NAME); 673 - goto no_fw; 674 - } 668 + int i, rc = 0; 675 669 676 670 phys_base = pci_resource_start(card->pdev, 1); 677 671 ··· 710 718 card->initialized_ports++; 711 719 } 712 720 713 - release_firmware(fw); 714 - no_fw: 715 - /* 716 - * rp2_fw_cb() is called from a workqueue long after rp2_probe() 717 - * has already returned success. So if something failed here, 718 - * we'll just leave the now-dormant device in place until somebody 719 - * unbinds it. 720 - */ 721 - if (rc) 722 - dev_warn(&card->pdev->dev, "driver initialization failed\n"); 723 - 724 - complete(&card->fw_loaded); 721 + return rc; 725 722 } 726 723 727 724 static int rp2_probe(struct pci_dev *pdev, 728 725 const struct pci_device_id *id) 729 726 { 727 + const struct firmware *fw; 730 728 struct rp2_card *card; 731 729 struct rp2_uart_port *ports; 732 730 void __iomem * const *bars; ··· 727 745 return -ENOMEM; 728 746 pci_set_drvdata(pdev, card); 729 747 spin_lock_init(&card->card_lock); 730 - init_completion(&card->fw_loaded); 731 748 732 749 rc = pcim_enable_device(pdev); 733 750 if (rc) ··· 759 778 return -ENOMEM; 760 779 card->ports = ports; 761 780 781 + rc = request_firmware(&fw, RP2_FW_NAME, &pdev->dev); 782 + if (rc < 0) { 783 + dev_err(&pdev->dev, "cannot find '%s' firmware image\n", 784 + RP2_FW_NAME); 785 + return rc; 786 + } 787 + 788 + rc = rp2_load_firmware(card, fw); 789 + 790 + release_firmware(fw); 791 + if (rc < 0) 792 + return rc; 793 + 762 794 rc = devm_request_irq(&pdev->dev, pdev->irq, rp2_uart_interrupt, 763 795 IRQF_SHARED, DRV_NAME, card); 764 796 if (rc) 765 797 return rc; 766 - 767 - /* 768 - * Only catastrophic errors (e.g. ENOMEM) are reported here. 769 - * If the FW image is missing, we'll find out in rp2_fw_cb() 770 - * and print an error message. 771 - */ 772 - rc = request_firmware_nowait(THIS_MODULE, 1, RP2_FW_NAME, &pdev->dev, 773 - GFP_KERNEL, card, rp2_fw_cb); 774 - if (rc) 775 - return rc; 776 - dev_dbg(&pdev->dev, "waiting for firmware blob...\n"); 777 798 778 799 return 0; 779 800 } ··· 784 801 { 785 802 struct rp2_card *card = pci_get_drvdata(pdev); 786 803 787 - wait_for_completion(&card->fw_loaded); 788 804 rp2_remove_ports(card); 789 805 } 790 806
+1 -1
drivers/tty/serial/serial-tegra.c
··· 338 338 339 339 do { 340 340 lsr = tegra_uart_read(tup, UART_LSR); 341 - if ((lsr | UART_LSR_TEMT) && !(lsr & UART_LSR_DR)) 341 + if ((lsr & UART_LSR_TEMT) && !(lsr & UART_LSR_DR)) 342 342 break; 343 343 udelay(1); 344 344 } while (--tmout);
+5 -3
drivers/tty/serial/serial_core.c
··· 863 863 goto check_and_exit; 864 864 } 865 865 866 - retval = security_locked_down(LOCKDOWN_TIOCSSERIAL); 867 - if (retval && (change_irq || change_port)) 868 - goto exit; 866 + if (change_irq || change_port) { 867 + retval = security_locked_down(LOCKDOWN_TIOCSSERIAL); 868 + if (retval) 869 + goto exit; 870 + } 869 871 870 872 /* 871 873 * Ask the low level driver to verify the settings.
+2 -2
drivers/tty/serial/sh-sci.c
··· 1023 1023 { 1024 1024 unsigned int bits; 1025 1025 1026 + if (rx_trig >= port->fifosize) 1027 + rx_trig = port->fifosize - 1; 1026 1028 if (rx_trig < 1) 1027 1029 rx_trig = 1; 1028 - if (rx_trig >= port->fifosize) 1029 - rx_trig = port->fifosize; 1030 1030 1031 1031 /* HSCIF can be set to an arbitrary level. */ 1032 1032 if (sci_getreg(port, HSRTRGR)->size) {
+3 -1
drivers/usb/cdns3/cdns3-gadget.c
··· 3268 3268 pm_runtime_get_sync(cdns->dev); 3269 3269 3270 3270 ret = cdns3_gadget_start(cdns); 3271 - if (ret) 3271 + if (ret) { 3272 + pm_runtime_put_sync(cdns->dev); 3272 3273 return ret; 3274 + } 3273 3275 3274 3276 /* 3275 3277 * Because interrupt line can be shared with other components in
+7 -7
drivers/usb/cdns3/cdnsp-gadget.c
··· 422 422 int cdnsp_ep_dequeue(struct cdnsp_ep *pep, struct cdnsp_request *preq) 423 423 { 424 424 struct cdnsp_device *pdev = pep->pdev; 425 - int ret; 425 + int ret_stop = 0; 426 + int ret_rem; 426 427 427 428 trace_cdnsp_request_dequeue(preq); 428 429 429 - if (GET_EP_CTX_STATE(pep->out_ctx) == EP_STATE_RUNNING) { 430 - ret = cdnsp_cmd_stop_ep(pdev, pep); 431 - if (ret) 432 - return ret; 433 - } 430 + if (GET_EP_CTX_STATE(pep->out_ctx) == EP_STATE_RUNNING) 431 + ret_stop = cdnsp_cmd_stop_ep(pdev, pep); 434 432 435 - return cdnsp_remove_request(pdev, preq, pep); 433 + ret_rem = cdnsp_remove_request(pdev, preq, pep); 434 + 435 + return ret_rem ? ret_rem : ret_stop; 436 436 } 437 437 438 438 static void cdnsp_zero_in_ctx(struct cdnsp_device *pdev)
+1
drivers/usb/chipidea/udc.c
··· 2061 2061 ci->gadget.name = ci->platdata->name; 2062 2062 ci->gadget.otg_caps = otg_caps; 2063 2063 ci->gadget.sg_supported = 1; 2064 + ci->gadget.irq = ci->irq; 2064 2065 2065 2066 if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA) 2066 2067 ci->gadget.quirk_avoids_skb_reserve = 1;
+8 -3
drivers/usb/core/devio.c
··· 1218 1218 ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb)); 1219 1219 if (ret) 1220 1220 return ret; 1221 - tbuf = kmalloc(len1, GFP_KERNEL); 1221 + 1222 + /* 1223 + * len1 can be almost arbitrarily large. Don't WARN if it's 1224 + * too big, just fail the request. 1225 + */ 1226 + tbuf = kmalloc(len1, GFP_KERNEL | __GFP_NOWARN); 1222 1227 if (!tbuf) { 1223 1228 ret = -ENOMEM; 1224 1229 goto done; ··· 1701 1696 if (num_sgs) { 1702 1697 as->urb->sg = kmalloc_array(num_sgs, 1703 1698 sizeof(struct scatterlist), 1704 - GFP_KERNEL); 1699 + GFP_KERNEL | __GFP_NOWARN); 1705 1700 if (!as->urb->sg) { 1706 1701 ret = -ENOMEM; 1707 1702 goto error; ··· 1736 1731 (uurb_start - as->usbm->vm_start); 1737 1732 } else { 1738 1733 as->urb->transfer_buffer = kmalloc(uurb->buffer_length, 1739 - GFP_KERNEL); 1734 + GFP_KERNEL | __GFP_NOWARN); 1740 1735 if (!as->urb->transfer_buffer) { 1741 1736 ret = -ENOMEM; 1742 1737 goto error;
+7 -6
drivers/usb/dwc3/gadget.c
··· 1244 1244 req->start_sg = sg_next(s); 1245 1245 1246 1246 req->num_queued_sgs++; 1247 + req->num_pending_sgs--; 1247 1248 1248 1249 /* 1249 1250 * The number of pending SG entries may not correspond to the ··· 1252 1251 * don't include unused SG entries. 1253 1252 */ 1254 1253 if (length == 0) { 1255 - req->num_pending_sgs -= req->request.num_mapped_sgs - req->num_queued_sgs; 1254 + req->num_pending_sgs = 0; 1256 1255 break; 1257 1256 } 1258 1257 ··· 2874 2873 struct dwc3_trb *trb = &dep->trb_pool[dep->trb_dequeue]; 2875 2874 struct scatterlist *sg = req->sg; 2876 2875 struct scatterlist *s; 2877 - unsigned int pending = req->num_pending_sgs; 2876 + unsigned int num_queued = req->num_queued_sgs; 2878 2877 unsigned int i; 2879 2878 int ret = 0; 2880 2879 2881 - for_each_sg(sg, s, pending, i) { 2880 + for_each_sg(sg, s, num_queued, i) { 2882 2881 trb = &dep->trb_pool[dep->trb_dequeue]; 2883 2882 2884 2883 req->sg = sg_next(s); 2885 - req->num_pending_sgs--; 2884 + req->num_queued_sgs--; 2886 2885 2887 2886 ret = dwc3_gadget_ep_reclaim_completed_trb(dep, req, 2888 2887 trb, event, status, true); ··· 2905 2904 2906 2905 static bool dwc3_gadget_ep_request_completed(struct dwc3_request *req) 2907 2906 { 2908 - return req->num_pending_sgs == 0; 2907 + return req->num_pending_sgs == 0 && req->num_queued_sgs == 0; 2909 2908 } 2910 2909 2911 2910 static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, ··· 2914 2913 { 2915 2914 int ret; 2916 2915 2917 - if (req->num_pending_sgs) 2916 + if (req->request.num_mapped_sgs) 2918 2917 ret = dwc3_gadget_ep_reclaim_trb_sg(dep, req, event, 2919 2918 status); 2920 2919 else
+3 -2
drivers/usb/gadget/udc/renesas_usb3.c
··· 1488 1488 struct renesas_usb3_request *usb3_req) 1489 1489 { 1490 1490 struct renesas_usb3 *usb3 = usb3_ep_to_usb3(usb3_ep); 1491 - struct renesas_usb3_request *usb3_req_first = usb3_get_request(usb3_ep); 1491 + struct renesas_usb3_request *usb3_req_first; 1492 1492 unsigned long flags; 1493 1493 int ret = -EAGAIN; 1494 1494 u32 enable_bits = 0; ··· 1496 1496 spin_lock_irqsave(&usb3->lock, flags); 1497 1497 if (usb3_ep->halt || usb3_ep->started) 1498 1498 goto out; 1499 - if (usb3_req != usb3_req_first) 1499 + usb3_req_first = __usb3_get_request(usb3_ep); 1500 + if (!usb3_req_first || usb3_req != usb3_req_first) 1500 1501 goto out; 1501 1502 1502 1503 if (usb3_pn_change(usb3, usb3_ep->num) < 0)
+7 -7
drivers/usb/host/xhci-ring.c
··· 828 828 list_for_each_entry_safe(td, tmp_td, &ep->cancelled_td_list, 829 829 cancelled_td_list) { 830 830 831 - /* 832 - * Doesn't matter what we pass for status, since the core will 833 - * just overwrite it (because the URB has been unlinked). 834 - */ 835 831 ring = xhci_urb_to_transfer_ring(ep->xhci, td->urb); 836 832 837 833 if (td->cancel_status == TD_CLEARED) 838 - xhci_td_cleanup(ep->xhci, td, ring, 0); 834 + xhci_td_cleanup(ep->xhci, td, ring, td->status); 839 835 840 836 if (ep->xhci->xhc_state & XHCI_STATE_DYING) 841 837 return; ··· 933 937 continue; 934 938 } 935 939 /* 936 - * If ring stopped on the TD we need to cancel, then we have to 940 + * If a ring stopped on the TD we need to cancel then we have to 937 941 * move the xHC endpoint ring dequeue pointer past this TD. 942 + * Rings halted due to STALL may show hw_deq is past the stalled 943 + * TD, but still require a set TR Deq command to flush xHC cache. 938 944 */ 939 945 hw_deq = xhci_get_hw_deq(xhci, ep->vdev, ep->ep_index, 940 946 td->urb->stream_id); 941 947 hw_deq &= ~0xf; 942 948 943 - if (trb_in_td(xhci, td->start_seg, td->first_trb, 949 + if (td->cancel_status == TD_HALTED) { 950 + cached_td = td; 951 + } else if (trb_in_td(xhci, td->start_seg, td->first_trb, 944 952 td->last_trb, hw_deq, false)) { 945 953 switch (td->cancel_status) { 946 954 case TD_CLEARED: /* TD is already no-op */
+2 -2
drivers/usb/misc/trancevibrator.c
··· 61 61 /* Set speed */ 62 62 retval = usb_control_msg(tv->udev, usb_sndctrlpipe(tv->udev, 0), 63 63 0x01, /* vendor request: set speed */ 64 - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, 64 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, 65 65 tv->speed, /* speed value */ 66 - 0, NULL, 0, USB_CTRL_GET_TIMEOUT); 66 + 0, NULL, 0, USB_CTRL_SET_TIMEOUT); 67 67 if (retval) { 68 68 tv->speed = old; 69 69 dev_dbg(&tv->udev->dev, "retval = %d\n", retval);
+1
drivers/usb/misc/uss720.c
··· 736 736 parport_announce_port(pp); 737 737 738 738 usb_set_intfdata(intf, pp); 739 + usb_put_dev(usbdev); 739 740 return 0; 740 741 741 742 probe_abort:
+3
drivers/usb/serial/ftdi_sio.c
··· 1034 1034 /* Sienna devices */ 1035 1035 { USB_DEVICE(FTDI_VID, FTDI_SIENNA_PID) }, 1036 1036 { USB_DEVICE(ECHELON_VID, ECHELON_U20_PID) }, 1037 + /* IDS GmbH devices */ 1038 + { USB_DEVICE(IDS_VID, IDS_SI31A_PID) }, 1039 + { USB_DEVICE(IDS_VID, IDS_CM31A_PID) }, 1037 1040 /* U-Blox devices */ 1038 1041 { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ZED_PID) }, 1039 1042 { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ODIN_PID) },
+7
drivers/usb/serial/ftdi_sio_ids.h
··· 1568 1568 #define UNJO_ISODEBUG_V1_PID 0x150D 1569 1569 1570 1570 /* 1571 + * IDS GmbH 1572 + */ 1573 + #define IDS_VID 0x2CAF 1574 + #define IDS_SI31A_PID 0x13A2 1575 + #define IDS_CM31A_PID 0x13A3 1576 + 1577 + /* 1571 1578 * U-Blox products (http://www.u-blox.com). 1572 1579 */ 1573 1580 #define UBLOX_VID 0x1546
+4
drivers/usb/serial/option.c
··· 1240 1240 .driver_info = NCTRL(0) | RSVD(1) }, 1241 1241 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1901, 0xff), /* Telit LN940 (MBIM) */ 1242 1242 .driver_info = NCTRL(0) }, 1243 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x7010, 0xff), /* Telit LE910-S1 (RNDIS) */ 1244 + .driver_info = NCTRL(2) }, 1245 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x7011, 0xff), /* Telit LE910-S1 (ECM) */ 1246 + .driver_info = NCTRL(2) }, 1243 1247 { USB_DEVICE(TELIT_VENDOR_ID, 0x9010), /* Telit SBL FN980 flashing device */ 1244 1248 .driver_info = NCTRL(0) | ZLP }, 1245 1249 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
+1
drivers/usb/serial/pl2303.c
··· 113 113 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) }, 114 114 { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) }, 115 115 { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) }, 116 + { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530GC_PRODUCT_ID) }, 116 117 { USB_DEVICE(SMART_VENDOR_ID, SMART_PRODUCT_ID) }, 117 118 { USB_DEVICE(AT_VENDOR_ID, AT_VTKIT3_PRODUCT_ID) }, 118 119 { } /* Terminating entry */
+1
drivers/usb/serial/pl2303.h
··· 158 158 /* ADLINK ND-6530 RS232,RS485 and RS422 adapter */ 159 159 #define ADLINK_VENDOR_ID 0x0b63 160 160 #define ADLINK_ND6530_PRODUCT_ID 0x6530 161 + #define ADLINK_ND6530GC_PRODUCT_ID 0x653a 161 162 162 163 /* SMART USB Serial Adapter */ 163 164 #define SMART_VENDOR_ID 0x0b8c
+3
drivers/usb/serial/ti_usb_3410_5052.c
··· 37 37 /* Vendor and product ids */ 38 38 #define TI_VENDOR_ID 0x0451 39 39 #define IBM_VENDOR_ID 0x04b3 40 + #define STARTECH_VENDOR_ID 0x14b0 40 41 #define TI_3410_PRODUCT_ID 0x3410 41 42 #define IBM_4543_PRODUCT_ID 0x4543 42 43 #define IBM_454B_PRODUCT_ID 0x454b ··· 371 370 { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1131_PRODUCT_ID) }, 372 371 { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1150_PRODUCT_ID) }, 373 372 { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1151_PRODUCT_ID) }, 373 + { USB_DEVICE(STARTECH_VENDOR_ID, TI_3410_PRODUCT_ID) }, 374 374 { } /* terminator */ 375 375 }; 376 376 ··· 410 408 { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1131_PRODUCT_ID) }, 411 409 { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1150_PRODUCT_ID) }, 412 410 { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1151_PRODUCT_ID) }, 411 + { USB_DEVICE(STARTECH_VENDOR_ID, TI_3410_PRODUCT_ID) }, 413 412 { } /* terminator */ 414 413 }; 415 414
+4 -3
drivers/usb/typec/mux.c
··· 191 191 bool match; 192 192 int nval; 193 193 u16 *val; 194 + int ret; 194 195 int i; 195 196 196 197 /* ··· 219 218 if (!val) 220 219 return ERR_PTR(-ENOMEM); 221 220 222 - nval = fwnode_property_read_u16_array(fwnode, "svid", val, nval); 223 - if (nval < 0) { 221 + ret = fwnode_property_read_u16_array(fwnode, "svid", val, nval); 222 + if (ret < 0) { 224 223 kfree(val); 225 - return ERR_PTR(nval); 224 + return ERR_PTR(ret); 226 225 } 227 226 228 227 for (i = 0; i < nval; i++) {
+36 -3
drivers/usb/typec/tcpm/tcpm.c
··· 1550 1550 if (PD_VDO_SVDM_VER(p[0]) < svdm_version) 1551 1551 typec_partner_set_svdm_version(port->partner, 1552 1552 PD_VDO_SVDM_VER(p[0])); 1553 + 1554 + tcpm_ams_start(port, DISCOVER_IDENTITY); 1553 1555 /* 6.4.4.3.1: Only respond as UFP (device) */ 1554 1556 if (port->data_role == TYPEC_DEVICE && 1555 1557 port->nr_snk_vdo) { ··· 1570 1568 } 1571 1569 break; 1572 1570 case CMD_DISCOVER_SVID: 1571 + tcpm_ams_start(port, DISCOVER_SVIDS); 1573 1572 break; 1574 1573 case CMD_DISCOVER_MODES: 1574 + tcpm_ams_start(port, DISCOVER_MODES); 1575 1575 break; 1576 1576 case CMD_ENTER_MODE: 1577 + tcpm_ams_start(port, DFP_TO_UFP_ENTER_MODE); 1577 1578 break; 1578 1579 case CMD_EXIT_MODE: 1580 + tcpm_ams_start(port, DFP_TO_UFP_EXIT_MODE); 1579 1581 break; 1580 1582 case CMD_ATTENTION: 1583 + tcpm_ams_start(port, ATTENTION); 1581 1584 /* Attention command does not have response */ 1582 1585 *adev_action = ADEV_ATTENTION; 1583 1586 return 0; ··· 2294 2287 bool frs_enable; 2295 2288 int ret; 2296 2289 2290 + if (tcpm_vdm_ams(port) && type != PD_DATA_VENDOR_DEF) { 2291 + port->vdm_state = VDM_STATE_ERR_BUSY; 2292 + tcpm_ams_finish(port); 2293 + mod_vdm_delayed_work(port, 0); 2294 + } 2295 + 2297 2296 switch (type) { 2298 2297 case PD_DATA_SOURCE_CAP: 2299 2298 for (i = 0; i < cnt; i++) ··· 2430 2417 NONE_AMS); 2431 2418 break; 2432 2419 case PD_DATA_VENDOR_DEF: 2433 - tcpm_handle_vdm_request(port, msg->payload, cnt); 2420 + if (tcpm_vdm_ams(port) || port->nr_snk_vdo) 2421 + tcpm_handle_vdm_request(port, msg->payload, cnt); 2422 + else if (port->negotiated_rev > PD_REV20) 2423 + tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS); 2434 2424 break; 2435 2425 case PD_DATA_BIST: 2436 2426 port->bist_request = le32_to_cpu(msg->payload[0]); ··· 2474 2458 { 2475 2459 enum pd_ctrl_msg_type type = pd_header_type_le(msg->header); 2476 2460 enum tcpm_state next_state; 2461 + 2462 + /* 2463 + * Stop VDM state machine if interrupted by other Messages while NOT_SUPP is allowed in 2464 + * VDM AMS if waiting for VDM responses and will be handled later. 2465 + */ 2466 + if (tcpm_vdm_ams(port) && type != PD_CTRL_NOT_SUPP && type != PD_CTRL_GOOD_CRC) { 2467 + port->vdm_state = VDM_STATE_ERR_BUSY; 2468 + tcpm_ams_finish(port); 2469 + mod_vdm_delayed_work(port, 0); 2470 + } 2477 2471 2478 2472 switch (type) { 2479 2473 case PD_CTRL_GOOD_CRC: ··· 2743 2717 enum pd_ext_msg_type type = pd_header_type_le(msg->header); 2744 2718 unsigned int data_size = pd_ext_header_data_size_le(msg->ext_msg.header); 2745 2719 2746 - if (!(msg->ext_msg.header & PD_EXT_HDR_CHUNKED)) { 2720 + /* stopping VDM state machine if interrupted by other Messages */ 2721 + if (tcpm_vdm_ams(port)) { 2722 + port->vdm_state = VDM_STATE_ERR_BUSY; 2723 + tcpm_ams_finish(port); 2724 + mod_vdm_delayed_work(port, 0); 2725 + } 2726 + 2727 + if (!(le16_to_cpu(msg->ext_msg.header) & PD_EXT_HDR_CHUNKED)) { 2747 2728 tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS); 2748 2729 tcpm_log(port, "Unchunked extended messages unsupported"); 2749 2730 return; ··· 2844 2811 "Data role mismatch, initiating error recovery"); 2845 2812 tcpm_set_state(port, ERROR_RECOVERY, 0); 2846 2813 } else { 2847 - if (msg->header & PD_HEADER_EXT_HDR) 2814 + if (le16_to_cpu(msg->header) & PD_HEADER_EXT_HDR) 2848 2815 tcpm_pd_ext_msg_request(port, msg); 2849 2816 else if (cnt) 2850 2817 tcpm_pd_data_request(port, msg);
+1 -1
drivers/usb/typec/ucsi/ucsi.c
··· 717 717 ucsi_send_command(con->ucsi, command, NULL, 0); 718 718 719 719 /* 3. ACK connector change */ 720 - clear_bit(EVENT_PENDING, &ucsi->flags); 721 720 ret = ucsi_acknowledge_connector_change(ucsi); 721 + clear_bit(EVENT_PENDING, &ucsi->flags); 722 722 if (ret) { 723 723 dev_err(ucsi->dev, "%s: ACK failed (%d)", __func__, ret); 724 724 goto out_unlock;
+18 -1
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 15 15 #include <linux/mlx5/vport.h> 16 16 #include <linux/mlx5/fs.h> 17 17 #include <linux/mlx5/mlx5_ifc_vdpa.h> 18 + #include <linux/mlx5/mpfs.h> 18 19 #include "mlx5_vdpa.h" 19 20 20 21 MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>"); ··· 1860 1859 static void mlx5_vdpa_free(struct vdpa_device *vdev) 1861 1860 { 1862 1861 struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev); 1862 + struct mlx5_core_dev *pfmdev; 1863 1863 struct mlx5_vdpa_net *ndev; 1864 1864 1865 1865 ndev = to_mlx5_vdpa_ndev(mvdev); 1866 1866 1867 1867 free_resources(ndev); 1868 + if (!is_zero_ether_addr(ndev->config.mac)) { 1869 + pfmdev = pci_get_drvdata(pci_physfn(mvdev->mdev->pdev)); 1870 + mlx5_mpfs_del_mac(pfmdev, ndev->config.mac); 1871 + } 1868 1872 mlx5_vdpa_free_resources(&ndev->mvdev); 1869 1873 mutex_destroy(&ndev->reslock); 1870 1874 } ··· 1996 1990 { 1997 1991 struct mlx5_vdpa_mgmtdev *mgtdev = container_of(v_mdev, struct mlx5_vdpa_mgmtdev, mgtdev); 1998 1992 struct virtio_net_config *config; 1993 + struct mlx5_core_dev *pfmdev; 1999 1994 struct mlx5_vdpa_dev *mvdev; 2000 1995 struct mlx5_vdpa_net *ndev; 2001 1996 struct mlx5_core_dev *mdev; ··· 2030 2023 if (err) 2031 2024 goto err_mtu; 2032 2025 2026 + if (!is_zero_ether_addr(config->mac)) { 2027 + pfmdev = pci_get_drvdata(pci_physfn(mdev->pdev)); 2028 + err = mlx5_mpfs_add_mac(pfmdev, config->mac); 2029 + if (err) 2030 + goto err_mtu; 2031 + } 2032 + 2033 2033 mvdev->vdev.dma_dev = mdev->device; 2034 2034 err = mlx5_vdpa_alloc_resources(&ndev->mvdev); 2035 2035 if (err) 2036 - goto err_mtu; 2036 + goto err_mpfs; 2037 2037 2038 2038 err = alloc_resources(ndev); 2039 2039 if (err) ··· 2058 2044 free_resources(ndev); 2059 2045 err_res: 2060 2046 mlx5_vdpa_free_resources(&ndev->mvdev); 2047 + err_mpfs: 2048 + if (!is_zero_ether_addr(config->mac)) 2049 + mlx5_mpfs_del_mac(pfmdev, config->mac); 2061 2050 err_mtu: 2062 2051 mutex_destroy(&ndev->reslock); 2063 2052 put_device(&mvdev->vdev.dev);
+1 -1
drivers/video/fbdev/hgafb.c
··· 558 558 int ret; 559 559 560 560 ret = hga_card_detect(); 561 - if (!ret) 561 + if (ret) 562 562 return ret; 563 563 564 564 printk(KERN_INFO "hgafb: %s with %ldK of memory detected.\n",
+5
fs/afs/cmservice.c
··· 322 322 return ret; 323 323 324 324 call->unmarshall++; 325 + fallthrough; 326 + 325 327 case 5: 326 328 break; 327 329 } ··· 420 418 r->node[loop] = ntohl(b[loop + 5]); 421 419 422 420 call->unmarshall++; 421 + fallthrough; 423 422 424 423 case 2: 425 424 break; ··· 533 530 r->node[loop] = ntohl(b[loop + 5]); 534 531 535 532 call->unmarshall++; 533 + fallthrough; 536 534 537 535 case 2: 538 536 break; ··· 667 663 668 664 afs_extract_to_tmp(call); 669 665 call->unmarshall++; 666 + fallthrough; 670 667 671 668 case 3: 672 669 break;
+3 -1
fs/afs/dir.c
··· 1919 1919 new_inode = d_inode(new_dentry); 1920 1920 if (new_inode) { 1921 1921 spin_lock(&new_inode->i_lock); 1922 - if (new_inode->i_nlink > 0) 1922 + if (S_ISDIR(new_inode->i_mode)) 1923 + clear_nlink(new_inode); 1924 + else if (new_inode->i_nlink > 0) 1923 1925 drop_nlink(new_inode); 1924 1926 spin_unlock(&new_inode->i_lock); 1925 1927 }
+4
fs/afs/fsclient.c
··· 388 388 req->file_size = vp->scb.status.size; 389 389 390 390 call->unmarshall++; 391 + fallthrough; 391 392 392 393 case 5: 393 394 break; ··· 1409 1408 _debug("motd '%s'", p); 1410 1409 1411 1410 call->unmarshall++; 1411 + fallthrough; 1412 1412 1413 1413 case 8: 1414 1414 break; ··· 1847 1845 xdr_decode_AFSVolSync(&bp, &op->volsync); 1848 1846 1849 1847 call->unmarshall++; 1848 + fallthrough; 1850 1849 1851 1850 case 6: 1852 1851 break; ··· 1982 1979 xdr_decode_AFSVolSync(&bp, &op->volsync); 1983 1980 1984 1981 call->unmarshall++; 1982 + fallthrough; 1985 1983 1986 1984 case 4: 1987 1985 break;
+1
fs/afs/vlclient.c
··· 593 593 if (ret < 0) 594 594 return ret; 595 595 call->unmarshall = 6; 596 + fallthrough; 596 597 597 598 case 6: 598 599 break;
+19 -6
fs/cifs/cifs_ioctl.h
··· 72 72 } __packed; 73 73 74 74 /* 75 - * Dump full key (32 byte encrypt/decrypt keys instead of 16 bytes) 76 - * is needed if GCM256 (stronger encryption) negotiated 75 + * Dump variable-sized keys 77 76 */ 78 77 struct smb3_full_key_debug_info { 79 - __u64 Suid; 78 + /* INPUT: size of userspace buffer */ 79 + __u32 in_size; 80 + 81 + /* 82 + * INPUT: 0 for current user, otherwise session to dump 83 + * OUTPUT: session id that was dumped 84 + */ 85 + __u64 session_id; 80 86 __u16 cipher_type; 81 - __u8 auth_key[16]; /* SMB2_NTLMV2_SESSKEY_SIZE */ 82 - __u8 smb3encryptionkey[32]; /* SMB3_ENC_DEC_KEY_SIZE */ 83 - __u8 smb3decryptionkey[32]; /* SMB3_ENC_DEC_KEY_SIZE */ 87 + __u8 session_key_length; 88 + __u8 server_in_key_length; 89 + __u8 server_out_key_length; 90 + __u8 data[]; 91 + /* 92 + * return this struct with the keys appended at the end: 93 + * __u8 session_key[session_key_length]; 94 + * __u8 server_in_key[server_in_key_length]; 95 + * __u8 server_out_key[server_out_key_length]; 96 + */ 84 97 } __packed; 85 98 86 99 struct smb3_notify {
+2 -1
fs/cifs/cifspdu.h
··· 148 148 #define SMB3_SIGN_KEY_SIZE (16) 149 149 150 150 /* 151 - * Size of the smb3 encryption/decryption keys 151 + * Size of the smb3 encryption/decryption key storage. 152 + * This size is big enough to store any cipher key types. 152 153 */ 153 154 #define SMB3_ENC_DEC_KEY_SIZE (32) 154 155
+104 -37
fs/cifs/ioctl.c
··· 33 33 #include "cifsfs.h" 34 34 #include "cifs_ioctl.h" 35 35 #include "smb2proto.h" 36 + #include "smb2glob.h" 36 37 #include <linux/btrfs.h> 37 38 38 39 static long cifs_ioctl_query_info(unsigned int xid, struct file *filep, ··· 215 214 return 0; 216 215 } 217 216 218 - static int cifs_dump_full_key(struct cifs_tcon *tcon, unsigned long arg) 217 + static int cifs_dump_full_key(struct cifs_tcon *tcon, struct smb3_full_key_debug_info __user *in) 219 218 { 220 - struct smb3_full_key_debug_info pfull_key_inf; 221 - __u64 suid; 222 - struct list_head *tmp; 219 + struct smb3_full_key_debug_info out; 223 220 struct cifs_ses *ses; 221 + int rc = 0; 224 222 bool found = false; 223 + u8 __user *end; 225 224 226 - if (!smb3_encryption_required(tcon)) 227 - return -EOPNOTSUPP; 225 + if (!smb3_encryption_required(tcon)) { 226 + rc = -EOPNOTSUPP; 227 + goto out; 228 + } 228 229 229 - ses = tcon->ses; /* default to user id for current user */ 230 - if (get_user(suid, (__u64 __user *)arg)) 231 - suid = 0; 232 - if (suid) { 233 - /* search to see if there is a session with a matching SMB UID */ 230 + /* copy user input into our output buffer */ 231 + if (copy_from_user(&out, in, sizeof(out))) { 232 + rc = -EINVAL; 233 + goto out; 234 + } 235 + 236 + if (!out.session_id) { 237 + /* if ses id is 0, use current user session */ 238 + ses = tcon->ses; 239 + } else { 240 + /* otherwise if a session id is given, look for it in all our sessions */ 241 + struct cifs_ses *ses_it = NULL; 242 + struct TCP_Server_Info *server_it = NULL; 243 + 234 244 spin_lock(&cifs_tcp_ses_lock); 235 - list_for_each(tmp, &tcon->ses->server->smb_ses_list) { 236 - ses = list_entry(tmp, struct cifs_ses, smb_ses_list); 237 - if (ses->Suid == suid) { 238 - found = true; 239 - break; 245 + list_for_each_entry(server_it, &cifs_tcp_ses_list, tcp_ses_list) { 246 + list_for_each_entry(ses_it, &server_it->smb_ses_list, smb_ses_list) { 247 + if (ses_it->Suid == out.session_id) { 248 + ses = ses_it; 249 + /* 250 + * since we are using the session outside the crit 251 + * section, we need to make sure it won't be released 252 + * so increment its refcount 253 + */ 254 + ses->ses_count++; 255 + found = true; 256 + goto search_end; 257 + } 240 258 } 241 259 } 260 + search_end: 242 261 spin_unlock(&cifs_tcp_ses_lock); 243 - if (found == false) 244 - return -EINVAL; 245 - } /* else uses default user's SMB UID (ie current user) */ 262 + if (!found) { 263 + rc = -ENOENT; 264 + goto out; 265 + } 266 + } 246 267 247 - pfull_key_inf.cipher_type = le16_to_cpu(ses->server->cipher_type); 248 - pfull_key_inf.Suid = ses->Suid; 249 - memcpy(pfull_key_inf.auth_key, ses->auth_key.response, 250 - 16 /* SMB2_NTLMV2_SESSKEY_SIZE */); 251 - memcpy(pfull_key_inf.smb3decryptionkey, ses->smb3decryptionkey, 252 - 32 /* SMB3_ENC_DEC_KEY_SIZE */); 253 - memcpy(pfull_key_inf.smb3encryptionkey, 254 - ses->smb3encryptionkey, 32 /* SMB3_ENC_DEC_KEY_SIZE */); 255 - if (copy_to_user((void __user *)arg, &pfull_key_inf, 256 - sizeof(struct smb3_full_key_debug_info))) 257 - return -EFAULT; 268 + switch (ses->server->cipher_type) { 269 + case SMB2_ENCRYPTION_AES128_CCM: 270 + case SMB2_ENCRYPTION_AES128_GCM: 271 + out.session_key_length = CIFS_SESS_KEY_SIZE; 272 + out.server_in_key_length = out.server_out_key_length = SMB3_GCM128_CRYPTKEY_SIZE; 273 + break; 274 + case SMB2_ENCRYPTION_AES256_CCM: 275 + case SMB2_ENCRYPTION_AES256_GCM: 276 + out.session_key_length = CIFS_SESS_KEY_SIZE; 277 + out.server_in_key_length = out.server_out_key_length = SMB3_GCM256_CRYPTKEY_SIZE; 278 + break; 279 + default: 280 + rc = -EOPNOTSUPP; 281 + goto out; 282 + } 258 283 259 - return 0; 284 + /* check if user buffer is big enough to store all the keys */ 285 + if (out.in_size < sizeof(out) + out.session_key_length + out.server_in_key_length 286 + + out.server_out_key_length) { 287 + rc = -ENOBUFS; 288 + goto out; 289 + } 290 + 291 + out.session_id = ses->Suid; 292 + out.cipher_type = le16_to_cpu(ses->server->cipher_type); 293 + 294 + /* overwrite user input with our output */ 295 + if (copy_to_user(in, &out, sizeof(out))) { 296 + rc = -EINVAL; 297 + goto out; 298 + } 299 + 300 + /* append all the keys at the end of the user buffer */ 301 + end = in->data; 302 + if (copy_to_user(end, ses->auth_key.response, out.session_key_length)) { 303 + rc = -EINVAL; 304 + goto out; 305 + } 306 + end += out.session_key_length; 307 + 308 + if (copy_to_user(end, ses->smb3encryptionkey, out.server_in_key_length)) { 309 + rc = -EINVAL; 310 + goto out; 311 + } 312 + end += out.server_in_key_length; 313 + 314 + if (copy_to_user(end, ses->smb3decryptionkey, out.server_out_key_length)) { 315 + rc = -EINVAL; 316 + goto out; 317 + } 318 + 319 + out: 320 + if (found) 321 + cifs_put_smb_ses(ses); 322 + return rc; 260 323 } 261 324 262 325 long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) ··· 436 371 rc = -EOPNOTSUPP; 437 372 break; 438 373 case CIFS_DUMP_KEY: 374 + /* 375 + * Dump encryption keys. This is an old ioctl that only 376 + * handles AES-128-{CCM,GCM}. 377 + */ 439 378 if (pSMBFile == NULL) 440 379 break; 441 380 if (!capable(CAP_SYS_ADMIN)) { ··· 467 398 else 468 399 rc = 0; 469 400 break; 470 - /* 471 - * Dump full key (32 bytes instead of 16 bytes) is 472 - * needed if GCM256 (stronger encryption) negotiated 473 - */ 474 401 case CIFS_DUMP_FULL_KEY: 402 + /* 403 + * Dump encryption keys (handles any key sizes) 404 + */ 475 405 if (pSMBFile == NULL) 476 406 break; 477 407 if (!capable(CAP_SYS_ADMIN)) { ··· 478 410 break; 479 411 } 480 412 tcon = tlink_tcon(pSMBFile->tlink); 481 - rc = cifs_dump_full_key(tcon, arg); 482 - 413 + rc = cifs_dump_full_key(tcon, (void __user *)arg); 483 414 break; 484 415 case CIFS_IOC_NOTIFY: 485 416 if (!S_ISDIR(inode->i_mode)) {
+7
fs/cifs/smb2pdu.c
··· 958 958 /* Internal types */ 959 959 server->capabilities |= SMB2_NT_FIND | SMB2_LARGE_FILES; 960 960 961 + /* 962 + * SMB3.0 supports only 1 cipher and doesn't have a encryption neg context 963 + * Set the cipher type manually. 964 + */ 965 + if (server->dialect == SMB30_PROT_ID && (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)) 966 + server->cipher_type = SMB2_ENCRYPTION_AES128_CCM; 967 + 961 968 security_blob = smb2_get_data_area_len(&blob_offset, &blob_length, 962 969 (struct smb2_sync_hdr *)rsp); 963 970 /*
+17 -12
fs/cifs/trace.h
··· 12 12 13 13 #include <linux/tracepoint.h> 14 14 15 + /* 16 + * Please use this 3-part article as a reference for writing new tracepoints: 17 + * https://lwn.net/Articles/379903/ 18 + */ 19 + 15 20 /* For logging errors in read or write */ 16 21 DECLARE_EVENT_CLASS(smb3_rw_err_class, 17 22 TP_PROTO(unsigned int xid, ··· 534 529 TP_ARGS(xid, func_name, rc), 535 530 TP_STRUCT__entry( 536 531 __field(unsigned int, xid) 537 - __field(const char *, func_name) 532 + __string(func_name, func_name) 538 533 __field(int, rc) 539 534 ), 540 535 TP_fast_assign( 541 536 __entry->xid = xid; 542 - __entry->func_name = func_name; 537 + __assign_str(func_name, func_name); 543 538 __entry->rc = rc; 544 539 ), 545 540 TP_printk("\t%s: xid=%u rc=%d", 546 - __entry->func_name, __entry->xid, __entry->rc) 541 + __get_str(func_name), __entry->xid, __entry->rc) 547 542 ) 548 543 549 544 #define DEFINE_SMB3_EXIT_ERR_EVENT(name) \ ··· 588 583 TP_ARGS(xid, func_name), 589 584 TP_STRUCT__entry( 590 585 __field(unsigned int, xid) 591 - __field(const char *, func_name) 586 + __string(func_name, func_name) 592 587 ), 593 588 TP_fast_assign( 594 589 __entry->xid = xid; 595 - __entry->func_name = func_name; 590 + __assign_str(func_name, func_name); 596 591 ), 597 592 TP_printk("\t%s: xid=%u", 598 - __entry->func_name, __entry->xid) 593 + __get_str(func_name), __entry->xid) 599 594 ) 600 595 601 596 #define DEFINE_SMB3_ENTER_EXIT_EVENT(name) \ ··· 862 857 TP_STRUCT__entry( 863 858 __field(__u64, currmid) 864 859 __field(__u64, conn_id) 865 - __field(char *, hostname) 860 + __string(hostname, hostname) 866 861 ), 867 862 TP_fast_assign( 868 863 __entry->currmid = currmid; 869 864 __entry->conn_id = conn_id; 870 - __entry->hostname = hostname; 865 + __assign_str(hostname, hostname); 871 866 ), 872 867 TP_printk("conn_id=0x%llx server=%s current_mid=%llu", 873 868 __entry->conn_id, 874 - __entry->hostname, 869 + __get_str(hostname), 875 870 __entry->currmid) 876 871 ) 877 872 ··· 896 891 TP_STRUCT__entry( 897 892 __field(__u64, currmid) 898 893 __field(__u64, conn_id) 899 - __field(char *, hostname) 894 + __string(hostname, hostname) 900 895 __field(int, credits) 901 896 __field(int, credits_to_add) 902 897 __field(int, in_flight) ··· 904 899 TP_fast_assign( 905 900 __entry->currmid = currmid; 906 901 __entry->conn_id = conn_id; 907 - __entry->hostname = hostname; 902 + __assign_str(hostname, hostname); 908 903 __entry->credits = credits; 909 904 __entry->credits_to_add = credits_to_add; 910 905 __entry->in_flight = in_flight; ··· 912 907 TP_printk("conn_id=0x%llx server=%s current_mid=%llu " 913 908 "credits=%d credit_change=%d in_flight=%d", 914 909 __entry->conn_id, 915 - __entry->hostname, 910 + __get_str(hostname), 916 911 __entry->currmid, 917 912 __entry->credits, 918 913 __entry->credits_to_add,
+6 -3
fs/debugfs/inode.c
··· 45 45 static int debugfs_setattr(struct user_namespace *mnt_userns, 46 46 struct dentry *dentry, struct iattr *ia) 47 47 { 48 - int ret = security_locked_down(LOCKDOWN_DEBUGFS); 48 + int ret; 49 49 50 - if (ret && (ia->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID))) 51 - return ret; 50 + if (ia->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)) { 51 + ret = security_locked_down(LOCKDOWN_DEBUGFS); 52 + if (ret) 53 + return ret; 54 + } 52 55 return simple_setattr(&init_user_ns, dentry, ia); 53 56 } 54 57
+7 -2
fs/gfs2/file.c
··· 540 540 struct gfs2_inode *ip = GFS2_I(inode); 541 541 struct gfs2_holder gh; 542 542 vm_fault_t ret; 543 + u16 state; 543 544 int err; 544 545 545 - gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &gh); 546 + state = (vmf->flags & FAULT_FLAG_WRITE) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; 547 + gfs2_holder_init(ip->i_gl, state, 0, &gh); 546 548 err = gfs2_glock_nq(&gh); 547 549 if (err) { 548 550 ret = block_page_mkwrite_return(err); ··· 913 911 current->backing_dev_info = inode_to_bdi(inode); 914 912 buffered = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); 915 913 current->backing_dev_info = NULL; 916 - if (unlikely(buffered <= 0)) 914 + if (unlikely(buffered <= 0)) { 915 + if (!ret) 916 + ret = buffered; 917 917 goto out_unlock; 918 + } 918 919 919 920 /* 920 921 * We need to ensure that the page cache pages are written to
+24 -4
fs/gfs2/glock.c
··· 582 582 spin_unlock(&gl->gl_lockref.lock); 583 583 } 584 584 585 + static bool is_system_glock(struct gfs2_glock *gl) 586 + { 587 + struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; 588 + struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); 589 + 590 + if (gl == m_ip->i_gl) 591 + return true; 592 + return false; 593 + } 594 + 585 595 /** 586 596 * do_xmote - Calls the DLM to change the state of a lock 587 597 * @gl: The lock state ··· 681 671 * to see sd_log_error and withdraw, and in the meantime, requeue the 682 672 * work for later. 683 673 * 674 + * We make a special exception for some system glocks, such as the 675 + * system statfs inode glock, which needs to be granted before the 676 + * gfs2_quotad daemon can exit, and that exit needs to finish before 677 + * we can unmount the withdrawn file system. 678 + * 684 679 * However, if we're just unlocking the lock (say, for unmount, when 685 680 * gfs2_gl_hash_clear calls clear_glock) and recovery is complete 686 681 * then it's okay to tell dlm to unlock it. 687 682 */ 688 683 if (unlikely(sdp->sd_log_error && !gfs2_withdrawn(sdp))) 689 684 gfs2_withdraw_delayed(sdp); 690 - if (glock_blocked_by_withdraw(gl)) { 691 - if (target != LM_ST_UNLOCKED || 692 - test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags)) { 685 + if (glock_blocked_by_withdraw(gl) && 686 + (target != LM_ST_UNLOCKED || 687 + test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags))) { 688 + if (!is_system_glock(gl)) { 693 689 gfs2_glock_queue_work(gl, GL_GLOCK_DFT_HOLD); 694 690 goto out; 691 + } else { 692 + clear_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags); 695 693 } 696 694 } 697 695 ··· 1484 1466 glock_blocked_by_withdraw(gl) && 1485 1467 gh->gh_gl != sdp->sd_jinode_gl) { 1486 1468 sdp->sd_glock_dqs_held++; 1469 + spin_unlock(&gl->gl_lockref.lock); 1487 1470 might_sleep(); 1488 1471 wait_on_bit(&sdp->sd_flags, SDF_WITHDRAW_RECOVERY, 1489 1472 TASK_UNINTERRUPTIBLE); 1473 + spin_lock(&gl->gl_lockref.lock); 1490 1474 } 1491 1475 if (gh->gh_flags & GL_NOCACHE) 1492 1476 handle_callback(gl, LM_ST_UNLOCKED, 0, false); ··· 1795 1775 while(!list_empty(list)) { 1796 1776 gl = list_first_entry(list, struct gfs2_glock, gl_lru); 1797 1777 list_del_init(&gl->gl_lru); 1778 + clear_bit(GLF_LRU, &gl->gl_flags); 1798 1779 if (!spin_trylock(&gl->gl_lockref.lock)) { 1799 1780 add_back_to_lru: 1800 1781 list_add(&gl->gl_lru, &lru_list); ··· 1841 1820 if (!test_bit(GLF_LOCK, &gl->gl_flags)) { 1842 1821 list_move(&gl->gl_lru, &dispose); 1843 1822 atomic_dec(&lru_count); 1844 - clear_bit(GLF_LRU, &gl->gl_flags); 1845 1823 freed++; 1846 1824 continue; 1847 1825 }
+1 -1
fs/gfs2/glops.c
··· 396 396 struct timespec64 atime; 397 397 u16 height, depth; 398 398 umode_t mode = be32_to_cpu(str->di_mode); 399 - bool is_new = ip->i_inode.i_flags & I_NEW; 399 + bool is_new = ip->i_inode.i_state & I_NEW; 400 400 401 401 if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr))) 402 402 goto corrupt;
+3 -3
fs/gfs2/log.c
··· 926 926 } 927 927 928 928 /** 929 - * ail_drain - drain the ail lists after a withdraw 929 + * gfs2_ail_drain - drain the ail lists after a withdraw 930 930 * @sdp: Pointer to GFS2 superblock 931 931 */ 932 - static void ail_drain(struct gfs2_sbd *sdp) 932 + void gfs2_ail_drain(struct gfs2_sbd *sdp) 933 933 { 934 934 struct gfs2_trans *tr; 935 935 ··· 956 956 list_del(&tr->tr_list); 957 957 gfs2_trans_free(sdp, tr); 958 958 } 959 + gfs2_drain_revokes(sdp); 959 960 spin_unlock(&sdp->sd_ail_lock); 960 961 } 961 962 ··· 1163 1162 if (tr && list_empty(&tr->tr_list)) 1164 1163 list_add(&tr->tr_list, &sdp->sd_ail1_list); 1165 1164 spin_unlock(&sdp->sd_ail_lock); 1166 - ail_drain(sdp); /* frees all transactions */ 1167 1165 tr = NULL; 1168 1166 goto out_end; 1169 1167 }
+1
fs/gfs2/log.h
··· 93 93 extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd); 94 94 extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl); 95 95 extern void gfs2_flush_revokes(struct gfs2_sbd *sdp); 96 + extern void gfs2_ail_drain(struct gfs2_sbd *sdp); 96 97 97 98 #endif /* __LOG_DOT_H__ */
+6 -1
fs/gfs2/lops.c
··· 885 885 gfs2_log_write_page(sdp, page); 886 886 } 887 887 888 - static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) 888 + void gfs2_drain_revokes(struct gfs2_sbd *sdp) 889 889 { 890 890 struct list_head *head = &sdp->sd_log_revokes; 891 891 struct gfs2_bufdata *bd; ··· 898 898 gfs2_glock_remove_revoke(gl); 899 899 kmem_cache_free(gfs2_bufdata_cachep, bd); 900 900 } 901 + } 902 + 903 + static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) 904 + { 905 + gfs2_drain_revokes(sdp); 901 906 } 902 907 903 908 static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
+1
fs/gfs2/lops.h
··· 20 20 extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh); 21 21 extern int gfs2_find_jhead(struct gfs2_jdesc *jd, 22 22 struct gfs2_log_header_host *head, bool keep_cache); 23 + extern void gfs2_drain_revokes(struct gfs2_sbd *sdp); 23 24 static inline unsigned int buf_limit(struct gfs2_sbd *sdp) 24 25 { 25 26 return sdp->sd_ldptrs;
+1
fs/gfs2/util.c
··· 131 131 if (test_bit(SDF_NORECOVERY, &sdp->sd_flags) || !sdp->sd_jdesc) 132 132 return; 133 133 134 + gfs2_ail_drain(sdp); /* frees all transactions */ 134 135 inode = sdp->sd_jdesc->jd_inode; 135 136 ip = GFS2_I(inode); 136 137 i_gl = ip->i_gl;
+15 -14
fs/io-wq.c
··· 979 979 return cwd->wqe->wq == data; 980 980 } 981 981 982 + void io_wq_exit_start(struct io_wq *wq) 983 + { 984 + set_bit(IO_WQ_BIT_EXIT, &wq->state); 985 + } 986 + 982 987 static void io_wq_exit_workers(struct io_wq *wq) 983 988 { 984 989 struct callback_head *cb; 985 990 int node; 986 - 987 - set_bit(IO_WQ_BIT_EXIT, &wq->state); 988 991 989 992 if (!wq->task) 990 993 return; ··· 1006 1003 struct io_wqe *wqe = wq->wqes[node]; 1007 1004 1008 1005 io_wq_for_each_worker(wqe, io_wq_worker_wake, NULL); 1009 - spin_lock_irq(&wq->hash->wait.lock); 1010 - list_del_init(&wq->wqes[node]->wait.entry); 1011 - spin_unlock_irq(&wq->hash->wait.lock); 1012 1006 } 1013 1007 rcu_read_unlock(); 1014 1008 io_worker_ref_put(wq); 1015 1009 wait_for_completion(&wq->worker_done); 1010 + 1011 + for_each_node(node) { 1012 + spin_lock_irq(&wq->hash->wait.lock); 1013 + list_del_init(&wq->wqes[node]->wait.entry); 1014 + spin_unlock_irq(&wq->hash->wait.lock); 1015 + } 1016 1016 put_task_struct(wq->task); 1017 1017 wq->task = NULL; 1018 1018 } ··· 1025 1019 int node; 1026 1020 1027 1021 cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node); 1028 - 1029 - io_wq_exit_workers(wq); 1030 1022 1031 1023 for_each_node(node) { 1032 1024 struct io_wqe *wqe = wq->wqes[node]; ··· 1040 1036 kfree(wq); 1041 1037 } 1042 1038 1043 - void io_wq_put(struct io_wq *wq) 1044 - { 1045 - if (refcount_dec_and_test(&wq->refs)) 1046 - io_wq_destroy(wq); 1047 - } 1048 - 1049 1039 void io_wq_put_and_exit(struct io_wq *wq) 1050 1040 { 1041 + WARN_ON_ONCE(!test_bit(IO_WQ_BIT_EXIT, &wq->state)); 1042 + 1051 1043 io_wq_exit_workers(wq); 1052 - io_wq_put(wq); 1044 + if (refcount_dec_and_test(&wq->refs)) 1045 + io_wq_destroy(wq); 1053 1046 } 1054 1047 1055 1048 static bool io_wq_worker_affinity(struct io_worker *worker, void *data)
+1 -1
fs/io-wq.h
··· 122 122 }; 123 123 124 124 struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data); 125 - void io_wq_put(struct io_wq *wq); 125 + void io_wq_exit_start(struct io_wq *wq); 126 126 void io_wq_put_and_exit(struct io_wq *wq); 127 127 128 128 void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work);
+13 -2
fs/io_uring.c
··· 9039 9039 struct io_tctx_node *node; 9040 9040 unsigned long index; 9041 9041 9042 - tctx->io_wq = NULL; 9043 9042 xa_for_each(&tctx->xa, index, node) 9044 9043 io_uring_del_task_file(index); 9045 - if (wq) 9044 + if (wq) { 9045 + /* 9046 + * Must be after io_uring_del_task_file() (removes nodes under 9047 + * uring_lock) to avoid race with io_uring_try_cancel_iowq(). 9048 + */ 9049 + tctx->io_wq = NULL; 9046 9050 io_wq_put_and_exit(wq); 9051 + } 9047 9052 } 9048 9053 9049 9054 static s64 tctx_inflight(struct io_uring_task *tctx, bool tracked) ··· 9083 9078 9084 9079 if (!current->io_uring) 9085 9080 return; 9081 + if (tctx->io_wq) 9082 + io_wq_exit_start(tctx->io_wq); 9083 + 9086 9084 WARN_ON_ONCE(!sqd || sqd->thread != current); 9087 9085 9088 9086 atomic_inc(&tctx->in_idle); ··· 9119 9111 struct io_uring_task *tctx = current->io_uring; 9120 9112 DEFINE_WAIT(wait); 9121 9113 s64 inflight; 9114 + 9115 + if (tctx->io_wq) 9116 + io_wq_exit_start(tctx->io_wq); 9122 9117 9123 9118 /* make sure overflow events are dropped */ 9124 9119 atomic_inc(&tctx->in_idle);
+1 -1
fs/netfs/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 3 3 config NETFS_SUPPORT 4 - tristate "Support for network filesystem high-level I/O" 4 + tristate 5 5 help 6 6 This option enables support for network filesystems, including 7 7 helpers for high-level buffered I/O, abstracting out read
+1 -1
fs/netfs/read_helper.c
··· 1068 1068 DEFINE_READAHEAD(ractl, file, NULL, mapping, index); 1069 1069 1070 1070 retry: 1071 - page = grab_cache_page_write_begin(mapping, index, 0); 1071 + page = grab_cache_page_write_begin(mapping, index, flags); 1072 1072 if (!page) 1073 1073 return -ENOMEM; 1074 1074
+1 -1
fs/nfs/filelayout/filelayout.c
··· 718 718 if (unlikely(!p)) 719 719 goto out_err; 720 720 fl->fh_array[i]->size = be32_to_cpup(p++); 721 - if (sizeof(struct nfs_fh) < fl->fh_array[i]->size) { 721 + if (fl->fh_array[i]->size > NFS_MAXFHSIZE) { 722 722 printk(KERN_ERR "NFS: Too big fh %d received %d\n", 723 723 i, fl->fh_array[i]->size); 724 724 goto out_err;
+1 -1
fs/nfs/namespace.c
··· 362 362 .set = param_set_nfs_timeout, 363 363 .get = param_get_nfs_timeout, 364 364 }; 365 - #define param_check_nfs_timeout(name, p) __param_check(name, p, int); 365 + #define param_check_nfs_timeout(name, p) __param_check(name, p, int) 366 366 367 367 module_param(nfs_mountpoint_expiry_timeout, nfs_timeout, 0644); 368 368 MODULE_PARM_DESC(nfs_mountpoint_expiry_timeout,
+1 -1
fs/nfs/nfs4file.c
··· 211 211 case SEEK_HOLE: 212 212 case SEEK_DATA: 213 213 ret = nfs42_proc_llseek(filep, offset, whence); 214 - if (ret != -ENOTSUPP) 214 + if (ret != -EOPNOTSUPP) 215 215 return ret; 216 216 fallthrough; 217 217 default:
+2 -2
fs/nfs/nfs4proc.c
··· 1706 1706 rcu_read_unlock(); 1707 1707 trace_nfs4_open_stateid_update_wait(state->inode, stateid, 0); 1708 1708 1709 - if (!signal_pending(current)) { 1709 + if (!fatal_signal_pending(current)) { 1710 1710 if (schedule_timeout(5*HZ) == 0) 1711 1711 status = -EAGAIN; 1712 1712 else ··· 3487 3487 write_sequnlock(&state->seqlock); 3488 3488 trace_nfs4_close_stateid_update_wait(state->inode, dst, 0); 3489 3489 3490 - if (signal_pending(current)) 3490 + if (fatal_signal_pending(current)) 3491 3491 status = -EINTR; 3492 3492 else 3493 3493 if (schedule_timeout(5*HZ) != 0)
+6 -14
fs/nfs/pagelist.c
··· 1094 1094 struct nfs_page *prev = NULL; 1095 1095 unsigned int size; 1096 1096 1097 - if (mirror->pg_count != 0) { 1098 - prev = nfs_list_entry(mirror->pg_list.prev); 1099 - } else { 1097 + if (list_empty(&mirror->pg_list)) { 1100 1098 if (desc->pg_ops->pg_init) 1101 1099 desc->pg_ops->pg_init(desc, req); 1102 1100 if (desc->pg_error < 0) 1103 1101 return 0; 1104 1102 mirror->pg_base = req->wb_pgbase; 1105 - } 1103 + mirror->pg_count = 0; 1104 + mirror->pg_recoalesce = 0; 1105 + } else 1106 + prev = nfs_list_entry(mirror->pg_list.prev); 1106 1107 1107 1108 if (desc->pg_maxretrans && req->wb_nio > desc->pg_maxretrans) { 1108 1109 if (NFS_SERVER(desc->pg_inode)->flags & NFS_MOUNT_SOFTERR) ··· 1128 1127 { 1129 1128 struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc); 1130 1129 1131 - 1132 1130 if (!list_empty(&mirror->pg_list)) { 1133 1131 int error = desc->pg_ops->pg_doio(desc); 1134 1132 if (error < 0) 1135 1133 desc->pg_error = error; 1136 - else 1134 + if (list_empty(&mirror->pg_list)) 1137 1135 mirror->pg_bytes_written += mirror->pg_count; 1138 - } 1139 - if (list_empty(&mirror->pg_list)) { 1140 - mirror->pg_count = 0; 1141 - mirror->pg_base = 0; 1142 1136 } 1143 1137 } 1144 1138 ··· 1223 1227 1224 1228 do { 1225 1229 list_splice_init(&mirror->pg_list, &head); 1226 - mirror->pg_bytes_written -= mirror->pg_count; 1227 - mirror->pg_count = 0; 1228 - mirror->pg_base = 0; 1229 - mirror->pg_recoalesce = 0; 1230 1230 1231 1231 while (!list_empty(&head)) { 1232 1232 struct nfs_page *req;
+8 -9
fs/nfs/pnfs.c
··· 1317 1317 { 1318 1318 struct pnfs_layout_hdr *lo = NULL; 1319 1319 struct nfs_inode *nfsi = NFS_I(ino); 1320 + struct pnfs_layout_range range = { 1321 + .iomode = IOMODE_ANY, 1322 + .offset = 0, 1323 + .length = NFS4_MAX_UINT64, 1324 + }; 1320 1325 LIST_HEAD(tmp_list); 1321 1326 const struct cred *cred; 1322 1327 nfs4_stateid stateid; ··· 1349 1344 } 1350 1345 valid_layout = pnfs_layout_is_valid(lo); 1351 1346 pnfs_clear_layoutcommit(ino, &tmp_list); 1352 - pnfs_mark_matching_lsegs_return(lo, &tmp_list, NULL, 0); 1347 + pnfs_mark_matching_lsegs_return(lo, &tmp_list, &range, 0); 1353 1348 1354 - if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) { 1355 - struct pnfs_layout_range range = { 1356 - .iomode = IOMODE_ANY, 1357 - .offset = 0, 1358 - .length = NFS4_MAX_UINT64, 1359 - }; 1349 + if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) 1360 1350 NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo, &range); 1361 - } 1362 1351 1363 1352 /* Don't send a LAYOUTRETURN if list was initially empty */ 1364 1353 if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags) || ··· 2677 2678 void 2678 2679 pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) 2679 2680 { 2680 - u64 rd_size = req->wb_bytes; 2681 + u64 rd_size; 2681 2682 2682 2683 pnfs_generic_pg_check_layout(pgio); 2683 2684 pnfs_generic_pg_check_range(pgio, req);
+1 -1
fs/nfs/super.c
··· 1379 1379 .set = param_set_portnr, 1380 1380 .get = param_get_uint, 1381 1381 }; 1382 - #define param_check_portnr(name, p) __param_check(name, p, unsigned int); 1382 + #define param_check_portnr(name, p) __param_check(name, p, unsigned int) 1383 1383 1384 1384 module_param_named(callback_tcpport, nfs_callback_set_tcpport, portnr, 0644); 1385 1385 module_param_named(callback_nr_threads, nfs_callback_nr_threads, ushort, 0644);
+24 -6
fs/notify/fanotify/fanotify_user.c
··· 424 424 * events generated by the listener process itself, without disclosing 425 425 * the pids of other processes. 426 426 */ 427 - if (!capable(CAP_SYS_ADMIN) && 427 + if (FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) && 428 428 task_tgid(current) != event->pid) 429 429 metadata.pid = 0; 430 430 431 - if (path && path->mnt && path->dentry) { 431 + /* 432 + * For now, fid mode is required for an unprivileged listener and 433 + * fid mode does not report fd in events. Keep this check anyway 434 + * for safety in case fid mode requirement is relaxed in the future 435 + * to allow unprivileged listener to get events with no fd and no fid. 436 + */ 437 + if (!FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) && 438 + path && path->mnt && path->dentry) { 432 439 fd = create_fd(group, path, &f); 433 440 if (fd < 0) 434 441 return fd; ··· 1047 1040 int f_flags, fd; 1048 1041 unsigned int fid_mode = flags & FANOTIFY_FID_BITS; 1049 1042 unsigned int class = flags & FANOTIFY_CLASS_BITS; 1043 + unsigned int internal_flags = 0; 1050 1044 1051 1045 pr_debug("%s: flags=%x event_f_flags=%x\n", 1052 1046 __func__, flags, event_f_flags); ··· 1061 1053 */ 1062 1054 if ((flags & FANOTIFY_ADMIN_INIT_FLAGS) || !fid_mode) 1063 1055 return -EPERM; 1056 + 1057 + /* 1058 + * Setting the internal flag FANOTIFY_UNPRIV on the group 1059 + * prevents setting mount/filesystem marks on this group and 1060 + * prevents reporting pid and open fd in events. 1061 + */ 1062 + internal_flags |= FANOTIFY_UNPRIV; 1064 1063 } 1065 1064 1066 1065 #ifdef CONFIG_AUDITSYSCALL ··· 1120 1105 goto out_destroy_group; 1121 1106 } 1122 1107 1123 - group->fanotify_data.flags = flags; 1108 + group->fanotify_data.flags = flags | internal_flags; 1124 1109 group->memcg = get_mem_cgroup_from_mm(current->mm); 1125 1110 1126 1111 group->fanotify_data.merge_hash = fanotify_alloc_merge_hash(); ··· 1320 1305 group = f.file->private_data; 1321 1306 1322 1307 /* 1323 - * An unprivileged user is not allowed to watch a mount point nor 1324 - * a filesystem. 1308 + * An unprivileged user is not allowed to setup mount nor filesystem 1309 + * marks. This also includes setting up such marks by a group that 1310 + * was initialized by an unprivileged user. 1325 1311 */ 1326 1312 ret = -EPERM; 1327 - if (!capable(CAP_SYS_ADMIN) && 1313 + if ((!capable(CAP_SYS_ADMIN) || 1314 + FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV)) && 1328 1315 mark_type != FAN_MARK_INODE) 1329 1316 goto fput_and_out; 1330 1317 ··· 1477 1460 max_marks = clamp(max_marks, FANOTIFY_OLD_DEFAULT_MAX_MARKS, 1478 1461 FANOTIFY_DEFAULT_MAX_USER_MARKS); 1479 1462 1463 + BUILD_BUG_ON(FANOTIFY_INIT_FLAGS & FANOTIFY_INTERNAL_GROUP_FLAGS); 1480 1464 BUILD_BUG_ON(HWEIGHT32(FANOTIFY_INIT_FLAGS) != 10); 1481 1465 BUILD_BUG_ON(HWEIGHT32(FANOTIFY_MARK_FLAGS) != 9); 1482 1466
+1 -1
fs/notify/fdinfo.c
··· 144 144 struct fsnotify_group *group = f->private_data; 145 145 146 146 seq_printf(m, "fanotify flags:%x event-flags:%x\n", 147 - group->fanotify_data.flags, 147 + group->fanotify_data.flags & FANOTIFY_INIT_FLAGS, 148 148 group->fanotify_data.f_flags); 149 149 150 150 show_fdinfo(m, f, fanotify_fdinfo);
+4
fs/proc/base.c
··· 2703 2703 void *page; 2704 2704 int rv; 2705 2705 2706 + /* A task may only write when it was the opener. */ 2707 + if (file->f_cred != current_real_cred()) 2708 + return -EPERM; 2709 + 2706 2710 rcu_read_lock(); 2707 2711 task = pid_task(proc_pid(inode), PIDTYPE_PID); 2708 2712 if (!task) {
+15 -3
fs/xfs/libxfs/xfs_ag_resv.c
··· 325 325 error2 = xfs_alloc_pagf_init(mp, tp, pag->pag_agno, 0); 326 326 if (error2) 327 327 return error2; 328 - ASSERT(xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved + 329 - xfs_perag_resv(pag, XFS_AG_RESV_RMAPBT)->ar_reserved <= 330 - pag->pagf_freeblks + pag->pagf_flcount); 328 + 329 + /* 330 + * If there isn't enough space in the AG to satisfy the 331 + * reservation, let the caller know that there wasn't enough 332 + * space. Callers are responsible for deciding what to do 333 + * next, since (in theory) we can stumble along with 334 + * insufficient reservation if data blocks are being freed to 335 + * replenish the AG's free space. 336 + */ 337 + if (!error && 338 + xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved + 339 + xfs_perag_resv(pag, XFS_AG_RESV_RMAPBT)->ar_reserved > 340 + pag->pagf_freeblks + pag->pagf_flcount) 341 + error = -ENOSPC; 331 342 } 343 + 332 344 return error; 333 345 } 334 346
-12
fs/xfs/libxfs/xfs_bmap.c
··· 605 605 606 606 ASSERT(cur); 607 607 ASSERT(whichfork != XFS_COW_FORK); 608 - ASSERT(!xfs_need_iread_extents(ifp)); 609 608 ASSERT(ifp->if_format == XFS_DINODE_FMT_BTREE); 610 609 ASSERT(be16_to_cpu(rblock->bb_level) == 1); 611 610 ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1); ··· 5349 5350 xfs_fsblock_t sum; 5350 5351 xfs_filblks_t len = *rlen; /* length to unmap in file */ 5351 5352 xfs_fileoff_t max_len; 5352 - xfs_agnumber_t prev_agno = NULLAGNUMBER, agno; 5353 5353 xfs_fileoff_t end; 5354 5354 struct xfs_iext_cursor icur; 5355 5355 bool done = false; ··· 5440 5442 del = got; 5441 5443 wasdel = isnullstartblock(del.br_startblock); 5442 5444 5443 - /* 5444 - * Make sure we don't touch multiple AGF headers out of order 5445 - * in a single transaction, as that could cause AB-BA deadlocks. 5446 - */ 5447 - if (!wasdel && !isrt) { 5448 - agno = XFS_FSB_TO_AGNO(mp, del.br_startblock); 5449 - if (prev_agno != NULLAGNUMBER && prev_agno > agno) 5450 - break; 5451 - prev_agno = agno; 5452 - } 5453 5445 if (got.br_startoff < start) { 5454 5446 del.br_startoff = start; 5455 5447 del.br_blockcount -= start - got.br_startoff;
+42 -4
fs/xfs/libxfs/xfs_inode_buf.c
··· 559 559 /* 560 560 * Validate di_extsize hint. 561 561 * 562 - * The rules are documented at xfs_ioctl_setattr_check_extsize(). 563 - * These functions must be kept in sync with each other. 562 + * 1. Extent size hint is only valid for directories and regular files. 563 + * 2. FS_XFLAG_EXTSIZE is only valid for regular files. 564 + * 3. FS_XFLAG_EXTSZINHERIT is only valid for directories. 565 + * 4. Hint cannot be larger than MAXTEXTLEN. 566 + * 5. Can be changed on directories at any time. 567 + * 6. Hint value of 0 turns off hints, clears inode flags. 568 + * 7. Extent size must be a multiple of the appropriate block size. 569 + * For realtime files, this is the rt extent size. 570 + * 8. For non-realtime files, the extent size hint must be limited 571 + * to half the AG size to avoid alignment extending the extent beyond the 572 + * limits of the AG. 564 573 */ 565 574 xfs_failaddr_t 566 575 xfs_inode_validate_extsize( ··· 588 579 hint_flag = (flags & XFS_DIFLAG_EXTSIZE); 589 580 inherit_flag = (flags & XFS_DIFLAG_EXTSZINHERIT); 590 581 extsize_bytes = XFS_FSB_TO_B(mp, extsize); 582 + 583 + /* 584 + * This comment describes a historic gap in this verifier function. 585 + * 586 + * On older kernels, the extent size hint verifier doesn't check that 587 + * the extent size hint is an integer multiple of the realtime extent 588 + * size on a directory with both RTINHERIT and EXTSZINHERIT flags set. 589 + * The verifier has always enforced the alignment rule for regular 590 + * files with the REALTIME flag set. 591 + * 592 + * If a directory with a misaligned extent size hint is allowed to 593 + * propagate that hint into a new regular realtime file, the result 594 + * is that the inode cluster buffer verifier will trigger a corruption 595 + * shutdown the next time it is run. 596 + * 597 + * Unfortunately, there could be filesystems with these misconfigured 598 + * directories in the wild, so we cannot add a check to this verifier 599 + * at this time because that will result a new source of directory 600 + * corruption errors when reading an existing filesystem. Instead, we 601 + * permit the misconfiguration to pass through the verifiers so that 602 + * callers of this function can correct and mitigate externally. 603 + */ 591 604 592 605 if (rt_flag) 593 606 blocksize_bytes = mp->m_sb.sb_rextsize << mp->m_sb.sb_blocklog; ··· 647 616 /* 648 617 * Validate di_cowextsize hint. 649 618 * 650 - * The rules are documented at xfs_ioctl_setattr_check_cowextsize(). 651 - * These functions must be kept in sync with each other. 619 + * 1. CoW extent size hint can only be set if reflink is enabled on the fs. 620 + * The inode does not have to have any shared blocks, but it must be a v3. 621 + * 2. FS_XFLAG_COWEXTSIZE is only valid for directories and regular files; 622 + * for a directory, the hint is propagated to new files. 623 + * 3. Can be changed on files & directories at any time. 624 + * 4. Hint value of 0 turns off hints, clears inode flags. 625 + * 5. Extent size must be a multiple of the appropriate block size. 626 + * 6. The extent size hint must be limited to half the AG size to avoid 627 + * alignment extending the extent beyond the limits of the AG. 652 628 */ 653 629 xfs_failaddr_t 654 630 xfs_inode_validate_cowextsize(
+17
fs/xfs/libxfs/xfs_trans_inode.c
··· 143 143 } 144 144 145 145 /* 146 + * Inode verifiers on older kernels don't check that the extent size 147 + * hint is an integer multiple of the rt extent size on a directory 148 + * with both rtinherit and extszinherit flags set. If we're logging a 149 + * directory that is misconfigured in this way, clear the hint. 150 + */ 151 + if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) && 152 + (ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) && 153 + (ip->i_extsize % ip->i_mount->m_sb.sb_rextsize) > 0) { 154 + xfs_info_once(ip->i_mount, 155 + "Correcting misaligned extent size hint in inode 0x%llx.", ip->i_ino); 156 + ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE | 157 + XFS_DIFLAG_EXTSZINHERIT); 158 + ip->i_extsize = 0; 159 + flags |= XFS_ILOG_CORE; 160 + } 161 + 162 + /* 146 163 * Record the specific change for fdatasync optimisation. This allows 147 164 * fdatasync to skip log forces for inodes that are only timestamp 148 165 * dirty.
+29
fs/xfs/xfs_inode.c
··· 690 690 const struct xfs_inode *pip) 691 691 { 692 692 unsigned int di_flags = 0; 693 + xfs_failaddr_t failaddr; 693 694 umode_t mode = VFS_I(ip)->i_mode; 694 695 695 696 if (S_ISDIR(mode)) { ··· 730 729 di_flags |= XFS_DIFLAG_FILESTREAM; 731 730 732 731 ip->i_diflags |= di_flags; 732 + 733 + /* 734 + * Inode verifiers on older kernels only check that the extent size 735 + * hint is an integer multiple of the rt extent size on realtime files. 736 + * They did not check the hint alignment on a directory with both 737 + * rtinherit and extszinherit flags set. If the misaligned hint is 738 + * propagated from a directory into a new realtime file, new file 739 + * allocations will fail due to math errors in the rt allocator and/or 740 + * trip the verifiers. Validate the hint settings in the new file so 741 + * that we don't let broken hints propagate. 742 + */ 743 + failaddr = xfs_inode_validate_extsize(ip->i_mount, ip->i_extsize, 744 + VFS_I(ip)->i_mode, ip->i_diflags); 745 + if (failaddr) { 746 + ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE | 747 + XFS_DIFLAG_EXTSZINHERIT); 748 + ip->i_extsize = 0; 749 + } 733 750 } 734 751 735 752 /* Propagate di_flags2 from a parent inode to a child inode. */ ··· 756 737 struct xfs_inode *ip, 757 738 const struct xfs_inode *pip) 758 739 { 740 + xfs_failaddr_t failaddr; 741 + 759 742 if (pip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) { 760 743 ip->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE; 761 744 ip->i_cowextsize = pip->i_cowextsize; 762 745 } 763 746 if (pip->i_diflags2 & XFS_DIFLAG2_DAX) 764 747 ip->i_diflags2 |= XFS_DIFLAG2_DAX; 748 + 749 + /* Don't let invalid cowextsize hints propagate. */ 750 + failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize, 751 + VFS_I(ip)->i_mode, ip->i_diflags, ip->i_diflags2); 752 + if (failaddr) { 753 + ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE; 754 + ip->i_cowextsize = 0; 755 + } 765 756 } 766 757 767 758 /*
+34 -67
fs/xfs/xfs_ioctl.c
··· 1267 1267 } 1268 1268 1269 1269 /* 1270 - * extent size hint validation is somewhat cumbersome. Rules are: 1271 - * 1272 - * 1. extent size hint is only valid for directories and regular files 1273 - * 2. FS_XFLAG_EXTSIZE is only valid for regular files 1274 - * 3. FS_XFLAG_EXTSZINHERIT is only valid for directories. 1275 - * 4. can only be changed on regular files if no extents are allocated 1276 - * 5. can be changed on directories at any time 1277 - * 6. extsize hint of 0 turns off hints, clears inode flags. 1278 - * 7. Extent size must be a multiple of the appropriate block size. 1279 - * 8. for non-realtime files, the extent size hint must be limited 1280 - * to half the AG size to avoid alignment extending the extent beyond the 1281 - * limits of the AG. 1282 - * 1283 - * Please keep this function in sync with xfs_scrub_inode_extsize. 1270 + * Validate a proposed extent size hint. For regular files, the hint can only 1271 + * be changed if no extents are allocated. 1284 1272 */ 1285 1273 static int 1286 1274 xfs_ioctl_setattr_check_extsize( ··· 1276 1288 struct fileattr *fa) 1277 1289 { 1278 1290 struct xfs_mount *mp = ip->i_mount; 1279 - xfs_extlen_t size; 1280 - xfs_fsblock_t extsize_fsb; 1291 + xfs_failaddr_t failaddr; 1292 + uint16_t new_diflags; 1281 1293 1282 1294 if (!fa->fsx_valid) 1283 1295 return 0; 1284 1296 1285 1297 if (S_ISREG(VFS_I(ip)->i_mode) && ip->i_df.if_nextents && 1286 - ((ip->i_extsize << mp->m_sb.sb_blocklog) != fa->fsx_extsize)) 1298 + XFS_FSB_TO_B(mp, ip->i_extsize) != fa->fsx_extsize) 1287 1299 return -EINVAL; 1288 1300 1289 - if (fa->fsx_extsize == 0) 1290 - return 0; 1291 - 1292 - extsize_fsb = XFS_B_TO_FSB(mp, fa->fsx_extsize); 1293 - if (extsize_fsb > MAXEXTLEN) 1301 + if (fa->fsx_extsize & mp->m_blockmask) 1294 1302 return -EINVAL; 1295 1303 1296 - if (XFS_IS_REALTIME_INODE(ip) || 1297 - (fa->fsx_xflags & FS_XFLAG_REALTIME)) { 1298 - size = mp->m_sb.sb_rextsize << mp->m_sb.sb_blocklog; 1299 - } else { 1300 - size = mp->m_sb.sb_blocksize; 1301 - if (extsize_fsb > mp->m_sb.sb_agblocks / 2) 1304 + new_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); 1305 + 1306 + /* 1307 + * Inode verifiers on older kernels don't check that the extent size 1308 + * hint is an integer multiple of the rt extent size on a directory 1309 + * with both rtinherit and extszinherit flags set. Don't let sysadmins 1310 + * misconfigure directories. 1311 + */ 1312 + if ((new_diflags & XFS_DIFLAG_RTINHERIT) && 1313 + (new_diflags & XFS_DIFLAG_EXTSZINHERIT)) { 1314 + unsigned int rtextsize_bytes; 1315 + 1316 + rtextsize_bytes = XFS_FSB_TO_B(mp, mp->m_sb.sb_rextsize); 1317 + if (fa->fsx_extsize % rtextsize_bytes) 1302 1318 return -EINVAL; 1303 1319 } 1304 1320 1305 - if (fa->fsx_extsize % size) 1306 - return -EINVAL; 1307 - 1308 - return 0; 1321 + failaddr = xfs_inode_validate_extsize(ip->i_mount, 1322 + XFS_B_TO_FSB(mp, fa->fsx_extsize), 1323 + VFS_I(ip)->i_mode, new_diflags); 1324 + return failaddr != NULL ? -EINVAL : 0; 1309 1325 } 1310 1326 1311 - /* 1312 - * CoW extent size hint validation rules are: 1313 - * 1314 - * 1. CoW extent size hint can only be set if reflink is enabled on the fs. 1315 - * The inode does not have to have any shared blocks, but it must be a v3. 1316 - * 2. FS_XFLAG_COWEXTSIZE is only valid for directories and regular files; 1317 - * for a directory, the hint is propagated to new files. 1318 - * 3. Can be changed on files & directories at any time. 1319 - * 4. CoW extsize hint of 0 turns off hints, clears inode flags. 1320 - * 5. Extent size must be a multiple of the appropriate block size. 1321 - * 6. The extent size hint must be limited to half the AG size to avoid 1322 - * alignment extending the extent beyond the limits of the AG. 1323 - * 1324 - * Please keep this function in sync with xfs_scrub_inode_cowextsize. 1325 - */ 1326 1327 static int 1327 1328 xfs_ioctl_setattr_check_cowextsize( 1328 1329 struct xfs_inode *ip, 1329 1330 struct fileattr *fa) 1330 1331 { 1331 1332 struct xfs_mount *mp = ip->i_mount; 1332 - xfs_extlen_t size; 1333 - xfs_fsblock_t cowextsize_fsb; 1333 + xfs_failaddr_t failaddr; 1334 + uint64_t new_diflags2; 1335 + uint16_t new_diflags; 1334 1336 1335 1337 if (!fa->fsx_valid) 1336 1338 return 0; 1337 1339 1338 - if (!(fa->fsx_xflags & FS_XFLAG_COWEXTSIZE)) 1339 - return 0; 1340 - 1341 - if (!xfs_sb_version_hasreflink(&ip->i_mount->m_sb)) 1340 + if (fa->fsx_cowextsize & mp->m_blockmask) 1342 1341 return -EINVAL; 1343 1342 1344 - if (fa->fsx_cowextsize == 0) 1345 - return 0; 1343 + new_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); 1344 + new_diflags2 = xfs_flags2diflags2(ip, fa->fsx_xflags); 1346 1345 1347 - cowextsize_fsb = XFS_B_TO_FSB(mp, fa->fsx_cowextsize); 1348 - if (cowextsize_fsb > MAXEXTLEN) 1349 - return -EINVAL; 1350 - 1351 - size = mp->m_sb.sb_blocksize; 1352 - if (cowextsize_fsb > mp->m_sb.sb_agblocks / 2) 1353 - return -EINVAL; 1354 - 1355 - if (fa->fsx_cowextsize % size) 1356 - return -EINVAL; 1357 - 1358 - return 0; 1346 + failaddr = xfs_inode_validate_cowextsize(ip->i_mount, 1347 + XFS_B_TO_FSB(mp, fa->fsx_cowextsize), 1348 + VFS_I(ip)->i_mode, new_diflags, new_diflags2); 1349 + return failaddr != NULL ? -EINVAL : 0; 1359 1350 } 1360 1351 1361 1352 static int
+2
fs/xfs/xfs_message.h
··· 73 73 xfs_printk_once(xfs_warn, dev, fmt, ##__VA_ARGS__) 74 74 #define xfs_notice_once(dev, fmt, ...) \ 75 75 xfs_printk_once(xfs_notice, dev, fmt, ##__VA_ARGS__) 76 + #define xfs_info_once(dev, fmt, ...) \ 77 + xfs_printk_once(xfs_info, dev, fmt, ##__VA_ARGS__) 76 78 77 79 void assfail(struct xfs_mount *mp, char *expr, char *f, int l); 78 80 void asswarn(struct xfs_mount *mp, char *expr, char *f, int l);
+2 -4
include/linux/device.h
··· 570 570 * @flags: Link flags. 571 571 * @rpm_active: Whether or not the consumer device is runtime-PM-active. 572 572 * @kref: Count repeated addition of the same link. 573 - * @rcu_head: An RCU head to use for deferred execution of SRCU callbacks. 573 + * @rm_work: Work structure used for removing the link. 574 574 * @supplier_preactivated: Supplier has been made active before consumer probe. 575 575 */ 576 576 struct device_link { ··· 583 583 u32 flags; 584 584 refcount_t rpm_active; 585 585 struct kref kref; 586 - #ifdef CONFIG_SRCU 587 - struct rcu_head rcu_head; 588 - #endif 586 + struct work_struct rm_work; 589 587 bool supplier_preactivated; /* Owned by consumer probe. */ 590 588 }; 591 589
+4
include/linux/fanotify.h
··· 51 51 #define FANOTIFY_INIT_FLAGS (FANOTIFY_ADMIN_INIT_FLAGS | \ 52 52 FANOTIFY_USER_INIT_FLAGS) 53 53 54 + /* Internal group flags */ 55 + #define FANOTIFY_UNPRIV 0x80000000 56 + #define FANOTIFY_INTERNAL_GROUP_FLAGS (FANOTIFY_UNPRIV) 57 + 54 58 #define FANOTIFY_MARK_TYPE_BITS (FAN_MARK_INODE | FAN_MARK_MOUNT | \ 55 59 FAN_MARK_FILESYSTEM) 56 60
+2 -1
include/linux/init.h
··· 242 242 asm(".section \"" __sec "\", \"a\" \n" \ 243 243 __stringify(__name) ": \n" \ 244 244 ".long " __stringify(__stub) " - . \n" \ 245 - ".previous \n"); 245 + ".previous \n"); \ 246 + static_assert(__same_type(initcall_t, &fn)); 246 247 #else 247 248 #define ____define_initcall(fn, __unused, __name, __sec) \ 248 249 static initcall_t __name __used \
+7 -1
include/linux/kvm_host.h
··· 10 10 #include <linux/spinlock.h> 11 11 #include <linux/signal.h> 12 12 #include <linux/sched.h> 13 + #include <linux/sched/stat.h> 13 14 #include <linux/bug.h> 14 15 #include <linux/minmax.h> 15 16 #include <linux/mm.h> ··· 147 146 */ 148 147 #define KVM_REQ_TLB_FLUSH (0 | KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP) 149 148 #define KVM_REQ_MMU_RELOAD (1 | KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP) 150 - #define KVM_REQ_PENDING_TIMER 2 149 + #define KVM_REQ_UNBLOCK 2 151 150 #define KVM_REQ_UNHALT 3 152 151 #define KVM_REQUEST_ARCH_BASE 8 153 152 ··· 264 263 static inline bool kvm_vcpu_mapped(struct kvm_host_map *map) 265 264 { 266 265 return !!map->hva; 266 + } 267 + 268 + static inline bool kvm_vcpu_can_poll(ktime_t cur, ktime_t stop) 269 + { 270 + return single_task_running() && !need_resched() && ktime_before(cur, stop); 267 271 } 268 272 269 273 /*
+22 -22
include/linux/mlx5/driver.h
··· 703 703 #define MLX5_LOG_SW_ICM_BLOCK_SIZE(dev) (MLX5_CAP_DEV_MEM(dev, log_sw_icm_alloc_granularity)) 704 704 #define MLX5_SW_ICM_BLOCK_SIZE(dev) (1 << MLX5_LOG_SW_ICM_BLOCK_SIZE(dev)) 705 705 706 + enum { 707 + MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0, 708 + MLX5_PROF_MASK_MR_CACHE = (u64)1 << 1, 709 + }; 710 + 711 + enum { 712 + MR_CACHE_LAST_STD_ENTRY = 20, 713 + MLX5_IMR_MTT_CACHE_ENTRY, 714 + MLX5_IMR_KSM_CACHE_ENTRY, 715 + MAX_MR_CACHE_ENTRIES 716 + }; 717 + 718 + struct mlx5_profile { 719 + u64 mask; 720 + u8 log_max_qp; 721 + struct { 722 + int size; 723 + int limit; 724 + } mr_cache[MAX_MR_CACHE_ENTRIES]; 725 + }; 726 + 706 727 struct mlx5_core_dev { 707 728 struct device *device; 708 729 enum mlx5_coredev_type coredev_type; ··· 752 731 struct mutex intf_state_mutex; 753 732 unsigned long intf_state; 754 733 struct mlx5_priv priv; 755 - struct mlx5_profile *profile; 734 + struct mlx5_profile profile; 756 735 u32 issi; 757 736 struct mlx5e_resources mlx5e_res; 758 737 struct mlx5_dm *dm; ··· 1104 1083 return mkey & 0xff; 1105 1084 } 1106 1085 1107 - enum { 1108 - MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0, 1109 - MLX5_PROF_MASK_MR_CACHE = (u64)1 << 1, 1110 - }; 1111 - 1112 - enum { 1113 - MR_CACHE_LAST_STD_ENTRY = 20, 1114 - MLX5_IMR_MTT_CACHE_ENTRY, 1115 - MLX5_IMR_KSM_CACHE_ENTRY, 1116 - MAX_MR_CACHE_ENTRIES 1117 - }; 1118 - 1119 1086 /* Async-atomic event notifier used by mlx5 core to forward FW 1120 1087 * evetns recived from event queue to mlx5 consumers. 1121 1088 * Optimise event queue dipatching. ··· 1156 1147 int mlx5_rdma_rn_get_params(struct mlx5_core_dev *mdev, 1157 1148 struct ib_device *device, 1158 1149 struct rdma_netdev_alloc_params *params); 1159 - 1160 - struct mlx5_profile { 1161 - u64 mask; 1162 - u8 log_max_qp; 1163 - struct { 1164 - int size; 1165 - int limit; 1166 - } mr_cache[MAX_MR_CACHE_ENTRIES]; 1167 - }; 1168 1150 1169 1151 enum { 1170 1152 MLX5_PCI_DEV_IS_VF = 1 << 0,
+18
include/linux/mlx5/mpfs.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB 2 + * Copyright (c) 2021 Mellanox Technologies Ltd. 3 + */ 4 + 5 + #ifndef _MLX5_MPFS_ 6 + #define _MLX5_MPFS_ 7 + 8 + struct mlx5_core_dev; 9 + 10 + #ifdef CONFIG_MLX5_MPFS 11 + int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u8 *mac); 12 + int mlx5_mpfs_del_mac(struct mlx5_core_dev *dev, u8 *mac); 13 + #else /* #ifndef CONFIG_MLX5_MPFS */ 14 + static inline int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u8 *mac) { return 0; } 15 + static inline int mlx5_mpfs_del_mac(struct mlx5_core_dev *dev, u8 *mac) { return 0; } 16 + #endif 17 + 18 + #endif
+5
include/linux/phy.h
··· 496 496 * @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY 497 497 * @state: State of the PHY for management purposes 498 498 * @dev_flags: Device-specific flags used by the PHY driver. 499 + * Bits [15:0] are free to use by the PHY driver to communicate 500 + * driver specific behavior. 501 + * Bits [23:16] are currently reserved for future use. 502 + * Bits [31:24] are reserved for defining generic 503 + * PHY driver behavior. 499 504 * @irq: IRQ number of the PHY's interrupt (-1 if none) 500 505 * @phy_timer: The timer for handling the state machine 501 506 * @phylink: Pointer to phylink instance for this PHY
+2
include/linux/sunrpc/xprt.h
··· 368 368 unsigned int num_prealloc, 369 369 unsigned int max_req); 370 370 void xprt_free(struct rpc_xprt *); 371 + void xprt_add_backlog(struct rpc_xprt *xprt, struct rpc_task *task); 372 + bool xprt_wake_up_backlog(struct rpc_xprt *xprt, struct rpc_rqst *req); 371 373 372 374 static inline int 373 375 xprt_enable_swap(struct rpc_xprt *xprt)
+2 -2
include/net/cfg80211.h
··· 5760 5760 */ 5761 5761 int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, 5762 5762 const u8 *addr, enum nl80211_iftype iftype, 5763 - u8 data_offset); 5763 + u8 data_offset, bool is_amsdu); 5764 5764 5765 5765 /** 5766 5766 * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3 ··· 5772 5772 static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, 5773 5773 enum nl80211_iftype iftype) 5774 5774 { 5775 - return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0); 5775 + return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0, false); 5776 5776 } 5777 5777 5778 5778 /**
-1
include/net/netfilter/nf_flow_table.h
··· 157 157 NF_FLOW_HW, 158 158 NF_FLOW_HW_DYING, 159 159 NF_FLOW_HW_DEAD, 160 - NF_FLOW_HW_REFRESH, 161 160 NF_FLOW_HW_PENDING, 162 161 }; 163 162
+1
include/net/nfc/nci_core.h
··· 298 298 struct sk_buff **resp); 299 299 300 300 struct nci_hci_dev *nci_hci_allocate(struct nci_dev *ndev); 301 + void nci_hci_deallocate(struct nci_dev *ndev); 301 302 int nci_hci_send_event(struct nci_dev *ndev, u8 gate, u8 event, 302 303 const u8 *param, size_t param_len); 303 304 int nci_hci_send_cmd(struct nci_dev *ndev, u8 gate,
+11
include/net/pkt_cls.h
··· 709 709 cls_common->extack = extack; 710 710 } 711 711 712 + #if IS_ENABLED(CONFIG_NET_TC_SKB_EXT) 713 + static inline struct tc_skb_ext *tc_skb_ext_alloc(struct sk_buff *skb) 714 + { 715 + struct tc_skb_ext *tc_skb_ext = skb_ext_add(skb, TC_SKB_EXT); 716 + 717 + if (tc_skb_ext) 718 + memset(tc_skb_ext, 0, sizeof(*tc_skb_ext)); 719 + return tc_skb_ext; 720 + } 721 + #endif 722 + 712 723 enum tc_matchall_command { 713 724 TC_CLSMATCHALL_REPLACE, 714 725 TC_CLSMATCHALL_DESTROY,
+1 -6
include/net/pkt_sched.h
··· 128 128 static inline void qdisc_run(struct Qdisc *q) 129 129 { 130 130 if (qdisc_run_begin(q)) { 131 - /* NOLOCK qdisc must check 'state' under the qdisc seqlock 132 - * to avoid racing with dev_qdisc_reset() 133 - */ 134 - if (!(q->flags & TCQ_F_NOLOCK) || 135 - likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) 136 - __qdisc_run(q); 131 + __qdisc_run(q); 137 132 qdisc_run_end(q); 138 133 } 139 134 }
+34 -1
include/net/sch_generic.h
··· 36 36 enum qdisc_state_t { 37 37 __QDISC_STATE_SCHED, 38 38 __QDISC_STATE_DEACTIVATED, 39 + __QDISC_STATE_MISSED, 39 40 }; 40 41 41 42 struct qdisc_size_table { ··· 160 159 static inline bool qdisc_run_begin(struct Qdisc *qdisc) 161 160 { 162 161 if (qdisc->flags & TCQ_F_NOLOCK) { 162 + if (spin_trylock(&qdisc->seqlock)) 163 + goto nolock_empty; 164 + 165 + /* If the MISSED flag is set, it means other thread has 166 + * set the MISSED flag before second spin_trylock(), so 167 + * we can return false here to avoid multi cpus doing 168 + * the set_bit() and second spin_trylock() concurrently. 169 + */ 170 + if (test_bit(__QDISC_STATE_MISSED, &qdisc->state)) 171 + return false; 172 + 173 + /* Set the MISSED flag before the second spin_trylock(), 174 + * if the second spin_trylock() return false, it means 175 + * other cpu holding the lock will do dequeuing for us 176 + * or it will see the MISSED flag set after releasing 177 + * lock and reschedule the net_tx_action() to do the 178 + * dequeuing. 179 + */ 180 + set_bit(__QDISC_STATE_MISSED, &qdisc->state); 181 + 182 + /* Retry again in case other CPU may not see the new flag 183 + * after it releases the lock at the end of qdisc_run_end(). 184 + */ 163 185 if (!spin_trylock(&qdisc->seqlock)) 164 186 return false; 187 + 188 + nolock_empty: 165 189 WRITE_ONCE(qdisc->empty, false); 166 190 } else if (qdisc_is_running(qdisc)) { 167 191 return false; ··· 202 176 static inline void qdisc_run_end(struct Qdisc *qdisc) 203 177 { 204 178 write_seqcount_end(&qdisc->running); 205 - if (qdisc->flags & TCQ_F_NOLOCK) 179 + if (qdisc->flags & TCQ_F_NOLOCK) { 206 180 spin_unlock(&qdisc->seqlock); 181 + 182 + if (unlikely(test_bit(__QDISC_STATE_MISSED, 183 + &qdisc->state))) { 184 + clear_bit(__QDISC_STATE_MISSED, &qdisc->state); 185 + __netif_schedule(qdisc); 186 + } 187 + } 207 188 } 208 189 209 190 static inline bool qdisc_may_bulk(const struct Qdisc *qdisc)
+3 -1
include/net/sock.h
··· 2231 2231 sk_mem_charge(sk, skb->truesize); 2232 2232 } 2233 2233 2234 - static inline void skb_set_owner_sk_safe(struct sk_buff *skb, struct sock *sk) 2234 + static inline __must_check bool skb_set_owner_sk_safe(struct sk_buff *skb, struct sock *sk) 2235 2235 { 2236 2236 if (sk && refcount_inc_not_zero(&sk->sk_refcnt)) { 2237 2237 skb_orphan(skb); 2238 2238 skb->destructor = sock_efree; 2239 2239 skb->sk = sk; 2240 + return true; 2240 2241 } 2242 + return false; 2241 2243 } 2242 2244 2243 2245 void sk_reset_timer(struct sock *sk, struct timer_list *timer,
+1 -1
include/sound/soc-dai.h
··· 81 81 #define SND_SOC_DAIFMT_CBP_CFP (1 << 12) /* codec clk provider & frame provider */ 82 82 #define SND_SOC_DAIFMT_CBC_CFP (2 << 12) /* codec clk consumer & frame provider */ 83 83 #define SND_SOC_DAIFMT_CBP_CFC (3 << 12) /* codec clk provider & frame consumer */ 84 - #define SND_SOC_DAIFMT_CBC_CFC (4 << 12) /* codec clk consumer & frame follower */ 84 + #define SND_SOC_DAIFMT_CBC_CFC (4 << 12) /* codec clk consumer & frame consumer */ 85 85 86 86 /* previous definitions kept for backwards-compatibility, do not use in new contributions */ 87 87 #define SND_SOC_DAIFMT_CBM_CFM SND_SOC_DAIFMT_CBP_CFP
+3 -2
include/uapi/linux/kvm.h
··· 8 8 * Note: you must update KVM_API_VERSION if you change this interface. 9 9 */ 10 10 11 + #include <linux/const.h> 11 12 #include <linux/types.h> 12 13 #include <linux/compiler.h> 13 14 #include <linux/ioctl.h> ··· 1880 1879 * conversion after harvesting an entry. Also, it must not skip any 1881 1880 * dirty bits, so that dirty bits are always harvested in sequence. 1882 1881 */ 1883 - #define KVM_DIRTY_GFN_F_DIRTY BIT(0) 1884 - #define KVM_DIRTY_GFN_F_RESET BIT(1) 1882 + #define KVM_DIRTY_GFN_F_DIRTY _BITUL(0) 1883 + #define KVM_DIRTY_GFN_F_RESET _BITUL(1) 1885 1884 #define KVM_DIRTY_GFN_F_MASK 0x3 1886 1885 1887 1886 /*
+1 -40
init/Kconfig
··· 442 442 443 443 source "kernel/irq/Kconfig" 444 444 source "kernel/time/Kconfig" 445 + source "kernel/bpf/Kconfig" 445 446 source "kernel/Kconfig.preempt" 446 447 447 448 menu "CPU/Task time and stats accounting" ··· 1713 1712 # end of the "standard kernel features (expert users)" menu 1714 1713 1715 1714 # syscall, maps, verifier 1716 - 1717 - config BPF_LSM 1718 - bool "LSM Instrumentation with BPF" 1719 - depends on BPF_EVENTS 1720 - depends on BPF_SYSCALL 1721 - depends on SECURITY 1722 - depends on BPF_JIT 1723 - help 1724 - Enables instrumentation of the security hooks with eBPF programs for 1725 - implementing dynamic MAC and Audit Policies. 1726 - 1727 - If you are unsure how to answer this question, answer N. 1728 - 1729 - config BPF_SYSCALL 1730 - bool "Enable bpf() system call" 1731 - select BPF 1732 - select IRQ_WORK 1733 - select TASKS_TRACE_RCU 1734 - select BINARY_PRINTF 1735 - select NET_SOCK_MSG if INET 1736 - default n 1737 - help 1738 - Enable the bpf() system call that allows to manipulate eBPF 1739 - programs and maps via file descriptors. 1740 - 1741 - config ARCH_WANT_DEFAULT_BPF_JIT 1742 - bool 1743 - 1744 - config BPF_JIT_ALWAYS_ON 1745 - bool "Permanently enable BPF JIT and remove BPF interpreter" 1746 - depends on BPF_SYSCALL && HAVE_EBPF_JIT && BPF_JIT 1747 - help 1748 - Enables BPF JIT and removes BPF interpreter to avoid 1749 - speculative execution of BPF instructions by the interpreter 1750 - 1751 - config BPF_JIT_DEFAULT_ON 1752 - def_bool ARCH_WANT_DEFAULT_BPF_JIT || BPF_JIT_ALWAYS_ON 1753 - depends on HAVE_EBPF_JIT && BPF_JIT 1754 - 1755 - source "kernel/bpf/preload/Kconfig" 1756 1715 1757 1716 config USERFAULTFD 1758 1717 bool "Enable userfaultfd() system call"
+89
kernel/bpf/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + # BPF interpreter that, for example, classic socket filters depend on. 4 + config BPF 5 + bool 6 + 7 + # Used by archs to tell that they support BPF JIT compiler plus which 8 + # flavour. Only one of the two can be selected for a specific arch since 9 + # eBPF JIT supersedes the cBPF JIT. 10 + 11 + # Classic BPF JIT (cBPF) 12 + config HAVE_CBPF_JIT 13 + bool 14 + 15 + # Extended BPF JIT (eBPF) 16 + config HAVE_EBPF_JIT 17 + bool 18 + 19 + # Used by archs to tell that they want the BPF JIT compiler enabled by 20 + # default for kernels that were compiled with BPF JIT support. 21 + config ARCH_WANT_DEFAULT_BPF_JIT 22 + bool 23 + 24 + menu "BPF subsystem" 25 + 26 + config BPF_SYSCALL 27 + bool "Enable bpf() system call" 28 + select BPF 29 + select IRQ_WORK 30 + select TASKS_TRACE_RCU 31 + select BINARY_PRINTF 32 + select NET_SOCK_MSG if INET 33 + default n 34 + help 35 + Enable the bpf() system call that allows to manipulate BPF programs 36 + and maps via file descriptors. 37 + 38 + config BPF_JIT 39 + bool "Enable BPF Just In Time compiler" 40 + depends on BPF 41 + depends on HAVE_CBPF_JIT || HAVE_EBPF_JIT 42 + depends on MODULES 43 + help 44 + BPF programs are normally handled by a BPF interpreter. This option 45 + allows the kernel to generate native code when a program is loaded 46 + into the kernel. This will significantly speed-up processing of BPF 47 + programs. 48 + 49 + Note, an admin should enable this feature changing: 50 + /proc/sys/net/core/bpf_jit_enable 51 + /proc/sys/net/core/bpf_jit_harden (optional) 52 + /proc/sys/net/core/bpf_jit_kallsyms (optional) 53 + 54 + config BPF_JIT_ALWAYS_ON 55 + bool "Permanently enable BPF JIT and remove BPF interpreter" 56 + depends on BPF_SYSCALL && HAVE_EBPF_JIT && BPF_JIT 57 + help 58 + Enables BPF JIT and removes BPF interpreter to avoid speculative 59 + execution of BPF instructions by the interpreter. 60 + 61 + config BPF_JIT_DEFAULT_ON 62 + def_bool ARCH_WANT_DEFAULT_BPF_JIT || BPF_JIT_ALWAYS_ON 63 + depends on HAVE_EBPF_JIT && BPF_JIT 64 + 65 + config BPF_UNPRIV_DEFAULT_OFF 66 + bool "Disable unprivileged BPF by default" 67 + depends on BPF_SYSCALL 68 + help 69 + Disables unprivileged BPF by default by setting the corresponding 70 + /proc/sys/kernel/unprivileged_bpf_disabled knob to 2. An admin can 71 + still reenable it by setting it to 0 later on, or permanently 72 + disable it by setting it to 1 (from which no other transition to 73 + 0 is possible anymore). 74 + 75 + source "kernel/bpf/preload/Kconfig" 76 + 77 + config BPF_LSM 78 + bool "Enable BPF LSM Instrumentation" 79 + depends on BPF_EVENTS 80 + depends on BPF_SYSCALL 81 + depends on SECURITY 82 + depends on BPF_JIT 83 + help 84 + Enables instrumentation of the security hooks with BPF programs for 85 + implementing dynamic MAC and Audit Policies. 86 + 87 + If you are unsure how to answer this question, answer N. 88 + 89 + endmenu # "BPF subsystem"
+2
kernel/bpf/bpf_lsm.c
··· 107 107 return &bpf_inode_storage_get_proto; 108 108 case BPF_FUNC_inode_storage_delete: 109 109 return &bpf_inode_storage_delete_proto; 110 + #ifdef CONFIG_NET 110 111 case BPF_FUNC_sk_storage_get: 111 112 return &bpf_sk_storage_get_proto; 112 113 case BPF_FUNC_sk_storage_delete: 113 114 return &bpf_sk_storage_delete_proto; 115 + #endif /* CONFIG_NET */ 114 116 case BPF_FUNC_spin_lock: 115 117 return &bpf_spin_lock_proto; 116 118 case BPF_FUNC_spin_unlock:
+12
kernel/bpf/btf.c
··· 5206 5206 m->ret_size = ret; 5207 5207 5208 5208 for (i = 0; i < nargs; i++) { 5209 + if (i == nargs - 1 && args[i].type == 0) { 5210 + bpf_log(log, 5211 + "The function %s with variable args is unsupported.\n", 5212 + tname); 5213 + return -EINVAL; 5214 + } 5209 5215 ret = __get_type_size(btf, args[i].type, &t); 5210 5216 if (ret < 0) { 5211 5217 bpf_log(log, 5212 5218 "The function %s arg%d type %s is unsupported.\n", 5213 5219 tname, i, btf_kind_str[BTF_INFO_KIND(t->info)]); 5220 + return -EINVAL; 5221 + } 5222 + if (ret == 0) { 5223 + bpf_log(log, 5224 + "The function %s has malformed void argument.\n", 5225 + tname); 5214 5226 return -EINVAL; 5215 5227 } 5216 5228 m->arg_size[i] = ret;
+19 -16
kernel/bpf/helpers.c
··· 692 692 return -EINVAL; 693 693 } 694 694 695 - /* Per-cpu temp buffers which can be used by printf-like helpers for %s or %p 695 + /* Per-cpu temp buffers used by printf-like helpers to store the bprintf binary 696 + * arguments representation. 696 697 */ 697 - #define MAX_PRINTF_BUF_LEN 512 698 + #define MAX_BPRINTF_BUF_LEN 512 698 699 699 - struct bpf_printf_buf { 700 - char tmp_buf[MAX_PRINTF_BUF_LEN]; 700 + /* Support executing three nested bprintf helper calls on a given CPU */ 701 + #define MAX_BPRINTF_NEST_LEVEL 3 702 + struct bpf_bprintf_buffers { 703 + char tmp_bufs[MAX_BPRINTF_NEST_LEVEL][MAX_BPRINTF_BUF_LEN]; 701 704 }; 702 - static DEFINE_PER_CPU(struct bpf_printf_buf, bpf_printf_buf); 703 - static DEFINE_PER_CPU(int, bpf_printf_buf_used); 705 + static DEFINE_PER_CPU(struct bpf_bprintf_buffers, bpf_bprintf_bufs); 706 + static DEFINE_PER_CPU(int, bpf_bprintf_nest_level); 704 707 705 708 static int try_get_fmt_tmp_buf(char **tmp_buf) 706 709 { 707 - struct bpf_printf_buf *bufs; 708 - int used; 710 + struct bpf_bprintf_buffers *bufs; 711 + int nest_level; 709 712 710 713 preempt_disable(); 711 - used = this_cpu_inc_return(bpf_printf_buf_used); 712 - if (WARN_ON_ONCE(used > 1)) { 713 - this_cpu_dec(bpf_printf_buf_used); 714 + nest_level = this_cpu_inc_return(bpf_bprintf_nest_level); 715 + if (WARN_ON_ONCE(nest_level > MAX_BPRINTF_NEST_LEVEL)) { 716 + this_cpu_dec(bpf_bprintf_nest_level); 714 717 preempt_enable(); 715 718 return -EBUSY; 716 719 } 717 - bufs = this_cpu_ptr(&bpf_printf_buf); 718 - *tmp_buf = bufs->tmp_buf; 720 + bufs = this_cpu_ptr(&bpf_bprintf_bufs); 721 + *tmp_buf = bufs->tmp_bufs[nest_level - 1]; 719 722 720 723 return 0; 721 724 } 722 725 723 726 void bpf_bprintf_cleanup(void) 724 727 { 725 - if (this_cpu_read(bpf_printf_buf_used)) { 726 - this_cpu_dec(bpf_printf_buf_used); 728 + if (this_cpu_read(bpf_bprintf_nest_level)) { 729 + this_cpu_dec(bpf_bprintf_nest_level); 727 730 preempt_enable(); 728 731 } 729 732 } ··· 763 760 if (num_args && try_get_fmt_tmp_buf(&tmp_buf)) 764 761 return -EBUSY; 765 762 766 - tmp_buf_end = tmp_buf + MAX_PRINTF_BUF_LEN; 763 + tmp_buf_end = tmp_buf + MAX_BPRINTF_BUF_LEN; 767 764 *bin_args = (u32 *)tmp_buf; 768 765 } 769 766
+11 -13
kernel/bpf/ringbuf.c
··· 221 221 return -ENOTSUPP; 222 222 } 223 223 224 - static size_t bpf_ringbuf_mmap_page_cnt(const struct bpf_ringbuf *rb) 225 - { 226 - size_t data_pages = (rb->mask + 1) >> PAGE_SHIFT; 227 - 228 - /* consumer page + producer page + 2 x data pages */ 229 - return RINGBUF_POS_PAGES + 2 * data_pages; 230 - } 231 - 232 224 static int ringbuf_map_mmap(struct bpf_map *map, struct vm_area_struct *vma) 233 225 { 234 226 struct bpf_ringbuf_map *rb_map; 235 - size_t mmap_sz; 236 227 237 228 rb_map = container_of(map, struct bpf_ringbuf_map, map); 238 - mmap_sz = bpf_ringbuf_mmap_page_cnt(rb_map->rb) << PAGE_SHIFT; 239 229 240 - if (vma->vm_pgoff * PAGE_SIZE + (vma->vm_end - vma->vm_start) > mmap_sz) 241 - return -EINVAL; 242 - 230 + if (vma->vm_flags & VM_WRITE) { 231 + /* allow writable mapping for the consumer_pos only */ 232 + if (vma->vm_pgoff != 0 || vma->vm_end - vma->vm_start != PAGE_SIZE) 233 + return -EPERM; 234 + } else { 235 + vma->vm_flags &= ~VM_MAYWRITE; 236 + } 237 + /* remap_vmalloc_range() checks size and offset constraints */ 243 238 return remap_vmalloc_range(vma, rb_map->rb, 244 239 vma->vm_pgoff + RINGBUF_PGOFF); 245 240 } ··· 310 315 return NULL; 311 316 312 317 len = round_up(size + BPF_RINGBUF_HDR_SZ, 8); 318 + if (len > rb->mask + 1) 319 + return NULL; 320 + 313 321 cons_pos = smp_load_acquire(&rb->consumer_pos); 314 322 315 323 if (in_nmi()) {
+2 -1
kernel/bpf/syscall.c
··· 50 50 static DEFINE_IDR(link_idr); 51 51 static DEFINE_SPINLOCK(link_idr_lock); 52 52 53 - int sysctl_unprivileged_bpf_disabled __read_mostly; 53 + int sysctl_unprivileged_bpf_disabled __read_mostly = 54 + IS_BUILTIN(CONFIG_BPF_UNPRIV_DEFAULT_OFF) ? 2 : 0; 54 55 55 56 static const struct bpf_map_ops * const bpf_map_types[] = { 56 57 #define BPF_PROG_TYPE(_id, _name, prog_ctx_type, kern_ctx_type)
+57 -37
kernel/bpf/verifier.c
··· 6409 6409 }; 6410 6410 6411 6411 static int retrieve_ptr_limit(const struct bpf_reg_state *ptr_reg, 6412 - const struct bpf_reg_state *off_reg, 6413 - u32 *alu_limit, u8 opcode) 6412 + u32 *alu_limit, bool mask_to_left) 6414 6413 { 6415 - bool off_is_neg = off_reg->smin_value < 0; 6416 - bool mask_to_left = (opcode == BPF_ADD && off_is_neg) || 6417 - (opcode == BPF_SUB && !off_is_neg); 6418 6414 u32 max = 0, ptr_limit = 0; 6419 - 6420 - if (!tnum_is_const(off_reg->var_off) && 6421 - (off_reg->smin_value < 0) != (off_reg->smax_value < 0)) 6422 - return REASON_BOUNDS; 6423 6415 6424 6416 switch (ptr_reg->type) { 6425 6417 case PTR_TO_STACK: ··· 6478 6486 return opcode == BPF_ADD || opcode == BPF_SUB; 6479 6487 } 6480 6488 6489 + struct bpf_sanitize_info { 6490 + struct bpf_insn_aux_data aux; 6491 + bool mask_to_left; 6492 + }; 6493 + 6481 6494 static int sanitize_ptr_alu(struct bpf_verifier_env *env, 6482 6495 struct bpf_insn *insn, 6483 6496 const struct bpf_reg_state *ptr_reg, 6484 6497 const struct bpf_reg_state *off_reg, 6485 6498 struct bpf_reg_state *dst_reg, 6486 - struct bpf_insn_aux_data *tmp_aux, 6499 + struct bpf_sanitize_info *info, 6487 6500 const bool commit_window) 6488 6501 { 6489 - struct bpf_insn_aux_data *aux = commit_window ? cur_aux(env) : tmp_aux; 6502 + struct bpf_insn_aux_data *aux = commit_window ? cur_aux(env) : &info->aux; 6490 6503 struct bpf_verifier_state *vstate = env->cur_state; 6491 6504 bool off_is_imm = tnum_is_const(off_reg->var_off); 6492 6505 bool off_is_neg = off_reg->smin_value < 0; ··· 6512 6515 if (vstate->speculative) 6513 6516 goto do_sim; 6514 6517 6515 - err = retrieve_ptr_limit(ptr_reg, off_reg, &alu_limit, opcode); 6518 + if (!commit_window) { 6519 + if (!tnum_is_const(off_reg->var_off) && 6520 + (off_reg->smin_value < 0) != (off_reg->smax_value < 0)) 6521 + return REASON_BOUNDS; 6522 + 6523 + info->mask_to_left = (opcode == BPF_ADD && off_is_neg) || 6524 + (opcode == BPF_SUB && !off_is_neg); 6525 + } 6526 + 6527 + err = retrieve_ptr_limit(ptr_reg, &alu_limit, info->mask_to_left); 6516 6528 if (err < 0) 6517 6529 return err; 6518 6530 ··· 6529 6523 /* In commit phase we narrow the masking window based on 6530 6524 * the observed pointer move after the simulated operation. 6531 6525 */ 6532 - alu_state = tmp_aux->alu_state; 6533 - alu_limit = abs(tmp_aux->alu_limit - alu_limit); 6526 + alu_state = info->aux.alu_state; 6527 + alu_limit = abs(info->aux.alu_limit - alu_limit); 6534 6528 } else { 6535 6529 alu_state = off_is_neg ? BPF_ALU_NEG_VALUE : 0; 6536 6530 alu_state |= off_is_imm ? BPF_ALU_IMMEDIATE : 0; ··· 6545 6539 /* If we're in commit phase, we're done here given we already 6546 6540 * pushed the truncated dst_reg into the speculative verification 6547 6541 * stack. 6542 + * 6543 + * Also, when register is a known constant, we rewrite register-based 6544 + * operation to immediate-based, and thus do not need masking (and as 6545 + * a consequence, do not need to simulate the zero-truncation either). 6548 6546 */ 6549 - if (commit_window) 6547 + if (commit_window || off_is_imm) 6550 6548 return 0; 6551 6549 6552 6550 /* Simulate and find potential out-of-bounds access under ··· 6695 6685 smin_ptr = ptr_reg->smin_value, smax_ptr = ptr_reg->smax_value; 6696 6686 u64 umin_val = off_reg->umin_value, umax_val = off_reg->umax_value, 6697 6687 umin_ptr = ptr_reg->umin_value, umax_ptr = ptr_reg->umax_value; 6698 - struct bpf_insn_aux_data tmp_aux = {}; 6688 + struct bpf_sanitize_info info = {}; 6699 6689 u8 opcode = BPF_OP(insn->code); 6700 6690 u32 dst = insn->dst_reg; 6701 6691 int ret; ··· 6764 6754 6765 6755 if (sanitize_needed(opcode)) { 6766 6756 ret = sanitize_ptr_alu(env, insn, ptr_reg, off_reg, dst_reg, 6767 - &tmp_aux, false); 6757 + &info, false); 6768 6758 if (ret < 0) 6769 6759 return sanitize_err(env, insn, ret, off_reg, dst_reg); 6770 6760 } ··· 6905 6895 return -EACCES; 6906 6896 if (sanitize_needed(opcode)) { 6907 6897 ret = sanitize_ptr_alu(env, insn, dst_reg, off_reg, dst_reg, 6908 - &tmp_aux, true); 6898 + &info, true); 6909 6899 if (ret < 0) 6910 6900 return sanitize_err(env, insn, ret, off_reg, dst_reg); 6911 6901 } ··· 7094 7084 s32 smin_val = src_reg->s32_min_value; 7095 7085 u32 umax_val = src_reg->u32_max_value; 7096 7086 7097 - /* Assuming scalar64_min_max_and will be called so its safe 7098 - * to skip updating register for known 32-bit case. 7099 - */ 7100 - if (src_known && dst_known) 7087 + if (src_known && dst_known) { 7088 + __mark_reg32_known(dst_reg, var32_off.value); 7101 7089 return; 7090 + } 7102 7091 7103 7092 /* We get our minimum from the var_off, since that's inherently 7104 7093 * bitwise. Our maximum is the minimum of the operands' maxima. ··· 7117 7108 dst_reg->s32_min_value = dst_reg->u32_min_value; 7118 7109 dst_reg->s32_max_value = dst_reg->u32_max_value; 7119 7110 } 7120 - 7121 7111 } 7122 7112 7123 7113 static void scalar_min_max_and(struct bpf_reg_state *dst_reg, ··· 7163 7155 s32 smin_val = src_reg->s32_min_value; 7164 7156 u32 umin_val = src_reg->u32_min_value; 7165 7157 7166 - /* Assuming scalar64_min_max_or will be called so it is safe 7167 - * to skip updating register for known case. 7168 - */ 7169 - if (src_known && dst_known) 7158 + if (src_known && dst_known) { 7159 + __mark_reg32_known(dst_reg, var32_off.value); 7170 7160 return; 7161 + } 7171 7162 7172 7163 /* We get our maximum from the var_off, and our minimum is the 7173 7164 * maximum of the operands' minima ··· 7231 7224 struct tnum var32_off = tnum_subreg(dst_reg->var_off); 7232 7225 s32 smin_val = src_reg->s32_min_value; 7233 7226 7234 - /* Assuming scalar64_min_max_xor will be called so it is safe 7235 - * to skip updating register for known case. 7236 - */ 7237 - if (src_known && dst_known) 7227 + if (src_known && dst_known) { 7228 + __mark_reg32_known(dst_reg, var32_off.value); 7238 7229 return; 7230 + } 7239 7231 7240 7232 /* We get both minimum and maximum from the var32_off. */ 7241 7233 dst_reg->u32_min_value = var32_off.value; ··· 13206 13200 return 0; 13207 13201 } 13208 13202 13203 + BTF_SET_START(btf_id_deny) 13204 + BTF_ID_UNUSED 13205 + #ifdef CONFIG_SMP 13206 + BTF_ID(func, migrate_disable) 13207 + BTF_ID(func, migrate_enable) 13208 + #endif 13209 + #if !defined CONFIG_PREEMPT_RCU && !defined CONFIG_TINY_RCU 13210 + BTF_ID(func, rcu_read_unlock_strict) 13211 + #endif 13212 + BTF_SET_END(btf_id_deny) 13213 + 13209 13214 static int check_attach_btf_id(struct bpf_verifier_env *env) 13210 13215 { 13211 13216 struct bpf_prog *prog = env->prog; ··· 13276 13259 ret = bpf_lsm_verify_prog(&env->log, prog); 13277 13260 if (ret < 0) 13278 13261 return ret; 13262 + } else if (prog->type == BPF_PROG_TYPE_TRACING && 13263 + btf_id_set_contains(&btf_id_deny, btf_id)) { 13264 + return -EINVAL; 13279 13265 } 13280 13266 13281 13267 key = bpf_trampoline_compute_key(tgt_prog, prog->aux->attach_btf, btf_id); ··· 13378 13358 if (is_priv) 13379 13359 env->test_state_freq = attr->prog_flags & BPF_F_TEST_STATE_FREQ; 13380 13360 13381 - if (bpf_prog_is_dev_bound(env->prog->aux)) { 13382 - ret = bpf_prog_offload_verifier_prep(env->prog); 13383 - if (ret) 13384 - goto skip_full_check; 13385 - } 13386 - 13387 13361 env->explored_states = kvcalloc(state_htab_size(env), 13388 13362 sizeof(struct bpf_verifier_state_list *), 13389 13363 GFP_USER); ··· 13404 13390 ret = resolve_pseudo_ldimm64(env); 13405 13391 if (ret < 0) 13406 13392 goto skip_full_check; 13393 + 13394 + if (bpf_prog_is_dev_bound(env->prog->aux)) { 13395 + ret = bpf_prog_offload_verifier_prep(env->prog); 13396 + if (ret) 13397 + goto skip_full_check; 13398 + } 13407 13399 13408 13400 ret = check_cfg(env); 13409 13401 if (ret < 0)
+16 -14
kernel/seccomp.c
··· 1105 1105 1106 1106 up(&match->notif->request); 1107 1107 wake_up_poll(&match->wqh, EPOLLIN | EPOLLRDNORM); 1108 - mutex_unlock(&match->notify_lock); 1109 1108 1110 1109 /* 1111 1110 * This is where we wait for a reply from userspace. 1112 1111 */ 1113 - wait: 1114 - err = wait_for_completion_interruptible(&n.ready); 1115 - mutex_lock(&match->notify_lock); 1116 - if (err == 0) { 1117 - /* Check if we were woken up by a addfd message */ 1112 + do { 1113 + mutex_unlock(&match->notify_lock); 1114 + err = wait_for_completion_interruptible(&n.ready); 1115 + mutex_lock(&match->notify_lock); 1116 + if (err != 0) 1117 + goto interrupted; 1118 + 1118 1119 addfd = list_first_entry_or_null(&n.addfd, 1119 1120 struct seccomp_kaddfd, list); 1120 - if (addfd && n.state != SECCOMP_NOTIFY_REPLIED) { 1121 + /* Check if we were woken up by a addfd message */ 1122 + if (addfd) 1121 1123 seccomp_handle_addfd(addfd); 1122 - mutex_unlock(&match->notify_lock); 1123 - goto wait; 1124 - } 1125 - ret = n.val; 1126 - err = n.error; 1127 - flags = n.flags; 1128 - } 1129 1124 1125 + } while (n.state != SECCOMP_NOTIFY_REPLIED); 1126 + 1127 + ret = n.val; 1128 + err = n.error; 1129 + flags = n.flags; 1130 + 1131 + interrupted: 1130 1132 /* If there were any pending addfd calls, clear them out */ 1131 1133 list_for_each_entry_safe(addfd, tmp, &n.addfd, list) { 1132 1134 /* The process went away before we got a chance to handle it */
+24 -5
kernel/sysctl.c
··· 225 225 mutex_unlock(&bpf_stats_enabled_mutex); 226 226 return ret; 227 227 } 228 - #endif 228 + 229 + static int bpf_unpriv_handler(struct ctl_table *table, int write, 230 + void *buffer, size_t *lenp, loff_t *ppos) 231 + { 232 + int ret, unpriv_enable = *(int *)table->data; 233 + bool locked_state = unpriv_enable == 1; 234 + struct ctl_table tmp = *table; 235 + 236 + if (write && !capable(CAP_SYS_ADMIN)) 237 + return -EPERM; 238 + 239 + tmp.data = &unpriv_enable; 240 + ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 241 + if (write && !ret) { 242 + if (locked_state && unpriv_enable != 1) 243 + return -EPERM; 244 + *(int *)table->data = unpriv_enable; 245 + } 246 + return ret; 247 + } 248 + #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */ 229 249 230 250 /* 231 251 * /proc/sys support ··· 2620 2600 .data = &sysctl_unprivileged_bpf_disabled, 2621 2601 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), 2622 2602 .mode = 0644, 2623 - /* only handle a transition from default "0" to "1" */ 2624 - .proc_handler = proc_dointvec_minmax, 2625 - .extra1 = SYSCTL_ONE, 2626 - .extra2 = SYSCTL_ONE, 2603 + .proc_handler = bpf_unpriv_handler, 2604 + .extra1 = SYSCTL_ZERO, 2605 + .extra2 = &two, 2627 2606 }, 2628 2607 { 2629 2608 .procname = "bpf_stats_enabled",
+3 -3
lib/percpu-refcount.c
··· 275 275 wait_event_lock_irq(percpu_ref_switch_waitq, !data->confirm_switch, 276 276 percpu_ref_switch_lock); 277 277 278 - if (data->force_atomic || (ref->percpu_count_ptr & __PERCPU_REF_DEAD)) 278 + if (data->force_atomic || percpu_ref_is_dying(ref)) 279 279 __percpu_ref_switch_to_atomic(ref, confirm_switch); 280 280 else 281 281 __percpu_ref_switch_to_percpu(ref); ··· 385 385 386 386 spin_lock_irqsave(&percpu_ref_switch_lock, flags); 387 387 388 - WARN_ONCE(ref->percpu_count_ptr & __PERCPU_REF_DEAD, 388 + WARN_ONCE(percpu_ref_is_dying(ref), 389 389 "%s called more than once on %ps!", __func__, 390 390 ref->data->release); 391 391 ··· 465 465 466 466 spin_lock_irqsave(&percpu_ref_switch_lock, flags); 467 467 468 - WARN_ON_ONCE(!(ref->percpu_count_ptr & __PERCPU_REF_DEAD)); 468 + WARN_ON_ONCE(!percpu_ref_is_dying(ref)); 469 469 WARN_ON_ONCE(__ref_is_percpu(ref, &percpu_count)); 470 470 471 471 ref->percpu_count_ptr &= ~__PERCPU_REF_DEAD;
-27
net/Kconfig
··· 302 302 select DQL 303 303 default y 304 304 305 - config BPF_JIT 306 - bool "enable BPF Just In Time compiler" 307 - depends on HAVE_CBPF_JIT || HAVE_EBPF_JIT 308 - depends on MODULES 309 - help 310 - Berkeley Packet Filter filtering capabilities are normally handled 311 - by an interpreter. This option allows kernel to generate a native 312 - code when filter is loaded in memory. This should speedup 313 - packet sniffing (libpcap/tcpdump). 314 - 315 - Note, admin should enable this feature changing: 316 - /proc/sys/net/core/bpf_jit_enable 317 - /proc/sys/net/core/bpf_jit_harden (optional) 318 - /proc/sys/net/core/bpf_jit_kallsyms (optional) 319 - 320 305 config BPF_STREAM_PARSER 321 306 bool "enable BPF STREAM_PARSER" 322 307 depends on INET ··· 455 470 e.g. notification messages. 456 471 457 472 endif # if NET 458 - 459 - # Used by archs to tell that they support BPF JIT compiler plus which flavour. 460 - # Only one of the two can be selected for a specific arch since eBPF JIT supersedes 461 - # the cBPF JIT. 462 - 463 - # Classic BPF JIT (cBPF) 464 - config HAVE_CBPF_JIT 465 - bool 466 - 467 - # Extended BPF JIT (eBPF) 468 - config HAVE_EBPF_JIT 469 - bool
+34 -17
net/can/isotp.c
··· 1062 1062 if (len < ISOTP_MIN_NAMELEN) 1063 1063 return -EINVAL; 1064 1064 1065 - /* do not register frame reception for functional addressing */ 1066 - if (so->opt.flags & CAN_ISOTP_SF_BROADCAST) 1067 - do_rx_reg = 0; 1068 - 1069 - /* do not validate rx address for functional addressing */ 1070 - if (do_rx_reg) { 1071 - if (addr->can_addr.tp.rx_id == addr->can_addr.tp.tx_id) 1072 - return -EADDRNOTAVAIL; 1073 - 1074 - if (addr->can_addr.tp.rx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG)) 1075 - return -EADDRNOTAVAIL; 1076 - } 1077 - 1078 1065 if (addr->can_addr.tp.tx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG)) 1079 1066 return -EADDRNOTAVAIL; 1080 1067 ··· 1069 1082 return -ENODEV; 1070 1083 1071 1084 lock_sock(sk); 1085 + 1086 + /* do not register frame reception for functional addressing */ 1087 + if (so->opt.flags & CAN_ISOTP_SF_BROADCAST) 1088 + do_rx_reg = 0; 1089 + 1090 + /* do not validate rx address for functional addressing */ 1091 + if (do_rx_reg) { 1092 + if (addr->can_addr.tp.rx_id == addr->can_addr.tp.tx_id) { 1093 + err = -EADDRNOTAVAIL; 1094 + goto out; 1095 + } 1096 + 1097 + if (addr->can_addr.tp.rx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG)) { 1098 + err = -EADDRNOTAVAIL; 1099 + goto out; 1100 + } 1101 + } 1072 1102 1073 1103 if (so->bound && addr->can_ifindex == so->ifindex && 1074 1104 addr->can_addr.tp.rx_id == so->rxid && ··· 1168 1164 return ISOTP_MIN_NAMELEN; 1169 1165 } 1170 1166 1171 - static int isotp_setsockopt(struct socket *sock, int level, int optname, 1167 + static int isotp_setsockopt_locked(struct socket *sock, int level, int optname, 1172 1168 sockptr_t optval, unsigned int optlen) 1173 1169 { 1174 1170 struct sock *sk = sock->sk; 1175 1171 struct isotp_sock *so = isotp_sk(sk); 1176 1172 int ret = 0; 1177 - 1178 - if (level != SOL_CAN_ISOTP) 1179 - return -EINVAL; 1180 1173 1181 1174 if (so->bound) 1182 1175 return -EISCONN; ··· 1246 1245 ret = -ENOPROTOOPT; 1247 1246 } 1248 1247 1248 + return ret; 1249 + } 1250 + 1251 + static int isotp_setsockopt(struct socket *sock, int level, int optname, 1252 + sockptr_t optval, unsigned int optlen) 1253 + 1254 + { 1255 + struct sock *sk = sock->sk; 1256 + int ret; 1257 + 1258 + if (level != SOL_CAN_ISOTP) 1259 + return -EINVAL; 1260 + 1261 + lock_sock(sk); 1262 + ret = isotp_setsockopt_locked(sock, level, optname, optval, optlen); 1263 + release_sock(sk); 1249 1264 return ret; 1250 1265 } 1251 1266
+24 -5
net/core/dev.c
··· 3853 3853 3854 3854 if (q->flags & TCQ_F_NOLOCK) { 3855 3855 rc = q->enqueue(skb, q, &to_free) & NET_XMIT_MASK; 3856 - qdisc_run(q); 3856 + if (likely(!netif_xmit_frozen_or_stopped(txq))) 3857 + qdisc_run(q); 3857 3858 3858 3859 if (unlikely(to_free)) 3859 3860 kfree_skb_list(to_free); ··· 5026 5025 sd->output_queue_tailp = &sd->output_queue; 5027 5026 local_irq_enable(); 5028 5027 5028 + rcu_read_lock(); 5029 + 5029 5030 while (head) { 5030 5031 struct Qdisc *q = head; 5031 5032 spinlock_t *root_lock = NULL; 5032 5033 5033 5034 head = head->next_sched; 5034 5035 5035 - if (!(q->flags & TCQ_F_NOLOCK)) { 5036 - root_lock = qdisc_lock(q); 5037 - spin_lock(root_lock); 5038 - } 5039 5036 /* We need to make sure head->next_sched is read 5040 5037 * before clearing __QDISC_STATE_SCHED 5041 5038 */ 5042 5039 smp_mb__before_atomic(); 5040 + 5041 + if (!(q->flags & TCQ_F_NOLOCK)) { 5042 + root_lock = qdisc_lock(q); 5043 + spin_lock(root_lock); 5044 + } else if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED, 5045 + &q->state))) { 5046 + /* There is a synchronize_net() between 5047 + * STATE_DEACTIVATED flag being set and 5048 + * qdisc_reset()/some_qdisc_is_busy() in 5049 + * dev_deactivate(), so we can safely bail out 5050 + * early here to avoid data race between 5051 + * qdisc_deactivate() and some_qdisc_is_busy() 5052 + * for lockless qdisc. 5053 + */ 5054 + clear_bit(__QDISC_STATE_SCHED, &q->state); 5055 + continue; 5056 + } 5057 + 5043 5058 clear_bit(__QDISC_STATE_SCHED, &q->state); 5044 5059 qdisc_run(q); 5045 5060 if (root_lock) 5046 5061 spin_unlock(root_lock); 5047 5062 } 5063 + 5064 + rcu_read_unlock(); 5048 5065 } 5049 5066 5050 5067 xfrm_dev_backlog(sd);
+1
net/core/filter.c
··· 3784 3784 __skb_push(skb, head_room); 3785 3785 memset(skb->data, 0, head_room); 3786 3786 skb_reset_mac_header(skb); 3787 + skb_reset_mac_len(skb); 3787 3788 } 3788 3789 3789 3790 return ret;
+4 -4
net/core/sock.c
··· 2132 2132 if (skb_is_tcp_pure_ack(skb)) 2133 2133 return; 2134 2134 2135 - if (can_skb_orphan_partial(skb)) 2136 - skb_set_owner_sk_safe(skb, skb->sk); 2137 - else 2138 - skb_orphan(skb); 2135 + if (can_skb_orphan_partial(skb) && skb_set_owner_sk_safe(skb, skb->sk)) 2136 + return; 2137 + 2138 + skb_orphan(skb); 2139 2139 } 2140 2140 EXPORT_SYMBOL(skb_orphan_partial); 2141 2141
+3 -2
net/dsa/master.c
··· 147 147 struct dsa_switch *ds = cpu_dp->ds; 148 148 int port = cpu_dp->index; 149 149 int len = ETH_GSTRING_LEN; 150 - int mcount = 0, count; 151 - unsigned int i; 150 + int mcount = 0, count, i; 152 151 uint8_t pfx[4]; 153 152 uint8_t *ndata; 154 153 ··· 177 178 */ 178 179 ds->ops->get_strings(ds, port, stringset, ndata); 179 180 count = ds->ops->get_sset_count(ds, port, stringset); 181 + if (count < 0) 182 + return; 180 183 for (i = 0; i < count; i++) { 181 184 memmove(ndata + (i * len + sizeof(pfx)), 182 185 ndata + i * len, len - sizeof(pfx));
+7 -5
net/dsa/slave.c
··· 776 776 struct dsa_switch *ds = dp->ds; 777 777 778 778 if (sset == ETH_SS_STATS) { 779 - int count; 779 + int count = 0; 780 780 781 - count = 4; 782 - if (ds->ops->get_sset_count) 783 - count += ds->ops->get_sset_count(ds, dp->index, sset); 781 + if (ds->ops->get_sset_count) { 782 + count = ds->ops->get_sset_count(ds, dp->index, sset); 783 + if (count < 0) 784 + return count; 785 + } 784 786 785 - return count; 787 + return count + 4; 786 788 } else if (sset == ETH_SS_TEST) { 787 789 return net_selftest_get_count(); 788 790 }
+1 -1
net/ethtool/stats.c
··· 119 119 */ 120 120 memset(&data->phy_stats, 0xff, sizeof(data->phy_stats)); 121 121 memset(&data->mac_stats, 0xff, sizeof(data->mac_stats)); 122 - memset(&data->ctrl_stats, 0xff, sizeof(data->mac_stats)); 122 + memset(&data->ctrl_stats, 0xff, sizeof(data->ctrl_stats)); 123 123 memset(&data->rmon_stats, 0xff, sizeof(data->rmon_stats)); 124 124 125 125 if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask) &&
+2
net/hsr/hsr_device.c
··· 218 218 if (master) { 219 219 skb->dev = master->dev; 220 220 skb_reset_mac_header(skb); 221 + skb_reset_mac_len(skb); 221 222 hsr_forward_skb(skb, master); 222 223 } else { 223 224 atomic_long_inc(&dev->tx_dropped); ··· 260 259 goto out; 261 260 262 261 skb_reset_mac_header(skb); 262 + skb_reset_mac_len(skb); 263 263 skb_reset_network_header(skb); 264 264 skb_reset_transport_header(skb); 265 265
+21 -9
net/hsr/hsr_forward.c
··· 474 474 } 475 475 } 476 476 477 - void hsr_fill_frame_info(__be16 proto, struct sk_buff *skb, 478 - struct hsr_frame_info *frame) 477 + int hsr_fill_frame_info(__be16 proto, struct sk_buff *skb, 478 + struct hsr_frame_info *frame) 479 479 { 480 480 struct hsr_port *port = frame->port_rcv; 481 481 struct hsr_priv *hsr = port->hsr; ··· 483 483 /* HSRv0 supervisory frames double as a tag so treat them as tagged. */ 484 484 if ((!hsr->prot_version && proto == htons(ETH_P_PRP)) || 485 485 proto == htons(ETH_P_HSR)) { 486 + /* Check if skb contains hsr_ethhdr */ 487 + if (skb->mac_len < sizeof(struct hsr_ethhdr)) 488 + return -EINVAL; 489 + 486 490 /* HSR tagged frame :- Data or Supervision */ 487 491 frame->skb_std = NULL; 488 492 frame->skb_prp = NULL; 489 493 frame->skb_hsr = skb; 490 494 frame->sequence_nr = hsr_get_skb_sequence_nr(skb); 491 - return; 495 + return 0; 492 496 } 493 497 494 498 /* Standard frame or PRP from master port */ 495 499 handle_std_frame(skb, frame); 500 + 501 + return 0; 496 502 } 497 503 498 - void prp_fill_frame_info(__be16 proto, struct sk_buff *skb, 499 - struct hsr_frame_info *frame) 504 + int prp_fill_frame_info(__be16 proto, struct sk_buff *skb, 505 + struct hsr_frame_info *frame) 500 506 { 501 507 /* Supervision frame */ 502 508 struct prp_rct *rct = skb_get_PRP_rct(skb); ··· 513 507 frame->skb_std = NULL; 514 508 frame->skb_prp = skb; 515 509 frame->sequence_nr = prp_get_skb_sequence_nr(rct); 516 - return; 510 + return 0; 517 511 } 518 512 handle_std_frame(skb, frame); 513 + 514 + return 0; 519 515 } 520 516 521 517 static int fill_frame_info(struct hsr_frame_info *frame, ··· 527 519 struct hsr_vlan_ethhdr *vlan_hdr; 528 520 struct ethhdr *ethhdr; 529 521 __be16 proto; 522 + int ret; 530 523 531 - /* Check if skb contains hsr_ethhdr */ 532 - if (skb->mac_len < sizeof(struct hsr_ethhdr)) 524 + /* Check if skb contains ethhdr */ 525 + if (skb->mac_len < sizeof(struct ethhdr)) 533 526 return -EINVAL; 534 527 535 528 memset(frame, 0, sizeof(*frame)); ··· 557 548 558 549 frame->is_from_san = false; 559 550 frame->port_rcv = port; 560 - hsr->proto_ops->fill_frame_info(proto, skb, frame); 551 + ret = hsr->proto_ops->fill_frame_info(proto, skb, frame); 552 + if (ret) 553 + return ret; 554 + 561 555 check_local_dest(port->hsr, skb, frame); 562 556 563 557 return 0;
+4 -4
net/hsr/hsr_forward.h
··· 24 24 struct hsr_port *port); 25 25 bool prp_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port); 26 26 bool hsr_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port); 27 - void prp_fill_frame_info(__be16 proto, struct sk_buff *skb, 28 - struct hsr_frame_info *frame); 29 - void hsr_fill_frame_info(__be16 proto, struct sk_buff *skb, 30 - struct hsr_frame_info *frame); 27 + int prp_fill_frame_info(__be16 proto, struct sk_buff *skb, 28 + struct hsr_frame_info *frame); 29 + int hsr_fill_frame_info(__be16 proto, struct sk_buff *skb, 30 + struct hsr_frame_info *frame); 31 31 #endif /* __HSR_FORWARD_H */
+2 -2
net/hsr/hsr_main.h
··· 186 186 struct hsr_port *port); 187 187 struct sk_buff * (*create_tagged_frame)(struct hsr_frame_info *frame, 188 188 struct hsr_port *port); 189 - void (*fill_frame_info)(__be16 proto, struct sk_buff *skb, 190 - struct hsr_frame_info *frame); 189 + int (*fill_frame_info)(__be16 proto, struct sk_buff *skb, 190 + struct hsr_frame_info *frame); 191 191 bool (*invalid_dan_ingress_frame)(__be16 protocol); 192 192 void (*update_san_info)(struct hsr_node *node, bool is_sup); 193 193 };
+5 -6
net/hsr/hsr_slave.c
··· 60 60 goto finish_pass; 61 61 62 62 skb_push(skb, ETH_HLEN); 63 - 64 - if (skb_mac_header(skb) != skb->data) { 65 - WARN_ONCE(1, "%s:%d: Malformed frame at source port %s)\n", 66 - __func__, __LINE__, port->dev->name); 67 - goto finish_consume; 68 - } 63 + skb_reset_mac_header(skb); 64 + if ((!hsr->prot_version && protocol == htons(ETH_P_PRP)) || 65 + protocol == htons(ETH_P_HSR)) 66 + skb_set_network_header(skb, ETH_HLEN + HSR_HLEN); 67 + skb_reset_mac_len(skb); 69 68 70 69 hsr_forward_skb(skb, port); 71 70
+2
net/ipv4/bpf_tcp_ca.c
··· 185 185 BTF_ID(func, tcp_reno_undo_cwnd) 186 186 BTF_ID(func, tcp_slow_start) 187 187 BTF_ID(func, tcp_cong_avoid_ai) 188 + #ifdef CONFIG_X86 188 189 #ifdef CONFIG_DYNAMIC_FTRACE 189 190 #if IS_BUILTIN(CONFIG_TCP_CONG_CUBIC) 190 191 BTF_ID(func, cubictcp_init) ··· 214 213 BTF_ID(func, bbr_set_state) 215 214 #endif 216 215 #endif /* CONFIG_DYNAMIC_FTRACE */ 216 + #endif /* CONFIG_X86 */ 217 217 BTF_SET_END(bpf_tcp_ca_kfunc_ids) 218 218 219 219 static bool bpf_tcp_ca_check_kfunc_call(u32 kfunc_btf_id)
-3
net/ipv6/mcast.c
··· 1745 1745 IPV6_TLV_PADN, 0 }; 1746 1746 1747 1747 /* we assume size > sizeof(ra) here */ 1748 - /* limit our allocations to order-0 page */ 1749 - size = min_t(int, size, SKB_MAX_ORDER(0, 0)); 1750 1748 skb = sock_alloc_send_skb(sk, size, 1, &err); 1751 - 1752 1749 if (!skb) 1753 1750 return NULL; 1754 1751
+3 -1
net/ipv6/reassembly.c
··· 343 343 hdr = ipv6_hdr(skb); 344 344 fhdr = (struct frag_hdr *)skb_transport_header(skb); 345 345 346 - if (!(fhdr->frag_off & htons(0xFFF9))) { 346 + if (!(fhdr->frag_off & htons(IP6_OFFSET | IP6_MF))) { 347 347 /* It is not a fragmented frame */ 348 348 skb->transport_header += sizeof(struct frag_hdr); 349 349 __IP6_INC_STATS(net, ··· 351 351 352 352 IP6CB(skb)->nhoff = (u8 *)fhdr - skb_network_header(skb); 353 353 IP6CB(skb)->flags |= IP6SKB_FRAGMENTED; 354 + IP6CB(skb)->frag_max_size = ntohs(hdr->payload_len) + 355 + sizeof(struct ipv6hdr); 354 356 return 1; 355 357 } 356 358
+13 -23
net/mac80211/ieee80211_i.h
··· 50 50 #define IEEE80211_ENCRYPT_HEADROOM 8 51 51 #define IEEE80211_ENCRYPT_TAILROOM 18 52 52 53 - /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent 54 - * reception of at least three fragmented frames. This limit can be increased 55 - * by changing this define, at the cost of slower frame reassembly and 56 - * increased memory use (about 2 kB of RAM per entry). */ 57 - #define IEEE80211_FRAGMENT_MAX 4 58 - 59 53 /* power level hasn't been configured (or set to automatic) */ 60 54 #define IEEE80211_UNSET_POWER_LEVEL INT_MIN 61 55 ··· 81 87 #define IEEE80211_DEAUTH_FRAME_LEN (24 /* hdr */ + 2 /* reason */) 82 88 83 89 #define IEEE80211_MAX_NAN_INSTANCE_ID 255 84 - 85 - struct ieee80211_fragment_entry { 86 - struct sk_buff_head skb_list; 87 - unsigned long first_frag_time; 88 - u16 seq; 89 - u16 extra_len; 90 - u16 last_frag; 91 - u8 rx_queue; 92 - bool check_sequential_pn; /* needed for CCMP/GCMP */ 93 - u8 last_pn[6]; /* PN of the last fragment if CCMP was used */ 94 - }; 95 - 96 90 97 91 struct ieee80211_bss { 98 92 u32 device_ts_beacon, device_ts_presp; ··· 223 241 */ 224 242 int security_idx; 225 243 226 - u32 tkip_iv32; 227 - u16 tkip_iv16; 244 + union { 245 + struct { 246 + u32 iv32; 247 + u16 iv16; 248 + } tkip; 249 + struct { 250 + u8 pn[IEEE80211_CCMP_PN_LEN]; 251 + } ccm_gcm; 252 + }; 228 253 }; 229 254 230 255 struct ieee80211_csa_settings { ··· 891 902 892 903 char name[IFNAMSIZ]; 893 904 894 - /* Fragment table for host-based reassembly */ 895 - struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX]; 896 - unsigned int fragment_next; 905 + struct ieee80211_fragment_cache frags; 897 906 898 907 /* TID bitmap for NoAck policy */ 899 908 u16 noack_map; ··· 2306 2319 #else 2307 2320 #define debug_noinline 2308 2321 #endif 2322 + 2323 + void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache); 2324 + void ieee80211_destroy_frag_cache(struct ieee80211_fragment_cache *cache); 2309 2325 2310 2326 #endif /* IEEE80211_I_H */
+3 -8
net/mac80211/iface.c
··· 8 8 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> 9 9 * Copyright 2013-2014 Intel Mobile Communications GmbH 10 10 * Copyright (c) 2016 Intel Deutschland GmbH 11 - * Copyright (C) 2018-2020 Intel Corporation 11 + * Copyright (C) 2018-2021 Intel Corporation 12 12 */ 13 13 #include <linux/slab.h> 14 14 #include <linux/kernel.h> ··· 677 677 */ 678 678 static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata) 679 679 { 680 - int i; 681 - 682 680 /* free extra data */ 683 681 ieee80211_free_keys(sdata, false); 684 682 685 683 ieee80211_debugfs_remove_netdev(sdata); 686 684 687 - for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) 688 - __skb_queue_purge(&sdata->fragments[i].skb_list); 689 - sdata->fragment_next = 0; 685 + ieee80211_destroy_frag_cache(&sdata->frags); 690 686 691 687 if (ieee80211_vif_is_mesh(&sdata->vif)) 692 688 ieee80211_mesh_teardown_sdata(sdata); ··· 1926 1930 sdata->wdev.wiphy = local->hw.wiphy; 1927 1931 sdata->local = local; 1928 1932 1929 - for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) 1930 - skb_queue_head_init(&sdata->fragments[i].skb_list); 1933 + ieee80211_init_frag_cache(&sdata->frags); 1931 1934 1932 1935 INIT_LIST_HEAD(&sdata->key_list); 1933 1936
+7
net/mac80211/key.c
··· 799 799 struct ieee80211_sub_if_data *sdata, 800 800 struct sta_info *sta) 801 801 { 802 + static atomic_t key_color = ATOMIC_INIT(0); 802 803 struct ieee80211_key *old_key; 803 804 int idx = key->conf.keyidx; 804 805 bool pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; ··· 850 849 key->local = sdata->local; 851 850 key->sdata = sdata; 852 851 key->sta = sta; 852 + 853 + /* 854 + * Assign a unique ID to every key so we can easily prevent mixed 855 + * key and fragment cache attacks. 856 + */ 857 + key->color = atomic_inc_return(&key_color); 853 858 854 859 increment_tailroom_need_count(sdata); 855 860
+2
net/mac80211/key.h
··· 128 128 } debugfs; 129 129 #endif 130 130 131 + unsigned int color; 132 + 131 133 /* 132 134 * key config, must be last because it contains key 133 135 * material as variable length member
+117 -33
net/mac80211/rx.c
··· 6 6 * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net> 7 7 * Copyright 2013-2014 Intel Mobile Communications GmbH 8 8 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH 9 - * Copyright (C) 2018-2020 Intel Corporation 9 + * Copyright (C) 2018-2021 Intel Corporation 10 10 */ 11 11 12 12 #include <linux/jiffies.h> ··· 2123 2123 return result; 2124 2124 } 2125 2125 2126 + void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache) 2127 + { 2128 + int i; 2129 + 2130 + for (i = 0; i < ARRAY_SIZE(cache->entries); i++) 2131 + skb_queue_head_init(&cache->entries[i].skb_list); 2132 + } 2133 + 2134 + void ieee80211_destroy_frag_cache(struct ieee80211_fragment_cache *cache) 2135 + { 2136 + int i; 2137 + 2138 + for (i = 0; i < ARRAY_SIZE(cache->entries); i++) 2139 + __skb_queue_purge(&cache->entries[i].skb_list); 2140 + } 2141 + 2126 2142 static inline struct ieee80211_fragment_entry * 2127 - ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata, 2143 + ieee80211_reassemble_add(struct ieee80211_fragment_cache *cache, 2128 2144 unsigned int frag, unsigned int seq, int rx_queue, 2129 2145 struct sk_buff **skb) 2130 2146 { 2131 2147 struct ieee80211_fragment_entry *entry; 2132 2148 2133 - entry = &sdata->fragments[sdata->fragment_next++]; 2134 - if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX) 2135 - sdata->fragment_next = 0; 2149 + entry = &cache->entries[cache->next++]; 2150 + if (cache->next >= IEEE80211_FRAGMENT_MAX) 2151 + cache->next = 0; 2136 2152 2137 - if (!skb_queue_empty(&entry->skb_list)) 2138 - __skb_queue_purge(&entry->skb_list); 2153 + __skb_queue_purge(&entry->skb_list); 2139 2154 2140 2155 __skb_queue_tail(&entry->skb_list, *skb); /* no need for locking */ 2141 2156 *skb = NULL; ··· 2165 2150 } 2166 2151 2167 2152 static inline struct ieee80211_fragment_entry * 2168 - ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata, 2153 + ieee80211_reassemble_find(struct ieee80211_fragment_cache *cache, 2169 2154 unsigned int frag, unsigned int seq, 2170 2155 int rx_queue, struct ieee80211_hdr *hdr) 2171 2156 { 2172 2157 struct ieee80211_fragment_entry *entry; 2173 2158 int i, idx; 2174 2159 2175 - idx = sdata->fragment_next; 2160 + idx = cache->next; 2176 2161 for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) { 2177 2162 struct ieee80211_hdr *f_hdr; 2178 2163 struct sk_buff *f_skb; ··· 2181 2166 if (idx < 0) 2182 2167 idx = IEEE80211_FRAGMENT_MAX - 1; 2183 2168 2184 - entry = &sdata->fragments[idx]; 2169 + entry = &cache->entries[idx]; 2185 2170 if (skb_queue_empty(&entry->skb_list) || entry->seq != seq || 2186 2171 entry->rx_queue != rx_queue || 2187 2172 entry->last_frag + 1 != frag) ··· 2209 2194 return NULL; 2210 2195 } 2211 2196 2197 + static bool requires_sequential_pn(struct ieee80211_rx_data *rx, __le16 fc) 2198 + { 2199 + return rx->key && 2200 + (rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP || 2201 + rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP_256 || 2202 + rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP || 2203 + rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP_256) && 2204 + ieee80211_has_protected(fc); 2205 + } 2206 + 2212 2207 static ieee80211_rx_result debug_noinline 2213 2208 ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) 2214 2209 { 2210 + struct ieee80211_fragment_cache *cache = &rx->sdata->frags; 2215 2211 struct ieee80211_hdr *hdr; 2216 2212 u16 sc; 2217 2213 __le16 fc; 2218 2214 unsigned int frag, seq; 2219 2215 struct ieee80211_fragment_entry *entry; 2220 2216 struct sk_buff *skb; 2217 + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); 2221 2218 2222 2219 hdr = (struct ieee80211_hdr *)rx->skb->data; 2223 2220 fc = hdr->frame_control; ··· 2244 2217 I802_DEBUG_INC(rx->local->dot11MulticastReceivedFrameCount); 2245 2218 goto out_no_led; 2246 2219 } 2220 + 2221 + if (rx->sta) 2222 + cache = &rx->sta->frags; 2247 2223 2248 2224 if (likely(!ieee80211_has_morefrags(fc) && frag == 0)) 2249 2225 goto out; ··· 2266 2236 2267 2237 if (frag == 0) { 2268 2238 /* This is the first fragment of a new frame. */ 2269 - entry = ieee80211_reassemble_add(rx->sdata, frag, seq, 2239 + entry = ieee80211_reassemble_add(cache, frag, seq, 2270 2240 rx->seqno_idx, &(rx->skb)); 2271 - if (rx->key && 2272 - (rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP || 2273 - rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP_256 || 2274 - rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP || 2275 - rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP_256) && 2276 - ieee80211_has_protected(fc)) { 2241 + if (requires_sequential_pn(rx, fc)) { 2277 2242 int queue = rx->security_idx; 2278 2243 2279 2244 /* Store CCMP/GCMP PN so that we can verify that the 2280 2245 * next fragment has a sequential PN value. 2281 2246 */ 2282 2247 entry->check_sequential_pn = true; 2248 + entry->is_protected = true; 2249 + entry->key_color = rx->key->color; 2283 2250 memcpy(entry->last_pn, 2284 2251 rx->key->u.ccmp.rx_pn[queue], 2285 2252 IEEE80211_CCMP_PN_LEN); ··· 2288 2261 sizeof(rx->key->u.gcmp.rx_pn[queue])); 2289 2262 BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN != 2290 2263 IEEE80211_GCMP_PN_LEN); 2264 + } else if (rx->key && 2265 + (ieee80211_has_protected(fc) || 2266 + (status->flag & RX_FLAG_DECRYPTED))) { 2267 + entry->is_protected = true; 2268 + entry->key_color = rx->key->color; 2291 2269 } 2292 2270 return RX_QUEUED; 2293 2271 } ··· 2300 2268 /* This is a fragment for a frame that should already be pending in 2301 2269 * fragment cache. Add this fragment to the end of the pending entry. 2302 2270 */ 2303 - entry = ieee80211_reassemble_find(rx->sdata, frag, seq, 2271 + entry = ieee80211_reassemble_find(cache, frag, seq, 2304 2272 rx->seqno_idx, hdr); 2305 2273 if (!entry) { 2306 2274 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); ··· 2315 2283 if (entry->check_sequential_pn) { 2316 2284 int i; 2317 2285 u8 pn[IEEE80211_CCMP_PN_LEN], *rpn; 2318 - int queue; 2319 2286 2320 - if (!rx->key || 2321 - (rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP && 2322 - rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP_256 && 2323 - rx->key->conf.cipher != WLAN_CIPHER_SUITE_GCMP && 2324 - rx->key->conf.cipher != WLAN_CIPHER_SUITE_GCMP_256)) 2287 + if (!requires_sequential_pn(rx, fc)) 2325 2288 return RX_DROP_UNUSABLE; 2289 + 2290 + /* Prevent mixed key and fragment cache attacks */ 2291 + if (entry->key_color != rx->key->color) 2292 + return RX_DROP_UNUSABLE; 2293 + 2326 2294 memcpy(pn, entry->last_pn, IEEE80211_CCMP_PN_LEN); 2327 2295 for (i = IEEE80211_CCMP_PN_LEN - 1; i >= 0; i--) { 2328 2296 pn[i]++; 2329 2297 if (pn[i]) 2330 2298 break; 2331 2299 } 2332 - queue = rx->security_idx; 2333 - rpn = rx->key->u.ccmp.rx_pn[queue]; 2300 + 2301 + rpn = rx->ccm_gcm.pn; 2334 2302 if (memcmp(pn, rpn, IEEE80211_CCMP_PN_LEN)) 2335 2303 return RX_DROP_UNUSABLE; 2336 2304 memcpy(entry->last_pn, pn, IEEE80211_CCMP_PN_LEN); 2305 + } else if (entry->is_protected && 2306 + (!rx->key || 2307 + (!ieee80211_has_protected(fc) && 2308 + !(status->flag & RX_FLAG_DECRYPTED)) || 2309 + rx->key->color != entry->key_color)) { 2310 + /* Drop this as a mixed key or fragment cache attack, even 2311 + * if for TKIP Michael MIC should protect us, and WEP is a 2312 + * lost cause anyway. 2313 + */ 2314 + return RX_DROP_UNUSABLE; 2315 + } else if (entry->is_protected && rx->key && 2316 + entry->key_color != rx->key->color && 2317 + (status->flag & RX_FLAG_DECRYPTED)) { 2318 + return RX_DROP_UNUSABLE; 2337 2319 } 2338 2320 2339 2321 skb_pull(rx->skb, ieee80211_hdrlen(fc)); ··· 2540 2494 struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; 2541 2495 2542 2496 /* 2543 - * Allow EAPOL frames to us/the PAE group address regardless 2544 - * of whether the frame was encrypted or not. 2497 + * Allow EAPOL frames to us/the PAE group address regardless of 2498 + * whether the frame was encrypted or not, and always disallow 2499 + * all other destination addresses for them. 2545 2500 */ 2546 - if (ehdr->h_proto == rx->sdata->control_port_protocol && 2547 - (ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) || 2548 - ether_addr_equal(ehdr->h_dest, pae_group_addr))) 2549 - return true; 2501 + if (unlikely(ehdr->h_proto == rx->sdata->control_port_protocol)) 2502 + return ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) || 2503 + ether_addr_equal(ehdr->h_dest, pae_group_addr); 2550 2504 2551 2505 if (ieee80211_802_1x_port_control(rx) || 2552 2506 ieee80211_drop_unencrypted(rx, fc)) ··· 2571 2525 cfg80211_rx_control_port(dev, skb, noencrypt); 2572 2526 dev_kfree_skb(skb); 2573 2527 } else { 2528 + struct ethhdr *ehdr = (void *)skb_mac_header(skb); 2529 + 2574 2530 memset(skb->cb, 0, sizeof(skb->cb)); 2531 + 2532 + /* 2533 + * 802.1X over 802.11 requires that the authenticator address 2534 + * be used for EAPOL frames. However, 802.1X allows the use of 2535 + * the PAE group address instead. If the interface is part of 2536 + * a bridge and we pass the frame with the PAE group address, 2537 + * then the bridge will forward it to the network (even if the 2538 + * client was not associated yet), which isn't supposed to 2539 + * happen. 2540 + * To avoid that, rewrite the destination address to our own 2541 + * address, so that the authenticator (e.g. hostapd) will see 2542 + * the frame, but bridge won't forward it anywhere else. Note 2543 + * that due to earlier filtering, the only other address can 2544 + * be the PAE group address. 2545 + */ 2546 + if (unlikely(skb->protocol == sdata->control_port_protocol && 2547 + !ether_addr_equal(ehdr->h_dest, sdata->vif.addr))) 2548 + ether_addr_copy(ehdr->h_dest, sdata->vif.addr); 2575 2549 2576 2550 /* deliver to local stack */ 2577 2551 if (rx->list) ··· 2632 2566 if ((sdata->vif.type == NL80211_IFTYPE_AP || 2633 2567 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && 2634 2568 !(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) && 2569 + ehdr->h_proto != rx->sdata->control_port_protocol && 2635 2570 (sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->u.vlan.sta)) { 2636 2571 if (is_multicast_ether_addr(ehdr->h_dest) && 2637 2572 ieee80211_vif_get_num_mcast_if(sdata) != 0) { ··· 2742 2675 if (ieee80211_data_to_8023_exthdr(skb, &ethhdr, 2743 2676 rx->sdata->vif.addr, 2744 2677 rx->sdata->vif.type, 2745 - data_offset)) 2678 + data_offset, true)) 2746 2679 return RX_DROP_UNUSABLE; 2747 2680 2748 2681 ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr, ··· 2798 2731 2799 2732 if (is_multicast_ether_addr(hdr->addr1)) 2800 2733 return RX_DROP_UNUSABLE; 2734 + 2735 + if (rx->key) { 2736 + /* 2737 + * We should not receive A-MSDUs on pre-HT connections, 2738 + * and HT connections cannot use old ciphers. Thus drop 2739 + * them, as in those cases we couldn't even have SPP 2740 + * A-MSDUs or such. 2741 + */ 2742 + switch (rx->key->conf.cipher) { 2743 + case WLAN_CIPHER_SUITE_WEP40: 2744 + case WLAN_CIPHER_SUITE_WEP104: 2745 + case WLAN_CIPHER_SUITE_TKIP: 2746 + return RX_DROP_UNUSABLE; 2747 + default: 2748 + break; 2749 + } 2750 + } 2801 2751 2802 2752 return __ieee80211_rx_h_amsdu(rx, 0); 2803 2753 }
+5 -1
net/mac80211/sta_info.c
··· 4 4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 5 5 * Copyright 2013-2014 Intel Mobile Communications GmbH 6 6 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH 7 - * Copyright (C) 2018-2020 Intel Corporation 7 + * Copyright (C) 2018-2021 Intel Corporation 8 8 */ 9 9 10 10 #include <linux/module.h> ··· 391 391 sta->rx_stats.last_rx = jiffies; 392 392 393 393 u64_stats_init(&sta->rx_stats.syncp); 394 + 395 + ieee80211_init_frag_cache(&sta->frags); 394 396 395 397 sta->sta_state = IEEE80211_STA_NONE; 396 398 ··· 1103 1101 kfree(sinfo); 1104 1102 1105 1103 ieee80211_sta_debugfs_remove(sta); 1104 + 1105 + ieee80211_destroy_frag_cache(&sta->frags); 1106 1106 1107 1107 cleanup_single_sta(sta); 1108 1108 }
+32 -1
net/mac80211/sta_info.h
··· 3 3 * Copyright 2002-2005, Devicescape Software, Inc. 4 4 * Copyright 2013-2014 Intel Mobile Communications GmbH 5 5 * Copyright(c) 2015-2017 Intel Deutschland GmbH 6 - * Copyright(c) 2020 Intel Corporation 6 + * Copyright(c) 2020-2021 Intel Corporation 7 7 */ 8 8 9 9 #ifndef STA_INFO_H ··· 439 439 }; 440 440 441 441 /* 442 + * IEEE 802.11-2016 (10.6 "Defragmentation") recommends support for "concurrent 443 + * reception of at least one MSDU per access category per associated STA" 444 + * on APs, or "at least one MSDU per access category" on other interface types. 445 + * 446 + * This limit can be increased by changing this define, at the cost of slower 447 + * frame reassembly and increased memory use while fragments are pending. 448 + */ 449 + #define IEEE80211_FRAGMENT_MAX 4 450 + 451 + struct ieee80211_fragment_entry { 452 + struct sk_buff_head skb_list; 453 + unsigned long first_frag_time; 454 + u16 seq; 455 + u16 extra_len; 456 + u16 last_frag; 457 + u8 rx_queue; 458 + u8 check_sequential_pn:1, /* needed for CCMP/GCMP */ 459 + is_protected:1; 460 + u8 last_pn[6]; /* PN of the last fragment if CCMP was used */ 461 + unsigned int key_color; 462 + }; 463 + 464 + struct ieee80211_fragment_cache { 465 + struct ieee80211_fragment_entry entries[IEEE80211_FRAGMENT_MAX]; 466 + unsigned int next; 467 + }; 468 + 469 + /* 442 470 * The bandwidth threshold below which the per-station CoDel parameters will be 443 471 * scaled to be more lenient (to prevent starvation of slow stations). This 444 472 * value will be scaled by the number of active stations when it is being ··· 559 531 * @status_stats.last_ack_signal: last ACK signal 560 532 * @status_stats.ack_signal_filled: last ACK signal validity 561 533 * @status_stats.avg_ack_signal: average ACK signal 534 + * @frags: fragment cache 562 535 */ 563 536 struct sta_info { 564 537 /* General information, mostly static */ ··· 667 638 u8 reserved_tid; 668 639 669 640 struct cfg80211_chan_def tdls_chandef; 641 + 642 + struct ieee80211_fragment_cache frags; 670 643 671 644 /* keep last! */ 672 645 struct ieee80211_sta sta;
+9 -4
net/mac80211/wpa.c
··· 3 3 * Copyright 2002-2004, Instant802 Networks, Inc. 4 4 * Copyright 2008, Jouni Malinen <j@w1.fi> 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 + * Copyright (C) 2020-2021 Intel Corporation 6 7 */ 7 8 8 9 #include <linux/netdevice.h> ··· 168 167 169 168 update_iv: 170 169 /* update IV in key information to be able to detect replays */ 171 - rx->key->u.tkip.rx[rx->security_idx].iv32 = rx->tkip_iv32; 172 - rx->key->u.tkip.rx[rx->security_idx].iv16 = rx->tkip_iv16; 170 + rx->key->u.tkip.rx[rx->security_idx].iv32 = rx->tkip.iv32; 171 + rx->key->u.tkip.rx[rx->security_idx].iv16 = rx->tkip.iv16; 173 172 174 173 return RX_CONTINUE; 175 174 ··· 295 294 key, skb->data + hdrlen, 296 295 skb->len - hdrlen, rx->sta->sta.addr, 297 296 hdr->addr1, hwaccel, rx->security_idx, 298 - &rx->tkip_iv32, 299 - &rx->tkip_iv16); 297 + &rx->tkip.iv32, 298 + &rx->tkip.iv16); 300 299 if (res != TKIP_DECRYPT_OK) 301 300 return RX_DROP_UNUSABLE; 302 301 ··· 554 553 } 555 554 556 555 memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN); 556 + if (unlikely(ieee80211_is_frag(hdr))) 557 + memcpy(rx->ccm_gcm.pn, pn, IEEE80211_CCMP_PN_LEN); 557 558 } 558 559 559 560 /* Remove CCMP header and MIC */ ··· 784 781 } 785 782 786 783 memcpy(key->u.gcmp.rx_pn[queue], pn, IEEE80211_GCMP_PN_LEN); 784 + if (unlikely(ieee80211_is_frag(hdr))) 785 + memcpy(rx->ccm_gcm.pn, pn, IEEE80211_CCMP_PN_LEN); 787 786 } 788 787 789 788 /* Remove GCMP header and MIC */
+1 -2
net/mptcp/options.c
··· 130 130 memcpy(mp_opt->hmac, ptr, MPTCPOPT_HMAC_LEN); 131 131 pr_debug("MP_JOIN hmac"); 132 132 } else { 133 - pr_warn("MP_JOIN bad option size"); 134 133 mp_opt->mp_join = 0; 135 134 } 136 135 break; ··· 1023 1024 MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ADDADDR); 1024 1025 } else { 1025 1026 mptcp_pm_add_addr_echoed(msk, &mp_opt.addr); 1026 - mptcp_pm_del_add_timer(msk, &mp_opt.addr); 1027 + mptcp_pm_del_add_timer(msk, &mp_opt.addr, true); 1027 1028 MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ECHOADD); 1028 1029 } 1029 1030
+4 -4
net/mptcp/pm_netlink.c
··· 346 346 347 347 struct mptcp_pm_add_entry * 348 348 mptcp_pm_del_add_timer(struct mptcp_sock *msk, 349 - struct mptcp_addr_info *addr) 349 + struct mptcp_addr_info *addr, bool check_id) 350 350 { 351 351 struct mptcp_pm_add_entry *entry; 352 352 struct sock *sk = (struct sock *)msk; 353 353 354 354 spin_lock_bh(&msk->pm.lock); 355 355 entry = mptcp_lookup_anno_list_by_saddr(msk, addr); 356 - if (entry) 356 + if (entry && (!check_id || entry->addr.id == addr->id)) 357 357 entry->retrans_times = ADD_ADDR_RETRANS_MAX; 358 358 spin_unlock_bh(&msk->pm.lock); 359 359 360 - if (entry) 360 + if (entry && (!check_id || entry->addr.id == addr->id)) 361 361 sk_stop_timer_sync(sk, &entry->add_timer); 362 362 363 363 return entry; ··· 1064 1064 { 1065 1065 struct mptcp_pm_add_entry *entry; 1066 1066 1067 - entry = mptcp_pm_del_add_timer(msk, addr); 1067 + entry = mptcp_pm_del_add_timer(msk, addr, false); 1068 1068 if (entry) { 1069 1069 list_del(&entry->list); 1070 1070 kfree(entry);
+17 -3
net/mptcp/protocol.c
··· 879 879 !mpext->frozen; 880 880 } 881 881 882 + /* we can append data to the given data frag if: 883 + * - there is space available in the backing page_frag 884 + * - the data frag tail matches the current page_frag free offset 885 + * - the data frag end sequence number matches the current write seq 886 + */ 882 887 static bool mptcp_frag_can_collapse_to(const struct mptcp_sock *msk, 883 888 const struct page_frag *pfrag, 884 889 const struct mptcp_data_frag *df) 885 890 { 886 891 return df && pfrag->page == df->page && 887 892 pfrag->size - pfrag->offset > 0 && 893 + pfrag->offset == (df->offset + df->data_len) && 888 894 df->data_seq + df->data_len == msk->write_seq; 889 895 } 890 896 ··· 2424 2418 timer_setup(&msk->sk.icsk_retransmit_timer, mptcp_retransmit_timer, 0); 2425 2419 timer_setup(&sk->sk_timer, mptcp_timeout_timer, 0); 2426 2420 2427 - tcp_assign_congestion_control(sk); 2428 - 2429 2421 return 0; 2430 2422 } 2431 2423 2432 2424 static int mptcp_init_sock(struct sock *sk) 2433 2425 { 2426 + struct inet_connection_sock *icsk = inet_csk(sk); 2434 2427 struct net *net = sock_net(sk); 2435 2428 int ret; 2436 2429 ··· 2446 2441 ret = __mptcp_socket_create(mptcp_sk(sk)); 2447 2442 if (ret) 2448 2443 return ret; 2444 + 2445 + /* fetch the ca name; do it outside __mptcp_init_sock(), so that clone will 2446 + * propagate the correct value 2447 + */ 2448 + tcp_assign_congestion_control(sk); 2449 + strcpy(mptcp_sk(sk)->ca_name, icsk->icsk_ca_ops->name); 2450 + 2451 + /* no need to keep a reference to the ops, the name will suffice */ 2452 + tcp_cleanup_congestion_control(sk); 2453 + icsk->icsk_ca_ops = NULL; 2449 2454 2450 2455 sk_sockets_allocated_inc(sk); 2451 2456 sk->sk_rcvbuf = sock_net(sk)->ipv4.sysctl_tcp_rmem[1]; ··· 2631 2616 sk_stream_kill_queues(sk); 2632 2617 xfrm_sk_free_policy(sk); 2633 2618 2634 - tcp_cleanup_congestion_control(sk); 2635 2619 sk_refcnt_debug_release(sk); 2636 2620 mptcp_dispose_initial_subflow(msk); 2637 2621 sock_put(sk);
+2 -1
net/mptcp/protocol.h
··· 258 258 } rcvq_space; 259 259 260 260 u32 setsockopt_seq; 261 + char ca_name[TCP_CA_NAME_MAX]; 261 262 }; 262 263 263 264 #define mptcp_lock_sock(___sk, cb) do { \ ··· 672 671 bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk); 673 672 struct mptcp_pm_add_entry * 674 673 mptcp_pm_del_add_timer(struct mptcp_sock *msk, 675 - struct mptcp_addr_info *addr); 674 + struct mptcp_addr_info *addr, bool check_id); 676 675 struct mptcp_pm_add_entry * 677 676 mptcp_lookup_anno_list_by_saddr(struct mptcp_sock *msk, 678 677 struct mptcp_addr_info *addr);
+2 -2
net/mptcp/sockopt.c
··· 547 547 } 548 548 549 549 if (ret == 0) 550 - tcp_set_congestion_control(sk, name, false, cap_net_admin); 550 + strcpy(msk->ca_name, name); 551 551 552 552 release_sock(sk); 553 553 return ret; ··· 705 705 sock_valbool_flag(ssk, SOCK_DBG, sock_flag(sk, SOCK_DBG)); 706 706 707 707 if (inet_csk(sk)->icsk_ca_ops != inet_csk(ssk)->icsk_ca_ops) 708 - tcp_set_congestion_control(ssk, inet_csk(sk)->icsk_ca_ops->name, false, true); 708 + tcp_set_congestion_control(ssk, msk->ca_name, false, true); 709 709 } 710 710 711 711 static void __mptcp_sockopt_sync(struct mptcp_sock *msk, struct sock *ssk)
-1
net/mptcp/subflow.c
··· 867 867 868 868 data_len = mpext->data_len; 869 869 if (data_len == 0) { 870 - pr_err("Infinite mapping not handled"); 871 870 MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_INFINITEMAPRX); 872 871 return MAPPING_INVALID; 873 872 }
+1 -2
net/netfilter/nf_flow_table_core.c
··· 306 306 { 307 307 flow->timeout = nf_flowtable_time_stamp + NF_FLOW_TIMEOUT; 308 308 309 - if (likely(!nf_flowtable_hw_offload(flow_table) || 310 - !test_and_clear_bit(NF_FLOW_HW_REFRESH, &flow->flags))) 309 + if (likely(!nf_flowtable_hw_offload(flow_table))) 311 310 return; 312 311 313 312 nf_flow_offload_add(flow_table, flow);
+4 -3
net/netfilter/nf_flow_table_offload.c
··· 902 902 903 903 err = flow_offload_rule_add(offload, flow_rule); 904 904 if (err < 0) 905 - set_bit(NF_FLOW_HW_REFRESH, &offload->flow->flags); 906 - else 907 - set_bit(IPS_HW_OFFLOAD_BIT, &offload->flow->ct->status); 905 + goto out; 908 906 907 + set_bit(IPS_HW_OFFLOAD_BIT, &offload->flow->ct->status); 908 + 909 + out: 909 910 nf_flow_offload_destroy(flow_rule); 910 911 } 911 912
+2 -2
net/netfilter/nft_set_pipapo.c
··· 408 408 * 409 409 * Return: true on match, false otherwise. 410 410 */ 411 - static bool nft_pipapo_lookup(const struct net *net, const struct nft_set *set, 412 - const u32 *key, const struct nft_set_ext **ext) 411 + bool nft_pipapo_lookup(const struct net *net, const struct nft_set *set, 412 + const u32 *key, const struct nft_set_ext **ext) 413 413 { 414 414 struct nft_pipapo *priv = nft_set_priv(set); 415 415 unsigned long *res_map, *fill_map;
+2
net/netfilter/nft_set_pipapo.h
··· 178 178 179 179 int pipapo_refill(unsigned long *map, int len, int rules, unsigned long *dst, 180 180 union nft_pipapo_map_bucket *mt, bool match_only); 181 + bool nft_pipapo_lookup(const struct net *net, const struct nft_set *set, 182 + const u32 *key, const struct nft_set_ext **ext); 181 183 182 184 /** 183 185 * pipapo_and_field_buckets_4bit() - Intersect 4-bit buckets
+3
net/netfilter/nft_set_pipapo_avx2.c
··· 1131 1131 bool map_index; 1132 1132 int i, ret = 0; 1133 1133 1134 + if (unlikely(!irq_fpu_usable())) 1135 + return nft_pipapo_lookup(net, set, key, ext); 1136 + 1134 1137 m = rcu_dereference(priv->match); 1135 1138 1136 1139 /* This also protects access to all data related to scratch maps */
+4 -2
net/netlink/af_netlink.c
··· 461 461 static inline void 462 462 netlink_lock_table(void) 463 463 { 464 + unsigned long flags; 465 + 464 466 /* read_lock() synchronizes us to netlink_table_grab */ 465 467 466 - read_lock(&nl_table_lock); 468 + read_lock_irqsave(&nl_table_lock, flags); 467 469 atomic_inc(&nl_table_users); 468 - read_unlock(&nl_table_lock); 470 + read_unlock_irqrestore(&nl_table_lock, flags); 469 471 } 470 472 471 473 static inline void
+1
net/nfc/nci/core.c
··· 1191 1191 void nci_free_device(struct nci_dev *ndev) 1192 1192 { 1193 1193 nfc_free_device(ndev->nfc_dev); 1194 + nci_hci_deallocate(ndev); 1194 1195 kfree(ndev); 1195 1196 } 1196 1197 EXPORT_SYMBOL(nci_free_device);
+5
net/nfc/nci/hci.c
··· 792 792 793 793 return hdev; 794 794 } 795 + 796 + void nci_hci_deallocate(struct nci_dev *ndev) 797 + { 798 + kfree(ndev->hci_dev); 799 + }
+1 -1
net/nfc/rawsock.c
··· 329 329 return -ESOCKTNOSUPPORT; 330 330 331 331 if (sock->type == SOCK_RAW) { 332 - if (!capable(CAP_NET_RAW)) 332 + if (!ns_capable(net->user_ns, CAP_NET_RAW)) 333 333 return -EPERM; 334 334 sock->ops = &rawsock_raw_ops; 335 335 } else {
+8
net/openvswitch/meter.c
··· 611 611 spin_lock(&meter->lock); 612 612 613 613 long_delta_ms = (now_ms - meter->used); /* ms */ 614 + if (long_delta_ms < 0) { 615 + /* This condition means that we have several threads fighting 616 + * for a meter lock, and the one who received the packets a 617 + * bit later wins. Assuming that all racing threads received 618 + * packets at the same time to avoid overflow. 619 + */ 620 + long_delta_ms = 0; 621 + } 614 622 615 623 /* Make sure delta_ms will not be too large, so that bucket will not 616 624 * wrap around below.
+8 -2
net/packet/af_packet.c
··· 422 422 ktime_to_timespec64_cond(shhwtstamps->hwtstamp, ts)) 423 423 return TP_STATUS_TS_RAW_HARDWARE; 424 424 425 - if (ktime_to_timespec64_cond(skb->tstamp, ts)) 425 + if ((flags & SOF_TIMESTAMPING_SOFTWARE) && 426 + ktime_to_timespec64_cond(skb->tstamp, ts)) 426 427 return TP_STATUS_TS_SOFTWARE; 427 428 428 429 return 0; ··· 2341 2340 2342 2341 skb_copy_bits(skb, 0, h.raw + macoff, snaplen); 2343 2342 2344 - if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) 2343 + /* Always timestamp; prefer an existing software timestamp taken 2344 + * closer to the time of capture. 2345 + */ 2346 + ts_status = tpacket_get_timestamp(skb, &ts, 2347 + po->tp_tstamp | SOF_TIMESTAMPING_SOFTWARE); 2348 + if (!ts_status) 2345 2349 ktime_get_real_ts64(&ts); 2346 2350 2347 2351 status |= ts_status;
+17 -6
net/rds/connection.c
··· 240 240 if (loop_trans) { 241 241 rds_trans_put(loop_trans); 242 242 conn->c_loopback = 1; 243 - if (is_outgoing && trans->t_prefer_loopback) { 244 - /* "outgoing" connection - and the transport 245 - * says it wants the connection handled by the 246 - * loopback transport. This is what TCP does. 247 - */ 248 - trans = &rds_loop_transport; 243 + if (trans->t_prefer_loopback) { 244 + if (likely(is_outgoing)) { 245 + /* "outgoing" connection to local address. 246 + * Protocol says it wants the connection 247 + * handled by the loopback transport. 248 + * This is what TCP does. 249 + */ 250 + trans = &rds_loop_transport; 251 + } else { 252 + /* No transport currently in use 253 + * should end up here, but if it 254 + * does, reset/destroy the connection. 255 + */ 256 + kmem_cache_free(rds_conn_slab, conn); 257 + conn = ERR_PTR(-EOPNOTSUPP); 258 + goto out; 259 + } 249 260 } 250 261 } 251 262
+2 -2
net/rds/tcp.c
··· 313 313 } 314 314 #endif 315 315 316 - static int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr, 317 - __u32 scope_id) 316 + int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr, 317 + __u32 scope_id) 318 318 { 319 319 struct net_device *dev = NULL; 320 320 #if IS_ENABLED(CONFIG_IPV6)
+2 -1
net/rds/tcp.h
··· 59 59 u64 rds_tcp_map_seq(struct rds_tcp_connection *tc, u32 seq); 60 60 extern struct rds_transport rds_tcp_transport; 61 61 void rds_tcp_accept_work(struct sock *sk); 62 - 62 + int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr, 63 + __u32 scope_id); 63 64 /* tcp_connect.c */ 64 65 int rds_tcp_conn_path_connect(struct rds_conn_path *cp); 65 66 void rds_tcp_conn_path_shutdown(struct rds_conn_path *conn);
+6
net/rds/tcp_listen.c
··· 167 167 } 168 168 #endif 169 169 170 + if (!rds_tcp_laddr_check(sock_net(sock->sk), peer_addr, dev_if)) { 171 + /* local address connection is only allowed via loopback */ 172 + ret = -EOPNOTSUPP; 173 + goto out; 174 + } 175 + 170 176 conn = rds_conn_create(sock_net(sock->sk), 171 177 my_addr, peer_addr, 172 178 &rds_tcp_transport, 0, GFP_KERNEL, dev_if);
+1 -1
net/sched/cls_api.c
··· 1624 1624 1625 1625 /* If we missed on some chain */ 1626 1626 if (ret == TC_ACT_UNSPEC && last_executed_chain) { 1627 - ext = skb_ext_add(skb, TC_SKB_EXT); 1627 + ext = tc_skb_ext_alloc(skb); 1628 1628 if (WARN_ON_ONCE(!ext)) 1629 1629 return TC_ACT_SHOT; 1630 1630 ext->chain = last_executed_chain;
+2 -1
net/sched/sch_dsmark.c
··· 407 407 struct dsmark_qdisc_data *p = qdisc_priv(sch); 408 408 409 409 pr_debug("%s(sch %p,[qdisc %p])\n", __func__, sch, p); 410 - qdisc_reset(p->q); 410 + if (p->q) 411 + qdisc_reset(p->q); 411 412 sch->qstats.backlog = 0; 412 413 sch->q.qlen = 0; 413 414 }
+13 -6
net/sched/sch_fq_pie.c
··· 138 138 139 139 /* Classifies packet into corresponding flow */ 140 140 idx = fq_pie_classify(skb, sch, &ret); 141 - sel_flow = &q->flows[idx]; 141 + if (idx == 0) { 142 + if (ret & __NET_XMIT_BYPASS) 143 + qdisc_qstats_drop(sch); 144 + __qdisc_drop(skb, to_free); 145 + return ret; 146 + } 147 + idx--; 142 148 149 + sel_flow = &q->flows[idx]; 143 150 /* Checks whether adding a new packet would exceed memory limit */ 144 151 get_pie_cb(skb)->mem_usage = skb->truesize; 145 152 memory_limited = q->memory_usage > q->memory_limit + skb->truesize; ··· 304 297 goto flow_error; 305 298 } 306 299 q->flows_cnt = nla_get_u32(tb[TCA_FQ_PIE_FLOWS]); 307 - if (!q->flows_cnt || q->flows_cnt >= 65536) { 300 + if (!q->flows_cnt || q->flows_cnt > 65536) { 308 301 NL_SET_ERR_MSG_MOD(extack, 309 - "Number of flows must range in [1..65535]"); 302 + "Number of flows must range in [1..65536]"); 310 303 goto flow_error; 311 304 } 312 305 } ··· 374 367 struct fq_pie_sched_data *q = from_timer(q, t, adapt_timer); 375 368 struct Qdisc *sch = q->sch; 376 369 spinlock_t *root_lock; /* to lock qdisc for probability calculations */ 377 - u16 idx; 370 + u32 idx; 378 371 379 372 root_lock = qdisc_lock(qdisc_root_sleeping(sch)); 380 373 spin_lock(root_lock); ··· 395 388 { 396 389 struct fq_pie_sched_data *q = qdisc_priv(sch); 397 390 int err; 398 - u16 idx; 391 + u32 idx; 399 392 400 393 pie_params_init(&q->p_params); 401 394 sch->limit = 10 * 1024; ··· 507 500 static void fq_pie_reset(struct Qdisc *sch) 508 501 { 509 502 struct fq_pie_sched_data *q = qdisc_priv(sch); 510 - u16 idx; 503 + u32 idx; 511 504 512 505 INIT_LIST_HEAD(&q->new_flows); 513 506 INIT_LIST_HEAD(&q->old_flows);
+48 -2
net/sched/sch_generic.c
··· 35 35 const struct Qdisc_ops *default_qdisc_ops = &pfifo_fast_ops; 36 36 EXPORT_SYMBOL(default_qdisc_ops); 37 37 38 + static void qdisc_maybe_clear_missed(struct Qdisc *q, 39 + const struct netdev_queue *txq) 40 + { 41 + clear_bit(__QDISC_STATE_MISSED, &q->state); 42 + 43 + /* Make sure the below netif_xmit_frozen_or_stopped() 44 + * checking happens after clearing STATE_MISSED. 45 + */ 46 + smp_mb__after_atomic(); 47 + 48 + /* Checking netif_xmit_frozen_or_stopped() again to 49 + * make sure STATE_MISSED is set if the STATE_MISSED 50 + * set by netif_tx_wake_queue()'s rescheduling of 51 + * net_tx_action() is cleared by the above clear_bit(). 52 + */ 53 + if (!netif_xmit_frozen_or_stopped(txq)) 54 + set_bit(__QDISC_STATE_MISSED, &q->state); 55 + } 56 + 38 57 /* Main transmission queue. */ 39 58 40 59 /* Modifications to data participating in scheduling must be protected with ··· 93 74 } 94 75 } else { 95 76 skb = SKB_XOFF_MAGIC; 77 + qdisc_maybe_clear_missed(q, txq); 96 78 } 97 79 } 98 80 ··· 262 242 } 263 243 } else { 264 244 skb = NULL; 245 + qdisc_maybe_clear_missed(q, txq); 265 246 } 266 247 if (lock) 267 248 spin_unlock(lock); ··· 272 251 *validate = true; 273 252 274 253 if ((q->flags & TCQ_F_ONETXQUEUE) && 275 - netif_xmit_frozen_or_stopped(txq)) 254 + netif_xmit_frozen_or_stopped(txq)) { 255 + qdisc_maybe_clear_missed(q, txq); 276 256 return skb; 257 + } 277 258 278 259 skb = qdisc_dequeue_skb_bad_txq(q); 279 260 if (unlikely(skb)) { ··· 334 311 HARD_TX_LOCK(dev, txq, smp_processor_id()); 335 312 if (!netif_xmit_frozen_or_stopped(txq)) 336 313 skb = dev_hard_start_xmit(skb, dev, txq, &ret); 314 + else 315 + qdisc_maybe_clear_missed(q, txq); 337 316 338 317 HARD_TX_UNLOCK(dev, txq); 339 318 } else { ··· 665 640 { 666 641 struct pfifo_fast_priv *priv = qdisc_priv(qdisc); 667 642 struct sk_buff *skb = NULL; 643 + bool need_retry = true; 668 644 int band; 669 645 646 + retry: 670 647 for (band = 0; band < PFIFO_FAST_BANDS && !skb; band++) { 671 648 struct skb_array *q = band2list(priv, band); 672 649 ··· 679 652 } 680 653 if (likely(skb)) { 681 654 qdisc_update_stats_at_dequeue(qdisc, skb); 655 + } else if (need_retry && 656 + test_bit(__QDISC_STATE_MISSED, &qdisc->state)) { 657 + /* Delay clearing the STATE_MISSED here to reduce 658 + * the overhead of the second spin_trylock() in 659 + * qdisc_run_begin() and __netif_schedule() calling 660 + * in qdisc_run_end(). 661 + */ 662 + clear_bit(__QDISC_STATE_MISSED, &qdisc->state); 663 + 664 + /* Make sure dequeuing happens after clearing 665 + * STATE_MISSED. 666 + */ 667 + smp_mb__after_atomic(); 668 + 669 + need_retry = false; 670 + 671 + goto retry; 682 672 } else { 683 673 WRITE_ONCE(qdisc->empty, true); 684 674 } ··· 1202 1158 qdisc_reset(qdisc); 1203 1159 1204 1160 spin_unlock_bh(qdisc_lock(qdisc)); 1205 - if (nolock) 1161 + if (nolock) { 1162 + clear_bit(__QDISC_STATE_MISSED, &qdisc->state); 1206 1163 spin_unlock_bh(&qdisc->seqlock); 1164 + } 1207 1165 } 1208 1166 1209 1167 static bool some_qdisc_is_busy(struct net_device *dev)
+1
net/sctp/socket.c
··· 4473 4473 transports) 4474 4474 t->encap_port = encap_port; 4475 4475 4476 + asoc->encap_port = encap_port; 4476 4477 return 0; 4477 4478 } 4478 4479
+1 -1
net/sctp/sysctl.c
··· 307 307 .data = &init_net.sctp.encap_port, 308 308 .maxlen = sizeof(int), 309 309 .mode = 0644, 310 - .proc_handler = proc_dointvec, 310 + .proc_handler = proc_dointvec_minmax, 311 311 .extra1 = SYSCTL_ZERO, 312 312 .extra2 = &udp_port_max, 313 313 },
+10 -1
net/smc/smc_ism.c
··· 429 429 430 430 int smcd_register_dev(struct smcd_dev *smcd) 431 431 { 432 + int rc; 433 + 432 434 mutex_lock(&smcd_dev_list.mutex); 433 435 if (list_empty(&smcd_dev_list.list)) { 434 436 u8 *system_eid = NULL; ··· 450 448 dev_name(&smcd->dev), smcd->pnetid, 451 449 smcd->pnetid_by_user ? " (user defined)" : ""); 452 450 453 - return device_add(&smcd->dev); 451 + rc = device_add(&smcd->dev); 452 + if (rc) { 453 + mutex_lock(&smcd_dev_list.mutex); 454 + list_del(&smcd->list); 455 + mutex_unlock(&smcd_dev_list.mutex); 456 + } 457 + 458 + return rc; 454 459 } 455 460 EXPORT_SYMBOL_GPL(smcd_register_dev); 456 461
-7
net/sunrpc/clnt.c
··· 1677 1677 return; 1678 1678 } 1679 1679 1680 - /* 1681 - * Even though there was an error, we may have acquired 1682 - * a request slot somehow. Make sure not to leak it. 1683 - */ 1684 - if (task->tk_rqstp) 1685 - xprt_release(task); 1686 - 1687 1680 switch (status) { 1688 1681 case -ENOMEM: 1689 1682 rpc_delay(task, HZ >> 2);
+34 -10
net/sunrpc/xprt.c
··· 70 70 static void xprt_init(struct rpc_xprt *xprt, struct net *net); 71 71 static __be32 xprt_alloc_xid(struct rpc_xprt *xprt); 72 72 static void xprt_destroy(struct rpc_xprt *xprt); 73 + static void xprt_request_init(struct rpc_task *task); 73 74 74 75 static DEFINE_SPINLOCK(xprt_list_lock); 75 76 static LIST_HEAD(xprt_list); ··· 1607 1606 spin_unlock(&xprt->queue_lock); 1608 1607 } 1609 1608 1610 - static void xprt_add_backlog(struct rpc_xprt *xprt, struct rpc_task *task) 1609 + static void xprt_complete_request_init(struct rpc_task *task) 1611 1610 { 1612 - set_bit(XPRT_CONGESTED, &xprt->state); 1613 - rpc_sleep_on(&xprt->backlog, task, NULL); 1611 + if (task->tk_rqstp) 1612 + xprt_request_init(task); 1614 1613 } 1615 1614 1616 - static void xprt_wake_up_backlog(struct rpc_xprt *xprt) 1615 + void xprt_add_backlog(struct rpc_xprt *xprt, struct rpc_task *task) 1617 1616 { 1618 - if (rpc_wake_up_next(&xprt->backlog) == NULL) 1619 - clear_bit(XPRT_CONGESTED, &xprt->state); 1617 + set_bit(XPRT_CONGESTED, &xprt->state); 1618 + rpc_sleep_on(&xprt->backlog, task, xprt_complete_request_init); 1620 1619 } 1620 + EXPORT_SYMBOL_GPL(xprt_add_backlog); 1621 + 1622 + static bool __xprt_set_rq(struct rpc_task *task, void *data) 1623 + { 1624 + struct rpc_rqst *req = data; 1625 + 1626 + if (task->tk_rqstp == NULL) { 1627 + memset(req, 0, sizeof(*req)); /* mark unused */ 1628 + task->tk_rqstp = req; 1629 + return true; 1630 + } 1631 + return false; 1632 + } 1633 + 1634 + bool xprt_wake_up_backlog(struct rpc_xprt *xprt, struct rpc_rqst *req) 1635 + { 1636 + if (rpc_wake_up_first(&xprt->backlog, __xprt_set_rq, req) == NULL) { 1637 + clear_bit(XPRT_CONGESTED, &xprt->state); 1638 + return false; 1639 + } 1640 + return true; 1641 + } 1642 + EXPORT_SYMBOL_GPL(xprt_wake_up_backlog); 1621 1643 1622 1644 static bool xprt_throttle_congested(struct rpc_xprt *xprt, struct rpc_task *task) 1623 1645 { ··· 1650 1626 goto out; 1651 1627 spin_lock(&xprt->reserve_lock); 1652 1628 if (test_bit(XPRT_CONGESTED, &xprt->state)) { 1653 - rpc_sleep_on(&xprt->backlog, task, NULL); 1629 + xprt_add_backlog(xprt, task); 1654 1630 ret = true; 1655 1631 } 1656 1632 spin_unlock(&xprt->reserve_lock); ··· 1727 1703 void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req) 1728 1704 { 1729 1705 spin_lock(&xprt->reserve_lock); 1730 - if (!xprt_dynamic_free_slot(xprt, req)) { 1706 + if (!xprt_wake_up_backlog(xprt, req) && 1707 + !xprt_dynamic_free_slot(xprt, req)) { 1731 1708 memset(req, 0, sizeof(*req)); /* mark unused */ 1732 1709 list_add(&req->rq_list, &xprt->free); 1733 1710 } 1734 - xprt_wake_up_backlog(xprt); 1735 1711 spin_unlock(&xprt->reserve_lock); 1736 1712 } 1737 1713 EXPORT_SYMBOL_GPL(xprt_free_slot); ··· 1918 1894 xdr_free_bvec(&req->rq_snd_buf); 1919 1895 if (req->rq_cred != NULL) 1920 1896 put_rpccred(req->rq_cred); 1921 - task->tk_rqstp = NULL; 1922 1897 if (req->rq_release_snd_buf) 1923 1898 req->rq_release_snd_buf(req); 1924 1899 1900 + task->tk_rqstp = NULL; 1925 1901 if (likely(!bc_prealloc(req))) 1926 1902 xprt->ops->free_slot(xprt, req); 1927 1903 else
+18 -9
net/sunrpc/xprtrdma/rpc_rdma.c
··· 628 628 return false; 629 629 } 630 630 631 - /* The tail iovec might not reside in the same page as the 632 - * head iovec. 631 + /* The tail iovec may include an XDR pad for the page list, 632 + * as well as additional content, and may not reside in the 633 + * same page as the head iovec. 633 634 */ 634 635 static bool rpcrdma_prepare_tail_iov(struct rpcrdma_req *req, 635 636 struct xdr_buf *xdr, ··· 748 747 struct rpcrdma_req *req, 749 748 struct xdr_buf *xdr) 750 749 { 751 - struct kvec *tail = &xdr->tail[0]; 752 - 753 750 if (!rpcrdma_prepare_head_iov(r_xprt, req, xdr->head[0].iov_len)) 754 751 return false; 755 752 756 - /* If there is a Read chunk, the page list is handled 753 + /* If there is a Read chunk, the page list is being handled 757 754 * via explicit RDMA, and thus is skipped here. 758 755 */ 759 756 760 - if (tail->iov_len) { 761 - if (!rpcrdma_prepare_tail_iov(req, xdr, 762 - offset_in_page(tail->iov_base), 763 - tail->iov_len)) 757 + /* Do not include the tail if it is only an XDR pad */ 758 + if (xdr->tail[0].iov_len > 3) { 759 + unsigned int page_base, len; 760 + 761 + /* If the content in the page list is an odd length, 762 + * xdr_write_pages() adds a pad at the beginning of 763 + * the tail iovec. Force the tail's non-pad content to 764 + * land at the next XDR position in the Send message. 765 + */ 766 + page_base = offset_in_page(xdr->tail[0].iov_base); 767 + len = xdr->tail[0].iov_len; 768 + page_base += len & 3; 769 + len -= len & 3; 770 + if (!rpcrdma_prepare_tail_iov(req, xdr, page_base, len)) 764 771 return false; 765 772 kref_get(&req->rl_kref); 766 773 }
+6 -6
net/sunrpc/xprtrdma/transport.c
··· 520 520 return; 521 521 522 522 out_sleep: 523 - set_bit(XPRT_CONGESTED, &xprt->state); 524 - rpc_sleep_on(&xprt->backlog, task, NULL); 525 523 task->tk_status = -EAGAIN; 524 + xprt_add_backlog(xprt, task); 526 525 } 527 526 528 527 /** ··· 536 537 struct rpcrdma_xprt *r_xprt = 537 538 container_of(xprt, struct rpcrdma_xprt, rx_xprt); 538 539 539 - memset(rqst, 0, sizeof(*rqst)); 540 - rpcrdma_buffer_put(&r_xprt->rx_buf, rpcr_to_rdmar(rqst)); 541 - if (unlikely(!rpc_wake_up_next(&xprt->backlog))) 542 - clear_bit(XPRT_CONGESTED, &xprt->state); 540 + rpcrdma_reply_put(&r_xprt->rx_buf, rpcr_to_rdmar(rqst)); 541 + if (!xprt_wake_up_backlog(xprt, rqst)) { 542 + memset(rqst, 0, sizeof(*rqst)); 543 + rpcrdma_buffer_put(&r_xprt->rx_buf, rpcr_to_rdmar(rqst)); 544 + } 543 545 } 544 546 545 547 static bool rpcrdma_check_regbuf(struct rpcrdma_xprt *r_xprt,
+15 -3
net/sunrpc/xprtrdma/verbs.c
··· 1201 1201 } 1202 1202 1203 1203 /** 1204 + * rpcrdma_reply_put - Put reply buffers back into pool 1205 + * @buffers: buffer pool 1206 + * @req: object to return 1207 + * 1208 + */ 1209 + void rpcrdma_reply_put(struct rpcrdma_buffer *buffers, struct rpcrdma_req *req) 1210 + { 1211 + if (req->rl_reply) { 1212 + rpcrdma_rep_put(buffers, req->rl_reply); 1213 + req->rl_reply = NULL; 1214 + } 1215 + } 1216 + 1217 + /** 1204 1218 * rpcrdma_buffer_get - Get a request buffer 1205 1219 * @buffers: Buffer pool from which to obtain a buffer 1206 1220 * ··· 1242 1228 */ 1243 1229 void rpcrdma_buffer_put(struct rpcrdma_buffer *buffers, struct rpcrdma_req *req) 1244 1230 { 1245 - if (req->rl_reply) 1246 - rpcrdma_rep_put(buffers, req->rl_reply); 1247 - req->rl_reply = NULL; 1231 + rpcrdma_reply_put(buffers, req); 1248 1232 1249 1233 spin_lock(&buffers->rb_lock); 1250 1234 list_add(&req->rl_list, &buffers->rb_send_bufs);
+1
net/sunrpc/xprtrdma/xprt_rdma.h
··· 479 479 void rpcrdma_buffer_put(struct rpcrdma_buffer *buffers, 480 480 struct rpcrdma_req *req); 481 481 void rpcrdma_rep_put(struct rpcrdma_buffer *buf, struct rpcrdma_rep *rep); 482 + void rpcrdma_reply_put(struct rpcrdma_buffer *buffers, struct rpcrdma_req *req); 482 483 483 484 bool rpcrdma_regbuf_realloc(struct rpcrdma_regbuf *rb, size_t size, 484 485 gfp_t flags);
+2
net/sunrpc/xprtsock.c
··· 1010 1010 kernel_sock_shutdown(transport->sock, SHUT_RDWR); 1011 1011 return -ENOTCONN; 1012 1012 } 1013 + if (!transport->inet) 1014 + return -ENOTCONN; 1013 1015 1014 1016 xs_pktdump("packet data:", 1015 1017 req->rq_svec->iov_base,
+4 -2
net/tipc/core.c
··· 60 60 tn->trial_addr = 0; 61 61 tn->addr_trial_end = 0; 62 62 tn->capabilities = TIPC_NODE_CAPABILITIES; 63 - INIT_WORK(&tn->final_work.work, tipc_net_finalize_work); 63 + INIT_WORK(&tn->work, tipc_net_finalize_work); 64 64 memset(tn->node_id, 0, sizeof(tn->node_id)); 65 65 memset(tn->node_id_string, 0, sizeof(tn->node_id_string)); 66 66 tn->mon_threshold = TIPC_DEF_MON_THRESHOLD; ··· 110 110 111 111 tipc_detach_loopback(net); 112 112 /* Make sure the tipc_net_finalize_work() finished */ 113 - cancel_work_sync(&tn->final_work.work); 113 + cancel_work_sync(&tn->work); 114 114 tipc_net_stop(net); 115 115 116 116 tipc_bcast_stop(net); ··· 119 119 #ifdef CONFIG_TIPC_CRYPTO 120 120 tipc_crypto_stop(&tipc_net(net)->crypto_tx); 121 121 #endif 122 + while (atomic_read(&tn->wq_count)) 123 + cond_resched(); 122 124 } 123 125 124 126 static void __net_exit tipc_pernet_pre_exit(struct net *net)
+3 -7
net/tipc/core.h
··· 91 91 extern int sysctl_tipc_rmem[3] __read_mostly; 92 92 extern int sysctl_tipc_named_timeout __read_mostly; 93 93 94 - struct tipc_net_work { 95 - struct work_struct work; 96 - struct net *net; 97 - u32 addr; 98 - }; 99 - 100 94 struct tipc_net { 101 95 u8 node_id[NODE_ID_LEN]; 102 96 u32 node_addr; ··· 142 148 struct tipc_crypto *crypto_tx; 143 149 #endif 144 150 /* Work item for net finalize */ 145 - struct tipc_net_work final_work; 151 + struct work_struct work; 152 + /* The numbers of work queues in schedule */ 153 + atomic_t wq_count; 146 154 }; 147 155 148 156 static inline struct tipc_net *tipc_net(struct net *net)
+2 -2
net/tipc/discover.c
··· 168 168 169 169 /* Apply trial address if we just left trial period */ 170 170 if (!trial && !self) { 171 - tipc_sched_net_finalize(net, tn->trial_addr); 171 + schedule_work(&tn->work); 172 172 msg_set_prevnode(buf_msg(d->skb), tn->trial_addr); 173 173 msg_set_type(buf_msg(d->skb), DSC_REQ_MSG); 174 174 } ··· 308 308 if (!time_before(jiffies, tn->addr_trial_end) && !tipc_own_addr(net)) { 309 309 mod_timer(&d->timer, jiffies + TIPC_DISC_INIT); 310 310 spin_unlock_bh(&d->lock); 311 - tipc_sched_net_finalize(net, tn->trial_addr); 311 + schedule_work(&tn->work); 312 312 return; 313 313 } 314 314
+5
net/tipc/link.c
··· 372 372 return l->net_plane; 373 373 } 374 374 375 + struct net *tipc_link_net(struct tipc_link *l) 376 + { 377 + return l->net; 378 + } 379 + 375 380 void tipc_link_update_caps(struct tipc_link *l, u16 capabilities) 376 381 { 377 382 l->peer_caps = capabilities;
+1
net/tipc/link.h
··· 156 156 int tipc_link_bc_nack_rcv(struct tipc_link *l, struct sk_buff *skb, 157 157 struct sk_buff_head *xmitq); 158 158 bool tipc_link_too_silent(struct tipc_link *l); 159 + struct net *tipc_link_net(struct tipc_link *l); 159 160 #endif
+2 -7
net/tipc/msg.c
··· 149 149 if (unlikely(head)) 150 150 goto err; 151 151 *buf = NULL; 152 + if (skb_has_frag_list(frag) && __skb_linearize(frag)) 153 + goto err; 152 154 frag = skb_unshare(frag, GFP_ATOMIC); 153 155 if (unlikely(!frag)) 154 156 goto err; 155 157 head = *headbuf = frag; 156 158 TIPC_SKB_CB(head)->tail = NULL; 157 - if (skb_is_nonlinear(head)) { 158 - skb_walk_frags(head, tail) { 159 - TIPC_SKB_CB(head)->tail = tail; 160 - } 161 - } else { 162 - skb_frag_list_init(head); 163 - } 164 159 return 0; 165 160 } 166 161
+3 -12
net/tipc/net.c
··· 41 41 #include "socket.h" 42 42 #include "node.h" 43 43 #include "bcast.h" 44 + #include "link.h" 44 45 #include "netlink.h" 45 46 #include "monitor.h" 46 47 ··· 143 142 144 143 void tipc_net_finalize_work(struct work_struct *work) 145 144 { 146 - struct tipc_net_work *fwork; 145 + struct tipc_net *tn = container_of(work, struct tipc_net, work); 147 146 148 - fwork = container_of(work, struct tipc_net_work, work); 149 - tipc_net_finalize(fwork->net, fwork->addr); 150 - } 151 - 152 - void tipc_sched_net_finalize(struct net *net, u32 addr) 153 - { 154 - struct tipc_net *tn = tipc_net(net); 155 - 156 - tn->final_work.net = net; 157 - tn->final_work.addr = addr; 158 - schedule_work(&tn->final_work.work); 147 + tipc_net_finalize(tipc_link_net(tn->bcl), tn->trial_addr); 159 148 } 160 149 161 150 void tipc_net_stop(struct net *net)
+6 -6
net/tipc/node.c
··· 423 423 write_unlock_bh(&n->lock); 424 424 425 425 if (flags & TIPC_NOTIFY_NODE_DOWN) 426 - tipc_publ_notify(net, publ_list, n->addr, n->capabilities); 426 + tipc_publ_notify(net, publ_list, sk.node, n->capabilities); 427 427 428 428 if (flags & TIPC_NOTIFY_NODE_UP) 429 - tipc_named_node_up(net, n->addr, n->capabilities); 429 + tipc_named_node_up(net, sk.node, n->capabilities); 430 430 431 431 if (flags & TIPC_NOTIFY_LINK_UP) { 432 - tipc_mon_peer_up(net, n->addr, bearer_id); 433 - tipc_nametbl_publish(net, &ua, &sk, n->link_id); 432 + tipc_mon_peer_up(net, sk.node, bearer_id); 433 + tipc_nametbl_publish(net, &ua, &sk, sk.ref); 434 434 } 435 435 if (flags & TIPC_NOTIFY_LINK_DOWN) { 436 - tipc_mon_peer_down(net, n->addr, bearer_id); 437 - tipc_nametbl_withdraw(net, &ua, &sk, n->link_id); 436 + tipc_mon_peer_down(net, sk.node, bearer_id); 437 + tipc_nametbl_withdraw(net, &ua, &sk, sk.ref); 438 438 } 439 439 } 440 440
+4 -1
net/tipc/socket.c
··· 1262 1262 spin_lock_bh(&inputq->lock); 1263 1263 if (skb_peek(arrvq) == skb) { 1264 1264 skb_queue_splice_tail_init(&tmpq, inputq); 1265 - __skb_dequeue(arrvq); 1265 + /* Decrease the skb's refcnt as increasing in the 1266 + * function tipc_skb_peek 1267 + */ 1268 + kfree_skb(__skb_dequeue(arrvq)); 1266 1269 } 1267 1270 spin_unlock_bh(&inputq->lock); 1268 1271 __skb_queue_purge(&tmpq);
+2
net/tipc/udp_media.c
··· 814 814 kfree_rcu(rcast, rcu); 815 815 } 816 816 817 + atomic_dec(&tipc_net(sock_net(ub->ubsock->sk))->wq_count); 817 818 dst_cache_destroy(&ub->rcast.dst_cache); 818 819 udp_tunnel_sock_release(ub->ubsock); 819 820 synchronize_net(); ··· 835 834 RCU_INIT_POINTER(ub->bearer, NULL); 836 835 837 836 /* sock_release need to be done outside of rtnl lock */ 837 + atomic_inc(&tipc_net(sock_net(ub->ubsock->sk))->wq_count); 838 838 INIT_WORK(&ub->work, cleanup_bearer); 839 839 schedule_work(&ub->work); 840 840 }
+6 -5
net/tls/tls_sw.c
··· 37 37 38 38 #include <linux/sched/signal.h> 39 39 #include <linux/module.h> 40 + #include <linux/splice.h> 40 41 #include <crypto/aead.h> 41 42 42 43 #include <net/strparser.h> ··· 1282 1281 } 1283 1282 1284 1283 static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock, 1285 - int flags, long timeo, int *err) 1284 + bool nonblock, long timeo, int *err) 1286 1285 { 1287 1286 struct tls_context *tls_ctx = tls_get_ctx(sk); 1288 1287 struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx); ··· 1307 1306 if (sock_flag(sk, SOCK_DONE)) 1308 1307 return NULL; 1309 1308 1310 - if ((flags & MSG_DONTWAIT) || !timeo) { 1309 + if (nonblock || !timeo) { 1311 1310 *err = -EAGAIN; 1312 1311 return NULL; 1313 1312 } ··· 1787 1786 bool async_capable; 1788 1787 bool async = false; 1789 1788 1790 - skb = tls_wait_data(sk, psock, flags, timeo, &err); 1789 + skb = tls_wait_data(sk, psock, flags & MSG_DONTWAIT, timeo, &err); 1791 1790 if (!skb) { 1792 1791 if (psock) { 1793 1792 int ret = sk_msg_recvmsg(sk, psock, msg, len, ··· 1991 1990 1992 1991 lock_sock(sk); 1993 1992 1994 - timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); 1993 + timeo = sock_rcvtimeo(sk, flags & SPLICE_F_NONBLOCK); 1995 1994 1996 - skb = tls_wait_data(sk, NULL, flags, timeo, &err); 1995 + skb = tls_wait_data(sk, NULL, flags & SPLICE_F_NONBLOCK, timeo, &err); 1997 1996 if (!skb) 1998 1997 goto splice_read_end; 1999 1998
+5 -2
net/wireless/util.c
··· 542 542 543 543 int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, 544 544 const u8 *addr, enum nl80211_iftype iftype, 545 - u8 data_offset) 545 + u8 data_offset, bool is_amsdu) 546 546 { 547 547 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 548 548 struct { ··· 629 629 skb_copy_bits(skb, hdrlen, &payload, sizeof(payload)); 630 630 tmp.h_proto = payload.proto; 631 631 632 - if (likely((ether_addr_equal(payload.hdr, rfc1042_header) && 632 + if (likely((!is_amsdu && ether_addr_equal(payload.hdr, rfc1042_header) && 633 633 tmp.h_proto != htons(ETH_P_AARP) && 634 634 tmp.h_proto != htons(ETH_P_IPX)) || 635 635 ether_addr_equal(payload.hdr, bridge_tunnel_header))) ··· 770 770 /* the last MSDU has no padding */ 771 771 remaining = skb->len - offset; 772 772 if (subframe_len > remaining) 773 + goto purge; 774 + /* mitigate A-MSDU aggregation injection attacks */ 775 + if (ether_addr_equal(eth.h_dest, rfc1042_header)) 773 776 goto purge; 774 777 775 778 offset += sizeof(struct ethhdr);
+1 -1
samples/bpf/xdpsock_user.c
··· 1255 1255 for (i = 0; i < batch_size; i++) { 1256 1256 struct xdp_desc *tx_desc = xsk_ring_prod__tx_desc(&xsk->tx, 1257 1257 idx + i); 1258 - tx_desc->addr = (*frame_nb + i) << XSK_UMEM__DEFAULT_FRAME_SHIFT; 1258 + tx_desc->addr = (*frame_nb + i) * opt_xsk_frame_size; 1259 1259 tx_desc->len = PKT_SIZE; 1260 1260 } 1261 1261
+45 -1
sound/pci/hda/patch_realtek.c
··· 2603 2603 {} 2604 2604 }; 2605 2605 2606 + static const struct snd_hda_pin_quirk alc882_pin_fixup_tbl[] = { 2607 + SND_HDA_PIN_QUIRK(0x10ec1220, 0x1043, "ASUS", ALC1220_FIXUP_CLEVO_P950, 2608 + {0x14, 0x01014010}, 2609 + {0x15, 0x01011012}, 2610 + {0x16, 0x01016011}, 2611 + {0x18, 0x01a19040}, 2612 + {0x19, 0x02a19050}, 2613 + {0x1a, 0x0181304f}, 2614 + {0x1b, 0x0221401f}, 2615 + {0x1e, 0x01456130}), 2616 + SND_HDA_PIN_QUIRK(0x10ec1220, 0x1462, "MS-7C35", ALC1220_FIXUP_CLEVO_P950, 2617 + {0x14, 0x01015010}, 2618 + {0x15, 0x01011012}, 2619 + {0x16, 0x01011011}, 2620 + {0x18, 0x01a11040}, 2621 + {0x19, 0x02a19050}, 2622 + {0x1a, 0x0181104f}, 2623 + {0x1b, 0x0221401f}, 2624 + {0x1e, 0x01451130}), 2625 + {} 2626 + }; 2627 + 2606 2628 /* 2607 2629 * BIOS auto configuration 2608 2630 */ ··· 2666 2644 2667 2645 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, 2668 2646 alc882_fixups); 2647 + snd_hda_pick_pin_fixup(codec, alc882_pin_fixup_tbl, alc882_fixups, true); 2669 2648 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 2670 2649 2671 2650 alc_auto_parse_customize_define(codec); ··· 6566 6543 ALC295_FIXUP_ASUS_DACS, 6567 6544 ALC295_FIXUP_HP_OMEN, 6568 6545 ALC285_FIXUP_HP_SPECTRE_X360, 6546 + ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, 6547 + ALC623_FIXUP_LENOVO_THINKSTATION_P340, 6569 6548 }; 6570 6549 6571 6550 static const struct hda_fixup alc269_fixups[] = { ··· 8134 8109 .chained = true, 8135 8110 .chain_id = ALC285_FIXUP_SPEAKER2_TO_DAC1, 8136 8111 }, 8112 + [ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = { 8113 + .type = HDA_FIXUP_FUNC, 8114 + .v.func = alc285_fixup_ideapad_s740_coef, 8115 + .chained = true, 8116 + .chain_id = ALC285_FIXUP_THINKPAD_HEADSET_JACK, 8117 + }, 8118 + [ALC623_FIXUP_LENOVO_THINKSTATION_P340] = { 8119 + .type = HDA_FIXUP_FUNC, 8120 + .v.func = alc_fixup_no_shutup, 8121 + .chained = true, 8122 + .chain_id = ALC283_FIXUP_HEADSET_MIC, 8123 + }, 8137 8124 }; 8138 8125 8139 8126 static const struct snd_pci_quirk alc269_fixup_tbl[] = { ··· 8328 8291 SND_PCI_QUIRK(0x103c, 0x87f7, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP), 8329 8292 SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), 8330 8293 SND_PCI_QUIRK(0x103c, 0x884c, "HP EliteBook 840 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), 8294 + SND_PCI_QUIRK(0x103c, 0x886d, "HP ZBook Fury 17.3 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), 8295 + SND_PCI_QUIRK(0x103c, 0x8870, "HP ZBook Fury 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), 8296 + SND_PCI_QUIRK(0x103c, 0x8873, "HP ZBook Studio 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), 8297 + SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED), 8331 8298 SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST), 8332 8299 SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), 8333 8300 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), ··· 8468 8427 SND_PCI_QUIRK(0x1558, 0xc019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 8469 8428 SND_PCI_QUIRK(0x1558, 0xc022, "Clevo NH77[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 8470 8429 SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS), 8471 - SND_PCI_QUIRK(0x17aa, 0x1048, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC), 8430 + SND_PCI_QUIRK(0x17aa, 0x1048, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340), 8472 8431 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), 8473 8432 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), 8474 8433 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), ··· 8518 8477 SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC), 8519 8478 SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME), 8520 8479 SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF), 8480 + SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP), 8521 8481 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 8522 8482 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), 8523 8483 SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI), ··· 8734 8692 {.id = ALC245_FIXUP_HP_X360_AMP, .name = "alc245-hp-x360-amp"}, 8735 8693 {.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"}, 8736 8694 {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"}, 8695 + {.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"}, 8696 + {.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"}, 8737 8697 {} 8738 8698 }; 8739 8699 #define ALC225_STANDARD_PINS \
-10
sound/soc/amd/raven/acp3x-pcm-dma.c
··· 235 235 return ret; 236 236 } 237 237 238 - if (!adata->play_stream && !adata->capture_stream && 239 - !adata->i2ssp_play_stream && !adata->i2ssp_capture_stream) 240 - rv_writel(1, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); 241 - 242 238 i2s_data->acp3x_base = adata->acp3x_base; 243 239 runtime->private_data = i2s_data; 244 240 return ret; ··· 361 365 } 362 366 } 363 367 364 - /* Disable ACP irq, when the current stream is being closed and 365 - * another stream is also not active. 366 - */ 367 - if (!adata->play_stream && !adata->capture_stream && 368 - !adata->i2ssp_play_stream && !adata->i2ssp_capture_stream) 369 - rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); 370 368 return 0; 371 369 } 372 370
+1
sound/soc/amd/raven/acp3x.h
··· 77 77 #define ACP_POWER_OFF_IN_PROGRESS 0x03 78 78 79 79 #define ACP3x_ITER_IRER_SAMP_LEN_MASK 0x38 80 + #define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF 80 81 81 82 struct acp3x_platform_info { 82 83 u16 play_i2s_instance;
+15
sound/soc/amd/raven/pci-acp3x.c
··· 76 76 return -ETIMEDOUT; 77 77 } 78 78 79 + static void acp3x_enable_interrupts(void __iomem *acp_base) 80 + { 81 + rv_writel(0x01, acp_base + mmACP_EXTERNAL_INTR_ENB); 82 + } 83 + 84 + static void acp3x_disable_interrupts(void __iomem *acp_base) 85 + { 86 + rv_writel(ACP_EXT_INTR_STAT_CLEAR_MASK, acp_base + 87 + mmACP_EXTERNAL_INTR_STAT); 88 + rv_writel(0x00, acp_base + mmACP_EXTERNAL_INTR_CNTL); 89 + rv_writel(0x00, acp_base + mmACP_EXTERNAL_INTR_ENB); 90 + } 91 + 79 92 static int acp3x_init(struct acp3x_dev_data *adata) 80 93 { 81 94 void __iomem *acp3x_base = adata->acp3x_base; ··· 106 93 pr_err("ACP3x reset failed\n"); 107 94 return ret; 108 95 } 96 + acp3x_enable_interrupts(acp3x_base); 109 97 return 0; 110 98 } 111 99 ··· 114 100 { 115 101 int ret; 116 102 103 + acp3x_disable_interrupts(acp3x_base); 117 104 /* Reset */ 118 105 ret = acp3x_reset(acp3x_base); 119 106 if (ret) {
+1 -1
sound/soc/codecs/ak5558.c
··· 307 307 }; 308 308 309 309 static struct snd_soc_dai_driver ak5552_dai = { 310 - .name = "ak5558-aif", 310 + .name = "ak5552-aif", 311 311 .capture = { 312 312 .stream_name = "Capture", 313 313 .channels_min = 1,
+3
sound/soc/codecs/cs35l32.c
··· 261 261 .readable_reg = cs35l32_readable_register, 262 262 .precious_reg = cs35l32_precious_register, 263 263 .cache_type = REGCACHE_RBTREE, 264 + 265 + .use_single_read = true, 266 + .use_single_write = true, 264 267 }; 265 268 266 269 static int cs35l32_handle_of_data(struct i2c_client *i2c_client,
+1
sound/soc/codecs/cs35l33.c
··· 1201 1201 dev_err(&i2c_client->dev, 1202 1202 "CS35L33 Device ID (%X). Expected ID %X\n", 1203 1203 devid, CS35L33_CHIP_ID); 1204 + ret = -EINVAL; 1204 1205 goto err_enable; 1205 1206 } 1206 1207
+3
sound/soc/codecs/cs35l34.c
··· 800 800 .readable_reg = cs35l34_readable_register, 801 801 .precious_reg = cs35l34_precious_register, 802 802 .cache_type = REGCACHE_RBTREE, 803 + 804 + .use_single_read = true, 805 + .use_single_write = true, 803 806 }; 804 807 805 808 static int cs35l34_handle_of_data(struct i2c_client *i2c_client,
+3
sound/soc/codecs/cs42l42.c
··· 399 399 .reg_defaults = cs42l42_reg_defaults, 400 400 .num_reg_defaults = ARRAY_SIZE(cs42l42_reg_defaults), 401 401 .cache_type = REGCACHE_RBTREE, 402 + 403 + .use_single_read = true, 404 + .use_single_write = true, 402 405 }; 403 406 404 407 static DECLARE_TLV_DB_SCALE(adc_tlv, -9600, 100, false);
+6 -1
sound/soc/codecs/cs42l56.c
··· 1175 1175 struct cs42l56_platform_data *pdata = 1176 1176 dev_get_platdata(&i2c_client->dev); 1177 1177 int ret, i; 1178 - unsigned int devid = 0; 1178 + unsigned int devid; 1179 1179 unsigned int alpha_rev, metal_rev; 1180 1180 unsigned int reg; 1181 1181 ··· 1245 1245 } 1246 1246 1247 1247 ret = regmap_read(cs42l56->regmap, CS42L56_CHIP_ID_1, &reg); 1248 + if (ret) { 1249 + dev_err(&i2c_client->dev, "Failed to read chip ID: %d\n", ret); 1250 + return ret; 1251 + } 1252 + 1248 1253 devid = reg & CS42L56_CHIP_ID_MASK; 1249 1254 if (devid != CS42L56_DEVID) { 1250 1255 dev_err(&i2c_client->dev,
+3
sound/soc/codecs/cs42l73.c
··· 1268 1268 .volatile_reg = cs42l73_volatile_register, 1269 1269 .readable_reg = cs42l73_readable_register, 1270 1270 .cache_type = REGCACHE_RBTREE, 1271 + 1272 + .use_single_read = true, 1273 + .use_single_write = true, 1271 1274 }; 1272 1275 1273 1276 static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
+3
sound/soc/codecs/cs53l30.c
··· 912 912 .writeable_reg = cs53l30_writeable_register, 913 913 .readable_reg = cs53l30_readable_register, 914 914 .cache_type = REGCACHE_RBTREE, 915 + 916 + .use_single_read = true, 917 + .use_single_write = true, 915 918 }; 916 919 917 920 static int cs53l30_i2c_probe(struct i2c_client *client,
+1 -4
sound/soc/codecs/da7219.c
··· 2181 2181 ret); 2182 2182 goto err; 2183 2183 } 2184 - 2185 - da7219->dai_clks[i] = devm_clk_hw_get_clk(dev, dai_clk_hw, NULL); 2186 - if (IS_ERR(da7219->dai_clks[i])) 2187 - return PTR_ERR(da7219->dai_clks[i]); 2184 + da7219->dai_clks[i] = dai_clk_hw->clk; 2188 2185 2189 2186 /* For DT setup onecell data, otherwise create lookup */ 2190 2187 if (np) {
+1
sound/soc/codecs/lpass-rx-macro.c
··· 3579 3579 { .compatible = "qcom,sm8250-lpass-rx-macro" }, 3580 3580 { } 3581 3581 }; 3582 + MODULE_DEVICE_TABLE(of, rx_macro_dt_match); 3582 3583 3583 3584 static struct platform_driver rx_macro_driver = { 3584 3585 .driver = {
+1
sound/soc/codecs/lpass-tx-macro.c
··· 1846 1846 { .compatible = "qcom,sm8250-lpass-tx-macro" }, 1847 1847 { } 1848 1848 }; 1849 + MODULE_DEVICE_TABLE(of, tx_macro_dt_match); 1849 1850 static struct platform_driver tx_macro_driver = { 1850 1851 .driver = { 1851 1852 .name = "tx_macro",
+11 -2
sound/soc/codecs/max98088.c
··· 41 41 enum max98088_type devtype; 42 42 struct max98088_pdata *pdata; 43 43 struct clk *mclk; 44 + unsigned char mclk_prescaler; 44 45 unsigned int sysclk; 45 46 struct max98088_cdata dai[2]; 46 47 int eq_textcnt; ··· 999 998 /* Configure NI when operating as master */ 1000 999 if (snd_soc_component_read(component, M98088_REG_14_DAI1_FORMAT) 1001 1000 & M98088_DAI_MAS) { 1001 + unsigned long pclk; 1002 + 1002 1003 if (max98088->sysclk == 0) { 1003 1004 dev_err(component->dev, "Invalid system clock frequency\n"); 1004 1005 return -EINVAL; 1005 1006 } 1006 1007 ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL) 1007 1008 * (unsigned long long int)rate; 1008 - do_div(ni, (unsigned long long int)max98088->sysclk); 1009 + pclk = DIV_ROUND_CLOSEST(max98088->sysclk, max98088->mclk_prescaler); 1010 + ni = DIV_ROUND_CLOSEST_ULL(ni, pclk); 1009 1011 snd_soc_component_write(component, M98088_REG_12_DAI1_CLKCFG_HI, 1010 1012 (ni >> 8) & 0x7F); 1011 1013 snd_soc_component_write(component, M98088_REG_13_DAI1_CLKCFG_LO, ··· 1069 1065 /* Configure NI when operating as master */ 1070 1066 if (snd_soc_component_read(component, M98088_REG_1C_DAI2_FORMAT) 1071 1067 & M98088_DAI_MAS) { 1068 + unsigned long pclk; 1069 + 1072 1070 if (max98088->sysclk == 0) { 1073 1071 dev_err(component->dev, "Invalid system clock frequency\n"); 1074 1072 return -EINVAL; 1075 1073 } 1076 1074 ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL) 1077 1075 * (unsigned long long int)rate; 1078 - do_div(ni, (unsigned long long int)max98088->sysclk); 1076 + pclk = DIV_ROUND_CLOSEST(max98088->sysclk, max98088->mclk_prescaler); 1077 + ni = DIV_ROUND_CLOSEST_ULL(ni, pclk); 1079 1078 snd_soc_component_write(component, M98088_REG_1A_DAI2_CLKCFG_HI, 1080 1079 (ni >> 8) & 0x7F); 1081 1080 snd_soc_component_write(component, M98088_REG_1B_DAI2_CLKCFG_LO, ··· 1120 1113 */ 1121 1114 if ((freq >= 10000000) && (freq < 20000000)) { 1122 1115 snd_soc_component_write(component, M98088_REG_10_SYS_CLK, 0x10); 1116 + max98088->mclk_prescaler = 1; 1123 1117 } else if ((freq >= 20000000) && (freq < 30000000)) { 1124 1118 snd_soc_component_write(component, M98088_REG_10_SYS_CLK, 0x20); 1119 + max98088->mclk_prescaler = 2; 1125 1120 } else { 1126 1121 dev_err(component->dev, "Invalid master clock frequency\n"); 1127 1122 return -EINVAL;
+2 -2
sound/soc/codecs/rt711-sdca.c
··· 683 683 ch_r = (rt711->fu1e_dapm_mute || rt711->fu1e_mixer_r_mute) ? 0x01 : 0x00; 684 684 685 685 err = regmap_write(rt711->regmap, 686 - SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT711_SDCA_ENT_USER_FU1E, 686 + SDW_SDCA_CTL(FUNC_NUM_MIC_ARRAY, RT711_SDCA_ENT_USER_FU1E, 687 687 RT711_SDCA_CTL_FU_MUTE, CH_L), ch_l); 688 688 if (err < 0) 689 689 return err; 690 690 691 691 err = regmap_write(rt711->regmap, 692 - SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT711_SDCA_ENT_USER_FU1E, 692 + SDW_SDCA_CTL(FUNC_NUM_MIC_ARRAY, RT711_SDCA_ENT_USER_FU1E, 693 693 RT711_SDCA_CTL_FU_MUTE, CH_R), ch_r); 694 694 if (err < 0) 695 695 return err;
+1
sound/soc/codecs/sti-sas.c
··· 408 408 }, 409 409 {}, 410 410 }; 411 + MODULE_DEVICE_TABLE(of, sti_sas_dev_match); 411 412 412 413 static int sti_sas_driver_probe(struct platform_device *pdev) 413 414 {
+1
sound/soc/fsl/Kconfig
··· 119 119 tristate "NXP Audio Base On RPMSG support" 120 120 depends on COMMON_CLK 121 121 depends on RPMSG 122 + depends on SND_IMX_SOC || SND_IMX_SOC = n 122 123 select SND_SOC_IMX_RPMSG if SND_IMX_SOC != n 123 124 help 124 125 Say Y if you want to add rpmsg audio support for the Freescale CPUs.
+29 -28
sound/soc/generic/audio-graph-card.c
··· 209 209 static int graph_parse_node(struct asoc_simple_priv *priv, 210 210 struct device_node *ep, 211 211 struct link_info *li, 212 - int is_cpu) 212 + int *cpu) 213 213 { 214 214 struct device *dev = simple_priv_to_dev(priv); 215 215 struct device_node *top = dev->of_node; ··· 217 217 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); 218 218 struct snd_soc_dai_link_component *dlc; 219 219 struct asoc_simple_dai *dai; 220 - int ret, single = 0; 220 + int ret; 221 221 222 - if (is_cpu) { 222 + if (cpu) { 223 223 dlc = asoc_link_to_cpu(dai_link, 0); 224 224 dai = simple_props_to_dai_cpu(dai_props, 0); 225 225 } else { ··· 229 229 230 230 graph_parse_mclk_fs(top, ep, dai_props); 231 231 232 - ret = asoc_simple_parse_dai(ep, dlc, &single); 232 + ret = asoc_simple_parse_dai(ep, dlc, cpu); 233 233 if (ret < 0) 234 234 return ret; 235 235 ··· 240 240 ret = asoc_simple_parse_clk(dev, ep, dai, dlc); 241 241 if (ret < 0) 242 242 return ret; 243 - 244 - if (is_cpu) 245 - asoc_simple_canonicalize_cpu(dlc, single); 246 243 247 244 return 0; 248 245 } ··· 273 276 struct link_info *li) 274 277 { 275 278 struct device *dev = simple_priv_to_dev(priv); 276 - struct snd_soc_card *card = simple_priv_to_card(priv); 277 279 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); 278 280 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); 279 281 struct device_node *top = dev->of_node; 280 282 struct device_node *ep = li->cpu ? cpu_ep : codec_ep; 281 - struct device_node *port; 282 - struct device_node *ports; 283 - struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); 284 - struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); 285 283 char dai_name[64]; 286 284 int ret; 287 - 288 - port = of_get_parent(ep); 289 - ports = of_get_parent(port); 290 285 291 286 dev_dbg(dev, "link_of DPCM (%pOF)\n", ep); 292 287 293 288 if (li->cpu) { 289 + struct snd_soc_card *card = simple_priv_to_card(priv); 290 + struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); 291 + int is_single_links = 0; 292 + 294 293 /* Codec is dummy */ 295 294 296 295 /* FE settings */ 297 296 dai_link->dynamic = 1; 298 297 dai_link->dpcm_merged_format = 1; 299 298 300 - ret = graph_parse_node(priv, cpu_ep, li, 1); 299 + ret = graph_parse_node(priv, cpu_ep, li, &is_single_links); 301 300 if (ret) 302 - goto out_put_node; 301 + return ret; 303 302 304 303 snprintf(dai_name, sizeof(dai_name), 305 304 "fe.%pOFP.%s", cpus->of_node, cpus->dai_name); ··· 311 318 */ 312 319 if (card->component_chaining && !soc_component_is_pcm(cpus)) 313 320 dai_link->no_pcm = 1; 321 + 322 + asoc_simple_canonicalize_cpu(cpus, is_single_links); 314 323 } else { 315 - struct snd_soc_codec_conf *cconf; 324 + struct snd_soc_codec_conf *cconf = simple_props_to_codec_conf(dai_props, 0); 325 + struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); 326 + struct device_node *port; 327 + struct device_node *ports; 316 328 317 329 /* CPU is dummy */ 318 330 ··· 325 327 dai_link->no_pcm = 1; 326 328 dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; 327 329 328 - cconf = simple_props_to_codec_conf(dai_props, 0); 329 - 330 - ret = graph_parse_node(priv, codec_ep, li, 0); 330 + ret = graph_parse_node(priv, codec_ep, li, NULL); 331 331 if (ret < 0) 332 - goto out_put_node; 332 + return ret; 333 333 334 334 snprintf(dai_name, sizeof(dai_name), 335 335 "be.%pOFP.%s", codecs->of_node, codecs->dai_name); 336 336 337 337 /* check "prefix" from top node */ 338 + port = of_get_parent(ep); 339 + ports = of_get_parent(port); 338 340 snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, 339 341 "prefix"); 340 342 if (of_node_name_eq(ports, "ports")) 341 343 snd_soc_of_parse_node_prefix(ports, cconf, codecs->of_node, "prefix"); 342 344 snd_soc_of_parse_node_prefix(port, cconf, codecs->of_node, 343 345 "prefix"); 346 + 347 + of_node_put(ports); 348 + of_node_put(port); 344 349 } 345 350 346 351 graph_parse_convert(dev, ep, &dai_props->adata); ··· 352 351 353 352 ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name); 354 353 355 - out_put_node: 356 354 li->link++; 357 355 358 - of_node_put(ports); 359 - of_node_put(port); 360 356 return ret; 361 357 } 362 358 ··· 367 369 struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); 368 370 struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); 369 371 char dai_name[64]; 370 - int ret; 372 + int ret, is_single_links = 0; 371 373 372 374 dev_dbg(dev, "link_of (%pOF)\n", cpu_ep); 373 375 374 - ret = graph_parse_node(priv, cpu_ep, li, 1); 376 + ret = graph_parse_node(priv, cpu_ep, li, &is_single_links); 375 377 if (ret < 0) 376 378 return ret; 377 379 378 - ret = graph_parse_node(priv, codec_ep, li, 0); 380 + ret = graph_parse_node(priv, codec_ep, li, NULL); 379 381 if (ret < 0) 380 382 return ret; 381 383 382 384 snprintf(dai_name, sizeof(dai_name), 383 385 "%s-%s", cpus->dai_name, codecs->dai_name); 386 + 387 + asoc_simple_canonicalize_cpu(cpus, is_single_links); 388 + 384 389 ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name); 385 390 if (ret < 0) 386 391 return ret;
+83 -85
sound/soc/generic/simple-card.c
··· 93 93 } 94 94 95 95 static void simple_parse_mclk_fs(struct device_node *top, 96 - struct device_node *cpu, 97 - struct device_node *codec, 96 + struct device_node *np, 98 97 struct simple_dai_props *props, 99 98 char *prefix) 100 99 { 101 - struct device_node *node = of_get_parent(cpu); 100 + struct device_node *node = of_get_parent(np); 102 101 char prop[128]; 103 102 104 103 snprintf(prop, sizeof(prop), "%smclk-fs", PREFIX); ··· 105 106 106 107 snprintf(prop, sizeof(prop), "%smclk-fs", prefix); 107 108 of_property_read_u32(node, prop, &props->mclk_fs); 108 - of_property_read_u32(cpu, prop, &props->mclk_fs); 109 - of_property_read_u32(codec, prop, &props->mclk_fs); 109 + of_property_read_u32(np, prop, &props->mclk_fs); 110 110 111 111 of_node_put(node); 112 + } 113 + 114 + static int simple_parse_node(struct asoc_simple_priv *priv, 115 + struct device_node *np, 116 + struct link_info *li, 117 + char *prefix, 118 + int *cpu) 119 + { 120 + struct device *dev = simple_priv_to_dev(priv); 121 + struct device_node *top = dev->of_node; 122 + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); 123 + struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); 124 + struct snd_soc_dai_link_component *dlc; 125 + struct asoc_simple_dai *dai; 126 + int ret; 127 + 128 + if (cpu) { 129 + dlc = asoc_link_to_cpu(dai_link, 0); 130 + dai = simple_props_to_dai_cpu(dai_props, 0); 131 + } else { 132 + dlc = asoc_link_to_codec(dai_link, 0); 133 + dai = simple_props_to_dai_codec(dai_props, 0); 134 + } 135 + 136 + simple_parse_mclk_fs(top, np, dai_props, prefix); 137 + 138 + ret = asoc_simple_parse_dai(np, dlc, cpu); 139 + if (ret) 140 + return ret; 141 + 142 + ret = asoc_simple_parse_clk(dev, np, dai, dlc); 143 + if (ret) 144 + return ret; 145 + 146 + ret = asoc_simple_parse_tdm(np, dai); 147 + if (ret) 148 + return ret; 149 + 150 + return 0; 151 + } 152 + 153 + static int simple_link_init(struct asoc_simple_priv *priv, 154 + struct device_node *node, 155 + struct device_node *codec, 156 + struct link_info *li, 157 + char *prefix, char *name) 158 + { 159 + struct device *dev = simple_priv_to_dev(priv); 160 + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); 161 + int ret; 162 + 163 + ret = asoc_simple_parse_daifmt(dev, node, codec, 164 + prefix, &dai_link->dai_fmt); 165 + if (ret < 0) 166 + return 0; 167 + 168 + dai_link->init = asoc_simple_dai_init; 169 + dai_link->ops = &simple_ops; 170 + 171 + return asoc_simple_set_dailink_name(dev, dai_link, name); 112 172 } 113 173 114 174 static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, ··· 179 121 struct device *dev = simple_priv_to_dev(priv); 180 122 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); 181 123 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); 182 - struct asoc_simple_dai *dai; 183 - struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); 184 - struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); 185 - struct snd_soc_dai_link_component *platforms = asoc_link_to_platform(dai_link, 0); 186 124 struct device_node *top = dev->of_node; 187 125 struct device_node *node = of_get_parent(np); 188 126 char *prefix = ""; 127 + char dai_name[64]; 189 128 int ret; 190 129 191 130 dev_dbg(dev, "link_of DPCM (%pOF)\n", np); 192 - 193 - li->link++; 194 131 195 132 /* For single DAI link & old style of DT node */ 196 133 if (is_top) 197 134 prefix = PREFIX; 198 135 199 136 if (li->cpu) { 137 + struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); 138 + struct snd_soc_dai_link_component *platforms = asoc_link_to_platform(dai_link, 0); 200 139 int is_single_links = 0; 201 140 202 141 /* Codec is dummy */ ··· 202 147 dai_link->dynamic = 1; 203 148 dai_link->dpcm_merged_format = 1; 204 149 205 - dai = simple_props_to_dai_cpu(dai_props, 0); 206 - 207 - ret = asoc_simple_parse_dai(np, cpus, &is_single_links); 208 - if (ret) 209 - goto out_put_node; 210 - 211 - ret = asoc_simple_parse_clk(dev, np, dai, cpus); 150 + ret = simple_parse_node(priv, np, li, prefix, &is_single_links); 212 151 if (ret < 0) 213 152 goto out_put_node; 214 153 215 - ret = asoc_simple_set_dailink_name(dev, dai_link, 216 - "fe.%s", 217 - cpus->dai_name); 218 - if (ret < 0) 219 - goto out_put_node; 154 + snprintf(dai_name, sizeof(dai_name), "fe.%s", cpus->dai_name); 220 155 221 156 asoc_simple_canonicalize_cpu(cpus, is_single_links); 222 157 asoc_simple_canonicalize_platform(platforms, cpus); 223 158 } else { 159 + struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); 224 160 struct snd_soc_codec_conf *cconf; 225 161 226 162 /* CPU is dummy */ ··· 220 174 dai_link->no_pcm = 1; 221 175 dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; 222 176 223 - dai = simple_props_to_dai_codec(dai_props, 0); 224 177 cconf = simple_props_to_codec_conf(dai_props, 0); 225 178 226 - ret = asoc_simple_parse_dai(np, codecs, NULL); 179 + ret = simple_parse_node(priv, np, li, prefix, NULL); 227 180 if (ret < 0) 228 181 goto out_put_node; 229 182 230 - ret = asoc_simple_parse_clk(dev, np, dai, codecs); 231 - if (ret < 0) 232 - goto out_put_node; 233 - 234 - ret = asoc_simple_set_dailink_name(dev, dai_link, 235 - "be.%s", 236 - codecs->dai_name); 237 - if (ret < 0) 238 - goto out_put_node; 183 + snprintf(dai_name, sizeof(dai_name), "be.%s", codecs->dai_name); 239 184 240 185 /* check "prefix" from top node */ 241 186 snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, ··· 238 201 } 239 202 240 203 simple_parse_convert(dev, np, &dai_props->adata); 241 - simple_parse_mclk_fs(top, np, codec, dai_props, prefix); 242 - 243 - ret = asoc_simple_parse_tdm(np, dai); 244 - if (ret) 245 - goto out_put_node; 246 - 247 - ret = asoc_simple_parse_daifmt(dev, node, codec, 248 - prefix, &dai_link->dai_fmt); 249 - if (ret < 0) 250 - goto out_put_node; 251 204 252 205 snd_soc_dai_link_set_capabilities(dai_link); 253 206 254 - dai_link->ops = &simple_ops; 255 - dai_link->init = asoc_simple_dai_init; 207 + ret = simple_link_init(priv, node, codec, li, prefix, dai_name); 256 208 257 209 out_put_node: 210 + li->link++; 211 + 258 212 of_node_put(node); 259 213 return ret; 260 214 } ··· 258 230 { 259 231 struct device *dev = simple_priv_to_dev(priv); 260 232 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); 261 - struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); 262 - struct asoc_simple_dai *cpu_dai = simple_props_to_dai_cpu(dai_props, 0); 263 - struct asoc_simple_dai *codec_dai = simple_props_to_dai_codec(dai_props, 0); 264 233 struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); 265 234 struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); 266 235 struct snd_soc_dai_link_component *platforms = asoc_link_to_platform(dai_link, 0); 267 - struct device_node *top = dev->of_node; 268 236 struct device_node *cpu = NULL; 269 237 struct device_node *node = NULL; 270 238 struct device_node *plat = NULL; 239 + char dai_name[64]; 271 240 char prop[128]; 272 241 char *prefix = ""; 273 242 int ret, single_cpu = 0; 274 243 275 244 cpu = np; 276 245 node = of_get_parent(np); 277 - li->link++; 278 246 279 247 dev_dbg(dev, "link_of (%pOF)\n", node); 280 248 ··· 281 257 snprintf(prop, sizeof(prop), "%splat", prefix); 282 258 plat = of_get_child_by_name(node, prop); 283 259 284 - ret = asoc_simple_parse_daifmt(dev, node, codec, 285 - prefix, &dai_link->dai_fmt); 260 + ret = simple_parse_node(priv, cpu, li, prefix, &single_cpu); 286 261 if (ret < 0) 287 262 goto dai_link_of_err; 288 263 289 - simple_parse_mclk_fs(top, cpu, codec, dai_props, prefix); 290 - 291 - ret = asoc_simple_parse_dai(cpu, cpus, &single_cpu); 292 - if (ret < 0) 293 - goto dai_link_of_err; 294 - 295 - ret = asoc_simple_parse_dai(codec, codecs, NULL); 264 + ret = simple_parse_node(priv, codec, li, prefix, NULL); 296 265 if (ret < 0) 297 266 goto dai_link_of_err; 298 267 ··· 293 276 if (ret < 0) 294 277 goto dai_link_of_err; 295 278 296 - ret = asoc_simple_parse_tdm(cpu, cpu_dai); 297 - if (ret < 0) 298 - goto dai_link_of_err; 299 - 300 - ret = asoc_simple_parse_tdm(codec, codec_dai); 301 - if (ret < 0) 302 - goto dai_link_of_err; 303 - 304 - ret = asoc_simple_parse_clk(dev, cpu, cpu_dai, cpus); 305 - if (ret < 0) 306 - goto dai_link_of_err; 307 - 308 - ret = asoc_simple_parse_clk(dev, codec, codec_dai, codecs); 309 - if (ret < 0) 310 - goto dai_link_of_err; 311 - 312 - ret = asoc_simple_set_dailink_name(dev, dai_link, 313 - "%s-%s", 314 - cpus->dai_name, 315 - codecs->dai_name); 316 - if (ret < 0) 317 - goto dai_link_of_err; 318 - 319 - dai_link->ops = &simple_ops; 320 - dai_link->init = asoc_simple_dai_init; 279 + snprintf(dai_name, sizeof(dai_name), 280 + "%s-%s", cpus->dai_name, codecs->dai_name); 321 281 322 282 asoc_simple_canonicalize_cpu(cpus, single_cpu); 323 283 asoc_simple_canonicalize_platform(platforms, cpus); 324 284 285 + ret = simple_link_init(priv, node, codec, li, prefix, dai_name); 286 + 325 287 dai_link_of_err: 326 288 of_node_put(plat); 327 289 of_node_put(node); 290 + 291 + li->link++; 328 292 329 293 return ret; 330 294 }
+25
sound/soc/intel/boards/bytcr_rt5640.c
··· 574 574 BYT_RT5640_SSP0_AIF1 | 575 575 BYT_RT5640_MCLK_EN), 576 576 }, 577 + { /* Glavey TM800A550L */ 578 + .matches = { 579 + DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 580 + DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), 581 + /* Above strings are too generic, also match on BIOS version */ 582 + DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"), 583 + }, 584 + .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | 585 + BYT_RT5640_SSP0_AIF1 | 586 + BYT_RT5640_MCLK_EN), 587 + }, 577 588 { 578 589 .matches = { 579 590 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), ··· 661 650 BYT_RT5640_OVCD_TH_2000UA | 662 651 BYT_RT5640_OVCD_SF_0P75 | 663 652 BYT_RT5640_MONO_SPEAKER | 653 + BYT_RT5640_MCLK_EN), 654 + }, 655 + { /* Lenovo Miix 3-830 */ 656 + .matches = { 657 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"), 658 + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 3-830"), 659 + }, 660 + .driver_data = (void *)(BYT_RT5640_IN1_MAP | 661 + BYT_RT5640_JD_SRC_JD2_IN4N | 662 + BYT_RT5640_OVCD_TH_2000UA | 663 + BYT_RT5640_OVCD_SF_0P75 | 664 + BYT_RT5640_MONO_SPEAKER | 665 + BYT_RT5640_DIFF_MIC | 666 + BYT_RT5640_SSP0_AIF1 | 664 667 BYT_RT5640_MCLK_EN), 665 668 }, 666 669 { /* Linx Linx7 tablet */
+1 -11
sound/soc/qcom/lpass-cpu.c
··· 835 835 if (dai_id == LPASS_DP_RX) 836 836 continue; 837 837 838 - drvdata->mi2s_osr_clk[dai_id] = devm_clk_get(dev, 838 + drvdata->mi2s_osr_clk[dai_id] = devm_clk_get_optional(dev, 839 839 variant->dai_osr_clk_names[i]); 840 - if (IS_ERR(drvdata->mi2s_osr_clk[dai_id])) { 841 - dev_warn(dev, 842 - "%s() error getting optional %s: %ld\n", 843 - __func__, 844 - variant->dai_osr_clk_names[i], 845 - PTR_ERR(drvdata->mi2s_osr_clk[dai_id])); 846 - 847 - drvdata->mi2s_osr_clk[dai_id] = NULL; 848 - } 849 - 850 840 drvdata->mi2s_bit_clk[dai_id] = devm_clk_get(dev, 851 841 variant->dai_bit_clk_names[i]); 852 842 if (IS_ERR(drvdata->mi2s_bit_clk[dai_id])) {
+5
sound/soc/sof/intel/hda-dai.c
··· 421 421 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 422 422 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME); 423 423 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); 424 + struct sof_ipc_fw_version *v = &sdev->fw_ready.version; 424 425 struct sof_ipc_dai_config *config; 425 426 struct snd_sof_dai *sof_dai; 426 427 struct sof_ipc_reply reply; 427 428 int ret; 429 + 430 + /* DAI_CONFIG IPC during hw_params is not supported in older firmware */ 431 + if (v->abi_version < SOF_ABI_VER(3, 18, 0)) 432 + return 0; 428 433 429 434 list_for_each_entry(sof_dai, &sdev->dai_list, list) { 430 435 if (!sof_dai->cpu_dai_name || !sof_dai->dai_config)
+1 -4
sound/soc/stm/stm32_sai_sub.c
··· 484 484 dev_err(dev, "mclk register returned %d\n", ret); 485 485 return ret; 486 486 } 487 - 488 - sai->sai_mclk = devm_clk_hw_get_clk(dev, hw, NULL); 489 - if (IS_ERR(sai->sai_mclk)) 490 - return PTR_ERR(sai->sai_mclk); 487 + sai->sai_mclk = hw->clk; 491 488 492 489 /* register mclk provider */ 493 490 return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
+1 -1
sound/usb/format.c
··· 436 436 if (snd_BUG_ON(altsetting >= 64 - 8)) 437 437 return false; 438 438 439 - err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, 439 + err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 440 440 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 441 441 UAC2_AS_VAL_ALT_SETTINGS << 8, 442 442 iface, &raw_data, sizeof(raw_data));
+1 -1
sound/usb/mixer_quirks.c
··· 3060 3060 case USB_ID(0x1235, 0x8203): /* Focusrite Scarlett 6i6 2nd Gen */ 3061 3061 case USB_ID(0x1235, 0x8204): /* Focusrite Scarlett 18i8 2nd Gen */ 3062 3062 case USB_ID(0x1235, 0x8201): /* Focusrite Scarlett 18i20 2nd Gen */ 3063 - err = snd_scarlett_gen2_controls_create(mixer); 3063 + err = snd_scarlett_gen2_init(mixer); 3064 3064 break; 3065 3065 3066 3066 case USB_ID(0x041e, 0x323b): /* Creative Sound Blaster E1 */
+51 -30
sound/usb/mixer_scarlett_gen2.c
··· 635 635 /* send a second message to get the response */ 636 636 637 637 err = snd_usb_ctl_msg(mixer->chip->dev, 638 - usb_sndctrlpipe(mixer->chip->dev, 0), 638 + usb_rcvctrlpipe(mixer->chip->dev, 0), 639 639 SCARLETT2_USB_VENDOR_SPECIFIC_CMD_RESP, 640 640 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 641 641 0, ··· 1997 1997 return usb_submit_urb(mixer->urb, GFP_KERNEL); 1998 1998 } 1999 1999 2000 - /* Entry point */ 2001 - int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer) 2000 + static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer, 2001 + const struct scarlett2_device_info *info) 2002 2002 { 2003 - const struct scarlett2_device_info *info; 2004 2003 int err; 2005 - 2006 - /* only use UAC_VERSION_2 */ 2007 - if (!mixer->protocol) 2008 - return 0; 2009 - 2010 - switch (mixer->chip->usb_id) { 2011 - case USB_ID(0x1235, 0x8203): 2012 - info = &s6i6_gen2_info; 2013 - break; 2014 - case USB_ID(0x1235, 0x8204): 2015 - info = &s18i8_gen2_info; 2016 - break; 2017 - case USB_ID(0x1235, 0x8201): 2018 - info = &s18i20_gen2_info; 2019 - break; 2020 - default: /* device not (yet) supported */ 2021 - return -EINVAL; 2022 - } 2023 - 2024 - if (!(mixer->chip->setup & SCARLETT2_ENABLE)) { 2025 - usb_audio_err(mixer->chip, 2026 - "Focusrite Scarlett Gen 2 Mixer Driver disabled; " 2027 - "use options snd_usb_audio device_setup=1 " 2028 - "to enable and report any issues to g@b4.vu"); 2029 - return 0; 2030 - } 2031 2004 2032 2005 /* Initialise private data, routing, sequence number */ 2033 2006 err = scarlett2_init_private(mixer, info); ··· 2045 2072 } 2046 2073 2047 2074 return 0; 2075 + } 2076 + 2077 + int snd_scarlett_gen2_init(struct usb_mixer_interface *mixer) 2078 + { 2079 + struct snd_usb_audio *chip = mixer->chip; 2080 + const struct scarlett2_device_info *info; 2081 + int err; 2082 + 2083 + /* only use UAC_VERSION_2 */ 2084 + if (!mixer->protocol) 2085 + return 0; 2086 + 2087 + switch (chip->usb_id) { 2088 + case USB_ID(0x1235, 0x8203): 2089 + info = &s6i6_gen2_info; 2090 + break; 2091 + case USB_ID(0x1235, 0x8204): 2092 + info = &s18i8_gen2_info; 2093 + break; 2094 + case USB_ID(0x1235, 0x8201): 2095 + info = &s18i20_gen2_info; 2096 + break; 2097 + default: /* device not (yet) supported */ 2098 + return -EINVAL; 2099 + } 2100 + 2101 + if (!(chip->setup & SCARLETT2_ENABLE)) { 2102 + usb_audio_info(chip, 2103 + "Focusrite Scarlett Gen 2 Mixer Driver disabled; " 2104 + "use options snd_usb_audio vid=0x%04x pid=0x%04x " 2105 + "device_setup=1 to enable and report any issues " 2106 + "to g@b4.vu", 2107 + USB_ID_VENDOR(chip->usb_id), 2108 + USB_ID_PRODUCT(chip->usb_id)); 2109 + return 0; 2110 + } 2111 + 2112 + usb_audio_info(chip, 2113 + "Focusrite Scarlett Gen 2 Mixer Driver enabled pid=0x%04x", 2114 + USB_ID_PRODUCT(chip->usb_id)); 2115 + 2116 + err = snd_scarlett_gen2_controls_create(mixer, info); 2117 + if (err < 0) 2118 + usb_audio_err(mixer->chip, 2119 + "Error initialising Scarlett Mixer Driver: %d", 2120 + err); 2121 + 2122 + return err; 2048 2123 }
+1 -1
sound/usb/mixer_scarlett_gen2.h
··· 2 2 #ifndef __USB_MIXER_SCARLETT_GEN2_H 3 3 #define __USB_MIXER_SCARLETT_GEN2_H 4 4 5 - int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer); 5 + int snd_scarlett_gen2_init(struct usb_mixer_interface *mixer); 6 6 7 7 #endif /* __USB_MIXER_SCARLETT_GEN2_H */
+3 -1
tools/bpf/bpftool/Documentation/bpftool-cgroup.rst
··· 30 30 | *ATTACH_TYPE* := { **ingress** | **egress** | **sock_create** | **sock_ops** | **device** | 31 31 | **bind4** | **bind6** | **post_bind4** | **post_bind6** | **connect4** | **connect6** | 32 32 | **getpeername4** | **getpeername6** | **getsockname4** | **getsockname6** | **sendmsg4** | 33 - | **sendmsg6** | **recvmsg4** | **recvmsg6** | **sysctl** | **getsockopt** | **setsockopt** } 33 + | **sendmsg6** | **recvmsg4** | **recvmsg6** | **sysctl** | **getsockopt** | **setsockopt** | 34 + | **sock_release** } 34 35 | *ATTACH_FLAGS* := { **multi** | **override** } 35 36 36 37 DESCRIPTION ··· 107 106 **getpeername6** call to getpeername(2) for an inet6 socket (since 5.8); 108 107 **getsockname4** call to getsockname(2) for an inet4 socket (since 5.8); 109 108 **getsockname6** call to getsockname(2) for an inet6 socket (since 5.8). 109 + **sock_release** closing an userspace inet socket (since 5.9). 110 110 111 111 **bpftool cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG* 112 112 Detach *PROG* from the cgroup *CGROUP* and attach type
+1 -1
tools/bpf/bpftool/Documentation/bpftool-prog.rst
··· 44 44 | **cgroup/connect4** | **cgroup/connect6** | **cgroup/getpeername4** | **cgroup/getpeername6** | 45 45 | **cgroup/getsockname4** | **cgroup/getsockname6** | **cgroup/sendmsg4** | **cgroup/sendmsg6** | 46 46 | **cgroup/recvmsg4** | **cgroup/recvmsg6** | **cgroup/sysctl** | 47 - | **cgroup/getsockopt** | **cgroup/setsockopt** | 47 + | **cgroup/getsockopt** | **cgroup/setsockopt** | **cgroup/sock_release** | 48 48 | **struct_ops** | **fentry** | **fexit** | **freplace** | **sk_lookup** 49 49 | } 50 50 | *ATTACH_TYPE* := {
+3 -3
tools/bpf/bpftool/bash-completion/bpftool
··· 478 478 cgroup/recvmsg4 cgroup/recvmsg6 \ 479 479 cgroup/post_bind4 cgroup/post_bind6 \ 480 480 cgroup/sysctl cgroup/getsockopt \ 481 - cgroup/setsockopt struct_ops \ 481 + cgroup/setsockopt cgroup/sock_release struct_ops \ 482 482 fentry fexit freplace sk_lookup" -- \ 483 483 "$cur" ) ) 484 484 return 0 ··· 1021 1021 device bind4 bind6 post_bind4 post_bind6 connect4 connect6 \ 1022 1022 getpeername4 getpeername6 getsockname4 getsockname6 \ 1023 1023 sendmsg4 sendmsg6 recvmsg4 recvmsg6 sysctl getsockopt \ 1024 - setsockopt' 1024 + setsockopt sock_release' 1025 1025 local ATTACH_FLAGS='multi override' 1026 1026 local PROG_TYPE='id pinned tag name' 1027 1027 case $prev in ··· 1032 1032 ingress|egress|sock_create|sock_ops|device|bind4|bind6|\ 1033 1033 post_bind4|post_bind6|connect4|connect6|getpeername4|\ 1034 1034 getpeername6|getsockname4|getsockname6|sendmsg4|sendmsg6|\ 1035 - recvmsg4|recvmsg6|sysctl|getsockopt|setsockopt) 1035 + recvmsg4|recvmsg6|sysctl|getsockopt|setsockopt|sock_release) 1036 1036 COMPREPLY=( $( compgen -W "$PROG_TYPE" -- \ 1037 1037 "$cur" ) ) 1038 1038 return 0
+2 -1
tools/bpf/bpftool/cgroup.c
··· 28 28 " connect6 | getpeername4 | getpeername6 |\n" \ 29 29 " getsockname4 | getsockname6 | sendmsg4 |\n" \ 30 30 " sendmsg6 | recvmsg4 | recvmsg6 |\n" \ 31 - " sysctl | getsockopt | setsockopt }" 31 + " sysctl | getsockopt | setsockopt |\n" \ 32 + " sock_release }" 32 33 33 34 static unsigned int query_flags; 34 35
+1 -1
tools/bpf/bpftool/prog.c
··· 2138 2138 " cgroup/getpeername4 | cgroup/getpeername6 |\n" 2139 2139 " cgroup/getsockname4 | cgroup/getsockname6 | cgroup/sendmsg4 |\n" 2140 2140 " cgroup/sendmsg6 | cgroup/recvmsg4 | cgroup/recvmsg6 |\n" 2141 - " cgroup/getsockopt | cgroup/setsockopt |\n" 2141 + " cgroup/getsockopt | cgroup/setsockopt | cgroup/sock_release |\n" 2142 2142 " struct_ops | fentry | fexit | freplace | sk_lookup }\n" 2143 2143 " ATTACH_TYPE := { msg_verdict | stream_verdict | stream_parser |\n" 2144 2144 " flow_dissector }\n"
+3 -2
tools/include/uapi/linux/kvm.h
··· 8 8 * Note: you must update KVM_API_VERSION if you change this interface. 9 9 */ 10 10 11 + #include <linux/const.h> 11 12 #include <linux/types.h> 12 13 #include <linux/compiler.h> 13 14 #include <linux/ioctl.h> ··· 1880 1879 * conversion after harvesting an entry. Also, it must not skip any 1881 1880 * dirty bits, so that dirty bits are always harvested in sequence. 1882 1881 */ 1883 - #define KVM_DIRTY_GFN_F_DIRTY BIT(0) 1884 - #define KVM_DIRTY_GFN_F_RESET BIT(1) 1882 + #define KVM_DIRTY_GFN_F_DIRTY _BITUL(0) 1883 + #define KVM_DIRTY_GFN_F_RESET _BITUL(1) 1885 1884 #define KVM_DIRTY_GFN_F_MASK 0x3 1886 1885 1887 1886 /*
+3
tools/lib/bpf/libbpf.c
··· 3216 3216 const struct btf_var_secinfo *vs; 3217 3217 const struct btf_type *sec; 3218 3218 3219 + if (!btf) 3220 + return 0; 3221 + 3219 3222 sec_btf_id = btf__find_by_name_kind(btf, KSYMS_SEC, 3220 3223 BTF_KIND_DATASEC); 3221 3224 if (sec_btf_id < 0)
+5
tools/lib/bpf/libbpf_internal.h
··· 41 41 #define ELF_C_READ_MMAP ELF_C_READ 42 42 #endif 43 43 44 + /* Older libelf all end up in this expression, for both 32 and 64 bit */ 45 + #ifndef GELF_ST_VISIBILITY 46 + #define GELF_ST_VISIBILITY(o) ((o) & 0x03) 47 + #endif 48 + 44 49 #define BTF_INFO_ENC(kind, kind_flag, vlen) \ 45 50 ((!!(kind_flag) << 31) | ((kind) << 24) | ((vlen) & BTF_MAX_VLEN)) 46 51 #define BTF_TYPE_ENC(name, info, size_or_type) (name), (info), (size_or_type)
+2 -2
tools/perf/perf.c
··· 443 443 const char *cmd; 444 444 char sbuf[STRERR_BUFSIZE]; 445 445 446 + perf_debug_setup(); 447 + 446 448 /* libsubcmd init */ 447 449 exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT); 448 450 pager_init(PERF_PAGER_ENVIRONMENT); ··· 532 530 * forever while the signal goes to some other non interested thread. 533 531 */ 534 532 pthread__block_sigwinch(); 535 - 536 - perf_debug_setup(); 537 533 538 534 while (1) { 539 535 static int done_help;
+21 -11
tools/perf/pmu-events/arch/powerpc/power10/cache.json
··· 1 1 [ 2 2 { 3 - "EventCode": "1003C", 3 + "EventCode": "0x1003C", 4 4 "EventName": "PM_EXEC_STALL_DMISS_L2L3", 5 5 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from either the local L2 or local L3." 6 6 }, 7 7 { 8 - "EventCode": "34056", 9 - "EventName": "PM_EXEC_STALL_LOAD_FINISH", 10 - "BriefDescription": "Cycles in which the oldest instruction in the pipeline was finishing a load after its data was reloaded from a data source beyond the local L1; cycles in which the LSU was processing an L1-hit; cycles in which the NTF instruction merged with another load in the LMQ." 8 + "EventCode": "0x1E054", 9 + "EventName": "PM_EXEC_STALL_DMISS_L21_L31", 10 + "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from another core's L2 or L3 on the same chip." 11 11 }, 12 12 { 13 - "EventCode": "3006C", 13 + "EventCode": "0x34054", 14 + "EventName": "PM_EXEC_STALL_DMISS_L2L3_NOCONFLICT", 15 + "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from the local L2 or local L3, without a dispatch conflict." 16 + }, 17 + { 18 + "EventCode": "0x34056", 19 + "EventName": "PM_EXEC_STALL_LOAD_FINISH", 20 + "BriefDescription": "Cycles in which the oldest instruction in the pipeline was finishing a load after its data was reloaded from a data source beyond the local L1; cycles in which the LSU was processing an L1-hit; cycles in which the NTF instruction merged with another load in the LMQ; cycles in which the NTF instruction is waiting for a data reload for a load miss, but the data comes back with a non-NTF instruction." 21 + }, 22 + { 23 + "EventCode": "0x3006C", 14 24 "EventName": "PM_RUN_CYC_SMT2_MODE", 15 25 "BriefDescription": "Cycles when this thread's run latch is set and the core is in SMT2 mode." 16 26 }, 17 27 { 18 - "EventCode": "300F4", 28 + "EventCode": "0x300F4", 19 29 "EventName": "PM_RUN_INST_CMPL_CONC", 20 30 "BriefDescription": "PowerPC instructions completed by this thread when all threads in the core had the run-latch set." 21 31 }, 22 32 { 23 - "EventCode": "4C016", 33 + "EventCode": "0x4C016", 24 34 "EventName": "PM_EXEC_STALL_DMISS_L2L3_CONFLICT", 25 35 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from the local L2 or local L3, with a dispatch conflict." 26 36 }, 27 37 { 28 - "EventCode": "4D014", 38 + "EventCode": "0x4D014", 29 39 "EventName": "PM_EXEC_STALL_LOAD", 30 40 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a load instruction executing in the Load Store Unit." 31 41 }, 32 42 { 33 - "EventCode": "4D016", 43 + "EventCode": "0x4D016", 34 44 "EventName": "PM_EXEC_STALL_PTESYNC", 35 45 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a PTESYNC instruction executing in the Load Store Unit." 36 46 }, 37 47 { 38 - "EventCode": "401EA", 48 + "EventCode": "0x401EA", 39 49 "EventName": "PM_THRESH_EXC_128", 40 50 "BriefDescription": "Threshold counter exceeded a value of 128." 41 51 }, 42 52 { 43 - "EventCode": "400F6", 53 + "EventCode": "0x400F6", 44 54 "EventName": "PM_BR_MPRED_CMPL", 45 55 "BriefDescription": "A mispredicted branch completed. Includes direction and target." 46 56 }
+1 -1
tools/perf/pmu-events/arch/powerpc/power10/floating_point.json
··· 1 1 [ 2 2 { 3 - "EventCode": "4016E", 3 + "EventCode": "0x4016E", 4 4 "EventName": "PM_THRESH_NOT_MET", 5 5 "BriefDescription": "Threshold counter did not meet threshold." 6 6 }
+77 -47
tools/perf/pmu-events/arch/powerpc/power10/frontend.json
··· 1 1 [ 2 2 { 3 - "EventCode": "10004", 3 + "EventCode": "0x10004", 4 4 "EventName": "PM_EXEC_STALL_TRANSLATION", 5 5 "BriefDescription": "Cycles in which the oldest instruction in the pipeline suffered a TLB miss or ERAT miss and waited for it to resolve." 6 6 }, 7 7 { 8 - "EventCode": "10010", 8 + "EventCode": "0x10006", 9 + "EventName": "PM_DISP_STALL_HELD_OTHER_CYC", 10 + "BriefDescription": "Cycles in which the NTC instruction is held at dispatch for any other reason." 11 + }, 12 + { 13 + "EventCode": "0x10010", 9 14 "EventName": "PM_PMC4_OVERFLOW", 10 15 "BriefDescription": "The event selected for PMC4 caused the event counter to overflow." 11 16 }, 12 17 { 13 - "EventCode": "10020", 18 + "EventCode": "0x10020", 14 19 "EventName": "PM_PMC4_REWIND", 15 20 "BriefDescription": "The speculative event selected for PMC4 rewinds and the counter for PMC4 is not charged." 16 21 }, 17 22 { 18 - "EventCode": "10038", 23 + "EventCode": "0x10038", 19 24 "EventName": "PM_DISP_STALL_TRANSLATION", 20 25 "BriefDescription": "Cycles when dispatch was stalled for this thread because the MMU was handling a translation miss." 21 26 }, 22 27 { 23 - "EventCode": "1003A", 28 + "EventCode": "0x1003A", 24 29 "EventName": "PM_DISP_STALL_BR_MPRED_IC_L2", 25 30 "BriefDescription": "Cycles when dispatch was stalled while the instruction was fetched from the local L2 after suffering a branch mispredict." 26 31 }, 27 32 { 28 - "EventCode": "1E050", 33 + "EventCode": "0x1D05E", 34 + "EventName": "PM_DISP_STALL_HELD_HALT_CYC", 35 + "BriefDescription": "Cycles in which the NTC instruction is held at dispatch because of power management." 36 + }, 37 + { 38 + "EventCode": "0x1E050", 29 39 "EventName": "PM_DISP_STALL_HELD_STF_MAPPER_CYC", 30 40 "BriefDescription": "Cycles in which the NTC instruction is held at dispatch because the STF mapper/SRB was full. Includes GPR (count, link, tar), VSR, VMR, FPR." 31 41 }, 32 42 { 33 - "EventCode": "1F054", 43 + "EventCode": "0x1F054", 34 44 "EventName": "PM_DTLB_HIT", 35 45 "BriefDescription": "The PTE required by the instruction was resident in the TLB (data TLB access). When MMCR1[16]=0 this event counts only demand hits. When MMCR1[16]=1 this event includes demand and prefetch. Applies to both HPT and RPT." 36 46 }, 37 47 { 38 - "EventCode": "101E8", 48 + "EventCode": "0x10064", 49 + "EventName": "PM_DISP_STALL_IC_L2", 50 + "BriefDescription": "Cycles when dispatch was stalled while the instruction was fetched from the local L2." 51 + }, 52 + { 53 + "EventCode": "0x101E8", 39 54 "EventName": "PM_THRESH_EXC_256", 40 55 "BriefDescription": "Threshold counter exceeded a count of 256." 41 56 }, 42 57 { 43 - "EventCode": "101EC", 58 + "EventCode": "0x101EC", 44 59 "EventName": "PM_THRESH_MET", 45 60 "BriefDescription": "Threshold exceeded." 46 61 }, 47 62 { 48 - "EventCode": "100F2", 63 + "EventCode": "0x100F2", 49 64 "EventName": "PM_1PLUS_PPC_CMPL", 50 65 "BriefDescription": "Cycles in which at least one instruction is completed by this thread." 51 66 }, 52 67 { 53 - "EventCode": "100F6", 68 + "EventCode": "0x100F6", 54 69 "EventName": "PM_IERAT_MISS", 55 70 "BriefDescription": "IERAT Reloaded to satisfy an IERAT miss. All page sizes are counted by this event." 56 71 }, 57 72 { 58 - "EventCode": "100F8", 73 + "EventCode": "0x100F8", 59 74 "EventName": "PM_DISP_STALL_CYC", 60 75 "BriefDescription": "Cycles the ICT has no itags assigned to this thread (no instructions were dispatched during these cycles)." 61 76 }, 62 77 { 63 - "EventCode": "20114", 78 + "EventCode": "0x20006", 79 + "EventName": "PM_DISP_STALL_HELD_ISSQ_FULL_CYC", 80 + "BriefDescription": "Cycles in which the NTC instruction is held at dispatch due to Issue queue full. Includes issue queue and branch queue." 81 + }, 82 + { 83 + "EventCode": "0x20114", 64 84 "EventName": "PM_MRK_L2_RC_DISP", 65 85 "BriefDescription": "Marked instruction RC dispatched in L2." 66 86 }, 67 87 { 68 - "EventCode": "2C010", 88 + "EventCode": "0x2C010", 69 89 "EventName": "PM_EXEC_STALL_LSU", 70 90 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was executing in the Load Store Unit. This does not include simple fixed point instructions." 71 91 }, 72 92 { 73 - "EventCode": "2C016", 93 + "EventCode": "0x2C016", 74 94 "EventName": "PM_DISP_STALL_IERAT_ONLY_MISS", 75 95 "BriefDescription": "Cycles when dispatch was stalled while waiting to resolve an instruction ERAT miss." 76 96 }, 77 97 { 78 - "EventCode": "2C01E", 98 + "EventCode": "0x2C01E", 79 99 "EventName": "PM_DISP_STALL_BR_MPRED_IC_L3", 80 100 "BriefDescription": "Cycles when dispatch was stalled while the instruction was fetched from the local L3 after suffering a branch mispredict." 81 101 }, 82 102 { 83 - "EventCode": "2D01A", 103 + "EventCode": "0x2D01A", 84 104 "EventName": "PM_DISP_STALL_IC_MISS", 85 105 "BriefDescription": "Cycles when dispatch was stalled for this thread due to an Icache Miss." 86 106 }, 87 107 { 88 - "EventCode": "2D01C", 89 - "EventName": "PM_CMPL_STALL_STCX", 90 - "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a stcx waiting for resolution from the nest before completing." 91 - }, 92 - { 93 - "EventCode": "2E018", 108 + "EventCode": "0x2E018", 94 109 "EventName": "PM_DISP_STALL_FETCH", 95 110 "BriefDescription": "Cycles when dispatch was stalled for this thread because Fetch was being held." 96 111 }, 97 112 { 98 - "EventCode": "2E01A", 113 + "EventCode": "0x2E01A", 99 114 "EventName": "PM_DISP_STALL_HELD_XVFC_MAPPER_CYC", 100 115 "BriefDescription": "Cycles in which the NTC instruction is held at dispatch because the XVFC mapper/SRB was full." 101 116 }, 102 117 { 103 - "EventCode": "2C142", 118 + "EventCode": "0x2C142", 104 119 "EventName": "PM_MRK_XFER_FROM_SRC_PMC2", 105 120 "BriefDescription": "For a marked data transfer instruction, the processor's L1 data cache was reloaded from the source specified in MMCR3[15:27]. If MMCR1[16|17] is 0 (default), this count includes only lines that were reloaded to satisfy a demand miss. If MMCR1[16|17] is 1, this count includes both demand misses and prefetch reloads." 106 121 }, 107 122 { 108 - "EventCode": "24050", 123 + "EventCode": "0x24050", 109 124 "EventName": "PM_IOPS_DISP", 110 125 "BriefDescription": "Internal Operations dispatched. PM_IOPS_DISP / PM_INST_DISP will show the average number of internal operations per PowerPC instruction." 111 126 }, 112 127 { 113 - "EventCode": "2405E", 128 + "EventCode": "0x2405E", 114 129 "EventName": "PM_ISSUE_CANCEL", 115 130 "BriefDescription": "An instruction issued and the issue was later cancelled. Only one cancel per PowerPC instruction." 116 131 }, 117 132 { 118 - "EventCode": "200FA", 133 + "EventCode": "0x200FA", 119 134 "EventName": "PM_BR_TAKEN_CMPL", 120 135 "BriefDescription": "Branch Taken instruction completed." 121 136 }, 122 137 { 123 - "EventCode": "30012", 138 + "EventCode": "0x30004", 139 + "EventName": "PM_DISP_STALL_FLUSH", 140 + "BriefDescription": "Cycles when dispatch was stalled because of a flush that happened to an instruction(s) that was not yet NTC. PM_EXEC_STALL_NTC_FLUSH only includes instructions that were flushed after becoming NTC." 141 + }, 142 + { 143 + "EventCode": "0x3000A", 144 + "EventName": "PM_DISP_STALL_ITLB_MISS", 145 + "BriefDescription": "Cycles when dispatch was stalled while waiting to resolve an instruction TLB miss." 146 + }, 147 + { 148 + "EventCode": "0x30012", 124 149 "EventName": "PM_FLUSH_COMPLETION", 125 150 "BriefDescription": "The instruction that was next to complete (oldest in the pipeline) did not complete because it suffered a flush." 126 151 }, 127 152 { 128 - "EventCode": "30014", 153 + "EventCode": "0x30014", 129 154 "EventName": "PM_EXEC_STALL_STORE", 130 155 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a store instruction executing in the Load Store Unit." 131 156 }, 132 157 { 133 - "EventCode": "30018", 158 + "EventCode": "0x30018", 134 159 "EventName": "PM_DISP_STALL_HELD_SCOREBOARD_CYC", 135 160 "BriefDescription": "Cycles in which the NTC instruction is held at dispatch while waiting on the Scoreboard. This event combines VSCR and FPSCR together." 136 161 }, 137 162 { 138 - "EventCode": "30026", 163 + "EventCode": "0x30026", 139 164 "EventName": "PM_EXEC_STALL_STORE_MISS", 140 165 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a store whose cache line was not resident in the L1 and was waiting for allocation of the missing line into the L1." 141 166 }, 142 167 { 143 - "EventCode": "3012A", 168 + "EventCode": "0x3012A", 144 169 "EventName": "PM_MRK_L2_RC_DONE", 145 170 "BriefDescription": "L2 RC machine completed the transaction for the marked instruction." 146 171 }, 147 172 { 148 - "EventCode": "3F046", 173 + "EventCode": "0x3F046", 149 174 "EventName": "PM_ITLB_HIT_1G", 150 175 "BriefDescription": "Instruction TLB hit (IERAT reload) page size 1G, which implies Radix Page Table translation is in use. When MMCR1[17]=0 this event counts only for demand misses. When MMCR1[17]=1 this event includes demand misses and prefetches." 151 176 }, 152 177 { 153 - "EventCode": "34058", 178 + "EventCode": "0x34058", 154 179 "EventName": "PM_DISP_STALL_BR_MPRED_ICMISS", 155 180 "BriefDescription": "Cycles when dispatch was stalled after a mispredicted branch resulted in an instruction cache miss." 156 181 }, 157 182 { 158 - "EventCode": "3D05C", 183 + "EventCode": "0x3D05C", 159 184 "EventName": "PM_DISP_STALL_HELD_RENAME_CYC", 160 185 "BriefDescription": "Cycles in which the NTC instruction is held at dispatch because the mapper/SRB was full. Includes GPR (count, link, tar), VSR, VMR, FPR and XVFC." 161 186 }, 162 187 { 163 - "EventCode": "3E052", 188 + "EventCode": "0x3E052", 164 189 "EventName": "PM_DISP_STALL_IC_L3", 165 190 "BriefDescription": "Cycles when dispatch was stalled while the instruction was fetched from the local L3." 166 191 }, 167 192 { 168 - "EventCode": "3E054", 193 + "EventCode": "0x3E054", 169 194 "EventName": "PM_LD_MISS_L1", 170 195 "BriefDescription": "Load Missed L1, counted at execution time (can be greater than loads finished). LMQ merges are not included in this count. i.e. if a load instruction misses on an address that is already allocated on the LMQ, this event will not increment for that load). Note that this count is per slice, so if a load spans multiple slices this event will increment multiple times for a single load." 171 196 }, 172 197 { 173 - "EventCode": "301EA", 198 + "EventCode": "0x301EA", 174 199 "EventName": "PM_THRESH_EXC_1024", 175 200 "BriefDescription": "Threshold counter exceeded a value of 1024." 176 201 }, 177 202 { 178 - "EventCode": "300FA", 203 + "EventCode": "0x300FA", 179 204 "EventName": "PM_INST_FROM_L3MISS", 180 205 "BriefDescription": "The processor's instruction cache was reloaded from a source other than the local core's L1, L2, or L3 due to a demand miss." 181 206 }, 182 207 { 183 - "EventCode": "40006", 208 + "EventCode": "0x40006", 184 209 "EventName": "PM_ISSUE_KILL", 185 210 "BriefDescription": "Cycles in which an instruction or group of instructions were cancelled after being issued. This event increments once per occurrence, regardless of how many instructions are included in the issue group." 186 211 }, 187 212 { 188 - "EventCode": "40116", 213 + "EventCode": "0x40116", 189 214 "EventName": "PM_MRK_LARX_FIN", 190 215 "BriefDescription": "Marked load and reserve instruction (LARX) finished. LARX and STCX are instructions used to acquire a lock." 191 216 }, 192 217 { 193 - "EventCode": "4C010", 218 + "EventCode": "0x4C010", 194 219 "EventName": "PM_DISP_STALL_BR_MPRED_IC_L3MISS", 195 220 "BriefDescription": "Cycles when dispatch was stalled while the instruction was fetched from sources beyond the local L3 after suffering a mispredicted branch." 196 221 }, 197 222 { 198 - "EventCode": "4D01E", 223 + "EventCode": "0x4D01E", 199 224 "EventName": "PM_DISP_STALL_BR_MPRED", 200 225 "BriefDescription": "Cycles when dispatch was stalled for this thread due to a mispredicted branch." 201 226 }, 202 227 { 203 - "EventCode": "4E010", 228 + "EventCode": "0x4E010", 204 229 "EventName": "PM_DISP_STALL_IC_L3MISS", 205 230 "BriefDescription": "Cycles when dispatch was stalled while the instruction was fetched from any source beyond the local L3." 206 231 }, 207 232 { 208 - "EventCode": "4E01A", 233 + "EventCode": "0x4E01A", 209 234 "EventName": "PM_DISP_STALL_HELD_CYC", 210 235 "BriefDescription": "Cycles in which the NTC instruction is held at dispatch for any reason." 211 236 }, 212 237 { 213 - "EventCode": "44056", 238 + "EventCode": "0x4003C", 239 + "EventName": "PM_DISP_STALL_HELD_SYNC_CYC", 240 + "BriefDescription": "Cycles in which the NTC instruction is held at dispatch because of a synchronizing instruction that requires the ICT to be empty before dispatch." 241 + }, 242 + { 243 + "EventCode": "0x44056", 214 244 "EventName": "PM_VECTOR_ST_CMPL", 215 245 "BriefDescription": "Vector store instructions completed." 216 246 }
+2 -2
tools/perf/pmu-events/arch/powerpc/power10/locks.json
··· 1 1 [ 2 2 { 3 - "EventCode": "1E058", 3 + "EventCode": "0x1E058", 4 4 "EventName": "PM_STCX_FAIL_FIN", 5 5 "BriefDescription": "Conditional store instruction (STCX) failed. LARX and STCX are instructions used to acquire a lock." 6 6 }, 7 7 { 8 - "EventCode": "4E050", 8 + "EventCode": "0x4E050", 9 9 "EventName": "PM_STCX_PASS_FIN", 10 10 "BriefDescription": "Conditional store instruction (STCX) passed. LARX and STCX are instructions used to acquire a lock." 11 11 }
+28 -33
tools/perf/pmu-events/arch/powerpc/power10/marked.json
··· 1 1 [ 2 2 { 3 - "EventCode": "1002C", 3 + "EventCode": "0x1002C", 4 4 "EventName": "PM_LD_PREFETCH_CACHE_LINE_MISS", 5 5 "BriefDescription": "The L1 cache was reloaded with a line that fulfills a prefetch request." 6 6 }, 7 7 { 8 - "EventCode": "10132", 8 + "EventCode": "0x10132", 9 9 "EventName": "PM_MRK_INST_ISSUED", 10 10 "BriefDescription": "Marked instruction issued. Note that stores always get issued twice, the address gets issued to the LSU and the data gets issued to the VSU. Also, issues can sometimes get killed/cancelled and cause multiple sequential issues for the same instruction." 11 11 }, 12 12 { 13 - "EventCode": "101E0", 13 + "EventCode": "0x101E0", 14 14 "EventName": "PM_MRK_INST_DISP", 15 15 "BriefDescription": "The thread has dispatched a randomly sampled marked instruction." 16 16 }, 17 17 { 18 - "EventCode": "101E2", 18 + "EventCode": "0x101E2", 19 19 "EventName": "PM_MRK_BR_TAKEN_CMPL", 20 20 "BriefDescription": "Marked Branch Taken instruction completed." 21 21 }, 22 22 { 23 - "EventCode": "20112", 23 + "EventCode": "0x20112", 24 24 "EventName": "PM_MRK_NTF_FIN", 25 25 "BriefDescription": "The marked instruction became the oldest in the pipeline before it finished. It excludes instructions that finish at dispatch." 26 26 }, 27 27 { 28 - "EventCode": "2C01C", 28 + "EventCode": "0x2C01C", 29 29 "EventName": "PM_EXEC_STALL_DMISS_OFF_CHIP", 30 30 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from a remote chip." 31 31 }, 32 32 { 33 - "EventCode": "20138", 33 + "EventCode": "0x20138", 34 34 "EventName": "PM_MRK_ST_NEST", 35 35 "BriefDescription": "A store has been sampled/marked and is at the point of execution where it has completed in the core and can no longer be flushed. At this point the store is sent to the L2." 36 36 }, 37 37 { 38 - "EventCode": "2013A", 38 + "EventCode": "0x2013A", 39 39 "EventName": "PM_MRK_BRU_FIN", 40 40 "BriefDescription": "Marked Branch instruction finished." 41 41 }, 42 42 { 43 - "EventCode": "2C144", 43 + "EventCode": "0x2C144", 44 44 "EventName": "PM_MRK_XFER_FROM_SRC_CYC_PMC2", 45 45 "BriefDescription": "Cycles taken for a marked demand miss to reload a line from the source specified in MMCR3[15:27]." 46 46 }, 47 47 { 48 - "EventCode": "24156", 48 + "EventCode": "0x24156", 49 49 "EventName": "PM_MRK_STCX_FIN", 50 50 "BriefDescription": "Marked conditional store instruction (STCX) finished. LARX and STCX are instructions used to acquire a lock." 51 51 }, 52 52 { 53 - "EventCode": "24158", 53 + "EventCode": "0x24158", 54 54 "EventName": "PM_MRK_INST", 55 55 "BriefDescription": "An instruction was marked. Includes both Random Instruction Sampling (RIS) at decode time and Random Event Sampling (RES) at the time the configured event happens." 56 56 }, 57 57 { 58 - "EventCode": "2415C", 58 + "EventCode": "0x2415C", 59 59 "EventName": "PM_MRK_BR_CMPL", 60 60 "BriefDescription": "A marked branch completed. All branches are included." 61 61 }, 62 62 { 63 - "EventCode": "200FD", 63 + "EventCode": "0x200FD", 64 64 "EventName": "PM_L1_ICACHE_MISS", 65 65 "BriefDescription": "Demand iCache Miss." 66 66 }, 67 67 { 68 - "EventCode": "30130", 68 + "EventCode": "0x30130", 69 69 "EventName": "PM_MRK_INST_FIN", 70 70 "BriefDescription": "marked instruction finished. Excludes instructions that finish at dispatch. Note that stores always finish twice since the address gets issued to the LSU and the data gets issued to the VSU." 71 71 }, 72 72 { 73 - "EventCode": "34146", 73 + "EventCode": "0x34146", 74 74 "EventName": "PM_MRK_LD_CMPL", 75 75 "BriefDescription": "Marked loads completed." 76 76 }, 77 77 { 78 - "EventCode": "3E158", 78 + "EventCode": "0x3E158", 79 79 "EventName": "PM_MRK_STCX_FAIL", 80 80 "BriefDescription": "Marked conditional store instruction (STCX) failed. LARX and STCX are instructions used to acquire a lock." 81 81 }, 82 82 { 83 - "EventCode": "3E15A", 83 + "EventCode": "0x3E15A", 84 84 "EventName": "PM_MRK_ST_FIN", 85 85 "BriefDescription": "The marked instruction was a store of any kind." 86 86 }, 87 87 { 88 - "EventCode": "30068", 88 + "EventCode": "0x30068", 89 89 "EventName": "PM_L1_ICACHE_RELOADED_PREF", 90 90 "BriefDescription": "Counts all Icache prefetch reloads ( includes demand turned into prefetch)." 91 91 }, 92 92 { 93 - "EventCode": "301E4", 93 + "EventCode": "0x301E4", 94 94 "EventName": "PM_MRK_BR_MPRED_CMPL", 95 95 "BriefDescription": "Marked Branch Mispredicted. Includes direction and target." 96 96 }, 97 97 { 98 - "EventCode": "300F6", 98 + "EventCode": "0x300F6", 99 99 "EventName": "PM_LD_DEMAND_MISS_L1", 100 100 "BriefDescription": "The L1 cache was reloaded with a line that fulfills a demand miss request. Counted at reload time, before finish." 101 101 }, 102 102 { 103 - "EventCode": "300FE", 103 + "EventCode": "0x300FE", 104 104 "EventName": "PM_DATA_FROM_L3MISS", 105 105 "BriefDescription": "The processor's data cache was reloaded from a source other than the local core's L1, L2, or L3 due to a demand miss." 106 106 }, 107 107 { 108 - "EventCode": "40012", 108 + "EventCode": "0x40012", 109 109 "EventName": "PM_L1_ICACHE_RELOADED_ALL", 110 110 "BriefDescription": "Counts all Icache reloads includes demand, prefetch, prefetch turned into demand and demand turned into prefetch." 111 111 }, 112 112 { 113 - "EventCode": "40134", 113 + "EventCode": "0x40134", 114 114 "EventName": "PM_MRK_INST_TIMEO", 115 115 "BriefDescription": "Marked instruction finish timeout (instruction was lost)." 116 116 }, 117 117 { 118 - "EventCode": "4003C", 119 - "EventName": "PM_DISP_STALL_HELD_SYNC_CYC", 120 - "BriefDescription": "Cycles in which the NTC instruction is held at dispatch because of a synchronizing instruction that requires the ICT to be empty before dispatch." 121 - }, 122 - { 123 - "EventCode": "4505A", 118 + "EventCode": "0x4505A", 124 119 "EventName": "PM_SP_FLOP_CMPL", 125 120 "BriefDescription": "Single Precision floating point instructions completed." 126 121 }, 127 122 { 128 - "EventCode": "4D058", 123 + "EventCode": "0x4D058", 129 124 "EventName": "PM_VECTOR_FLOP_CMPL", 130 125 "BriefDescription": "Vector floating point instructions completed." 131 126 }, 132 127 { 133 - "EventCode": "4D05A", 128 + "EventCode": "0x4D05A", 134 129 "EventName": "PM_NON_MATH_FLOP_CMPL", 135 130 "BriefDescription": "Non Math instructions completed." 136 131 }, 137 132 { 138 - "EventCode": "401E0", 133 + "EventCode": "0x401E0", 139 134 "EventName": "PM_MRK_INST_CMPL", 140 135 "BriefDescription": "marked instruction completed." 141 136 }, 142 137 { 143 - "EventCode": "400FE", 138 + "EventCode": "0x400FE", 144 139 "EventName": "PM_DATA_FROM_MEMORY", 145 140 "BriefDescription": "The processor's data cache was reloaded from local, remote, or distant memory due to a demand miss." 146 141 }
+37 -42
tools/perf/pmu-events/arch/powerpc/power10/memory.json
··· 1 1 [ 2 2 { 3 - "EventCode": "1000A", 3 + "EventCode": "0x1000A", 4 4 "EventName": "PM_PMC3_REWIND", 5 5 "BriefDescription": "The speculative event selected for PMC3 rewinds and the counter for PMC3 is not charged." 6 6 }, 7 7 { 8 - "EventCode": "1C040", 8 + "EventCode": "0x1C040", 9 9 "EventName": "PM_XFER_FROM_SRC_PMC1", 10 10 "BriefDescription": "The processor's L1 data cache was reloaded from the source specified in MMCR3[0:12]. If MMCR1[16|17] is 0 (default), this count includes only lines that were reloaded to satisfy a demand miss. If MMCR1[16|17] is 1, this count includes both demand misses and prefetch reloads." 11 11 }, 12 12 { 13 - "EventCode": "1C142", 13 + "EventCode": "0x1C142", 14 14 "EventName": "PM_MRK_XFER_FROM_SRC_PMC1", 15 15 "BriefDescription": "For a marked data transfer instruction, the processor's L1 data cache was reloaded from the source specified in MMCR3[0:12]. If MMCR1[16|17] is 0 (default), this count includes only lines that were reloaded to satisfy a demand miss. If MMCR1[16|17] is 1, this count includes both demand misses and prefetch reloads." 16 16 }, 17 17 { 18 - "EventCode": "1C144", 18 + "EventCode": "0x1C144", 19 19 "EventName": "PM_MRK_XFER_FROM_SRC_CYC_PMC1", 20 20 "BriefDescription": "Cycles taken for a marked demand miss to reload a line from the source specified in MMCR3[0:12]." 21 21 }, 22 22 { 23 - "EventCode": "1C056", 23 + "EventCode": "0x1C056", 24 24 "EventName": "PM_DERAT_MISS_4K", 25 25 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 4K. When MMCR1[16]=0 this event counts only DERAT reloads for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 26 26 }, 27 27 { 28 - "EventCode": "1C058", 28 + "EventCode": "0x1C058", 29 29 "EventName": "PM_DTLB_MISS_16G", 30 30 "BriefDescription": "Data TLB reload (after a miss) page size 16G. When MMCR1[16]=0 this event counts only for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 31 31 }, 32 32 { 33 - "EventCode": "1C05C", 33 + "EventCode": "0x1C05C", 34 34 "EventName": "PM_DTLB_MISS_2M", 35 35 "BriefDescription": "Data TLB reload (after a miss) page size 2M. Implies radix translation was used. When MMCR1[16]=0 this event counts only for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 36 36 }, 37 37 { 38 - "EventCode": "1E056", 38 + "EventCode": "0x1E056", 39 39 "EventName": "PM_EXEC_STALL_STORE_PIPE", 40 40 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was executing in the store unit. This does not include cycles spent handling store misses, PTESYNC instructions or TLBIE instructions." 41 41 }, 42 42 { 43 - "EventCode": "1F150", 43 + "EventCode": "0x1F150", 44 44 "EventName": "PM_MRK_ST_L2_CYC", 45 45 "BriefDescription": "Cycles from L2 RC dispatch to L2 RC completion." 46 46 }, 47 47 { 48 - "EventCode": "10062", 48 + "EventCode": "0x10062", 49 49 "EventName": "PM_LD_L3MISS_PEND_CYC", 50 50 "BriefDescription": "Cycles L3 miss was pending for this thread." 51 51 }, 52 52 { 53 - "EventCode": "20010", 53 + "EventCode": "0x20010", 54 54 "EventName": "PM_PMC1_OVERFLOW", 55 55 "BriefDescription": "The event selected for PMC1 caused the event counter to overflow." 56 56 }, 57 57 { 58 - "EventCode": "2001A", 58 + "EventCode": "0x2001A", 59 59 "EventName": "PM_ITLB_HIT", 60 60 "BriefDescription": "The PTE required to translate the instruction address was resident in the TLB (instruction TLB access/IERAT reload). Applies to both HPT and RPT. When MMCR1[17]=0 this event counts only for demand misses. When MMCR1[17]=1 this event includes demand misses and prefetches." 61 61 }, 62 62 { 63 - "EventCode": "2003E", 63 + "EventCode": "0x2003E", 64 64 "EventName": "PM_PTESYNC_FIN", 65 65 "BriefDescription": "Ptesync instruction finished in the store unit. Only one ptesync can finish at a time." 66 66 }, 67 67 { 68 - "EventCode": "2C040", 68 + "EventCode": "0x2C040", 69 69 "EventName": "PM_XFER_FROM_SRC_PMC2", 70 70 "BriefDescription": "The processor's L1 data cache was reloaded from the source specified in MMCR3[15:27]. If MMCR1[16|17] is 0 (default), this count includes only lines that were reloaded to satisfy a demand miss. If MMCR1[16|17] is 1, this count includes both demand misses and prefetch reloads." 71 71 }, 72 72 { 73 - "EventCode": "2C054", 73 + "EventCode": "0x2C054", 74 74 "EventName": "PM_DERAT_MISS_64K", 75 75 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 64K. When MMCR1[16]=0 this event counts only DERAT reloads for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 76 76 }, 77 77 { 78 - "EventCode": "2C056", 78 + "EventCode": "0x2C056", 79 79 "EventName": "PM_DTLB_MISS_4K", 80 80 "BriefDescription": "Data TLB reload (after a miss) page size 4K. When MMCR1[16]=0 this event counts only for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 81 81 }, 82 82 { 83 - "EventCode": "2D154", 83 + "EventCode": "0x2D154", 84 84 "EventName": "PM_MRK_DERAT_MISS_64K", 85 85 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 64K for a marked instruction. When MMCR1[16]=0 this event counts only DERAT reloads for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 86 86 }, 87 87 { 88 - "EventCode": "200F6", 88 + "EventCode": "0x200F6", 89 89 "EventName": "PM_DERAT_MISS", 90 90 "BriefDescription": "DERAT Reloaded to satisfy a DERAT miss. All page sizes are counted by this event. When MMCR1[16]=0 this event counts only DERAT reloads for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 91 91 }, 92 92 { 93 - "EventCode": "3000A", 94 - "EventName": "PM_DISP_STALL_ITLB_MISS", 95 - "BriefDescription": "Cycles when dispatch was stalled while waiting to resolve an instruction TLB miss." 96 - }, 97 - { 98 - "EventCode": "30016", 93 + "EventCode": "0x30016", 99 94 "EventName": "PM_EXEC_STALL_DERAT_DTLB_MISS", 100 95 "BriefDescription": "Cycles in which the oldest instruction in the pipeline suffered a TLB miss and waited for it resolve." 101 96 }, 102 97 { 103 - "EventCode": "3C040", 98 + "EventCode": "0x3C040", 104 99 "EventName": "PM_XFER_FROM_SRC_PMC3", 105 100 "BriefDescription": "The processor's L1 data cache was reloaded from the source specified in MMCR3[30:42]. If MMCR1[16|17] is 0 (default), this count includes only lines that were reloaded to satisfy a demand miss. If MMCR1[16|17] is 1, this count includes both demand misses and prefetch reloads." 106 101 }, 107 102 { 108 - "EventCode": "3C142", 103 + "EventCode": "0x3C142", 109 104 "EventName": "PM_MRK_XFER_FROM_SRC_PMC3", 110 105 "BriefDescription": "For a marked data transfer instruction, the processor's L1 data cache was reloaded from the source specified in MMCR3[30:42]. If MMCR1[16|17] is 0 (default), this count includes only lines that were reloaded to satisfy a demand miss. If MMCR1[16|17] is 1, this count includes both demand misses and prefetch reloads." 111 106 }, 112 107 { 113 - "EventCode": "3C144", 108 + "EventCode": "0x3C144", 114 109 "EventName": "PM_MRK_XFER_FROM_SRC_CYC_PMC3", 115 110 "BriefDescription": "Cycles taken for a marked demand miss to reload a line from the source specified in MMCR3[30:42]." 116 111 }, 117 112 { 118 - "EventCode": "3C054", 113 + "EventCode": "0x3C054", 119 114 "EventName": "PM_DERAT_MISS_16M", 120 115 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 16M. When MMCR1[16]=0 this event counts only DERAT reloads for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 121 116 }, 122 117 { 123 - "EventCode": "3C056", 118 + "EventCode": "0x3C056", 124 119 "EventName": "PM_DTLB_MISS_64K", 125 120 "BriefDescription": "Data TLB reload (after a miss) page size 64K. When MMCR1[16]=0 this event counts only for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 126 121 }, 127 122 { 128 - "EventCode": "3C058", 123 + "EventCode": "0x3C058", 129 124 "EventName": "PM_LARX_FIN", 130 125 "BriefDescription": "Load and reserve instruction (LARX) finished. LARX and STCX are instructions used to acquire a lock." 131 126 }, 132 127 { 133 - "EventCode": "301E2", 128 + "EventCode": "0x301E2", 134 129 "EventName": "PM_MRK_ST_CMPL", 135 130 "BriefDescription": "Marked store completed and sent to nest. Note that this count excludes cache-inhibited stores." 136 131 }, 137 132 { 138 - "EventCode": "300FC", 133 + "EventCode": "0x300FC", 139 134 "EventName": "PM_DTLB_MISS", 140 135 "BriefDescription": "The DPTEG required for the load/store instruction in execution was missing from the TLB. It includes pages of all sizes for demand and prefetch activity." 141 136 }, 142 137 { 143 - "EventCode": "4D02C", 138 + "EventCode": "0x4D02C", 144 139 "EventName": "PM_PMC1_REWIND", 145 140 "BriefDescription": "The speculative event selected for PMC1 rewinds and the counter for PMC1 is not charged." 146 141 }, 147 142 { 148 - "EventCode": "4003E", 143 + "EventCode": "0x4003E", 149 144 "EventName": "PM_LD_CMPL", 150 145 "BriefDescription": "Loads completed." 151 146 }, 152 147 { 153 - "EventCode": "4C040", 148 + "EventCode": "0x4C040", 154 149 "EventName": "PM_XFER_FROM_SRC_PMC4", 155 150 "BriefDescription": "The processor's L1 data cache was reloaded from the source specified in MMCR3[45:57]. If MMCR1[16|17] is 0 (default), this count includes only lines that were reloaded to satisfy a demand miss. If MMCR1[16|17] is 1, this count includes both demand misses and prefetch reloads." 156 151 }, 157 152 { 158 - "EventCode": "4C142", 153 + "EventCode": "0x4C142", 159 154 "EventName": "PM_MRK_XFER_FROM_SRC_PMC4", 160 155 "BriefDescription": "For a marked data transfer instruction, the processor's L1 data cache was reloaded from the source specified in MMCR3[45:57]. If MMCR1[16|17] is 0 (default), this count includes only lines that were reloaded to satisfy a demand miss. If MMCR1[16|17] is 1, this count includes both demand misses and prefetch reloads." 161 156 }, 162 157 { 163 - "EventCode": "4C144", 158 + "EventCode": "0x4C144", 164 159 "EventName": "PM_MRK_XFER_FROM_SRC_CYC_PMC4", 165 160 "BriefDescription": "Cycles taken for a marked demand miss to reload a line from the source specified in MMCR3[45:57]." 166 161 }, 167 162 { 168 - "EventCode": "4C056", 163 + "EventCode": "0x4C056", 169 164 "EventName": "PM_DTLB_MISS_16M", 170 165 "BriefDescription": "Data TLB reload (after a miss) page size 16M. When MMCR1[16]=0 this event counts only for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 171 166 }, 172 167 { 173 - "EventCode": "4C05A", 168 + "EventCode": "0x4C05A", 174 169 "EventName": "PM_DTLB_MISS_1G", 175 170 "BriefDescription": "Data TLB reload (after a miss) page size 1G. Implies radix translation was used. When MMCR1[16]=0 this event counts only for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 176 171 }, 177 172 { 178 - "EventCode": "4C15E", 173 + "EventCode": "0x4C15E", 179 174 "EventName": "PM_MRK_DTLB_MISS_64K", 180 175 "BriefDescription": "Marked Data TLB reload (after a miss) page size 64K. When MMCR1[16]=0 this event counts only for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 181 176 }, 182 177 { 183 - "EventCode": "4D056", 178 + "EventCode": "0x4D056", 184 179 "EventName": "PM_NON_FMA_FLOP_CMPL", 185 180 "BriefDescription": "Non FMA instruction completed." 186 181 }, 187 182 { 188 - "EventCode": "40164", 183 + "EventCode": "0x40164", 189 184 "EventName": "PM_MRK_DERAT_MISS_2M", 190 185 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 2M for a marked instruction. When MMCR1[16]=0 this event counts only DERAT reloads for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 191 186 }
+54 -79
tools/perf/pmu-events/arch/powerpc/power10/others.json
··· 1 1 [ 2 2 { 3 - "EventCode": "10016", 3 + "EventCode": "0x10016", 4 4 "EventName": "PM_VSU0_ISSUE", 5 5 "BriefDescription": "VSU instructions issued to VSU pipe 0." 6 6 }, 7 7 { 8 - "EventCode": "1001C", 8 + "EventCode": "0x1001C", 9 9 "EventName": "PM_ULTRAVISOR_INST_CMPL", 10 10 "BriefDescription": "PowerPC instructions that completed while the thread was in ultravisor state." 11 11 }, 12 12 { 13 - "EventCode": "100F0", 13 + "EventCode": "0x100F0", 14 14 "EventName": "PM_CYC", 15 15 "BriefDescription": "Processor cycles." 16 16 }, 17 17 { 18 - "EventCode": "10134", 18 + "EventCode": "0x10134", 19 19 "EventName": "PM_MRK_ST_DONE_L2", 20 20 "BriefDescription": "Marked stores completed in L2 (RC machine done)." 21 21 }, 22 22 { 23 - "EventCode": "1505E", 23 + "EventCode": "0x1505E", 24 24 "EventName": "PM_LD_HIT_L1", 25 25 "BriefDescription": "Loads that finished without experiencing an L1 miss." 26 26 }, 27 27 { 28 - "EventCode": "1D05E", 29 - "EventName": "PM_DISP_STALL_HELD_HALT_CYC", 30 - "BriefDescription": "Cycles in which the NTC instruction is held at dispatch because of power management." 31 - }, 32 - { 33 - "EventCode": "1E054", 34 - "EventName": "PM_EXEC_STALL_DMISS_L21_L31", 35 - "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from another core's L2 or L3 on the same chip." 36 - }, 37 - { 38 - "EventCode": "1E05A", 39 - "EventName": "PM_CMPL_STALL_LWSYNC", 40 - "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a lwsync waiting to complete." 41 - }, 42 - { 43 - "EventCode": "1F056", 28 + "EventCode": "0x1F056", 44 29 "EventName": "PM_DISP_SS0_2_INSTR_CYC", 45 30 "BriefDescription": "Cycles in which Superslice 0 dispatches either 1 or 2 instructions." 46 31 }, 47 32 { 48 - "EventCode": "1F15C", 33 + "EventCode": "0x1F15C", 49 34 "EventName": "PM_MRK_STCX_L2_CYC", 50 35 "BriefDescription": "Cycles spent in the nest portion of a marked Stcx instruction. It starts counting when the operation starts to drain to the L2 and it stops counting when the instruction retires from the Instruction Completion Table (ICT) in the Instruction Sequencing Unit (ISU)." 51 36 }, 52 37 { 53 - "EventCode": "10066", 38 + "EventCode": "0x10066", 54 39 "EventName": "PM_ADJUNCT_CYC", 55 40 "BriefDescription": "Cycles in which the thread is in Adjunct state. MSR[S HV PR] bits = 011." 56 41 }, 57 42 { 58 - "EventCode": "101E4", 43 + "EventCode": "0x101E4", 59 44 "EventName": "PM_MRK_L1_ICACHE_MISS", 60 45 "BriefDescription": "Marked Instruction suffered an icache Miss." 61 46 }, 62 47 { 63 - "EventCode": "101EA", 48 + "EventCode": "0x101EA", 64 49 "EventName": "PM_MRK_L1_RELOAD_VALID", 65 50 "BriefDescription": "Marked demand reload." 66 51 }, 67 52 { 68 - "EventCode": "100F4", 53 + "EventCode": "0x100F4", 69 54 "EventName": "PM_FLOP_CMPL", 70 55 "BriefDescription": "Floating Point Operations Completed. Includes any type. It counts once for each 1, 2, 4 or 8 flop instruction. Use PM_1|2|4|8_FLOP_CMPL events to count flops." 71 56 }, 72 57 { 73 - "EventCode": "100FA", 58 + "EventCode": "0x100FA", 74 59 "EventName": "PM_RUN_LATCH_ANY_THREAD_CYC", 75 60 "BriefDescription": "Cycles when at least one thread has the run latch set." 76 61 }, 77 62 { 78 - "EventCode": "100FC", 63 + "EventCode": "0x100FC", 79 64 "EventName": "PM_LD_REF_L1", 80 65 "BriefDescription": "All L1 D cache load references counted at finish, gated by reject. In P9 and earlier this event counted only cacheable loads but in P10 both cacheable and non-cacheable loads are included." 81 66 }, 82 67 { 83 - "EventCode": "20006", 84 - "EventName": "PM_DISP_STALL_HELD_ISSQ_FULL_CYC", 85 - "BriefDescription": "Cycles in which the NTC instruction is held at dispatch due to Issue queue full. Includes issue queue and branch queue." 86 - }, 87 - { 88 - "EventCode": "2000C", 68 + "EventCode": "0x2000C", 89 69 "EventName": "PM_RUN_LATCH_ALL_THREADS_CYC", 90 70 "BriefDescription": "Cycles when the run latch is set for all threads." 91 71 }, 92 72 { 93 - "EventCode": "2E010", 73 + "EventCode": "0x2E010", 94 74 "EventName": "PM_ADJUNCT_INST_CMPL", 95 75 "BriefDescription": "PowerPC instructions that completed while the thread is in Adjunct state." 96 76 }, 97 77 { 98 - "EventCode": "2E014", 78 + "EventCode": "0x2E014", 99 79 "EventName": "PM_STCX_FIN", 100 80 "BriefDescription": "Conditional store instruction (STCX) finished. LARX and STCX are instructions used to acquire a lock." 101 81 }, 102 82 { 103 - "EventCode": "20130", 83 + "EventCode": "0x20130", 104 84 "EventName": "PM_MRK_INST_DECODED", 105 85 "BriefDescription": "An instruction was marked at decode time. Random Instruction Sampling (RIS) only." 106 86 }, 107 87 { 108 - "EventCode": "20132", 88 + "EventCode": "0x20132", 109 89 "EventName": "PM_MRK_DFU_ISSUE", 110 90 "BriefDescription": "The marked instruction was a decimal floating point operation issued to the VSU. Measured at issue time." 111 91 }, 112 92 { 113 - "EventCode": "20134", 93 + "EventCode": "0x20134", 114 94 "EventName": "PM_MRK_FXU_ISSUE", 115 95 "BriefDescription": "The marked instruction was a fixed point operation issued to the VSU. Measured at issue time." 116 96 }, 117 97 { 118 - "EventCode": "2505C", 98 + "EventCode": "0x2505C", 119 99 "EventName": "PM_VSU_ISSUE", 120 100 "BriefDescription": "At least one VSU instruction was issued to one of the VSU pipes. Up to 4 per cycle. Includes fixed point operations." 121 101 }, 122 102 { 123 - "EventCode": "2F054", 103 + "EventCode": "0x2F054", 124 104 "EventName": "PM_DISP_SS1_2_INSTR_CYC", 125 105 "BriefDescription": "Cycles in which Superslice 1 dispatches either 1 or 2 instructions." 126 106 }, 127 107 { 128 - "EventCode": "2F056", 108 + "EventCode": "0x2F056", 129 109 "EventName": "PM_DISP_SS1_4_INSTR_CYC", 130 110 "BriefDescription": "Cycles in which Superslice 1 dispatches either 3 or 4 instructions." 131 111 }, 132 112 { 133 - "EventCode": "2006C", 113 + "EventCode": "0x2006C", 134 114 "EventName": "PM_RUN_CYC_SMT4_MODE", 135 115 "BriefDescription": "Cycles when this thread's run latch is set and the core is in SMT4 mode." 136 116 }, 137 117 { 138 - "EventCode": "201E0", 118 + "EventCode": "0x201E0", 139 119 "EventName": "PM_MRK_DATA_FROM_MEMORY", 140 120 "BriefDescription": "The processor's data cache was reloaded from local, remote, or distant memory due to a demand miss for a marked load." 141 121 }, 142 122 { 143 - "EventCode": "201E4", 123 + "EventCode": "0x201E4", 144 124 "EventName": "PM_MRK_DATA_FROM_L3MISS", 145 125 "BriefDescription": "The processor's data cache was reloaded from a source other than the local core's L1, L2, or L3 due to a demand miss for a marked load." 146 126 }, 147 127 { 148 - "EventCode": "201E8", 128 + "EventCode": "0x201E8", 149 129 "EventName": "PM_THRESH_EXC_512", 150 130 "BriefDescription": "Threshold counter exceeded a value of 512." 151 131 }, 152 132 { 153 - "EventCode": "200F2", 133 + "EventCode": "0x200F2", 154 134 "EventName": "PM_INST_DISP", 155 135 "BriefDescription": "PowerPC instructions dispatched." 156 136 }, 157 137 { 158 - "EventCode": "30132", 138 + "EventCode": "0x30132", 159 139 "EventName": "PM_MRK_VSU_FIN", 160 140 "BriefDescription": "VSU marked instructions finished. Excludes simple FX instructions issued to the Store Unit." 161 141 }, 162 142 { 163 - "EventCode": "30038", 143 + "EventCode": "0x30038", 164 144 "EventName": "PM_EXEC_STALL_DMISS_LMEM", 165 145 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from the local memory, local OpenCapp cache, or local OpenCapp memory." 166 146 }, 167 147 { 168 - "EventCode": "3F04A", 148 + "EventCode": "0x3F04A", 169 149 "EventName": "PM_LSU_ST5_FIN", 170 150 "BriefDescription": "LSU Finished an internal operation in ST2 port." 171 151 }, 172 152 { 173 - "EventCode": "34054", 174 - "EventName": "PM_EXEC_STALL_DMISS_L2L3_NOCONFLICT", 175 - "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from the local L2 or local L3, without a dispatch conflict." 176 - }, 177 - { 178 - "EventCode": "3405A", 153 + "EventCode": "0x3405A", 179 154 "EventName": "PM_PRIVILEGED_INST_CMPL", 180 155 "BriefDescription": "PowerPC Instructions that completed while the thread is in Privileged state." 181 156 }, 182 157 { 183 - "EventCode": "3F150", 158 + "EventCode": "0x3F150", 184 159 "EventName": "PM_MRK_ST_DRAIN_CYC", 185 160 "BriefDescription": "cycles to drain st from core to L2." 186 161 }, 187 162 { 188 - "EventCode": "3F054", 163 + "EventCode": "0x3F054", 189 164 "EventName": "PM_DISP_SS0_4_INSTR_CYC", 190 165 "BriefDescription": "Cycles in which Superslice 0 dispatches either 3 or 4 instructions." 191 166 }, 192 167 { 193 - "EventCode": "3F056", 168 + "EventCode": "0x3F056", 194 169 "EventName": "PM_DISP_SS0_8_INSTR_CYC", 195 170 "BriefDescription": "Cycles in which Superslice 0 dispatches either 5, 6, 7 or 8 instructions." 196 171 }, 197 172 { 198 - "EventCode": "30162", 173 + "EventCode": "0x30162", 199 174 "EventName": "PM_MRK_ISSUE_DEPENDENT_LOAD", 200 175 "BriefDescription": "The marked instruction was dependent on a load. It is eligible for issue kill." 201 176 }, 202 177 { 203 - "EventCode": "40114", 178 + "EventCode": "0x40114", 204 179 "EventName": "PM_MRK_START_PROBE_NOP_DISP", 205 180 "BriefDescription": "Marked Start probe nop dispatched. Instruction AND R0,R0,R0." 206 181 }, 207 182 { 208 - "EventCode": "4001C", 183 + "EventCode": "0x4001C", 209 184 "EventName": "PM_VSU_FIN", 210 185 "BriefDescription": "VSU instructions finished." 211 186 }, 212 187 { 213 - "EventCode": "4C01A", 188 + "EventCode": "0x4C01A", 214 189 "EventName": "PM_EXEC_STALL_DMISS_OFF_NODE", 215 190 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from a distant chip." 216 191 }, 217 192 { 218 - "EventCode": "4D012", 193 + "EventCode": "0x4D012", 219 194 "EventName": "PM_PMC3_SAVED", 220 195 "BriefDescription": "The conditions for the speculative event selected for PMC3 are met and PMC3 is charged." 221 196 }, 222 197 { 223 - "EventCode": "4D022", 198 + "EventCode": "0x4D022", 224 199 "EventName": "PM_HYPERVISOR_INST_CMPL", 225 200 "BriefDescription": "PowerPC instructions that completed while the thread is in hypervisor state." 226 201 }, 227 202 { 228 - "EventCode": "4D026", 203 + "EventCode": "0x4D026", 229 204 "EventName": "PM_ULTRAVISOR_CYC", 230 205 "BriefDescription": "Cycles when the thread is in Ultravisor state. MSR[S HV PR]=110." 231 206 }, 232 207 { 233 - "EventCode": "4D028", 208 + "EventCode": "0x4D028", 234 209 "EventName": "PM_PRIVILEGED_CYC", 235 210 "BriefDescription": "Cycles when the thread is in Privileged state. MSR[S HV PR]=x00." 236 211 }, 237 212 { 238 - "EventCode": "40030", 213 + "EventCode": "0x40030", 239 214 "EventName": "PM_INST_FIN", 240 215 "BriefDescription": "Instructions finished." 241 216 }, 242 217 { 243 - "EventCode": "44146", 218 + "EventCode": "0x44146", 244 219 "EventName": "PM_MRK_STCX_CORE_CYC", 245 220 "BriefDescription": "Cycles spent in the core portion of a marked Stcx instruction. It starts counting when the instruction is decoded and stops counting when it drains into the L2." 246 221 }, 247 222 { 248 - "EventCode": "44054", 223 + "EventCode": "0x44054", 249 224 "EventName": "PM_VECTOR_LD_CMPL", 250 225 "BriefDescription": "Vector load instructions completed." 251 226 }, 252 227 { 253 - "EventCode": "45054", 228 + "EventCode": "0x45054", 254 229 "EventName": "PM_FMA_CMPL", 255 230 "BriefDescription": "Two floating point instructions completed (FMA class of instructions: fmadd, fnmadd, fmsub, fnmsub). Scalar instructions only." 256 231 }, 257 232 { 258 - "EventCode": "45056", 233 + "EventCode": "0x45056", 259 234 "EventName": "PM_SCALAR_FLOP_CMPL", 260 235 "BriefDescription": "Scalar floating point instructions completed." 261 236 }, 262 237 { 263 - "EventCode": "4505C", 238 + "EventCode": "0x4505C", 264 239 "EventName": "PM_MATH_FLOP_CMPL", 265 240 "BriefDescription": "Math floating point instructions completed." 266 241 }, 267 242 { 268 - "EventCode": "4D05E", 243 + "EventCode": "0x4D05E", 269 244 "EventName": "PM_BR_CMPL", 270 245 "BriefDescription": "A branch completed. All branches are included." 271 246 }, 272 247 { 273 - "EventCode": "4E15E", 248 + "EventCode": "0x4E15E", 274 249 "EventName": "PM_MRK_INST_FLUSHED", 275 250 "BriefDescription": "The marked instruction was flushed." 276 251 }, 277 252 { 278 - "EventCode": "401E6", 253 + "EventCode": "0x401E6", 279 254 "EventName": "PM_MRK_INST_FROM_L3MISS", 280 255 "BriefDescription": "The processor's instruction cache was reloaded from a source other than the local core's L1, L2, or L3 due to a demand miss for a marked instruction." 281 256 }, 282 257 { 283 - "EventCode": "401E8", 258 + "EventCode": "0x401E8", 284 259 "EventName": "PM_MRK_DATA_FROM_L2MISS", 285 260 "BriefDescription": "The processor's data cache was reloaded from a source other than the local core's L1 or L2 due to a demand miss for a marked load." 286 261 }, 287 262 { 288 - "EventCode": "400F0", 263 + "EventCode": "0x400F0", 289 264 "EventName": "PM_LD_DEMAND_MISS_L1_FIN", 290 265 "BriefDescription": "Load Missed L1, counted at finish time." 291 266 }, 292 267 { 293 - "EventCode": "400FA", 268 + "EventCode": "0x400FA", 294 269 "EventName": "PM_RUN_INST_CMPL", 295 270 "BriefDescription": "Completed PowerPC instructions gated by the run latch." 296 271 }
+66 -71
tools/perf/pmu-events/arch/powerpc/power10/pipeline.json
··· 1 1 [ 2 2 { 3 - "EventCode": "100FE", 3 + "EventCode": "0x100FE", 4 4 "EventName": "PM_INST_CMPL", 5 5 "BriefDescription": "PowerPC instructions completed." 6 6 }, 7 7 { 8 - "EventCode": "10006", 9 - "EventName": "PM_DISP_STALL_HELD_OTHER_CYC", 10 - "BriefDescription": "Cycles in which the NTC instruction is held at dispatch for any other reason." 11 - }, 12 - { 13 - "EventCode": "1000C", 8 + "EventCode": "0x1000C", 14 9 "EventName": "PM_LSU_LD0_FIN", 15 10 "BriefDescription": "LSU Finished an internal operation in LD0 port." 16 11 }, 17 12 { 18 - "EventCode": "1000E", 13 + "EventCode": "0x1000E", 19 14 "EventName": "PM_MMA_ISSUED", 20 15 "BriefDescription": "MMA instructions issued." 21 16 }, 22 17 { 23 - "EventCode": "10012", 18 + "EventCode": "0x10012", 24 19 "EventName": "PM_LSU_ST0_FIN", 25 20 "BriefDescription": "LSU Finished an internal operation in ST0 port." 26 21 }, 27 22 { 28 - "EventCode": "10014", 23 + "EventCode": "0x10014", 29 24 "EventName": "PM_LSU_ST4_FIN", 30 25 "BriefDescription": "LSU Finished an internal operation in ST4 port." 31 26 }, 32 27 { 33 - "EventCode": "10018", 28 + "EventCode": "0x10018", 34 29 "EventName": "PM_IC_DEMAND_CYC", 35 30 "BriefDescription": "Cycles in which an instruction reload is pending to satisfy a demand miss." 36 31 }, 37 32 { 38 - "EventCode": "10022", 33 + "EventCode": "0x10022", 39 34 "EventName": "PM_PMC2_SAVED", 40 35 "BriefDescription": "The conditions for the speculative event selected for PMC2 are met and PMC2 is charged." 41 36 }, 42 37 { 43 - "EventCode": "10024", 38 + "EventCode": "0x10024", 44 39 "EventName": "PM_PMC5_OVERFLOW", 45 40 "BriefDescription": "The event selected for PMC5 caused the event counter to overflow." 46 41 }, 47 42 { 48 - "EventCode": "10058", 43 + "EventCode": "0x10058", 49 44 "EventName": "PM_EXEC_STALL_FIN_AT_DISP", 50 45 "BriefDescription": "Cycles in which the oldest instruction in the pipeline finished at dispatch and did not require execution in the LSU, BRU or VSU." 51 46 }, 52 47 { 53 - "EventCode": "1005A", 48 + "EventCode": "0x1005A", 54 49 "EventName": "PM_FLUSH_MPRED", 55 50 "BriefDescription": "A flush occurred due to a mispredicted branch. Includes target and direction." 56 51 }, 57 52 { 58 - "EventCode": "1C05A", 53 + "EventCode": "0x1C05A", 59 54 "EventName": "PM_DERAT_MISS_2M", 60 55 "BriefDescription": "Data ERAT Miss (Data TLB Access) page size 2M. Implies radix translation. When MMCR1[16]=0 this event counts only DERAT reloads for demand misses. When MMCR1[16]=1 this event includes demand misses and prefetches." 61 56 }, 62 57 { 63 - "EventCode": "10064", 64 - "EventName": "PM_DISP_STALL_IC_L2", 65 - "BriefDescription": "Cycles when dispatch was stalled while the instruction was fetched from the local L2." 58 + "EventCode": "0x1E05A", 59 + "EventName": "PM_CMPL_STALL_LWSYNC", 60 + "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a lwsync waiting to complete." 66 61 }, 67 62 { 68 - "EventCode": "10068", 63 + "EventCode": "0x10068", 69 64 "EventName": "PM_BR_FIN", 70 65 "BriefDescription": "A branch instruction finished. Includes predicted/mispredicted/unconditional." 71 66 }, 72 67 { 73 - "EventCode": "1006A", 68 + "EventCode": "0x1006A", 74 69 "EventName": "PM_FX_LSU_FIN", 75 70 "BriefDescription": "Simple fixed point instruction issued to the store unit. Measured at finish time." 76 71 }, 77 72 { 78 - "EventCode": "1006C", 73 + "EventCode": "0x1006C", 79 74 "EventName": "PM_RUN_CYC_ST_MODE", 80 75 "BriefDescription": "Cycles when the run latch is set and the core is in ST mode." 81 76 }, 82 77 { 83 - "EventCode": "20004", 78 + "EventCode": "0x20004", 84 79 "EventName": "PM_ISSUE_STALL", 85 80 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was dispatched but not issued yet." 86 81 }, 87 82 { 88 - "EventCode": "2000A", 83 + "EventCode": "0x2000A", 89 84 "EventName": "PM_HYPERVISOR_CYC", 90 85 "BriefDescription": "Cycles when the thread is in Hypervisor state. MSR[S HV PR]=010." 91 86 }, 92 87 { 93 - "EventCode": "2000E", 88 + "EventCode": "0x2000E", 94 89 "EventName": "PM_LSU_LD1_FIN", 95 90 "BriefDescription": "LSU Finished an internal operation in LD1 port." 96 91 }, 97 92 { 98 - "EventCode": "2C014", 93 + "EventCode": "0x2C014", 99 94 "EventName": "PM_CMPL_STALL_SPECIAL", 100 95 "BriefDescription": "Cycles in which the oldest instruction in the pipeline required special handling before completing." 101 96 }, 102 97 { 103 - "EventCode": "2C018", 98 + "EventCode": "0x2C018", 104 99 "EventName": "PM_EXEC_STALL_DMISS_L3MISS", 105 100 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for a load miss to resolve from a source beyond the local L2 or local L3." 106 101 }, 107 102 { 108 - "EventCode": "2D010", 103 + "EventCode": "0x2D010", 109 104 "EventName": "PM_LSU_ST1_FIN", 110 105 "BriefDescription": "LSU Finished an internal operation in ST1 port." 111 106 }, 112 107 { 113 - "EventCode": "2D012", 108 + "EventCode": "0x2D012", 114 109 "EventName": "PM_VSU1_ISSUE", 115 110 "BriefDescription": "VSU instructions issued to VSU pipe 1." 116 111 }, 117 112 { 118 - "EventCode": "2D018", 113 + "EventCode": "0x2D018", 119 114 "EventName": "PM_EXEC_STALL_VSU", 120 115 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was executing in the VSU (includes FXU, VSU, CRU)." 121 116 }, 122 117 { 123 - "EventCode": "2E01E", 124 - "EventName": "PM_EXEC_STALL_NTC_FLUSH", 125 - "BriefDescription": "Cycles in which the oldest instruction in the pipeline was executing in any unit before it was flushed. Note that if the flush of the oldest instruction happens after finish, the cycles from dispatch to issue will be included in PM_DISP_STALL and the cycles from issue to finish will be included in PM_EXEC_STALL and its corresponding children." 118 + "EventCode": "0x2D01C", 119 + "EventName": "PM_CMPL_STALL_STCX", 120 + "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a stcx waiting for resolution from the nest before completing." 126 121 }, 127 122 { 128 - "EventCode": "2013C", 123 + "EventCode": "0x2E01E", 124 + "EventName": "PM_EXEC_STALL_NTC_FLUSH", 125 + "BriefDescription": "Cycles in which the oldest instruction in the pipeline was executing in any unit before it was flushed. Note that if the flush of the oldest instruction happens after finish, the cycles from dispatch to issue will be included in PM_DISP_STALL and the cycles from issue to finish will be included in PM_EXEC_STALL and its corresponding children. This event will also count cycles when the previous NTF instruction is still completing and the new NTF instruction is stalled at dispatch." 126 + }, 127 + { 128 + "EventCode": "0x2013C", 129 129 "EventName": "PM_MRK_FX_LSU_FIN", 130 130 "BriefDescription": "The marked instruction was simple fixed point that was issued to the store unit. Measured at finish time." 131 131 }, 132 132 { 133 - "EventCode": "2405A", 133 + "EventCode": "0x2405A", 134 134 "EventName": "PM_NTC_FIN", 135 135 "BriefDescription": "Cycles in which the oldest instruction in the pipeline (NTC) finishes. Note that instructions can finish out of order, therefore not all the instructions that finish have a Next-to-complete status." 136 136 }, 137 137 { 138 - "EventCode": "201E2", 138 + "EventCode": "0x201E2", 139 139 "EventName": "PM_MRK_LD_MISS_L1", 140 140 "BriefDescription": "Marked DL1 Demand Miss counted at finish time." 141 141 }, 142 142 { 143 - "EventCode": "200F4", 143 + "EventCode": "0x200F4", 144 144 "EventName": "PM_RUN_CYC", 145 145 "BriefDescription": "Processor cycles gated by the run latch." 146 146 }, 147 147 { 148 - "EventCode": "30004", 149 - "EventName": "PM_DISP_STALL_FLUSH", 150 - "BriefDescription": "Cycles when dispatch was stalled because of a flush that happened to an instruction(s) that was not yet NTC. PM_EXEC_STALL_NTC_FLUSH only includes instructions that were flushed after becoming NTC." 151 - }, 152 - { 153 - "EventCode": "30008", 148 + "EventCode": "0x30008", 154 149 "EventName": "PM_EXEC_STALL", 155 150 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting to finish in one of the execution units (BRU, LSU, VSU). Only cycles between issue and finish are counted in this category." 156 151 }, 157 152 { 158 - "EventCode": "3001A", 153 + "EventCode": "0x3001A", 159 154 "EventName": "PM_LSU_ST2_FIN", 160 155 "BriefDescription": "LSU Finished an internal operation in ST2 port." 161 156 }, 162 157 { 163 - "EventCode": "30020", 158 + "EventCode": "0x30020", 164 159 "EventName": "PM_PMC2_REWIND", 165 160 "BriefDescription": "The speculative event selected for PMC2 rewinds and the counter for PMC2 is not charged." 166 161 }, 167 162 { 168 - "EventCode": "30022", 163 + "EventCode": "0x30022", 169 164 "EventName": "PM_PMC4_SAVED", 170 165 "BriefDescription": "The conditions for the speculative event selected for PMC4 are met and PMC4 is charged." 171 166 }, 172 167 { 173 - "EventCode": "30024", 168 + "EventCode": "0x30024", 174 169 "EventName": "PM_PMC6_OVERFLOW", 175 170 "BriefDescription": "The event selected for PMC6 caused the event counter to overflow." 176 171 }, 177 172 { 178 - "EventCode": "30028", 173 + "EventCode": "0x30028", 179 174 "EventName": "PM_CMPL_STALL_MEM_ECC", 180 175 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was waiting for the non-speculative finish of either a stcx waiting for its result or a load waiting for non-critical sectors of data and ECC." 181 176 }, 182 177 { 183 - "EventCode": "30036", 178 + "EventCode": "0x30036", 184 179 "EventName": "PM_EXEC_STALL_SIMPLE_FX", 185 180 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a simple fixed point instruction executing in the Load Store Unit." 186 181 }, 187 182 { 188 - "EventCode": "3003A", 183 + "EventCode": "0x3003A", 189 184 "EventName": "PM_CMPL_STALL_EXCEPTION", 190 185 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was not allowed to complete because it was interrupted by ANY exception, which has to be serviced before the instruction can complete." 191 186 }, 192 187 { 193 - "EventCode": "3F044", 188 + "EventCode": "0x3F044", 194 189 "EventName": "PM_VSU2_ISSUE", 195 190 "BriefDescription": "VSU instructions issued to VSU pipe 2." 196 191 }, 197 192 { 198 - "EventCode": "30058", 193 + "EventCode": "0x30058", 199 194 "EventName": "PM_TLBIE_FIN", 200 195 "BriefDescription": "TLBIE instructions finished in the LSU. Two TLBIEs can finish each cycle. All will be counted." 201 196 }, 202 197 { 203 - "EventCode": "3D058", 198 + "EventCode": "0x3D058", 204 199 "EventName": "PM_SCALAR_FSQRT_FDIV_ISSUE", 205 200 "BriefDescription": "Scalar versions of four floating point operations: fdiv,fsqrt (xvdivdp, xvdivsp, xvsqrtdp, xvsqrtsp)." 206 201 }, 207 202 { 208 - "EventCode": "30066", 203 + "EventCode": "0x30066", 209 204 "EventName": "PM_LSU_FIN", 210 205 "BriefDescription": "LSU Finished an internal operation (up to 4 per cycle)." 211 206 }, 212 207 { 213 - "EventCode": "40004", 208 + "EventCode": "0x40004", 214 209 "EventName": "PM_FXU_ISSUE", 215 210 "BriefDescription": "A fixed point instruction was issued to the VSU." 216 211 }, 217 212 { 218 - "EventCode": "40008", 213 + "EventCode": "0x40008", 219 214 "EventName": "PM_NTC_ALL_FIN", 220 215 "BriefDescription": "Cycles in which both instructions in the ICT entry pair show as finished. These are the cycles between finish and completion for the oldest pair of instructions in the pipeline." 221 216 }, 222 217 { 223 - "EventCode": "40010", 218 + "EventCode": "0x40010", 224 219 "EventName": "PM_PMC3_OVERFLOW", 225 220 "BriefDescription": "The event selected for PMC3 caused the event counter to overflow." 226 221 }, 227 222 { 228 - "EventCode": "4C012", 223 + "EventCode": "0x4C012", 229 224 "EventName": "PM_EXEC_STALL_DERAT_ONLY_MISS", 230 225 "BriefDescription": "Cycles in which the oldest instruction in the pipeline suffered an ERAT miss and waited for it resolve." 231 226 }, 232 227 { 233 - "EventCode": "4C018", 228 + "EventCode": "0x4C018", 234 229 "EventName": "PM_CMPL_STALL", 235 230 "BriefDescription": "Cycles in which the oldest instruction in the pipeline cannot complete because the thread was blocked for any reason." 236 231 }, 237 232 { 238 - "EventCode": "4C01E", 233 + "EventCode": "0x4C01E", 239 234 "EventName": "PM_LSU_ST3_FIN", 240 235 "BriefDescription": "LSU Finished an internal operation in ST3 port." 241 236 }, 242 237 { 243 - "EventCode": "4D018", 238 + "EventCode": "0x4D018", 244 239 "EventName": "PM_EXEC_STALL_BRU", 245 240 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was executing in the Branch unit." 246 241 }, 247 242 { 248 - "EventCode": "4D01A", 243 + "EventCode": "0x4D01A", 249 244 "EventName": "PM_CMPL_STALL_HWSYNC", 250 245 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a hwsync waiting for response from L2 before completing." 251 246 }, 252 247 { 253 - "EventCode": "4D01C", 248 + "EventCode": "0x4D01C", 254 249 "EventName": "PM_EXEC_STALL_TLBIEL", 255 250 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a TLBIEL instruction executing in the Load Store Unit. TLBIEL instructions have lower overhead than TLBIE instructions because they don't get set to the nest." 256 251 }, 257 252 { 258 - "EventCode": "4E012", 253 + "EventCode": "0x4E012", 259 254 "EventName": "PM_EXEC_STALL_UNKNOWN", 260 255 "BriefDescription": "Cycles in which the oldest instruction in the pipeline completed without an ntf_type pulse. The ntf_pulse was missed by the ISU because the NTF finishes and completions came too close together." 261 256 }, 262 257 { 263 - "EventCode": "4D020", 258 + "EventCode": "0x4D020", 264 259 "EventName": "PM_VSU3_ISSUE", 265 260 "BriefDescription": "VSU instruction was issued to VSU pipe 3." 266 261 }, 267 262 { 268 - "EventCode": "40132", 263 + "EventCode": "0x40132", 269 264 "EventName": "PM_MRK_LSU_FIN", 270 265 "BriefDescription": "LSU marked instruction finish." 271 266 }, 272 267 { 273 - "EventCode": "45058", 268 + "EventCode": "0x45058", 274 269 "EventName": "PM_IC_MISS_CMPL", 275 270 "BriefDescription": "Non-speculative icache miss, counted at completion." 276 271 }, 277 272 { 278 - "EventCode": "4D050", 273 + "EventCode": "0x4D050", 279 274 "EventName": "PM_VSU_NON_FLOP_CMPL", 280 275 "BriefDescription": "Non-floating point VSU instructions completed." 281 276 }, 282 277 { 283 - "EventCode": "4D052", 278 + "EventCode": "0x4D052", 284 279 "EventName": "PM_2FLOP_CMPL", 285 280 "BriefDescription": "Double Precision vector version of fmul, fsub, fcmp, fsel, fabs, fnabs, fres, fsqrte, fneg completed." 286 281 }, 287 282 { 288 - "EventCode": "400F2", 283 + "EventCode": "0x400F2", 289 284 "EventName": "PM_1PLUS_PPC_DISP", 290 285 "BriefDescription": "Cycles at least one Instr Dispatched." 291 286 }, 292 287 { 293 - "EventCode": "400F8", 288 + "EventCode": "0x400F8", 294 289 "EventName": "PM_FLUSH", 295 290 "BriefDescription": "Flush (any type)." 296 291 }
+4 -4
tools/perf/pmu-events/arch/powerpc/power10/pmc.json
··· 1 1 [ 2 2 { 3 - "EventCode": "301E8", 3 + "EventCode": "0x301E8", 4 4 "EventName": "PM_THRESH_EXC_64", 5 5 "BriefDescription": "Threshold counter exceeded a value of 64." 6 6 }, 7 7 { 8 - "EventCode": "45050", 8 + "EventCode": "0x45050", 9 9 "EventName": "PM_1FLOP_CMPL", 10 10 "BriefDescription": "One floating point instruction completed (fadd, fmul, fsub, fcmp, fsel, fabs, fnabs, fres, fsqrte, fneg)." 11 11 }, 12 12 { 13 - "EventCode": "45052", 13 + "EventCode": "0x45052", 14 14 "EventName": "PM_4FLOP_CMPL", 15 15 "BriefDescription": "Four floating point instructions completed (fadd, fmul, fsub, fcmp, fsel, fabs, fnabs, fres, fsqrte, fneg)." 16 16 }, 17 17 { 18 - "EventCode": "4D054", 18 + "EventCode": "0x4D054", 19 19 "EventName": "PM_8FLOP_CMPL", 20 20 "BriefDescription": "Four Double Precision vector instructions completed." 21 21 }
+11 -11
tools/perf/pmu-events/arch/powerpc/power10/translation.json
··· 1 1 [ 2 2 { 3 - "EventCode": "1F15E", 3 + "EventCode": "0x1F15E", 4 4 "EventName": "PM_MRK_START_PROBE_NOP_CMPL", 5 5 "BriefDescription": "Marked Start probe nop (AND R0,R0,R0) completed." 6 6 }, 7 7 { 8 - "EventCode": "20016", 8 + "EventCode": "0x20016", 9 9 "EventName": "PM_ST_FIN", 10 10 "BriefDescription": "Store finish count. Includes speculative activity." 11 11 }, 12 12 { 13 - "EventCode": "20018", 13 + "EventCode": "0x20018", 14 14 "EventName": "PM_ST_FWD", 15 15 "BriefDescription": "Store forwards that finished." 16 16 }, 17 17 { 18 - "EventCode": "2011C", 18 + "EventCode": "0x2011C", 19 19 "EventName": "PM_MRK_NTF_CYC", 20 20 "BriefDescription": "Cycles during which the marked instruction is the oldest in the pipeline (NTF or NTC)." 21 21 }, 22 22 { 23 - "EventCode": "2E01C", 23 + "EventCode": "0x2E01C", 24 24 "EventName": "PM_EXEC_STALL_TLBIE", 25 25 "BriefDescription": "Cycles in which the oldest instruction in the pipeline was a TLBIE instruction executing in the Load Store Unit." 26 26 }, 27 27 { 28 - "EventCode": "201E6", 28 + "EventCode": "0x201E6", 29 29 "EventName": "PM_THRESH_EXC_32", 30 30 "BriefDescription": "Threshold counter exceeded a value of 32." 31 31 }, 32 32 { 33 - "EventCode": "200F0", 33 + "EventCode": "0x200F0", 34 34 "EventName": "PM_ST_CMPL", 35 35 "BriefDescription": "Stores completed from S2Q (2nd-level store queue). This event includes regular stores, stcx and cache inhibited stores. The following operations are excluded (pteupdate, snoop tlbie complete, store atomics, miso, load atomic payloads, tlbie, tlbsync, slbieg, isync, msgsnd, slbiag, cpabort, copy, tcheck, tend, stsync, dcbst, icbi, dcbf, hwsync, lwsync, ptesync, eieio, msgsync)." 36 36 }, 37 37 { 38 - "EventCode": "200FE", 38 + "EventCode": "0x200FE", 39 39 "EventName": "PM_DATA_FROM_L2MISS", 40 40 "BriefDescription": "The processor's data cache was reloaded from a source other than the local core's L1 or L2 due to a demand miss." 41 41 }, 42 42 { 43 - "EventCode": "30010", 43 + "EventCode": "0x30010", 44 44 "EventName": "PM_PMC2_OVERFLOW", 45 45 "BriefDescription": "The event selected for PMC2 caused the event counter to overflow." 46 46 }, 47 47 { 48 - "EventCode": "4D010", 48 + "EventCode": "0x4D010", 49 49 "EventName": "PM_PMC1_SAVED", 50 50 "BriefDescription": "The conditions for the speculative event selected for PMC1 are met and PMC1 is charged." 51 51 }, 52 52 { 53 - "EventCode": "4D05C", 53 + "EventCode": "0x4D05C", 54 54 "EventName": "PM_DPP_FLOP_CMPL", 55 55 "BriefDescription": "Double-Precision or Quad-Precision instructions completed." 56 56 }
+1 -1
tools/perf/pmu-events/jevents.c
··· 960 960 struct rlimit rlim; 961 961 962 962 if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) 963 - return min((int)rlim.rlim_max / 2, 512); 963 + return min(rlim.rlim_max / 2, (rlim_t)512); 964 964 965 965 return 512; 966 966 }
+2 -2
tools/perf/util/bpf_counter.c
··· 451 451 goto out; 452 452 } 453 453 454 - err = -1; 455 454 link = bpf_program__attach(skel->progs.on_switch); 456 - if (!link) { 455 + if (IS_ERR(link)) { 457 456 pr_err("Failed to attach leader program\n"); 457 + err = PTR_ERR(link); 458 458 goto out; 459 459 } 460 460
+1 -1
tools/testing/selftests/bpf/network_helpers.c
··· 40 40 .tcp.doff = 5, 41 41 }; 42 42 43 - static int settimeo(int fd, int timeout_ms) 43 + int settimeo(int fd, int timeout_ms) 44 44 { 45 45 struct timeval timeout = { .tv_sec = 3 }; 46 46
+1
tools/testing/selftests/bpf/network_helpers.h
··· 33 33 } __packed; 34 34 extern struct ipv6_packet pkt_v6; 35 35 36 + int settimeo(int fd, int timeout_ms); 36 37 int start_server(int family, int type, const char *addr, __u16 port, 37 38 int timeout_ms); 38 39 int connect_to_fd(int server_fd, int timeout_ms);
+48 -1
tools/testing/selftests/bpf/prog_tests/ringbuf.c
··· 86 86 const size_t rec_sz = BPF_RINGBUF_HDR_SZ + sizeof(struct sample); 87 87 pthread_t thread; 88 88 long bg_ret = -1; 89 - int err, cnt; 89 + int err, cnt, rb_fd; 90 90 int page_size = getpagesize(); 91 + void *mmap_ptr, *tmp_ptr; 91 92 92 93 skel = test_ringbuf__open(); 93 94 if (CHECK(!skel, "skel_open", "skeleton open failed\n")) ··· 101 100 err = test_ringbuf__load(skel); 102 101 if (CHECK(err != 0, "skel_load", "skeleton load failed\n")) 103 102 goto cleanup; 103 + 104 + rb_fd = bpf_map__fd(skel->maps.ringbuf); 105 + /* good read/write cons_pos */ 106 + mmap_ptr = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, rb_fd, 0); 107 + ASSERT_OK_PTR(mmap_ptr, "rw_cons_pos"); 108 + tmp_ptr = mremap(mmap_ptr, page_size, 2 * page_size, MREMAP_MAYMOVE); 109 + if (!ASSERT_ERR_PTR(tmp_ptr, "rw_extend")) 110 + goto cleanup; 111 + ASSERT_ERR(mprotect(mmap_ptr, page_size, PROT_EXEC), "exec_cons_pos_protect"); 112 + ASSERT_OK(munmap(mmap_ptr, page_size), "unmap_rw"); 113 + 114 + /* bad writeable prod_pos */ 115 + mmap_ptr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, rb_fd, page_size); 116 + err = -errno; 117 + ASSERT_ERR_PTR(mmap_ptr, "wr_prod_pos"); 118 + ASSERT_EQ(err, -EPERM, "wr_prod_pos_err"); 119 + 120 + /* bad writeable data pages */ 121 + mmap_ptr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, rb_fd, 2 * page_size); 122 + err = -errno; 123 + ASSERT_ERR_PTR(mmap_ptr, "wr_data_page_one"); 124 + ASSERT_EQ(err, -EPERM, "wr_data_page_one_err"); 125 + mmap_ptr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, rb_fd, 3 * page_size); 126 + ASSERT_ERR_PTR(mmap_ptr, "wr_data_page_two"); 127 + mmap_ptr = mmap(NULL, 2 * page_size, PROT_WRITE, MAP_SHARED, rb_fd, 2 * page_size); 128 + ASSERT_ERR_PTR(mmap_ptr, "wr_data_page_all"); 129 + 130 + /* good read-only pages */ 131 + mmap_ptr = mmap(NULL, 4 * page_size, PROT_READ, MAP_SHARED, rb_fd, 0); 132 + if (!ASSERT_OK_PTR(mmap_ptr, "ro_prod_pos")) 133 + goto cleanup; 134 + 135 + ASSERT_ERR(mprotect(mmap_ptr, 4 * page_size, PROT_WRITE), "write_protect"); 136 + ASSERT_ERR(mprotect(mmap_ptr, 4 * page_size, PROT_EXEC), "exec_protect"); 137 + ASSERT_ERR_PTR(mremap(mmap_ptr, 0, 4 * page_size, MREMAP_MAYMOVE), "ro_remap"); 138 + ASSERT_OK(munmap(mmap_ptr, 4 * page_size), "unmap_ro"); 139 + 140 + /* good read-only pages with initial offset */ 141 + mmap_ptr = mmap(NULL, page_size, PROT_READ, MAP_SHARED, rb_fd, page_size); 142 + if (!ASSERT_OK_PTR(mmap_ptr, "ro_prod_pos")) 143 + goto cleanup; 144 + 145 + ASSERT_ERR(mprotect(mmap_ptr, page_size, PROT_WRITE), "write_protect"); 146 + ASSERT_ERR(mprotect(mmap_ptr, page_size, PROT_EXEC), "exec_protect"); 147 + ASSERT_ERR_PTR(mremap(mmap_ptr, 0, 3 * page_size, MREMAP_MAYMOVE), "ro_remap"); 148 + ASSERT_OK(munmap(mmap_ptr, page_size), "unmap_ro"); 104 149 105 150 /* only trigger BPF program for current process */ 106 151 skel->bss->pid = getpid();
+785
tools/testing/selftests/bpf/prog_tests/tc_redirect.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 + 3 + /* 4 + * This test sets up 3 netns (src <-> fwd <-> dst). There is no direct veth link 5 + * between src and dst. The netns fwd has veth links to each src and dst. The 6 + * client is in src and server in dst. The test installs a TC BPF program to each 7 + * host facing veth in fwd which calls into i) bpf_redirect_neigh() to perform the 8 + * neigh addr population and redirect or ii) bpf_redirect_peer() for namespace 9 + * switch from ingress side; it also installs a checker prog on the egress side 10 + * to drop unexpected traffic. 11 + */ 12 + 13 + #define _GNU_SOURCE 14 + 15 + #include <arpa/inet.h> 16 + #include <linux/limits.h> 17 + #include <linux/sysctl.h> 18 + #include <linux/if_tun.h> 19 + #include <linux/if.h> 20 + #include <sched.h> 21 + #include <stdbool.h> 22 + #include <stdio.h> 23 + #include <sys/stat.h> 24 + #include <sys/mount.h> 25 + 26 + #include "test_progs.h" 27 + #include "network_helpers.h" 28 + #include "test_tc_neigh_fib.skel.h" 29 + #include "test_tc_neigh.skel.h" 30 + #include "test_tc_peer.skel.h" 31 + 32 + #define NS_SRC "ns_src" 33 + #define NS_FWD "ns_fwd" 34 + #define NS_DST "ns_dst" 35 + 36 + #define IP4_SRC "172.16.1.100" 37 + #define IP4_DST "172.16.2.100" 38 + #define IP4_TUN_SRC "172.17.1.100" 39 + #define IP4_TUN_FWD "172.17.1.200" 40 + #define IP4_PORT 9004 41 + 42 + #define IP6_SRC "0::1:dead:beef:cafe" 43 + #define IP6_DST "0::2:dead:beef:cafe" 44 + #define IP6_TUN_SRC "1::1:dead:beef:cafe" 45 + #define IP6_TUN_FWD "1::2:dead:beef:cafe" 46 + #define IP6_PORT 9006 47 + 48 + #define IP4_SLL "169.254.0.1" 49 + #define IP4_DLL "169.254.0.2" 50 + #define IP4_NET "169.254.0.0" 51 + 52 + #define MAC_DST_FWD "00:11:22:33:44:55" 53 + #define MAC_DST "00:22:33:44:55:66" 54 + 55 + #define IFADDR_STR_LEN 18 56 + #define PING_ARGS "-i 0.2 -c 3 -w 10 -q" 57 + 58 + #define SRC_PROG_PIN_FILE "/sys/fs/bpf/test_tc_src" 59 + #define DST_PROG_PIN_FILE "/sys/fs/bpf/test_tc_dst" 60 + #define CHK_PROG_PIN_FILE "/sys/fs/bpf/test_tc_chk" 61 + 62 + #define TIMEOUT_MILLIS 10000 63 + 64 + #define log_err(MSG, ...) \ 65 + fprintf(stderr, "(%s:%d: errno: %s) " MSG "\n", \ 66 + __FILE__, __LINE__, strerror(errno), ##__VA_ARGS__) 67 + 68 + static const char * const namespaces[] = {NS_SRC, NS_FWD, NS_DST, NULL}; 69 + 70 + static int write_file(const char *path, const char *newval) 71 + { 72 + FILE *f; 73 + 74 + f = fopen(path, "r+"); 75 + if (!f) 76 + return -1; 77 + if (fwrite(newval, strlen(newval), 1, f) != 1) { 78 + log_err("writing to %s failed", path); 79 + fclose(f); 80 + return -1; 81 + } 82 + fclose(f); 83 + return 0; 84 + } 85 + 86 + struct nstoken { 87 + int orig_netns_fd; 88 + }; 89 + 90 + static int setns_by_fd(int nsfd) 91 + { 92 + int err; 93 + 94 + err = setns(nsfd, CLONE_NEWNET); 95 + close(nsfd); 96 + 97 + if (!ASSERT_OK(err, "setns")) 98 + return err; 99 + 100 + /* Switch /sys to the new namespace so that e.g. /sys/class/net 101 + * reflects the devices in the new namespace. 102 + */ 103 + err = unshare(CLONE_NEWNS); 104 + if (!ASSERT_OK(err, "unshare")) 105 + return err; 106 + 107 + err = umount2("/sys", MNT_DETACH); 108 + if (!ASSERT_OK(err, "umount2 /sys")) 109 + return err; 110 + 111 + err = mount("sysfs", "/sys", "sysfs", 0, NULL); 112 + if (!ASSERT_OK(err, "mount /sys")) 113 + return err; 114 + 115 + err = mount("bpffs", "/sys/fs/bpf", "bpf", 0, NULL); 116 + if (!ASSERT_OK(err, "mount /sys/fs/bpf")) 117 + return err; 118 + 119 + return 0; 120 + } 121 + 122 + /** 123 + * open_netns() - Switch to specified network namespace by name. 124 + * 125 + * Returns token with which to restore the original namespace 126 + * using close_netns(). 127 + */ 128 + static struct nstoken *open_netns(const char *name) 129 + { 130 + int nsfd; 131 + char nspath[PATH_MAX]; 132 + int err; 133 + struct nstoken *token; 134 + 135 + token = malloc(sizeof(struct nstoken)); 136 + if (!ASSERT_OK_PTR(token, "malloc token")) 137 + return NULL; 138 + 139 + token->orig_netns_fd = open("/proc/self/ns/net", O_RDONLY); 140 + if (!ASSERT_GE(token->orig_netns_fd, 0, "open /proc/self/ns/net")) 141 + goto fail; 142 + 143 + snprintf(nspath, sizeof(nspath), "%s/%s", "/var/run/netns", name); 144 + nsfd = open(nspath, O_RDONLY | O_CLOEXEC); 145 + if (!ASSERT_GE(nsfd, 0, "open netns fd")) 146 + goto fail; 147 + 148 + err = setns_by_fd(nsfd); 149 + if (!ASSERT_OK(err, "setns_by_fd")) 150 + goto fail; 151 + 152 + return token; 153 + fail: 154 + free(token); 155 + return NULL; 156 + } 157 + 158 + static void close_netns(struct nstoken *token) 159 + { 160 + ASSERT_OK(setns_by_fd(token->orig_netns_fd), "setns_by_fd"); 161 + free(token); 162 + } 163 + 164 + static int netns_setup_namespaces(const char *verb) 165 + { 166 + const char * const *ns = namespaces; 167 + char cmd[128]; 168 + 169 + while (*ns) { 170 + snprintf(cmd, sizeof(cmd), "ip netns %s %s", verb, *ns); 171 + if (!ASSERT_OK(system(cmd), cmd)) 172 + return -1; 173 + ns++; 174 + } 175 + return 0; 176 + } 177 + 178 + struct netns_setup_result { 179 + int ifindex_veth_src_fwd; 180 + int ifindex_veth_dst_fwd; 181 + }; 182 + 183 + static int get_ifaddr(const char *name, char *ifaddr) 184 + { 185 + char path[PATH_MAX]; 186 + FILE *f; 187 + int ret; 188 + 189 + snprintf(path, PATH_MAX, "/sys/class/net/%s/address", name); 190 + f = fopen(path, "r"); 191 + if (!ASSERT_OK_PTR(f, path)) 192 + return -1; 193 + 194 + ret = fread(ifaddr, 1, IFADDR_STR_LEN, f); 195 + if (!ASSERT_EQ(ret, IFADDR_STR_LEN, "fread ifaddr")) { 196 + fclose(f); 197 + return -1; 198 + } 199 + fclose(f); 200 + return 0; 201 + } 202 + 203 + static int get_ifindex(const char *name) 204 + { 205 + char path[PATH_MAX]; 206 + char buf[32]; 207 + FILE *f; 208 + int ret; 209 + 210 + snprintf(path, PATH_MAX, "/sys/class/net/%s/ifindex", name); 211 + f = fopen(path, "r"); 212 + if (!ASSERT_OK_PTR(f, path)) 213 + return -1; 214 + 215 + ret = fread(buf, 1, sizeof(buf), f); 216 + if (!ASSERT_GT(ret, 0, "fread ifindex")) { 217 + fclose(f); 218 + return -1; 219 + } 220 + fclose(f); 221 + return atoi(buf); 222 + } 223 + 224 + #define SYS(fmt, ...) \ 225 + ({ \ 226 + char cmd[1024]; \ 227 + snprintf(cmd, sizeof(cmd), fmt, ##__VA_ARGS__); \ 228 + if (!ASSERT_OK(system(cmd), cmd)) \ 229 + goto fail; \ 230 + }) 231 + 232 + static int netns_setup_links_and_routes(struct netns_setup_result *result) 233 + { 234 + struct nstoken *nstoken = NULL; 235 + char veth_src_fwd_addr[IFADDR_STR_LEN+1] = {}; 236 + 237 + SYS("ip link add veth_src type veth peer name veth_src_fwd"); 238 + SYS("ip link add veth_dst type veth peer name veth_dst_fwd"); 239 + 240 + SYS("ip link set veth_dst_fwd address " MAC_DST_FWD); 241 + SYS("ip link set veth_dst address " MAC_DST); 242 + 243 + if (get_ifaddr("veth_src_fwd", veth_src_fwd_addr)) 244 + goto fail; 245 + 246 + result->ifindex_veth_src_fwd = get_ifindex("veth_src_fwd"); 247 + if (result->ifindex_veth_src_fwd < 0) 248 + goto fail; 249 + result->ifindex_veth_dst_fwd = get_ifindex("veth_dst_fwd"); 250 + if (result->ifindex_veth_dst_fwd < 0) 251 + goto fail; 252 + 253 + SYS("ip link set veth_src netns " NS_SRC); 254 + SYS("ip link set veth_src_fwd netns " NS_FWD); 255 + SYS("ip link set veth_dst_fwd netns " NS_FWD); 256 + SYS("ip link set veth_dst netns " NS_DST); 257 + 258 + /** setup in 'src' namespace */ 259 + nstoken = open_netns(NS_SRC); 260 + if (!ASSERT_OK_PTR(nstoken, "setns src")) 261 + goto fail; 262 + 263 + SYS("ip addr add " IP4_SRC "/32 dev veth_src"); 264 + SYS("ip addr add " IP6_SRC "/128 dev veth_src nodad"); 265 + SYS("ip link set dev veth_src up"); 266 + 267 + SYS("ip route add " IP4_DST "/32 dev veth_src scope global"); 268 + SYS("ip route add " IP4_NET "/16 dev veth_src scope global"); 269 + SYS("ip route add " IP6_DST "/128 dev veth_src scope global"); 270 + 271 + SYS("ip neigh add " IP4_DST " dev veth_src lladdr %s", 272 + veth_src_fwd_addr); 273 + SYS("ip neigh add " IP6_DST " dev veth_src lladdr %s", 274 + veth_src_fwd_addr); 275 + 276 + close_netns(nstoken); 277 + 278 + /** setup in 'fwd' namespace */ 279 + nstoken = open_netns(NS_FWD); 280 + if (!ASSERT_OK_PTR(nstoken, "setns fwd")) 281 + goto fail; 282 + 283 + /* The fwd netns automatically gets a v6 LL address / routes, but also 284 + * needs v4 one in order to start ARP probing. IP4_NET route is added 285 + * to the endpoints so that the ARP processing will reply. 286 + */ 287 + SYS("ip addr add " IP4_SLL "/32 dev veth_src_fwd"); 288 + SYS("ip addr add " IP4_DLL "/32 dev veth_dst_fwd"); 289 + SYS("ip link set dev veth_src_fwd up"); 290 + SYS("ip link set dev veth_dst_fwd up"); 291 + 292 + SYS("ip route add " IP4_SRC "/32 dev veth_src_fwd scope global"); 293 + SYS("ip route add " IP6_SRC "/128 dev veth_src_fwd scope global"); 294 + SYS("ip route add " IP4_DST "/32 dev veth_dst_fwd scope global"); 295 + SYS("ip route add " IP6_DST "/128 dev veth_dst_fwd scope global"); 296 + 297 + close_netns(nstoken); 298 + 299 + /** setup in 'dst' namespace */ 300 + nstoken = open_netns(NS_DST); 301 + if (!ASSERT_OK_PTR(nstoken, "setns dst")) 302 + goto fail; 303 + 304 + SYS("ip addr add " IP4_DST "/32 dev veth_dst"); 305 + SYS("ip addr add " IP6_DST "/128 dev veth_dst nodad"); 306 + SYS("ip link set dev veth_dst up"); 307 + 308 + SYS("ip route add " IP4_SRC "/32 dev veth_dst scope global"); 309 + SYS("ip route add " IP4_NET "/16 dev veth_dst scope global"); 310 + SYS("ip route add " IP6_SRC "/128 dev veth_dst scope global"); 311 + 312 + SYS("ip neigh add " IP4_SRC " dev veth_dst lladdr " MAC_DST_FWD); 313 + SYS("ip neigh add " IP6_SRC " dev veth_dst lladdr " MAC_DST_FWD); 314 + 315 + close_netns(nstoken); 316 + 317 + return 0; 318 + fail: 319 + if (nstoken) 320 + close_netns(nstoken); 321 + return -1; 322 + } 323 + 324 + static int netns_load_bpf(void) 325 + { 326 + SYS("tc qdisc add dev veth_src_fwd clsact"); 327 + SYS("tc filter add dev veth_src_fwd ingress bpf da object-pinned " 328 + SRC_PROG_PIN_FILE); 329 + SYS("tc filter add dev veth_src_fwd egress bpf da object-pinned " 330 + CHK_PROG_PIN_FILE); 331 + 332 + SYS("tc qdisc add dev veth_dst_fwd clsact"); 333 + SYS("tc filter add dev veth_dst_fwd ingress bpf da object-pinned " 334 + DST_PROG_PIN_FILE); 335 + SYS("tc filter add dev veth_dst_fwd egress bpf da object-pinned " 336 + CHK_PROG_PIN_FILE); 337 + 338 + return 0; 339 + fail: 340 + return -1; 341 + } 342 + 343 + static void test_tcp(int family, const char *addr, __u16 port) 344 + { 345 + int listen_fd = -1, accept_fd = -1, client_fd = -1; 346 + char buf[] = "testing testing"; 347 + int n; 348 + struct nstoken *nstoken; 349 + 350 + nstoken = open_netns(NS_DST); 351 + if (!ASSERT_OK_PTR(nstoken, "setns dst")) 352 + return; 353 + 354 + listen_fd = start_server(family, SOCK_STREAM, addr, port, 0); 355 + if (!ASSERT_GE(listen_fd, 0, "listen")) 356 + goto done; 357 + 358 + close_netns(nstoken); 359 + nstoken = open_netns(NS_SRC); 360 + if (!ASSERT_OK_PTR(nstoken, "setns src")) 361 + goto done; 362 + 363 + client_fd = connect_to_fd(listen_fd, TIMEOUT_MILLIS); 364 + if (!ASSERT_GE(client_fd, 0, "connect_to_fd")) 365 + goto done; 366 + 367 + accept_fd = accept(listen_fd, NULL, NULL); 368 + if (!ASSERT_GE(accept_fd, 0, "accept")) 369 + goto done; 370 + 371 + if (!ASSERT_OK(settimeo(accept_fd, TIMEOUT_MILLIS), "settimeo")) 372 + goto done; 373 + 374 + n = write(client_fd, buf, sizeof(buf)); 375 + if (!ASSERT_EQ(n, sizeof(buf), "send to server")) 376 + goto done; 377 + 378 + n = read(accept_fd, buf, sizeof(buf)); 379 + ASSERT_EQ(n, sizeof(buf), "recv from server"); 380 + 381 + done: 382 + if (nstoken) 383 + close_netns(nstoken); 384 + if (listen_fd >= 0) 385 + close(listen_fd); 386 + if (accept_fd >= 0) 387 + close(accept_fd); 388 + if (client_fd >= 0) 389 + close(client_fd); 390 + } 391 + 392 + static int test_ping(int family, const char *addr) 393 + { 394 + const char *ping = family == AF_INET6 ? "ping6" : "ping"; 395 + 396 + SYS("ip netns exec " NS_SRC " %s " PING_ARGS " %s > /dev/null", ping, addr); 397 + return 0; 398 + fail: 399 + return -1; 400 + } 401 + 402 + static void test_connectivity(void) 403 + { 404 + test_tcp(AF_INET, IP4_DST, IP4_PORT); 405 + test_ping(AF_INET, IP4_DST); 406 + test_tcp(AF_INET6, IP6_DST, IP6_PORT); 407 + test_ping(AF_INET6, IP6_DST); 408 + } 409 + 410 + static int set_forwarding(bool enable) 411 + { 412 + int err; 413 + 414 + err = write_file("/proc/sys/net/ipv4/ip_forward", enable ? "1" : "0"); 415 + if (!ASSERT_OK(err, "set ipv4.ip_forward=0")) 416 + return err; 417 + 418 + err = write_file("/proc/sys/net/ipv6/conf/all/forwarding", enable ? "1" : "0"); 419 + if (!ASSERT_OK(err, "set ipv6.forwarding=0")) 420 + return err; 421 + 422 + return 0; 423 + } 424 + 425 + static void test_tc_redirect_neigh_fib(struct netns_setup_result *setup_result) 426 + { 427 + struct nstoken *nstoken = NULL; 428 + struct test_tc_neigh_fib *skel = NULL; 429 + int err; 430 + 431 + nstoken = open_netns(NS_FWD); 432 + if (!ASSERT_OK_PTR(nstoken, "setns fwd")) 433 + return; 434 + 435 + skel = test_tc_neigh_fib__open(); 436 + if (!ASSERT_OK_PTR(skel, "test_tc_neigh_fib__open")) 437 + goto done; 438 + 439 + if (!ASSERT_OK(test_tc_neigh_fib__load(skel), "test_tc_neigh_fib__load")) 440 + goto done; 441 + 442 + err = bpf_program__pin(skel->progs.tc_src, SRC_PROG_PIN_FILE); 443 + if (!ASSERT_OK(err, "pin " SRC_PROG_PIN_FILE)) 444 + goto done; 445 + 446 + err = bpf_program__pin(skel->progs.tc_chk, CHK_PROG_PIN_FILE); 447 + if (!ASSERT_OK(err, "pin " CHK_PROG_PIN_FILE)) 448 + goto done; 449 + 450 + err = bpf_program__pin(skel->progs.tc_dst, DST_PROG_PIN_FILE); 451 + if (!ASSERT_OK(err, "pin " DST_PROG_PIN_FILE)) 452 + goto done; 453 + 454 + if (netns_load_bpf()) 455 + goto done; 456 + 457 + /* bpf_fib_lookup() checks if forwarding is enabled */ 458 + if (!ASSERT_OK(set_forwarding(true), "enable forwarding")) 459 + goto done; 460 + 461 + test_connectivity(); 462 + 463 + done: 464 + if (skel) 465 + test_tc_neigh_fib__destroy(skel); 466 + close_netns(nstoken); 467 + } 468 + 469 + static void test_tc_redirect_neigh(struct netns_setup_result *setup_result) 470 + { 471 + struct nstoken *nstoken = NULL; 472 + struct test_tc_neigh *skel = NULL; 473 + int err; 474 + 475 + nstoken = open_netns(NS_FWD); 476 + if (!ASSERT_OK_PTR(nstoken, "setns fwd")) 477 + return; 478 + 479 + skel = test_tc_neigh__open(); 480 + if (!ASSERT_OK_PTR(skel, "test_tc_neigh__open")) 481 + goto done; 482 + 483 + skel->rodata->IFINDEX_SRC = setup_result->ifindex_veth_src_fwd; 484 + skel->rodata->IFINDEX_DST = setup_result->ifindex_veth_dst_fwd; 485 + 486 + err = test_tc_neigh__load(skel); 487 + if (!ASSERT_OK(err, "test_tc_neigh__load")) 488 + goto done; 489 + 490 + err = bpf_program__pin(skel->progs.tc_src, SRC_PROG_PIN_FILE); 491 + if (!ASSERT_OK(err, "pin " SRC_PROG_PIN_FILE)) 492 + goto done; 493 + 494 + err = bpf_program__pin(skel->progs.tc_chk, CHK_PROG_PIN_FILE); 495 + if (!ASSERT_OK(err, "pin " CHK_PROG_PIN_FILE)) 496 + goto done; 497 + 498 + err = bpf_program__pin(skel->progs.tc_dst, DST_PROG_PIN_FILE); 499 + if (!ASSERT_OK(err, "pin " DST_PROG_PIN_FILE)) 500 + goto done; 501 + 502 + if (netns_load_bpf()) 503 + goto done; 504 + 505 + if (!ASSERT_OK(set_forwarding(false), "disable forwarding")) 506 + goto done; 507 + 508 + test_connectivity(); 509 + 510 + done: 511 + if (skel) 512 + test_tc_neigh__destroy(skel); 513 + close_netns(nstoken); 514 + } 515 + 516 + static void test_tc_redirect_peer(struct netns_setup_result *setup_result) 517 + { 518 + struct nstoken *nstoken; 519 + struct test_tc_peer *skel; 520 + int err; 521 + 522 + nstoken = open_netns(NS_FWD); 523 + if (!ASSERT_OK_PTR(nstoken, "setns fwd")) 524 + return; 525 + 526 + skel = test_tc_peer__open(); 527 + if (!ASSERT_OK_PTR(skel, "test_tc_peer__open")) 528 + goto done; 529 + 530 + skel->rodata->IFINDEX_SRC = setup_result->ifindex_veth_src_fwd; 531 + skel->rodata->IFINDEX_DST = setup_result->ifindex_veth_dst_fwd; 532 + 533 + err = test_tc_peer__load(skel); 534 + if (!ASSERT_OK(err, "test_tc_peer__load")) 535 + goto done; 536 + 537 + err = bpf_program__pin(skel->progs.tc_src, SRC_PROG_PIN_FILE); 538 + if (!ASSERT_OK(err, "pin " SRC_PROG_PIN_FILE)) 539 + goto done; 540 + 541 + err = bpf_program__pin(skel->progs.tc_chk, CHK_PROG_PIN_FILE); 542 + if (!ASSERT_OK(err, "pin " CHK_PROG_PIN_FILE)) 543 + goto done; 544 + 545 + err = bpf_program__pin(skel->progs.tc_dst, DST_PROG_PIN_FILE); 546 + if (!ASSERT_OK(err, "pin " DST_PROG_PIN_FILE)) 547 + goto done; 548 + 549 + if (netns_load_bpf()) 550 + goto done; 551 + 552 + if (!ASSERT_OK(set_forwarding(false), "disable forwarding")) 553 + goto done; 554 + 555 + test_connectivity(); 556 + 557 + done: 558 + if (skel) 559 + test_tc_peer__destroy(skel); 560 + close_netns(nstoken); 561 + } 562 + 563 + static int tun_open(char *name) 564 + { 565 + struct ifreq ifr; 566 + int fd, err; 567 + 568 + fd = open("/dev/net/tun", O_RDWR); 569 + if (!ASSERT_GE(fd, 0, "open /dev/net/tun")) 570 + return -1; 571 + 572 + memset(&ifr, 0, sizeof(ifr)); 573 + 574 + ifr.ifr_flags = IFF_TUN | IFF_NO_PI; 575 + if (*name) 576 + strncpy(ifr.ifr_name, name, IFNAMSIZ); 577 + 578 + err = ioctl(fd, TUNSETIFF, &ifr); 579 + if (!ASSERT_OK(err, "ioctl TUNSETIFF")) 580 + goto fail; 581 + 582 + SYS("ip link set dev %s up", name); 583 + 584 + return fd; 585 + fail: 586 + close(fd); 587 + return -1; 588 + } 589 + 590 + #define MAX(a, b) ((a) > (b) ? (a) : (b)) 591 + enum { 592 + SRC_TO_TARGET = 0, 593 + TARGET_TO_SRC = 1, 594 + }; 595 + 596 + static int tun_relay_loop(int src_fd, int target_fd) 597 + { 598 + fd_set rfds, wfds; 599 + 600 + FD_ZERO(&rfds); 601 + FD_ZERO(&wfds); 602 + 603 + for (;;) { 604 + char buf[1500]; 605 + int direction, nread, nwrite; 606 + 607 + FD_SET(src_fd, &rfds); 608 + FD_SET(target_fd, &rfds); 609 + 610 + if (select(1 + MAX(src_fd, target_fd), &rfds, NULL, NULL, NULL) < 0) { 611 + log_err("select failed"); 612 + return 1; 613 + } 614 + 615 + direction = FD_ISSET(src_fd, &rfds) ? SRC_TO_TARGET : TARGET_TO_SRC; 616 + 617 + nread = read(direction == SRC_TO_TARGET ? src_fd : target_fd, buf, sizeof(buf)); 618 + if (nread < 0) { 619 + log_err("read failed"); 620 + return 1; 621 + } 622 + 623 + nwrite = write(direction == SRC_TO_TARGET ? target_fd : src_fd, buf, nread); 624 + if (nwrite != nread) { 625 + log_err("write failed"); 626 + return 1; 627 + } 628 + } 629 + } 630 + 631 + static void test_tc_redirect_peer_l3(struct netns_setup_result *setup_result) 632 + { 633 + struct test_tc_peer *skel = NULL; 634 + struct nstoken *nstoken = NULL; 635 + int err; 636 + int tunnel_pid = -1; 637 + int src_fd, target_fd; 638 + int ifindex; 639 + 640 + /* Start a L3 TUN/TAP tunnel between the src and dst namespaces. 641 + * This test is using TUN/TAP instead of e.g. IPIP or GRE tunnel as those 642 + * expose the L2 headers encapsulating the IP packet to BPF and hence 643 + * don't have skb in suitable state for this test. Alternative to TUN/TAP 644 + * would be e.g. Wireguard which would appear as a pure L3 device to BPF, 645 + * but that requires much more complicated setup. 646 + */ 647 + nstoken = open_netns(NS_SRC); 648 + if (!ASSERT_OK_PTR(nstoken, "setns " NS_SRC)) 649 + return; 650 + 651 + src_fd = tun_open("tun_src"); 652 + if (!ASSERT_GE(src_fd, 0, "tun_open tun_src")) 653 + goto fail; 654 + 655 + close_netns(nstoken); 656 + 657 + nstoken = open_netns(NS_FWD); 658 + if (!ASSERT_OK_PTR(nstoken, "setns " NS_FWD)) 659 + goto fail; 660 + 661 + target_fd = tun_open("tun_fwd"); 662 + if (!ASSERT_GE(target_fd, 0, "tun_open tun_fwd")) 663 + goto fail; 664 + 665 + tunnel_pid = fork(); 666 + if (!ASSERT_GE(tunnel_pid, 0, "fork tun_relay_loop")) 667 + goto fail; 668 + 669 + if (tunnel_pid == 0) 670 + exit(tun_relay_loop(src_fd, target_fd)); 671 + 672 + skel = test_tc_peer__open(); 673 + if (!ASSERT_OK_PTR(skel, "test_tc_peer__open")) 674 + goto fail; 675 + 676 + ifindex = get_ifindex("tun_fwd"); 677 + if (!ASSERT_GE(ifindex, 0, "get_ifindex tun_fwd")) 678 + goto fail; 679 + 680 + skel->rodata->IFINDEX_SRC = ifindex; 681 + skel->rodata->IFINDEX_DST = setup_result->ifindex_veth_dst_fwd; 682 + 683 + err = test_tc_peer__load(skel); 684 + if (!ASSERT_OK(err, "test_tc_peer__load")) 685 + goto fail; 686 + 687 + err = bpf_program__pin(skel->progs.tc_src_l3, SRC_PROG_PIN_FILE); 688 + if (!ASSERT_OK(err, "pin " SRC_PROG_PIN_FILE)) 689 + goto fail; 690 + 691 + err = bpf_program__pin(skel->progs.tc_dst_l3, DST_PROG_PIN_FILE); 692 + if (!ASSERT_OK(err, "pin " DST_PROG_PIN_FILE)) 693 + goto fail; 694 + 695 + err = bpf_program__pin(skel->progs.tc_chk, CHK_PROG_PIN_FILE); 696 + if (!ASSERT_OK(err, "pin " CHK_PROG_PIN_FILE)) 697 + goto fail; 698 + 699 + /* Load "tc_src_l3" to the tun_fwd interface to redirect packets 700 + * towards dst, and "tc_dst" to redirect packets 701 + * and "tc_chk" on veth_dst_fwd to drop non-redirected packets. 702 + */ 703 + SYS("tc qdisc add dev tun_fwd clsact"); 704 + SYS("tc filter add dev tun_fwd ingress bpf da object-pinned " 705 + SRC_PROG_PIN_FILE); 706 + 707 + SYS("tc qdisc add dev veth_dst_fwd clsact"); 708 + SYS("tc filter add dev veth_dst_fwd ingress bpf da object-pinned " 709 + DST_PROG_PIN_FILE); 710 + SYS("tc filter add dev veth_dst_fwd egress bpf da object-pinned " 711 + CHK_PROG_PIN_FILE); 712 + 713 + /* Setup route and neigh tables */ 714 + SYS("ip -netns " NS_SRC " addr add dev tun_src " IP4_TUN_SRC "/24"); 715 + SYS("ip -netns " NS_FWD " addr add dev tun_fwd " IP4_TUN_FWD "/24"); 716 + 717 + SYS("ip -netns " NS_SRC " addr add dev tun_src " IP6_TUN_SRC "/64 nodad"); 718 + SYS("ip -netns " NS_FWD " addr add dev tun_fwd " IP6_TUN_FWD "/64 nodad"); 719 + 720 + SYS("ip -netns " NS_SRC " route del " IP4_DST "/32 dev veth_src scope global"); 721 + SYS("ip -netns " NS_SRC " route add " IP4_DST "/32 via " IP4_TUN_FWD 722 + " dev tun_src scope global"); 723 + SYS("ip -netns " NS_DST " route add " IP4_TUN_SRC "/32 dev veth_dst scope global"); 724 + SYS("ip -netns " NS_SRC " route del " IP6_DST "/128 dev veth_src scope global"); 725 + SYS("ip -netns " NS_SRC " route add " IP6_DST "/128 via " IP6_TUN_FWD 726 + " dev tun_src scope global"); 727 + SYS("ip -netns " NS_DST " route add " IP6_TUN_SRC "/128 dev veth_dst scope global"); 728 + 729 + SYS("ip -netns " NS_DST " neigh add " IP4_TUN_SRC " dev veth_dst lladdr " MAC_DST_FWD); 730 + SYS("ip -netns " NS_DST " neigh add " IP6_TUN_SRC " dev veth_dst lladdr " MAC_DST_FWD); 731 + 732 + if (!ASSERT_OK(set_forwarding(false), "disable forwarding")) 733 + goto fail; 734 + 735 + test_connectivity(); 736 + 737 + fail: 738 + if (tunnel_pid > 0) { 739 + kill(tunnel_pid, SIGTERM); 740 + waitpid(tunnel_pid, NULL, 0); 741 + } 742 + if (src_fd >= 0) 743 + close(src_fd); 744 + if (target_fd >= 0) 745 + close(target_fd); 746 + if (skel) 747 + test_tc_peer__destroy(skel); 748 + if (nstoken) 749 + close_netns(nstoken); 750 + } 751 + 752 + #define RUN_TEST(name) \ 753 + ({ \ 754 + struct netns_setup_result setup_result; \ 755 + if (test__start_subtest(#name)) \ 756 + if (ASSERT_OK(netns_setup_namespaces("add"), "setup namespaces")) { \ 757 + if (ASSERT_OK(netns_setup_links_and_routes(&setup_result), \ 758 + "setup links and routes")) \ 759 + test_ ## name(&setup_result); \ 760 + netns_setup_namespaces("delete"); \ 761 + } \ 762 + }) 763 + 764 + static void *test_tc_redirect_run_tests(void *arg) 765 + { 766 + RUN_TEST(tc_redirect_peer); 767 + RUN_TEST(tc_redirect_peer_l3); 768 + RUN_TEST(tc_redirect_neigh); 769 + RUN_TEST(tc_redirect_neigh_fib); 770 + return NULL; 771 + } 772 + 773 + void test_tc_redirect(void) 774 + { 775 + pthread_t test_thread; 776 + int err; 777 + 778 + /* Run the tests in their own thread to isolate the namespace changes 779 + * so they do not affect the environment of other tests. 780 + * (specifically needed because of unshare(CLONE_NEWNS) in open_netns()) 781 + */ 782 + err = pthread_create(&test_thread, NULL, &test_tc_redirect_run_tests, NULL); 783 + if (ASSERT_OK(err, "pthread_create")) 784 + ASSERT_OK(pthread_join(test_thread, NULL), "pthread_join"); 785 + }
+10 -23
tools/testing/selftests/bpf/progs/test_tc_neigh.c
··· 33 33 a.s6_addr32[3] == b.s6_addr32[3]) 34 34 #endif 35 35 36 - enum { 37 - dev_src, 38 - dev_dst, 39 - }; 40 - 41 - struct bpf_map_def SEC("maps") ifindex_map = { 42 - .type = BPF_MAP_TYPE_ARRAY, 43 - .key_size = sizeof(int), 44 - .value_size = sizeof(int), 45 - .max_entries = 2, 46 - }; 36 + volatile const __u32 IFINDEX_SRC; 37 + volatile const __u32 IFINDEX_DST; 47 38 48 39 static __always_inline bool is_remote_ep_v4(struct __sk_buff *skb, 49 40 __be32 addr) ··· 70 79 return v6_equal(ip6h->daddr, addr); 71 80 } 72 81 73 - static __always_inline int get_dev_ifindex(int which) 74 - { 75 - int *ifindex = bpf_map_lookup_elem(&ifindex_map, &which); 76 - 77 - return ifindex ? *ifindex : 0; 78 - } 79 - 80 - SEC("chk_egress") int tc_chk(struct __sk_buff *skb) 82 + SEC("classifier/chk_egress") 83 + int tc_chk(struct __sk_buff *skb) 81 84 { 82 85 void *data_end = ctx_ptr(skb->data_end); 83 86 void *data = ctx_ptr(skb->data); ··· 83 98 return !raw[0] && !raw[1] && !raw[2] ? TC_ACT_SHOT : TC_ACT_OK; 84 99 } 85 100 86 - SEC("dst_ingress") int tc_dst(struct __sk_buff *skb) 101 + SEC("classifier/dst_ingress") 102 + int tc_dst(struct __sk_buff *skb) 87 103 { 88 104 __u8 zero[ETH_ALEN * 2]; 89 105 bool redirect = false; ··· 105 119 if (bpf_skb_store_bytes(skb, 0, &zero, sizeof(zero), 0) < 0) 106 120 return TC_ACT_SHOT; 107 121 108 - return bpf_redirect_neigh(get_dev_ifindex(dev_src), NULL, 0, 0); 122 + return bpf_redirect_neigh(IFINDEX_SRC, NULL, 0, 0); 109 123 } 110 124 111 - SEC("src_ingress") int tc_src(struct __sk_buff *skb) 125 + SEC("classifier/src_ingress") 126 + int tc_src(struct __sk_buff *skb) 112 127 { 113 128 __u8 zero[ETH_ALEN * 2]; 114 129 bool redirect = false; ··· 130 143 if (bpf_skb_store_bytes(skb, 0, &zero, sizeof(zero), 0) < 0) 131 144 return TC_ACT_SHOT; 132 145 133 - return bpf_redirect_neigh(get_dev_ifindex(dev_dst), NULL, 0, 0); 146 + return bpf_redirect_neigh(IFINDEX_DST, NULL, 0, 0); 134 147 } 135 148 136 149 char __license[] SEC("license") = "GPL";
+6 -3
tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c
··· 75 75 return 0; 76 76 } 77 77 78 - SEC("chk_egress") int tc_chk(struct __sk_buff *skb) 78 + SEC("classifier/chk_egress") 79 + int tc_chk(struct __sk_buff *skb) 79 80 { 80 81 void *data_end = ctx_ptr(skb->data_end); 81 82 void *data = ctx_ptr(skb->data); ··· 143 142 /* these are identical, but keep them separate for compatibility with the 144 143 * section names expected by test_tc_redirect.sh 145 144 */ 146 - SEC("dst_ingress") int tc_dst(struct __sk_buff *skb) 145 + SEC("classifier/dst_ingress") 146 + int tc_dst(struct __sk_buff *skb) 147 147 { 148 148 return tc_redir(skb); 149 149 } 150 150 151 - SEC("src_ingress") int tc_src(struct __sk_buff *skb) 151 + SEC("classifier/src_ingress") 152 + int tc_src(struct __sk_buff *skb) 152 153 { 153 154 return tc_redir(skb); 154 155 }
+40 -22
tools/testing/selftests/bpf/progs/test_tc_peer.c
··· 5 5 #include <linux/bpf.h> 6 6 #include <linux/stddef.h> 7 7 #include <linux/pkt_cls.h> 8 + #include <linux/if_ether.h> 9 + #include <linux/ip.h> 8 10 9 11 #include <bpf/bpf_helpers.h> 10 12 11 - enum { 12 - dev_src, 13 - dev_dst, 14 - }; 13 + volatile const __u32 IFINDEX_SRC; 14 + volatile const __u32 IFINDEX_DST; 15 15 16 - struct bpf_map_def SEC("maps") ifindex_map = { 17 - .type = BPF_MAP_TYPE_ARRAY, 18 - .key_size = sizeof(int), 19 - .value_size = sizeof(int), 20 - .max_entries = 2, 21 - }; 16 + static const __u8 src_mac[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55}; 17 + static const __u8 dst_mac[] = {0x00, 0x22, 0x33, 0x44, 0x55, 0x66}; 22 18 23 - static __always_inline int get_dev_ifindex(int which) 24 - { 25 - int *ifindex = bpf_map_lookup_elem(&ifindex_map, &which); 26 - 27 - return ifindex ? *ifindex : 0; 28 - } 29 - 30 - SEC("chk_egress") int tc_chk(struct __sk_buff *skb) 19 + SEC("classifier/chk_egress") 20 + int tc_chk(struct __sk_buff *skb) 31 21 { 32 22 return TC_ACT_SHOT; 33 23 } 34 24 35 - SEC("dst_ingress") int tc_dst(struct __sk_buff *skb) 25 + SEC("classifier/dst_ingress") 26 + int tc_dst(struct __sk_buff *skb) 36 27 { 37 - return bpf_redirect_peer(get_dev_ifindex(dev_src), 0); 28 + return bpf_redirect_peer(IFINDEX_SRC, 0); 38 29 } 39 30 40 - SEC("src_ingress") int tc_src(struct __sk_buff *skb) 31 + SEC("classifier/src_ingress") 32 + int tc_src(struct __sk_buff *skb) 41 33 { 42 - return bpf_redirect_peer(get_dev_ifindex(dev_dst), 0); 34 + return bpf_redirect_peer(IFINDEX_DST, 0); 35 + } 36 + 37 + SEC("classifier/dst_ingress_l3") 38 + int tc_dst_l3(struct __sk_buff *skb) 39 + { 40 + return bpf_redirect(IFINDEX_SRC, 0); 41 + } 42 + 43 + SEC("classifier/src_ingress_l3") 44 + int tc_src_l3(struct __sk_buff *skb) 45 + { 46 + __u16 proto = skb->protocol; 47 + 48 + if (bpf_skb_change_head(skb, ETH_HLEN, 0) != 0) 49 + return TC_ACT_SHOT; 50 + 51 + if (bpf_skb_store_bytes(skb, 0, &src_mac, ETH_ALEN, 0) != 0) 52 + return TC_ACT_SHOT; 53 + 54 + if (bpf_skb_store_bytes(skb, ETH_ALEN, &dst_mac, ETH_ALEN, 0) != 0) 55 + return TC_ACT_SHOT; 56 + 57 + if (bpf_skb_store_bytes(skb, ETH_ALEN + ETH_ALEN, &proto, sizeof(__u16), 0) != 0) 58 + return TC_ACT_SHOT; 59 + 60 + return bpf_redirect_peer(IFINDEX_DST, 0); 43 61 } 44 62 45 63 char __license[] SEC("license") = "GPL";
-216
tools/testing/selftests/bpf/test_tc_redirect.sh
··· 1 - #!/bin/bash 2 - # SPDX-License-Identifier: GPL-2.0 3 - # 4 - # This test sets up 3 netns (src <-> fwd <-> dst). There is no direct veth link 5 - # between src and dst. The netns fwd has veth links to each src and dst. The 6 - # client is in src and server in dst. The test installs a TC BPF program to each 7 - # host facing veth in fwd which calls into i) bpf_redirect_neigh() to perform the 8 - # neigh addr population and redirect or ii) bpf_redirect_peer() for namespace 9 - # switch from ingress side; it also installs a checker prog on the egress side 10 - # to drop unexpected traffic. 11 - 12 - if [[ $EUID -ne 0 ]]; then 13 - echo "This script must be run as root" 14 - echo "FAIL" 15 - exit 1 16 - fi 17 - 18 - # check that needed tools are present 19 - command -v nc >/dev/null 2>&1 || \ 20 - { echo >&2 "nc is not available"; exit 1; } 21 - command -v dd >/dev/null 2>&1 || \ 22 - { echo >&2 "dd is not available"; exit 1; } 23 - command -v timeout >/dev/null 2>&1 || \ 24 - { echo >&2 "timeout is not available"; exit 1; } 25 - command -v ping >/dev/null 2>&1 || \ 26 - { echo >&2 "ping is not available"; exit 1; } 27 - if command -v ping6 >/dev/null 2>&1; then PING6=ping6; else PING6=ping; fi 28 - command -v perl >/dev/null 2>&1 || \ 29 - { echo >&2 "perl is not available"; exit 1; } 30 - command -v jq >/dev/null 2>&1 || \ 31 - { echo >&2 "jq is not available"; exit 1; } 32 - command -v bpftool >/dev/null 2>&1 || \ 33 - { echo >&2 "bpftool is not available"; exit 1; } 34 - 35 - readonly GREEN='\033[0;92m' 36 - readonly RED='\033[0;31m' 37 - readonly NC='\033[0m' # No Color 38 - 39 - readonly PING_ARG="-c 3 -w 10 -q" 40 - 41 - readonly TIMEOUT=10 42 - 43 - readonly NS_SRC="ns-src-$(mktemp -u XXXXXX)" 44 - readonly NS_FWD="ns-fwd-$(mktemp -u XXXXXX)" 45 - readonly NS_DST="ns-dst-$(mktemp -u XXXXXX)" 46 - 47 - readonly IP4_SRC="172.16.1.100" 48 - readonly IP4_DST="172.16.2.100" 49 - 50 - readonly IP6_SRC="::1:dead:beef:cafe" 51 - readonly IP6_DST="::2:dead:beef:cafe" 52 - 53 - readonly IP4_SLL="169.254.0.1" 54 - readonly IP4_DLL="169.254.0.2" 55 - readonly IP4_NET="169.254.0.0" 56 - 57 - netns_cleanup() 58 - { 59 - ip netns del ${NS_SRC} 60 - ip netns del ${NS_FWD} 61 - ip netns del ${NS_DST} 62 - } 63 - 64 - netns_setup() 65 - { 66 - ip netns add "${NS_SRC}" 67 - ip netns add "${NS_FWD}" 68 - ip netns add "${NS_DST}" 69 - 70 - ip link add veth_src type veth peer name veth_src_fwd 71 - ip link add veth_dst type veth peer name veth_dst_fwd 72 - 73 - ip link set veth_src netns ${NS_SRC} 74 - ip link set veth_src_fwd netns ${NS_FWD} 75 - 76 - ip link set veth_dst netns ${NS_DST} 77 - ip link set veth_dst_fwd netns ${NS_FWD} 78 - 79 - ip -netns ${NS_SRC} addr add ${IP4_SRC}/32 dev veth_src 80 - ip -netns ${NS_DST} addr add ${IP4_DST}/32 dev veth_dst 81 - 82 - # The fwd netns automatically get a v6 LL address / routes, but also 83 - # needs v4 one in order to start ARP probing. IP4_NET route is added 84 - # to the endpoints so that the ARP processing will reply. 85 - 86 - ip -netns ${NS_FWD} addr add ${IP4_SLL}/32 dev veth_src_fwd 87 - ip -netns ${NS_FWD} addr add ${IP4_DLL}/32 dev veth_dst_fwd 88 - 89 - ip -netns ${NS_SRC} addr add ${IP6_SRC}/128 dev veth_src nodad 90 - ip -netns ${NS_DST} addr add ${IP6_DST}/128 dev veth_dst nodad 91 - 92 - ip -netns ${NS_SRC} link set dev veth_src up 93 - ip -netns ${NS_FWD} link set dev veth_src_fwd up 94 - 95 - ip -netns ${NS_DST} link set dev veth_dst up 96 - ip -netns ${NS_FWD} link set dev veth_dst_fwd up 97 - 98 - ip -netns ${NS_SRC} route add ${IP4_DST}/32 dev veth_src scope global 99 - ip -netns ${NS_SRC} route add ${IP4_NET}/16 dev veth_src scope global 100 - ip -netns ${NS_FWD} route add ${IP4_SRC}/32 dev veth_src_fwd scope global 101 - 102 - ip -netns ${NS_SRC} route add ${IP6_DST}/128 dev veth_src scope global 103 - ip -netns ${NS_FWD} route add ${IP6_SRC}/128 dev veth_src_fwd scope global 104 - 105 - ip -netns ${NS_DST} route add ${IP4_SRC}/32 dev veth_dst scope global 106 - ip -netns ${NS_DST} route add ${IP4_NET}/16 dev veth_dst scope global 107 - ip -netns ${NS_FWD} route add ${IP4_DST}/32 dev veth_dst_fwd scope global 108 - 109 - ip -netns ${NS_DST} route add ${IP6_SRC}/128 dev veth_dst scope global 110 - ip -netns ${NS_FWD} route add ${IP6_DST}/128 dev veth_dst_fwd scope global 111 - 112 - fmac_src=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_src_fwd/address) 113 - fmac_dst=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_dst_fwd/address) 114 - 115 - ip -netns ${NS_SRC} neigh add ${IP4_DST} dev veth_src lladdr $fmac_src 116 - ip -netns ${NS_DST} neigh add ${IP4_SRC} dev veth_dst lladdr $fmac_dst 117 - 118 - ip -netns ${NS_SRC} neigh add ${IP6_DST} dev veth_src lladdr $fmac_src 119 - ip -netns ${NS_DST} neigh add ${IP6_SRC} dev veth_dst lladdr $fmac_dst 120 - } 121 - 122 - netns_test_connectivity() 123 - { 124 - set +e 125 - 126 - ip netns exec ${NS_DST} bash -c "nc -4 -l -p 9004 &" 127 - ip netns exec ${NS_DST} bash -c "nc -6 -l -p 9006 &" 128 - 129 - TEST="TCPv4 connectivity test" 130 - ip netns exec ${NS_SRC} bash -c "timeout ${TIMEOUT} dd if=/dev/zero bs=1000 count=100 > /dev/tcp/${IP4_DST}/9004" 131 - if [ $? -ne 0 ]; then 132 - echo -e "${TEST}: ${RED}FAIL${NC}" 133 - exit 1 134 - fi 135 - echo -e "${TEST}: ${GREEN}PASS${NC}" 136 - 137 - TEST="TCPv6 connectivity test" 138 - ip netns exec ${NS_SRC} bash -c "timeout ${TIMEOUT} dd if=/dev/zero bs=1000 count=100 > /dev/tcp/${IP6_DST}/9006" 139 - if [ $? -ne 0 ]; then 140 - echo -e "${TEST}: ${RED}FAIL${NC}" 141 - exit 1 142 - fi 143 - echo -e "${TEST}: ${GREEN}PASS${NC}" 144 - 145 - TEST="ICMPv4 connectivity test" 146 - ip netns exec ${NS_SRC} ping $PING_ARG ${IP4_DST} 147 - if [ $? -ne 0 ]; then 148 - echo -e "${TEST}: ${RED}FAIL${NC}" 149 - exit 1 150 - fi 151 - echo -e "${TEST}: ${GREEN}PASS${NC}" 152 - 153 - TEST="ICMPv6 connectivity test" 154 - ip netns exec ${NS_SRC} $PING6 $PING_ARG ${IP6_DST} 155 - if [ $? -ne 0 ]; then 156 - echo -e "${TEST}: ${RED}FAIL${NC}" 157 - exit 1 158 - fi 159 - echo -e "${TEST}: ${GREEN}PASS${NC}" 160 - 161 - set -e 162 - } 163 - 164 - hex_mem_str() 165 - { 166 - perl -e 'print join(" ", unpack("(H2)8", pack("L", @ARGV)))' $1 167 - } 168 - 169 - netns_setup_bpf() 170 - { 171 - local obj=$1 172 - local use_forwarding=${2:-0} 173 - 174 - ip netns exec ${NS_FWD} tc qdisc add dev veth_src_fwd clsact 175 - ip netns exec ${NS_FWD} tc filter add dev veth_src_fwd ingress bpf da obj $obj sec src_ingress 176 - ip netns exec ${NS_FWD} tc filter add dev veth_src_fwd egress bpf da obj $obj sec chk_egress 177 - 178 - ip netns exec ${NS_FWD} tc qdisc add dev veth_dst_fwd clsact 179 - ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd ingress bpf da obj $obj sec dst_ingress 180 - ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd egress bpf da obj $obj sec chk_egress 181 - 182 - if [ "$use_forwarding" -eq "1" ]; then 183 - # bpf_fib_lookup() checks if forwarding is enabled 184 - ip netns exec ${NS_FWD} sysctl -w net.ipv4.ip_forward=1 185 - ip netns exec ${NS_FWD} sysctl -w net.ipv6.conf.veth_dst_fwd.forwarding=1 186 - ip netns exec ${NS_FWD} sysctl -w net.ipv6.conf.veth_src_fwd.forwarding=1 187 - return 0 188 - fi 189 - 190 - veth_src=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_src_fwd/ifindex) 191 - veth_dst=$(ip netns exec ${NS_FWD} cat /sys/class/net/veth_dst_fwd/ifindex) 192 - 193 - progs=$(ip netns exec ${NS_FWD} bpftool net --json | jq -r '.[] | .tc | map(.id) | .[]') 194 - for prog in $progs; do 195 - map=$(bpftool prog show id $prog --json | jq -r '.map_ids | .? | .[]') 196 - if [ ! -z "$map" ]; then 197 - bpftool map update id $map key hex $(hex_mem_str 0) value hex $(hex_mem_str $veth_src) 198 - bpftool map update id $map key hex $(hex_mem_str 1) value hex $(hex_mem_str $veth_dst) 199 - fi 200 - done 201 - } 202 - 203 - trap netns_cleanup EXIT 204 - set -e 205 - 206 - netns_setup 207 - netns_setup_bpf test_tc_neigh.o 208 - netns_test_connectivity 209 - netns_cleanup 210 - netns_setup 211 - netns_setup_bpf test_tc_neigh_fib.o 1 212 - netns_test_connectivity 213 - netns_cleanup 214 - netns_setup 215 - netns_setup_bpf test_tc_peer.o 216 - netns_test_connectivity
-2
tools/testing/selftests/bpf/verifier/stack_ptr.c
··· 295 295 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 0), 296 296 BPF_EXIT_INSN(), 297 297 }, 298 - .result_unpriv = REJECT, 299 - .errstr_unpriv = "invalid write to stack R1 off=0 size=1", 300 298 .result = ACCEPT, 301 299 .retval = 42, 302 300 },
-8
tools/testing/selftests/bpf/verifier/value_ptr_arith.c
··· 300 300 }, 301 301 .fixup_map_array_48b = { 3 }, 302 302 .result = ACCEPT, 303 - .result_unpriv = REJECT, 304 - .errstr_unpriv = "R0 pointer arithmetic of map value goes out of range", 305 303 .retval = 1, 306 304 }, 307 305 { ··· 369 371 }, 370 372 .fixup_map_array_48b = { 3 }, 371 373 .result = ACCEPT, 372 - .result_unpriv = REJECT, 373 - .errstr_unpriv = "R0 pointer arithmetic of map value goes out of range", 374 374 .retval = 1, 375 375 }, 376 376 { ··· 468 472 }, 469 473 .fixup_map_array_48b = { 3 }, 470 474 .result = ACCEPT, 471 - .result_unpriv = REJECT, 472 - .errstr_unpriv = "R0 pointer arithmetic of map value goes out of range", 473 475 .retval = 1, 474 476 }, 475 477 { ··· 760 766 }, 761 767 .fixup_map_array_48b = { 3 }, 762 768 .result = ACCEPT, 763 - .result_unpriv = REJECT, 764 - .errstr_unpriv = "R0 pointer arithmetic of map value goes out of range", 765 769 .retval = 1, 766 770 }, 767 771 {
+1
tools/testing/selftests/kvm/.gitignore
··· 41 41 /kvm_create_max_vcpus 42 42 /kvm_page_table_test 43 43 /memslot_modification_stress_test 44 + /memslot_perf_test 44 45 /set_memory_region_test 45 46 /steal_time
+2 -1
tools/testing/selftests/kvm/Makefile
··· 33 33 UNAME_M := s390x 34 34 endif 35 35 36 - LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/sparsebit.c lib/test_util.c lib/guest_modes.c lib/perf_test_util.c 36 + LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/rbtree.c lib/sparsebit.c lib/test_util.c lib/guest_modes.c lib/perf_test_util.c 37 37 LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c lib/x86_64/svm.c lib/x86_64/ucall.c lib/x86_64/handlers.S 38 38 LIBKVM_aarch64 = lib/aarch64/processor.c lib/aarch64/ucall.c 39 39 LIBKVM_s390x = lib/s390x/processor.c lib/s390x/ucall.c lib/s390x/diag318_test_handler.c ··· 74 74 TEST_GEN_PROGS_x86_64 += kvm_create_max_vcpus 75 75 TEST_GEN_PROGS_x86_64 += kvm_page_table_test 76 76 TEST_GEN_PROGS_x86_64 += memslot_modification_stress_test 77 + TEST_GEN_PROGS_x86_64 += memslot_perf_test 77 78 TEST_GEN_PROGS_x86_64 += set_memory_region_test 78 79 TEST_GEN_PROGS_x86_64 += steal_time 79 80
+110 -66
tools/testing/selftests/kvm/demand_paging_test.c
··· 9 9 10 10 #define _GNU_SOURCE /* for pipe2 */ 11 11 12 + #include <inttypes.h> 12 13 #include <stdio.h> 13 14 #include <stdlib.h> 14 15 #include <time.h> ··· 39 38 40 39 static int nr_vcpus = 1; 41 40 static uint64_t guest_percpu_mem_size = DEFAULT_PER_VCPU_MEM_SIZE; 41 + static size_t demand_paging_size; 42 42 static char *guest_data_prototype; 43 43 44 44 static void *vcpu_worker(void *data) ··· 73 71 return NULL; 74 72 } 75 73 76 - static int handle_uffd_page_request(int uffd, uint64_t addr) 74 + static int handle_uffd_page_request(int uffd_mode, int uffd, uint64_t addr) 77 75 { 78 - pid_t tid; 76 + pid_t tid = syscall(__NR_gettid); 79 77 struct timespec start; 80 78 struct timespec ts_diff; 81 - struct uffdio_copy copy; 82 79 int r; 83 - 84 - tid = syscall(__NR_gettid); 85 - 86 - copy.src = (uint64_t)guest_data_prototype; 87 - copy.dst = addr; 88 - copy.len = perf_test_args.host_page_size; 89 - copy.mode = 0; 90 80 91 81 clock_gettime(CLOCK_MONOTONIC, &start); 92 82 93 - r = ioctl(uffd, UFFDIO_COPY, &copy); 94 - if (r == -1) { 95 - pr_info("Failed Paged in 0x%lx from thread %d with errno: %d\n", 96 - addr, tid, errno); 97 - return r; 83 + if (uffd_mode == UFFDIO_REGISTER_MODE_MISSING) { 84 + struct uffdio_copy copy; 85 + 86 + copy.src = (uint64_t)guest_data_prototype; 87 + copy.dst = addr; 88 + copy.len = demand_paging_size; 89 + copy.mode = 0; 90 + 91 + r = ioctl(uffd, UFFDIO_COPY, &copy); 92 + if (r == -1) { 93 + pr_info("Failed UFFDIO_COPY in 0x%lx from thread %d with errno: %d\n", 94 + addr, tid, errno); 95 + return r; 96 + } 97 + } else if (uffd_mode == UFFDIO_REGISTER_MODE_MINOR) { 98 + struct uffdio_continue cont = {0}; 99 + 100 + cont.range.start = addr; 101 + cont.range.len = demand_paging_size; 102 + 103 + r = ioctl(uffd, UFFDIO_CONTINUE, &cont); 104 + if (r == -1) { 105 + pr_info("Failed UFFDIO_CONTINUE in 0x%lx from thread %d with errno: %d\n", 106 + addr, tid, errno); 107 + return r; 108 + } 109 + } else { 110 + TEST_FAIL("Invalid uffd mode %d", uffd_mode); 98 111 } 99 112 100 113 ts_diff = timespec_elapsed(start); 101 114 102 - PER_PAGE_DEBUG("UFFDIO_COPY %d \t%ld ns\n", tid, 115 + PER_PAGE_DEBUG("UFFD page-in %d \t%ld ns\n", tid, 103 116 timespec_to_ns(ts_diff)); 104 117 PER_PAGE_DEBUG("Paged in %ld bytes at 0x%lx from thread %d\n", 105 - perf_test_args.host_page_size, addr, tid); 118 + demand_paging_size, addr, tid); 106 119 107 120 return 0; 108 121 } ··· 125 108 bool quit_uffd_thread; 126 109 127 110 struct uffd_handler_args { 111 + int uffd_mode; 128 112 int uffd; 129 113 int pipefd; 130 114 useconds_t delay; ··· 187 169 if (r == -1) { 188 170 if (errno == EAGAIN) 189 171 continue; 190 - pr_info("Read of uffd gor errno %d", errno); 172 + pr_info("Read of uffd got errno %d\n", errno); 191 173 return NULL; 192 174 } 193 175 ··· 202 184 if (delay) 203 185 usleep(delay); 204 186 addr = msg.arg.pagefault.address; 205 - r = handle_uffd_page_request(uffd, addr); 187 + r = handle_uffd_page_request(uffd_args->uffd_mode, uffd, addr); 206 188 if (r < 0) 207 189 return NULL; 208 190 pages++; ··· 216 198 return NULL; 217 199 } 218 200 219 - static int setup_demand_paging(struct kvm_vm *vm, 220 - pthread_t *uffd_handler_thread, int pipefd, 221 - useconds_t uffd_delay, 222 - struct uffd_handler_args *uffd_args, 223 - void *hva, uint64_t len) 201 + static void setup_demand_paging(struct kvm_vm *vm, 202 + pthread_t *uffd_handler_thread, int pipefd, 203 + int uffd_mode, useconds_t uffd_delay, 204 + struct uffd_handler_args *uffd_args, 205 + void *hva, void *alias, uint64_t len) 224 206 { 207 + bool is_minor = (uffd_mode == UFFDIO_REGISTER_MODE_MINOR); 225 208 int uffd; 226 209 struct uffdio_api uffdio_api; 227 210 struct uffdio_register uffdio_register; 211 + uint64_t expected_ioctls = ((uint64_t) 1) << _UFFDIO_COPY; 212 + 213 + PER_PAGE_DEBUG("Userfaultfd %s mode, faults resolved with %s\n", 214 + is_minor ? "MINOR" : "MISSING", 215 + is_minor ? "UFFDIO_CONINUE" : "UFFDIO_COPY"); 216 + 217 + /* In order to get minor faults, prefault via the alias. */ 218 + if (is_minor) { 219 + size_t p; 220 + 221 + expected_ioctls = ((uint64_t) 1) << _UFFDIO_CONTINUE; 222 + 223 + TEST_ASSERT(alias != NULL, "Alias required for minor faults"); 224 + for (p = 0; p < (len / demand_paging_size); ++p) { 225 + memcpy(alias + (p * demand_paging_size), 226 + guest_data_prototype, demand_paging_size); 227 + } 228 + } 228 229 229 230 uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK); 230 - if (uffd == -1) { 231 - pr_info("uffd creation failed\n"); 232 - return -1; 233 - } 231 + TEST_ASSERT(uffd >= 0, "uffd creation failed, errno: %d", errno); 234 232 235 233 uffdio_api.api = UFFD_API; 236 234 uffdio_api.features = 0; 237 - if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1) { 238 - pr_info("ioctl uffdio_api failed\n"); 239 - return -1; 240 - } 235 + TEST_ASSERT(ioctl(uffd, UFFDIO_API, &uffdio_api) != -1, 236 + "ioctl UFFDIO_API failed: %" PRIu64, 237 + (uint64_t)uffdio_api.api); 241 238 242 239 uffdio_register.range.start = (uint64_t)hva; 243 240 uffdio_register.range.len = len; 244 - uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING; 245 - if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1) { 246 - pr_info("ioctl uffdio_register failed\n"); 247 - return -1; 248 - } 241 + uffdio_register.mode = uffd_mode; 242 + TEST_ASSERT(ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) != -1, 243 + "ioctl UFFDIO_REGISTER failed"); 244 + TEST_ASSERT((uffdio_register.ioctls & expected_ioctls) == 245 + expected_ioctls, "missing userfaultfd ioctls"); 249 246 250 - if ((uffdio_register.ioctls & UFFD_API_RANGE_IOCTLS) != 251 - UFFD_API_RANGE_IOCTLS) { 252 - pr_info("unexpected userfaultfd ioctl set\n"); 253 - return -1; 254 - } 255 - 247 + uffd_args->uffd_mode = uffd_mode; 256 248 uffd_args->uffd = uffd; 257 249 uffd_args->pipefd = pipefd; 258 250 uffd_args->delay = uffd_delay; ··· 271 243 272 244 PER_VCPU_DEBUG("Created uffd thread for HVA range [%p, %p)\n", 273 245 hva, hva + len); 274 - 275 - return 0; 276 246 } 277 247 278 248 struct test_params { 279 - bool use_uffd; 249 + int uffd_mode; 280 250 useconds_t uffd_delay; 251 + enum vm_mem_backing_src_type src_type; 281 252 bool partition_vcpu_memory_access; 282 253 }; 283 254 ··· 294 267 int r; 295 268 296 269 vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size, 297 - VM_MEM_SRC_ANONYMOUS); 270 + p->src_type); 298 271 299 272 perf_test_args.wr_fract = 1; 300 273 301 - guest_data_prototype = malloc(perf_test_args.host_page_size); 274 + demand_paging_size = get_backing_src_pagesz(p->src_type); 275 + 276 + guest_data_prototype = malloc(demand_paging_size); 302 277 TEST_ASSERT(guest_data_prototype, 303 278 "Failed to allocate buffer for guest data pattern"); 304 - memset(guest_data_prototype, 0xAB, perf_test_args.host_page_size); 279 + memset(guest_data_prototype, 0xAB, demand_paging_size); 305 280 306 281 vcpu_threads = malloc(nr_vcpus * sizeof(*vcpu_threads)); 307 282 TEST_ASSERT(vcpu_threads, "Memory allocation failed"); ··· 311 282 perf_test_setup_vcpus(vm, nr_vcpus, guest_percpu_mem_size, 312 283 p->partition_vcpu_memory_access); 313 284 314 - if (p->use_uffd) { 285 + if (p->uffd_mode) { 315 286 uffd_handler_threads = 316 287 malloc(nr_vcpus * sizeof(*uffd_handler_threads)); 317 288 TEST_ASSERT(uffd_handler_threads, "Memory allocation failed"); ··· 325 296 for (vcpu_id = 0; vcpu_id < nr_vcpus; vcpu_id++) { 326 297 vm_paddr_t vcpu_gpa; 327 298 void *vcpu_hva; 299 + void *vcpu_alias; 328 300 uint64_t vcpu_mem_size; 329 301 330 302 ··· 340 310 PER_VCPU_DEBUG("Added VCPU %d with test mem gpa [%lx, %lx)\n", 341 311 vcpu_id, vcpu_gpa, vcpu_gpa + vcpu_mem_size); 342 312 343 - /* Cache the HVA pointer of the region */ 313 + /* Cache the host addresses of the region */ 344 314 vcpu_hva = addr_gpa2hva(vm, vcpu_gpa); 315 + vcpu_alias = addr_gpa2alias(vm, vcpu_gpa); 345 316 346 317 /* 347 318 * Set up user fault fd to handle demand paging ··· 352 321 O_CLOEXEC | O_NONBLOCK); 353 322 TEST_ASSERT(!r, "Failed to set up pipefd"); 354 323 355 - r = setup_demand_paging(vm, 356 - &uffd_handler_threads[vcpu_id], 357 - pipefds[vcpu_id * 2], 358 - p->uffd_delay, &uffd_args[vcpu_id], 359 - vcpu_hva, vcpu_mem_size); 360 - if (r < 0) 361 - exit(-r); 324 + setup_demand_paging(vm, &uffd_handler_threads[vcpu_id], 325 + pipefds[vcpu_id * 2], p->uffd_mode, 326 + p->uffd_delay, &uffd_args[vcpu_id], 327 + vcpu_hva, vcpu_alias, 328 + vcpu_mem_size); 362 329 } 363 330 } 364 331 ··· 384 355 385 356 pr_info("All vCPU threads joined\n"); 386 357 387 - if (p->use_uffd) { 358 + if (p->uffd_mode) { 388 359 char c; 389 360 390 361 /* Tell the user fault fd handler threads to quit */ ··· 406 377 407 378 free(guest_data_prototype); 408 379 free(vcpu_threads); 409 - if (p->use_uffd) { 380 + if (p->uffd_mode) { 410 381 free(uffd_handler_threads); 411 382 free(uffd_args); 412 383 free(pipefds); ··· 416 387 static void help(char *name) 417 388 { 418 389 puts(""); 419 - printf("usage: %s [-h] [-m mode] [-u] [-d uffd_delay_usec]\n" 420 - " [-b memory] [-v vcpus] [-o]\n", name); 390 + printf("usage: %s [-h] [-m vm_mode] [-u uffd_mode] [-d uffd_delay_usec]\n" 391 + " [-b memory] [-t type] [-v vcpus] [-o]\n", name); 421 392 guest_modes_help(); 422 - printf(" -u: use User Fault FD to handle vCPU page\n" 423 - " faults.\n"); 393 + printf(" -u: use userfaultfd to handle vCPU page faults. Mode is a\n" 394 + " UFFD registration mode: 'MISSING' or 'MINOR'.\n"); 424 395 printf(" -d: add a delay in usec to the User Fault\n" 425 396 " FD handler to simulate demand paging\n" 426 397 " overheads. Ignored without -u.\n"); 427 398 printf(" -b: specify the size of the memory region which should be\n" 428 399 " demand paged by each vCPU. e.g. 10M or 3G.\n" 429 400 " Default: 1G\n"); 401 + printf(" -t: The type of backing memory to use. Default: anonymous\n"); 402 + backing_src_help(); 430 403 printf(" -v: specify the number of vCPUs to run.\n"); 431 404 printf(" -o: Overlap guest memory accesses instead of partitioning\n" 432 405 " them into a separate region of memory for each vCPU.\n"); ··· 440 409 { 441 410 int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS); 442 411 struct test_params p = { 412 + .src_type = VM_MEM_SRC_ANONYMOUS, 443 413 .partition_vcpu_memory_access = true, 444 414 }; 445 415 int opt; 446 416 447 417 guest_modes_append_default(); 448 418 449 - while ((opt = getopt(argc, argv, "hm:ud:b:v:o")) != -1) { 419 + while ((opt = getopt(argc, argv, "hm:u:d:b:t:v:o")) != -1) { 450 420 switch (opt) { 451 421 case 'm': 452 422 guest_modes_cmdline(optarg); 453 423 break; 454 424 case 'u': 455 - p.use_uffd = true; 425 + if (!strcmp("MISSING", optarg)) 426 + p.uffd_mode = UFFDIO_REGISTER_MODE_MISSING; 427 + else if (!strcmp("MINOR", optarg)) 428 + p.uffd_mode = UFFDIO_REGISTER_MODE_MINOR; 429 + TEST_ASSERT(p.uffd_mode, "UFFD mode must be 'MISSING' or 'MINOR'."); 456 430 break; 457 431 case 'd': 458 432 p.uffd_delay = strtoul(optarg, NULL, 0); ··· 465 429 break; 466 430 case 'b': 467 431 guest_percpu_mem_size = parse_size(optarg); 432 + break; 433 + case 't': 434 + p.src_type = parse_backing_src_type(optarg); 468 435 break; 469 436 case 'v': 470 437 nr_vcpus = atoi(optarg); ··· 482 443 help(argv[0]); 483 444 break; 484 445 } 446 + } 447 + 448 + if (p.uffd_mode == UFFDIO_REGISTER_MODE_MINOR && 449 + !backing_src_is_shared(p.src_type)) { 450 + TEST_FAIL("userfaultfd MINOR mode requires shared memory; pick a different -t"); 485 451 } 486 452 487 453 for_each_guest_mode(run_test, &p);
+31 -1
tools/testing/selftests/kvm/hardware_disable_test.c
··· 132 132 TEST_ASSERT(false, "%s: [%d] child escaped the ninja\n", __func__, run); 133 133 } 134 134 135 + void wait_for_child_setup(pid_t pid) 136 + { 137 + /* 138 + * Wait for the child to post to the semaphore, but wake up periodically 139 + * to check if the child exited prematurely. 140 + */ 141 + for (;;) { 142 + const struct timespec wait_period = { .tv_sec = 1 }; 143 + int status; 144 + 145 + if (!sem_timedwait(sem, &wait_period)) 146 + return; 147 + 148 + /* Child is still running, keep waiting. */ 149 + if (pid != waitpid(pid, &status, WNOHANG)) 150 + continue; 151 + 152 + /* 153 + * Child is no longer running, which is not expected. 154 + * 155 + * If it exited with a non-zero status, we explicitly forward 156 + * the child's status in case it exited with KSFT_SKIP. 157 + */ 158 + if (WIFEXITED(status)) 159 + exit(WEXITSTATUS(status)); 160 + else 161 + TEST_ASSERT(false, "Child exited unexpectedly"); 162 + } 163 + } 164 + 135 165 int main(int argc, char **argv) 136 166 { 137 167 uint32_t i; ··· 178 148 run_test(i); /* This function always exits */ 179 149 180 150 pr_debug("%s: [%d] waiting semaphore\n", __func__, i); 181 - sem_wait(sem); 151 + wait_for_child_setup(pid); 182 152 r = (rand() % DELAY_US_MAX) + 1; 183 153 pr_debug("%s: [%d] waiting %dus\n", __func__, i, r); 184 154 usleep(r);
+3 -1
tools/testing/selftests/kvm/include/kvm_util.h
··· 77 77 }; 78 78 extern const struct vm_guest_mode_params vm_guest_mode_params[]; 79 79 80 + int open_kvm_dev_path_or_exit(void); 80 81 int kvm_check_cap(long cap); 81 82 int vm_enable_cap(struct kvm_vm *vm, struct kvm_enable_cap *cap); 82 83 int vcpu_enable_cap(struct kvm_vm *vm, uint32_t vcpu_id, ··· 147 146 void *addr_gpa2hva(struct kvm_vm *vm, vm_paddr_t gpa); 148 147 void *addr_gva2hva(struct kvm_vm *vm, vm_vaddr_t gva); 149 148 vm_paddr_t addr_hva2gpa(struct kvm_vm *vm, void *hva); 149 + void *addr_gpa2alias(struct kvm_vm *vm, vm_paddr_t gpa); 150 150 151 151 /* 152 152 * Address Guest Virtual to Guest Physical ··· 304 302 305 303 unsigned int vm_get_page_size(struct kvm_vm *vm); 306 304 unsigned int vm_get_page_shift(struct kvm_vm *vm); 307 - unsigned int vm_get_max_gfn(struct kvm_vm *vm); 305 + uint64_t vm_get_max_gfn(struct kvm_vm *vm); 308 306 int vm_get_fd(struct kvm_vm *vm); 309 307 310 308 unsigned int vm_calc_num_guest_pages(enum vm_guest_mode mode, size_t size);
+12
tools/testing/selftests/kvm/include/test_util.h
··· 17 17 #include <errno.h> 18 18 #include <unistd.h> 19 19 #include <fcntl.h> 20 + #include <sys/mman.h> 20 21 #include "kselftest.h" 21 22 22 23 static inline int _no_printf(const char *format, ...) { return 0; } ··· 85 84 VM_MEM_SRC_ANONYMOUS_HUGETLB_1GB, 86 85 VM_MEM_SRC_ANONYMOUS_HUGETLB_2GB, 87 86 VM_MEM_SRC_ANONYMOUS_HUGETLB_16GB, 87 + VM_MEM_SRC_SHMEM, 88 + VM_MEM_SRC_SHARED_HUGETLB, 88 89 NUM_SRC_TYPES, 89 90 }; 90 91 ··· 102 99 size_t get_backing_src_pagesz(uint32_t i); 103 100 void backing_src_help(void); 104 101 enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name); 102 + 103 + /* 104 + * Whether or not the given source type is shared memory (as opposed to 105 + * anonymous). 106 + */ 107 + static inline bool backing_src_is_shared(enum vm_mem_backing_src_type t) 108 + { 109 + return vm_mem_backing_src_alias(t)->flag & MAP_SHARED; 110 + } 105 111 106 112 #endif /* SELFTEST_KVM_TEST_UTIL_H */
+220 -58
tools/testing/selftests/kvm/lib/kvm_util.c
··· 32 32 } 33 33 34 34 /* 35 + * Open KVM_DEV_PATH if available, otherwise exit the entire program. 36 + * 37 + * Input Args: 38 + * flags - The flags to pass when opening KVM_DEV_PATH. 39 + * 40 + * Return: 41 + * The opened file descriptor of /dev/kvm. 42 + */ 43 + static int _open_kvm_dev_path_or_exit(int flags) 44 + { 45 + int fd; 46 + 47 + fd = open(KVM_DEV_PATH, flags); 48 + if (fd < 0) { 49 + print_skip("%s not available, is KVM loaded? (errno: %d)", 50 + KVM_DEV_PATH, errno); 51 + exit(KSFT_SKIP); 52 + } 53 + 54 + return fd; 55 + } 56 + 57 + int open_kvm_dev_path_or_exit(void) 58 + { 59 + return _open_kvm_dev_path_or_exit(O_RDONLY); 60 + } 61 + 62 + /* 35 63 * Capability 36 64 * 37 65 * Input Args: ··· 80 52 int ret; 81 53 int kvm_fd; 82 54 83 - kvm_fd = open(KVM_DEV_PATH, O_RDONLY); 84 - if (kvm_fd < 0) 85 - exit(KSFT_SKIP); 86 - 55 + kvm_fd = open_kvm_dev_path_or_exit(); 87 56 ret = ioctl(kvm_fd, KVM_CHECK_EXTENSION, cap); 88 57 TEST_ASSERT(ret != -1, "KVM_CHECK_EXTENSION IOCTL failed,\n" 89 58 " rc: %i errno: %i", ret, errno); ··· 153 128 154 129 static void vm_open(struct kvm_vm *vm, int perm) 155 130 { 156 - vm->kvm_fd = open(KVM_DEV_PATH, perm); 157 - if (vm->kvm_fd < 0) 158 - exit(KSFT_SKIP); 131 + vm->kvm_fd = _open_kvm_dev_path_or_exit(perm); 159 132 160 133 if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) { 161 134 print_skip("immediate_exit not available"); ··· 226 203 TEST_ASSERT(vm != NULL, "Insufficient Memory"); 227 204 228 205 INIT_LIST_HEAD(&vm->vcpus); 229 - INIT_LIST_HEAD(&vm->userspace_mem_regions); 206 + vm->regions.gpa_tree = RB_ROOT; 207 + vm->regions.hva_tree = RB_ROOT; 208 + hash_init(vm->regions.slot_hash); 230 209 231 210 vm->mode = mode; 232 211 vm->type = 0; ··· 320 295 */ 321 296 uint64_t vcpu_pages = (DEFAULT_STACK_PGS + num_percpu_pages) * nr_vcpus; 322 297 uint64_t extra_pg_pages = (extra_mem_pages + vcpu_pages) / PTES_PER_MIN_PAGE * 2; 323 - uint64_t pages = DEFAULT_GUEST_PHY_PAGES + vcpu_pages + extra_pg_pages; 298 + uint64_t pages = DEFAULT_GUEST_PHY_PAGES + extra_mem_pages + vcpu_pages + extra_pg_pages; 324 299 struct kvm_vm *vm; 325 300 int i; 326 301 ··· 380 355 */ 381 356 void kvm_vm_restart(struct kvm_vm *vmp, int perm) 382 357 { 358 + int ctr; 383 359 struct userspace_mem_region *region; 384 360 385 361 vm_open(vmp, perm); 386 362 if (vmp->has_irqchip) 387 363 vm_create_irqchip(vmp); 388 364 389 - list_for_each_entry(region, &vmp->userspace_mem_regions, list) { 365 + hash_for_each(vmp->regions.slot_hash, ctr, region, slot_node) { 390 366 int ret = ioctl(vmp->fd, KVM_SET_USER_MEMORY_REGION, &region->region); 391 367 TEST_ASSERT(ret == 0, "KVM_SET_USER_MEMORY_REGION IOCTL failed,\n" 392 368 " rc: %i errno: %i\n" ··· 450 424 static struct userspace_mem_region * 451 425 userspace_mem_region_find(struct kvm_vm *vm, uint64_t start, uint64_t end) 452 426 { 453 - struct userspace_mem_region *region; 427 + struct rb_node *node; 454 428 455 - list_for_each_entry(region, &vm->userspace_mem_regions, list) { 429 + for (node = vm->regions.gpa_tree.rb_node; node; ) { 430 + struct userspace_mem_region *region = 431 + container_of(node, struct userspace_mem_region, gpa_node); 456 432 uint64_t existing_start = region->region.guest_phys_addr; 457 433 uint64_t existing_end = region->region.guest_phys_addr 458 434 + region->region.memory_size - 1; 459 435 if (start <= existing_end && end >= existing_start) 460 436 return region; 437 + 438 + if (start < existing_start) 439 + node = node->rb_left; 440 + else 441 + node = node->rb_right; 461 442 } 462 443 463 444 return NULL; ··· 579 546 } 580 547 581 548 static void __vm_mem_region_delete(struct kvm_vm *vm, 582 - struct userspace_mem_region *region) 549 + struct userspace_mem_region *region, 550 + bool unlink) 583 551 { 584 552 int ret; 585 553 586 - list_del(&region->list); 554 + if (unlink) { 555 + rb_erase(&region->gpa_node, &vm->regions.gpa_tree); 556 + rb_erase(&region->hva_node, &vm->regions.hva_tree); 557 + hash_del(&region->slot_node); 558 + } 587 559 588 560 region->region.memory_size = 0; 589 561 ret = ioctl(vm->fd, KVM_SET_USER_MEMORY_REGION, &region->region); ··· 607 569 */ 608 570 void kvm_vm_free(struct kvm_vm *vmp) 609 571 { 610 - struct userspace_mem_region *region, *tmp; 572 + int ctr; 573 + struct hlist_node *node; 574 + struct userspace_mem_region *region; 611 575 612 576 if (vmp == NULL) 613 577 return; 614 578 615 579 /* Free userspace_mem_regions. */ 616 - list_for_each_entry_safe(region, tmp, &vmp->userspace_mem_regions, list) 617 - __vm_mem_region_delete(vmp, region); 580 + hash_for_each_safe(vmp->regions.slot_hash, ctr, node, region, slot_node) 581 + __vm_mem_region_delete(vmp, region, false); 618 582 619 583 /* Free sparsebit arrays. */ 620 584 sparsebit_free(&vmp->vpages_valid); ··· 698 658 return 0; 699 659 } 700 660 661 + static void vm_userspace_mem_region_gpa_insert(struct rb_root *gpa_tree, 662 + struct userspace_mem_region *region) 663 + { 664 + struct rb_node **cur, *parent; 665 + 666 + for (cur = &gpa_tree->rb_node, parent = NULL; *cur; ) { 667 + struct userspace_mem_region *cregion; 668 + 669 + cregion = container_of(*cur, typeof(*cregion), gpa_node); 670 + parent = *cur; 671 + if (region->region.guest_phys_addr < 672 + cregion->region.guest_phys_addr) 673 + cur = &(*cur)->rb_left; 674 + else { 675 + TEST_ASSERT(region->region.guest_phys_addr != 676 + cregion->region.guest_phys_addr, 677 + "Duplicate GPA in region tree"); 678 + 679 + cur = &(*cur)->rb_right; 680 + } 681 + } 682 + 683 + rb_link_node(&region->gpa_node, parent, cur); 684 + rb_insert_color(&region->gpa_node, gpa_tree); 685 + } 686 + 687 + static void vm_userspace_mem_region_hva_insert(struct rb_root *hva_tree, 688 + struct userspace_mem_region *region) 689 + { 690 + struct rb_node **cur, *parent; 691 + 692 + for (cur = &hva_tree->rb_node, parent = NULL; *cur; ) { 693 + struct userspace_mem_region *cregion; 694 + 695 + cregion = container_of(*cur, typeof(*cregion), hva_node); 696 + parent = *cur; 697 + if (region->host_mem < cregion->host_mem) 698 + cur = &(*cur)->rb_left; 699 + else { 700 + TEST_ASSERT(region->host_mem != 701 + cregion->host_mem, 702 + "Duplicate HVA in region tree"); 703 + 704 + cur = &(*cur)->rb_right; 705 + } 706 + } 707 + 708 + rb_link_node(&region->hva_node, parent, cur); 709 + rb_insert_color(&region->hva_node, hva_tree); 710 + } 711 + 701 712 /* 702 713 * VM Userspace Memory Region Add 703 714 * 704 715 * Input Args: 705 716 * vm - Virtual Machine 706 - * backing_src - Storage source for this region. 707 - * NULL to use anonymous memory. 717 + * src_type - Storage source for this region. 718 + * NULL to use anonymous memory. 708 719 * guest_paddr - Starting guest physical address 709 720 * slot - KVM region slot 710 721 * npages - Number of physical pages ··· 813 722 (uint64_t) region->region.memory_size); 814 723 815 724 /* Confirm no region with the requested slot already exists. */ 816 - list_for_each_entry(region, &vm->userspace_mem_regions, list) { 725 + hash_for_each_possible(vm->regions.slot_hash, region, slot_node, 726 + slot) { 817 727 if (region->region.slot != slot) 818 728 continue; 819 729 ··· 847 755 if (alignment > 1) 848 756 region->mmap_size += alignment; 849 757 758 + region->fd = -1; 759 + if (backing_src_is_shared(src_type)) { 760 + int memfd_flags = MFD_CLOEXEC; 761 + 762 + if (src_type == VM_MEM_SRC_SHARED_HUGETLB) 763 + memfd_flags |= MFD_HUGETLB; 764 + 765 + region->fd = memfd_create("kvm_selftest", memfd_flags); 766 + TEST_ASSERT(region->fd != -1, 767 + "memfd_create failed, errno: %i", errno); 768 + 769 + ret = ftruncate(region->fd, region->mmap_size); 770 + TEST_ASSERT(ret == 0, "ftruncate failed, errno: %i", errno); 771 + 772 + ret = fallocate(region->fd, 773 + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 774 + region->mmap_size); 775 + TEST_ASSERT(ret == 0, "fallocate failed, errno: %i", errno); 776 + } 777 + 850 778 region->mmap_start = mmap(NULL, region->mmap_size, 851 779 PROT_READ | PROT_WRITE, 852 - MAP_PRIVATE | MAP_ANONYMOUS 853 - | vm_mem_backing_src_alias(src_type)->flag, 854 - -1, 0); 780 + vm_mem_backing_src_alias(src_type)->flag, 781 + region->fd, 0); 855 782 TEST_ASSERT(region->mmap_start != MAP_FAILED, 856 783 "test_malloc failed, mmap_start: %p errno: %i", 857 784 region->mmap_start, errno); ··· 904 793 ret, errno, slot, flags, 905 794 guest_paddr, (uint64_t) region->region.memory_size); 906 795 907 - /* Add to linked-list of memory regions. */ 908 - list_add(&region->list, &vm->userspace_mem_regions); 796 + /* Add to quick lookup data structures */ 797 + vm_userspace_mem_region_gpa_insert(&vm->regions.gpa_tree, region); 798 + vm_userspace_mem_region_hva_insert(&vm->regions.hva_tree, region); 799 + hash_add(vm->regions.slot_hash, &region->slot_node, slot); 800 + 801 + /* If shared memory, create an alias. */ 802 + if (region->fd >= 0) { 803 + region->mmap_alias = mmap(NULL, region->mmap_size, 804 + PROT_READ | PROT_WRITE, 805 + vm_mem_backing_src_alias(src_type)->flag, 806 + region->fd, 0); 807 + TEST_ASSERT(region->mmap_alias != MAP_FAILED, 808 + "mmap of alias failed, errno: %i", errno); 809 + 810 + /* Align host alias address */ 811 + region->host_alias = align(region->mmap_alias, alignment); 812 + } 909 813 } 910 814 911 815 /* ··· 943 817 { 944 818 struct userspace_mem_region *region; 945 819 946 - list_for_each_entry(region, &vm->userspace_mem_regions, list) { 820 + hash_for_each_possible(vm->regions.slot_hash, region, slot_node, 821 + memslot) 947 822 if (region->region.slot == memslot) 948 823 return region; 949 - } 950 824 951 825 fprintf(stderr, "No mem region with the requested slot found,\n" 952 826 " requested slot: %u\n", memslot); ··· 1031 905 */ 1032 906 void vm_mem_region_delete(struct kvm_vm *vm, uint32_t slot) 1033 907 { 1034 - __vm_mem_region_delete(vm, memslot2region(vm, slot)); 908 + __vm_mem_region_delete(vm, memslot2region(vm, slot), true); 1035 909 } 1036 910 1037 911 /* ··· 1051 925 { 1052 926 int dev_fd, ret; 1053 927 1054 - dev_fd = open(KVM_DEV_PATH, O_RDONLY); 1055 - if (dev_fd < 0) 1056 - exit(KSFT_SKIP); 928 + dev_fd = open_kvm_dev_path_or_exit(); 1057 929 1058 930 ret = ioctl(dev_fd, KVM_GET_VCPU_MMAP_SIZE, NULL); 1059 931 TEST_ASSERT(ret >= sizeof(struct kvm_run), ··· 1223 1099 uint64_t pages = (sz >> vm->page_shift) + ((sz % vm->page_size) != 0); 1224 1100 1225 1101 virt_pgd_alloc(vm, pgd_memslot); 1102 + vm_paddr_t paddr = vm_phy_pages_alloc(vm, pages, 1103 + KVM_UTIL_MIN_PFN * vm->page_size, 1104 + data_memslot); 1226 1105 1227 1106 /* 1228 1107 * Find an unused range of virtual page addresses of at least ··· 1235 1108 1236 1109 /* Map the virtual pages. */ 1237 1110 for (vm_vaddr_t vaddr = vaddr_start; pages > 0; 1238 - pages--, vaddr += vm->page_size) { 1239 - vm_paddr_t paddr; 1240 - 1241 - paddr = vm_phy_page_alloc(vm, 1242 - KVM_UTIL_MIN_PFN * vm->page_size, data_memslot); 1111 + pages--, vaddr += vm->page_size, paddr += vm->page_size) { 1243 1112 1244 1113 virt_pg_map(vm, vaddr, paddr, pgd_memslot); 1245 1114 ··· 1300 1177 { 1301 1178 struct userspace_mem_region *region; 1302 1179 1303 - list_for_each_entry(region, &vm->userspace_mem_regions, list) { 1304 - if ((gpa >= region->region.guest_phys_addr) 1305 - && (gpa <= (region->region.guest_phys_addr 1306 - + region->region.memory_size - 1))) 1307 - return (void *) ((uintptr_t) region->host_mem 1308 - + (gpa - region->region.guest_phys_addr)); 1180 + region = userspace_mem_region_find(vm, gpa, gpa); 1181 + if (!region) { 1182 + TEST_FAIL("No vm physical memory at 0x%lx", gpa); 1183 + return NULL; 1309 1184 } 1310 1185 1311 - TEST_FAIL("No vm physical memory at 0x%lx", gpa); 1312 - return NULL; 1186 + return (void *)((uintptr_t)region->host_mem 1187 + + (gpa - region->region.guest_phys_addr)); 1313 1188 } 1314 1189 1315 1190 /* ··· 1329 1208 */ 1330 1209 vm_paddr_t addr_hva2gpa(struct kvm_vm *vm, void *hva) 1331 1210 { 1332 - struct userspace_mem_region *region; 1211 + struct rb_node *node; 1333 1212 1334 - list_for_each_entry(region, &vm->userspace_mem_regions, list) { 1335 - if ((hva >= region->host_mem) 1336 - && (hva <= (region->host_mem 1337 - + region->region.memory_size - 1))) 1338 - return (vm_paddr_t) ((uintptr_t) 1339 - region->region.guest_phys_addr 1340 - + (hva - (uintptr_t) region->host_mem)); 1213 + for (node = vm->regions.hva_tree.rb_node; node; ) { 1214 + struct userspace_mem_region *region = 1215 + container_of(node, struct userspace_mem_region, hva_node); 1216 + 1217 + if (hva >= region->host_mem) { 1218 + if (hva <= (region->host_mem 1219 + + region->region.memory_size - 1)) 1220 + return (vm_paddr_t)((uintptr_t) 1221 + region->region.guest_phys_addr 1222 + + (hva - (uintptr_t)region->host_mem)); 1223 + 1224 + node = node->rb_right; 1225 + } else 1226 + node = node->rb_left; 1341 1227 } 1342 1228 1343 1229 TEST_FAIL("No mapping to a guest physical address, hva: %p", hva); 1344 1230 return -1; 1231 + } 1232 + 1233 + /* 1234 + * Address VM physical to Host Virtual *alias*. 1235 + * 1236 + * Input Args: 1237 + * vm - Virtual Machine 1238 + * gpa - VM physical address 1239 + * 1240 + * Output Args: None 1241 + * 1242 + * Return: 1243 + * Equivalent address within the host virtual *alias* area, or NULL 1244 + * (without failing the test) if the guest memory is not shared (so 1245 + * no alias exists). 1246 + * 1247 + * When vm_create() and related functions are called with a shared memory 1248 + * src_type, we also create a writable, shared alias mapping of the 1249 + * underlying guest memory. This allows the host to manipulate guest memory 1250 + * without mapping that memory in the guest's address space. And, for 1251 + * userfaultfd-based demand paging, we can do so without triggering userfaults. 1252 + */ 1253 + void *addr_gpa2alias(struct kvm_vm *vm, vm_paddr_t gpa) 1254 + { 1255 + struct userspace_mem_region *region; 1256 + uintptr_t offset; 1257 + 1258 + region = userspace_mem_region_find(vm, gpa, gpa); 1259 + if (!region) 1260 + return NULL; 1261 + 1262 + if (!region->host_alias) 1263 + return NULL; 1264 + 1265 + offset = gpa - region->region.guest_phys_addr; 1266 + return (void *) ((uintptr_t) region->host_alias + offset); 1345 1267 } 1346 1268 1347 1269 /* ··· 1986 1822 */ 1987 1823 void vm_dump(FILE *stream, struct kvm_vm *vm, uint8_t indent) 1988 1824 { 1825 + int ctr; 1989 1826 struct userspace_mem_region *region; 1990 1827 struct vcpu *vcpu; 1991 1828 ··· 1994 1829 fprintf(stream, "%*sfd: %i\n", indent, "", vm->fd); 1995 1830 fprintf(stream, "%*spage_size: 0x%x\n", indent, "", vm->page_size); 1996 1831 fprintf(stream, "%*sMem Regions:\n", indent, ""); 1997 - list_for_each_entry(region, &vm->userspace_mem_regions, list) { 1832 + hash_for_each(vm->regions.slot_hash, ctr, region, slot_node) { 1998 1833 fprintf(stream, "%*sguest_phys: 0x%lx size: 0x%lx " 1999 1834 "host_virt: %p\n", indent + 2, "", 2000 1835 (uint64_t) region->region.guest_phys_addr, ··· 2180 2015 2181 2016 if (vm == NULL) { 2182 2017 /* Ensure that the KVM vendor-specific module is loaded. */ 2183 - f = fopen(KVM_DEV_PATH, "r"); 2184 - TEST_ASSERT(f != NULL, "Error in opening KVM dev file: %d", 2185 - errno); 2186 - fclose(f); 2018 + close(open_kvm_dev_path_or_exit()); 2187 2019 } 2188 2020 2189 2021 f = fopen("/sys/module/kvm_intel/parameters/unrestricted_guest", "r"); ··· 2203 2041 return vm->page_shift; 2204 2042 } 2205 2043 2206 - unsigned int vm_get_max_gfn(struct kvm_vm *vm) 2044 + uint64_t vm_get_max_gfn(struct kvm_vm *vm) 2207 2045 { 2208 2046 return vm->max_gfn; 2209 2047 }
+15 -2
tools/testing/selftests/kvm/lib/kvm_util_internal.h
··· 8 8 #ifndef SELFTEST_KVM_UTIL_INTERNAL_H 9 9 #define SELFTEST_KVM_UTIL_INTERNAL_H 10 10 11 + #include "linux/hashtable.h" 12 + #include "linux/rbtree.h" 13 + 11 14 #include "sparsebit.h" 12 15 13 16 struct userspace_mem_region { ··· 19 16 int fd; 20 17 off_t offset; 21 18 void *host_mem; 19 + void *host_alias; 22 20 void *mmap_start; 21 + void *mmap_alias; 23 22 size_t mmap_size; 24 - struct list_head list; 23 + struct rb_node gpa_node; 24 + struct rb_node hva_node; 25 + struct hlist_node slot_node; 25 26 }; 26 27 27 28 struct vcpu { ··· 36 29 struct kvm_dirty_gfn *dirty_gfns; 37 30 uint32_t fetch_index; 38 31 uint32_t dirty_gfns_count; 32 + }; 33 + 34 + struct userspace_mem_regions { 35 + struct rb_root gpa_tree; 36 + struct rb_root hva_tree; 37 + DECLARE_HASHTABLE(slot_hash, 9); 39 38 }; 40 39 41 40 struct kvm_vm { ··· 56 43 unsigned int va_bits; 57 44 uint64_t max_gfn; 58 45 struct list_head vcpus; 59 - struct list_head userspace_mem_regions; 46 + struct userspace_mem_regions regions; 60 47 struct sparsebit *vpages_valid; 61 48 struct sparsebit *vpages_mapped; 62 49 bool has_irqchip;
+3 -1
tools/testing/selftests/kvm/lib/perf_test_util.c
··· 2 2 /* 3 3 * Copyright (C) 2020, Google LLC. 4 4 */ 5 + #include <inttypes.h> 5 6 6 7 #include "kvm_util.h" 7 8 #include "perf_test_util.h" ··· 81 80 */ 82 81 TEST_ASSERT(guest_num_pages < vm_get_max_gfn(vm), 83 82 "Requested more guest memory than address space allows.\n" 84 - " guest pages: %lx max gfn: %x vcpus: %d wss: %lx]\n", 83 + " guest pages: %" PRIx64 " max gfn: %" PRIx64 84 + " vcpus: %d wss: %" PRIx64 "]\n", 85 85 guest_num_pages, vm_get_max_gfn(vm), vcpus, 86 86 vcpu_memory_bytes); 87 87
+1
tools/testing/selftests/kvm/lib/rbtree.c
··· 1 + #include "../../../../lib/rbtree.c"
+35 -16
tools/testing/selftests/kvm/lib/test_util.c
··· 168 168 169 169 const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i) 170 170 { 171 + static const int anon_flags = MAP_PRIVATE | MAP_ANONYMOUS; 172 + static const int anon_huge_flags = anon_flags | MAP_HUGETLB; 173 + 171 174 static const struct vm_mem_backing_src_alias aliases[] = { 172 175 [VM_MEM_SRC_ANONYMOUS] = { 173 176 .name = "anonymous", 174 - .flag = 0, 177 + .flag = anon_flags, 175 178 }, 176 179 [VM_MEM_SRC_ANONYMOUS_THP] = { 177 180 .name = "anonymous_thp", 178 - .flag = 0, 181 + .flag = anon_flags, 179 182 }, 180 183 [VM_MEM_SRC_ANONYMOUS_HUGETLB] = { 181 184 .name = "anonymous_hugetlb", 182 - .flag = MAP_HUGETLB, 185 + .flag = anon_huge_flags, 183 186 }, 184 187 [VM_MEM_SRC_ANONYMOUS_HUGETLB_16KB] = { 185 188 .name = "anonymous_hugetlb_16kb", 186 - .flag = MAP_HUGETLB | MAP_HUGE_16KB, 189 + .flag = anon_huge_flags | MAP_HUGE_16KB, 187 190 }, 188 191 [VM_MEM_SRC_ANONYMOUS_HUGETLB_64KB] = { 189 192 .name = "anonymous_hugetlb_64kb", 190 - .flag = MAP_HUGETLB | MAP_HUGE_64KB, 193 + .flag = anon_huge_flags | MAP_HUGE_64KB, 191 194 }, 192 195 [VM_MEM_SRC_ANONYMOUS_HUGETLB_512KB] = { 193 196 .name = "anonymous_hugetlb_512kb", 194 - .flag = MAP_HUGETLB | MAP_HUGE_512KB, 197 + .flag = anon_huge_flags | MAP_HUGE_512KB, 195 198 }, 196 199 [VM_MEM_SRC_ANONYMOUS_HUGETLB_1MB] = { 197 200 .name = "anonymous_hugetlb_1mb", 198 - .flag = MAP_HUGETLB | MAP_HUGE_1MB, 201 + .flag = anon_huge_flags | MAP_HUGE_1MB, 199 202 }, 200 203 [VM_MEM_SRC_ANONYMOUS_HUGETLB_2MB] = { 201 204 .name = "anonymous_hugetlb_2mb", 202 - .flag = MAP_HUGETLB | MAP_HUGE_2MB, 205 + .flag = anon_huge_flags | MAP_HUGE_2MB, 203 206 }, 204 207 [VM_MEM_SRC_ANONYMOUS_HUGETLB_8MB] = { 205 208 .name = "anonymous_hugetlb_8mb", 206 - .flag = MAP_HUGETLB | MAP_HUGE_8MB, 209 + .flag = anon_huge_flags | MAP_HUGE_8MB, 207 210 }, 208 211 [VM_MEM_SRC_ANONYMOUS_HUGETLB_16MB] = { 209 212 .name = "anonymous_hugetlb_16mb", 210 - .flag = MAP_HUGETLB | MAP_HUGE_16MB, 213 + .flag = anon_huge_flags | MAP_HUGE_16MB, 211 214 }, 212 215 [VM_MEM_SRC_ANONYMOUS_HUGETLB_32MB] = { 213 216 .name = "anonymous_hugetlb_32mb", 214 - .flag = MAP_HUGETLB | MAP_HUGE_32MB, 217 + .flag = anon_huge_flags | MAP_HUGE_32MB, 215 218 }, 216 219 [VM_MEM_SRC_ANONYMOUS_HUGETLB_256MB] = { 217 220 .name = "anonymous_hugetlb_256mb", 218 - .flag = MAP_HUGETLB | MAP_HUGE_256MB, 221 + .flag = anon_huge_flags | MAP_HUGE_256MB, 219 222 }, 220 223 [VM_MEM_SRC_ANONYMOUS_HUGETLB_512MB] = { 221 224 .name = "anonymous_hugetlb_512mb", 222 - .flag = MAP_HUGETLB | MAP_HUGE_512MB, 225 + .flag = anon_huge_flags | MAP_HUGE_512MB, 223 226 }, 224 227 [VM_MEM_SRC_ANONYMOUS_HUGETLB_1GB] = { 225 228 .name = "anonymous_hugetlb_1gb", 226 - .flag = MAP_HUGETLB | MAP_HUGE_1GB, 229 + .flag = anon_huge_flags | MAP_HUGE_1GB, 227 230 }, 228 231 [VM_MEM_SRC_ANONYMOUS_HUGETLB_2GB] = { 229 232 .name = "anonymous_hugetlb_2gb", 230 - .flag = MAP_HUGETLB | MAP_HUGE_2GB, 233 + .flag = anon_huge_flags | MAP_HUGE_2GB, 231 234 }, 232 235 [VM_MEM_SRC_ANONYMOUS_HUGETLB_16GB] = { 233 236 .name = "anonymous_hugetlb_16gb", 234 - .flag = MAP_HUGETLB | MAP_HUGE_16GB, 237 + .flag = anon_huge_flags | MAP_HUGE_16GB, 238 + }, 239 + [VM_MEM_SRC_SHMEM] = { 240 + .name = "shmem", 241 + .flag = MAP_SHARED, 242 + }, 243 + [VM_MEM_SRC_SHARED_HUGETLB] = { 244 + .name = "shared_hugetlb", 245 + /* 246 + * No MAP_HUGETLB, we use MFD_HUGETLB instead. Since 247 + * we're using "file backed" memory, we need to specify 248 + * this when the FD is created, not when the area is 249 + * mapped. 250 + */ 251 + .flag = MAP_SHARED, 235 252 }, 236 253 }; 237 254 _Static_assert(ARRAY_SIZE(aliases) == NUM_SRC_TYPES, ··· 267 250 268 251 switch (i) { 269 252 case VM_MEM_SRC_ANONYMOUS: 253 + case VM_MEM_SRC_SHMEM: 270 254 return getpagesize(); 271 255 case VM_MEM_SRC_ANONYMOUS_THP: 272 256 return get_trans_hugepagesz(); 273 257 case VM_MEM_SRC_ANONYMOUS_HUGETLB: 258 + case VM_MEM_SRC_SHARED_HUGETLB: 274 259 return get_def_hugetlb_pagesz(); 275 260 default: 276 261 return MAP_HUGE_PAGE_SIZE(flag);
+4 -12
tools/testing/selftests/kvm/lib/x86_64/processor.c
··· 657 657 return cpuid; 658 658 659 659 cpuid = allocate_kvm_cpuid2(); 660 - kvm_fd = open(KVM_DEV_PATH, O_RDONLY); 661 - if (kvm_fd < 0) 662 - exit(KSFT_SKIP); 660 + kvm_fd = open_kvm_dev_path_or_exit(); 663 661 664 662 ret = ioctl(kvm_fd, KVM_GET_SUPPORTED_CPUID, cpuid); 665 663 TEST_ASSERT(ret == 0, "KVM_GET_SUPPORTED_CPUID failed %d %d\n", ··· 689 691 690 692 buffer.header.nmsrs = 1; 691 693 buffer.entry.index = msr_index; 692 - kvm_fd = open(KVM_DEV_PATH, O_RDONLY); 693 - if (kvm_fd < 0) 694 - exit(KSFT_SKIP); 694 + kvm_fd = open_kvm_dev_path_or_exit(); 695 695 696 696 r = ioctl(kvm_fd, KVM_GET_MSRS, &buffer.header); 697 697 TEST_ASSERT(r == 1, "KVM_GET_MSRS IOCTL failed,\n" ··· 982 986 struct kvm_msr_list *list; 983 987 int nmsrs, r, kvm_fd; 984 988 985 - kvm_fd = open(KVM_DEV_PATH, O_RDONLY); 986 - if (kvm_fd < 0) 987 - exit(KSFT_SKIP); 989 + kvm_fd = open_kvm_dev_path_or_exit(); 988 990 989 991 nmsrs = kvm_get_num_msrs_fd(kvm_fd); 990 992 list = malloc(sizeof(*list) + nmsrs * sizeof(list->indices[0])); ··· 1306 1312 return cpuid; 1307 1313 1308 1314 cpuid = allocate_kvm_cpuid2(); 1309 - kvm_fd = open(KVM_DEV_PATH, O_RDONLY); 1310 - if (kvm_fd < 0) 1311 - exit(KSFT_SKIP); 1315 + kvm_fd = open_kvm_dev_path_or_exit(); 1312 1316 1313 1317 ret = ioctl(kvm_fd, KVM_GET_SUPPORTED_HV_CPUID, cpuid); 1314 1318 TEST_ASSERT(ret == 0, "KVM_GET_SUPPORTED_HV_CPUID failed %d %d\n",
+11 -7
tools/testing/selftests/kvm/memslot_modification_stress_test.c
··· 71 71 }; 72 72 73 73 static void add_remove_memslot(struct kvm_vm *vm, useconds_t delay, 74 - uint64_t nr_modifications, uint64_t gpa) 74 + uint64_t nr_modifications) 75 75 { 76 + const uint64_t pages = 1; 77 + uint64_t gpa; 76 78 int i; 79 + 80 + /* 81 + * Add the dummy memslot just below the perf_test_util memslot, which is 82 + * at the top of the guest physical address space. 83 + */ 84 + gpa = guest_test_phys_mem - pages * vm_get_page_size(vm); 77 85 78 86 for (i = 0; i < nr_modifications; i++) { 79 87 usleep(delay); 80 88 vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, gpa, 81 - DUMMY_MEMSLOT_INDEX, 1, 0); 89 + DUMMY_MEMSLOT_INDEX, pages, 0); 82 90 83 91 vm_mem_region_delete(vm, DUMMY_MEMSLOT_INDEX); 84 92 } ··· 128 120 pr_info("Started all vCPUs\n"); 129 121 130 122 add_remove_memslot(vm, p->memslot_modification_delay, 131 - p->nr_memslot_modifications, 132 - guest_test_phys_mem + 133 - (guest_percpu_mem_size * nr_vcpus) + 134 - perf_test_args.host_page_size + 135 - perf_test_args.guest_page_size); 123 + p->nr_memslot_modifications); 136 124 137 125 run_vcpus = false; 138 126
+1037
tools/testing/selftests/kvm/memslot_perf_test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * A memslot-related performance benchmark. 4 + * 5 + * Copyright (C) 2021 Oracle and/or its affiliates. 6 + * 7 + * Basic guest setup / host vCPU thread code lifted from set_memory_region_test. 8 + */ 9 + #include <pthread.h> 10 + #include <sched.h> 11 + #include <semaphore.h> 12 + #include <stdatomic.h> 13 + #include <stdbool.h> 14 + #include <stdint.h> 15 + #include <stdio.h> 16 + #include <stdlib.h> 17 + #include <string.h> 18 + #include <sys/mman.h> 19 + #include <time.h> 20 + #include <unistd.h> 21 + 22 + #include <linux/compiler.h> 23 + 24 + #include <test_util.h> 25 + #include <kvm_util.h> 26 + #include <processor.h> 27 + 28 + #define VCPU_ID 0 29 + 30 + #define MEM_SIZE ((512U << 20) + 4096) 31 + #define MEM_SIZE_PAGES (MEM_SIZE / 4096) 32 + #define MEM_GPA 0x10000000UL 33 + #define MEM_AUX_GPA MEM_GPA 34 + #define MEM_SYNC_GPA MEM_AUX_GPA 35 + #define MEM_TEST_GPA (MEM_AUX_GPA + 4096) 36 + #define MEM_TEST_SIZE (MEM_SIZE - 4096) 37 + static_assert(MEM_SIZE % 4096 == 0, "invalid mem size"); 38 + static_assert(MEM_TEST_SIZE % 4096 == 0, "invalid mem test size"); 39 + 40 + /* 41 + * 32 MiB is max size that gets well over 100 iterations on 509 slots. 42 + * Considering that each slot needs to have at least one page up to 43 + * 8194 slots in use can then be tested (although with slightly 44 + * limited resolution). 45 + */ 46 + #define MEM_SIZE_MAP ((32U << 20) + 4096) 47 + #define MEM_SIZE_MAP_PAGES (MEM_SIZE_MAP / 4096) 48 + #define MEM_TEST_MAP_SIZE (MEM_SIZE_MAP - 4096) 49 + #define MEM_TEST_MAP_SIZE_PAGES (MEM_TEST_MAP_SIZE / 4096) 50 + static_assert(MEM_SIZE_MAP % 4096 == 0, "invalid map test region size"); 51 + static_assert(MEM_TEST_MAP_SIZE % 4096 == 0, "invalid map test region size"); 52 + static_assert(MEM_TEST_MAP_SIZE_PAGES % 2 == 0, "invalid map test region size"); 53 + static_assert(MEM_TEST_MAP_SIZE_PAGES > 2, "invalid map test region size"); 54 + 55 + /* 56 + * 128 MiB is min size that fills 32k slots with at least one page in each 57 + * while at the same time gets 100+ iterations in such test 58 + */ 59 + #define MEM_TEST_UNMAP_SIZE (128U << 20) 60 + #define MEM_TEST_UNMAP_SIZE_PAGES (MEM_TEST_UNMAP_SIZE / 4096) 61 + /* 2 MiB chunk size like a typical huge page */ 62 + #define MEM_TEST_UNMAP_CHUNK_PAGES (2U << (20 - 12)) 63 + static_assert(MEM_TEST_UNMAP_SIZE <= MEM_TEST_SIZE, 64 + "invalid unmap test region size"); 65 + static_assert(MEM_TEST_UNMAP_SIZE % 4096 == 0, 66 + "invalid unmap test region size"); 67 + static_assert(MEM_TEST_UNMAP_SIZE_PAGES % 68 + (2 * MEM_TEST_UNMAP_CHUNK_PAGES) == 0, 69 + "invalid unmap test region size"); 70 + 71 + /* 72 + * For the move active test the middle of the test area is placed on 73 + * a memslot boundary: half lies in the memslot being moved, half in 74 + * other memslot(s). 75 + * 76 + * When running this test with 32k memslots (32764, really) each memslot 77 + * contains 4 pages. 78 + * The last one additionally contains the remaining 21 pages of memory, 79 + * for the total size of 25 pages. 80 + * Hence, the maximum size here is 50 pages. 81 + */ 82 + #define MEM_TEST_MOVE_SIZE_PAGES (50) 83 + #define MEM_TEST_MOVE_SIZE (MEM_TEST_MOVE_SIZE_PAGES * 4096) 84 + #define MEM_TEST_MOVE_GPA_DEST (MEM_GPA + MEM_SIZE) 85 + static_assert(MEM_TEST_MOVE_SIZE <= MEM_TEST_SIZE, 86 + "invalid move test region size"); 87 + 88 + #define MEM_TEST_VAL_1 0x1122334455667788 89 + #define MEM_TEST_VAL_2 0x99AABBCCDDEEFF00 90 + 91 + struct vm_data { 92 + struct kvm_vm *vm; 93 + pthread_t vcpu_thread; 94 + uint32_t nslots; 95 + uint64_t npages; 96 + uint64_t pages_per_slot; 97 + void **hva_slots; 98 + bool mmio_ok; 99 + uint64_t mmio_gpa_min; 100 + uint64_t mmio_gpa_max; 101 + }; 102 + 103 + struct sync_area { 104 + atomic_bool start_flag; 105 + atomic_bool exit_flag; 106 + atomic_bool sync_flag; 107 + void *move_area_ptr; 108 + }; 109 + 110 + /* 111 + * Technically, we need also for the atomic bool to be address-free, which 112 + * is recommended, but not strictly required, by C11 for lockless 113 + * implementations. 114 + * However, in practice both GCC and Clang fulfill this requirement on 115 + * all KVM-supported platforms. 116 + */ 117 + static_assert(ATOMIC_BOOL_LOCK_FREE == 2, "atomic bool is not lockless"); 118 + 119 + static sem_t vcpu_ready; 120 + 121 + static bool map_unmap_verify; 122 + 123 + static bool verbose; 124 + #define pr_info_v(...) \ 125 + do { \ 126 + if (verbose) \ 127 + pr_info(__VA_ARGS__); \ 128 + } while (0) 129 + 130 + static void *vcpu_worker(void *data) 131 + { 132 + struct vm_data *vm = data; 133 + struct kvm_run *run; 134 + struct ucall uc; 135 + uint64_t cmd; 136 + 137 + run = vcpu_state(vm->vm, VCPU_ID); 138 + while (1) { 139 + vcpu_run(vm->vm, VCPU_ID); 140 + 141 + if (run->exit_reason == KVM_EXIT_IO) { 142 + cmd = get_ucall(vm->vm, VCPU_ID, &uc); 143 + if (cmd != UCALL_SYNC) 144 + break; 145 + 146 + sem_post(&vcpu_ready); 147 + continue; 148 + } 149 + 150 + if (run->exit_reason != KVM_EXIT_MMIO) 151 + break; 152 + 153 + TEST_ASSERT(vm->mmio_ok, "Unexpected mmio exit"); 154 + TEST_ASSERT(run->mmio.is_write, "Unexpected mmio read"); 155 + TEST_ASSERT(run->mmio.len == 8, 156 + "Unexpected exit mmio size = %u", run->mmio.len); 157 + TEST_ASSERT(run->mmio.phys_addr >= vm->mmio_gpa_min && 158 + run->mmio.phys_addr <= vm->mmio_gpa_max, 159 + "Unexpected exit mmio address = 0x%llx", 160 + run->mmio.phys_addr); 161 + } 162 + 163 + if (run->exit_reason == KVM_EXIT_IO && cmd == UCALL_ABORT) 164 + TEST_FAIL("%s at %s:%ld, val = %lu", (const char *)uc.args[0], 165 + __FILE__, uc.args[1], uc.args[2]); 166 + 167 + return NULL; 168 + } 169 + 170 + static void wait_for_vcpu(void) 171 + { 172 + struct timespec ts; 173 + 174 + TEST_ASSERT(!clock_gettime(CLOCK_REALTIME, &ts), 175 + "clock_gettime() failed: %d\n", errno); 176 + 177 + ts.tv_sec += 2; 178 + TEST_ASSERT(!sem_timedwait(&vcpu_ready, &ts), 179 + "sem_timedwait() failed: %d\n", errno); 180 + } 181 + 182 + static void *vm_gpa2hva(struct vm_data *data, uint64_t gpa, uint64_t *rempages) 183 + { 184 + uint64_t gpage, pgoffs; 185 + uint32_t slot, slotoffs; 186 + void *base; 187 + 188 + TEST_ASSERT(gpa >= MEM_GPA, "Too low gpa to translate"); 189 + TEST_ASSERT(gpa < MEM_GPA + data->npages * 4096, 190 + "Too high gpa to translate"); 191 + gpa -= MEM_GPA; 192 + 193 + gpage = gpa / 4096; 194 + pgoffs = gpa % 4096; 195 + slot = min(gpage / data->pages_per_slot, (uint64_t)data->nslots - 1); 196 + slotoffs = gpage - (slot * data->pages_per_slot); 197 + 198 + if (rempages) { 199 + uint64_t slotpages; 200 + 201 + if (slot == data->nslots - 1) 202 + slotpages = data->npages - slot * data->pages_per_slot; 203 + else 204 + slotpages = data->pages_per_slot; 205 + 206 + TEST_ASSERT(!pgoffs, 207 + "Asking for remaining pages in slot but gpa not page aligned"); 208 + *rempages = slotpages - slotoffs; 209 + } 210 + 211 + base = data->hva_slots[slot]; 212 + return (uint8_t *)base + slotoffs * 4096 + pgoffs; 213 + } 214 + 215 + static uint64_t vm_slot2gpa(struct vm_data *data, uint32_t slot) 216 + { 217 + TEST_ASSERT(slot < data->nslots, "Too high slot number"); 218 + 219 + return MEM_GPA + slot * data->pages_per_slot * 4096; 220 + } 221 + 222 + static struct vm_data *alloc_vm(void) 223 + { 224 + struct vm_data *data; 225 + 226 + data = malloc(sizeof(*data)); 227 + TEST_ASSERT(data, "malloc(vmdata) failed"); 228 + 229 + data->vm = NULL; 230 + data->hva_slots = NULL; 231 + 232 + return data; 233 + } 234 + 235 + static bool prepare_vm(struct vm_data *data, int nslots, uint64_t *maxslots, 236 + void *guest_code, uint64_t mempages, 237 + struct timespec *slot_runtime) 238 + { 239 + uint32_t max_mem_slots; 240 + uint64_t rempages; 241 + uint64_t guest_addr; 242 + uint32_t slot; 243 + struct timespec tstart; 244 + struct sync_area *sync; 245 + 246 + max_mem_slots = kvm_check_cap(KVM_CAP_NR_MEMSLOTS); 247 + TEST_ASSERT(max_mem_slots > 1, 248 + "KVM_CAP_NR_MEMSLOTS should be greater than 1"); 249 + TEST_ASSERT(nslots > 1 || nslots == -1, 250 + "Slot count cap should be greater than 1"); 251 + if (nslots != -1) 252 + max_mem_slots = min(max_mem_slots, (uint32_t)nslots); 253 + pr_info_v("Allowed number of memory slots: %"PRIu32"\n", max_mem_slots); 254 + 255 + TEST_ASSERT(mempages > 1, 256 + "Can't test without any memory"); 257 + 258 + data->npages = mempages; 259 + data->nslots = max_mem_slots - 1; 260 + data->pages_per_slot = mempages / data->nslots; 261 + if (!data->pages_per_slot) { 262 + *maxslots = mempages + 1; 263 + return false; 264 + } 265 + 266 + rempages = mempages % data->nslots; 267 + data->hva_slots = malloc(sizeof(*data->hva_slots) * data->nslots); 268 + TEST_ASSERT(data->hva_slots, "malloc() fail"); 269 + 270 + data->vm = vm_create_default(VCPU_ID, 1024, guest_code); 271 + 272 + pr_info_v("Adding slots 1..%i, each slot with %"PRIu64" pages + %"PRIu64" extra pages last\n", 273 + max_mem_slots - 1, data->pages_per_slot, rempages); 274 + 275 + clock_gettime(CLOCK_MONOTONIC, &tstart); 276 + for (slot = 1, guest_addr = MEM_GPA; slot < max_mem_slots; slot++) { 277 + uint64_t npages; 278 + 279 + npages = data->pages_per_slot; 280 + if (slot == max_mem_slots - 1) 281 + npages += rempages; 282 + 283 + vm_userspace_mem_region_add(data->vm, VM_MEM_SRC_ANONYMOUS, 284 + guest_addr, slot, npages, 285 + 0); 286 + guest_addr += npages * 4096; 287 + } 288 + *slot_runtime = timespec_elapsed(tstart); 289 + 290 + for (slot = 0, guest_addr = MEM_GPA; slot < max_mem_slots - 1; slot++) { 291 + uint64_t npages; 292 + uint64_t gpa; 293 + 294 + npages = data->pages_per_slot; 295 + if (slot == max_mem_slots - 2) 296 + npages += rempages; 297 + 298 + gpa = vm_phy_pages_alloc(data->vm, npages, guest_addr, 299 + slot + 1); 300 + TEST_ASSERT(gpa == guest_addr, 301 + "vm_phy_pages_alloc() failed\n"); 302 + 303 + data->hva_slots[slot] = addr_gpa2hva(data->vm, guest_addr); 304 + memset(data->hva_slots[slot], 0, npages * 4096); 305 + 306 + guest_addr += npages * 4096; 307 + } 308 + 309 + virt_map(data->vm, MEM_GPA, MEM_GPA, mempages, 0); 310 + 311 + sync = (typeof(sync))vm_gpa2hva(data, MEM_SYNC_GPA, NULL); 312 + atomic_init(&sync->start_flag, false); 313 + atomic_init(&sync->exit_flag, false); 314 + atomic_init(&sync->sync_flag, false); 315 + 316 + data->mmio_ok = false; 317 + 318 + return true; 319 + } 320 + 321 + static void launch_vm(struct vm_data *data) 322 + { 323 + pr_info_v("Launching the test VM\n"); 324 + 325 + pthread_create(&data->vcpu_thread, NULL, vcpu_worker, data); 326 + 327 + /* Ensure the guest thread is spun up. */ 328 + wait_for_vcpu(); 329 + } 330 + 331 + static void free_vm(struct vm_data *data) 332 + { 333 + kvm_vm_free(data->vm); 334 + free(data->hva_slots); 335 + free(data); 336 + } 337 + 338 + static void wait_guest_exit(struct vm_data *data) 339 + { 340 + pthread_join(data->vcpu_thread, NULL); 341 + } 342 + 343 + static void let_guest_run(struct sync_area *sync) 344 + { 345 + atomic_store_explicit(&sync->start_flag, true, memory_order_release); 346 + } 347 + 348 + static void guest_spin_until_start(void) 349 + { 350 + struct sync_area *sync = (typeof(sync))MEM_SYNC_GPA; 351 + 352 + while (!atomic_load_explicit(&sync->start_flag, memory_order_acquire)) 353 + ; 354 + } 355 + 356 + static void make_guest_exit(struct sync_area *sync) 357 + { 358 + atomic_store_explicit(&sync->exit_flag, true, memory_order_release); 359 + } 360 + 361 + static bool _guest_should_exit(void) 362 + { 363 + struct sync_area *sync = (typeof(sync))MEM_SYNC_GPA; 364 + 365 + return atomic_load_explicit(&sync->exit_flag, memory_order_acquire); 366 + } 367 + 368 + #define guest_should_exit() unlikely(_guest_should_exit()) 369 + 370 + /* 371 + * noinline so we can easily see how much time the host spends waiting 372 + * for the guest. 373 + * For the same reason use alarm() instead of polling clock_gettime() 374 + * to implement a wait timeout. 375 + */ 376 + static noinline void host_perform_sync(struct sync_area *sync) 377 + { 378 + alarm(2); 379 + 380 + atomic_store_explicit(&sync->sync_flag, true, memory_order_release); 381 + while (atomic_load_explicit(&sync->sync_flag, memory_order_acquire)) 382 + ; 383 + 384 + alarm(0); 385 + } 386 + 387 + static bool guest_perform_sync(void) 388 + { 389 + struct sync_area *sync = (typeof(sync))MEM_SYNC_GPA; 390 + bool expected; 391 + 392 + do { 393 + if (guest_should_exit()) 394 + return false; 395 + 396 + expected = true; 397 + } while (!atomic_compare_exchange_weak_explicit(&sync->sync_flag, 398 + &expected, false, 399 + memory_order_acq_rel, 400 + memory_order_relaxed)); 401 + 402 + return true; 403 + } 404 + 405 + static void guest_code_test_memslot_move(void) 406 + { 407 + struct sync_area *sync = (typeof(sync))MEM_SYNC_GPA; 408 + uintptr_t base = (typeof(base))READ_ONCE(sync->move_area_ptr); 409 + 410 + GUEST_SYNC(0); 411 + 412 + guest_spin_until_start(); 413 + 414 + while (!guest_should_exit()) { 415 + uintptr_t ptr; 416 + 417 + for (ptr = base; ptr < base + MEM_TEST_MOVE_SIZE; 418 + ptr += 4096) 419 + *(uint64_t *)ptr = MEM_TEST_VAL_1; 420 + 421 + /* 422 + * No host sync here since the MMIO exits are so expensive 423 + * that the host would spend most of its time waiting for 424 + * the guest and so instead of measuring memslot move 425 + * performance we would measure the performance and 426 + * likelihood of MMIO exits 427 + */ 428 + } 429 + 430 + GUEST_DONE(); 431 + } 432 + 433 + static void guest_code_test_memslot_map(void) 434 + { 435 + struct sync_area *sync = (typeof(sync))MEM_SYNC_GPA; 436 + 437 + GUEST_SYNC(0); 438 + 439 + guest_spin_until_start(); 440 + 441 + while (1) { 442 + uintptr_t ptr; 443 + 444 + for (ptr = MEM_TEST_GPA; 445 + ptr < MEM_TEST_GPA + MEM_TEST_MAP_SIZE / 2; ptr += 4096) 446 + *(uint64_t *)ptr = MEM_TEST_VAL_1; 447 + 448 + if (!guest_perform_sync()) 449 + break; 450 + 451 + for (ptr = MEM_TEST_GPA + MEM_TEST_MAP_SIZE / 2; 452 + ptr < MEM_TEST_GPA + MEM_TEST_MAP_SIZE; ptr += 4096) 453 + *(uint64_t *)ptr = MEM_TEST_VAL_2; 454 + 455 + if (!guest_perform_sync()) 456 + break; 457 + } 458 + 459 + GUEST_DONE(); 460 + } 461 + 462 + static void guest_code_test_memslot_unmap(void) 463 + { 464 + struct sync_area *sync = (typeof(sync))MEM_SYNC_GPA; 465 + 466 + GUEST_SYNC(0); 467 + 468 + guest_spin_until_start(); 469 + 470 + while (1) { 471 + uintptr_t ptr = MEM_TEST_GPA; 472 + 473 + /* 474 + * We can afford to access (map) just a small number of pages 475 + * per host sync as otherwise the host will spend 476 + * a significant amount of its time waiting for the guest 477 + * (instead of doing unmap operations), so this will 478 + * effectively turn this test into a map performance test. 479 + * 480 + * Just access a single page to be on the safe side. 481 + */ 482 + *(uint64_t *)ptr = MEM_TEST_VAL_1; 483 + 484 + if (!guest_perform_sync()) 485 + break; 486 + 487 + ptr += MEM_TEST_UNMAP_SIZE / 2; 488 + *(uint64_t *)ptr = MEM_TEST_VAL_2; 489 + 490 + if (!guest_perform_sync()) 491 + break; 492 + } 493 + 494 + GUEST_DONE(); 495 + } 496 + 497 + static void guest_code_test_memslot_rw(void) 498 + { 499 + GUEST_SYNC(0); 500 + 501 + guest_spin_until_start(); 502 + 503 + while (1) { 504 + uintptr_t ptr; 505 + 506 + for (ptr = MEM_TEST_GPA; 507 + ptr < MEM_TEST_GPA + MEM_TEST_SIZE; ptr += 4096) 508 + *(uint64_t *)ptr = MEM_TEST_VAL_1; 509 + 510 + if (!guest_perform_sync()) 511 + break; 512 + 513 + for (ptr = MEM_TEST_GPA + 4096 / 2; 514 + ptr < MEM_TEST_GPA + MEM_TEST_SIZE; ptr += 4096) { 515 + uint64_t val = *(uint64_t *)ptr; 516 + 517 + GUEST_ASSERT_1(val == MEM_TEST_VAL_2, val); 518 + *(uint64_t *)ptr = 0; 519 + } 520 + 521 + if (!guest_perform_sync()) 522 + break; 523 + } 524 + 525 + GUEST_DONE(); 526 + } 527 + 528 + static bool test_memslot_move_prepare(struct vm_data *data, 529 + struct sync_area *sync, 530 + uint64_t *maxslots, bool isactive) 531 + { 532 + uint64_t movesrcgpa, movetestgpa; 533 + 534 + movesrcgpa = vm_slot2gpa(data, data->nslots - 1); 535 + 536 + if (isactive) { 537 + uint64_t lastpages; 538 + 539 + vm_gpa2hva(data, movesrcgpa, &lastpages); 540 + if (lastpages < MEM_TEST_MOVE_SIZE_PAGES / 2) { 541 + *maxslots = 0; 542 + return false; 543 + } 544 + } 545 + 546 + movetestgpa = movesrcgpa - (MEM_TEST_MOVE_SIZE / (isactive ? 2 : 1)); 547 + sync->move_area_ptr = (void *)movetestgpa; 548 + 549 + if (isactive) { 550 + data->mmio_ok = true; 551 + data->mmio_gpa_min = movesrcgpa; 552 + data->mmio_gpa_max = movesrcgpa + MEM_TEST_MOVE_SIZE / 2 - 1; 553 + } 554 + 555 + return true; 556 + } 557 + 558 + static bool test_memslot_move_prepare_active(struct vm_data *data, 559 + struct sync_area *sync, 560 + uint64_t *maxslots) 561 + { 562 + return test_memslot_move_prepare(data, sync, maxslots, true); 563 + } 564 + 565 + static bool test_memslot_move_prepare_inactive(struct vm_data *data, 566 + struct sync_area *sync, 567 + uint64_t *maxslots) 568 + { 569 + return test_memslot_move_prepare(data, sync, maxslots, false); 570 + } 571 + 572 + static void test_memslot_move_loop(struct vm_data *data, struct sync_area *sync) 573 + { 574 + uint64_t movesrcgpa; 575 + 576 + movesrcgpa = vm_slot2gpa(data, data->nslots - 1); 577 + vm_mem_region_move(data->vm, data->nslots - 1 + 1, 578 + MEM_TEST_MOVE_GPA_DEST); 579 + vm_mem_region_move(data->vm, data->nslots - 1 + 1, movesrcgpa); 580 + } 581 + 582 + static void test_memslot_do_unmap(struct vm_data *data, 583 + uint64_t offsp, uint64_t count) 584 + { 585 + uint64_t gpa, ctr; 586 + 587 + for (gpa = MEM_TEST_GPA + offsp * 4096, ctr = 0; ctr < count; ) { 588 + uint64_t npages; 589 + void *hva; 590 + int ret; 591 + 592 + hva = vm_gpa2hva(data, gpa, &npages); 593 + TEST_ASSERT(npages, "Empty memory slot at gptr 0x%"PRIx64, gpa); 594 + npages = min(npages, count - ctr); 595 + ret = madvise(hva, npages * 4096, MADV_DONTNEED); 596 + TEST_ASSERT(!ret, 597 + "madvise(%p, MADV_DONTNEED) on VM memory should not fail for gptr 0x%"PRIx64, 598 + hva, gpa); 599 + ctr += npages; 600 + gpa += npages * 4096; 601 + } 602 + TEST_ASSERT(ctr == count, 603 + "madvise(MADV_DONTNEED) should exactly cover all of the requested area"); 604 + } 605 + 606 + static void test_memslot_map_unmap_check(struct vm_data *data, 607 + uint64_t offsp, uint64_t valexp) 608 + { 609 + uint64_t gpa; 610 + uint64_t *val; 611 + 612 + if (!map_unmap_verify) 613 + return; 614 + 615 + gpa = MEM_TEST_GPA + offsp * 4096; 616 + val = (typeof(val))vm_gpa2hva(data, gpa, NULL); 617 + TEST_ASSERT(*val == valexp, 618 + "Guest written values should read back correctly before unmap (%"PRIu64" vs %"PRIu64" @ %"PRIx64")", 619 + *val, valexp, gpa); 620 + *val = 0; 621 + } 622 + 623 + static void test_memslot_map_loop(struct vm_data *data, struct sync_area *sync) 624 + { 625 + /* 626 + * Unmap the second half of the test area while guest writes to (maps) 627 + * the first half. 628 + */ 629 + test_memslot_do_unmap(data, MEM_TEST_MAP_SIZE_PAGES / 2, 630 + MEM_TEST_MAP_SIZE_PAGES / 2); 631 + 632 + /* 633 + * Wait for the guest to finish writing the first half of the test 634 + * area, verify the written value on the first and the last page of 635 + * this area and then unmap it. 636 + * Meanwhile, the guest is writing to (mapping) the second half of 637 + * the test area. 638 + */ 639 + host_perform_sync(sync); 640 + test_memslot_map_unmap_check(data, 0, MEM_TEST_VAL_1); 641 + test_memslot_map_unmap_check(data, 642 + MEM_TEST_MAP_SIZE_PAGES / 2 - 1, 643 + MEM_TEST_VAL_1); 644 + test_memslot_do_unmap(data, 0, MEM_TEST_MAP_SIZE_PAGES / 2); 645 + 646 + 647 + /* 648 + * Wait for the guest to finish writing the second half of the test 649 + * area and verify the written value on the first and the last page 650 + * of this area. 651 + * The area will be unmapped at the beginning of the next loop 652 + * iteration. 653 + * Meanwhile, the guest is writing to (mapping) the first half of 654 + * the test area. 655 + */ 656 + host_perform_sync(sync); 657 + test_memslot_map_unmap_check(data, MEM_TEST_MAP_SIZE_PAGES / 2, 658 + MEM_TEST_VAL_2); 659 + test_memslot_map_unmap_check(data, MEM_TEST_MAP_SIZE_PAGES - 1, 660 + MEM_TEST_VAL_2); 661 + } 662 + 663 + static void test_memslot_unmap_loop_common(struct vm_data *data, 664 + struct sync_area *sync, 665 + uint64_t chunk) 666 + { 667 + uint64_t ctr; 668 + 669 + /* 670 + * Wait for the guest to finish mapping page(s) in the first half 671 + * of the test area, verify the written value and then perform unmap 672 + * of this area. 673 + * Meanwhile, the guest is writing to (mapping) page(s) in the second 674 + * half of the test area. 675 + */ 676 + host_perform_sync(sync); 677 + test_memslot_map_unmap_check(data, 0, MEM_TEST_VAL_1); 678 + for (ctr = 0; ctr < MEM_TEST_UNMAP_SIZE_PAGES / 2; ctr += chunk) 679 + test_memslot_do_unmap(data, ctr, chunk); 680 + 681 + /* Likewise, but for the opposite host / guest areas */ 682 + host_perform_sync(sync); 683 + test_memslot_map_unmap_check(data, MEM_TEST_UNMAP_SIZE_PAGES / 2, 684 + MEM_TEST_VAL_2); 685 + for (ctr = MEM_TEST_UNMAP_SIZE_PAGES / 2; 686 + ctr < MEM_TEST_UNMAP_SIZE_PAGES; ctr += chunk) 687 + test_memslot_do_unmap(data, ctr, chunk); 688 + } 689 + 690 + static void test_memslot_unmap_loop(struct vm_data *data, 691 + struct sync_area *sync) 692 + { 693 + test_memslot_unmap_loop_common(data, sync, 1); 694 + } 695 + 696 + static void test_memslot_unmap_loop_chunked(struct vm_data *data, 697 + struct sync_area *sync) 698 + { 699 + test_memslot_unmap_loop_common(data, sync, MEM_TEST_UNMAP_CHUNK_PAGES); 700 + } 701 + 702 + static void test_memslot_rw_loop(struct vm_data *data, struct sync_area *sync) 703 + { 704 + uint64_t gptr; 705 + 706 + for (gptr = MEM_TEST_GPA + 4096 / 2; 707 + gptr < MEM_TEST_GPA + MEM_TEST_SIZE; gptr += 4096) 708 + *(uint64_t *)vm_gpa2hva(data, gptr, NULL) = MEM_TEST_VAL_2; 709 + 710 + host_perform_sync(sync); 711 + 712 + for (gptr = MEM_TEST_GPA; 713 + gptr < MEM_TEST_GPA + MEM_TEST_SIZE; gptr += 4096) { 714 + uint64_t *vptr = (typeof(vptr))vm_gpa2hva(data, gptr, NULL); 715 + uint64_t val = *vptr; 716 + 717 + TEST_ASSERT(val == MEM_TEST_VAL_1, 718 + "Guest written values should read back correctly (is %"PRIu64" @ %"PRIx64")", 719 + val, gptr); 720 + *vptr = 0; 721 + } 722 + 723 + host_perform_sync(sync); 724 + } 725 + 726 + struct test_data { 727 + const char *name; 728 + uint64_t mem_size; 729 + void (*guest_code)(void); 730 + bool (*prepare)(struct vm_data *data, struct sync_area *sync, 731 + uint64_t *maxslots); 732 + void (*loop)(struct vm_data *data, struct sync_area *sync); 733 + }; 734 + 735 + static bool test_execute(int nslots, uint64_t *maxslots, 736 + unsigned int maxtime, 737 + const struct test_data *tdata, 738 + uint64_t *nloops, 739 + struct timespec *slot_runtime, 740 + struct timespec *guest_runtime) 741 + { 742 + uint64_t mem_size = tdata->mem_size ? : MEM_SIZE_PAGES; 743 + struct vm_data *data; 744 + struct sync_area *sync; 745 + struct timespec tstart; 746 + bool ret = true; 747 + 748 + data = alloc_vm(); 749 + if (!prepare_vm(data, nslots, maxslots, tdata->guest_code, 750 + mem_size, slot_runtime)) { 751 + ret = false; 752 + goto exit_free; 753 + } 754 + 755 + sync = (typeof(sync))vm_gpa2hva(data, MEM_SYNC_GPA, NULL); 756 + 757 + if (tdata->prepare && 758 + !tdata->prepare(data, sync, maxslots)) { 759 + ret = false; 760 + goto exit_free; 761 + } 762 + 763 + launch_vm(data); 764 + 765 + clock_gettime(CLOCK_MONOTONIC, &tstart); 766 + let_guest_run(sync); 767 + 768 + while (1) { 769 + *guest_runtime = timespec_elapsed(tstart); 770 + if (guest_runtime->tv_sec >= maxtime) 771 + break; 772 + 773 + tdata->loop(data, sync); 774 + 775 + (*nloops)++; 776 + } 777 + 778 + make_guest_exit(sync); 779 + wait_guest_exit(data); 780 + 781 + exit_free: 782 + free_vm(data); 783 + 784 + return ret; 785 + } 786 + 787 + static const struct test_data tests[] = { 788 + { 789 + .name = "map", 790 + .mem_size = MEM_SIZE_MAP_PAGES, 791 + .guest_code = guest_code_test_memslot_map, 792 + .loop = test_memslot_map_loop, 793 + }, 794 + { 795 + .name = "unmap", 796 + .mem_size = MEM_TEST_UNMAP_SIZE_PAGES + 1, 797 + .guest_code = guest_code_test_memslot_unmap, 798 + .loop = test_memslot_unmap_loop, 799 + }, 800 + { 801 + .name = "unmap chunked", 802 + .mem_size = MEM_TEST_UNMAP_SIZE_PAGES + 1, 803 + .guest_code = guest_code_test_memslot_unmap, 804 + .loop = test_memslot_unmap_loop_chunked, 805 + }, 806 + { 807 + .name = "move active area", 808 + .guest_code = guest_code_test_memslot_move, 809 + .prepare = test_memslot_move_prepare_active, 810 + .loop = test_memslot_move_loop, 811 + }, 812 + { 813 + .name = "move inactive area", 814 + .guest_code = guest_code_test_memslot_move, 815 + .prepare = test_memslot_move_prepare_inactive, 816 + .loop = test_memslot_move_loop, 817 + }, 818 + { 819 + .name = "RW", 820 + .guest_code = guest_code_test_memslot_rw, 821 + .loop = test_memslot_rw_loop 822 + }, 823 + }; 824 + 825 + #define NTESTS ARRAY_SIZE(tests) 826 + 827 + struct test_args { 828 + int tfirst; 829 + int tlast; 830 + int nslots; 831 + int seconds; 832 + int runs; 833 + }; 834 + 835 + static void help(char *name, struct test_args *targs) 836 + { 837 + int ctr; 838 + 839 + pr_info("usage: %s [-h] [-v] [-d] [-s slots] [-f first_test] [-e last_test] [-l test_length] [-r run_count]\n", 840 + name); 841 + pr_info(" -h: print this help screen.\n"); 842 + pr_info(" -v: enable verbose mode (not for benchmarking).\n"); 843 + pr_info(" -d: enable extra debug checks.\n"); 844 + pr_info(" -s: specify memslot count cap (-1 means no cap; currently: %i)\n", 845 + targs->nslots); 846 + pr_info(" -f: specify the first test to run (currently: %i; max %zu)\n", 847 + targs->tfirst, NTESTS - 1); 848 + pr_info(" -e: specify the last test to run (currently: %i; max %zu)\n", 849 + targs->tlast, NTESTS - 1); 850 + pr_info(" -l: specify the test length in seconds (currently: %i)\n", 851 + targs->seconds); 852 + pr_info(" -r: specify the number of runs per test (currently: %i)\n", 853 + targs->runs); 854 + 855 + pr_info("\nAvailable tests:\n"); 856 + for (ctr = 0; ctr < NTESTS; ctr++) 857 + pr_info("%d: %s\n", ctr, tests[ctr].name); 858 + } 859 + 860 + static bool parse_args(int argc, char *argv[], 861 + struct test_args *targs) 862 + { 863 + int opt; 864 + 865 + while ((opt = getopt(argc, argv, "hvds:f:e:l:r:")) != -1) { 866 + switch (opt) { 867 + case 'h': 868 + default: 869 + help(argv[0], targs); 870 + return false; 871 + case 'v': 872 + verbose = true; 873 + break; 874 + case 'd': 875 + map_unmap_verify = true; 876 + break; 877 + case 's': 878 + targs->nslots = atoi(optarg); 879 + if (targs->nslots <= 0 && targs->nslots != -1) { 880 + pr_info("Slot count cap has to be positive or -1 for no cap\n"); 881 + return false; 882 + } 883 + break; 884 + case 'f': 885 + targs->tfirst = atoi(optarg); 886 + if (targs->tfirst < 0) { 887 + pr_info("First test to run has to be non-negative\n"); 888 + return false; 889 + } 890 + break; 891 + case 'e': 892 + targs->tlast = atoi(optarg); 893 + if (targs->tlast < 0 || targs->tlast >= NTESTS) { 894 + pr_info("Last test to run has to be non-negative and less than %zu\n", 895 + NTESTS); 896 + return false; 897 + } 898 + break; 899 + case 'l': 900 + targs->seconds = atoi(optarg); 901 + if (targs->seconds < 0) { 902 + pr_info("Test length in seconds has to be non-negative\n"); 903 + return false; 904 + } 905 + break; 906 + case 'r': 907 + targs->runs = atoi(optarg); 908 + if (targs->runs <= 0) { 909 + pr_info("Runs per test has to be positive\n"); 910 + return false; 911 + } 912 + break; 913 + } 914 + } 915 + 916 + if (optind < argc) { 917 + help(argv[0], targs); 918 + return false; 919 + } 920 + 921 + if (targs->tfirst > targs->tlast) { 922 + pr_info("First test to run cannot be greater than the last test to run\n"); 923 + return false; 924 + } 925 + 926 + return true; 927 + } 928 + 929 + struct test_result { 930 + struct timespec slot_runtime, guest_runtime, iter_runtime; 931 + int64_t slottimens, runtimens; 932 + uint64_t nloops; 933 + }; 934 + 935 + static bool test_loop(const struct test_data *data, 936 + const struct test_args *targs, 937 + struct test_result *rbestslottime, 938 + struct test_result *rbestruntime) 939 + { 940 + uint64_t maxslots; 941 + struct test_result result; 942 + 943 + result.nloops = 0; 944 + if (!test_execute(targs->nslots, &maxslots, targs->seconds, data, 945 + &result.nloops, 946 + &result.slot_runtime, &result.guest_runtime)) { 947 + if (maxslots) 948 + pr_info("Memslot count too high for this test, decrease the cap (max is %"PRIu64")\n", 949 + maxslots); 950 + else 951 + pr_info("Memslot count may be too high for this test, try adjusting the cap\n"); 952 + 953 + return false; 954 + } 955 + 956 + pr_info("Test took %ld.%.9lds for slot setup + %ld.%.9lds all iterations\n", 957 + result.slot_runtime.tv_sec, result.slot_runtime.tv_nsec, 958 + result.guest_runtime.tv_sec, result.guest_runtime.tv_nsec); 959 + if (!result.nloops) { 960 + pr_info("No full loops done - too short test time or system too loaded?\n"); 961 + return true; 962 + } 963 + 964 + result.iter_runtime = timespec_div(result.guest_runtime, 965 + result.nloops); 966 + pr_info("Done %"PRIu64" iterations, avg %ld.%.9lds each\n", 967 + result.nloops, 968 + result.iter_runtime.tv_sec, 969 + result.iter_runtime.tv_nsec); 970 + result.slottimens = timespec_to_ns(result.slot_runtime); 971 + result.runtimens = timespec_to_ns(result.iter_runtime); 972 + 973 + /* 974 + * Only rank the slot setup time for tests using the whole test memory 975 + * area so they are comparable 976 + */ 977 + if (!data->mem_size && 978 + (!rbestslottime->slottimens || 979 + result.slottimens < rbestslottime->slottimens)) 980 + *rbestslottime = result; 981 + if (!rbestruntime->runtimens || 982 + result.runtimens < rbestruntime->runtimens) 983 + *rbestruntime = result; 984 + 985 + return true; 986 + } 987 + 988 + int main(int argc, char *argv[]) 989 + { 990 + struct test_args targs = { 991 + .tfirst = 0, 992 + .tlast = NTESTS - 1, 993 + .nslots = -1, 994 + .seconds = 5, 995 + .runs = 1, 996 + }; 997 + struct test_result rbestslottime; 998 + int tctr; 999 + 1000 + /* Tell stdout not to buffer its content */ 1001 + setbuf(stdout, NULL); 1002 + 1003 + if (!parse_args(argc, argv, &targs)) 1004 + return -1; 1005 + 1006 + rbestslottime.slottimens = 0; 1007 + for (tctr = targs.tfirst; tctr <= targs.tlast; tctr++) { 1008 + const struct test_data *data = &tests[tctr]; 1009 + unsigned int runctr; 1010 + struct test_result rbestruntime; 1011 + 1012 + if (tctr > targs.tfirst) 1013 + pr_info("\n"); 1014 + 1015 + pr_info("Testing %s performance with %i runs, %d seconds each\n", 1016 + data->name, targs.runs, targs.seconds); 1017 + 1018 + rbestruntime.runtimens = 0; 1019 + for (runctr = 0; runctr < targs.runs; runctr++) 1020 + if (!test_loop(data, &targs, 1021 + &rbestslottime, &rbestruntime)) 1022 + break; 1023 + 1024 + if (rbestruntime.runtimens) 1025 + pr_info("Best runtime result was %ld.%.9lds per iteration (with %"PRIu64" iterations)\n", 1026 + rbestruntime.iter_runtime.tv_sec, 1027 + rbestruntime.iter_runtime.tv_nsec, 1028 + rbestruntime.nloops); 1029 + } 1030 + 1031 + if (rbestslottime.slottimens) 1032 + pr_info("Best slot setup time for the whole test area was %ld.%.9lds\n", 1033 + rbestslottime.slot_runtime.tv_sec, 1034 + rbestslottime.slot_runtime.tv_nsec); 1035 + 1036 + return 0; 1037 + }
+5
tools/testing/selftests/kvm/x86_64/get_cpuid_test.c
··· 19 19 u32 function; 20 20 u32 index; 21 21 } mangled_cpuids[] = { 22 + /* 23 + * These entries depend on the vCPU's XCR0 register and IA32_XSS MSR, 24 + * which are not controlled for by this test. 25 + */ 22 26 {.function = 0xd, .index = 0}, 27 + {.function = 0xd, .index = 1}, 23 28 }; 24 29 25 30 static void test_guest_cpuids(struct kvm_cpuid2 *guest_cpuid)
+2 -6
tools/testing/selftests/kvm/x86_64/get_msr_index_features.c
··· 37 37 int old_res, res, kvm_fd, r; 38 38 struct kvm_msr_list *list; 39 39 40 - kvm_fd = open(KVM_DEV_PATH, O_RDONLY); 41 - if (kvm_fd < 0) 42 - exit(KSFT_SKIP); 40 + kvm_fd = open_kvm_dev_path_or_exit(); 43 41 44 42 old_res = kvm_num_index_msrs(kvm_fd, 0); 45 43 TEST_ASSERT(old_res != 0, "Expecting nmsrs to be > 0"); ··· 99 101 int res, old_res, i, kvm_fd; 100 102 struct kvm_msr_list *feature_list; 101 103 102 - kvm_fd = open(KVM_DEV_PATH, O_RDONLY); 103 - if (kvm_fd < 0) 104 - exit(KSFT_SKIP); 104 + kvm_fd = open_kvm_dev_path_or_exit(); 105 105 106 106 old_res = kvm_num_feature_msrs(kvm_fd, 0); 107 107 TEST_ASSERT(old_res != 0, "Expecting nmsrs to be > 0");
+1
tools/testing/selftests/nci/.gitignore
··· 1 + /nci_dev
+4 -4
tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json
··· 9 9 "setup": [ 10 10 "$IP link add dev $DUMMY type dummy || /bin/true" 11 11 ], 12 - "cmdUnderTest": "$TC qdisc add dev $DUMMY root fq_pie flows 65536", 13 - "expExitCode": "2", 12 + "cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root fq_pie flows 65536", 13 + "expExitCode": "0", 14 14 "verifyCmd": "$TC qdisc show dev $DUMMY", 15 - "matchPattern": "qdisc", 16 - "matchCount": "0", 15 + "matchPattern": "qdisc fq_pie 1: root refcnt 2 limit 10240p flows 65536", 16 + "matchCount": "1", 17 17 "teardown": [ 18 18 "$IP link del dev $DUMMY" 19 19 ]
+4 -2
virt/kvm/kvm_main.c
··· 307 307 { 308 308 return kvm_make_all_cpus_request_except(kvm, req, NULL); 309 309 } 310 + EXPORT_SYMBOL_GPL(kvm_make_all_cpus_request); 310 311 311 312 #ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL 312 313 void kvm_flush_remote_tlbs(struct kvm *kvm) ··· 2930 2929 goto out; 2931 2930 if (signal_pending(current)) 2932 2931 goto out; 2932 + if (kvm_check_request(KVM_REQ_UNBLOCK, vcpu)) 2933 + goto out; 2933 2934 2934 2935 ret = 0; 2935 2936 out: ··· 2976 2973 goto out; 2977 2974 } 2978 2975 poll_end = cur = ktime_get(); 2979 - } while (single_task_running() && !need_resched() && 2980 - ktime_before(cur, stop)); 2976 + } while (kvm_vcpu_can_poll(cur, stop)); 2981 2977 } 2982 2978 2983 2979 prepare_to_rcuwait(&vcpu->wait);
+6 -10
virt/lib/irqbypass.c
··· 40 40 if (prod->add_consumer) 41 41 ret = prod->add_consumer(prod, cons); 42 42 43 - if (ret) 44 - goto err_add_consumer; 45 - 46 - ret = cons->add_producer(cons, prod); 47 - if (ret) 48 - goto err_add_producer; 43 + if (!ret) { 44 + ret = cons->add_producer(cons, prod); 45 + if (ret && prod->del_consumer) 46 + prod->del_consumer(prod, cons); 47 + } 49 48 50 49 if (cons->start) 51 50 cons->start(cons); 52 51 if (prod->start) 53 52 prod->start(prod); 54 - err_add_producer: 55 - if (prod->del_consumer) 56 - prod->del_consumer(prod, cons); 57 - err_add_consumer: 53 + 58 54 return ret; 59 55 } 60 56