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

Merge 5.15-rc4 into char-misc-next

We need the char-misc fixes in here as well.

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

+4145 -2314
+42 -4
Documentation/devicetree/bindings/interconnect/qcom,sdm660.yaml
··· 31 31 32 32 clocks: 33 33 minItems: 1 34 - maxItems: 3 34 + maxItems: 7 35 35 36 36 clock-names: 37 37 minItems: 1 38 - maxItems: 3 38 + maxItems: 7 39 39 40 40 required: 41 41 - compatible ··· 72 72 contains: 73 73 enum: 74 74 - qcom,sdm660-a2noc 75 + then: 76 + properties: 77 + clocks: 78 + items: 79 + - description: Bus Clock. 80 + - description: Bus A Clock. 81 + - description: IPA Clock. 82 + - description: UFS AXI Clock. 83 + - description: Aggregate2 UFS AXI Clock. 84 + - description: Aggregate2 USB3 AXI Clock. 85 + - description: Config NoC USB2 AXI Clock. 86 + clock-names: 87 + items: 88 + - const: bus 89 + - const: bus_a 90 + - const: ipa 91 + - const: ufs_axi 92 + - const: aggre2_ufs_axi 93 + - const: aggre2_usb3_axi 94 + - const: cfg_noc_usb2_axi 95 + 96 + - if: 97 + properties: 98 + compatible: 99 + contains: 100 + enum: 75 101 - qcom,sdm660-bimc 76 102 - qcom,sdm660-cnoc 77 103 - qcom,sdm660-gnoc ··· 117 91 - | 118 92 #include <dt-bindings/clock/qcom,rpmcc.h> 119 93 #include <dt-bindings/clock/qcom,mmcc-sdm660.h> 94 + #include <dt-bindings/clock/qcom,gcc-sdm660.h> 120 95 121 96 bimc: interconnect@1008000 { 122 97 compatible = "qcom,sdm660-bimc"; ··· 150 123 compatible = "qcom,sdm660-a2noc"; 151 124 reg = <0x01704000 0xc100>; 152 125 #interconnect-cells = <1>; 153 - clock-names = "bus", "bus_a"; 126 + clock-names = "bus", 127 + "bus_a", 128 + "ipa", 129 + "ufs_axi", 130 + "aggre2_ufs_axi", 131 + "aggre2_usb3_axi", 132 + "cfg_noc_usb2_axi"; 154 133 clocks = <&rpmcc RPM_SMD_AGGR2_NOC_CLK>, 155 - <&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>; 134 + <&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>, 135 + <&rpmcc RPM_SMD_IPA_CLK>, 136 + <&gcc GCC_UFS_AXI_CLK>, 137 + <&gcc GCC_AGGRE2_UFS_AXI_CLK>, 138 + <&gcc GCC_AGGRE2_USB3_AXI_CLK>, 139 + <&gcc GCC_CFG_NOC_USB2_AXI_CLK>; 156 140 }; 157 141 158 142 mnoc: interconnect@1745000 {
-17
Documentation/hwmon/k10temp.rst
··· 132 132 Core Complex Die (CCD) temperatures. Up to 8 such temperatures are reported 133 133 as temp{3..10}_input, labeled Tccd{1..8}. Actual support depends on the CPU 134 134 variant. 135 - 136 - Various Family 17h and 18h CPUs report voltage and current telemetry 137 - information. The following attributes may be reported. 138 - 139 - Attribute Label Description 140 - =============== ======= ================ 141 - in0_input Vcore Core voltage 142 - in1_input Vsoc SoC voltage 143 - curr1_input Icore Core current 144 - curr2_input Isoc SoC current 145 - =============== ======= ================ 146 - 147 - Current values are raw (unscaled) as reported by the CPU. Core current is 148 - reported as multiples of 1A / LSB. SoC is reported as multiples of 0.25A 149 - / LSB. The real current is board specific. Reported currents should be seen 150 - as rough guidance, and should be scaled using sensors3.conf as appropriate 151 - for a given board.
+16 -12
MAINTAINERS
··· 414 414 F: drivers/acpi/pmic/ 415 415 416 416 ACPI THERMAL DRIVER 417 - M: Zhang Rui <rui.zhang@intel.com> 417 + M: Rafael J. Wysocki <rafael@kernel.org> 418 + R: Zhang Rui <rui.zhang@intel.com> 418 419 L: linux-acpi@vger.kernel.org 419 420 S: Supported 420 421 W: https://01.org/linux-acpi ··· 811 810 F: drivers/dma/altera-msgdma.c 812 811 813 812 ALTERA PIO DRIVER 814 - M: Joyce Ooi <joyce.ooi@intel.com> 813 + M: Mun Yew Tham <mun.yew.tham@intel.com> 815 814 L: linux-gpio@vger.kernel.org 816 815 S: Maintained 817 816 F: drivers/gpio/gpio-altera.c ··· 2962 2961 F: include/linux/async_tx.h 2963 2962 2964 2963 AT24 EEPROM DRIVER 2965 - M: Bartosz Golaszewski <bgolaszewski@baylibre.com> 2964 + M: Bartosz Golaszewski <brgl@bgdev.pl> 2966 2965 L: linux-i2c@vger.kernel.org 2967 2966 S: Maintained 2968 2967 T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git ··· 3385 3384 F: Documentation/userspace-api/ebpf/ 3386 3385 F: arch/*/net/* 3387 3386 F: include/linux/bpf* 3387 + F: include/linux/btf* 3388 3388 F: include/linux/filter.h 3389 3389 F: include/trace/events/xdp.h 3390 3390 F: include/uapi/linux/bpf* 3391 + F: include/uapi/linux/btf* 3391 3392 F: include/uapi/linux/filter.h 3392 3393 F: kernel/bpf/ 3393 3394 F: kernel/trace/bpf_trace.c ··· 3823 3820 3824 3821 BROADCOM NETXTREME-E ROCE DRIVER 3825 3822 M: Selvin Xavier <selvin.xavier@broadcom.com> 3826 - M: Naresh Kumar PBS <nareshkumar.pbs@broadcom.com> 3827 3823 L: linux-rdma@vger.kernel.org 3828 3824 S: Supported 3829 3825 W: http://www.broadcom.com ··· 4657 4655 T: git git://git.samba.org/sfrench/cifs-2.6.git 4658 4656 F: Documentation/admin-guide/cifs/ 4659 4657 F: fs/cifs/ 4660 - F: fs/cifs_common/ 4658 + F: fs/smbfs_common/ 4661 4659 4662 4660 COMPACTPCI HOTPLUG CORE 4663 4661 M: Scott Murray <scott@spiteful.org> ··· 7987 7985 7988 7986 GPIO SUBSYSTEM 7989 7987 M: Linus Walleij <linus.walleij@linaro.org> 7990 - M: Bartosz Golaszewski <bgolaszewski@baylibre.com> 7988 + M: Bartosz Golaszewski <brgl@bgdev.pl> 7991 7989 L: linux-gpio@vger.kernel.org 7992 7990 S: Maintained 7993 7991 T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git ··· 10195 10193 L: linux-cifs@vger.kernel.org 10196 10194 S: Maintained 10197 10195 T: git git://git.samba.org/ksmbd.git 10198 - F: fs/cifs_common/ 10199 10196 F: fs/ksmbd/ 10197 + F: fs/smbfs_common/ 10200 10198 10201 10199 KERNEL UNIT TESTING FRAMEWORK (KUnit) 10202 10200 M: Brendan Higgins <brendanhiggins@google.com> ··· 11368 11366 F: drivers/iio/proximity/mb1232.c 11369 11367 11370 11368 MAXIM MAX77650 PMIC MFD DRIVER 11371 - M: Bartosz Golaszewski <bgolaszewski@baylibre.com> 11369 + M: Bartosz Golaszewski <brgl@bgdev.pl> 11372 11370 L: linux-kernel@vger.kernel.org 11373 11371 S: Maintained 11374 11372 F: Documentation/devicetree/bindings/*/*max77650.yaml ··· 17885 17883 M: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> 17886 17884 L: alsa-devel@alsa-project.org (moderated for non-subscribers) 17887 17885 S: Maintained 17888 - F: Documentation/devicetree/bindings/iio/adc/st,stm32-*.yaml 17886 + F: Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.yaml 17887 + F: Documentation/devicetree/bindings/sound/st,stm32-*.yaml 17889 17888 F: sound/soc/stm/ 17890 17889 17891 17890 STM32 TIMER/LPTIMER DRIVERS ··· 18550 18547 F: drivers/media/radio/radio-raremono.c 18551 18548 18552 18549 THERMAL 18553 - M: Zhang Rui <rui.zhang@intel.com> 18550 + M: Rafael J. Wysocki <rafael@kernel.org> 18554 18551 M: Daniel Lezcano <daniel.lezcano@linaro.org> 18555 18552 R: Amit Kucheria <amitk@kernel.org> 18553 + R: Zhang Rui <rui.zhang@intel.com> 18556 18554 L: linux-pm@vger.kernel.org 18557 18555 S: Supported 18558 18556 Q: https://patchwork.kernel.org/project/linux-pm/list/ 18559 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git 18557 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal 18560 18558 F: Documentation/devicetree/bindings/thermal/ 18561 18559 F: drivers/thermal/ 18562 18560 F: include/linux/cpu_cooling.h ··· 18686 18682 18687 18683 TI DAVINCI MACHINE SUPPORT 18688 18684 M: Sekhar Nori <nsekhar@ti.com> 18689 - R: Bartosz Golaszewski <bgolaszewski@baylibre.com> 18685 + R: Bartosz Golaszewski <brgl@bgdev.pl> 18690 18686 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 18691 18687 S: Supported 18692 18688 T: git git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci.git
+1 -1
Makefile
··· 2 2 VERSION = 5 3 3 PATCHLEVEL = 15 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc3 5 + EXTRAVERSION = -rc4 6 6 NAME = Opossums on Parade 7 7 8 8 # *DOCUMENTATION*
+1 -1
arch/arm64/kvm/hyp/nvhe/Makefile
··· 54 54 # runtime. Because the hypervisor is part of the kernel binary, relocations 55 55 # produce a kernel VA. We enumerate relocations targeting hyp at build time 56 56 # and convert the kernel VAs at those positions to hyp VAs. 57 - $(obj)/hyp-reloc.S: $(obj)/kvm_nvhe.tmp.o $(obj)/gen-hyprel 57 + $(obj)/hyp-reloc.S: $(obj)/kvm_nvhe.tmp.o $(obj)/gen-hyprel FORCE 58 58 $(call if_changed,hyprel) 59 59 60 60 # 5) Compile hyp-reloc.S and link it into the existing partially linked object.
-3
arch/arm64/kvm/perf.c
··· 50 50 51 51 int kvm_perf_init(void) 52 52 { 53 - if (kvm_pmu_probe_pmuver() != ID_AA64DFR0_PMUVER_IMP_DEF && !is_protected_kvm_enabled()) 54 - static_branch_enable(&kvm_arm_pmu_available); 55 - 56 53 return perf_register_guest_info_callbacks(&kvm_guest_cbs); 57 54 } 58 55
+8 -1
arch/arm64/kvm/pmu-emul.c
··· 740 740 kvm_pmu_create_perf_event(vcpu, select_idx); 741 741 } 742 742 743 - int kvm_pmu_probe_pmuver(void) 743 + void kvm_host_pmu_init(struct arm_pmu *pmu) 744 + { 745 + if (pmu->pmuver != 0 && pmu->pmuver != ID_AA64DFR0_PMUVER_IMP_DEF && 746 + !kvm_arm_support_pmu_v3() && !is_protected_kvm_enabled()) 747 + static_branch_enable(&kvm_arm_pmu_available); 748 + } 749 + 750 + static int kvm_pmu_probe_pmuver(void) 744 751 { 745 752 struct perf_event_attr attr = { }; 746 753 struct perf_event *event;
-4
arch/m68k/68000/entry.S
··· 15 15 #include <asm/unistd.h> 16 16 #include <asm/errno.h> 17 17 #include <asm/setup.h> 18 - #include <asm/segment.h> 19 18 #include <asm/traps.h> 20 19 #include <asm/asm-offsets.h> 21 20 #include <asm/entry.h> ··· 24 25 .globl system_call 25 26 .globl resume 26 27 .globl ret_from_exception 27 - .globl ret_from_signal 28 28 .globl sys_call_table 29 29 .globl bad_interrupt 30 30 .globl inthandler1 ··· 57 59 subql #4,%sp /* dummy return address */ 58 60 SAVE_SWITCH_STACK 59 61 jbsr syscall_trace_leave 60 - 61 - ret_from_signal: 62 62 RESTORE_SWITCH_STACK 63 63 addql #4,%sp 64 64 jra ret_from_exception
-1
arch/m68k/Kconfig
··· 29 29 select NO_DMA if !MMU && !COLDFIRE 30 30 select OLD_SIGACTION 31 31 select OLD_SIGSUSPEND3 32 - select SET_FS 33 32 select UACCESS_MEMCPY if !MMU 34 33 select VIRT_TO_BUS 35 34 select ZONE_DMA
-4
arch/m68k/coldfire/entry.S
··· 31 31 #include <asm/thread_info.h> 32 32 #include <asm/errno.h> 33 33 #include <asm/setup.h> 34 - #include <asm/segment.h> 35 34 #include <asm/asm-offsets.h> 36 35 #include <asm/entry.h> 37 36 ··· 50 51 .globl system_call 51 52 .globl resume 52 53 .globl ret_from_exception 53 - .globl ret_from_signal 54 54 .globl sys_call_table 55 55 .globl inthandler 56 56 ··· 96 98 subql #4,%sp /* dummy return address */ 97 99 SAVE_SWITCH_STACK 98 100 jbsr syscall_trace_leave 99 - 100 - ret_from_signal: 101 101 RESTORE_SWITCH_STACK 102 102 addql #4,%sp 103 103
+28 -3
arch/m68k/include/asm/processor.h
··· 9 9 #define __ASM_M68K_PROCESSOR_H 10 10 11 11 #include <linux/thread_info.h> 12 - #include <asm/segment.h> 13 12 #include <asm/fpu.h> 14 13 #include <asm/ptrace.h> 15 14 ··· 74 75 #define TASK_UNMAPPED_BASE 0 75 76 #endif 76 77 78 + /* Address spaces (or Function Codes in Motorola lingo) */ 79 + #define USER_DATA 1 80 + #define USER_PROGRAM 2 81 + #define SUPER_DATA 5 82 + #define SUPER_PROGRAM 6 83 + #define CPU_SPACE 7 84 + 85 + #ifdef CONFIG_CPU_HAS_ADDRESS_SPACES 86 + /* 87 + * Set the SFC/DFC registers for special MM operations. For most normal 88 + * operation these remain set to USER_DATA for the uaccess routines. 89 + */ 90 + static inline void set_fc(unsigned long val) 91 + { 92 + WARN_ON_ONCE(in_interrupt()); 93 + 94 + __asm__ __volatile__ ("movec %0,%/sfc\n\t" 95 + "movec %0,%/dfc\n\t" 96 + : /* no outputs */ : "r" (val) : "memory"); 97 + } 98 + #else 99 + static inline void set_fc(unsigned long val) 100 + { 101 + } 102 + #endif /* CONFIG_CPU_HAS_ADDRESS_SPACES */ 103 + 77 104 struct thread_struct { 78 105 unsigned long ksp; /* kernel stack pointer */ 79 106 unsigned long usp; /* user stack pointer */ 80 107 unsigned short sr; /* saved status register */ 81 - unsigned short fs; /* saved fs (sfc, dfc) */ 108 + unsigned short fc; /* saved fc (sfc, dfc) */ 82 109 unsigned long crp[2]; /* cpu root pointer */ 83 110 unsigned long esp0; /* points to SR of stack frame */ 84 111 unsigned long faddr; /* info about last fault */ ··· 117 92 #define INIT_THREAD { \ 118 93 .ksp = sizeof(init_stack) + (unsigned long) init_stack, \ 119 94 .sr = PS_S, \ 120 - .fs = __KERNEL_DS, \ 95 + .fc = USER_DATA, \ 121 96 } 122 97 123 98 /*
-59
arch/m68k/include/asm/segment.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _M68K_SEGMENT_H 3 - #define _M68K_SEGMENT_H 4 - 5 - /* define constants */ 6 - /* Address spaces (FC0-FC2) */ 7 - #define USER_DATA (1) 8 - #ifndef __USER_DS 9 - #define __USER_DS (USER_DATA) 10 - #endif 11 - #define USER_PROGRAM (2) 12 - #define SUPER_DATA (5) 13 - #ifndef __KERNEL_DS 14 - #define __KERNEL_DS (SUPER_DATA) 15 - #endif 16 - #define SUPER_PROGRAM (6) 17 - #define CPU_SPACE (7) 18 - 19 - #ifndef __ASSEMBLY__ 20 - 21 - typedef struct { 22 - unsigned long seg; 23 - } mm_segment_t; 24 - 25 - #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 26 - 27 - #ifdef CONFIG_CPU_HAS_ADDRESS_SPACES 28 - /* 29 - * Get/set the SFC/DFC registers for MOVES instructions 30 - */ 31 - #define USER_DS MAKE_MM_SEG(__USER_DS) 32 - #define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS) 33 - 34 - static inline mm_segment_t get_fs(void) 35 - { 36 - mm_segment_t _v; 37 - __asm__ ("movec %/dfc,%0":"=r" (_v.seg):); 38 - return _v; 39 - } 40 - 41 - static inline void set_fs(mm_segment_t val) 42 - { 43 - __asm__ __volatile__ ("movec %0,%/sfc\n\t" 44 - "movec %0,%/dfc\n\t" 45 - : /* no outputs */ : "r" (val.seg) : "memory"); 46 - } 47 - 48 - #else 49 - #define USER_DS MAKE_MM_SEG(TASK_SIZE) 50 - #define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF) 51 - #define get_fs() (current_thread_info()->addr_limit) 52 - #define set_fs(x) (current_thread_info()->addr_limit = (x)) 53 - #endif 54 - 55 - #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg) 56 - 57 - #endif /* __ASSEMBLY__ */ 58 - 59 - #endif /* _M68K_SEGMENT_H */
-3
arch/m68k/include/asm/thread_info.h
··· 4 4 5 5 #include <asm/types.h> 6 6 #include <asm/page.h> 7 - #include <asm/segment.h> 8 7 9 8 /* 10 9 * On machines with 4k pages we default to an 8k thread size, though we ··· 26 27 struct thread_info { 27 28 struct task_struct *task; /* main task structure */ 28 29 unsigned long flags; 29 - mm_segment_t addr_limit; /* thread address space */ 30 30 int preempt_count; /* 0 => preemptable, <0 => BUG */ 31 31 __u32 cpu; /* should always be 0 on m68k */ 32 32 unsigned long tp_value; /* thread pointer */ ··· 35 37 #define INIT_THREAD_INFO(tsk) \ 36 38 { \ 37 39 .task = &tsk, \ 38 - .addr_limit = KERNEL_DS, \ 39 40 .preempt_count = INIT_PREEMPT_COUNT, \ 40 41 } 41 42
+3 -8
arch/m68k/include/asm/tlbflush.h
··· 13 13 if (CPU_IS_COLDFIRE) { 14 14 mmu_write(MMUOR, MMUOR_CNL); 15 15 } else if (CPU_IS_040_OR_060) { 16 - mm_segment_t old_fs = get_fs(); 17 - set_fs(KERNEL_DS); 16 + set_fc(SUPER_DATA); 18 17 __asm__ __volatile__(".chip 68040\n\t" 19 18 "pflush (%0)\n\t" 20 19 ".chip 68k" 21 20 : : "a" (addr)); 22 - set_fs(old_fs); 21 + set_fc(USER_DATA); 23 22 } else if (CPU_IS_020_OR_030) 24 23 __asm__ __volatile__("pflush #4,#4,(%0)" : : "a" (addr)); 25 24 } ··· 83 84 84 85 static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr) 85 86 { 86 - if (vma->vm_mm == current->active_mm) { 87 - mm_segment_t old_fs = force_uaccess_begin(); 88 - 87 + if (vma->vm_mm == current->active_mm) 89 88 __flush_tlb_one(addr); 90 - force_uaccess_end(old_fs); 91 - } 92 89 } 93 90 94 91 static inline void flush_tlb_range(struct vm_area_struct *vma,
+4
arch/m68k/include/asm/traps.h
··· 267 267 } un; 268 268 }; 269 269 270 + #ifdef CONFIG_M68040 271 + asmlinkage void berr_040cleanup(struct frame *fp); 272 + #endif 273 + 270 274 #endif /* __ASSEMBLY__ */ 271 275 272 276 #endif /* _M68K_TRAPS_H */
+141 -74
arch/m68k/include/asm/uaccess.h
··· 9 9 */ 10 10 #include <linux/compiler.h> 11 11 #include <linux/types.h> 12 - #include <asm/segment.h> 13 12 #include <asm/extable.h> 14 13 15 14 /* We let the MMU do all checking */ 16 15 static inline int access_ok(const void __user *addr, 17 16 unsigned long size) 18 17 { 18 + /* 19 + * XXX: for !CONFIG_CPU_HAS_ADDRESS_SPACES this really needs to check 20 + * for TASK_SIZE! 21 + */ 19 22 return 1; 20 23 } 21 24 ··· 38 35 #define MOVES "move" 39 36 #endif 40 37 41 - extern int __put_user_bad(void); 42 - extern int __get_user_bad(void); 43 - 44 - #define __put_user_asm(res, x, ptr, bwl, reg, err) \ 38 + #define __put_user_asm(inst, res, x, ptr, bwl, reg, err) \ 45 39 asm volatile ("\n" \ 46 - "1: "MOVES"."#bwl" %2,%1\n" \ 40 + "1: "inst"."#bwl" %2,%1\n" \ 47 41 "2:\n" \ 48 42 " .section .fixup,\"ax\"\n" \ 49 43 " .even\n" \ ··· 56 56 : "+d" (res), "=m" (*(ptr)) \ 57 57 : #reg (x), "i" (err)) 58 58 59 + #define __put_user_asm8(inst, res, x, ptr) \ 60 + do { \ 61 + const void *__pu_ptr = (const void __force *)(ptr); \ 62 + \ 63 + asm volatile ("\n" \ 64 + "1: "inst".l %2,(%1)+\n" \ 65 + "2: "inst".l %R2,(%1)\n" \ 66 + "3:\n" \ 67 + " .section .fixup,\"ax\"\n" \ 68 + " .even\n" \ 69 + "10: movel %3,%0\n" \ 70 + " jra 3b\n" \ 71 + " .previous\n" \ 72 + "\n" \ 73 + " .section __ex_table,\"a\"\n" \ 74 + " .align 4\n" \ 75 + " .long 1b,10b\n" \ 76 + " .long 2b,10b\n" \ 77 + " .long 3b,10b\n" \ 78 + " .previous" \ 79 + : "+d" (res), "+a" (__pu_ptr) \ 80 + : "r" (x), "i" (-EFAULT) \ 81 + : "memory"); \ 82 + } while (0) 83 + 59 84 /* 60 85 * These are the main single-value transfer routines. They automatically 61 86 * use the right size if we just have the right pointer type. ··· 93 68 __chk_user_ptr(ptr); \ 94 69 switch (sizeof (*(ptr))) { \ 95 70 case 1: \ 96 - __put_user_asm(__pu_err, __pu_val, ptr, b, d, -EFAULT); \ 71 + __put_user_asm(MOVES, __pu_err, __pu_val, ptr, b, d, -EFAULT); \ 97 72 break; \ 98 73 case 2: \ 99 - __put_user_asm(__pu_err, __pu_val, ptr, w, r, -EFAULT); \ 74 + __put_user_asm(MOVES, __pu_err, __pu_val, ptr, w, r, -EFAULT); \ 100 75 break; \ 101 76 case 4: \ 102 - __put_user_asm(__pu_err, __pu_val, ptr, l, r, -EFAULT); \ 77 + __put_user_asm(MOVES, __pu_err, __pu_val, ptr, l, r, -EFAULT); \ 103 78 break; \ 104 79 case 8: \ 105 - { \ 106 - const void __user *__pu_ptr = (ptr); \ 107 - asm volatile ("\n" \ 108 - "1: "MOVES".l %2,(%1)+\n" \ 109 - "2: "MOVES".l %R2,(%1)\n" \ 110 - "3:\n" \ 111 - " .section .fixup,\"ax\"\n" \ 112 - " .even\n" \ 113 - "10: movel %3,%0\n" \ 114 - " jra 3b\n" \ 115 - " .previous\n" \ 116 - "\n" \ 117 - " .section __ex_table,\"a\"\n" \ 118 - " .align 4\n" \ 119 - " .long 1b,10b\n" \ 120 - " .long 2b,10b\n" \ 121 - " .long 3b,10b\n" \ 122 - " .previous" \ 123 - : "+d" (__pu_err), "+a" (__pu_ptr) \ 124 - : "r" (__pu_val), "i" (-EFAULT) \ 125 - : "memory"); \ 80 + __put_user_asm8(MOVES, __pu_err, __pu_val, ptr); \ 126 81 break; \ 127 - } \ 128 82 default: \ 129 - __pu_err = __put_user_bad(); \ 130 - break; \ 83 + BUILD_BUG(); \ 131 84 } \ 132 85 __pu_err; \ 133 86 }) 134 87 #define put_user(x, ptr) __put_user(x, ptr) 135 88 136 89 137 - #define __get_user_asm(res, x, ptr, type, bwl, reg, err) ({ \ 90 + #define __get_user_asm(inst, res, x, ptr, type, bwl, reg, err) ({ \ 138 91 type __gu_val; \ 139 92 asm volatile ("\n" \ 140 - "1: "MOVES"."#bwl" %2,%1\n" \ 93 + "1: "inst"."#bwl" %2,%1\n" \ 141 94 "2:\n" \ 142 95 " .section .fixup,\"ax\"\n" \ 143 96 " .even\n" \ ··· 133 130 (x) = (__force typeof(*(ptr)))(__force unsigned long)__gu_val; \ 134 131 }) 135 132 133 + #define __get_user_asm8(inst, res, x, ptr) \ 134 + do { \ 135 + const void *__gu_ptr = (const void __force *)(ptr); \ 136 + union { \ 137 + u64 l; \ 138 + __typeof__(*(ptr)) t; \ 139 + } __gu_val; \ 140 + \ 141 + asm volatile ("\n" \ 142 + "1: "inst".l (%2)+,%1\n" \ 143 + "2: "inst".l (%2),%R1\n" \ 144 + "3:\n" \ 145 + " .section .fixup,\"ax\"\n" \ 146 + " .even\n" \ 147 + "10: move.l %3,%0\n" \ 148 + " sub.l %1,%1\n" \ 149 + " sub.l %R1,%R1\n" \ 150 + " jra 3b\n" \ 151 + " .previous\n" \ 152 + "\n" \ 153 + " .section __ex_table,\"a\"\n" \ 154 + " .align 4\n" \ 155 + " .long 1b,10b\n" \ 156 + " .long 2b,10b\n" \ 157 + " .previous" \ 158 + : "+d" (res), "=&r" (__gu_val.l), \ 159 + "+a" (__gu_ptr) \ 160 + : "i" (-EFAULT) \ 161 + : "memory"); \ 162 + (x) = __gu_val.t; \ 163 + } while (0) 164 + 136 165 #define __get_user(x, ptr) \ 137 166 ({ \ 138 167 int __gu_err = 0; \ 139 168 __chk_user_ptr(ptr); \ 140 169 switch (sizeof(*(ptr))) { \ 141 170 case 1: \ 142 - __get_user_asm(__gu_err, x, ptr, u8, b, d, -EFAULT); \ 171 + __get_user_asm(MOVES, __gu_err, x, ptr, u8, b, d, -EFAULT); \ 143 172 break; \ 144 173 case 2: \ 145 - __get_user_asm(__gu_err, x, ptr, u16, w, r, -EFAULT); \ 174 + __get_user_asm(MOVES, __gu_err, x, ptr, u16, w, r, -EFAULT); \ 146 175 break; \ 147 176 case 4: \ 148 - __get_user_asm(__gu_err, x, ptr, u32, l, r, -EFAULT); \ 177 + __get_user_asm(MOVES, __gu_err, x, ptr, u32, l, r, -EFAULT); \ 149 178 break; \ 150 - case 8: { \ 151 - const void __user *__gu_ptr = (ptr); \ 152 - union { \ 153 - u64 l; \ 154 - __typeof__(*(ptr)) t; \ 155 - } __gu_val; \ 156 - asm volatile ("\n" \ 157 - "1: "MOVES".l (%2)+,%1\n" \ 158 - "2: "MOVES".l (%2),%R1\n" \ 159 - "3:\n" \ 160 - " .section .fixup,\"ax\"\n" \ 161 - " .even\n" \ 162 - "10: move.l %3,%0\n" \ 163 - " sub.l %1,%1\n" \ 164 - " sub.l %R1,%R1\n" \ 165 - " jra 3b\n" \ 166 - " .previous\n" \ 167 - "\n" \ 168 - " .section __ex_table,\"a\"\n" \ 169 - " .align 4\n" \ 170 - " .long 1b,10b\n" \ 171 - " .long 2b,10b\n" \ 172 - " .previous" \ 173 - : "+d" (__gu_err), "=&r" (__gu_val.l), \ 174 - "+a" (__gu_ptr) \ 175 - : "i" (-EFAULT) \ 176 - : "memory"); \ 177 - (x) = __gu_val.t; \ 179 + case 8: \ 180 + __get_user_asm8(MOVES, __gu_err, x, ptr); \ 178 181 break; \ 179 - } \ 180 182 default: \ 181 - __gu_err = __get_user_bad(); \ 182 - break; \ 183 + BUILD_BUG(); \ 183 184 } \ 184 185 __gu_err; \ 185 186 }) ··· 329 322 330 323 switch (n) { 331 324 case 1: 332 - __put_user_asm(res, *(u8 *)from, (u8 __user *)to, b, d, 1); 325 + __put_user_asm(MOVES, res, *(u8 *)from, (u8 __user *)to, 326 + b, d, 1); 333 327 break; 334 328 case 2: 335 - __put_user_asm(res, *(u16 *)from, (u16 __user *)to, w, r, 2); 329 + __put_user_asm(MOVES, res, *(u16 *)from, (u16 __user *)to, 330 + w, r, 2); 336 331 break; 337 332 case 3: 338 333 __constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,); 339 334 break; 340 335 case 4: 341 - __put_user_asm(res, *(u32 *)from, (u32 __user *)to, l, r, 4); 336 + __put_user_asm(MOVES, res, *(u32 *)from, (u32 __user *)to, 337 + l, r, 4); 342 338 break; 343 339 case 5: 344 340 __constant_copy_to_user_asm(res, to, from, tmp, 5, l, b,); ··· 390 380 #define INLINE_COPY_FROM_USER 391 381 #define INLINE_COPY_TO_USER 392 382 393 - #define user_addr_max() \ 394 - (uaccess_kernel() ? ~0UL : TASK_SIZE) 383 + #define HAVE_GET_KERNEL_NOFAULT 384 + 385 + #define __get_kernel_nofault(dst, src, type, err_label) \ 386 + do { \ 387 + type *__gk_dst = (type *)(dst); \ 388 + type *__gk_src = (type *)(src); \ 389 + int __gk_err = 0; \ 390 + \ 391 + switch (sizeof(type)) { \ 392 + case 1: \ 393 + __get_user_asm("move", __gk_err, *__gk_dst, __gk_src, \ 394 + u8, b, d, -EFAULT); \ 395 + break; \ 396 + case 2: \ 397 + __get_user_asm("move", __gk_err, *__gk_dst, __gk_src, \ 398 + u16, w, r, -EFAULT); \ 399 + break; \ 400 + case 4: \ 401 + __get_user_asm("move", __gk_err, *__gk_dst, __gk_src, \ 402 + u32, l, r, -EFAULT); \ 403 + break; \ 404 + case 8: \ 405 + __get_user_asm8("move", __gk_err, *__gk_dst, __gk_src); \ 406 + break; \ 407 + default: \ 408 + BUILD_BUG(); \ 409 + } \ 410 + if (unlikely(__gk_err)) \ 411 + goto err_label; \ 412 + } while (0) 413 + 414 + #define __put_kernel_nofault(dst, src, type, err_label) \ 415 + do { \ 416 + type __pk_src = *(type *)(src); \ 417 + type *__pk_dst = (type *)(dst); \ 418 + int __pk_err = 0; \ 419 + \ 420 + switch (sizeof(type)) { \ 421 + case 1: \ 422 + __put_user_asm("move", __pk_err, __pk_src, __pk_dst, \ 423 + b, d, -EFAULT); \ 424 + break; \ 425 + case 2: \ 426 + __put_user_asm("move", __pk_err, __pk_src, __pk_dst, \ 427 + w, r, -EFAULT); \ 428 + break; \ 429 + case 4: \ 430 + __put_user_asm("move", __pk_err, __pk_src, __pk_dst, \ 431 + l, r, -EFAULT); \ 432 + break; \ 433 + case 8: \ 434 + __put_user_asm8("move", __pk_err, __pk_src, __pk_dst); \ 435 + break; \ 436 + default: \ 437 + BUILD_BUG(); \ 438 + } \ 439 + if (unlikely(__pk_err)) \ 440 + goto err_label; \ 441 + } while (0) 395 442 396 443 extern long strncpy_from_user(char *dst, const char __user *src, long count); 397 444 extern __must_check long strnlen_user(const char __user *str, long n);
+1 -1
arch/m68k/kernel/asm-offsets.c
··· 31 31 DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp)); 32 32 DEFINE(THREAD_USP, offsetof(struct thread_struct, usp)); 33 33 DEFINE(THREAD_SR, offsetof(struct thread_struct, sr)); 34 - DEFINE(THREAD_FS, offsetof(struct thread_struct, fs)); 34 + DEFINE(THREAD_FC, offsetof(struct thread_struct, fc)); 35 35 DEFINE(THREAD_CRP, offsetof(struct thread_struct, crp)); 36 36 DEFINE(THREAD_ESP0, offsetof(struct thread_struct, esp0)); 37 37 DEFINE(THREAD_FPREG, offsetof(struct thread_struct, fp));
+28 -30
arch/m68k/kernel/entry.S
··· 36 36 #include <linux/linkage.h> 37 37 #include <asm/errno.h> 38 38 #include <asm/setup.h> 39 - #include <asm/segment.h> 40 39 #include <asm/traps.h> 41 40 #include <asm/unistd.h> 42 41 #include <asm/asm-offsets.h> ··· 77 78 78 79 ENTRY(sys_sigreturn) 79 80 SAVE_SWITCH_STACK 80 - movel %sp,%sp@- | switch_stack pointer 81 - pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer 81 + movel %sp,%a1 | switch_stack pointer 82 + lea %sp@(SWITCH_STACK_SIZE),%a0 | pt_regs pointer 83 + lea %sp@(-84),%sp | leave a gap 84 + movel %a1,%sp@- 85 + movel %a0,%sp@- 82 86 jbsr do_sigreturn 83 - addql #8,%sp 84 - RESTORE_SWITCH_STACK 85 - rts 87 + jra 1f | shared with rt_sigreturn() 86 88 87 89 ENTRY(sys_rt_sigreturn) 88 90 SAVE_SWITCH_STACK 89 - movel %sp,%sp@- | switch_stack pointer 90 - pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer 91 + movel %sp,%a1 | switch_stack pointer 92 + lea %sp@(SWITCH_STACK_SIZE),%a0 | pt_regs pointer 93 + lea %sp@(-84),%sp | leave a gap 94 + movel %a1,%sp@- 95 + movel %a0,%sp@- 96 + | stack contents: 97 + | [original pt_regs address] [original switch_stack address] 98 + | [gap] [switch_stack] [pt_regs] [exception frame] 91 99 jbsr do_rt_sigreturn 92 - addql #8,%sp 100 + 101 + 1: 102 + | stack contents now: 103 + | [original pt_regs address] [original switch_stack address] 104 + | [unused part of the gap] [moved switch_stack] [moved pt_regs] 105 + | [replacement exception frame] 106 + | return value of do_{rt_,}sigreturn() points to moved switch_stack. 107 + 108 + movel %d0,%sp | discard the leftover junk 93 109 RESTORE_SWITCH_STACK 110 + | stack contents now is just [syscall return address] [pt_regs] [frame] 111 + | return pt_regs.d0 112 + movel %sp@(PT_OFF_D0+4),%d0 94 113 rts 95 114 96 115 ENTRY(buserr) ··· 197 180 jbsr syscall_trace 198 181 RESTORE_SWITCH_STACK 199 182 addql #4,%sp 200 - jra .Lret_from_exception 201 - 202 - ENTRY(ret_from_signal) 203 - movel %curptr@(TASK_STACK),%a1 204 - tstb %a1@(TINFO_FLAGS+2) 205 - jge 1f 206 - jbsr syscall_trace 207 - 1: RESTORE_SWITCH_STACK 208 - addql #4,%sp 209 - /* on 68040 complete pending writebacks if any */ 210 - #ifdef CONFIG_M68040 211 - bfextu %sp@(PT_OFF_FORMATVEC){#0,#4},%d0 212 - subql #7,%d0 | bus error frame ? 213 - jbne 1f 214 - movel %sp,%sp@- 215 - jbsr berr_040cleanup 216 - addql #4,%sp 217 - 1: 218 - #endif 219 183 jra .Lret_from_exception 220 184 221 185 ENTRY(system_call) ··· 336 338 337 339 /* save fs (sfc,%dfc) (may be pointing to kernel memory) */ 338 340 movec %sfc,%d0 339 - movew %d0,%a0@(TASK_THREAD+THREAD_FS) 341 + movew %d0,%a0@(TASK_THREAD+THREAD_FC) 340 342 341 343 /* save usp */ 342 344 /* it is better to use a movel here instead of a movew 8*) */ ··· 422 424 movel %a0,%usp 423 425 424 426 /* restore fs (sfc,%dfc) */ 425 - movew %a1@(TASK_THREAD+THREAD_FS),%a0 427 + movew %a1@(TASK_THREAD+THREAD_FC),%a0 426 428 movec %a0,%sfc 427 429 movec %a0,%dfc 428 430
+2 -2
arch/m68k/kernel/process.c
··· 92 92 93 93 void flush_thread(void) 94 94 { 95 - current->thread.fs = __USER_DS; 95 + current->thread.fc = USER_DATA; 96 96 #ifdef CONFIG_FPU 97 97 if (!FPU_IS_EMU) { 98 98 unsigned long zero = 0; ··· 155 155 * Must save the current SFC/DFC value, NOT the value when 156 156 * the parent was last descheduled - RGH 10-08-96 157 157 */ 158 - p->thread.fs = get_fs().seg; 158 + p->thread.fc = USER_DATA; 159 159 160 160 if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) { 161 161 /* kernel thread */
+82 -115
arch/m68k/kernel/signal.c
··· 447 447 448 448 if (CPU_IS_060 ? sc->sc_fpstate[2] : sc->sc_fpstate[0]) { 449 449 fpu_version = sc->sc_fpstate[0]; 450 - if (CPU_IS_020_OR_030 && 450 + if (CPU_IS_020_OR_030 && !regs->stkadj && 451 451 regs->vector >= (VEC_FPBRUC * 4) && 452 452 regs->vector <= (VEC_FPNAN * 4)) { 453 453 /* Clear pending exception in 68882 idle frame */ ··· 510 510 if (!(CPU_IS_060 || CPU_IS_COLDFIRE)) 511 511 context_size = fpstate[1]; 512 512 fpu_version = fpstate[0]; 513 - if (CPU_IS_020_OR_030 && 513 + if (CPU_IS_020_OR_030 && !regs->stkadj && 514 514 regs->vector >= (VEC_FPBRUC * 4) && 515 515 regs->vector <= (VEC_FPNAN * 4)) { 516 516 /* Clear pending exception in 68882 idle frame */ ··· 641 641 static int mangle_kernel_stack(struct pt_regs *regs, int formatvec, 642 642 void __user *fp) 643 643 { 644 - int fsize = frame_extra_sizes(formatvec >> 12); 645 - if (fsize < 0) { 644 + int extra = frame_extra_sizes(formatvec >> 12); 645 + char buf[sizeof_field(struct frame, un)]; 646 + 647 + if (extra < 0) { 646 648 /* 647 649 * user process trying to return with weird frame format 648 650 */ 649 651 pr_debug("user process returning with weird frame format\n"); 650 - return 1; 652 + return -1; 651 653 } 652 - if (!fsize) { 653 - regs->format = formatvec >> 12; 654 - regs->vector = formatvec & 0xfff; 655 - } else { 656 - struct switch_stack *sw = (struct switch_stack *)regs - 1; 657 - /* yes, twice as much as max(sizeof(frame.un.fmt<x>)) */ 658 - unsigned long buf[sizeof_field(struct frame, un) / 2]; 654 + if (extra && copy_from_user(buf, fp, extra)) 655 + return -1; 656 + regs->format = formatvec >> 12; 657 + regs->vector = formatvec & 0xfff; 658 + if (extra) { 659 + void *p = (struct switch_stack *)regs - 1; 660 + struct frame *new = (void *)regs - extra; 661 + int size = sizeof(struct pt_regs)+sizeof(struct switch_stack); 659 662 660 - /* that'll make sure that expansion won't crap over data */ 661 - if (copy_from_user(buf + fsize / 4, fp, fsize)) 662 - return 1; 663 - 664 - /* point of no return */ 665 - regs->format = formatvec >> 12; 666 - regs->vector = formatvec & 0xfff; 667 - #define frame_offset (sizeof(struct pt_regs)+sizeof(struct switch_stack)) 668 - __asm__ __volatile__ ( 669 - #ifdef CONFIG_COLDFIRE 670 - " movel %0,%/sp\n\t" 671 - " bra ret_from_signal\n" 672 - #else 673 - " movel %0,%/a0\n\t" 674 - " subl %1,%/a0\n\t" /* make room on stack */ 675 - " movel %/a0,%/sp\n\t" /* set stack pointer */ 676 - /* move switch_stack and pt_regs */ 677 - "1: movel %0@+,%/a0@+\n\t" 678 - " dbra %2,1b\n\t" 679 - " lea %/sp@(%c3),%/a0\n\t" /* add offset of fmt */ 680 - " lsrl #2,%1\n\t" 681 - " subql #1,%1\n\t" 682 - /* copy to the gap we'd made */ 683 - "2: movel %4@+,%/a0@+\n\t" 684 - " dbra %1,2b\n\t" 685 - " bral ret_from_signal\n" 663 + memmove(p - extra, p, size); 664 + memcpy(p - extra + size, buf, extra); 665 + current->thread.esp0 = (unsigned long)&new->ptregs; 666 + #ifdef CONFIG_M68040 667 + /* on 68040 complete pending writebacks if any */ 668 + if (new->ptregs.format == 7) // bus error frame 669 + berr_040cleanup(new); 686 670 #endif 687 - : /* no outputs, it doesn't ever return */ 688 - : "a" (sw), "d" (fsize), "d" (frame_offset/4-1), 689 - "n" (frame_offset), "a" (buf + fsize/4) 690 - : "a0"); 691 - #undef frame_offset 692 671 } 693 - return 0; 672 + return extra; 694 673 } 695 674 696 675 static inline int ··· 677 698 { 678 699 int formatvec; 679 700 struct sigcontext context; 680 - int err = 0; 681 701 682 702 siginfo_build_tests(); 683 703 ··· 685 707 686 708 /* get previous context */ 687 709 if (copy_from_user(&context, usc, sizeof(context))) 688 - goto badframe; 710 + return -1; 689 711 690 712 /* restore passed registers */ 691 713 regs->d0 = context.sc_d0; ··· 698 720 wrusp(context.sc_usp); 699 721 formatvec = context.sc_formatvec; 700 722 701 - err = restore_fpu_state(&context); 723 + if (restore_fpu_state(&context)) 724 + return -1; 702 725 703 - if (err || mangle_kernel_stack(regs, formatvec, fp)) 704 - goto badframe; 705 - 706 - return 0; 707 - 708 - badframe: 709 - return 1; 726 + return mangle_kernel_stack(regs, formatvec, fp); 710 727 } 711 728 712 729 static inline int ··· 718 745 719 746 err = __get_user(temp, &uc->uc_mcontext.version); 720 747 if (temp != MCONTEXT_VERSION) 721 - goto badframe; 748 + return -1; 722 749 /* restore passed registers */ 723 750 err |= __get_user(regs->d0, &gregs[0]); 724 751 err |= __get_user(regs->d1, &gregs[1]); ··· 747 774 err |= restore_altstack(&uc->uc_stack); 748 775 749 776 if (err) 750 - goto badframe; 777 + return -1; 751 778 752 - if (mangle_kernel_stack(regs, temp, &uc->uc_extra)) 753 - goto badframe; 754 - 755 - return 0; 756 - 757 - badframe: 758 - return 1; 779 + return mangle_kernel_stack(regs, temp, &uc->uc_extra); 759 780 } 760 781 761 - asmlinkage int do_sigreturn(struct pt_regs *regs, struct switch_stack *sw) 782 + asmlinkage void *do_sigreturn(struct pt_regs *regs, struct switch_stack *sw) 762 783 { 763 784 unsigned long usp = rdusp(); 764 785 struct sigframe __user *frame = (struct sigframe __user *)(usp - 4); 765 786 sigset_t set; 787 + int size; 766 788 767 789 if (!access_ok(frame, sizeof(*frame))) 768 790 goto badframe; ··· 769 801 770 802 set_current_blocked(&set); 771 803 772 - if (restore_sigcontext(regs, &frame->sc, frame + 1)) 804 + size = restore_sigcontext(regs, &frame->sc, frame + 1); 805 + if (size < 0) 773 806 goto badframe; 774 - return regs->d0; 807 + return (void *)sw - size; 775 808 776 809 badframe: 777 810 force_sig(SIGSEGV); 778 - return 0; 811 + return sw; 779 812 } 780 813 781 - asmlinkage int do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw) 814 + asmlinkage void *do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw) 782 815 { 783 816 unsigned long usp = rdusp(); 784 817 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(usp - 4); 785 818 sigset_t set; 819 + int size; 786 820 787 821 if (!access_ok(frame, sizeof(*frame))) 788 822 goto badframe; ··· 793 823 794 824 set_current_blocked(&set); 795 825 796 - if (rt_restore_ucontext(regs, sw, &frame->uc)) 826 + size = rt_restore_ucontext(regs, sw, &frame->uc); 827 + if (size < 0) 797 828 goto badframe; 798 - return regs->d0; 829 + return (void *)sw - size; 799 830 800 831 badframe: 801 832 force_sig(SIGSEGV); 802 - return 0; 833 + return sw; 834 + } 835 + 836 + static inline struct pt_regs *rte_regs(struct pt_regs *regs) 837 + { 838 + return (void *)regs + regs->stkadj; 803 839 } 804 840 805 841 static void setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs, 806 842 unsigned long mask) 807 843 { 844 + struct pt_regs *tregs = rte_regs(regs); 808 845 sc->sc_mask = mask; 809 846 sc->sc_usp = rdusp(); 810 847 sc->sc_d0 = regs->d0; 811 848 sc->sc_d1 = regs->d1; 812 849 sc->sc_a0 = regs->a0; 813 850 sc->sc_a1 = regs->a1; 814 - sc->sc_sr = regs->sr; 815 - sc->sc_pc = regs->pc; 816 - sc->sc_formatvec = regs->format << 12 | regs->vector; 851 + sc->sc_sr = tregs->sr; 852 + sc->sc_pc = tregs->pc; 853 + sc->sc_formatvec = tregs->format << 12 | tregs->vector; 817 854 save_a5_state(sc, regs); 818 855 save_fpu_state(sc, regs); 819 856 } ··· 828 851 static inline int rt_setup_ucontext(struct ucontext __user *uc, struct pt_regs *regs) 829 852 { 830 853 struct switch_stack *sw = (struct switch_stack *)regs - 1; 854 + struct pt_regs *tregs = rte_regs(regs); 831 855 greg_t __user *gregs = uc->uc_mcontext.gregs; 832 856 int err = 0; 833 857 ··· 849 871 err |= __put_user(sw->a5, &gregs[13]); 850 872 err |= __put_user(sw->a6, &gregs[14]); 851 873 err |= __put_user(rdusp(), &gregs[15]); 852 - err |= __put_user(regs->pc, &gregs[16]); 853 - err |= __put_user(regs->sr, &gregs[17]); 854 - err |= __put_user((regs->format << 12) | regs->vector, &uc->uc_formatvec); 874 + err |= __put_user(tregs->pc, &gregs[16]); 875 + err |= __put_user(tregs->sr, &gregs[17]); 876 + err |= __put_user((tregs->format << 12) | tregs->vector, &uc->uc_formatvec); 855 877 err |= rt_save_fpu_state(uc, regs); 856 878 return err; 857 879 } ··· 868 890 struct pt_regs *regs) 869 891 { 870 892 struct sigframe __user *frame; 871 - int fsize = frame_extra_sizes(regs->format); 893 + struct pt_regs *tregs = rte_regs(regs); 894 + int fsize = frame_extra_sizes(tregs->format); 872 895 struct sigcontext context; 873 896 int err = 0, sig = ksig->sig; 874 897 875 898 if (fsize < 0) { 876 899 pr_debug("setup_frame: Unknown frame format %#x\n", 877 - regs->format); 900 + tregs->format); 878 901 return -EFAULT; 879 902 } 880 903 ··· 886 907 887 908 err |= __put_user(sig, &frame->sig); 888 909 889 - err |= __put_user(regs->vector, &frame->code); 910 + err |= __put_user(tregs->vector, &frame->code); 890 911 err |= __put_user(&frame->sc, &frame->psc); 891 912 892 913 if (_NSIG_WORDS > 1) ··· 913 934 push_cache ((unsigned long) &frame->retcode); 914 935 915 936 /* 916 - * Set up registers for signal handler. All the state we are about 917 - * to destroy is successfully copied to sigframe. 918 - */ 919 - wrusp ((unsigned long) frame); 920 - regs->pc = (unsigned long) ksig->ka.sa.sa_handler; 921 - adjustformat(regs); 922 - 923 - /* 924 937 * This is subtle; if we build more than one sigframe, all but the 925 938 * first one will see frame format 0 and have fsize == 0, so we won't 926 939 * screw stkadj. 927 940 */ 928 - if (fsize) 941 + if (fsize) { 929 942 regs->stkadj = fsize; 930 - 931 - /* Prepare to skip over the extra stuff in the exception frame. */ 932 - if (regs->stkadj) { 933 - struct pt_regs *tregs = 934 - (struct pt_regs *)((ulong)regs + regs->stkadj); 943 + tregs = rte_regs(regs); 935 944 pr_debug("Performing stackadjust=%04lx\n", regs->stkadj); 936 - /* This must be copied with decreasing addresses to 937 - handle overlaps. */ 938 945 tregs->vector = 0; 939 946 tregs->format = 0; 940 - tregs->pc = regs->pc; 941 947 tregs->sr = regs->sr; 942 948 } 949 + 950 + /* 951 + * Set up registers for signal handler. All the state we are about 952 + * to destroy is successfully copied to sigframe. 953 + */ 954 + wrusp ((unsigned long) frame); 955 + tregs->pc = (unsigned long) ksig->ka.sa.sa_handler; 956 + adjustformat(regs); 957 + 943 958 return 0; 944 959 } 945 960 ··· 941 968 struct pt_regs *regs) 942 969 { 943 970 struct rt_sigframe __user *frame; 944 - int fsize = frame_extra_sizes(regs->format); 971 + struct pt_regs *tregs = rte_regs(regs); 972 + int fsize = frame_extra_sizes(tregs->format); 945 973 int err = 0, sig = ksig->sig; 946 974 947 975 if (fsize < 0) { ··· 993 1019 push_cache ((unsigned long) &frame->retcode); 994 1020 995 1021 /* 996 - * Set up registers for signal handler. All the state we are about 997 - * to destroy is successfully copied to sigframe. 998 - */ 999 - wrusp ((unsigned long) frame); 1000 - regs->pc = (unsigned long) ksig->ka.sa.sa_handler; 1001 - adjustformat(regs); 1002 - 1003 - /* 1004 1022 * This is subtle; if we build more than one sigframe, all but the 1005 1023 * first one will see frame format 0 and have fsize == 0, so we won't 1006 1024 * screw stkadj. 1007 1025 */ 1008 - if (fsize) 1026 + if (fsize) { 1009 1027 regs->stkadj = fsize; 1010 - 1011 - /* Prepare to skip over the extra stuff in the exception frame. */ 1012 - if (regs->stkadj) { 1013 - struct pt_regs *tregs = 1014 - (struct pt_regs *)((ulong)regs + regs->stkadj); 1028 + tregs = rte_regs(regs); 1015 1029 pr_debug("Performing stackadjust=%04lx\n", regs->stkadj); 1016 - /* This must be copied with decreasing addresses to 1017 - handle overlaps. */ 1018 1030 tregs->vector = 0; 1019 1031 tregs->format = 0; 1020 - tregs->pc = regs->pc; 1021 1032 tregs->sr = regs->sr; 1022 1033 } 1034 + 1035 + /* 1036 + * Set up registers for signal handler. All the state we are about 1037 + * to destroy is successfully copied to sigframe. 1038 + */ 1039 + wrusp ((unsigned long) frame); 1040 + tregs->pc = (unsigned long) ksig->ka.sa.sa_handler; 1041 + adjustformat(regs); 1023 1042 return 0; 1024 1043 } 1025 1044
+4 -9
arch/m68k/kernel/traps.c
··· 181 181 static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs) 182 182 { 183 183 unsigned long mmusr; 184 - mm_segment_t old_fs = get_fs(); 185 184 186 - set_fs(MAKE_MM_SEG(wbs)); 185 + set_fc(wbs); 187 186 188 187 if (iswrite) 189 188 asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr)); ··· 191 192 192 193 asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr)); 193 194 194 - set_fs(old_fs); 195 + set_fc(USER_DATA); 195 196 196 197 return mmusr; 197 198 } ··· 200 201 unsigned long wbd) 201 202 { 202 203 int res = 0; 203 - mm_segment_t old_fs = get_fs(); 204 204 205 - /* set_fs can not be moved, otherwise put_user() may oops */ 206 - set_fs(MAKE_MM_SEG(wbs)); 205 + set_fc(wbs); 207 206 208 207 switch (wbs & WBSIZ_040) { 209 208 case BA_SIZE_BYTE: ··· 215 218 break; 216 219 } 217 220 218 - /* set_fs can not be moved, otherwise put_user() may oops */ 219 - set_fs(old_fs); 220 - 221 + set_fc(USER_DATA); 221 222 222 223 pr_debug("do_040writeback1, res=%d\n", res); 223 224
-1
arch/m68k/mac/misc.c
··· 18 18 19 19 #include <linux/uaccess.h> 20 20 #include <asm/io.h> 21 - #include <asm/segment.h> 22 21 #include <asm/setup.h> 23 22 #include <asm/macintosh.h> 24 23 #include <asm/mac_via.h>
+3 -22
arch/m68k/mm/cache.c
··· 49 49 if (mmusr & MMU_R_040) 50 50 return (mmusr & PAGE_MASK) | (vaddr & ~PAGE_MASK); 51 51 } else { 52 - unsigned short mmusr; 53 - unsigned long *descaddr; 54 - 55 - asm volatile ("ptestr %3,%2@,#7,%0\n\t" 56 - "pmove %%psr,%1" 57 - : "=a&" (descaddr), "=m" (mmusr) 58 - : "a" (vaddr), "d" (get_fs().seg)); 59 - if (mmusr & (MMU_I|MMU_B|MMU_L)) 60 - return 0; 61 - descaddr = phys_to_virt((unsigned long)descaddr); 62 - switch (mmusr & MMU_NUM) { 63 - case 1: 64 - return (*descaddr & 0xfe000000) | (vaddr & 0x01ffffff); 65 - case 2: 66 - return (*descaddr & 0xfffc0000) | (vaddr & 0x0003ffff); 67 - case 3: 68 - return (*descaddr & PAGE_MASK) | (vaddr & ~PAGE_MASK); 69 - } 52 + WARN_ON_ONCE(!CPU_IS_040_OR_060); 70 53 } 71 54 return 0; 72 55 } ··· 90 107 91 108 void flush_icache_range(unsigned long address, unsigned long endaddr) 92 109 { 93 - mm_segment_t old_fs = get_fs(); 94 - 95 - set_fs(KERNEL_DS); 110 + set_fc(SUPER_DATA); 96 111 flush_icache_user_range(address, endaddr); 97 - set_fs(old_fs); 112 + set_fc(USER_DATA); 98 113 } 99 114 EXPORT_SYMBOL(flush_icache_range); 100 115
-6
arch/m68k/mm/init.c
··· 72 72 if (!empty_zero_page) 73 73 panic("%s: Failed to allocate %lu bytes align=0x%lx\n", 74 74 __func__, PAGE_SIZE, PAGE_SIZE); 75 - 76 - /* 77 - * Set up SFC/DFC registers (user data space). 78 - */ 79 - set_fs (USER_DS); 80 - 81 75 max_zone_pfn[ZONE_DMA] = end_mem >> PAGE_SHIFT; 82 76 free_area_init(max_zone_pfn); 83 77 }
-1
arch/m68k/mm/kmap.c
··· 17 17 #include <linux/vmalloc.h> 18 18 19 19 #include <asm/setup.h> 20 - #include <asm/segment.h> 21 20 #include <asm/page.h> 22 21 #include <asm/io.h> 23 22 #include <asm/tlbflush.h>
-1
arch/m68k/mm/memory.c
··· 15 15 #include <linux/gfp.h> 16 16 17 17 #include <asm/setup.h> 18 - #include <asm/segment.h> 19 18 #include <asm/page.h> 20 19 #include <asm/traps.h> 21 20 #include <asm/machdep.h>
+1 -1
arch/m68k/mm/motorola.c
··· 467 467 /* 468 468 * Set up SFC/DFC registers 469 469 */ 470 - set_fs(KERNEL_DS); 470 + set_fc(USER_DATA); 471 471 472 472 #ifdef DEBUG 473 473 printk ("before free_area_init\n");
+1 -2
arch/m68k/sun3/config.c
··· 31 31 #include <asm/intersil.h> 32 32 #include <asm/irq.h> 33 33 #include <asm/sections.h> 34 - #include <asm/segment.h> 35 34 #include <asm/sun3ints.h> 36 35 37 36 char sun3_reserved_pmeg[SUN3_PMEGS_NUM]; ··· 88 89 sun3_reserved_pmeg[249] = 1; 89 90 sun3_reserved_pmeg[252] = 1; 90 91 sun3_reserved_pmeg[253] = 1; 91 - set_fs(KERNEL_DS); 92 + set_fc(USER_DATA); 92 93 } 93 94 94 95 /* Without this, Bad Things happen when something calls arch_reset. */
+2 -4
arch/m68k/sun3/mmu_emu.c
··· 23 23 #include <linux/uaccess.h> 24 24 #include <asm/page.h> 25 25 #include <asm/sun3mmu.h> 26 - #include <asm/segment.h> 27 26 #include <asm/oplib.h> 28 27 #include <asm/mmu_context.h> 29 28 #include <asm/dvma.h> ··· 190 191 for(seg = 0; seg < PAGE_OFFSET; seg += SUN3_PMEG_SIZE) 191 192 sun3_put_segmap(seg, SUN3_INVALID_PMEG); 192 193 193 - set_fs(MAKE_MM_SEG(3)); 194 + set_fc(3); 194 195 for(seg = 0; seg < 0x10000000; seg += SUN3_PMEG_SIZE) { 195 196 i = sun3_get_segmap(seg); 196 197 for(j = 1; j < CONTEXTS_NUM; j++) 197 198 (*(romvec->pv_setctxt))(j, (void *)seg, i); 198 199 } 199 - set_fs(KERNEL_DS); 200 - 200 + set_fc(USER_DATA); 201 201 } 202 202 203 203 /* erase the mappings for a dead context. Uses the pg_dir for hints
-1
arch/m68k/sun3/sun3ints.c
··· 11 11 #include <linux/sched.h> 12 12 #include <linux/kernel_stat.h> 13 13 #include <linux/interrupt.h> 14 - #include <asm/segment.h> 15 14 #include <asm/intersil.h> 16 15 #include <asm/oplib.h> 17 16 #include <asm/sun3ints.h>
-1
arch/m68k/sun3x/prom.c
··· 14 14 #include <asm/traps.h> 15 15 #include <asm/sun3xprom.h> 16 16 #include <asm/idprom.h> 17 - #include <asm/segment.h> 18 17 #include <asm/sun3ints.h> 19 18 #include <asm/openprom.h> 20 19 #include <asm/machines.h>
+43 -14
arch/mips/net/bpf_jit.c
··· 662 662 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative : func) : \ 663 663 func##_positive) 664 664 665 + static bool is_bad_offset(int b_off) 666 + { 667 + return b_off > 0x1ffff || b_off < -0x20000; 668 + } 669 + 665 670 static int build_body(struct jit_ctx *ctx) 666 671 { 667 672 const struct bpf_prog *prog = ctx->skf; ··· 733 728 /* Load return register on DS for failures */ 734 729 emit_reg_move(r_ret, r_zero, ctx); 735 730 /* Return with error */ 736 - emit_b(b_imm(prog->len, ctx), ctx); 731 + b_off = b_imm(prog->len, ctx); 732 + if (is_bad_offset(b_off)) 733 + return -E2BIG; 734 + emit_b(b_off, ctx); 737 735 emit_nop(ctx); 738 736 break; 739 737 case BPF_LD | BPF_W | BPF_IND: ··· 783 775 emit_jalr(MIPS_R_RA, r_s0, ctx); 784 776 emit_reg_move(MIPS_R_A0, r_skb, ctx); /* delay slot */ 785 777 /* Check the error value */ 786 - emit_bcond(MIPS_COND_NE, r_ret, 0, 787 - b_imm(prog->len, ctx), ctx); 778 + b_off = b_imm(prog->len, ctx); 779 + if (is_bad_offset(b_off)) 780 + return -E2BIG; 781 + emit_bcond(MIPS_COND_NE, r_ret, 0, b_off, ctx); 788 782 emit_reg_move(r_ret, r_zero, ctx); 789 783 /* We are good */ 790 784 /* X <- P[1:K] & 0xf */ ··· 865 855 /* A /= X */ 866 856 ctx->flags |= SEEN_X | SEEN_A; 867 857 /* Check if r_X is zero */ 868 - emit_bcond(MIPS_COND_EQ, r_X, r_zero, 869 - b_imm(prog->len, ctx), ctx); 858 + b_off = b_imm(prog->len, ctx); 859 + if (is_bad_offset(b_off)) 860 + return -E2BIG; 861 + emit_bcond(MIPS_COND_EQ, r_X, r_zero, b_off, ctx); 870 862 emit_load_imm(r_ret, 0, ctx); /* delay slot */ 871 863 emit_div(r_A, r_X, ctx); 872 864 break; ··· 876 864 /* A %= X */ 877 865 ctx->flags |= SEEN_X | SEEN_A; 878 866 /* Check if r_X is zero */ 879 - emit_bcond(MIPS_COND_EQ, r_X, r_zero, 880 - b_imm(prog->len, ctx), ctx); 867 + b_off = b_imm(prog->len, ctx); 868 + if (is_bad_offset(b_off)) 869 + return -E2BIG; 870 + emit_bcond(MIPS_COND_EQ, r_X, r_zero, b_off, ctx); 881 871 emit_load_imm(r_ret, 0, ctx); /* delay slot */ 882 872 emit_mod(r_A, r_X, ctx); 883 873 break; ··· 940 926 break; 941 927 case BPF_JMP | BPF_JA: 942 928 /* pc += K */ 943 - emit_b(b_imm(i + k + 1, ctx), ctx); 929 + b_off = b_imm(i + k + 1, ctx); 930 + if (is_bad_offset(b_off)) 931 + return -E2BIG; 932 + emit_b(b_off, ctx); 944 933 emit_nop(ctx); 945 934 break; 946 935 case BPF_JMP | BPF_JEQ | BPF_K: ··· 1073 1056 break; 1074 1057 case BPF_RET | BPF_A: 1075 1058 ctx->flags |= SEEN_A; 1076 - if (i != prog->len - 1) 1059 + if (i != prog->len - 1) { 1077 1060 /* 1078 1061 * If this is not the last instruction 1079 1062 * then jump to the epilogue 1080 1063 */ 1081 - emit_b(b_imm(prog->len, ctx), ctx); 1064 + b_off = b_imm(prog->len, ctx); 1065 + if (is_bad_offset(b_off)) 1066 + return -E2BIG; 1067 + emit_b(b_off, ctx); 1068 + } 1082 1069 emit_reg_move(r_ret, r_A, ctx); /* delay slot */ 1083 1070 break; 1084 1071 case BPF_RET | BPF_K: ··· 1096 1075 * If this is not the last instruction 1097 1076 * then jump to the epilogue 1098 1077 */ 1099 - emit_b(b_imm(prog->len, ctx), ctx); 1078 + b_off = b_imm(prog->len, ctx); 1079 + if (is_bad_offset(b_off)) 1080 + return -E2BIG; 1081 + emit_b(b_off, ctx); 1100 1082 emit_nop(ctx); 1101 1083 } 1102 1084 break; ··· 1157 1133 /* Load *dev pointer */ 1158 1134 emit_load_ptr(r_s0, r_skb, off, ctx); 1159 1135 /* error (0) in the delay slot */ 1160 - emit_bcond(MIPS_COND_EQ, r_s0, r_zero, 1161 - b_imm(prog->len, ctx), ctx); 1136 + b_off = b_imm(prog->len, ctx); 1137 + if (is_bad_offset(b_off)) 1138 + return -E2BIG; 1139 + emit_bcond(MIPS_COND_EQ, r_s0, r_zero, b_off, ctx); 1162 1140 emit_reg_move(r_ret, r_zero, ctx); 1163 1141 if (code == (BPF_ANC | SKF_AD_IFINDEX)) { 1164 1142 BUILD_BUG_ON(sizeof_field(struct net_device, ifindex) != 4); ··· 1270 1244 1271 1245 /* Generate the actual JIT code */ 1272 1246 build_prologue(&ctx); 1273 - build_body(&ctx); 1247 + if (build_body(&ctx)) { 1248 + module_memfree(ctx.target); 1249 + goto out; 1250 + } 1274 1251 build_epilogue(&ctx); 1275 1252 1276 1253 /* Update the icache */
+2 -1
arch/nios2/Kconfig.debug
··· 3 3 config EARLY_PRINTK 4 4 bool "Activate early kernel debugging" 5 5 default y 6 + depends on TTY 6 7 select SERIAL_CORE_CONSOLE 7 8 help 8 - Enable early printk on console 9 + Enable early printk on console. 9 10 This is useful for kernel debugging when your machine crashes very 10 11 early before the console code is initialized. 11 12 You should normally say N here, unless you want to debug such a crash.
-2
arch/nios2/kernel/setup.c
··· 149 149 150 150 void __init setup_arch(char **cmdline_p) 151 151 { 152 - int dram_start; 153 - 154 152 console_verbose(); 155 153 156 154 memory_start = memblock_start_of_DRAM();
+2 -2
arch/s390/kvm/interrupt.c
··· 419 419 static void __set_cpu_idle(struct kvm_vcpu *vcpu) 420 420 { 421 421 kvm_s390_set_cpuflags(vcpu, CPUSTAT_WAIT); 422 - set_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask); 422 + set_bit(vcpu->vcpu_idx, vcpu->kvm->arch.idle_mask); 423 423 } 424 424 425 425 static void __unset_cpu_idle(struct kvm_vcpu *vcpu) 426 426 { 427 427 kvm_s390_clear_cpuflags(vcpu, CPUSTAT_WAIT); 428 - clear_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask); 428 + clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.idle_mask); 429 429 } 430 430 431 431 static void __reset_intercept_indicators(struct kvm_vcpu *vcpu)
+1 -1
arch/s390/kvm/kvm-s390.c
··· 4066 4066 kvm_s390_patch_guest_per_regs(vcpu); 4067 4067 } 4068 4068 4069 - clear_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.gisa_int.kicked_mask); 4069 + clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.gisa_int.kicked_mask); 4070 4070 4071 4071 vcpu->arch.sie_block->icptcode = 0; 4072 4072 cpuflags = atomic_read(&vcpu->arch.sie_block->cpuflags);
+1 -1
arch/s390/kvm/kvm-s390.h
··· 79 79 80 80 static inline int is_vcpu_idle(struct kvm_vcpu *vcpu) 81 81 { 82 - return test_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask); 82 + return test_bit(vcpu->vcpu_idx, vcpu->kvm->arch.idle_mask); 83 83 } 84 84 85 85 static inline int kvm_is_ucontrol(struct kvm *kvm)
+3 -2
arch/x86/crypto/sm4-aesni-avx-asm_64.S
··· 367 367 * %rdx: src (1..8 blocks) 368 368 * %rcx: num blocks (1..8) 369 369 */ 370 - FRAME_BEGIN 371 - 372 370 cmpq $5, %rcx; 373 371 jb sm4_aesni_avx_crypt4; 372 + 373 + FRAME_BEGIN 374 + 374 375 vmovdqu (0 * 16)(%rdx), RA0; 375 376 vmovdqu (1 * 16)(%rdx), RA1; 376 377 vmovdqu (2 * 16)(%rdx), RA2;
+1
arch/x86/events/core.c
··· 2465 2465 if (err) { 2466 2466 if (event->destroy) 2467 2467 event->destroy(event); 2468 + event->destroy = NULL; 2468 2469 } 2469 2470 2470 2471 if (READ_ONCE(x86_pmu.attr_rdpmc) &&
+1
arch/x86/events/intel/core.c
··· 263 263 INTEL_EVENT_CONSTRAINT_RANGE(0xa8, 0xb0, 0xf), 264 264 INTEL_EVENT_CONSTRAINT_RANGE(0xb7, 0xbd, 0xf), 265 265 INTEL_EVENT_CONSTRAINT_RANGE(0xd0, 0xe6, 0xf), 266 + INTEL_EVENT_CONSTRAINT(0xef, 0xf), 266 267 INTEL_EVENT_CONSTRAINT_RANGE(0xf0, 0xf4, 0xf), 267 268 EVENT_CONSTRAINT_END 268 269 };
+1 -1
arch/x86/include/asm/kvm_page_track.h
··· 46 46 struct kvm_page_track_notifier_node *node); 47 47 }; 48 48 49 - void kvm_page_track_init(struct kvm *kvm); 49 + int kvm_page_track_init(struct kvm *kvm); 50 50 void kvm_page_track_cleanup(struct kvm *kvm); 51 51 52 52 void kvm_page_track_free_memslot(struct kvm_memory_slot *slot);
+14
arch/x86/include/asm/kvmclock.h
··· 2 2 #ifndef _ASM_X86_KVM_CLOCK_H 3 3 #define _ASM_X86_KVM_CLOCK_H 4 4 5 + #include <linux/percpu.h> 6 + 5 7 extern struct clocksource kvm_clock; 8 + 9 + DECLARE_PER_CPU(struct pvclock_vsyscall_time_info *, hv_clock_per_cpu); 10 + 11 + static inline struct pvclock_vcpu_time_info *this_cpu_pvti(void) 12 + { 13 + return &this_cpu_read(hv_clock_per_cpu)->pvti; 14 + } 15 + 16 + static inline struct pvclock_vsyscall_time_info *this_cpu_hvclock(void) 17 + { 18 + return this_cpu_read(hv_clock_per_cpu); 19 + } 6 20 7 21 #endif /* _ASM_X86_KVM_CLOCK_H */
+2 -11
arch/x86/kernel/kvmclock.c
··· 49 49 static struct pvclock_vsyscall_time_info 50 50 hv_clock_boot[HVC_BOOT_ARRAY_SIZE] __bss_decrypted __aligned(PAGE_SIZE); 51 51 static struct pvclock_wall_clock wall_clock __bss_decrypted; 52 - static DEFINE_PER_CPU(struct pvclock_vsyscall_time_info *, hv_clock_per_cpu); 53 52 static struct pvclock_vsyscall_time_info *hvclock_mem; 54 - 55 - static inline struct pvclock_vcpu_time_info *this_cpu_pvti(void) 56 - { 57 - return &this_cpu_read(hv_clock_per_cpu)->pvti; 58 - } 59 - 60 - static inline struct pvclock_vsyscall_time_info *this_cpu_hvclock(void) 61 - { 62 - return this_cpu_read(hv_clock_per_cpu); 63 - } 53 + DEFINE_PER_CPU(struct pvclock_vsyscall_time_info *, hv_clock_per_cpu); 54 + EXPORT_PER_CPU_SYMBOL_GPL(hv_clock_per_cpu); 64 55 65 56 /* 66 57 * The wallclock is the time of day when we booted. Since then, some time may
+2 -2
arch/x86/kvm/cpuid.c
··· 65 65 for (i = 0; i < nent; i++) { 66 66 e = &entries[i]; 67 67 68 - if (e->function == function && (e->index == index || 69 - !(e->flags & KVM_CPUID_FLAG_SIGNIFCANT_INDEX))) 68 + if (e->function == function && 69 + (!(e->flags & KVM_CPUID_FLAG_SIGNIFCANT_INDEX) || e->index == index)) 70 70 return e; 71 71 } 72 72
+1 -2
arch/x86/kvm/emulate.c
··· 435 435 __FOP_RET(#op) 436 436 437 437 asm(".pushsection .fixup, \"ax\"\n" 438 - ".global kvm_fastop_exception \n" 439 438 "kvm_fastop_exception: xor %esi, %esi; ret\n" 440 439 ".popsection"); 441 440 ··· 4205 4206 u64 cr4 = ctxt->ops->get_cr(ctxt, 4); 4206 4207 4207 4208 if (cr4 & X86_CR4_TSD && ctxt->ops->cpl(ctxt)) 4208 - return emulate_ud(ctxt); 4209 + return emulate_gp(ctxt, 0); 4209 4210 4210 4211 return X86EMUL_CONTINUE; 4211 4212 }
+3 -4
arch/x86/kvm/hyperv.c
··· 939 939 for (i = 0; i < ARRAY_SIZE(hv_vcpu->stimer); i++) 940 940 stimer_init(&hv_vcpu->stimer[i], i); 941 941 942 - hv_vcpu->vp_index = kvm_vcpu_get_idx(vcpu); 942 + hv_vcpu->vp_index = vcpu->vcpu_idx; 943 943 944 944 return 0; 945 945 } ··· 1444 1444 switch (msr) { 1445 1445 case HV_X64_MSR_VP_INDEX: { 1446 1446 struct kvm_hv *hv = to_kvm_hv(vcpu->kvm); 1447 - int vcpu_idx = kvm_vcpu_get_idx(vcpu); 1448 1447 u32 new_vp_index = (u32)data; 1449 1448 1450 1449 if (!host || new_vp_index >= KVM_MAX_VCPUS) ··· 1458 1459 * VP index is changing, adjust num_mismatched_vp_indexes if 1459 1460 * it now matches or no longer matches vcpu_idx. 1460 1461 */ 1461 - if (hv_vcpu->vp_index == vcpu_idx) 1462 + if (hv_vcpu->vp_index == vcpu->vcpu_idx) 1462 1463 atomic_inc(&hv->num_mismatched_vp_indexes); 1463 - else if (new_vp_index == vcpu_idx) 1464 + else if (new_vp_index == vcpu->vcpu_idx) 1464 1465 atomic_dec(&hv->num_mismatched_vp_indexes); 1465 1466 1466 1467 hv_vcpu->vp_index = new_vp_index;
+1 -1
arch/x86/kvm/hyperv.h
··· 83 83 { 84 84 struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); 85 85 86 - return hv_vcpu ? hv_vcpu->vp_index : kvm_vcpu_get_idx(vcpu); 86 + return hv_vcpu ? hv_vcpu->vp_index : vcpu->vcpu_idx; 87 87 } 88 88 89 89 int kvm_hv_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data, bool host);
+5 -5
arch/x86/kvm/ioapic.c
··· 319 319 unsigned index; 320 320 bool mask_before, mask_after; 321 321 union kvm_ioapic_redirect_entry *e; 322 - unsigned long vcpu_bitmap; 323 322 int old_remote_irr, old_delivery_status, old_dest_id, old_dest_mode; 323 + DECLARE_BITMAP(vcpu_bitmap, KVM_MAX_VCPUS); 324 324 325 325 switch (ioapic->ioregsel) { 326 326 case IOAPIC_REG_VERSION: ··· 384 384 irq.shorthand = APIC_DEST_NOSHORT; 385 385 irq.dest_id = e->fields.dest_id; 386 386 irq.msi_redir_hint = false; 387 - bitmap_zero(&vcpu_bitmap, 16); 387 + bitmap_zero(vcpu_bitmap, KVM_MAX_VCPUS); 388 388 kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq, 389 - &vcpu_bitmap); 389 + vcpu_bitmap); 390 390 if (old_dest_mode != e->fields.dest_mode || 391 391 old_dest_id != e->fields.dest_id) { 392 392 /* ··· 399 399 kvm_lapic_irq_dest_mode( 400 400 !!e->fields.dest_mode); 401 401 kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq, 402 - &vcpu_bitmap); 402 + vcpu_bitmap); 403 403 } 404 404 kvm_make_scan_ioapic_request_mask(ioapic->kvm, 405 - &vcpu_bitmap); 405 + vcpu_bitmap); 406 406 } else { 407 407 kvm_make_scan_ioapic_request(ioapic->kvm); 408 408 }
+10 -7
arch/x86/kvm/mmu/mmu.c
··· 2027 2027 } while (!sp->unsync_children); 2028 2028 } 2029 2029 2030 - static void mmu_sync_children(struct kvm_vcpu *vcpu, 2031 - struct kvm_mmu_page *parent) 2030 + static int mmu_sync_children(struct kvm_vcpu *vcpu, 2031 + struct kvm_mmu_page *parent, bool can_yield) 2032 2032 { 2033 2033 int i; 2034 2034 struct kvm_mmu_page *sp; ··· 2055 2055 } 2056 2056 if (need_resched() || rwlock_needbreak(&vcpu->kvm->mmu_lock)) { 2057 2057 kvm_mmu_flush_or_zap(vcpu, &invalid_list, false, flush); 2058 + if (!can_yield) { 2059 + kvm_make_request(KVM_REQ_MMU_SYNC, vcpu); 2060 + return -EINTR; 2061 + } 2062 + 2058 2063 cond_resched_rwlock_write(&vcpu->kvm->mmu_lock); 2059 2064 flush = false; 2060 2065 } 2061 2066 } 2062 2067 2063 2068 kvm_mmu_flush_or_zap(vcpu, &invalid_list, false, flush); 2069 + return 0; 2064 2070 } 2065 2071 2066 2072 static void __clear_sp_write_flooding_count(struct kvm_mmu_page *sp) ··· 2151 2145 WARN_ON(!list_empty(&invalid_list)); 2152 2146 kvm_make_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu); 2153 2147 } 2154 - 2155 - if (sp->unsync_children) 2156 - kvm_make_request(KVM_REQ_MMU_SYNC, vcpu); 2157 2148 2158 2149 __clear_sp_write_flooding_count(sp); 2159 2150 ··· 3687 3684 write_lock(&vcpu->kvm->mmu_lock); 3688 3685 kvm_mmu_audit(vcpu, AUDIT_PRE_SYNC); 3689 3686 3690 - mmu_sync_children(vcpu, sp); 3687 + mmu_sync_children(vcpu, sp, true); 3691 3688 3692 3689 kvm_mmu_audit(vcpu, AUDIT_POST_SYNC); 3693 3690 write_unlock(&vcpu->kvm->mmu_lock); ··· 3703 3700 if (IS_VALID_PAE_ROOT(root)) { 3704 3701 root &= PT64_BASE_ADDR_MASK; 3705 3702 sp = to_shadow_page(root); 3706 - mmu_sync_children(vcpu, sp); 3703 + mmu_sync_children(vcpu, sp, true); 3707 3704 } 3708 3705 } 3709 3706
+2 -2
arch/x86/kvm/mmu/page_track.c
··· 164 164 cleanup_srcu_struct(&head->track_srcu); 165 165 } 166 166 167 - void kvm_page_track_init(struct kvm *kvm) 167 + int kvm_page_track_init(struct kvm *kvm) 168 168 { 169 169 struct kvm_page_track_notifier_head *head; 170 170 171 171 head = &kvm->arch.track_notifier_head; 172 - init_srcu_struct(&head->track_srcu); 173 172 INIT_HLIST_HEAD(&head->track_notifier_list); 173 + return init_srcu_struct(&head->track_srcu); 174 174 } 175 175 176 176 /*
+23 -23
arch/x86/kvm/mmu/paging_tmpl.h
··· 707 707 if (!is_shadow_present_pte(*it.sptep)) { 708 708 table_gfn = gw->table_gfn[it.level - 2]; 709 709 access = gw->pt_access[it.level - 2]; 710 - sp = kvm_mmu_get_page(vcpu, table_gfn, addr, it.level-1, 711 - false, access); 710 + sp = kvm_mmu_get_page(vcpu, table_gfn, addr, 711 + it.level-1, false, access); 712 + /* 713 + * We must synchronize the pagetable before linking it 714 + * because the guest doesn't need to flush tlb when 715 + * the gpte is changed from non-present to present. 716 + * Otherwise, the guest may use the wrong mapping. 717 + * 718 + * For PG_LEVEL_4K, kvm_mmu_get_page() has already 719 + * synchronized it transiently via kvm_sync_page(). 720 + * 721 + * For higher level pagetable, we synchronize it via 722 + * the slower mmu_sync_children(). If it needs to 723 + * break, some progress has been made; return 724 + * RET_PF_RETRY and retry on the next #PF. 725 + * KVM_REQ_MMU_SYNC is not necessary but it 726 + * expedites the process. 727 + */ 728 + if (sp->unsync_children && 729 + mmu_sync_children(vcpu, sp, false)) 730 + return RET_PF_RETRY; 712 731 } 713 732 714 733 /* ··· 1066 1047 * Using the cached information from sp->gfns is safe because: 1067 1048 * - The spte has a reference to the struct page, so the pfn for a given gfn 1068 1049 * can't change unless all sptes pointing to it are nuked first. 1069 - * 1070 - * Note: 1071 - * We should flush all tlbs if spte is dropped even though guest is 1072 - * responsible for it. Since if we don't, kvm_mmu_notifier_invalidate_page 1073 - * and kvm_mmu_notifier_invalidate_range_start detect the mapping page isn't 1074 - * used by guest then tlbs are not flushed, so guest is allowed to access the 1075 - * freed pages. 1076 - * And we increase kvm->tlbs_dirty to delay tlbs flush in this case. 1077 1050 */ 1078 1051 static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) 1079 1052 { ··· 1118 1107 return 0; 1119 1108 1120 1109 if (FNAME(prefetch_invalid_gpte)(vcpu, sp, &sp->spt[i], gpte)) { 1121 - /* 1122 - * Update spte before increasing tlbs_dirty to make 1123 - * sure no tlb flush is lost after spte is zapped; see 1124 - * the comments in kvm_flush_remote_tlbs(). 1125 - */ 1126 - smp_wmb(); 1127 - vcpu->kvm->tlbs_dirty++; 1110 + set_spte_ret |= SET_SPTE_NEED_REMOTE_TLB_FLUSH; 1128 1111 continue; 1129 1112 } 1130 1113 ··· 1133 1128 1134 1129 if (gfn != sp->gfns[i]) { 1135 1130 drop_spte(vcpu->kvm, &sp->spt[i]); 1136 - /* 1137 - * The same as above where we are doing 1138 - * prefetch_invalid_gpte(). 1139 - */ 1140 - smp_wmb(); 1141 - vcpu->kvm->tlbs_dirty++; 1131 + set_spte_ret |= SET_SPTE_NEED_REMOTE_TLB_FLUSH; 1142 1132 continue; 1143 1133 } 1144 1134
+6 -4
arch/x86/kvm/svm/nested.c
··· 545 545 (svm->nested.ctl.int_ctl & int_ctl_vmcb12_bits) | 546 546 (svm->vmcb01.ptr->control.int_ctl & int_ctl_vmcb01_bits); 547 547 548 - svm->vmcb->control.virt_ext = svm->nested.ctl.virt_ext; 549 548 svm->vmcb->control.int_vector = svm->nested.ctl.int_vector; 550 549 svm->vmcb->control.int_state = svm->nested.ctl.int_state; 551 550 svm->vmcb->control.event_inj = svm->nested.ctl.event_inj; ··· 578 579 } 579 580 580 581 int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa, 581 - struct vmcb *vmcb12) 582 + struct vmcb *vmcb12, bool from_vmrun) 582 583 { 583 584 struct vcpu_svm *svm = to_svm(vcpu); 584 585 int ret; ··· 608 609 nested_vmcb02_prepare_save(svm, vmcb12); 609 610 610 611 ret = nested_svm_load_cr3(&svm->vcpu, vmcb12->save.cr3, 611 - nested_npt_enabled(svm), true); 612 + nested_npt_enabled(svm), from_vmrun); 612 613 if (ret) 613 614 return ret; 614 615 615 616 if (!npt_enabled) 616 617 vcpu->arch.mmu->inject_page_fault = svm_inject_page_fault_nested; 618 + 619 + if (!from_vmrun) 620 + kvm_make_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu); 617 621 618 622 svm_set_gif(svm, true); 619 623 ··· 683 681 684 682 svm->nested.nested_run_pending = 1; 685 683 686 - if (enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12)) 684 + if (enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, true)) 687 685 goto out_exit_err; 688 686 689 687 if (nested_svm_vmrun_msrpm(svm))
+62 -30
arch/x86/kvm/svm/sev.c
··· 595 595 return 0; 596 596 } 597 597 598 + static int __sev_launch_update_vmsa(struct kvm *kvm, struct kvm_vcpu *vcpu, 599 + int *error) 600 + { 601 + struct sev_data_launch_update_vmsa vmsa; 602 + struct vcpu_svm *svm = to_svm(vcpu); 603 + int ret; 604 + 605 + /* Perform some pre-encryption checks against the VMSA */ 606 + ret = sev_es_sync_vmsa(svm); 607 + if (ret) 608 + return ret; 609 + 610 + /* 611 + * The LAUNCH_UPDATE_VMSA command will perform in-place encryption of 612 + * the VMSA memory content (i.e it will write the same memory region 613 + * with the guest's key), so invalidate it first. 614 + */ 615 + clflush_cache_range(svm->vmsa, PAGE_SIZE); 616 + 617 + vmsa.reserved = 0; 618 + vmsa.handle = to_kvm_svm(kvm)->sev_info.handle; 619 + vmsa.address = __sme_pa(svm->vmsa); 620 + vmsa.len = PAGE_SIZE; 621 + return sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_VMSA, &vmsa, error); 622 + } 623 + 598 624 static int sev_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp) 599 625 { 600 - struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; 601 - struct sev_data_launch_update_vmsa vmsa; 602 626 struct kvm_vcpu *vcpu; 603 627 int i, ret; 604 628 605 629 if (!sev_es_guest(kvm)) 606 630 return -ENOTTY; 607 631 608 - vmsa.reserved = 0; 609 - 610 632 kvm_for_each_vcpu(i, vcpu, kvm) { 611 - struct vcpu_svm *svm = to_svm(vcpu); 612 - 613 - /* Perform some pre-encryption checks against the VMSA */ 614 - ret = sev_es_sync_vmsa(svm); 633 + ret = mutex_lock_killable(&vcpu->mutex); 615 634 if (ret) 616 635 return ret; 617 636 618 - /* 619 - * The LAUNCH_UPDATE_VMSA command will perform in-place 620 - * encryption of the VMSA memory content (i.e it will write 621 - * the same memory region with the guest's key), so invalidate 622 - * it first. 623 - */ 624 - clflush_cache_range(svm->vmsa, PAGE_SIZE); 637 + ret = __sev_launch_update_vmsa(kvm, vcpu, &argp->error); 625 638 626 - vmsa.handle = sev->handle; 627 - vmsa.address = __sme_pa(svm->vmsa); 628 - vmsa.len = PAGE_SIZE; 629 - ret = sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_VMSA, &vmsa, 630 - &argp->error); 639 + mutex_unlock(&vcpu->mutex); 631 640 if (ret) 632 641 return ret; 633 - 634 - svm->vcpu.arch.guest_state_protected = true; 635 642 } 636 643 637 644 return 0; ··· 1404 1397 1405 1398 /* Bind ASID to this guest */ 1406 1399 ret = sev_bind_asid(kvm, start.handle, error); 1407 - if (ret) 1400 + if (ret) { 1401 + sev_decommission(start.handle); 1408 1402 goto e_free_session; 1403 + } 1409 1404 1410 1405 params.handle = start.handle; 1411 1406 if (copy_to_user((void __user *)(uintptr_t)argp->data, ··· 1473 1464 1474 1465 /* Pin guest memory */ 1475 1466 guest_page = sev_pin_memory(kvm, params.guest_uaddr & PAGE_MASK, 1476 - PAGE_SIZE, &n, 0); 1467 + PAGE_SIZE, &n, 1); 1477 1468 if (IS_ERR(guest_page)) { 1478 1469 ret = PTR_ERR(guest_page); 1479 1470 goto e_free_trans; ··· 1510 1501 return sev_issue_cmd(kvm, SEV_CMD_RECEIVE_FINISH, &data, &argp->error); 1511 1502 } 1512 1503 1504 + static bool cmd_allowed_from_miror(u32 cmd_id) 1505 + { 1506 + /* 1507 + * Allow mirrors VM to call KVM_SEV_LAUNCH_UPDATE_VMSA to enable SEV-ES 1508 + * active mirror VMs. Also allow the debugging and status commands. 1509 + */ 1510 + if (cmd_id == KVM_SEV_LAUNCH_UPDATE_VMSA || 1511 + cmd_id == KVM_SEV_GUEST_STATUS || cmd_id == KVM_SEV_DBG_DECRYPT || 1512 + cmd_id == KVM_SEV_DBG_ENCRYPT) 1513 + return true; 1514 + 1515 + return false; 1516 + } 1517 + 1513 1518 int svm_mem_enc_op(struct kvm *kvm, void __user *argp) 1514 1519 { 1515 1520 struct kvm_sev_cmd sev_cmd; ··· 1540 1517 1541 1518 mutex_lock(&kvm->lock); 1542 1519 1543 - /* enc_context_owner handles all memory enc operations */ 1544 - if (is_mirroring_enc_context(kvm)) { 1520 + /* Only the enc_context_owner handles some memory enc operations. */ 1521 + if (is_mirroring_enc_context(kvm) && 1522 + !cmd_allowed_from_miror(sev_cmd.id)) { 1545 1523 r = -EINVAL; 1546 1524 goto out; 1547 1525 } ··· 1739 1715 { 1740 1716 struct file *source_kvm_file; 1741 1717 struct kvm *source_kvm; 1742 - struct kvm_sev_info *mirror_sev; 1743 - unsigned int asid; 1718 + struct kvm_sev_info source_sev, *mirror_sev; 1744 1719 int ret; 1745 1720 1746 1721 source_kvm_file = fget(source_fd); ··· 1762 1739 goto e_source_unlock; 1763 1740 } 1764 1741 1765 - asid = to_kvm_svm(source_kvm)->sev_info.asid; 1742 + memcpy(&source_sev, &to_kvm_svm(source_kvm)->sev_info, 1743 + sizeof(source_sev)); 1766 1744 1767 1745 /* 1768 1746 * The mirror kvm holds an enc_context_owner ref so its asid can't ··· 1783 1759 /* Set enc_context_owner and copy its encryption context over */ 1784 1760 mirror_sev = &to_kvm_svm(kvm)->sev_info; 1785 1761 mirror_sev->enc_context_owner = source_kvm; 1786 - mirror_sev->asid = asid; 1787 1762 mirror_sev->active = true; 1763 + mirror_sev->asid = source_sev.asid; 1764 + mirror_sev->fd = source_sev.fd; 1765 + mirror_sev->es_active = source_sev.es_active; 1766 + mirror_sev->handle = source_sev.handle; 1767 + /* 1768 + * Do not copy ap_jump_table. Since the mirror does not share the same 1769 + * KVM contexts as the original, and they may have different 1770 + * memory-views. 1771 + */ 1788 1772 1789 1773 mutex_unlock(&kvm->lock); 1790 1774 return 0;
+74 -63
arch/x86/kvm/svm/svm.c
··· 1566 1566 1567 1567 svm->vmcb->control.int_ctl |= svm->nested.ctl.int_ctl & 1568 1568 V_IRQ_INJECTION_BITS_MASK; 1569 + 1570 + svm->vmcb->control.int_vector = svm->nested.ctl.int_vector; 1569 1571 } 1570 1572 1571 1573 vmcb_mark_dirty(svm->vmcb, VMCB_INTR); ··· 2222 2220 2223 2221 /* Both #GP cases have zero error_code */ 2224 2222 if (error_code) 2223 + goto reinject; 2224 + 2225 + /* All SVM instructions expect page aligned RAX */ 2226 + if (svm->vmcb->save.rax & ~PAGE_MASK) 2225 2227 goto reinject; 2226 2228 2227 2229 /* Decode the instruction for usage later */ ··· 4291 4285 struct kvm_host_map map_save; 4292 4286 int ret; 4293 4287 4294 - if (is_guest_mode(vcpu)) { 4295 - /* FED8h - SVM Guest */ 4296 - put_smstate(u64, smstate, 0x7ed8, 1); 4297 - /* FEE0h - SVM Guest VMCB Physical Address */ 4298 - put_smstate(u64, smstate, 0x7ee0, svm->nested.vmcb12_gpa); 4288 + if (!is_guest_mode(vcpu)) 4289 + return 0; 4299 4290 4300 - svm->vmcb->save.rax = vcpu->arch.regs[VCPU_REGS_RAX]; 4301 - svm->vmcb->save.rsp = vcpu->arch.regs[VCPU_REGS_RSP]; 4302 - svm->vmcb->save.rip = vcpu->arch.regs[VCPU_REGS_RIP]; 4291 + /* FED8h - SVM Guest */ 4292 + put_smstate(u64, smstate, 0x7ed8, 1); 4293 + /* FEE0h - SVM Guest VMCB Physical Address */ 4294 + put_smstate(u64, smstate, 0x7ee0, svm->nested.vmcb12_gpa); 4303 4295 4304 - ret = nested_svm_vmexit(svm); 4305 - if (ret) 4306 - return ret; 4296 + svm->vmcb->save.rax = vcpu->arch.regs[VCPU_REGS_RAX]; 4297 + svm->vmcb->save.rsp = vcpu->arch.regs[VCPU_REGS_RSP]; 4298 + svm->vmcb->save.rip = vcpu->arch.regs[VCPU_REGS_RIP]; 4307 4299 4308 - /* 4309 - * KVM uses VMCB01 to store L1 host state while L2 runs but 4310 - * VMCB01 is going to be used during SMM and thus the state will 4311 - * be lost. Temporary save non-VMLOAD/VMSAVE state to the host save 4312 - * area pointed to by MSR_VM_HSAVE_PA. APM guarantees that the 4313 - * format of the area is identical to guest save area offsetted 4314 - * by 0x400 (matches the offset of 'struct vmcb_save_area' 4315 - * within 'struct vmcb'). Note: HSAVE area may also be used by 4316 - * L1 hypervisor to save additional host context (e.g. KVM does 4317 - * that, see svm_prepare_guest_switch()) which must be 4318 - * preserved. 4319 - */ 4320 - if (kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.hsave_msr), 4321 - &map_save) == -EINVAL) 4322 - return 1; 4300 + ret = nested_svm_vmexit(svm); 4301 + if (ret) 4302 + return ret; 4323 4303 4324 - BUILD_BUG_ON(offsetof(struct vmcb, save) != 0x400); 4304 + /* 4305 + * KVM uses VMCB01 to store L1 host state while L2 runs but 4306 + * VMCB01 is going to be used during SMM and thus the state will 4307 + * be lost. Temporary save non-VMLOAD/VMSAVE state to the host save 4308 + * area pointed to by MSR_VM_HSAVE_PA. APM guarantees that the 4309 + * format of the area is identical to guest save area offsetted 4310 + * by 0x400 (matches the offset of 'struct vmcb_save_area' 4311 + * within 'struct vmcb'). Note: HSAVE area may also be used by 4312 + * L1 hypervisor to save additional host context (e.g. KVM does 4313 + * that, see svm_prepare_guest_switch()) which must be 4314 + * preserved. 4315 + */ 4316 + if (kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.hsave_msr), 4317 + &map_save) == -EINVAL) 4318 + return 1; 4325 4319 4326 - svm_copy_vmrun_state(map_save.hva + 0x400, 4327 - &svm->vmcb01.ptr->save); 4320 + BUILD_BUG_ON(offsetof(struct vmcb, save) != 0x400); 4328 4321 4329 - kvm_vcpu_unmap(vcpu, &map_save, true); 4330 - } 4322 + svm_copy_vmrun_state(map_save.hva + 0x400, 4323 + &svm->vmcb01.ptr->save); 4324 + 4325 + kvm_vcpu_unmap(vcpu, &map_save, true); 4331 4326 return 0; 4332 4327 } 4333 4328 ··· 4336 4329 { 4337 4330 struct vcpu_svm *svm = to_svm(vcpu); 4338 4331 struct kvm_host_map map, map_save; 4339 - int ret = 0; 4332 + u64 saved_efer, vmcb12_gpa; 4333 + struct vmcb *vmcb12; 4334 + int ret; 4340 4335 4341 - if (guest_cpuid_has(vcpu, X86_FEATURE_LM)) { 4342 - u64 saved_efer = GET_SMSTATE(u64, smstate, 0x7ed0); 4343 - u64 guest = GET_SMSTATE(u64, smstate, 0x7ed8); 4344 - u64 vmcb12_gpa = GET_SMSTATE(u64, smstate, 0x7ee0); 4345 - struct vmcb *vmcb12; 4336 + if (!guest_cpuid_has(vcpu, X86_FEATURE_LM)) 4337 + return 0; 4346 4338 4347 - if (guest) { 4348 - if (!guest_cpuid_has(vcpu, X86_FEATURE_SVM)) 4349 - return 1; 4339 + /* Non-zero if SMI arrived while vCPU was in guest mode. */ 4340 + if (!GET_SMSTATE(u64, smstate, 0x7ed8)) 4341 + return 0; 4350 4342 4351 - if (!(saved_efer & EFER_SVME)) 4352 - return 1; 4343 + if (!guest_cpuid_has(vcpu, X86_FEATURE_SVM)) 4344 + return 1; 4353 4345 4354 - if (kvm_vcpu_map(vcpu, 4355 - gpa_to_gfn(vmcb12_gpa), &map) == -EINVAL) 4356 - return 1; 4346 + saved_efer = GET_SMSTATE(u64, smstate, 0x7ed0); 4347 + if (!(saved_efer & EFER_SVME)) 4348 + return 1; 4357 4349 4358 - if (svm_allocate_nested(svm)) 4359 - return 1; 4350 + vmcb12_gpa = GET_SMSTATE(u64, smstate, 0x7ee0); 4351 + if (kvm_vcpu_map(vcpu, gpa_to_gfn(vmcb12_gpa), &map) == -EINVAL) 4352 + return 1; 4360 4353 4361 - vmcb12 = map.hva; 4354 + ret = 1; 4355 + if (kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.hsave_msr), &map_save) == -EINVAL) 4356 + goto unmap_map; 4362 4357 4363 - nested_load_control_from_vmcb12(svm, &vmcb12->control); 4358 + if (svm_allocate_nested(svm)) 4359 + goto unmap_save; 4364 4360 4365 - ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12); 4366 - kvm_vcpu_unmap(vcpu, &map, true); 4361 + /* 4362 + * Restore L1 host state from L1 HSAVE area as VMCB01 was 4363 + * used during SMM (see svm_enter_smm()) 4364 + */ 4367 4365 4368 - /* 4369 - * Restore L1 host state from L1 HSAVE area as VMCB01 was 4370 - * used during SMM (see svm_enter_smm()) 4371 - */ 4372 - if (kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.hsave_msr), 4373 - &map_save) == -EINVAL) 4374 - return 1; 4366 + svm_copy_vmrun_state(&svm->vmcb01.ptr->save, map_save.hva + 0x400); 4375 4367 4376 - svm_copy_vmrun_state(&svm->vmcb01.ptr->save, 4377 - map_save.hva + 0x400); 4368 + /* 4369 + * Enter the nested guest now 4370 + */ 4378 4371 4379 - kvm_vcpu_unmap(vcpu, &map_save, true); 4380 - } 4381 - } 4372 + vmcb12 = map.hva; 4373 + nested_load_control_from_vmcb12(svm, &vmcb12->control); 4374 + ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, false); 4382 4375 4376 + unmap_save: 4377 + kvm_vcpu_unmap(vcpu, &map_save, true); 4378 + unmap_map: 4379 + kvm_vcpu_unmap(vcpu, &map, true); 4383 4380 return ret; 4384 4381 } 4385 4382
+2 -1
arch/x86/kvm/svm/svm.h
··· 459 459 return vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_NMI); 460 460 } 461 461 462 - int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb_gpa, struct vmcb *vmcb12); 462 + int enter_svm_guest_mode(struct kvm_vcpu *vcpu, 463 + u64 vmcb_gpa, struct vmcb *vmcb12, bool from_vmrun); 463 464 void svm_leave_nested(struct vcpu_svm *svm); 464 465 void svm_free_nested(struct vcpu_svm *svm); 465 466 int svm_allocate_nested(struct vcpu_svm *svm);
+9 -3
arch/x86/kvm/vmx/evmcs.c
··· 353 353 switch (msr_index) { 354 354 case MSR_IA32_VMX_EXIT_CTLS: 355 355 case MSR_IA32_VMX_TRUE_EXIT_CTLS: 356 - ctl_high &= ~VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL; 356 + ctl_high &= ~EVMCS1_UNSUPPORTED_VMEXIT_CTRL; 357 357 break; 358 358 case MSR_IA32_VMX_ENTRY_CTLS: 359 359 case MSR_IA32_VMX_TRUE_ENTRY_CTLS: 360 - ctl_high &= ~VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL; 360 + ctl_high &= ~EVMCS1_UNSUPPORTED_VMENTRY_CTRL; 361 361 break; 362 362 case MSR_IA32_VMX_PROCBASED_CTLS2: 363 - ctl_high &= ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; 363 + ctl_high &= ~EVMCS1_UNSUPPORTED_2NDEXEC; 364 + break; 365 + case MSR_IA32_VMX_PINBASED_CTLS: 366 + ctl_high &= ~EVMCS1_UNSUPPORTED_PINCTRL; 367 + break; 368 + case MSR_IA32_VMX_VMFUNC: 369 + ctl_low &= ~EVMCS1_UNSUPPORTED_VMFUNC; 364 370 break; 365 371 } 366 372
+15 -9
arch/x86/kvm/vmx/nested.c
··· 2583 2583 * Guest state is invalid and unrestricted guest is disabled, 2584 2584 * which means L1 attempted VMEntry to L2 with invalid state. 2585 2585 * Fail the VMEntry. 2586 + * 2587 + * However when force loading the guest state (SMM exit or 2588 + * loading nested state after migration, it is possible to 2589 + * have invalid guest state now, which will be later fixed by 2590 + * restoring L2 register state 2586 2591 */ 2587 - if (CC(!vmx_guest_state_valid(vcpu))) { 2592 + if (CC(from_vmentry && !vmx_guest_state_valid(vcpu))) { 2588 2593 *entry_failure_code = ENTRY_FAIL_DEFAULT; 2589 2594 return -EINVAL; 2590 2595 } ··· 4356 4351 if (nested_vmx_load_msr(vcpu, vmcs12->vm_exit_msr_load_addr, 4357 4352 vmcs12->vm_exit_msr_load_count)) 4358 4353 nested_vmx_abort(vcpu, VMX_ABORT_LOAD_HOST_MSR_FAIL); 4354 + 4355 + to_vmx(vcpu)->emulation_required = vmx_emulation_required(vcpu); 4359 4356 } 4360 4357 4361 4358 static inline u64 nested_vmx_get_vmcs01_guest_efer(struct vcpu_vmx *vmx) ··· 4906 4899 return -ENOMEM; 4907 4900 } 4908 4901 4909 - /* 4910 - * Emulate the VMXON instruction. 4911 - * Currently, we just remember that VMX is active, and do not save or even 4912 - * inspect the argument to VMXON (the so-called "VMXON pointer") because we 4913 - * do not currently need to store anything in that guest-allocated memory 4914 - * region. Consequently, VMCLEAR and VMPTRLD also do not verify that the their 4915 - * argument is different from the VMXON pointer (which the spec says they do). 4916 - */ 4902 + /* Emulate the VMXON instruction. */ 4917 4903 static int handle_vmon(struct kvm_vcpu *vcpu) 4918 4904 { 4919 4905 int ret; ··· 5902 5902 return true; 5903 5903 case EXIT_REASON_VMFUNC: 5904 5904 /* VM functions are emulated through L2->L0 vmexits. */ 5905 + return true; 5906 + case EXIT_REASON_BUS_LOCK: 5907 + /* 5908 + * At present, bus lock VM exit is never exposed to L1. 5909 + * Handle L2's bus locks in L0 directly. 5910 + */ 5905 5911 return true; 5906 5912 default: 5907 5913 break;
+27 -12
arch/x86/kvm/vmx/vmx.c
··· 1323 1323 vmx_prepare_switch_to_host(to_vmx(vcpu)); 1324 1324 } 1325 1325 1326 - static bool emulation_required(struct kvm_vcpu *vcpu) 1326 + bool vmx_emulation_required(struct kvm_vcpu *vcpu) 1327 1327 { 1328 1328 return emulate_invalid_guest_state && !vmx_guest_state_valid(vcpu); 1329 1329 } ··· 1367 1367 vmcs_writel(GUEST_RFLAGS, rflags); 1368 1368 1369 1369 if ((old_rflags ^ vmx->rflags) & X86_EFLAGS_VM) 1370 - vmx->emulation_required = emulation_required(vcpu); 1370 + vmx->emulation_required = vmx_emulation_required(vcpu); 1371 1371 } 1372 1372 1373 1373 u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu) ··· 1837 1837 &msr_info->data)) 1838 1838 return 1; 1839 1839 /* 1840 - * Enlightened VMCS v1 doesn't have certain fields, but buggy 1841 - * Hyper-V versions are still trying to use corresponding 1842 - * features when they are exposed. Filter out the essential 1843 - * minimum. 1840 + * Enlightened VMCS v1 doesn't have certain VMCS fields but 1841 + * instead of just ignoring the features, different Hyper-V 1842 + * versions are either trying to use them and fail or do some 1843 + * sanity checking and refuse to boot. Filter all unsupported 1844 + * features out. 1844 1845 */ 1845 1846 if (!msr_info->host_initiated && 1846 1847 vmx->nested.enlightened_vmcs_enabled) ··· 3078 3077 } 3079 3078 3080 3079 /* depends on vcpu->arch.cr0 to be set to a new value */ 3081 - vmx->emulation_required = emulation_required(vcpu); 3080 + vmx->emulation_required = vmx_emulation_required(vcpu); 3082 3081 } 3083 3082 3084 3083 static int vmx_get_max_tdp_level(void) ··· 3331 3330 { 3332 3331 __vmx_set_segment(vcpu, var, seg); 3333 3332 3334 - to_vmx(vcpu)->emulation_required = emulation_required(vcpu); 3333 + to_vmx(vcpu)->emulation_required = vmx_emulation_required(vcpu); 3335 3334 } 3336 3335 3337 3336 static void vmx_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l) ··· 6622 6621 vmx->loaded_vmcs->soft_vnmi_blocked)) 6623 6622 vmx->loaded_vmcs->entry_time = ktime_get(); 6624 6623 6625 - /* Don't enter VMX if guest state is invalid, let the exit handler 6626 - start emulation until we arrive back to a valid state */ 6627 - if (vmx->emulation_required) 6624 + /* 6625 + * Don't enter VMX if guest state is invalid, let the exit handler 6626 + * start emulation until we arrive back to a valid state. Synthesize a 6627 + * consistency check VM-Exit due to invalid guest state and bail. 6628 + */ 6629 + if (unlikely(vmx->emulation_required)) { 6630 + 6631 + /* We don't emulate invalid state of a nested guest */ 6632 + vmx->fail = is_guest_mode(vcpu); 6633 + 6634 + vmx->exit_reason.full = EXIT_REASON_INVALID_STATE; 6635 + vmx->exit_reason.failed_vmentry = 1; 6636 + kvm_register_mark_available(vcpu, VCPU_EXREG_EXIT_INFO_1); 6637 + vmx->exit_qualification = ENTRY_FAIL_DEFAULT; 6638 + kvm_register_mark_available(vcpu, VCPU_EXREG_EXIT_INFO_2); 6639 + vmx->exit_intr_info = 0; 6628 6640 return EXIT_FASTPATH_NONE; 6641 + } 6629 6642 6630 6643 trace_kvm_entry(vcpu); 6631 6644 ··· 6848 6833 */ 6849 6834 tsx_ctrl = vmx_find_uret_msr(vmx, MSR_IA32_TSX_CTRL); 6850 6835 if (tsx_ctrl) 6851 - vmx->guest_uret_msrs[i].mask = ~(u64)TSX_CTRL_CPUID_CLEAR; 6836 + tsx_ctrl->mask = ~(u64)TSX_CTRL_CPUID_CLEAR; 6852 6837 } 6853 6838 6854 6839 err = alloc_loaded_vmcs(&vmx->vmcs01);
+1 -4
arch/x86/kvm/vmx/vmx.h
··· 248 248 * only loaded into hardware when necessary, e.g. SYSCALL #UDs outside 249 249 * of 64-bit mode or if EFER.SCE=1, thus the SYSCALL MSRs don't need to 250 250 * be loaded into hardware if those conditions aren't met. 251 - * nr_active_uret_msrs tracks the number of MSRs that need to be loaded 252 - * into hardware when running the guest. guest_uret_msrs[] is resorted 253 - * whenever the number of "active" uret MSRs is modified. 254 251 */ 255 252 struct vmx_uret_msr guest_uret_msrs[MAX_NR_USER_RETURN_MSRS]; 256 - int nr_active_uret_msrs; 257 253 bool guest_uret_msrs_loaded; 258 254 #ifdef CONFIG_X86_64 259 255 u64 msr_host_kernel_gs_base; ··· 355 359 void vmx_set_host_fs_gs(struct vmcs_host_state *host, u16 fs_sel, u16 gs_sel, 356 360 unsigned long fs_base, unsigned long gs_base); 357 361 int vmx_get_cpl(struct kvm_vcpu *vcpu); 362 + bool vmx_emulation_required(struct kvm_vcpu *vcpu); 358 363 unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu); 359 364 void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags); 360 365 u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu);
+26 -2
arch/x86/kvm/x86.c
··· 1332 1332 MSR_ARCH_PERFMON_EVENTSEL0 + 12, MSR_ARCH_PERFMON_EVENTSEL0 + 13, 1333 1333 MSR_ARCH_PERFMON_EVENTSEL0 + 14, MSR_ARCH_PERFMON_EVENTSEL0 + 15, 1334 1334 MSR_ARCH_PERFMON_EVENTSEL0 + 16, MSR_ARCH_PERFMON_EVENTSEL0 + 17, 1335 + 1336 + MSR_K7_EVNTSEL0, MSR_K7_EVNTSEL1, MSR_K7_EVNTSEL2, MSR_K7_EVNTSEL3, 1337 + MSR_K7_PERFCTR0, MSR_K7_PERFCTR1, MSR_K7_PERFCTR2, MSR_K7_PERFCTR3, 1338 + MSR_F15H_PERF_CTL0, MSR_F15H_PERF_CTL1, MSR_F15H_PERF_CTL2, 1339 + MSR_F15H_PERF_CTL3, MSR_F15H_PERF_CTL4, MSR_F15H_PERF_CTL5, 1340 + MSR_F15H_PERF_CTR0, MSR_F15H_PERF_CTR1, MSR_F15H_PERF_CTR2, 1341 + MSR_F15H_PERF_CTR3, MSR_F15H_PERF_CTR4, MSR_F15H_PERF_CTR5, 1335 1342 }; 1336 1343 1337 1344 static u32 msrs_to_save[ARRAY_SIZE(msrs_to_save_all)]; ··· 2976 2969 offsetof(struct compat_vcpu_info, time)); 2977 2970 if (vcpu->xen.vcpu_time_info_set) 2978 2971 kvm_setup_pvclock_page(v, &vcpu->xen.vcpu_time_info_cache, 0); 2979 - if (v == kvm_get_vcpu(v->kvm, 0)) 2972 + if (!v->vcpu_idx) 2980 2973 kvm_hv_setup_tsc_page(v->kvm, &vcpu->hv_clock); 2981 2974 return 0; 2982 2975 } ··· 7665 7658 7666 7659 /* Process a latched INIT or SMI, if any. */ 7667 7660 kvm_make_request(KVM_REQ_EVENT, vcpu); 7661 + 7662 + /* 7663 + * Even if KVM_SET_SREGS2 loaded PDPTRs out of band, 7664 + * on SMM exit we still need to reload them from 7665 + * guest memory 7666 + */ 7667 + vcpu->arch.pdptrs_from_userspace = false; 7668 7668 } 7669 7669 7670 7670 kvm_mmu_reset_context(vcpu); ··· 10666 10652 int r; 10667 10653 10668 10654 vcpu->arch.last_vmentry_cpu = -1; 10655 + vcpu->arch.regs_avail = ~0; 10656 + vcpu->arch.regs_dirty = ~0; 10669 10657 10670 10658 if (!irqchip_in_kernel(vcpu->kvm) || kvm_vcpu_is_reset_bsp(vcpu)) 10671 10659 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; ··· 10908 10892 10909 10893 kvm_set_rflags(vcpu, X86_EFLAGS_FIXED); 10910 10894 kvm_rip_write(vcpu, 0xfff0); 10895 + 10896 + vcpu->arch.cr3 = 0; 10897 + kvm_register_mark_dirty(vcpu, VCPU_EXREG_CR3); 10911 10898 10912 10899 /* 10913 10900 * CR0.CD/NW are set on RESET, preserved on INIT. Note, some versions ··· 11158 11139 11159 11140 int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) 11160 11141 { 11142 + int ret; 11143 + 11161 11144 if (type) 11162 11145 return -EINVAL; 11146 + 11147 + ret = kvm_page_track_init(kvm); 11148 + if (ret) 11149 + return ret; 11163 11150 11164 11151 INIT_HLIST_HEAD(&kvm->arch.mask_notifier_list); 11165 11152 INIT_LIST_HEAD(&kvm->arch.active_mmu_pages); ··· 11199 11174 11200 11175 kvm_apicv_init(kvm); 11201 11176 kvm_hv_init_vm(kvm); 11202 - kvm_page_track_init(kvm); 11203 11177 kvm_mmu_init_vm(kvm); 11204 11178 kvm_xen_init_vm(kvm); 11205 11179
+48 -18
arch/x86/net/bpf_jit_comp.c
··· 1341 1341 if (insn->imm == (BPF_AND | BPF_FETCH) || 1342 1342 insn->imm == (BPF_OR | BPF_FETCH) || 1343 1343 insn->imm == (BPF_XOR | BPF_FETCH)) { 1344 - u8 *branch_target; 1345 1344 bool is64 = BPF_SIZE(insn->code) == BPF_DW; 1346 1345 u32 real_src_reg = src_reg; 1346 + u32 real_dst_reg = dst_reg; 1347 + u8 *branch_target; 1347 1348 1348 1349 /* 1349 1350 * Can't be implemented with a single x86 insn. ··· 1355 1354 emit_mov_reg(&prog, true, BPF_REG_AX, BPF_REG_0); 1356 1355 if (src_reg == BPF_REG_0) 1357 1356 real_src_reg = BPF_REG_AX; 1357 + if (dst_reg == BPF_REG_0) 1358 + real_dst_reg = BPF_REG_AX; 1358 1359 1359 1360 branch_target = prog; 1360 1361 /* Load old value */ 1361 1362 emit_ldx(&prog, BPF_SIZE(insn->code), 1362 - BPF_REG_0, dst_reg, insn->off); 1363 + BPF_REG_0, real_dst_reg, insn->off); 1363 1364 /* 1364 1365 * Perform the (commutative) operation locally, 1365 1366 * put the result in the AUX_REG. ··· 1372 1369 add_2reg(0xC0, AUX_REG, real_src_reg)); 1373 1370 /* Attempt to swap in new value */ 1374 1371 err = emit_atomic(&prog, BPF_CMPXCHG, 1375 - dst_reg, AUX_REG, insn->off, 1372 + real_dst_reg, AUX_REG, 1373 + insn->off, 1376 1374 BPF_SIZE(insn->code)); 1377 1375 if (WARN_ON(err)) 1378 1376 return err; ··· 1387 1383 /* Restore R0 after clobbering RAX */ 1388 1384 emit_mov_reg(&prog, true, BPF_REG_0, BPF_REG_AX); 1389 1385 break; 1390 - 1391 1386 } 1392 1387 1393 1388 err = emit_atomic(&prog, insn->imm, dst_reg, src_reg, 1394 - insn->off, BPF_SIZE(insn->code)); 1389 + insn->off, BPF_SIZE(insn->code)); 1395 1390 if (err) 1396 1391 return err; 1397 1392 break; ··· 1747 1744 } 1748 1745 1749 1746 static int invoke_bpf_prog(const struct btf_func_model *m, u8 **pprog, 1750 - struct bpf_prog *p, int stack_size, bool mod_ret) 1747 + struct bpf_prog *p, int stack_size, bool save_ret) 1751 1748 { 1752 1749 u8 *prog = *pprog; 1753 1750 u8 *jmp_insn; ··· 1780 1777 if (emit_call(&prog, p->bpf_func, prog)) 1781 1778 return -EINVAL; 1782 1779 1783 - /* BPF_TRAMP_MODIFY_RETURN trampolines can modify the return 1780 + /* 1781 + * BPF_TRAMP_MODIFY_RETURN trampolines can modify the return 1784 1782 * of the previous call which is then passed on the stack to 1785 1783 * the next BPF program. 1784 + * 1785 + * BPF_TRAMP_FENTRY trampoline may need to return the return 1786 + * value of BPF_PROG_TYPE_STRUCT_OPS prog. 1786 1787 */ 1787 - if (mod_ret) 1788 + if (save_ret) 1788 1789 emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -8); 1789 1790 1790 1791 /* replace 2 nops with JE insn, since jmp target is known */ ··· 1835 1828 } 1836 1829 1837 1830 static int invoke_bpf(const struct btf_func_model *m, u8 **pprog, 1838 - struct bpf_tramp_progs *tp, int stack_size) 1831 + struct bpf_tramp_progs *tp, int stack_size, 1832 + bool save_ret) 1839 1833 { 1840 1834 int i; 1841 1835 u8 *prog = *pprog; 1842 1836 1843 1837 for (i = 0; i < tp->nr_progs; i++) { 1844 - if (invoke_bpf_prog(m, &prog, tp->progs[i], stack_size, false)) 1838 + if (invoke_bpf_prog(m, &prog, tp->progs[i], stack_size, 1839 + save_ret)) 1845 1840 return -EINVAL; 1846 1841 } 1847 1842 *pprog = prog; ··· 1884 1875 1885 1876 *pprog = prog; 1886 1877 return 0; 1878 + } 1879 + 1880 + static bool is_valid_bpf_tramp_flags(unsigned int flags) 1881 + { 1882 + if ((flags & BPF_TRAMP_F_RESTORE_REGS) && 1883 + (flags & BPF_TRAMP_F_SKIP_FRAME)) 1884 + return false; 1885 + 1886 + /* 1887 + * BPF_TRAMP_F_RET_FENTRY_RET is only used by bpf_struct_ops, 1888 + * and it must be used alone. 1889 + */ 1890 + if ((flags & BPF_TRAMP_F_RET_FENTRY_RET) && 1891 + (flags & ~BPF_TRAMP_F_RET_FENTRY_RET)) 1892 + return false; 1893 + 1894 + return true; 1887 1895 } 1888 1896 1889 1897 /* Example: ··· 1975 1949 struct bpf_tramp_progs *fmod_ret = &tprogs[BPF_TRAMP_MODIFY_RETURN]; 1976 1950 u8 **branches = NULL; 1977 1951 u8 *prog; 1952 + bool save_ret; 1978 1953 1979 1954 /* x86-64 supports up to 6 arguments. 7+ can be added in the future */ 1980 1955 if (nr_args > 6) 1981 1956 return -ENOTSUPP; 1982 1957 1983 - if ((flags & BPF_TRAMP_F_RESTORE_REGS) && 1984 - (flags & BPF_TRAMP_F_SKIP_FRAME)) 1958 + if (!is_valid_bpf_tramp_flags(flags)) 1985 1959 return -EINVAL; 1986 1960 1987 - if (flags & BPF_TRAMP_F_CALL_ORIG) 1988 - stack_size += 8; /* room for return value of orig_call */ 1961 + /* room for return value of orig_call or fentry prog */ 1962 + save_ret = flags & (BPF_TRAMP_F_CALL_ORIG | BPF_TRAMP_F_RET_FENTRY_RET); 1963 + if (save_ret) 1964 + stack_size += 8; 1989 1965 1990 1966 if (flags & BPF_TRAMP_F_IP_ARG) 1991 1967 stack_size += 8; /* room for IP address argument */ ··· 2033 2005 } 2034 2006 2035 2007 if (fentry->nr_progs) 2036 - if (invoke_bpf(m, &prog, fentry, stack_size)) 2008 + if (invoke_bpf(m, &prog, fentry, stack_size, 2009 + flags & BPF_TRAMP_F_RET_FENTRY_RET)) 2037 2010 return -EINVAL; 2038 2011 2039 2012 if (fmod_ret->nr_progs) { ··· 2081 2052 } 2082 2053 2083 2054 if (fexit->nr_progs) 2084 - if (invoke_bpf(m, &prog, fexit, stack_size)) { 2055 + if (invoke_bpf(m, &prog, fexit, stack_size, false)) { 2085 2056 ret = -EINVAL; 2086 2057 goto cleanup; 2087 2058 } ··· 2101 2072 ret = -EINVAL; 2102 2073 goto cleanup; 2103 2074 } 2104 - /* restore original return value back into RAX */ 2105 - emit_ldx(&prog, BPF_DW, BPF_REG_0, BPF_REG_FP, -8); 2106 2075 } 2076 + /* restore return value of orig_call or fentry prog back into RAX */ 2077 + if (save_ret) 2078 + emit_ldx(&prog, BPF_DW, BPF_REG_0, BPF_REG_FP, -8); 2107 2079 2108 2080 EMIT1(0x5B); /* pop rbx */ 2109 2081 EMIT1(0xC9); /* leave */
+3 -13
block/bfq-iosched.c
··· 2662 2662 * are likely to increase the throughput. 2663 2663 */ 2664 2664 bfqq->new_bfqq = new_bfqq; 2665 - /* 2666 - * The above assignment schedules the following redirections: 2667 - * each time some I/O for bfqq arrives, the process that 2668 - * generated that I/O is disassociated from bfqq and 2669 - * associated with new_bfqq. Here we increases new_bfqq->ref 2670 - * in advance, adding the number of processes that are 2671 - * expected to be associated with new_bfqq as they happen to 2672 - * issue I/O. 2673 - */ 2674 2665 new_bfqq->ref += process_refs; 2675 2666 return new_bfqq; 2676 2667 } ··· 2723 2732 void *io_struct, bool request, struct bfq_io_cq *bic) 2724 2733 { 2725 2734 struct bfq_queue *in_service_bfqq, *new_bfqq; 2726 - 2727 - /* if a merge has already been setup, then proceed with that first */ 2728 - if (bfqq->new_bfqq) 2729 - return bfqq->new_bfqq; 2730 2735 2731 2736 /* 2732 2737 * Check delayed stable merge for rotational or non-queueing ··· 2824 2837 */ 2825 2838 if (bfq_too_late_for_merging(bfqq)) 2826 2839 return NULL; 2840 + 2841 + if (bfqq->new_bfqq) 2842 + return bfqq->new_bfqq; 2827 2843 2828 2844 if (!io_struct || unlikely(bfqq == &bfqd->oom_bfqq)) 2829 2845 return NULL;
+12
drivers/acpi/nfit/core.c
··· 3007 3007 ndr_desc->target_node = NUMA_NO_NODE; 3008 3008 } 3009 3009 3010 + /* Fallback to address based numa information if node lookup failed */ 3011 + if (ndr_desc->numa_node == NUMA_NO_NODE) { 3012 + ndr_desc->numa_node = memory_add_physaddr_to_nid(spa->address); 3013 + dev_info(acpi_desc->dev, "changing numa node from %d to %d for nfit region [%pa-%pa]", 3014 + NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end); 3015 + } 3016 + if (ndr_desc->target_node == NUMA_NO_NODE) { 3017 + ndr_desc->target_node = phys_to_target_node(spa->address); 3018 + dev_info(acpi_desc->dev, "changing target node from %d to %d for nfit region [%pa-%pa]", 3019 + NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end); 3020 + } 3021 + 3010 3022 /* 3011 3023 * Persistence domain bits are hierarchical, if 3012 3024 * ACPI_NFIT_CAPABILITY_CACHE_FLUSH is set then
+63 -27
drivers/base/core.c
··· 95 95 96 96 list_add(&link->s_hook, &sup->consumers); 97 97 list_add(&link->c_hook, &con->suppliers); 98 + pr_debug("%pfwP Linked as a fwnode consumer to %pfwP\n", 99 + con, sup); 98 100 out: 99 101 mutex_unlock(&fwnode_link_lock); 100 102 101 103 return ret; 104 + } 105 + 106 + /** 107 + * __fwnode_link_del - Delete a link between two fwnode_handles. 108 + * @link: the fwnode_link to be deleted 109 + * 110 + * The fwnode_link_lock needs to be held when this function is called. 111 + */ 112 + static void __fwnode_link_del(struct fwnode_link *link) 113 + { 114 + pr_debug("%pfwP Dropping the fwnode link to %pfwP\n", 115 + link->consumer, link->supplier); 116 + list_del(&link->s_hook); 117 + list_del(&link->c_hook); 118 + kfree(link); 102 119 } 103 120 104 121 /** ··· 129 112 struct fwnode_link *link, *tmp; 130 113 131 114 mutex_lock(&fwnode_link_lock); 132 - list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) { 133 - list_del(&link->s_hook); 134 - list_del(&link->c_hook); 135 - kfree(link); 136 - } 115 + list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) 116 + __fwnode_link_del(link); 137 117 mutex_unlock(&fwnode_link_lock); 138 118 } 139 119 ··· 145 131 struct fwnode_link *link, *tmp; 146 132 147 133 mutex_lock(&fwnode_link_lock); 148 - list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) { 149 - list_del(&link->s_hook); 150 - list_del(&link->c_hook); 151 - kfree(link); 152 - } 134 + list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) 135 + __fwnode_link_del(link); 153 136 mutex_unlock(&fwnode_link_lock); 154 137 } 155 138 ··· 986 975 { 987 976 struct device_link *link; 988 977 int ret = 0; 978 + struct fwnode_handle *sup_fw; 989 979 990 980 /* 991 981 * Device waiting for supplier to become available is not allowed to ··· 995 983 mutex_lock(&fwnode_link_lock); 996 984 if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) && 997 985 !fw_devlink_is_permissive()) { 998 - dev_dbg(dev, "probe deferral - wait for supplier %pfwP\n", 999 - list_first_entry(&dev->fwnode->suppliers, 1000 - struct fwnode_link, 1001 - c_hook)->supplier); 986 + sup_fw = list_first_entry(&dev->fwnode->suppliers, 987 + struct fwnode_link, 988 + c_hook)->supplier; 989 + dev_err_probe(dev, -EPROBE_DEFER, "wait for supplier %pfwP\n", 990 + sup_fw); 1002 991 mutex_unlock(&fwnode_link_lock); 1003 992 return -EPROBE_DEFER; 1004 993 } ··· 1014 1001 if (link->status != DL_STATE_AVAILABLE && 1015 1002 !(link->flags & DL_FLAG_SYNC_STATE_ONLY)) { 1016 1003 device_links_missing_supplier(dev); 1017 - dev_dbg(dev, "probe deferral - supplier %s not ready\n", 1018 - dev_name(link->supplier)); 1004 + dev_err_probe(dev, -EPROBE_DEFER, 1005 + "supplier %s not ready\n", 1006 + dev_name(link->supplier)); 1019 1007 ret = -EPROBE_DEFER; 1020 1008 break; 1021 1009 } ··· 1736 1722 struct device *sup_dev; 1737 1723 int ret = 0; 1738 1724 1725 + /* 1726 + * In some cases, a device P might also be a supplier to its child node 1727 + * C. However, this would defer the probe of C until the probe of P 1728 + * completes successfully. This is perfectly fine in the device driver 1729 + * model. device_add() doesn't guarantee probe completion of the device 1730 + * by the time it returns. 1731 + * 1732 + * However, there are a few drivers that assume C will finish probing 1733 + * as soon as it's added and before P finishes probing. So, we provide 1734 + * a flag to let fw_devlink know not to delay the probe of C until the 1735 + * probe of P completes successfully. 1736 + * 1737 + * When such a flag is set, we can't create device links where P is the 1738 + * supplier of C as that would delay the probe of C. 1739 + */ 1740 + if (sup_handle->flags & FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD && 1741 + fwnode_is_ancestor_of(sup_handle, con->fwnode)) 1742 + return -EINVAL; 1743 + 1739 1744 sup_dev = get_dev_from_fwnode(sup_handle); 1740 1745 if (sup_dev) { 1741 1746 /* ··· 1805 1772 * be broken by applying logic. Check for these types of cycles and 1806 1773 * break them so that devices in the cycle probe properly. 1807 1774 * 1808 - * If the supplier's parent is dependent on the consumer, then 1809 - * the consumer-supplier dependency is a false dependency. So, 1810 - * treat it as an invalid link. 1775 + * If the supplier's parent is dependent on the consumer, then the 1776 + * consumer and supplier have a cyclic dependency. Since fw_devlink 1777 + * can't tell which of the inferred dependencies are incorrect, don't 1778 + * enforce probe ordering between any of the devices in this cyclic 1779 + * dependency. Do this by relaxing all the fw_devlink device links in 1780 + * this cycle and by treating the fwnode link between the consumer and 1781 + * the supplier as an invalid dependency. 1811 1782 */ 1812 1783 sup_dev = fwnode_get_next_parent_dev(sup_handle); 1813 1784 if (sup_dev && device_is_dependent(con, sup_dev)) { 1814 - dev_dbg(con, "Not linking to %pfwP - False link\n", 1815 - sup_handle); 1785 + dev_info(con, "Fixing up cyclic dependency with %pfwP (%s)\n", 1786 + sup_handle, dev_name(sup_dev)); 1787 + device_links_write_lock(); 1788 + fw_devlink_relax_cycle(con, sup_dev); 1789 + device_links_write_unlock(); 1816 1790 ret = -EINVAL; 1817 1791 } else { 1818 1792 /* ··· 1898 1858 if (!own_link || ret == -EAGAIN) 1899 1859 continue; 1900 1860 1901 - list_del(&link->s_hook); 1902 - list_del(&link->c_hook); 1903 - kfree(link); 1861 + __fwnode_link_del(link); 1904 1862 } 1905 1863 } 1906 1864 ··· 1950 1912 if (!own_link || ret == -EAGAIN) 1951 1913 continue; 1952 1914 1953 - list_del(&link->s_hook); 1954 - list_del(&link->c_hook); 1955 - kfree(link); 1915 + __fwnode_link_del(link); 1956 1916 1957 1917 /* If no device link was created, nothing more to do. */ 1958 1918 if (ret)
+17 -12
drivers/block/nbd.c
··· 97 97 98 98 atomic_t recv_threads; 99 99 wait_queue_head_t recv_wq; 100 - loff_t blksize; 100 + unsigned int blksize_bits; 101 101 loff_t bytesize; 102 102 #if IS_ENABLED(CONFIG_DEBUG_FS) 103 103 struct dentry *dbg_dir; 104 104 #endif 105 105 }; 106 + 107 + static inline unsigned int nbd_blksize(struct nbd_config *config) 108 + { 109 + return 1u << config->blksize_bits; 110 + } 106 111 107 112 struct nbd_device { 108 113 struct blk_mq_tag_set tag_set; ··· 151 146 152 147 #define NBD_MAGIC 0x68797548 153 148 154 - #define NBD_DEF_BLKSIZE 1024 149 + #define NBD_DEF_BLKSIZE_BITS 10 155 150 156 151 static unsigned int nbds_max = 16; 157 152 static int max_part = 16; ··· 322 317 loff_t blksize) 323 318 { 324 319 if (!blksize) 325 - blksize = NBD_DEF_BLKSIZE; 320 + blksize = 1u << NBD_DEF_BLKSIZE_BITS; 326 321 if (blksize < 512 || blksize > PAGE_SIZE || !is_power_of_2(blksize)) 327 322 return -EINVAL; 328 323 329 324 nbd->config->bytesize = bytesize; 330 - nbd->config->blksize = blksize; 325 + nbd->config->blksize_bits = __ffs(blksize); 331 326 332 327 if (!nbd->task_recv) 333 328 return 0; ··· 1342 1337 args->index = i; 1343 1338 queue_work(nbd->recv_workq, &args->work); 1344 1339 } 1345 - return nbd_set_size(nbd, config->bytesize, config->blksize); 1340 + return nbd_set_size(nbd, config->bytesize, nbd_blksize(config)); 1346 1341 } 1347 1342 1348 1343 static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *bdev) ··· 1411 1406 case NBD_SET_BLKSIZE: 1412 1407 return nbd_set_size(nbd, config->bytesize, arg); 1413 1408 case NBD_SET_SIZE: 1414 - return nbd_set_size(nbd, arg, config->blksize); 1409 + return nbd_set_size(nbd, arg, nbd_blksize(config)); 1415 1410 case NBD_SET_SIZE_BLOCKS: 1416 - if (check_mul_overflow((loff_t)arg, config->blksize, &bytesize)) 1411 + if (check_shl_overflow(arg, config->blksize_bits, &bytesize)) 1417 1412 return -EINVAL; 1418 - return nbd_set_size(nbd, bytesize, config->blksize); 1413 + return nbd_set_size(nbd, bytesize, nbd_blksize(config)); 1419 1414 case NBD_SET_TIMEOUT: 1420 1415 nbd_set_cmd_timeout(nbd, arg); 1421 1416 return 0; ··· 1481 1476 atomic_set(&config->recv_threads, 0); 1482 1477 init_waitqueue_head(&config->recv_wq); 1483 1478 init_waitqueue_head(&config->conn_wait); 1484 - config->blksize = NBD_DEF_BLKSIZE; 1479 + config->blksize_bits = NBD_DEF_BLKSIZE_BITS; 1485 1480 atomic_set(&config->live_connections, 0); 1486 1481 try_module_get(THIS_MODULE); 1487 1482 return config; ··· 1609 1604 debugfs_create_file("tasks", 0444, dir, nbd, &nbd_dbg_tasks_fops); 1610 1605 debugfs_create_u64("size_bytes", 0444, dir, &config->bytesize); 1611 1606 debugfs_create_u32("timeout", 0444, dir, &nbd->tag_set.timeout); 1612 - debugfs_create_u64("blocksize", 0444, dir, &config->blksize); 1607 + debugfs_create_u32("blocksize_bits", 0444, dir, &config->blksize_bits); 1613 1608 debugfs_create_file("flags", 0444, dir, nbd, &nbd_dbg_flags_fops); 1614 1609 1615 1610 return 0; ··· 1831 1826 static int nbd_genl_size_set(struct genl_info *info, struct nbd_device *nbd) 1832 1827 { 1833 1828 struct nbd_config *config = nbd->config; 1834 - u64 bsize = config->blksize; 1829 + u64 bsize = nbd_blksize(config); 1835 1830 u64 bytes = config->bytesize; 1836 1831 1837 1832 if (info->attrs[NBD_ATTR_SIZE_BYTES]) ··· 1840 1835 if (info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]) 1841 1836 bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]); 1842 1837 1843 - if (bytes != config->bytesize || bsize != config->blksize) 1838 + if (bytes != config->bytesize || bsize != nbd_blksize(config)) 1844 1839 return nbd_set_size(nbd, bytes, bsize); 1845 1840 return 0; 1846 1841 }
+8 -6
drivers/crypto/ccp/ccp-ops.c
··· 778 778 in_place ? DMA_BIDIRECTIONAL 779 779 : DMA_TO_DEVICE); 780 780 if (ret) 781 - goto e_ctx; 781 + goto e_aad; 782 782 783 783 if (in_place) { 784 784 dst = src; ··· 863 863 op.u.aes.size = 0; 864 864 ret = cmd_q->ccp->vdata->perform->aes(&op); 865 865 if (ret) 866 - goto e_dst; 866 + goto e_final_wa; 867 867 868 868 if (aes->action == CCP_AES_ACTION_ENCRYPT) { 869 869 /* Put the ciphered tag after the ciphertext. */ ··· 873 873 ret = ccp_init_dm_workarea(&tag, cmd_q, authsize, 874 874 DMA_BIDIRECTIONAL); 875 875 if (ret) 876 - goto e_tag; 876 + goto e_final_wa; 877 877 ret = ccp_set_dm_area(&tag, 0, p_tag, 0, authsize); 878 - if (ret) 879 - goto e_tag; 878 + if (ret) { 879 + ccp_dm_free(&tag); 880 + goto e_final_wa; 881 + } 880 882 881 883 ret = crypto_memneq(tag.address, final_wa.address, 882 884 authsize) ? -EBADMSG : 0; 883 885 ccp_dm_free(&tag); 884 886 } 885 887 886 - e_tag: 888 + e_final_wa: 887 889 ccp_dm_free(&final_wa); 888 890 889 891 e_dst:
+2 -9
drivers/gpio/gpio-pca953x.c
··· 468 468 mutex_lock(&chip->i2c_lock); 469 469 ret = regmap_read(chip->regmap, inreg, &reg_val); 470 470 mutex_unlock(&chip->i2c_lock); 471 - if (ret < 0) { 472 - /* 473 - * NOTE: 474 - * diagnostic already emitted; that's all we should 475 - * do unless gpio_*_value_cansleep() calls become different 476 - * from their nonsleeping siblings (and report faults). 477 - */ 478 - return 0; 479 - } 471 + if (ret < 0) 472 + return ret; 480 473 481 474 return !!(reg_val & bit); 482 475 }
+22
drivers/gpio/gpio-rockchip.c
··· 689 689 struct device_node *pctlnp = of_get_parent(np); 690 690 struct pinctrl_dev *pctldev = NULL; 691 691 struct rockchip_pin_bank *bank = NULL; 692 + struct rockchip_pin_output_deferred *cfg; 692 693 static int gpio; 693 694 int id, ret; 694 695 ··· 717 716 if (ret) 718 717 return ret; 719 718 719 + /* 720 + * Prevent clashes with a deferred output setting 721 + * being added right at this moment. 722 + */ 723 + mutex_lock(&bank->deferred_lock); 724 + 720 725 ret = rockchip_gpiolib_register(bank); 721 726 if (ret) { 722 727 clk_disable_unprepare(bank->clk); 728 + mutex_unlock(&bank->deferred_lock); 723 729 return ret; 724 730 } 731 + 732 + while (!list_empty(&bank->deferred_output)) { 733 + cfg = list_first_entry(&bank->deferred_output, 734 + struct rockchip_pin_output_deferred, head); 735 + list_del(&cfg->head); 736 + 737 + ret = rockchip_gpio_direction_output(&bank->gpio_chip, cfg->pin, cfg->arg); 738 + if (ret) 739 + dev_warn(dev, "setting output pin %u to %u failed\n", cfg->pin, cfg->arg); 740 + 741 + kfree(cfg); 742 + } 743 + 744 + mutex_unlock(&bank->deferred_lock); 725 745 726 746 platform_set_drvdata(pdev, bank); 727 747 dev_info(dev, "probed %pOF\n", np);
+31
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
··· 837 837 return 0; 838 838 } 839 839 840 + /* Mirrors the is_displayable check in radeonsi's gfx6_compute_surface */ 841 + static int check_tiling_flags_gfx6(struct amdgpu_framebuffer *afb) 842 + { 843 + u64 micro_tile_mode; 844 + 845 + /* Zero swizzle mode means linear */ 846 + if (AMDGPU_TILING_GET(afb->tiling_flags, SWIZZLE_MODE) == 0) 847 + return 0; 848 + 849 + micro_tile_mode = AMDGPU_TILING_GET(afb->tiling_flags, MICRO_TILE_MODE); 850 + switch (micro_tile_mode) { 851 + case 0: /* DISPLAY */ 852 + case 3: /* RENDER */ 853 + return 0; 854 + default: 855 + drm_dbg_kms(afb->base.dev, 856 + "Micro tile mode %llu not supported for scanout\n", 857 + micro_tile_mode); 858 + return -EINVAL; 859 + } 860 + } 861 + 840 862 static void get_block_dimensions(unsigned int block_log2, unsigned int cpp, 841 863 unsigned int *width, unsigned int *height) 842 864 { ··· 1125 1103 const struct drm_mode_fb_cmd2 *mode_cmd, 1126 1104 struct drm_gem_object *obj) 1127 1105 { 1106 + struct amdgpu_device *adev = drm_to_adev(dev); 1128 1107 int ret, i; 1129 1108 1130 1109 /* ··· 1144 1121 ret = amdgpu_display_get_fb_info(rfb, &rfb->tiling_flags, &rfb->tmz_surface); 1145 1122 if (ret) 1146 1123 return ret; 1124 + 1125 + if (!dev->mode_config.allow_fb_modifiers) { 1126 + drm_WARN_ONCE(dev, adev->family >= AMDGPU_FAMILY_AI, 1127 + "GFX9+ requires FB check based on format modifier\n"); 1128 + ret = check_tiling_flags_gfx6(rfb); 1129 + if (ret) 1130 + return ret; 1131 + } 1147 1132 1148 1133 if (dev->mode_config.allow_fb_modifiers && 1149 1134 !(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
+1 -1
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
··· 3599 3599 3600 3600 /* set static priority for a queue/ring */ 3601 3601 gfx_v9_0_mqd_set_priority(ring, mqd); 3602 - mqd->cp_hqd_quantum = RREG32(mmCP_HQD_QUANTUM); 3602 + mqd->cp_hqd_quantum = RREG32_SOC15(GC, 0, mmCP_HQD_QUANTUM); 3603 3603 3604 3604 /* map_queues packet doesn't need activate the queue, 3605 3605 * so only kiq need set this field.
+2 -1
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
··· 1098 1098 { 1099 1099 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1100 1100 1101 + gmc_v10_0_gart_disable(adev); 1102 + 1101 1103 if (amdgpu_sriov_vf(adev)) { 1102 1104 /* full access mode, so don't touch any GMC register */ 1103 1105 DRM_DEBUG("For SRIOV client, shouldn't do anything.\n"); ··· 1108 1106 1109 1107 amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0); 1110 1108 amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0); 1111 - gmc_v10_0_gart_disable(adev); 1112 1109 1113 1110 return 0; 1114 1111 }
+2 -1
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 1794 1794 { 1795 1795 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1796 1796 1797 + gmc_v9_0_gart_disable(adev); 1798 + 1797 1799 if (amdgpu_sriov_vf(adev)) { 1798 1800 /* full access mode, so don't touch any GMC register */ 1799 1801 DRM_DEBUG("For SRIOV client, shouldn't do anything.\n"); ··· 1804 1802 1805 1803 amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0); 1806 1804 amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0); 1807 - gmc_v9_0_gart_disable(adev); 1808 1805 1809 1806 return 0; 1810 1807 }
+8
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
··· 868 868 msleep(1000); 869 869 } 870 870 871 + /* TODO: check whether can submit a doorbell request to raise 872 + * a doorbell fence to exit gfxoff. 873 + */ 874 + if (adev->in_s0ix) 875 + amdgpu_gfx_off_ctrl(adev, false); 876 + 871 877 sdma_v5_2_soft_reset(adev); 872 878 /* unhalt the MEs */ 873 879 sdma_v5_2_enable(adev, true); ··· 882 876 883 877 /* start the gfx rings and rlc compute queues */ 884 878 r = sdma_v5_2_gfx_resume(adev); 879 + if (adev->in_s0ix) 880 + amdgpu_gfx_off_ctrl(adev, true); 885 881 if (r) 886 882 return r; 887 883 r = sdma_v5_2_rlc_resume(adev);
+2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 1115 1115 1116 1116 init_data.asic_id.pci_revision_id = adev->pdev->revision; 1117 1117 init_data.asic_id.hw_internal_rev = adev->external_rev_id; 1118 + init_data.asic_id.chip_id = adev->pdev->device; 1118 1119 1119 1120 init_data.asic_id.vram_width = adev->gmc.vram_width; 1120 1121 /* TODO: initialize init_data.asic_id.vram_type here!!!! */ ··· 1720 1719 linear_lut[i] = 0xFFFF * i / 15; 1721 1720 1722 1721 params.set = 0; 1722 + params.backlight_ramping_override = false; 1723 1723 params.backlight_ramping_start = 0xCCCC; 1724 1724 params.backlight_ramping_reduction = 0xCCCCCCCC; 1725 1725 params.backlight_lut_array_size = 16;
+1 -3
drivers/gpu/drm/exynos/exynos5433_drm_decon.c
··· 793 793 { 794 794 struct device *dev = &pdev->dev; 795 795 struct decon_context *ctx; 796 - struct resource *res; 797 796 int ret; 798 797 int i; 799 798 ··· 817 818 ctx->clks[i] = clk; 818 819 } 819 820 820 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 821 - ctx->addr = devm_ioremap_resource(dev, res); 821 + ctx->addr = devm_platform_ioremap_resource(pdev, 0); 822 822 if (IS_ERR(ctx->addr)) 823 823 return PTR_ERR(ctx->addr); 824 824
+1 -3
drivers/gpu/drm/exynos/exynos_drm_dsi.c
··· 1738 1738 static int exynos_dsi_probe(struct platform_device *pdev) 1739 1739 { 1740 1740 struct device *dev = &pdev->dev; 1741 - struct resource *res; 1742 1741 struct exynos_dsi *dsi; 1743 1742 int ret, i; 1744 1743 ··· 1788 1789 } 1789 1790 } 1790 1791 1791 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1792 - dsi->reg_base = devm_ioremap_resource(dev, res); 1792 + dsi->reg_base = devm_platform_ioremap_resource(pdev, 0); 1793 1793 if (IS_ERR(dsi->reg_base)) 1794 1794 return PTR_ERR(dsi->reg_base); 1795 1795
+1 -4
drivers/gpu/drm/exynos/exynos_drm_fimc.c
··· 85 85 /* 86 86 * A structure of fimc context. 87 87 * 88 - * @regs_res: register resources. 89 88 * @regs: memory mapped io registers. 90 89 * @lock: locking of operations. 91 90 * @clocks: fimc clocks. ··· 102 103 struct exynos_drm_ipp_formats *formats; 103 104 unsigned int num_formats; 104 105 105 - struct resource *regs_res; 106 106 void __iomem *regs; 107 107 spinlock_t lock; 108 108 struct clk *clocks[FIMC_CLKS_MAX]; ··· 1325 1327 ctx->num_formats = num_formats; 1326 1328 1327 1329 /* resource memory */ 1328 - ctx->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1329 - ctx->regs = devm_ioremap_resource(dev, ctx->regs_res); 1330 + ctx->regs = devm_platform_ioremap_resource(pdev, 0); 1330 1331 if (IS_ERR(ctx->regs)) 1331 1332 return PTR_ERR(ctx->regs); 1332 1333
+1 -3
drivers/gpu/drm/exynos/exynos_drm_fimd.c
··· 1202 1202 return PTR_ERR(ctx->lcd_clk); 1203 1203 } 1204 1204 1205 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1206 - 1207 - ctx->regs = devm_ioremap_resource(dev, res); 1205 + ctx->regs = devm_platform_ioremap_resource(pdev, 0); 1208 1206 if (IS_ERR(ctx->regs)) 1209 1207 return PTR_ERR(ctx->regs); 1210 1208
+1 -4
drivers/gpu/drm/exynos/exynos_drm_g2d.c
··· 1449 1449 static int g2d_probe(struct platform_device *pdev) 1450 1450 { 1451 1451 struct device *dev = &pdev->dev; 1452 - struct resource *res; 1453 1452 struct g2d_data *g2d; 1454 1453 int ret; 1455 1454 ··· 1490 1491 clear_bit(G2D_BIT_SUSPEND_RUNQUEUE, &g2d->flags); 1491 1492 clear_bit(G2D_BIT_ENGINE_BUSY, &g2d->flags); 1492 1493 1493 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1494 - 1495 - g2d->regs = devm_ioremap_resource(dev, res); 1494 + g2d->regs = devm_platform_ioremap_resource(pdev, 0); 1496 1495 if (IS_ERR(g2d->regs)) { 1497 1496 ret = PTR_ERR(g2d->regs); 1498 1497 goto err_put_clk;
+1 -5
drivers/gpu/drm/exynos/exynos_drm_gsc.c
··· 86 86 /* 87 87 * A structure of gsc context. 88 88 * 89 - * @regs_res: register resources. 90 89 * @regs: memory mapped io registers. 91 90 * @gsc_clk: gsc gate clock. 92 91 * @sc: scaler infomations. ··· 102 103 struct exynos_drm_ipp_formats *formats; 103 104 unsigned int num_formats; 104 105 105 - struct resource *regs_res; 106 106 void __iomem *regs; 107 107 const char **clk_names; 108 108 struct clk *clocks[GSC_MAX_CLOCKS]; ··· 1270 1272 } 1271 1273 } 1272 1274 1273 - /* resource memory */ 1274 - ctx->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1275 - ctx->regs = devm_ioremap_resource(dev, ctx->regs_res); 1275 + ctx->regs = devm_platform_ioremap_resource(pdev, 0); 1276 1276 if (IS_ERR(ctx->regs)) 1277 1277 return PTR_ERR(ctx->regs); 1278 1278
+1 -3
drivers/gpu/drm/exynos/exynos_drm_rotator.c
··· 278 278 static int rotator_probe(struct platform_device *pdev) 279 279 { 280 280 struct device *dev = &pdev->dev; 281 - struct resource *regs_res; 282 281 struct rot_context *rot; 283 282 const struct rot_variant *variant; 284 283 int irq; ··· 291 292 rot->formats = variant->formats; 292 293 rot->num_formats = variant->num_formats; 293 294 rot->dev = dev; 294 - regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 295 - rot->regs = devm_ioremap_resource(dev, regs_res); 295 + rot->regs = devm_platform_ioremap_resource(pdev, 0); 296 296 if (IS_ERR(rot->regs)) 297 297 return PTR_ERR(rot->regs); 298 298
+1 -3
drivers/gpu/drm/exynos/exynos_drm_scaler.c
··· 485 485 static int scaler_probe(struct platform_device *pdev) 486 486 { 487 487 struct device *dev = &pdev->dev; 488 - struct resource *regs_res; 489 488 struct scaler_context *scaler; 490 489 int irq; 491 490 int ret, i; ··· 497 498 (struct scaler_data *)of_device_get_match_data(dev); 498 499 499 500 scaler->dev = dev; 500 - regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 501 - scaler->regs = devm_ioremap_resource(dev, regs_res); 501 + scaler->regs = devm_platform_ioremap_resource(pdev, 0); 502 502 if (IS_ERR(scaler->regs)) 503 503 return PTR_ERR(scaler->regs); 504 504
+1 -3
drivers/gpu/drm/exynos/exynos_hdmi.c
··· 1957 1957 struct hdmi_audio_infoframe *audio_infoframe; 1958 1958 struct device *dev = &pdev->dev; 1959 1959 struct hdmi_context *hdata; 1960 - struct resource *res; 1961 1960 int ret; 1962 1961 1963 1962 hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL); ··· 1978 1979 return ret; 1979 1980 } 1980 1981 1981 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1982 - hdata->regs = devm_ioremap_resource(dev, res); 1982 + hdata->regs = devm_platform_ioremap_resource(pdev, 0); 1983 1983 if (IS_ERR(hdata->regs)) { 1984 1984 ret = PTR_ERR(hdata->regs); 1985 1985 return ret;
+3 -2
drivers/gpu/drm/i915/gt/intel_context.c
··· 362 362 return 0; 363 363 } 364 364 365 - static int sw_fence_dummy_notify(struct i915_sw_fence *sf, 366 - enum i915_sw_fence_notify state) 365 + static int __i915_sw_fence_call 366 + sw_fence_dummy_notify(struct i915_sw_fence *sf, 367 + enum i915_sw_fence_notify state) 367 368 { 368 369 return NOTIFY_DONE; 369 370 }
-2
drivers/gpu/drm/i915/gt/intel_rps.c
··· 882 882 if (!intel_rps_is_enabled(rps)) 883 883 return; 884 884 885 - GEM_BUG_ON(atomic_read(&rps->num_waiters)); 886 - 887 885 if (!intel_rps_clear_active(rps)) 888 886 return; 889 887
+5 -5
drivers/gpu/drm/i915/gt/uc/abi/guc_communication_ctb_abi.h
··· 102 102 * | +-------+--------------------------------------------------------------+ 103 103 * | | 7:0 | NUM_DWORDS = length (in dwords) of the embedded HXG message | 104 104 * +---+-------+--------------------------------------------------------------+ 105 - * | 1 | 31:0 | +--------------------------------------------------------+ | 106 - * +---+-------+ | | | 107 - * |...| | | Embedded `HXG Message`_ | | 108 - * +---+-------+ | | | 109 - * | n | 31:0 | +--------------------------------------------------------+ | 105 + * | 1 | 31:0 | | 106 + * +---+-------+ | 107 + * |...| | [Embedded `HXG Message`_] | 108 + * +---+-------+ | 109 + * | n | 31:0 | | 110 110 * +---+-------+--------------------------------------------------------------+ 111 111 */ 112 112
+5 -5
drivers/gpu/drm/i915/gt/uc/abi/guc_communication_mmio_abi.h
··· 38 38 * +---+-------+--------------------------------------------------------------+ 39 39 * | | Bits | Description | 40 40 * +===+=======+==============================================================+ 41 - * | 0 | 31:0 | +--------------------------------------------------------+ | 42 - * +---+-------+ | | | 43 - * |...| | | Embedded `HXG Message`_ | | 44 - * +---+-------+ | | | 45 - * | n | 31:0 | +--------------------------------------------------------+ | 41 + * | 0 | 31:0 | | 42 + * +---+-------+ | 43 + * |...| | [Embedded `HXG Message`_] | 44 + * +---+-------+ | 45 + * | n | 31:0 | | 46 46 * +---+-------+--------------------------------------------------------------+ 47 47 */ 48 48
+2 -2
drivers/gpu/drm/i915/gvt/scheduler.c
··· 576 576 577 577 /* No one is going to touch shadow bb from now on. */ 578 578 i915_gem_object_flush_map(bb->obj); 579 - i915_gem_object_unlock(bb->obj); 579 + i915_gem_ww_ctx_fini(&ww); 580 580 } 581 581 } 582 582 return 0; ··· 630 630 return ret; 631 631 } 632 632 633 - i915_gem_object_unlock(wa_ctx->indirect_ctx.obj); 633 + i915_gem_ww_ctx_fini(&ww); 634 634 635 635 /* FIXME: we are not tracking our pinned VMA leaving it 636 636 * up to the core to fix up the stray pin_count upon
+2 -9
drivers/gpu/drm/i915/i915_request.c
··· 829 829 i915_sw_fence_init(&rq->submit, submit_notify); 830 830 i915_sw_fence_init(&rq->semaphore, semaphore_notify); 831 831 832 - dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock, 0, 0); 833 - 834 832 rq->capture_list = NULL; 835 833 836 834 init_llist_head(&rq->execute_cb); ··· 903 905 rq->ring = ce->ring; 904 906 rq->execution_mask = ce->engine->mask; 905 907 906 - kref_init(&rq->fence.refcount); 907 - rq->fence.flags = 0; 908 - rq->fence.error = 0; 909 - INIT_LIST_HEAD(&rq->fence.cb_list); 910 - 911 908 ret = intel_timeline_get_seqno(tl, rq, &seqno); 912 909 if (ret) 913 910 goto err_free; 914 911 915 - rq->fence.context = tl->fence_context; 916 - rq->fence.seqno = seqno; 912 + dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock, 913 + tl->fence_context, seqno); 917 914 918 915 RCU_INIT_POINTER(rq->timeline, tl); 919 916 rq->hwsp_seqno = tl->hwsp_seqno;
-3
drivers/gpu/drm/tegra/dc.c
··· 1845 1845 bool prepare_bandwidth_transition) 1846 1846 { 1847 1847 const struct tegra_plane_state *old_tegra_state, *new_tegra_state; 1848 - const struct tegra_dc_state *old_dc_state, *new_dc_state; 1849 1848 u32 i, new_avg_bw, old_avg_bw, new_peak_bw, old_peak_bw; 1850 1849 const struct drm_plane_state *old_plane_state; 1851 1850 const struct drm_crtc_state *old_crtc_state; ··· 1857 1858 return; 1858 1859 1859 1860 old_crtc_state = drm_atomic_get_old_crtc_state(state, crtc); 1860 - old_dc_state = to_const_dc_state(old_crtc_state); 1861 - new_dc_state = to_const_dc_state(crtc->state); 1862 1861 1863 1862 if (!crtc->state->active) { 1864 1863 if (!old_crtc_state->active)
-6
drivers/gpu/drm/tegra/dc.h
··· 35 35 return NULL; 36 36 } 37 37 38 - static inline const struct tegra_dc_state * 39 - to_const_dc_state(const struct drm_crtc_state *state) 40 - { 41 - return to_dc_state((struct drm_crtc_state *)state); 42 - } 43 - 44 38 struct tegra_dc_stats { 45 39 unsigned long frames; 46 40 unsigned long vblank;
+1 -1
drivers/gpu/drm/tegra/uapi.c
··· 222 222 mapping->iova = sg_dma_address(mapping->sgt->sgl); 223 223 } 224 224 225 - mapping->iova_end = mapping->iova + host1x_to_tegra_bo(mapping->bo)->size; 225 + mapping->iova_end = mapping->iova + host1x_to_tegra_bo(mapping->bo)->gem.size; 226 226 227 227 err = xa_alloc(&context->mappings, &args->mapping, mapping, XA_LIMIT(1, U32_MAX), 228 228 GFP_KERNEL);
+4 -2
drivers/gpu/host1x/fence.c
··· 15 15 #include "intr.h" 16 16 #include "syncpt.h" 17 17 18 - DEFINE_SPINLOCK(lock); 18 + static DEFINE_SPINLOCK(lock); 19 19 20 20 struct host1x_syncpt_fence { 21 21 struct dma_fence base; ··· 152 152 return ERR_PTR(-ENOMEM); 153 153 154 154 fence->waiter = kzalloc(sizeof(*fence->waiter), GFP_KERNEL); 155 - if (!fence->waiter) 155 + if (!fence->waiter) { 156 + kfree(fence); 156 157 return ERR_PTR(-ENOMEM); 158 + } 157 159 158 160 fence->sp = sp; 159 161 fence->threshold = threshold;
+4 -4
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
··· 255 255 if (!privdata->cl_data) 256 256 return -ENOMEM; 257 257 258 - rc = devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); 258 + mp2_select_ops(privdata); 259 + 260 + rc = amd_sfh_hid_client_init(privdata); 259 261 if (rc) 260 262 return rc; 261 263 262 - mp2_select_ops(privdata); 263 - 264 - return amd_sfh_hid_client_init(privdata); 264 + return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); 265 265 } 266 266 267 267 static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
+7
drivers/hid/hid-apple.c
··· 336 336 337 337 /* 338 338 * MacBook JIS keyboard has wrong logical maximum 339 + * Magic Keyboard JIS has wrong logical maximum 339 340 */ 340 341 static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc, 341 342 unsigned int *rsize) 342 343 { 343 344 struct apple_sc *asc = hid_get_drvdata(hdev); 345 + 346 + if(*rsize >=71 && rdesc[70] == 0x65 && rdesc[64] == 0x65) { 347 + hid_info(hdev, 348 + "fixing up Magic Keyboard JIS report descriptor\n"); 349 + rdesc[64] = rdesc[70] = 0xe7; 350 + } 344 351 345 352 if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 && 346 353 rdesc[53] == 0x65 && rdesc[59] == 0x65) {
+10 -3
drivers/hid/hid-betopff.c
··· 56 56 { 57 57 struct betopff_device *betopff; 58 58 struct hid_report *report; 59 - struct hid_input *hidinput = 60 - list_first_entry(&hid->inputs, struct hid_input, list); 59 + struct hid_input *hidinput; 61 60 struct list_head *report_list = 62 61 &hid->report_enum[HID_OUTPUT_REPORT].report_list; 63 - struct input_dev *dev = hidinput->input; 62 + struct input_dev *dev; 64 63 int field_count = 0; 65 64 int error; 66 65 int i, j; 66 + 67 + if (list_empty(&hid->inputs)) { 68 + hid_err(hid, "no inputs found\n"); 69 + return -ENODEV; 70 + } 71 + 72 + hidinput = list_first_entry(&hid->inputs, struct hid_input, list); 73 + dev = hidinput->input; 67 74 68 75 if (list_empty(report_list)) { 69 76 hid_err(hid, "no output reports found\n");
+3 -1
drivers/hid/hid-u2fzero.c
··· 198 198 } 199 199 200 200 ret = u2fzero_recv(dev, &req, &resp); 201 - if (ret < 0) 201 + 202 + /* ignore errors or packets without data */ 203 + if (ret < offsetof(struct u2f_hid_msg, init.data)) 202 204 return 0; 203 205 204 206 /* only take the minimum amount of data it is safe to take */
+8
drivers/hid/wacom_wac.c
··· 4746 4746 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63, 4747 4747 INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, 4748 4748 .touch_max = 10 }; 4749 + static const struct wacom_features wacom_features_0x3c6 = 4750 + { "Wacom Intuos BT S", 15200, 9500, 4095, 63, 4751 + INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; 4752 + static const struct wacom_features wacom_features_0x3c8 = 4753 + { "Wacom Intuos BT M", 21600, 13500, 4095, 63, 4754 + INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; 4749 4755 4750 4756 static const struct wacom_features wacom_features_HID_ANY_ID = 4751 4757 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID }; ··· 4925 4919 { USB_DEVICE_WACOM(0x37A) }, 4926 4920 { USB_DEVICE_WACOM(0x37B) }, 4927 4921 { BT_DEVICE_WACOM(0x393) }, 4922 + { BT_DEVICE_WACOM(0x3c6) }, 4923 + { BT_DEVICE_WACOM(0x3c8) }, 4928 4924 { USB_DEVICE_WACOM(0x4001) }, 4929 4925 { USB_DEVICE_WACOM(0x4004) }, 4930 4926 { USB_DEVICE_WACOM(0x5000) },
-6
drivers/hwmon/k10temp.c
··· 362 362 HWMON_T_INPUT | HWMON_T_LABEL, 363 363 HWMON_T_INPUT | HWMON_T_LABEL, 364 364 HWMON_T_INPUT | HWMON_T_LABEL), 365 - HWMON_CHANNEL_INFO(in, 366 - HWMON_I_INPUT | HWMON_I_LABEL, 367 - HWMON_I_INPUT | HWMON_I_LABEL), 368 - HWMON_CHANNEL_INFO(curr, 369 - HWMON_C_INPUT | HWMON_C_LABEL, 370 - HWMON_C_INPUT | HWMON_C_LABEL), 371 365 NULL 372 366 }; 373 367
+6 -2
drivers/hwmon/ltc2947-core.c
··· 989 989 return ret; 990 990 991 991 /* check external clock presence */ 992 - extclk = devm_clk_get(st->dev, NULL); 993 - if (!IS_ERR(extclk)) { 992 + extclk = devm_clk_get_optional(st->dev, NULL); 993 + if (IS_ERR(extclk)) 994 + return dev_err_probe(st->dev, PTR_ERR(extclk), 995 + "Failed to get external clock\n"); 996 + 997 + if (extclk) { 994 998 unsigned long rate_hz; 995 999 u8 pre = 0, div, tbctl; 996 1000 u64 aux;
+9 -3
drivers/hwmon/mlxreg-fan.c
··· 315 315 { 316 316 struct mlxreg_fan *fan = cdev->devdata; 317 317 unsigned long cur_state; 318 + int i, config = 0; 318 319 u32 regval; 319 - int i; 320 320 int err; 321 321 322 322 /* ··· 329 329 * overwritten. 330 330 */ 331 331 if (state >= MLXREG_FAN_SPEED_MIN && state <= MLXREG_FAN_SPEED_MAX) { 332 + /* 333 + * This is configuration change, which is only supported through sysfs. 334 + * For configuration non-zero value is to be returned to avoid thermal 335 + * statistics update. 336 + */ 337 + config = 1; 332 338 state -= MLXREG_FAN_MAX_STATE; 333 339 for (i = 0; i < state; i++) 334 340 fan->cooling_levels[i] = state; ··· 349 343 350 344 cur_state = MLXREG_FAN_PWM_DUTY2STATE(regval); 351 345 if (state < cur_state) 352 - return 0; 346 + return config; 353 347 354 348 state = cur_state; 355 349 } ··· 365 359 dev_err(fan->dev, "Failed to write PWM duty\n"); 366 360 return err; 367 361 } 368 - return 0; 362 + return config; 369 363 } 370 364 371 365 static const struct thermal_cooling_device_ops mlxreg_fan_cooling_ops = {
+5 -12
drivers/hwmon/occ/common.c
··· 340 340 if (val == OCC_TEMP_SENSOR_FAULT) 341 341 return -EREMOTEIO; 342 342 343 - /* 344 - * VRM doesn't return temperature, only alarm bit. This 345 - * attribute maps to tempX_alarm instead of tempX_input for 346 - * VRM 347 - */ 348 - if (temp->fru_type != OCC_FRU_TYPE_VRM) { 349 - /* sensor not ready */ 350 - if (val == 0) 351 - return -EAGAIN; 343 + /* sensor not ready */ 344 + if (val == 0) 345 + return -EAGAIN; 352 346 353 - val *= 1000; 354 - } 347 + val *= 1000; 355 348 break; 356 349 case 2: 357 350 val = temp->fru_type; ··· 879 886 0, i); 880 887 attr++; 881 888 882 - if (sensors->temp.version > 1 && 889 + if (sensors->temp.version == 2 && 883 890 temp->fru_type == OCC_FRU_TYPE_VRM) { 884 891 snprintf(attr->name, sizeof(attr->name), 885 892 "temp%d_alarm", s);
+8 -2
drivers/hwmon/pmbus/ibm-cffps.c
··· 171 171 cmd = CFFPS_SN_CMD; 172 172 break; 173 173 case CFFPS_DEBUGFS_MAX_POWER_OUT: 174 - rc = i2c_smbus_read_word_swapped(psu->client, 175 - CFFPS_MAX_POWER_OUT_CMD); 174 + if (psu->version == cffps1) { 175 + rc = i2c_smbus_read_word_swapped(psu->client, 176 + CFFPS_MAX_POWER_OUT_CMD); 177 + } else { 178 + rc = i2c_smbus_read_word_data(psu->client, 179 + CFFPS_MAX_POWER_OUT_CMD); 180 + } 181 + 176 182 if (rc < 0) 177 183 return rc; 178 184
+1 -1
drivers/hwmon/pmbus/mp2975.c
··· 54 54 55 55 #define MP2975_RAIL2_FUNC (PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | \ 56 56 PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | \ 57 - PMBUS_PHASE_VIRTUAL) 57 + PMBUS_HAVE_POUT | PMBUS_PHASE_VIRTUAL) 58 58 59 59 struct mp2975_data { 60 60 struct pmbus_driver_info info;
+40 -33
drivers/hwmon/tmp421.c
··· 100 100 s16 temp[4]; 101 101 }; 102 102 103 - static int temp_from_s16(s16 reg) 103 + static int temp_from_raw(u16 reg, bool extended) 104 104 { 105 105 /* Mask out status bits */ 106 106 int temp = reg & ~0xf; 107 107 108 - return (temp * 1000 + 128) / 256; 108 + if (extended) 109 + temp = temp - 64 * 256; 110 + else 111 + temp = (s16)temp; 112 + 113 + return DIV_ROUND_CLOSEST(temp * 1000, 256); 109 114 } 110 115 111 - static int temp_from_u16(u16 reg) 116 + static int tmp421_update_device(struct tmp421_data *data) 112 117 { 113 - /* Mask out status bits */ 114 - int temp = reg & ~0xf; 115 - 116 - /* Add offset for extended temperature range. */ 117 - temp -= 64 * 256; 118 - 119 - return (temp * 1000 + 128) / 256; 120 - } 121 - 122 - static struct tmp421_data *tmp421_update_device(struct device *dev) 123 - { 124 - struct tmp421_data *data = dev_get_drvdata(dev); 125 118 struct i2c_client *client = data->client; 119 + int ret = 0; 126 120 int i; 127 121 128 122 mutex_lock(&data->update_lock); 129 123 130 124 if (time_after(jiffies, data->last_updated + (HZ / 2)) || 131 125 !data->valid) { 132 - data->config = i2c_smbus_read_byte_data(client, 133 - TMP421_CONFIG_REG_1); 126 + ret = i2c_smbus_read_byte_data(client, TMP421_CONFIG_REG_1); 127 + if (ret < 0) 128 + goto exit; 129 + data->config = ret; 134 130 135 131 for (i = 0; i < data->channels; i++) { 136 - data->temp[i] = i2c_smbus_read_byte_data(client, 137 - TMP421_TEMP_MSB[i]) << 8; 138 - data->temp[i] |= i2c_smbus_read_byte_data(client, 139 - TMP421_TEMP_LSB[i]); 132 + ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_MSB[i]); 133 + if (ret < 0) 134 + goto exit; 135 + data->temp[i] = ret << 8; 136 + 137 + ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_LSB[i]); 138 + if (ret < 0) 139 + goto exit; 140 + data->temp[i] |= ret; 140 141 } 141 142 data->last_updated = jiffies; 142 143 data->valid = 1; 143 144 } 144 145 146 + exit: 145 147 mutex_unlock(&data->update_lock); 146 148 147 - return data; 149 + if (ret < 0) { 150 + data->valid = 0; 151 + return ret; 152 + } 153 + 154 + return 0; 148 155 } 149 156 150 157 static int tmp421_read(struct device *dev, enum hwmon_sensor_types type, 151 158 u32 attr, int channel, long *val) 152 159 { 153 - struct tmp421_data *tmp421 = tmp421_update_device(dev); 160 + struct tmp421_data *tmp421 = dev_get_drvdata(dev); 161 + int ret = 0; 162 + 163 + ret = tmp421_update_device(tmp421); 164 + if (ret) 165 + return ret; 154 166 155 167 switch (attr) { 156 168 case hwmon_temp_input: 157 - if (tmp421->config & TMP421_CONFIG_RANGE) 158 - *val = temp_from_u16(tmp421->temp[channel]); 159 - else 160 - *val = temp_from_s16(tmp421->temp[channel]); 169 + *val = temp_from_raw(tmp421->temp[channel], 170 + tmp421->config & TMP421_CONFIG_RANGE); 161 171 return 0; 162 172 case hwmon_temp_fault: 163 173 /* 164 - * The OPEN bit signals a fault. This is bit 0 of the temperature 165 - * register (low byte). 174 + * Any of OPEN or /PVLD bits indicate a hardware mulfunction 175 + * and the conversion result may be incorrect 166 176 */ 167 - *val = tmp421->temp[channel] & 0x01; 177 + *val = !!(tmp421->temp[channel] & 0x03); 168 178 return 0; 169 179 default: 170 180 return -EOPNOTSUPP; ··· 187 177 { 188 178 switch (attr) { 189 179 case hwmon_temp_fault: 190 - if (channel == 0) 191 - return 0; 192 - return 0444; 193 180 case hwmon_temp_input: 194 181 return 0444; 195 182 default:
+11 -18
drivers/hwmon/w83791d.c
··· 273 273 char valid; /* !=0 if following fields are valid */ 274 274 unsigned long last_updated; /* In jiffies */ 275 275 276 - /* array of 2 pointers to subclients */ 277 - struct i2c_client *lm75[2]; 278 - 279 276 /* volts */ 280 277 u8 in[NUMBER_OF_VIN]; /* Register value */ 281 278 u8 in_max[NUMBER_OF_VIN]; /* Register value */ ··· 1254 1257 static int w83791d_detect_subclients(struct i2c_client *client) 1255 1258 { 1256 1259 struct i2c_adapter *adapter = client->adapter; 1257 - struct w83791d_data *data = i2c_get_clientdata(client); 1258 1260 int address = client->addr; 1259 1261 int i, id; 1260 1262 u8 val; ··· 1276 1280 } 1277 1281 1278 1282 val = w83791d_read(client, W83791D_REG_I2C_SUBADDR); 1279 - if (!(val & 0x08)) 1280 - data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter, 1281 - 0x48 + (val & 0x7)); 1282 - if (!(val & 0x80)) { 1283 - if (!IS_ERR(data->lm75[0]) && 1284 - ((val & 0x7) == ((val >> 4) & 0x7))) { 1285 - dev_err(&client->dev, 1286 - "duplicate addresses 0x%x, " 1287 - "use force_subclient\n", 1288 - data->lm75[0]->addr); 1289 - return -ENODEV; 1290 - } 1291 - data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter, 1292 - 0x48 + ((val >> 4) & 0x7)); 1283 + 1284 + if (!(val & 0x88) && (val & 0x7) == ((val >> 4) & 0x7)) { 1285 + dev_err(&client->dev, 1286 + "duplicate addresses 0x%x, use force_subclient\n", 0x48 + (val & 0x7)); 1287 + return -ENODEV; 1293 1288 } 1289 + 1290 + if (!(val & 0x08)) 1291 + devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + (val & 0x7)); 1292 + 1293 + if (!(val & 0x80)) 1294 + devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + ((val >> 4) & 0x7)); 1294 1295 1295 1296 return 0; 1296 1297 }
+11 -17
drivers/hwmon/w83792d.c
··· 264 264 char valid; /* !=0 if following fields are valid */ 265 265 unsigned long last_updated; /* In jiffies */ 266 266 267 - /* array of 2 pointers to subclients */ 268 - struct i2c_client *lm75[2]; 269 - 270 267 u8 in[9]; /* Register value */ 271 268 u8 in_max[9]; /* Register value */ 272 269 u8 in_min[9]; /* Register value */ ··· 924 927 int address = new_client->addr; 925 928 u8 val; 926 929 struct i2c_adapter *adapter = new_client->adapter; 927 - struct w83792d_data *data = i2c_get_clientdata(new_client); 928 930 929 931 id = i2c_adapter_id(adapter); 930 932 if (force_subclients[0] == id && force_subclients[1] == address) { ··· 942 946 } 943 947 944 948 val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR); 945 - if (!(val & 0x08)) 946 - data->lm75[0] = devm_i2c_new_dummy_device(&new_client->dev, adapter, 947 - 0x48 + (val & 0x7)); 948 - if (!(val & 0x80)) { 949 - if (!IS_ERR(data->lm75[0]) && 950 - ((val & 0x7) == ((val >> 4) & 0x7))) { 951 - dev_err(&new_client->dev, 952 - "duplicate addresses 0x%x, use force_subclient\n", 953 - data->lm75[0]->addr); 954 - return -ENODEV; 955 - } 956 - data->lm75[1] = devm_i2c_new_dummy_device(&new_client->dev, adapter, 957 - 0x48 + ((val >> 4) & 0x7)); 949 + 950 + if (!(val & 0x88) && (val & 0x7) == ((val >> 4) & 0x7)) { 951 + dev_err(&new_client->dev, 952 + "duplicate addresses 0x%x, use force_subclient\n", 0x48 + (val & 0x7)); 953 + return -ENODEV; 958 954 } 955 + 956 + if (!(val & 0x08)) 957 + devm_i2c_new_dummy_device(&new_client->dev, adapter, 0x48 + (val & 0x7)); 958 + 959 + if (!(val & 0x80)) 960 + devm_i2c_new_dummy_device(&new_client->dev, adapter, 0x48 + ((val >> 4) & 0x7)); 959 961 960 962 return 0; 961 963 }
+11 -15
drivers/hwmon/w83793.c
··· 202 202 } 203 203 204 204 struct w83793_data { 205 - struct i2c_client *lm75[2]; 206 205 struct device *hwmon_dev; 207 206 struct mutex update_lock; 208 207 char valid; /* !=0 if following fields are valid */ ··· 1565 1566 int address = client->addr; 1566 1567 u8 tmp; 1567 1568 struct i2c_adapter *adapter = client->adapter; 1568 - struct w83793_data *data = i2c_get_clientdata(client); 1569 1569 1570 1570 id = i2c_adapter_id(adapter); 1571 1571 if (force_subclients[0] == id && force_subclients[1] == address) { ··· 1584 1586 } 1585 1587 1586 1588 tmp = w83793_read_value(client, W83793_REG_I2C_SUBADDR); 1587 - if (!(tmp & 0x08)) 1588 - data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter, 1589 - 0x48 + (tmp & 0x7)); 1590 - if (!(tmp & 0x80)) { 1591 - if (!IS_ERR(data->lm75[0]) 1592 - && ((tmp & 0x7) == ((tmp >> 4) & 0x7))) { 1593 - dev_err(&client->dev, 1594 - "duplicate addresses 0x%x, " 1595 - "use force_subclients\n", data->lm75[0]->addr); 1596 - return -ENODEV; 1597 - } 1598 - data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter, 1599 - 0x48 + ((tmp >> 4) & 0x7)); 1589 + 1590 + if (!(tmp & 0x88) && (tmp & 0x7) == ((tmp >> 4) & 0x7)) { 1591 + dev_err(&client->dev, 1592 + "duplicate addresses 0x%x, use force_subclient\n", 0x48 + (tmp & 0x7)); 1593 + return -ENODEV; 1600 1594 } 1595 + 1596 + if (!(tmp & 0x08)) 1597 + devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + (tmp & 0x7)); 1598 + 1599 + if (!(tmp & 0x80)) 1600 + devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + ((tmp >> 4) & 0x7)); 1601 1601 1602 1602 return 0; 1603 1603 }
+45 -6
drivers/infiniband/core/cma.c
··· 1746 1746 } 1747 1747 } 1748 1748 1749 - static void cma_cancel_listens(struct rdma_id_private *id_priv) 1749 + static void _cma_cancel_listens(struct rdma_id_private *id_priv) 1750 1750 { 1751 1751 struct rdma_id_private *dev_id_priv; 1752 + 1753 + lockdep_assert_held(&lock); 1752 1754 1753 1755 /* 1754 1756 * Remove from listen_any_list to prevent added devices from spawning 1755 1757 * additional listen requests. 1756 1758 */ 1757 - mutex_lock(&lock); 1758 1759 list_del(&id_priv->list); 1759 1760 1760 1761 while (!list_empty(&id_priv->listen_list)) { ··· 1769 1768 rdma_destroy_id(&dev_id_priv->id); 1770 1769 mutex_lock(&lock); 1771 1770 } 1771 + } 1772 + 1773 + static void cma_cancel_listens(struct rdma_id_private *id_priv) 1774 + { 1775 + mutex_lock(&lock); 1776 + _cma_cancel_listens(id_priv); 1772 1777 mutex_unlock(&lock); 1773 1778 } 1774 1779 ··· 1783 1776 { 1784 1777 switch (state) { 1785 1778 case RDMA_CM_ADDR_QUERY: 1779 + /* 1780 + * We can avoid doing the rdma_addr_cancel() based on state, 1781 + * only RDMA_CM_ADDR_QUERY has a work that could still execute. 1782 + * Notice that the addr_handler work could still be exiting 1783 + * outside this state, however due to the interaction with the 1784 + * handler_mutex the work is guaranteed not to touch id_priv 1785 + * during exit. 1786 + */ 1786 1787 rdma_addr_cancel(&id_priv->id.route.addr.dev_addr); 1787 1788 break; 1788 1789 case RDMA_CM_ROUTE_QUERY: ··· 1825 1810 static void destroy_mc(struct rdma_id_private *id_priv, 1826 1811 struct cma_multicast *mc) 1827 1812 { 1813 + bool send_only = mc->join_state == BIT(SENDONLY_FULLMEMBER_JOIN); 1814 + 1828 1815 if (rdma_cap_ib_mcast(id_priv->id.device, id_priv->id.port_num)) 1829 1816 ib_sa_free_multicast(mc->sa_mc); 1830 1817 ··· 1843 1826 1844 1827 cma_set_mgid(id_priv, (struct sockaddr *)&mc->addr, 1845 1828 &mgid); 1846 - cma_igmp_send(ndev, &mgid, false); 1829 + 1830 + if (!send_only) 1831 + cma_igmp_send(ndev, &mgid, false); 1832 + 1847 1833 dev_put(ndev); 1848 1834 } 1849 1835 ··· 2594 2574 return 0; 2595 2575 2596 2576 err_listen: 2597 - list_del(&id_priv->list); 2577 + _cma_cancel_listens(id_priv); 2598 2578 mutex_unlock(&lock); 2599 2579 if (to_destroy) 2600 2580 rdma_destroy_id(&to_destroy->id); ··· 3433 3413 if (dst_addr->sa_family == AF_IB) { 3434 3414 ret = cma_resolve_ib_addr(id_priv); 3435 3415 } else { 3416 + /* 3417 + * The FSM can return back to RDMA_CM_ADDR_BOUND after 3418 + * rdma_resolve_ip() is called, eg through the error 3419 + * path in addr_handler(). If this happens the existing 3420 + * request must be canceled before issuing a new one. 3421 + * Since canceling a request is a bit slow and this 3422 + * oddball path is rare, keep track once a request has 3423 + * been issued. The track turns out to be a permanent 3424 + * state since this is the only cancel as it is 3425 + * immediately before rdma_resolve_ip(). 3426 + */ 3427 + if (id_priv->used_resolve_ip) 3428 + rdma_addr_cancel(&id->route.addr.dev_addr); 3429 + else 3430 + id_priv->used_resolve_ip = 1; 3436 3431 ret = rdma_resolve_ip(cma_src_addr(id_priv), dst_addr, 3437 3432 &id->route.addr.dev_addr, 3438 3433 timeout_ms, addr_handler, ··· 3806 3771 int ret; 3807 3772 3808 3773 if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_LISTEN)) { 3774 + struct sockaddr_in any_in = { 3775 + .sin_family = AF_INET, 3776 + .sin_addr.s_addr = htonl(INADDR_ANY), 3777 + }; 3778 + 3809 3779 /* For a well behaved ULP state will be RDMA_CM_IDLE */ 3810 - id->route.addr.src_addr.ss_family = AF_INET; 3811 - ret = rdma_bind_addr(id, cma_src_addr(id_priv)); 3780 + ret = rdma_bind_addr(id, (struct sockaddr *)&any_in); 3812 3781 if (ret) 3813 3782 return ret; 3814 3783 if (WARN_ON(!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND,
+1
drivers/infiniband/core/cma_priv.h
··· 91 91 u8 afonly; 92 92 u8 timeout; 93 93 u8 min_rnr_timer; 94 + u8 used_resolve_ip; 94 95 enum ib_gid_type gid_type; 95 96 96 97 /*
+4 -4
drivers/infiniband/hw/hfi1/ipoib_tx.c
··· 876 876 struct hfi1_ipoib_txq *txq = &priv->txqs[q]; 877 877 u64 completed = atomic64_read(&txq->complete_txreqs); 878 878 879 - dd_dev_info(priv->dd, "timeout txq %llx q %u stopped %u stops %d no_desc %d ring_full %d\n", 880 - (unsigned long long)txq, q, 879 + dd_dev_info(priv->dd, "timeout txq %p q %u stopped %u stops %d no_desc %d ring_full %d\n", 880 + txq, q, 881 881 __netif_subqueue_stopped(dev, txq->q_idx), 882 882 atomic_read(&txq->stops), 883 883 atomic_read(&txq->no_desc), 884 884 atomic_read(&txq->ring_full)); 885 - dd_dev_info(priv->dd, "sde %llx engine %u\n", 886 - (unsigned long long)txq->sde, 885 + dd_dev_info(priv->dd, "sde %p engine %u\n", 886 + txq->sde, 887 887 txq->sde ? txq->sde->this_idx : 0); 888 888 dd_dev_info(priv->dd, "flow %x\n", txq->flow.as_int); 889 889 dd_dev_info(priv->dd, "sent %llu completed %llu used %llu\n",
+22 -9
drivers/infiniband/hw/hns/hns_roce_cq.c
··· 326 326 INIT_LIST_HEAD(&hr_cq->rq_list); 327 327 } 328 328 329 - static void set_cqe_size(struct hns_roce_cq *hr_cq, struct ib_udata *udata, 330 - struct hns_roce_ib_create_cq *ucmd) 329 + static int set_cqe_size(struct hns_roce_cq *hr_cq, struct ib_udata *udata, 330 + struct hns_roce_ib_create_cq *ucmd) 331 331 { 332 332 struct hns_roce_dev *hr_dev = to_hr_dev(hr_cq->ib_cq.device); 333 333 334 - if (udata) { 335 - if (udata->inlen >= offsetofend(typeof(*ucmd), cqe_size)) 336 - hr_cq->cqe_size = ucmd->cqe_size; 337 - else 338 - hr_cq->cqe_size = HNS_ROCE_V2_CQE_SIZE; 339 - } else { 334 + if (!udata) { 340 335 hr_cq->cqe_size = hr_dev->caps.cqe_sz; 336 + return 0; 341 337 } 338 + 339 + if (udata->inlen >= offsetofend(typeof(*ucmd), cqe_size)) { 340 + if (ucmd->cqe_size != HNS_ROCE_V2_CQE_SIZE && 341 + ucmd->cqe_size != HNS_ROCE_V3_CQE_SIZE) { 342 + ibdev_err(&hr_dev->ib_dev, 343 + "invalid cqe size %u.\n", ucmd->cqe_size); 344 + return -EINVAL; 345 + } 346 + 347 + hr_cq->cqe_size = ucmd->cqe_size; 348 + } else { 349 + hr_cq->cqe_size = HNS_ROCE_V2_CQE_SIZE; 350 + } 351 + 352 + return 0; 342 353 } 343 354 344 355 int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr, ··· 377 366 378 367 set_cq_param(hr_cq, attr->cqe, attr->comp_vector, &ucmd); 379 368 380 - set_cqe_size(hr_cq, udata, &ucmd); 369 + ret = set_cqe_size(hr_cq, udata, &ucmd); 370 + if (ret) 371 + return ret; 381 372 382 373 ret = alloc_cq_buf(hr_dev, hr_cq, udata, ucmd.buf_addr); 383 374 if (ret) {
+7 -6
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
··· 3299 3299 dest = get_cqe_v2(hr_cq, (prod_index + nfreed) & 3300 3300 hr_cq->ib_cq.cqe); 3301 3301 owner_bit = hr_reg_read(dest, CQE_OWNER); 3302 - memcpy(dest, cqe, sizeof(*cqe)); 3302 + memcpy(dest, cqe, hr_cq->cqe_size); 3303 3303 hr_reg_write(dest, CQE_OWNER, owner_bit); 3304 3304 } 3305 3305 } ··· 4397 4397 hr_qp->path_mtu = ib_mtu; 4398 4398 4399 4399 mtu = ib_mtu_enum_to_int(ib_mtu); 4400 - if (WARN_ON(mtu < 0)) 4400 + if (WARN_ON(mtu <= 0)) 4401 + return -EINVAL; 4402 + #define MAX_LP_MSG_LEN 65536 4403 + /* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 64KB */ 4404 + lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / mtu); 4405 + if (WARN_ON(lp_pktn_ini >= 0xF)) 4401 4406 return -EINVAL; 4402 4407 4403 4408 if (attr_mask & IB_QP_PATH_MTU) { 4404 4409 hr_reg_write(context, QPC_MTU, ib_mtu); 4405 4410 hr_reg_clear(qpc_mask, QPC_MTU); 4406 4411 } 4407 - 4408 - #define MAX_LP_MSG_LEN 65536 4409 - /* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 64KB */ 4410 - lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / mtu); 4411 4412 4412 4413 hr_reg_write(context, QPC_LP_PKTN_INI, lp_pktn_ini); 4413 4414 hr_reg_clear(qpc_mask, QPC_LP_PKTN_INI);
+2 -2
drivers/infiniband/hw/irdma/cm.c
··· 3496 3496 original_hw_tcp_state == IRDMA_TCP_STATE_TIME_WAIT || 3497 3497 last_ae == IRDMA_AE_RDMAP_ROE_BAD_LLP_CLOSE || 3498 3498 last_ae == IRDMA_AE_BAD_CLOSE || 3499 - last_ae == IRDMA_AE_LLP_CONNECTION_RESET || iwdev->reset)) { 3499 + last_ae == IRDMA_AE_LLP_CONNECTION_RESET || iwdev->rf->reset)) { 3500 3500 issue_close = 1; 3501 3501 iwqp->cm_id = NULL; 3502 3502 qp->term_flags = 0; ··· 4250 4250 teardown_entry); 4251 4251 attr.qp_state = IB_QPS_ERR; 4252 4252 irdma_modify_qp(&cm_node->iwqp->ibqp, &attr, IB_QP_STATE, NULL); 4253 - if (iwdev->reset) 4253 + if (iwdev->rf->reset) 4254 4254 irdma_cm_disconn(cm_node->iwqp); 4255 4255 irdma_rem_ref_cm_node(cm_node); 4256 4256 }
+11 -3
drivers/infiniband/hw/irdma/hw.c
··· 176 176 case IRDMA_AE_LLP_RECEIVED_MPA_CRC_ERROR: 177 177 qp->flush_code = FLUSH_GENERAL_ERR; 178 178 break; 179 + case IRDMA_AE_LLP_TOO_MANY_RETRIES: 180 + qp->flush_code = FLUSH_RETRY_EXC_ERR; 181 + break; 182 + case IRDMA_AE_AMP_MWBIND_INVALID_RIGHTS: 183 + case IRDMA_AE_AMP_MWBIND_BIND_DISABLED: 184 + case IRDMA_AE_AMP_MWBIND_INVALID_BOUNDS: 185 + qp->flush_code = FLUSH_MW_BIND_ERR; 186 + break; 179 187 default: 180 188 qp->flush_code = FLUSH_FATAL_ERR; 181 189 break; ··· 1497 1489 1498 1490 irdma_puda_dele_rsrc(vsi, IRDMA_PUDA_RSRC_TYPE_IEQ, false); 1499 1491 if (irdma_initialize_ieq(iwdev)) { 1500 - iwdev->reset = true; 1492 + iwdev->rf->reset = true; 1501 1493 rf->gen_ops.request_reset(rf); 1502 1494 } 1503 1495 } ··· 1640 1632 case IEQ_CREATED: 1641 1633 if (!iwdev->roce_mode) 1642 1634 irdma_puda_dele_rsrc(&iwdev->vsi, IRDMA_PUDA_RSRC_TYPE_IEQ, 1643 - iwdev->reset); 1635 + iwdev->rf->reset); 1644 1636 fallthrough; 1645 1637 case ILQ_CREATED: 1646 1638 if (!iwdev->roce_mode) 1647 1639 irdma_puda_dele_rsrc(&iwdev->vsi, 1648 1640 IRDMA_PUDA_RSRC_TYPE_ILQ, 1649 - iwdev->reset); 1641 + iwdev->rf->reset); 1650 1642 break; 1651 1643 default: 1652 1644 ibdev_warn(&iwdev->ibdev, "bad init_state = %d\n", iwdev->init_state);
+1 -1
drivers/infiniband/hw/irdma/i40iw_if.c
··· 55 55 56 56 iwdev = to_iwdev(ibdev); 57 57 if (reset) 58 - iwdev->reset = true; 58 + iwdev->rf->reset = true; 59 59 60 60 iwdev->iw_status = 0; 61 61 irdma_port_ibevent(iwdev);
-1
drivers/infiniband/hw/irdma/main.h
··· 346 346 bool roce_mode:1; 347 347 bool roce_dcqcn_en:1; 348 348 bool dcb:1; 349 - bool reset:1; 350 349 bool iw_ooo:1; 351 350 enum init_completion_state init_state; 352 351
+2
drivers/infiniband/hw/irdma/user.h
··· 102 102 FLUSH_REM_OP_ERR, 103 103 FLUSH_LOC_LEN_ERR, 104 104 FLUSH_FATAL_ERR, 105 + FLUSH_RETRY_EXC_ERR, 106 + FLUSH_MW_BIND_ERR, 105 107 }; 106 108 107 109 enum irdma_cmpl_status {
+1 -1
drivers/infiniband/hw/irdma/utils.c
··· 2507 2507 struct irdma_qp *qp = sc_qp->qp_uk.back_qp; 2508 2508 struct ib_qp_attr attr; 2509 2509 2510 - if (qp->iwdev->reset) 2510 + if (qp->iwdev->rf->reset) 2511 2511 return; 2512 2512 attr.qp_state = IB_QPS_ERR; 2513 2513
+6 -3
drivers/infiniband/hw/irdma/verbs.c
··· 535 535 irdma_qp_rem_ref(&iwqp->ibqp); 536 536 wait_for_completion(&iwqp->free_qp); 537 537 irdma_free_lsmm_rsrc(iwqp); 538 - if (!iwdev->reset) 539 - irdma_cqp_qp_destroy_cmd(&iwdev->rf->sc_dev, &iwqp->sc_qp); 538 + irdma_cqp_qp_destroy_cmd(&iwdev->rf->sc_dev, &iwqp->sc_qp); 540 539 541 540 if (!iwqp->user_mode) { 542 541 if (iwqp->iwscq) { ··· 2034 2035 /* Kmode allocations */ 2035 2036 int rsize; 2036 2037 2037 - if (entries > rf->max_cqe) { 2038 + if (entries < 1 || entries > rf->max_cqe) { 2038 2039 err_code = -EINVAL; 2039 2040 goto cq_free_rsrc; 2040 2041 } ··· 3352 3353 return IB_WC_LOC_LEN_ERR; 3353 3354 case FLUSH_GENERAL_ERR: 3354 3355 return IB_WC_WR_FLUSH_ERR; 3356 + case FLUSH_RETRY_EXC_ERR: 3357 + return IB_WC_RETRY_EXC_ERR; 3358 + case FLUSH_MW_BIND_ERR: 3359 + return IB_WC_MW_BIND_ERR; 3355 3360 case FLUSH_FATAL_ERR: 3356 3361 default: 3357 3362 return IB_WC_FATAL_ERR;
+1 -1
drivers/infiniband/hw/qib/qib_sysfs.c
··· 403 403 } 404 404 405 405 #define QIB_DIAGC_ATTR(N) \ 406 - static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL); \ 406 + static_assert(__same_type(((struct qib_ibport *)0)->rvp.n_##N, u64)); \ 407 407 static struct qib_diagc_attr qib_diagc_attr_##N = { \ 408 408 .attr = __ATTR(N, 0664, diagc_attr_show, diagc_attr_store), \ 409 409 .counter = \
+1 -1
drivers/infiniband/hw/usnic/usnic_ib.h
··· 90 90 91 91 struct usnic_ib_vf { 92 92 struct usnic_ib_dev *pf; 93 - spinlock_t lock; 93 + struct mutex lock; 94 94 struct usnic_vnic *vnic; 95 95 unsigned int qp_grp_ref_cnt; 96 96 struct usnic_ib_pd *pd;
+1 -1
drivers/infiniband/hw/usnic/usnic_ib_main.c
··· 572 572 } 573 573 574 574 vf->pf = pf; 575 - spin_lock_init(&vf->lock); 575 + mutex_init(&vf->lock); 576 576 mutex_lock(&pf->usdev_lock); 577 577 list_add_tail(&vf->link, &pf->vf_dev_list); 578 578 /*
+8 -8
drivers/infiniband/hw/usnic/usnic_ib_verbs.c
··· 196 196 for (i = 0; dev_list[i]; i++) { 197 197 dev = dev_list[i]; 198 198 vf = dev_get_drvdata(dev); 199 - spin_lock(&vf->lock); 199 + mutex_lock(&vf->lock); 200 200 vnic = vf->vnic; 201 201 if (!usnic_vnic_check_room(vnic, res_spec)) { 202 202 usnic_dbg("Found used vnic %s from %s\n", ··· 208 208 vf, pd, res_spec, 209 209 trans_spec); 210 210 211 - spin_unlock(&vf->lock); 211 + mutex_unlock(&vf->lock); 212 212 goto qp_grp_check; 213 213 } 214 - spin_unlock(&vf->lock); 214 + mutex_unlock(&vf->lock); 215 215 216 216 } 217 217 usnic_uiom_free_dev_list(dev_list); ··· 220 220 221 221 /* Try to find resources on an unused vf */ 222 222 list_for_each_entry(vf, &us_ibdev->vf_dev_list, link) { 223 - spin_lock(&vf->lock); 223 + mutex_lock(&vf->lock); 224 224 vnic = vf->vnic; 225 225 if (vf->qp_grp_ref_cnt == 0 && 226 226 usnic_vnic_check_room(vnic, res_spec) == 0) { ··· 228 228 vf, pd, res_spec, 229 229 trans_spec); 230 230 231 - spin_unlock(&vf->lock); 231 + mutex_unlock(&vf->lock); 232 232 goto qp_grp_check; 233 233 } 234 - spin_unlock(&vf->lock); 234 + mutex_unlock(&vf->lock); 235 235 } 236 236 237 237 usnic_info("No free qp grp found on %s\n", ··· 253 253 254 254 WARN_ON(qp_grp->state != IB_QPS_RESET); 255 255 256 - spin_lock(&vf->lock); 256 + mutex_lock(&vf->lock); 257 257 usnic_ib_qp_grp_destroy(qp_grp); 258 - spin_unlock(&vf->lock); 258 + mutex_unlock(&vf->lock); 259 259 } 260 260 261 261 static int create_qp_validate_user_data(struct usnic_ib_create_qp_cmd cmd)
+19 -6
drivers/interconnect/qcom/sdm660.c
··· 44 44 #define NOC_PERM_MODE_BYPASS (1 << NOC_QOS_MODE_BYPASS) 45 45 46 46 #define NOC_QOS_PRIORITYn_ADDR(n) (0x8 + (n * 0x1000)) 47 - #define NOC_QOS_PRIORITY_MASK 0xf 47 + #define NOC_QOS_PRIORITY_P1_MASK 0xc 48 + #define NOC_QOS_PRIORITY_P0_MASK 0x3 48 49 #define NOC_QOS_PRIORITY_P1_SHIFT 0x2 49 - #define NOC_QOS_PRIORITY_P0_SHIFT 0x3 50 50 51 51 #define NOC_QOS_MODEn_ADDR(n) (0xc + (n * 0x1000)) 52 52 #define NOC_QOS_MODEn_MASK 0x3 ··· 171 171 { .id = "bus" }, 172 172 { .id = "bus_a" }, 173 173 { .id = "iface" }, 174 + }; 175 + 176 + static const struct clk_bulk_data bus_a2noc_clocks[] = { 177 + { .id = "bus" }, 178 + { .id = "bus_a" }, 179 + { .id = "ipa" }, 180 + { .id = "ufs_axi" }, 181 + { .id = "aggre2_ufs_axi" }, 182 + { .id = "aggre2_usb3_axi" }, 183 + { .id = "cfg_noc_usb2_axi" }, 174 184 }; 175 185 176 186 /** ··· 317 307 DEFINE_QNODE(slv_prng, SDM660_SLAVE_PRNG, 4, -1, 44, true, -1, 0, -1, 0); 318 308 DEFINE_QNODE(slv_spdm, SDM660_SLAVE_SPDM, 4, -1, 60, true, -1, 0, -1, 0); 319 309 DEFINE_QNODE(slv_qdss_cfg, SDM660_SLAVE_QDSS_CFG, 4, -1, 63, true, -1, 0, -1, 0); 320 - DEFINE_QNODE(slv_cnoc_mnoc_cfg, SDM660_SLAVE_BLSP_1, 4, -1, 66, true, -1, 0, -1, SDM660_MASTER_CNOC_MNOC_CFG); 310 + DEFINE_QNODE(slv_cnoc_mnoc_cfg, SDM660_SLAVE_CNOC_MNOC_CFG, 4, -1, 66, true, -1, 0, -1, SDM660_MASTER_CNOC_MNOC_CFG); 321 311 DEFINE_QNODE(slv_snoc_cfg, SDM660_SLAVE_SNOC_CFG, 4, -1, 70, true, -1, 0, -1, 0); 322 312 DEFINE_QNODE(slv_qm_cfg, SDM660_SLAVE_QM_CFG, 4, -1, 212, true, -1, 0, -1, 0); 323 313 DEFINE_QNODE(slv_clk_ctl, SDM660_SLAVE_CLK_CTL, 4, -1, 47, true, -1, 0, -1, 0); ··· 634 624 /* Must be updated one at a time, P1 first, P0 last */ 635 625 val = qos->areq_prio << NOC_QOS_PRIORITY_P1_SHIFT; 636 626 rc = regmap_update_bits(rmap, NOC_QOS_PRIORITYn_ADDR(qos->qos_port), 637 - NOC_QOS_PRIORITY_MASK, val); 627 + NOC_QOS_PRIORITY_P1_MASK, val); 638 628 if (rc) 639 629 return rc; 640 630 641 - val = qos->prio_level << NOC_QOS_PRIORITY_P0_SHIFT; 642 631 return regmap_update_bits(rmap, NOC_QOS_PRIORITYn_ADDR(qos->qos_port), 643 - NOC_QOS_PRIORITY_MASK, val); 632 + NOC_QOS_PRIORITY_P0_MASK, qos->prio_level); 644 633 } 645 634 646 635 static int qcom_icc_set_noc_qos(struct icc_node *src, u64 max_bw) ··· 819 810 qp->bus_clks = devm_kmemdup(dev, bus_mm_clocks, 820 811 sizeof(bus_mm_clocks), GFP_KERNEL); 821 812 qp->num_clks = ARRAY_SIZE(bus_mm_clocks); 813 + } else if (of_device_is_compatible(dev->of_node, "qcom,sdm660-a2noc")) { 814 + qp->bus_clks = devm_kmemdup(dev, bus_a2noc_clocks, 815 + sizeof(bus_a2noc_clocks), GFP_KERNEL); 816 + qp->num_clks = ARRAY_SIZE(bus_a2noc_clocks); 822 817 } else { 823 818 if (of_device_is_compatible(dev->of_node, "qcom,sdm660-bimc")) 824 819 qp->is_bimc_node = true;
+35 -21
drivers/iommu/apple-dart.c
··· 183 183 184 184 static struct platform_driver apple_dart_driver; 185 185 static const struct iommu_ops apple_dart_iommu_ops; 186 - static const struct iommu_flush_ops apple_dart_tlb_ops; 187 186 188 187 static struct apple_dart_domain *to_dart_domain(struct iommu_domain *dom) 189 188 { ··· 337 338 apple_dart_domain_flush_tlb(to_dart_domain(domain)); 338 339 } 339 340 340 - static void apple_dart_tlb_flush_all(void *cookie) 341 - { 342 - apple_dart_domain_flush_tlb(cookie); 343 - } 344 - 345 - static void apple_dart_tlb_flush_walk(unsigned long iova, size_t size, 346 - size_t granule, void *cookie) 347 - { 348 - apple_dart_domain_flush_tlb(cookie); 349 - } 350 - 351 - static const struct iommu_flush_ops apple_dart_tlb_ops = { 352 - .tlb_flush_all = apple_dart_tlb_flush_all, 353 - .tlb_flush_walk = apple_dart_tlb_flush_walk, 354 - }; 355 - 356 341 static phys_addr_t apple_dart_iova_to_phys(struct iommu_domain *domain, 357 342 dma_addr_t iova) 358 343 { ··· 418 435 .ias = 32, 419 436 .oas = 36, 420 437 .coherent_walk = 1, 421 - .tlb = &apple_dart_tlb_ops, 422 438 .iommu_dev = dart->dev, 423 439 }; 424 440 ··· 643 661 return -EINVAL; 644 662 } 645 663 664 + static DEFINE_MUTEX(apple_dart_groups_lock); 665 + 666 + static void apple_dart_release_group(void *iommu_data) 667 + { 668 + int i, sid; 669 + struct apple_dart_stream_map *stream_map; 670 + struct apple_dart_master_cfg *group_master_cfg = iommu_data; 671 + 672 + mutex_lock(&apple_dart_groups_lock); 673 + 674 + for_each_stream_map(i, group_master_cfg, stream_map) 675 + for_each_set_bit(sid, &stream_map->sidmap, DART_MAX_STREAMS) 676 + stream_map->dart->sid2group[sid] = NULL; 677 + 678 + kfree(iommu_data); 679 + mutex_unlock(&apple_dart_groups_lock); 680 + } 681 + 646 682 static struct iommu_group *apple_dart_device_group(struct device *dev) 647 683 { 648 - static DEFINE_MUTEX(lock); 649 684 int i, sid; 650 685 struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); 651 686 struct apple_dart_stream_map *stream_map; 687 + struct apple_dart_master_cfg *group_master_cfg; 652 688 struct iommu_group *group = NULL; 653 689 struct iommu_group *res = ERR_PTR(-EINVAL); 654 690 655 - mutex_lock(&lock); 691 + mutex_lock(&apple_dart_groups_lock); 656 692 657 693 for_each_stream_map(i, cfg, stream_map) { 658 694 for_each_set_bit(sid, &stream_map->sidmap, DART_MAX_STREAMS) { ··· 698 698 #endif 699 699 group = generic_device_group(dev); 700 700 701 + res = ERR_PTR(-ENOMEM); 702 + if (!group) 703 + goto out; 704 + 705 + group_master_cfg = kzalloc(sizeof(*group_master_cfg), GFP_KERNEL); 706 + if (!group_master_cfg) { 707 + iommu_group_put(group); 708 + goto out; 709 + } 710 + 711 + memcpy(group_master_cfg, cfg, sizeof(*group_master_cfg)); 712 + iommu_group_set_iommudata(group, group_master_cfg, 713 + apple_dart_release_group); 714 + 701 715 for_each_stream_map(i, cfg, stream_map) 702 716 for_each_set_bit(sid, &stream_map->sidmap, DART_MAX_STREAMS) 703 717 stream_map->dart->sid2group[sid] = group; ··· 719 705 res = group; 720 706 721 707 out: 722 - mutex_unlock(&lock); 708 + mutex_unlock(&apple_dart_groups_lock); 723 709 return res; 724 710 } 725 711
+3 -3
drivers/iommu/intel/dmar.c
··· 1942 1942 reason = dmar_get_fault_reason(fault_reason, &fault_type); 1943 1943 1944 1944 if (fault_type == INTR_REMAP) 1945 - pr_err("[INTR-REMAP] Request device [0x%02x:0x%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n", 1945 + pr_err("[INTR-REMAP] Request device [%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n", 1946 1946 source_id >> 8, PCI_SLOT(source_id & 0xFF), 1947 1947 PCI_FUNC(source_id & 0xFF), addr >> 48, 1948 1948 fault_reason, reason); 1949 1949 else if (pasid == INVALID_IOASID) 1950 - pr_err("[%s NO_PASID] Request device [0x%02x:0x%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n", 1950 + pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n", 1951 1951 type ? "DMA Read" : "DMA Write", 1952 1952 source_id >> 8, PCI_SLOT(source_id & 0xFF), 1953 1953 PCI_FUNC(source_id & 0xFF), addr, 1954 1954 fault_reason, reason); 1955 1955 else 1956 - pr_err("[%s PASID 0x%x] Request device [0x%02x:0x%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n", 1956 + pr_err("[%s PASID 0x%x] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n", 1957 1957 type ? "DMA Read" : "DMA Write", pasid, 1958 1958 source_id >> 8, PCI_SLOT(source_id & 0xFF), 1959 1959 PCI_FUNC(source_id & 0xFF), addr,
+47 -16
drivers/ipack/devices/ipoctal.c
··· 33 33 unsigned int pointer_read; 34 34 unsigned int pointer_write; 35 35 struct tty_port tty_port; 36 + bool tty_registered; 36 37 union scc2698_channel __iomem *regs; 37 38 union scc2698_block __iomem *block_regs; 38 39 unsigned int board_id; ··· 82 81 return 0; 83 82 } 84 83 85 - static int ipoctal_open(struct tty_struct *tty, struct file *file) 84 + static int ipoctal_install(struct tty_driver *driver, struct tty_struct *tty) 86 85 { 87 86 struct ipoctal_channel *channel = dev_get_drvdata(tty->dev); 88 87 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index); 89 - int err; 90 - 91 - tty->driver_data = channel; 88 + int res; 92 89 93 90 if (!ipack_get_carrier(ipoctal->dev)) 94 91 return -EBUSY; 95 92 96 - err = tty_port_open(&channel->tty_port, tty, file); 97 - if (err) 98 - ipack_put_carrier(ipoctal->dev); 93 + res = tty_standard_install(driver, tty); 94 + if (res) 95 + goto err_put_carrier; 99 96 100 - return err; 97 + tty->driver_data = channel; 98 + 99 + return 0; 100 + 101 + err_put_carrier: 102 + ipack_put_carrier(ipoctal->dev); 103 + 104 + return res; 105 + } 106 + 107 + static int ipoctal_open(struct tty_struct *tty, struct file *file) 108 + { 109 + struct ipoctal_channel *channel = tty->driver_data; 110 + 111 + return tty_port_open(&channel->tty_port, tty, file); 101 112 } 102 113 103 114 static void ipoctal_reset_stats(struct ipoctal_stats *stats) ··· 277 264 int res; 278 265 int i; 279 266 struct tty_driver *tty; 280 - char name[20]; 281 267 struct ipoctal_channel *channel; 282 268 struct ipack_region *region; 283 269 void __iomem *addr; ··· 367 355 /* Fill struct tty_driver with ipoctal data */ 368 356 tty->owner = THIS_MODULE; 369 357 tty->driver_name = KBUILD_MODNAME; 370 - sprintf(name, KBUILD_MODNAME ".%d.%d.", bus_nr, slot); 371 - tty->name = name; 358 + tty->name = kasprintf(GFP_KERNEL, KBUILD_MODNAME ".%d.%d.", bus_nr, slot); 359 + if (!tty->name) { 360 + res = -ENOMEM; 361 + goto err_put_driver; 362 + } 372 363 tty->major = 0; 373 364 374 365 tty->minor_start = 0; ··· 386 371 res = tty_register_driver(tty); 387 372 if (res) { 388 373 dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n"); 389 - tty_driver_kref_put(tty); 390 - return res; 374 + goto err_free_name; 391 375 } 392 376 393 377 /* Save struct tty_driver for use it when uninstalling the device */ ··· 397 383 398 384 channel = &ipoctal->channel[i]; 399 385 tty_port_init(&channel->tty_port); 400 - tty_port_alloc_xmit_buf(&channel->tty_port); 386 + res = tty_port_alloc_xmit_buf(&channel->tty_port); 387 + if (res) 388 + continue; 401 389 channel->tty_port.ops = &ipoctal_tty_port_ops; 402 390 403 391 ipoctal_reset_stats(&channel->stats); ··· 407 391 spin_lock_init(&channel->lock); 408 392 channel->pointer_read = 0; 409 393 channel->pointer_write = 0; 410 - tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL); 394 + tty_dev = tty_port_register_device_attr(&channel->tty_port, tty, 395 + i, NULL, channel, NULL); 411 396 if (IS_ERR(tty_dev)) { 412 397 dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n"); 398 + tty_port_free_xmit_buf(&channel->tty_port); 413 399 tty_port_destroy(&channel->tty_port); 414 400 continue; 415 401 } 416 - dev_set_drvdata(tty_dev, channel); 402 + channel->tty_registered = true; 417 403 } 418 404 419 405 /* ··· 427 409 ipoctal_irq_handler, ipoctal); 428 410 429 411 return 0; 412 + 413 + err_free_name: 414 + kfree(tty->name); 415 + err_put_driver: 416 + tty_driver_kref_put(tty); 417 + 418 + return res; 430 419 } 431 420 432 421 static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel, ··· 673 648 674 649 static const struct tty_operations ipoctal_fops = { 675 650 .ioctl = NULL, 651 + .install = ipoctal_install, 676 652 .open = ipoctal_open, 677 653 .close = ipoctal_close, 678 654 .write = ipoctal_write_tty, ··· 716 690 717 691 for (i = 0; i < NR_CHANNELS; i++) { 718 692 struct ipoctal_channel *channel = &ipoctal->channel[i]; 693 + 694 + if (!channel->tty_registered) 695 + continue; 696 + 719 697 tty_unregister_device(ipoctal->tty_drv, i); 720 698 tty_port_free_xmit_buf(&channel->tty_port); 721 699 tty_port_destroy(&channel->tty_port); 722 700 } 723 701 724 702 tty_unregister_driver(ipoctal->tty_drv); 703 + kfree(ipoctal->tty_drv->name); 725 704 tty_driver_kref_put(ipoctal->tty_drv); 726 705 kfree(ipoctal); 727 706 }
+9 -9
drivers/media/platform/s5p-jpeg/jpeg-core.c
··· 1140 1140 continue; 1141 1141 length = 0; 1142 1142 switch (c) { 1143 - /* SOF0: baseline JPEG */ 1144 - case SOF0: 1143 + /* JPEG_MARKER_SOF0: baseline JPEG */ 1144 + case JPEG_MARKER_SOF0: 1145 1145 if (get_word_be(&jpeg_buffer, &word)) 1146 1146 break; 1147 1147 length = (long)word - 2; ··· 1172 1172 notfound = 0; 1173 1173 break; 1174 1174 1175 - case DQT: 1175 + case JPEG_MARKER_DQT: 1176 1176 if (get_word_be(&jpeg_buffer, &word)) 1177 1177 break; 1178 1178 length = (long)word - 2; ··· 1185 1185 skip(&jpeg_buffer, length); 1186 1186 break; 1187 1187 1188 - case DHT: 1188 + case JPEG_MARKER_DHT: 1189 1189 if (get_word_be(&jpeg_buffer, &word)) 1190 1190 break; 1191 1191 length = (long)word - 2; ··· 1198 1198 skip(&jpeg_buffer, length); 1199 1199 break; 1200 1200 1201 - case SOS: 1201 + case JPEG_MARKER_SOS: 1202 1202 sos = jpeg_buffer.curr - 2; /* 0xffda */ 1203 1203 break; 1204 1204 1205 1205 /* skip payload-less markers */ 1206 - case RST ... RST + 7: 1207 - case SOI: 1208 - case EOI: 1209 - case TEM: 1206 + case JPEG_MARKER_RST ... JPEG_MARKER_RST + 7: 1207 + case JPEG_MARKER_SOI: 1208 + case JPEG_MARKER_EOI: 1209 + case JPEG_MARKER_TEM: 1210 1210 break; 1211 1211 1212 1212 /* skip uninteresting payload markers */
+14 -14
drivers/media/platform/s5p-jpeg/jpeg-core.h
··· 37 37 #define EXYNOS3250_IRQ_TIMEOUT 0x10000000 38 38 39 39 /* a selection of JPEG markers */ 40 - #define TEM 0x01 41 - #define SOF0 0xc0 42 - #define DHT 0xc4 43 - #define RST 0xd0 44 - #define SOI 0xd8 45 - #define EOI 0xd9 46 - #define SOS 0xda 47 - #define DQT 0xdb 48 - #define DHP 0xde 40 + #define JPEG_MARKER_TEM 0x01 41 + #define JPEG_MARKER_SOF0 0xc0 42 + #define JPEG_MARKER_DHT 0xc4 43 + #define JPEG_MARKER_RST 0xd0 44 + #define JPEG_MARKER_SOI 0xd8 45 + #define JPEG_MARKER_EOI 0xd9 46 + #define JPEG_MARKER_SOS 0xda 47 + #define JPEG_MARKER_DQT 0xdb 48 + #define JPEG_MARKER_DHP 0xde 49 49 50 50 /* Flags that indicate a format can be used for capture/output */ 51 51 #define SJPEG_FMT_FLAG_ENC_CAPTURE (1 << 0) ··· 187 187 * @fmt: driver-specific format of this queue 188 188 * @w: image width 189 189 * @h: image height 190 - * @sos: SOS marker's position relative to the buffer beginning 191 - * @dht: DHT markers' positions relative to the buffer beginning 192 - * @dqt: DQT markers' positions relative to the buffer beginning 193 - * @sof: SOF0 marker's position relative to the buffer beginning 194 - * @sof_len: SOF0 marker's payload length (without length field itself) 190 + * @sos: JPEG_MARKER_SOS's position relative to the buffer beginning 191 + * @dht: JPEG_MARKER_DHT' positions relative to the buffer beginning 192 + * @dqt: JPEG_MARKER_DQT' positions relative to the buffer beginning 193 + * @sof: JPEG_MARKER_SOF0's position relative to the buffer beginning 194 + * @sof_len: JPEG_MARKER_SOF0's payload length (without length field itself) 195 195 * @size: image buffer size in bytes 196 196 */ 197 197 struct s5p_jpeg_q_data {
+20 -1
drivers/media/rc/ir_toy.c
··· 24 24 // End transmit and repeat reset command so we exit sump mode 25 25 static const u8 COMMAND_RESET[] = { 0xff, 0xff, 0, 0, 0, 0, 0 }; 26 26 static const u8 COMMAND_SMODE_ENTER[] = { 's' }; 27 + static const u8 COMMAND_SMODE_EXIT[] = { 0 }; 27 28 static const u8 COMMAND_TXSTART[] = { 0x26, 0x24, 0x25, 0x03 }; 28 29 29 30 #define REPLY_XMITCOUNT 't' ··· 310 309 buf[i] = cpu_to_be16(v); 311 310 } 312 311 313 - buf[count] = cpu_to_be16(0xffff); 312 + buf[count] = 0xffff; 314 313 315 314 irtoy->tx_buf = buf; 316 315 irtoy->tx_len = size; 317 316 irtoy->emitted = 0; 317 + 318 + // There is an issue where if the unit is receiving IR while the 319 + // first TXSTART command is sent, the device might end up hanging 320 + // with its led on. It does not respond to any command when this 321 + // happens. To work around this, re-enter sample mode. 322 + err = irtoy_command(irtoy, COMMAND_SMODE_EXIT, 323 + sizeof(COMMAND_SMODE_EXIT), STATE_RESET); 324 + if (err) { 325 + dev_err(irtoy->dev, "exit sample mode: %d\n", err); 326 + return err; 327 + } 328 + 329 + err = irtoy_command(irtoy, COMMAND_SMODE_ENTER, 330 + sizeof(COMMAND_SMODE_ENTER), STATE_COMMAND); 331 + if (err) { 332 + dev_err(irtoy->dev, "enter sample mode: %d\n", err); 333 + return err; 334 + } 318 335 319 336 err = irtoy_command(irtoy, COMMAND_TXSTART, sizeof(COMMAND_TXSTART), 320 337 STATE_TX);
+12 -3
drivers/mmc/host/dw_mmc.c
··· 1802 1802 1803 1803 spin_lock_irqsave(&host->irq_lock, flags); 1804 1804 1805 - if (!host->data_status) 1805 + /* 1806 + * Only inject an error if we haven't already got an error or data over 1807 + * interrupt. 1808 + */ 1809 + if (!host->data_status) { 1806 1810 host->data_status = SDMMC_INT_DCRC; 1807 - set_bit(EVENT_DATA_ERROR, &host->pending_events); 1808 - tasklet_schedule(&host->tasklet); 1811 + set_bit(EVENT_DATA_ERROR, &host->pending_events); 1812 + tasklet_schedule(&host->tasklet); 1813 + } 1809 1814 1810 1815 spin_unlock_irqrestore(&host->irq_lock, flags); 1811 1816 ··· 2726 2721 } 2727 2722 2728 2723 if (pending & DW_MCI_DATA_ERROR_FLAGS) { 2724 + spin_lock(&host->irq_lock); 2725 + 2729 2726 /* if there is an error report DATA_ERROR */ 2730 2727 mci_writel(host, RINTSTS, DW_MCI_DATA_ERROR_FLAGS); 2731 2728 host->data_status = pending; 2732 2729 smp_wmb(); /* drain writebuffer */ 2733 2730 set_bit(EVENT_DATA_ERROR, &host->pending_events); 2734 2731 tasklet_schedule(&host->tasklet); 2732 + 2733 + spin_unlock(&host->irq_lock); 2735 2734 } 2736 2735 2737 2736 if (pending & SDMMC_INT_DATA_OVER) {
+2
drivers/mmc/host/renesas_sdhi_core.c
··· 561 561 /* Unknown why but without polling reset status, it will hang */ 562 562 read_poll_timeout(reset_control_status, ret, ret == 0, 1, 100, 563 563 false, priv->rstc); 564 + /* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */ 565 + sd_ctrl_write16(host, CTL_RESET_SD, 0x0001); 564 566 priv->needs_adjust_hs400 = false; 565 567 renesas_sdhi_set_clock(host, host->clk_cache); 566 568 } else if (priv->scc_ctl) {
+10 -7
drivers/net/dsa/mv88e6xxx/chip.c
··· 2834 2834 if (err) 2835 2835 return err; 2836 2836 2837 - /* Port Control 2: don't force a good FCS, set the maximum frame size to 2838 - * 10240 bytes, disable 802.1q tags checking, don't discard tagged or 2837 + /* Port Control 2: don't force a good FCS, set the MTU size to 2838 + * 10222 bytes, disable 802.1q tags checking, don't discard tagged or 2839 2839 * untagged frames on this port, do a destination address lookup on all 2840 2840 * received packets as usual, disable ARP mirroring and don't send a 2841 2841 * copy of all transmitted/received frames on this port to the CPU. ··· 2854 2854 return err; 2855 2855 2856 2856 if (chip->info->ops->port_set_jumbo_size) { 2857 - err = chip->info->ops->port_set_jumbo_size(chip, port, 10240); 2857 + err = chip->info->ops->port_set_jumbo_size(chip, port, 10218); 2858 2858 if (err) 2859 2859 return err; 2860 2860 } ··· 2944 2944 struct mv88e6xxx_chip *chip = ds->priv; 2945 2945 2946 2946 if (chip->info->ops->port_set_jumbo_size) 2947 - return 10240; 2947 + return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; 2948 2948 else if (chip->info->ops->set_max_frame_size) 2949 - return 1632; 2950 - return 1522; 2949 + return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; 2950 + return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; 2951 2951 } 2952 2952 2953 2953 static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu) 2954 2954 { 2955 2955 struct mv88e6xxx_chip *chip = ds->priv; 2956 2956 int ret = 0; 2957 + 2958 + if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) 2959 + new_mtu += EDSA_HLEN; 2957 2960 2958 2961 mv88e6xxx_reg_lock(chip); 2959 2962 if (chip->info->ops->port_set_jumbo_size) ··· 3728 3725 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, 3729 3726 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, 3730 3727 .port_set_ether_type = mv88e6351_port_set_ether_type, 3731 - .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, 3732 3728 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, 3733 3729 .port_pause_limit = mv88e6097_port_pause_limit, 3734 3730 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, ··· 3752 3750 .avb_ops = &mv88e6165_avb_ops, 3753 3751 .ptp_ops = &mv88e6165_ptp_ops, 3754 3752 .phylink_validate = mv88e6185_phylink_validate, 3753 + .set_max_frame_size = mv88e6185_g1_set_max_frame_size, 3755 3754 }; 3756 3755 3757 3756 static const struct mv88e6xxx_ops mv88e6165_ops = {
+1
drivers/net/dsa/mv88e6xxx/chip.h
··· 18 18 #include <linux/timecounter.h> 19 19 #include <net/dsa.h> 20 20 21 + #define EDSA_HLEN 8 21 22 #define MV88E6XXX_N_FID 4096 22 23 23 24 /* PVT limits for 4-bit port and 5-bit switch */
+2
drivers/net/dsa/mv88e6xxx/global1.c
··· 232 232 u16 val; 233 233 int err; 234 234 235 + mtu += ETH_HLEN + ETH_FCS_LEN; 236 + 235 237 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &val); 236 238 if (err) 237 239 return err;
+2
drivers/net/dsa/mv88e6xxx/port.c
··· 1277 1277 u16 reg; 1278 1278 int err; 1279 1279 1280 + size += VLAN_ETH_HLEN + ETH_FCS_LEN; 1281 + 1280 1282 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, &reg); 1281 1283 if (err) 1282 1284 return err;
+3
drivers/net/ethernet/broadcom/bgmac-platform.c
··· 192 192 bgmac->dma_dev = &pdev->dev; 193 193 194 194 ret = of_get_mac_address(np, bgmac->net_dev->dev_addr); 195 + if (ret == -EPROBE_DEFER) 196 + return ret; 197 + 195 198 if (ret) 196 199 dev_warn(&pdev->dev, 197 200 "MAC address not present in device tree\n");
+1 -2
drivers/net/ethernet/freescale/enetc/enetc_pf.c
··· 541 541 542 542 if (phy_interface_mode_is_rgmii(phy_mode)) { 543 543 val = enetc_port_rd(hw, ENETC_PM0_IF_MODE); 544 - val &= ~ENETC_PM0_IFM_EN_AUTO; 545 - val &= ENETC_PM0_IFM_IFMODE_MASK; 544 + val &= ~(ENETC_PM0_IFM_EN_AUTO | ENETC_PM0_IFM_IFMODE_MASK); 546 545 val |= ENETC_PM0_IFM_IFMODE_GMII | ENETC_PM0_IFM_RG; 547 546 enetc_port_wr(hw, ENETC_PM0_IF_MODE, val); 548 547 }
-1
drivers/net/ethernet/hisilicon/hns3/hnae3.h
··· 752 752 u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */ 753 753 u16 tqp_count[HNAE3_MAX_TC]; 754 754 u16 tqp_offset[HNAE3_MAX_TC]; 755 - unsigned long tc_en; /* bitmap of TC enabled */ 756 755 u8 num_tc; /* Total number of enabled TCs */ 757 756 bool mqprio_active; 758 757 };
+7 -9
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
··· 623 623 return ret; 624 624 } 625 625 626 - for (i = 0; i < HNAE3_MAX_TC; i++) { 627 - if (!test_bit(i, &tc_info->tc_en)) 628 - continue; 629 - 626 + for (i = 0; i < tc_info->num_tc; i++) 630 627 netdev_set_tc_queue(netdev, i, tc_info->tqp_count[i], 631 628 tc_info->tqp_offset[i]); 632 - } 633 629 } 634 630 635 631 ret = netif_set_real_num_tx_queues(netdev, queue_size); ··· 774 778 775 779 if (hns3_nic_resetting(netdev)) 776 780 return -EBUSY; 781 + 782 + if (!test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) { 783 + netdev_warn(netdev, "net open repeatedly!\n"); 784 + return 0; 785 + } 777 786 778 787 netif_carrier_off(netdev); 779 788 ··· 4866 4865 struct hnae3_tc_info *tc_info = &kinfo->tc_info; 4867 4866 int i; 4868 4867 4869 - for (i = 0; i < HNAE3_MAX_TC; i++) { 4868 + for (i = 0; i < tc_info->num_tc; i++) { 4870 4869 int j; 4871 - 4872 - if (!test_bit(i, &tc_info->tc_en)) 4873 - continue; 4874 4870 4875 4871 for (j = 0; j < tc_info->tqp_count[i]; j++) { 4876 4872 struct hnae3_queue *q;
+4 -2
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
··· 334 334 335 335 #if IS_ENABLED(CONFIG_VLAN_8021Q) 336 336 /* Disable the vlan filter for selftest does not support it */ 337 - if (h->ae_algo->ops->enable_vlan_filter) 337 + if (h->ae_algo->ops->enable_vlan_filter && 338 + ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) 338 339 h->ae_algo->ops->enable_vlan_filter(h, false); 339 340 #endif 340 341 ··· 360 359 h->ae_algo->ops->halt_autoneg(h, false); 361 360 362 361 #if IS_ENABLED(CONFIG_VLAN_8021Q) 363 - if (h->ae_algo->ops->enable_vlan_filter) 362 + if (h->ae_algo->ops->enable_vlan_filter && 363 + ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) 364 364 h->ae_algo->ops->enable_vlan_filter(h, true); 365 365 #endif 366 366
+13 -8
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
··· 467 467 return ret; 468 468 } 469 469 470 - static int hclge_firmware_compat_config(struct hclge_dev *hdev) 470 + static int hclge_firmware_compat_config(struct hclge_dev *hdev, bool en) 471 471 { 472 472 struct hclge_firmware_compat_cmd *req; 473 473 struct hclge_desc desc; ··· 475 475 476 476 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_IMP_COMPAT_CFG, false); 477 477 478 - req = (struct hclge_firmware_compat_cmd *)desc.data; 478 + if (en) { 479 + req = (struct hclge_firmware_compat_cmd *)desc.data; 479 480 480 - hnae3_set_bit(compat, HCLGE_LINK_EVENT_REPORT_EN_B, 1); 481 - hnae3_set_bit(compat, HCLGE_NCSI_ERROR_REPORT_EN_B, 1); 482 - if (hnae3_dev_phy_imp_supported(hdev)) 483 - hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1); 484 - req->compat = cpu_to_le32(compat); 481 + hnae3_set_bit(compat, HCLGE_LINK_EVENT_REPORT_EN_B, 1); 482 + hnae3_set_bit(compat, HCLGE_NCSI_ERROR_REPORT_EN_B, 1); 483 + if (hnae3_dev_phy_imp_supported(hdev)) 484 + hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1); 485 + 486 + req->compat = cpu_to_le32(compat); 487 + } 485 488 486 489 return hclge_cmd_send(&hdev->hw, &desc, 1); 487 490 } ··· 541 538 /* ask the firmware to enable some features, driver can work without 542 539 * it. 543 540 */ 544 - ret = hclge_firmware_compat_config(hdev); 541 + ret = hclge_firmware_compat_config(hdev, true); 545 542 if (ret) 546 543 dev_warn(&hdev->pdev->dev, 547 544 "Firmware compatible features not enabled(%d).\n", ··· 571 568 572 569 void hclge_cmd_uninit(struct hclge_dev *hdev) 573 570 { 571 + hclge_firmware_compat_config(hdev, false); 572 + 574 573 set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); 575 574 /* wait to ensure that the firmware completes the possible left 576 575 * over commands.
+16 -13
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
··· 247 247 } 248 248 249 249 hclge_tm_schd_info_update(hdev, num_tc); 250 + if (num_tc > 1) 251 + hdev->flag |= HCLGE_FLAG_DCB_ENABLE; 252 + else 253 + hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE; 250 254 251 255 ret = hclge_ieee_ets_to_tm_info(hdev, ets); 252 256 if (ret) ··· 310 306 u8 i, j, pfc_map, *prio_tc; 311 307 int ret; 312 308 313 - if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || 314 - hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE) 309 + if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE)) 315 310 return -EINVAL; 316 311 317 312 if (pfc->pfc_en == hdev->tm_info.pfc_en) ··· 444 441 static void hclge_sync_mqprio_qopt(struct hnae3_tc_info *tc_info, 445 442 struct tc_mqprio_qopt_offload *mqprio_qopt) 446 443 { 447 - int i; 448 - 449 444 memset(tc_info, 0, sizeof(*tc_info)); 450 445 tc_info->num_tc = mqprio_qopt->qopt.num_tc; 451 446 memcpy(tc_info->prio_tc, mqprio_qopt->qopt.prio_tc_map, ··· 452 451 sizeof_field(struct hnae3_tc_info, tqp_count)); 453 452 memcpy(tc_info->tqp_offset, mqprio_qopt->qopt.offset, 454 453 sizeof_field(struct hnae3_tc_info, tqp_offset)); 455 - 456 - for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) 457 - set_bit(tc_info->prio_tc[i], &tc_info->tc_en); 458 454 } 459 455 460 456 static int hclge_config_tc(struct hclge_dev *hdev, ··· 517 519 return hclge_notify_init_up(hdev); 518 520 519 521 err_out: 520 - /* roll-back */ 521 - memcpy(&kinfo->tc_info, &old_tc_info, sizeof(old_tc_info)); 522 - if (hclge_config_tc(hdev, &kinfo->tc_info)) 523 - dev_err(&hdev->pdev->dev, 524 - "failed to roll back tc configuration\n"); 525 - 522 + if (!tc) { 523 + dev_warn(&hdev->pdev->dev, 524 + "failed to destroy mqprio, will active after reset, ret = %d\n", 525 + ret); 526 + } else { 527 + /* roll-back */ 528 + memcpy(&kinfo->tc_info, &old_tc_info, sizeof(old_tc_info)); 529 + if (hclge_config_tc(hdev, &kinfo->tc_info)) 530 + dev_err(&hdev->pdev->dev, 531 + "failed to roll back tc configuration\n"); 532 + } 526 533 hclge_notify_init_up(hdev); 527 534 528 535 return ret;
+24 -4
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
··· 719 719 sprintf(result[(*index)++], "%6u", para->rate); 720 720 } 721 721 722 - static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len) 722 + static int __hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *data_str, 723 + char *buf, int len) 723 724 { 724 - char data_str[ARRAY_SIZE(tm_pg_items)][HCLGE_DBG_DATA_STR_LEN]; 725 725 struct hclge_tm_shaper_para c_shaper_para, p_shaper_para; 726 726 char *result[ARRAY_SIZE(tm_pg_items)], *sch_mode_str; 727 727 u8 pg_id, sch_mode, weight, pri_bit_map, i, j; ··· 729 729 int pos = 0; 730 730 int ret; 731 731 732 - for (i = 0; i < ARRAY_SIZE(tm_pg_items); i++) 733 - result[i] = &data_str[i][0]; 732 + for (i = 0; i < ARRAY_SIZE(tm_pg_items); i++) { 733 + result[i] = data_str; 734 + data_str += HCLGE_DBG_DATA_STR_LEN; 735 + } 734 736 735 737 hclge_dbg_fill_content(content, sizeof(content), tm_pg_items, 736 738 NULL, ARRAY_SIZE(tm_pg_items)); ··· 781 779 } 782 780 783 781 return 0; 782 + } 783 + 784 + static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len) 785 + { 786 + char *data_str; 787 + int ret; 788 + 789 + data_str = kcalloc(ARRAY_SIZE(tm_pg_items), 790 + HCLGE_DBG_DATA_STR_LEN, GFP_KERNEL); 791 + 792 + if (!data_str) 793 + return -ENOMEM; 794 + 795 + ret = __hclge_dbg_dump_tm_pg(hdev, data_str, buf, len); 796 + 797 + kfree(data_str); 798 + 799 + return ret; 784 800 } 785 801 786 802 static int hclge_dbg_dump_tm_port(struct hclge_dev *hdev, char *buf, int len)
+15 -12
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 8708 8708 } 8709 8709 8710 8710 /* check if we just hit the duplicate */ 8711 - if (!ret) { 8712 - dev_warn(&hdev->pdev->dev, "VF %u mac(%pM) exists\n", 8713 - vport->vport_id, addr); 8714 - return 0; 8715 - } 8716 - 8717 - dev_err(&hdev->pdev->dev, 8718 - "PF failed to add unicast entry(%pM) in the MAC table\n", 8719 - addr); 8711 + if (!ret) 8712 + return -EEXIST; 8720 8713 8721 8714 return ret; 8722 8715 } ··· 8861 8868 } else { 8862 8869 set_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE, 8863 8870 &vport->state); 8864 - break; 8871 + 8872 + /* If one unicast mac address is existing in hardware, 8873 + * we need to try whether other unicast mac addresses 8874 + * are new addresses that can be added. 8875 + */ 8876 + if (ret != -EEXIST) 8877 + break; 8865 8878 } 8866 8879 } 8867 8880 } ··· 12796 12797 continue; 12797 12798 12798 12799 if (vport->vf_info.trusted) { 12799 - uc_en = vport->vf_info.request_uc_en > 0; 12800 - mc_en = vport->vf_info.request_mc_en > 0; 12800 + uc_en = vport->vf_info.request_uc_en > 0 || 12801 + vport->overflow_promisc_flags & 12802 + HNAE3_OVERFLOW_UPE; 12803 + mc_en = vport->vf_info.request_mc_en > 0 || 12804 + vport->overflow_promisc_flags & 12805 + HNAE3_OVERFLOW_MPE; 12801 12806 } 12802 12807 bc_en = vport->vf_info.request_bc_en > 0; 12803 12808
+5 -28
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
··· 687 687 688 688 for (i = 0; i < HNAE3_MAX_TC; i++) { 689 689 if (hdev->hw_tc_map & BIT(i) && i < kinfo->tc_info.num_tc) { 690 - set_bit(i, &kinfo->tc_info.tc_en); 691 690 kinfo->tc_info.tqp_offset[i] = i * kinfo->rss_size; 692 691 kinfo->tc_info.tqp_count[i] = kinfo->rss_size; 693 692 } else { 694 693 /* Set to default queue if TC is disable */ 695 - clear_bit(i, &kinfo->tc_info.tc_en); 696 694 kinfo->tc_info.tqp_offset[i] = 0; 697 695 kinfo->tc_info.tqp_count[i] = 1; 698 696 } ··· 727 729 for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) 728 730 hdev->tm_info.prio_tc[i] = 729 731 (i >= hdev->tm_info.num_tc) ? 0 : i; 730 - 731 - /* DCB is enabled if we have more than 1 TC or pfc_en is 732 - * non-zero. 733 - */ 734 - if (hdev->tm_info.num_tc > 1 || hdev->tm_info.pfc_en) 735 - hdev->flag |= HCLGE_FLAG_DCB_ENABLE; 736 - else 737 - hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE; 738 732 } 739 733 740 734 static void hclge_tm_pg_info_init(struct hclge_dev *hdev) ··· 757 767 758 768 static void hclge_update_fc_mode_by_dcb_flag(struct hclge_dev *hdev) 759 769 { 760 - if (!(hdev->flag & HCLGE_FLAG_DCB_ENABLE)) { 770 + if (hdev->tm_info.num_tc == 1 && !hdev->tm_info.pfc_en) { 761 771 if (hdev->fc_mode_last_time == HCLGE_FC_PFC) 762 772 dev_warn(&hdev->pdev->dev, 763 - "DCB is disable, but last mode is FC_PFC\n"); 773 + "Only 1 tc used, but last mode is FC_PFC\n"); 764 774 765 775 hdev->tm_info.fc_mode = hdev->fc_mode_last_time; 766 776 } else if (hdev->tm_info.fc_mode != HCLGE_FC_PFC) { ··· 786 796 } 787 797 } 788 798 789 - static void hclge_pfc_info_init(struct hclge_dev *hdev) 799 + void hclge_tm_pfc_info_update(struct hclge_dev *hdev) 790 800 { 791 801 if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) 792 802 hclge_update_fc_mode(hdev); ··· 802 812 803 813 hclge_tm_vport_info_update(hdev); 804 814 805 - hclge_pfc_info_init(hdev); 815 + hclge_tm_pfc_info_update(hdev); 806 816 } 807 817 808 818 static int hclge_tm_pg_to_pri_map(struct hclge_dev *hdev) ··· 1548 1558 hclge_tm_schd_info_init(hdev); 1549 1559 } 1550 1560 1551 - void hclge_tm_pfc_info_update(struct hclge_dev *hdev) 1552 - { 1553 - /* DCB is enabled if we have more than 1 TC or pfc_en is 1554 - * non-zero. 1555 - */ 1556 - if (hdev->tm_info.num_tc > 1 || hdev->tm_info.pfc_en) 1557 - hdev->flag |= HCLGE_FLAG_DCB_ENABLE; 1558 - else 1559 - hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE; 1560 - 1561 - hclge_pfc_info_init(hdev); 1562 - } 1563 - 1564 1561 int hclge_tm_init_hw(struct hclge_dev *hdev, bool init) 1565 1562 { 1566 1563 int ret; ··· 1593 1616 if (ret) 1594 1617 return ret; 1595 1618 1596 - if (!(hdev->flag & HCLGE_FLAG_DCB_ENABLE)) 1619 + if (hdev->tm_info.num_tc == 1 && !hdev->tm_info.pfc_en) 1597 1620 return 0; 1598 1621 1599 1622 return hclge_tm_bp_setup(hdev);
+1 -1
drivers/net/ethernet/hisilicon/hns_mdio.c
··· 354 354 355 355 if (dev_of_node(bus->parent)) { 356 356 if (!mdio_dev->subctrl_vbase) { 357 - dev_err(&bus->dev, "mdio sys ctl reg has not maped\n"); 357 + dev_err(&bus->dev, "mdio sys ctl reg has not mapped\n"); 358 358 return -ENODEV; 359 359 } 360 360
-8
drivers/net/ethernet/ibm/ibmvnic.c
··· 4708 4708 return 0; 4709 4709 } 4710 4710 4711 - if (adapter->failover_pending) { 4712 - adapter->init_done_rc = -EAGAIN; 4713 - netdev_dbg(netdev, "Failover pending, ignoring login response\n"); 4714 - complete(&adapter->init_done); 4715 - /* login response buffer will be released on reset */ 4716 - return 0; 4717 - } 4718 - 4719 4711 netdev->mtu = adapter->req_mtu - ETH_HLEN; 4720 4712 4721 4713 netdev_dbg(adapter->netdev, "Login Response Buffer:\n");
+15 -7
drivers/net/ethernet/intel/e100.c
··· 2437 2437 sizeof(info->bus_info)); 2438 2438 } 2439 2439 2440 - #define E100_PHY_REGS 0x1C 2440 + #define E100_PHY_REGS 0x1D 2441 2441 static int e100_get_regs_len(struct net_device *netdev) 2442 2442 { 2443 2443 struct nic *nic = netdev_priv(netdev); 2444 - return 1 + E100_PHY_REGS + sizeof(nic->mem->dump_buf); 2444 + 2445 + /* We know the number of registers, and the size of the dump buffer. 2446 + * Calculate the total size in bytes. 2447 + */ 2448 + return (1 + E100_PHY_REGS) * sizeof(u32) + sizeof(nic->mem->dump_buf); 2445 2449 } 2446 2450 2447 2451 static void e100_get_regs(struct net_device *netdev, ··· 2459 2455 buff[0] = ioread8(&nic->csr->scb.cmd_hi) << 24 | 2460 2456 ioread8(&nic->csr->scb.cmd_lo) << 16 | 2461 2457 ioread16(&nic->csr->scb.status); 2462 - for (i = E100_PHY_REGS; i >= 0; i--) 2463 - buff[1 + E100_PHY_REGS - i] = 2464 - mdio_read(netdev, nic->mii.phy_id, i); 2458 + for (i = 0; i < E100_PHY_REGS; i++) 2459 + /* Note that we read the registers in reverse order. This 2460 + * ordering is the ABI apparently used by ethtool and other 2461 + * applications. 2462 + */ 2463 + buff[1 + i] = mdio_read(netdev, nic->mii.phy_id, 2464 + E100_PHY_REGS - 1 - i); 2465 2465 memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf)); 2466 2466 e100_exec_cb(nic, NULL, e100_dump); 2467 2467 msleep(10); 2468 - memcpy(&buff[2 + E100_PHY_REGS], nic->mem->dump_buf, 2469 - sizeof(nic->mem->dump_buf)); 2468 + memcpy(&buff[1 + E100_PHY_REGS], nic->mem->dump_buf, 2469 + sizeof(nic->mem->dump_buf)); 2470 2470 } 2471 2471 2472 2472 static void e100_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
+1 -1
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
··· 3208 3208 max_combined = ixgbe_max_rss_indices(adapter); 3209 3209 } 3210 3210 3211 - return max_combined; 3211 + return min_t(int, max_combined, num_online_cpus()); 3212 3212 } 3213 3213 3214 3214 static void ixgbe_get_channels(struct net_device *dev,
+6 -2
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 10112 10112 struct ixgbe_adapter *adapter = netdev_priv(dev); 10113 10113 struct bpf_prog *old_prog; 10114 10114 bool need_reset; 10115 + int num_queues; 10115 10116 10116 10117 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) 10117 10118 return -EINVAL; ··· 10162 10161 /* Kick start the NAPI context if there is an AF_XDP socket open 10163 10162 * on that queue id. This so that receiving will start. 10164 10163 */ 10165 - if (need_reset && prog) 10166 - for (i = 0; i < adapter->num_rx_queues; i++) 10164 + if (need_reset && prog) { 10165 + num_queues = min_t(int, adapter->num_rx_queues, 10166 + adapter->num_xdp_queues); 10167 + for (i = 0; i < num_queues; i++) 10167 10168 if (adapter->xdp_ring[i]->xsk_pool) 10168 10169 (void)ixgbe_xsk_wakeup(adapter->netdev, i, 10169 10170 XDP_WAKEUP_RX); 10171 + } 10170 10172 10171 10173 return 0; 10172 10174 }
+2 -4
drivers/net/ethernet/micrel/Makefile
··· 4 4 # 5 5 6 6 obj-$(CONFIG_KS8842) += ks8842.o 7 - obj-$(CONFIG_KS8851) += ks8851.o 8 - ks8851-objs = ks8851_common.o ks8851_spi.o 9 - obj-$(CONFIG_KS8851_MLL) += ks8851_mll.o 10 - ks8851_mll-objs = ks8851_common.o ks8851_par.o 7 + obj-$(CONFIG_KS8851) += ks8851_common.o ks8851_spi.o 8 + obj-$(CONFIG_KS8851_MLL) += ks8851_common.o ks8851_par.o 11 9 obj-$(CONFIG_KSZ884X_PCI) += ksz884x.o
+8
drivers/net/ethernet/micrel/ks8851_common.c
··· 1057 1057 1058 1058 return 0; 1059 1059 } 1060 + EXPORT_SYMBOL_GPL(ks8851_suspend); 1060 1061 1061 1062 int ks8851_resume(struct device *dev) 1062 1063 { ··· 1071 1070 1072 1071 return 0; 1073 1072 } 1073 + EXPORT_SYMBOL_GPL(ks8851_resume); 1074 1074 #endif 1075 1075 1076 1076 static int ks8851_register_mdiobus(struct ks8851_net *ks, struct device *dev) ··· 1245 1243 err_reg_io: 1246 1244 return ret; 1247 1245 } 1246 + EXPORT_SYMBOL_GPL(ks8851_probe_common); 1248 1247 1249 1248 int ks8851_remove_common(struct device *dev) 1250 1249 { ··· 1264 1261 1265 1262 return 0; 1266 1263 } 1264 + EXPORT_SYMBOL_GPL(ks8851_remove_common); 1265 + 1266 + MODULE_DESCRIPTION("KS8851 Network driver"); 1267 + MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); 1268 + MODULE_LICENSE("GPL");
-9
drivers/net/ethernet/pensando/ionic/ionic_stats.c
··· 380 380 &ionic_dbg_intr_stats_desc[i]); 381 381 (*buf)++; 382 382 } 383 - for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++) { 384 - **buf = IONIC_READ_STAT64(&txqcq->napi_stats, 385 - &ionic_dbg_napi_stats_desc[i]); 386 - (*buf)++; 387 - } 388 - for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++) { 389 - **buf = txqcq->napi_stats.work_done_cntr[i]; 390 - (*buf)++; 391 - } 392 383 for (i = 0; i < IONIC_MAX_NUM_SG_CNTR; i++) { 393 384 **buf = txstats->sg_cntr[i]; 394 385 (*buf)++;
+4
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 486 486 timer_setup(&priv->eee_ctrl_timer, stmmac_eee_ctrl_timer, 0); 487 487 stmmac_set_eee_timer(priv, priv->hw, STMMAC_DEFAULT_LIT_LS, 488 488 eee_tw_timer); 489 + if (priv->hw->xpcs) 490 + xpcs_config_eee(priv->hw->xpcs, 491 + priv->plat->mult_fact_100ns, 492 + true); 489 493 } 490 494 491 495 if (priv->plat->has_gmac4 && priv->tx_lpi_timer <= STMMAC_ET_MAX) {
+1
drivers/net/ethernet/sun/Kconfig
··· 73 73 config SUNVNET_COMMON 74 74 tristate "Common routines to support Sun Virtual Networking" 75 75 depends on SUN_LDOMS 76 + depends on INET 76 77 default m 77 78 78 79 config SUNVNET
+1
drivers/net/hamradio/Kconfig
··· 48 48 config DMASCC 49 49 tristate "High-speed (DMA) SCC driver for AX.25" 50 50 depends on ISA && AX25 && BROKEN_ON_SMP && ISA_DMA_API 51 + depends on VIRT_TO_BUS 51 52 help 52 53 This is a driver for high-speed SCC boards, i.e. those supporting 53 54 DMA on one port. You usually use those boards to connect your
+5 -1
drivers/net/mdio/mdio-ipq4019.c
··· 207 207 { 208 208 struct ipq4019_mdio_data *priv; 209 209 struct mii_bus *bus; 210 + struct resource *res; 210 211 int ret; 211 212 212 213 bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv)); ··· 225 224 return PTR_ERR(priv->mdio_clk); 226 225 227 226 /* The platform resource is provided on the chipset IPQ5018 */ 228 - priv->eth_ldo_rdy = devm_platform_ioremap_resource(pdev, 1); 227 + /* This resource is optional */ 228 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 229 + if (res) 230 + priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res); 229 231 230 232 bus->name = "ipq4019_mdio"; 231 233 bus->read = ipq4019_mdio_read;
+10 -5
drivers/net/mdio/mdio-mscc-miim.c
··· 134 134 135 135 static int mscc_miim_probe(struct platform_device *pdev) 136 136 { 137 - struct mii_bus *bus; 138 137 struct mscc_miim_dev *dev; 138 + struct resource *res; 139 + struct mii_bus *bus; 139 140 int ret; 140 141 141 142 bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*dev)); ··· 157 156 return PTR_ERR(dev->regs); 158 157 } 159 158 160 - dev->phy_regs = devm_platform_ioremap_resource(pdev, 1); 161 - if (IS_ERR(dev->phy_regs)) { 162 - dev_err(&pdev->dev, "Unable to map internal phy registers\n"); 163 - return PTR_ERR(dev->phy_regs); 159 + /* This resource is optional */ 160 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 161 + if (res) { 162 + dev->phy_regs = devm_ioremap_resource(&pdev->dev, res); 163 + if (IS_ERR(dev->phy_regs)) { 164 + dev_err(&pdev->dev, "Unable to map internal phy registers\n"); 165 + return PTR_ERR(dev->phy_regs); 166 + } 164 167 } 165 168 166 169 ret = of_mdiobus_register(bus, pdev->dev.of_node);
+1 -5
drivers/net/mhi_net.c
··· 321 321 /* Start MHI channels */ 322 322 err = mhi_prepare_for_transfer(mhi_dev); 323 323 if (err) 324 - goto out_err; 324 + return err; 325 325 326 326 /* Number of transfer descriptors determines size of the queue */ 327 327 mhi_netdev->rx_queue_sz = mhi_get_free_desc_count(mhi_dev, DMA_FROM_DEVICE); ··· 331 331 return err; 332 332 333 333 return 0; 334 - 335 - out_err: 336 - free_netdev(ndev); 337 - return err; 338 334 } 339 335 340 336 static void mhi_net_dellink(struct mhi_device *mhi_dev, struct net_device *ndev)
+110 -4
drivers/net/phy/bcm7xxx.c
··· 27 27 #define MII_BCM7XXX_SHD_2_ADDR_CTRL 0xe 28 28 #define MII_BCM7XXX_SHD_2_CTRL_STAT 0xf 29 29 #define MII_BCM7XXX_SHD_2_BIAS_TRIM 0x1a 30 + #define MII_BCM7XXX_SHD_3_PCS_CTRL 0x0 31 + #define MII_BCM7XXX_SHD_3_PCS_STATUS 0x1 32 + #define MII_BCM7XXX_SHD_3_EEE_CAP 0x2 30 33 #define MII_BCM7XXX_SHD_3_AN_EEE_ADV 0x3 34 + #define MII_BCM7XXX_SHD_3_EEE_LP 0x4 35 + #define MII_BCM7XXX_SHD_3_EEE_WK_ERR 0x5 31 36 #define MII_BCM7XXX_SHD_3_PCS_CTRL_2 0x6 32 37 #define MII_BCM7XXX_PCS_CTRL_2_DEF 0x4400 33 38 #define MII_BCM7XXX_SHD_3_AN_STAT 0xb ··· 221 216 return genphy_config_aneg(phydev); 222 217 } 223 218 224 - static int phy_set_clr_bits(struct phy_device *dev, int location, 225 - int set_mask, int clr_mask) 219 + static int __phy_set_clr_bits(struct phy_device *dev, int location, 220 + int set_mask, int clr_mask) 226 221 { 227 222 int v, ret; 228 223 229 - v = phy_read(dev, location); 224 + v = __phy_read(dev, location); 230 225 if (v < 0) 231 226 return v; 232 227 233 228 v &= ~clr_mask; 234 229 v |= set_mask; 235 230 236 - ret = phy_write(dev, location, v); 231 + ret = __phy_write(dev, location, v); 237 232 if (ret < 0) 238 233 return ret; 239 234 240 235 return v; 236 + } 237 + 238 + static int phy_set_clr_bits(struct phy_device *dev, int location, 239 + int set_mask, int clr_mask) 240 + { 241 + int ret; 242 + 243 + mutex_lock(&dev->mdio.bus->mdio_lock); 244 + ret = __phy_set_clr_bits(dev, location, set_mask, clr_mask); 245 + mutex_unlock(&dev->mdio.bus->mdio_lock); 246 + 247 + return ret; 241 248 } 242 249 243 250 static int bcm7xxx_28nm_ephy_01_afe_config_init(struct phy_device *phydev) ··· 413 396 return ret; 414 397 415 398 return bcm7xxx_28nm_ephy_apd_enable(phydev); 399 + } 400 + 401 + #define MII_BCM7XXX_REG_INVALID 0xff 402 + 403 + static u8 bcm7xxx_28nm_ephy_regnum_to_shd(u16 regnum) 404 + { 405 + switch (regnum) { 406 + case MDIO_CTRL1: 407 + return MII_BCM7XXX_SHD_3_PCS_CTRL; 408 + case MDIO_STAT1: 409 + return MII_BCM7XXX_SHD_3_PCS_STATUS; 410 + case MDIO_PCS_EEE_ABLE: 411 + return MII_BCM7XXX_SHD_3_EEE_CAP; 412 + case MDIO_AN_EEE_ADV: 413 + return MII_BCM7XXX_SHD_3_AN_EEE_ADV; 414 + case MDIO_AN_EEE_LPABLE: 415 + return MII_BCM7XXX_SHD_3_EEE_LP; 416 + case MDIO_PCS_EEE_WK_ERR: 417 + return MII_BCM7XXX_SHD_3_EEE_WK_ERR; 418 + default: 419 + return MII_BCM7XXX_REG_INVALID; 420 + } 421 + } 422 + 423 + static bool bcm7xxx_28nm_ephy_dev_valid(int devnum) 424 + { 425 + return devnum == MDIO_MMD_AN || devnum == MDIO_MMD_PCS; 426 + } 427 + 428 + static int bcm7xxx_28nm_ephy_read_mmd(struct phy_device *phydev, 429 + int devnum, u16 regnum) 430 + { 431 + u8 shd = bcm7xxx_28nm_ephy_regnum_to_shd(regnum); 432 + int ret; 433 + 434 + if (!bcm7xxx_28nm_ephy_dev_valid(devnum) || 435 + shd == MII_BCM7XXX_REG_INVALID) 436 + return -EOPNOTSUPP; 437 + 438 + /* set shadow mode 2 */ 439 + ret = __phy_set_clr_bits(phydev, MII_BCM7XXX_TEST, 440 + MII_BCM7XXX_SHD_MODE_2, 0); 441 + if (ret < 0) 442 + return ret; 443 + 444 + /* Access the desired shadow register address */ 445 + ret = __phy_write(phydev, MII_BCM7XXX_SHD_2_ADDR_CTRL, shd); 446 + if (ret < 0) 447 + goto reset_shadow_mode; 448 + 449 + ret = __phy_read(phydev, MII_BCM7XXX_SHD_2_CTRL_STAT); 450 + 451 + reset_shadow_mode: 452 + /* reset shadow mode 2 */ 453 + __phy_set_clr_bits(phydev, MII_BCM7XXX_TEST, 0, 454 + MII_BCM7XXX_SHD_MODE_2); 455 + return ret; 456 + } 457 + 458 + static int bcm7xxx_28nm_ephy_write_mmd(struct phy_device *phydev, 459 + int devnum, u16 regnum, u16 val) 460 + { 461 + u8 shd = bcm7xxx_28nm_ephy_regnum_to_shd(regnum); 462 + int ret; 463 + 464 + if (!bcm7xxx_28nm_ephy_dev_valid(devnum) || 465 + shd == MII_BCM7XXX_REG_INVALID) 466 + return -EOPNOTSUPP; 467 + 468 + /* set shadow mode 2 */ 469 + ret = __phy_set_clr_bits(phydev, MII_BCM7XXX_TEST, 470 + MII_BCM7XXX_SHD_MODE_2, 0); 471 + if (ret < 0) 472 + return ret; 473 + 474 + /* Access the desired shadow register address */ 475 + ret = __phy_write(phydev, MII_BCM7XXX_SHD_2_ADDR_CTRL, shd); 476 + if (ret < 0) 477 + goto reset_shadow_mode; 478 + 479 + /* Write the desired value in the shadow register */ 480 + __phy_write(phydev, MII_BCM7XXX_SHD_2_CTRL_STAT, val); 481 + 482 + reset_shadow_mode: 483 + /* reset shadow mode 2 */ 484 + return __phy_set_clr_bits(phydev, MII_BCM7XXX_TEST, 0, 485 + MII_BCM7XXX_SHD_MODE_2); 416 486 } 417 487 418 488 static int bcm7xxx_28nm_ephy_resume(struct phy_device *phydev) ··· 699 595 .get_stats = bcm7xxx_28nm_get_phy_stats, \ 700 596 .probe = bcm7xxx_28nm_probe, \ 701 597 .remove = bcm7xxx_28nm_remove, \ 598 + .read_mmd = bcm7xxx_28nm_ephy_read_mmd, \ 599 + .write_mmd = bcm7xxx_28nm_ephy_write_mmd, \ 702 600 } 703 601 704 602 #define BCM7XXX_40NM_EPHY(_oui, _name) \
+5
drivers/net/phy/mdio_bus.c
··· 525 525 NULL == bus->read || NULL == bus->write) 526 526 return -EINVAL; 527 527 528 + if (bus->parent && bus->parent->of_node) 529 + bus->parent->of_node->fwnode.flags |= 530 + FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD; 531 + 528 532 BUG_ON(bus->state != MDIOBUS_ALLOCATED && 529 533 bus->state != MDIOBUS_UNREGISTERED); 530 534 ··· 541 537 err = device_register(&bus->dev); 542 538 if (err) { 543 539 pr_err("mii_bus %s failed to register\n", bus->id); 540 + put_device(&bus->dev); 544 541 return -EINVAL; 545 542 } 546 543
+21 -2
drivers/net/phy/mxl-gpy.c
··· 493 493 return ret; 494 494 } 495 495 496 + static int gpy115_loopback(struct phy_device *phydev, bool enable) 497 + { 498 + int ret; 499 + int fw_minor; 500 + 501 + if (enable) 502 + return gpy_loopback(phydev, enable); 503 + 504 + ret = phy_read(phydev, PHY_FWV); 505 + if (ret < 0) 506 + return ret; 507 + 508 + fw_minor = FIELD_GET(PHY_FWV_MINOR_MASK, ret); 509 + if (fw_minor > 0x0076) 510 + return gpy_loopback(phydev, 0); 511 + 512 + return genphy_soft_reset(phydev); 513 + } 514 + 496 515 static struct phy_driver gpy_drivers[] = { 497 516 { 498 517 PHY_ID_MATCH_MODEL(PHY_ID_GPY2xx), ··· 546 527 .handle_interrupt = gpy_handle_interrupt, 547 528 .set_wol = gpy_set_wol, 548 529 .get_wol = gpy_get_wol, 549 - .set_loopback = gpy_loopback, 530 + .set_loopback = gpy115_loopback, 550 531 }, 551 532 { 552 533 PHY_ID_MATCH_MODEL(PHY_ID_GPY115C), ··· 563 544 .handle_interrupt = gpy_handle_interrupt, 564 545 .set_wol = gpy_set_wol, 565 546 .get_wol = gpy_get_wol, 566 - .set_loopback = gpy_loopback, 547 + .set_loopback = gpy115_loopback, 567 548 }, 568 549 { 569 550 .phy_id = PHY_ID_GPY211B,
+3
drivers/net/usb/smsc95xx.c
··· 1178 1178 1179 1179 static void smsc95xx_handle_link_change(struct net_device *net) 1180 1180 { 1181 + struct usbnet *dev = netdev_priv(net); 1182 + 1181 1183 phy_print_status(net->phydev); 1184 + usbnet_defer_kevent(dev, EVENT_LINK_CHANGE); 1182 1185 } 1183 1186 1184 1187 static int smsc95xx_start_phy(struct usbnet *dev)
+2 -2
drivers/net/wireless/mac80211_hwsim.c
··· 1867 1867 bcn_int -= data->bcn_delta; 1868 1868 data->bcn_delta = 0; 1869 1869 } 1870 - hrtimer_forward(&data->beacon_timer, hrtimer_get_expires(timer), 1871 - ns_to_ktime(bcn_int * NSEC_PER_USEC)); 1870 + hrtimer_forward_now(&data->beacon_timer, 1871 + ns_to_ktime(bcn_int * NSEC_PER_USEC)); 1872 1872 return HRTIMER_RESTART; 1873 1873 } 1874 1874
+1 -4
drivers/nvdimm/pmem.c
··· 380 380 struct nd_pfn_sb *pfn_sb; 381 381 struct pmem_device *pmem; 382 382 struct request_queue *q; 383 - struct device *gendev; 384 383 struct gendisk *disk; 385 384 void *addr; 386 385 int rc; ··· 488 489 } 489 490 dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); 490 491 pmem->dax_dev = dax_dev; 491 - gendev = disk_to_dev(disk); 492 - gendev->groups = pmem_attribute_groups; 493 492 494 - device_add_disk(dev, disk, NULL); 493 + device_add_disk(dev, disk, pmem_attribute_groups); 495 494 if (devm_add_action_or_reset(dev, pmem_release_disk, pmem)) 496 495 return -ENOMEM; 497 496
+3 -1
drivers/nvme/host/core.c
··· 978 978 blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req) 979 979 { 980 980 struct nvme_command *cmd = nvme_req(req)->cmd; 981 + struct nvme_ctrl *ctrl = nvme_req(req)->ctrl; 981 982 blk_status_t ret = BLK_STS_OK; 982 983 983 984 if (!(req->rq_flags & RQF_DONTPREP)) { ··· 1027 1026 return BLK_STS_IOERR; 1028 1027 } 1029 1028 1030 - nvme_req(req)->genctr++; 1029 + if (!(ctrl->quirks & NVME_QUIRK_SKIP_CID_GEN)) 1030 + nvme_req(req)->genctr++; 1031 1031 cmd->common.command_id = nvme_cid(req); 1032 1032 trace_nvme_setup_cmd(req, cmd); 1033 1033 return ret;
+6
drivers/nvme/host/nvme.h
··· 138 138 * 48 bits. 139 139 */ 140 140 NVME_QUIRK_DMA_ADDRESS_BITS_48 = (1 << 16), 141 + 142 + /* 143 + * The controller requires the command_id value be be limited, so skip 144 + * encoding the generation sequence number. 145 + */ 146 + NVME_QUIRK_SKIP_CID_GEN = (1 << 17), 141 147 }; 142 148 143 149 /*
+2 -1
drivers/nvme/host/pci.c
··· 3369 3369 { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005), 3370 3370 .driver_data = NVME_QUIRK_SINGLE_VECTOR | 3371 3371 NVME_QUIRK_128_BYTES_SQES | 3372 - NVME_QUIRK_SHARED_TAGS }, 3372 + NVME_QUIRK_SHARED_TAGS | 3373 + NVME_QUIRK_SKIP_CID_GEN }, 3373 3374 3374 3375 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, 3375 3376 { 0, }
+2
drivers/perf/arm_pmu.c
··· 952 952 pmu->name, pmu->num_events, 953 953 has_nmi ? ", using NMIs" : ""); 954 954 955 + kvm_host_pmu_init(pmu); 956 + 955 957 return 0; 956 958 957 959 out_destroy:
+1 -1
drivers/pinctrl/core.c
··· 2306 2306 2307 2307 /** 2308 2308 * devm_pinctrl_unregister() - Resource managed version of pinctrl_unregister(). 2309 - * @dev: device for which which resource was allocated 2309 + * @dev: device for which resource was allocated 2310 2310 * @pctldev: the pinctrl device to unregister. 2311 2311 */ 2312 2312 void devm_pinctrl_unregister(struct device *dev, struct pinctrl_dev *pctldev)
+14 -5
drivers/pinctrl/pinctrl-amd.c
··· 445 445 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 446 446 struct amd_gpio *gpio_dev = gpiochip_get_data(gc); 447 447 u32 wake_mask = BIT(WAKE_CNTRL_OFF_S0I3) | BIT(WAKE_CNTRL_OFF_S3); 448 + int err; 448 449 449 450 raw_spin_lock_irqsave(&gpio_dev->lock, flags); 450 451 pin_reg = readl(gpio_dev->base + (d->hwirq)*4); ··· 457 456 458 457 writel(pin_reg, gpio_dev->base + (d->hwirq)*4); 459 458 raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); 459 + 460 + if (on) 461 + err = enable_irq_wake(gpio_dev->irq); 462 + else 463 + err = disable_irq_wake(gpio_dev->irq); 464 + 465 + if (err) 466 + dev_err(&gpio_dev->pdev->dev, "failed to %s wake-up interrupt\n", 467 + on ? "enable" : "disable"); 460 468 461 469 return 0; 462 470 } ··· 912 902 static int amd_gpio_probe(struct platform_device *pdev) 913 903 { 914 904 int ret = 0; 915 - int irq_base; 916 905 struct resource *res; 917 906 struct amd_gpio *gpio_dev; 918 907 struct gpio_irq_chip *girq; ··· 934 925 if (!gpio_dev->base) 935 926 return -ENOMEM; 936 927 937 - irq_base = platform_get_irq(pdev, 0); 938 - if (irq_base < 0) 939 - return irq_base; 928 + gpio_dev->irq = platform_get_irq(pdev, 0); 929 + if (gpio_dev->irq < 0) 930 + return gpio_dev->irq; 940 931 941 932 #ifdef CONFIG_PM_SLEEP 942 933 gpio_dev->saved_regs = devm_kcalloc(&pdev->dev, amd_pinctrl_desc.npins, ··· 996 987 goto out2; 997 988 } 998 989 999 - ret = devm_request_irq(&pdev->dev, irq_base, amd_gpio_irq_handler, 990 + ret = devm_request_irq(&pdev->dev, gpio_dev->irq, amd_gpio_irq_handler, 1000 991 IRQF_SHARED, KBUILD_MODNAME, gpio_dev); 1001 992 if (ret) 1002 993 goto out2;
+1
drivers/pinctrl/pinctrl-amd.h
··· 98 98 struct resource *res; 99 99 struct platform_device *pdev; 100 100 u32 *saved_regs; 101 + int irq; 101 102 }; 102 103 103 104 /* KERNCZ configuration*/
+67
drivers/pinctrl/pinctrl-rockchip.c
··· 2092 2092 return false; 2093 2093 } 2094 2094 2095 + static int rockchip_pinconf_defer_output(struct rockchip_pin_bank *bank, 2096 + unsigned int pin, u32 arg) 2097 + { 2098 + struct rockchip_pin_output_deferred *cfg; 2099 + 2100 + cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); 2101 + if (!cfg) 2102 + return -ENOMEM; 2103 + 2104 + cfg->pin = pin; 2105 + cfg->arg = arg; 2106 + 2107 + list_add_tail(&cfg->head, &bank->deferred_output); 2108 + 2109 + return 0; 2110 + } 2111 + 2095 2112 /* set the pin config settings for a specified pin */ 2096 2113 static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, 2097 2114 unsigned long *configs, unsigned num_configs) ··· 2152 2135 RK_FUNC_GPIO); 2153 2136 if (rc != RK_FUNC_GPIO) 2154 2137 return -EINVAL; 2138 + 2139 + /* 2140 + * Check for gpio driver not being probed yet. 2141 + * The lock makes sure that either gpio-probe has completed 2142 + * or the gpio driver hasn't probed yet. 2143 + */ 2144 + mutex_lock(&bank->deferred_lock); 2145 + if (!gpio || !gpio->direction_output) { 2146 + rc = rockchip_pinconf_defer_output(bank, pin - bank->pin_base, arg); 2147 + mutex_unlock(&bank->deferred_lock); 2148 + if (rc) 2149 + return rc; 2150 + 2151 + break; 2152 + } 2153 + mutex_unlock(&bank->deferred_lock); 2155 2154 2156 2155 rc = gpio->direction_output(gpio, pin - bank->pin_base, 2157 2156 arg); ··· 2236 2203 rc = rockchip_get_mux(bank, pin - bank->pin_base); 2237 2204 if (rc != RK_FUNC_GPIO) 2238 2205 return -EINVAL; 2206 + 2207 + if (!gpio || !gpio->get) { 2208 + arg = 0; 2209 + break; 2210 + } 2239 2211 2240 2212 rc = gpio->get(gpio, pin - bank->pin_base); 2241 2213 if (rc < 0) ··· 2488 2450 pin_bank->name, pin); 2489 2451 pdesc++; 2490 2452 } 2453 + 2454 + INIT_LIST_HEAD(&pin_bank->deferred_output); 2455 + mutex_init(&pin_bank->deferred_lock); 2491 2456 } 2492 2457 2493 2458 ret = rockchip_pinctrl_parse_dt(pdev, info); ··· 2752 2711 if (ret) { 2753 2712 dev_err(&pdev->dev, "failed to register gpio device\n"); 2754 2713 return ret; 2714 + } 2715 + 2716 + return 0; 2717 + } 2718 + 2719 + static int rockchip_pinctrl_remove(struct platform_device *pdev) 2720 + { 2721 + struct rockchip_pinctrl *info = platform_get_drvdata(pdev); 2722 + struct rockchip_pin_bank *bank; 2723 + struct rockchip_pin_output_deferred *cfg; 2724 + int i; 2725 + 2726 + of_platform_depopulate(&pdev->dev); 2727 + 2728 + for (i = 0; i < info->ctrl->nr_banks; i++) { 2729 + bank = &info->ctrl->pin_banks[i]; 2730 + 2731 + mutex_lock(&bank->deferred_lock); 2732 + while (!list_empty(&bank->deferred_output)) { 2733 + cfg = list_first_entry(&bank->deferred_output, 2734 + struct rockchip_pin_output_deferred, head); 2735 + list_del(&cfg->head); 2736 + kfree(cfg); 2737 + } 2738 + mutex_unlock(&bank->deferred_lock); 2755 2739 } 2756 2740 2757 2741 return 0; ··· 3241 3175 3242 3176 static struct platform_driver rockchip_pinctrl_driver = { 3243 3177 .probe = rockchip_pinctrl_probe, 3178 + .remove = rockchip_pinctrl_remove, 3244 3179 .driver = { 3245 3180 .name = "rockchip-pinctrl", 3246 3181 .pm = &rockchip_pinctrl_dev_pm_ops,
+10
drivers/pinctrl/pinctrl-rockchip.h
··· 141 141 * @toggle_edge_mode: bit mask to toggle (falling/rising) edge mode 142 142 * @recalced_mask: bit mask to indicate a need to recalulate the mask 143 143 * @route_mask: bits describing the routing pins of per bank 144 + * @deferred_output: gpio output settings to be done after gpio bank probed 145 + * @deferred_lock: mutex for the deferred_output shared btw gpio and pinctrl 144 146 */ 145 147 struct rockchip_pin_bank { 146 148 struct device *dev; ··· 171 169 u32 toggle_edge_mode; 172 170 u32 recalced_mask; 173 171 u32 route_mask; 172 + struct list_head deferred_output; 173 + struct mutex deferred_lock; 174 174 }; 175 175 176 176 /** ··· 245 241 unsigned int func; 246 242 unsigned long *configs; 247 243 unsigned int nconfigs; 244 + }; 245 + 246 + struct rockchip_pin_output_deferred { 247 + struct list_head head; 248 + unsigned int pin; 249 + u32 arg; 248 250 }; 249 251 250 252 /**
+1
drivers/pinctrl/qcom/pinctrl-sc7280.c
··· 1496 1496 static struct platform_driver sc7280_pinctrl_driver = { 1497 1497 .driver = { 1498 1498 .name = "sc7280-pinctrl", 1499 + .pm = &msm_pinctrl_dev_pm_ops, 1499 1500 .of_match_table = sc7280_pinctrl_of_match, 1500 1501 }, 1501 1502 .probe = sc7280_pinctrl_probe,
+34 -3
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. 3 + * Copyright (c) 2012-2014, 2016-2021 The Linux Foundation. All rights reserved. 4 4 */ 5 5 6 6 #include <linux/gpio/driver.h> ··· 14 14 #include <linux/platform_device.h> 15 15 #include <linux/regmap.h> 16 16 #include <linux/slab.h> 17 + #include <linux/spmi.h> 17 18 #include <linux/types.h> 18 19 19 20 #include <dt-bindings/pinctrl/qcom,pmic-gpio.h> ··· 172 171 struct pinctrl_dev *ctrl; 173 172 struct gpio_chip chip; 174 173 struct irq_chip irq; 174 + u8 usid; 175 + u8 pid_base; 175 176 }; 176 177 177 178 static const struct pinconf_generic_params pmic_gpio_bindings[] = { ··· 952 949 unsigned int *parent_hwirq, 953 950 unsigned int *parent_type) 954 951 { 955 - *parent_hwirq = child_hwirq + 0xc0; 952 + struct pmic_gpio_state *state = gpiochip_get_data(chip); 953 + 954 + *parent_hwirq = child_hwirq + state->pid_base; 956 955 *parent_type = child_type; 957 956 958 957 return 0; 958 + } 959 + 960 + static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, 961 + unsigned int parent_hwirq, 962 + unsigned int parent_type) 963 + { 964 + struct pmic_gpio_state *state = gpiochip_get_data(chip); 965 + struct irq_fwspec *fwspec; 966 + 967 + fwspec = kzalloc(sizeof(*fwspec), GFP_KERNEL); 968 + if (!fwspec) 969 + return NULL; 970 + 971 + fwspec->fwnode = chip->irq.parent_domain->fwnode; 972 + 973 + fwspec->param_count = 4; 974 + fwspec->param[0] = state->usid; 975 + fwspec->param[1] = parent_hwirq; 976 + /* param[2] must be left as 0 */ 977 + fwspec->param[3] = parent_type; 978 + 979 + return fwspec; 959 980 } 960 981 961 982 static int pmic_gpio_probe(struct platform_device *pdev) ··· 992 965 struct pmic_gpio_pad *pad, *pads; 993 966 struct pmic_gpio_state *state; 994 967 struct gpio_irq_chip *girq; 968 + const struct spmi_device *parent_spmi_dev; 995 969 int ret, npins, i; 996 970 u32 reg; 997 971 ··· 1012 984 1013 985 state->dev = &pdev->dev; 1014 986 state->map = dev_get_regmap(dev->parent, NULL); 987 + parent_spmi_dev = to_spmi_device(dev->parent); 988 + state->usid = parent_spmi_dev->usid; 989 + state->pid_base = reg >> 8; 1015 990 1016 991 pindesc = devm_kcalloc(dev, npins, sizeof(*pindesc), GFP_KERNEL); 1017 992 if (!pindesc) ··· 1090 1059 girq->fwnode = of_node_to_fwnode(state->dev->of_node); 1091 1060 girq->parent_domain = parent_domain; 1092 1061 girq->child_to_parent_hwirq = pmic_gpio_child_to_parent_hwirq; 1093 - girq->populate_parent_alloc_arg = gpiochip_populate_parent_fwspec_fourcell; 1062 + girq->populate_parent_alloc_arg = pmic_gpio_populate_parent_fwspec; 1094 1063 girq->child_offset_to_irq = pmic_gpio_child_offset_to_irq; 1095 1064 girq->child_irq_domain_ops.translate = pmic_gpio_domain_translate; 1096 1065
+2 -7
drivers/ptp/ptp_kvm_x86.c
··· 15 15 #include <linux/ptp_clock_kernel.h> 16 16 #include <linux/ptp_kvm.h> 17 17 18 - struct pvclock_vsyscall_time_info *hv_clock; 19 - 20 18 static phys_addr_t clock_pair_gpa; 21 19 static struct kvm_clock_pairing clock_pair; 22 20 ··· 26 28 return -ENODEV; 27 29 28 30 clock_pair_gpa = slow_virt_to_phys(&clock_pair); 29 - hv_clock = pvclock_get_pvti_cpu0_va(); 30 - if (!hv_clock) 31 + if (!pvclock_get_pvti_cpu0_va()) 31 32 return -ENODEV; 32 33 33 34 ret = kvm_hypercall2(KVM_HC_CLOCK_PAIRING, clock_pair_gpa, ··· 61 64 struct pvclock_vcpu_time_info *src; 62 65 unsigned int version; 63 66 long ret; 64 - int cpu; 65 67 66 - cpu = smp_processor_id(); 67 - src = &hv_clock[cpu].pvti; 68 + src = this_cpu_pvti(); 68 69 69 70 do { 70 71 /*
+5 -3
drivers/s390/cio/blacklist.c
··· 262 262 263 263 if (strcmp("free", parm) == 0) { 264 264 rc = blacklist_parse_parameters(buf, free, 0); 265 - /* There could be subchannels without proper devices connected. 266 - * evaluate all the entries 265 + /* 266 + * Evaluate the subchannels without an online device. This way, 267 + * no path-verification will be triggered on those subchannels 268 + * and it avoids unnecessary delays. 267 269 */ 268 - css_schedule_eval_all(); 270 + css_schedule_eval_cond(CSS_EVAL_NOT_ONLINE, 0); 269 271 } else if (strcmp("add", parm) == 0) 270 272 rc = blacklist_parse_parameters(buf, add, 0); 271 273 else if (strcmp("purge", parm) == 0)
+31 -9
drivers/s390/cio/css.c
··· 788 788 return 0; 789 789 } 790 790 791 - void css_schedule_eval_all_unreg(unsigned long delay) 791 + static int __unset_online(struct device *dev, void *data) 792 + { 793 + struct idset *set = data; 794 + struct subchannel *sch = to_subchannel(dev); 795 + struct ccw_device *cdev = sch_get_cdev(sch); 796 + 797 + if (cdev && cdev->online) 798 + idset_sch_del(set, sch->schid); 799 + 800 + return 0; 801 + } 802 + 803 + void css_schedule_eval_cond(enum css_eval_cond cond, unsigned long delay) 792 804 { 793 805 unsigned long flags; 794 - struct idset *unreg_set; 806 + struct idset *set; 795 807 796 808 /* Find unregistered subchannels. */ 797 - unreg_set = idset_sch_new(); 798 - if (!unreg_set) { 809 + set = idset_sch_new(); 810 + if (!set) { 799 811 /* Fallback. */ 800 812 css_schedule_eval_all(); 801 813 return; 802 814 } 803 - idset_fill(unreg_set); 804 - bus_for_each_dev(&css_bus_type, NULL, unreg_set, __unset_registered); 815 + idset_fill(set); 816 + switch (cond) { 817 + case CSS_EVAL_UNREG: 818 + bus_for_each_dev(&css_bus_type, NULL, set, __unset_registered); 819 + break; 820 + case CSS_EVAL_NOT_ONLINE: 821 + bus_for_each_dev(&css_bus_type, NULL, set, __unset_online); 822 + break; 823 + default: 824 + break; 825 + } 826 + 805 827 /* Apply to slow_subchannel_set. */ 806 828 spin_lock_irqsave(&slow_subchannel_lock, flags); 807 - idset_add_set(slow_subchannel_set, unreg_set); 829 + idset_add_set(slow_subchannel_set, set); 808 830 atomic_set(&css_eval_scheduled, 1); 809 831 queue_delayed_work(cio_work_q, &slow_path_work, delay); 810 832 spin_unlock_irqrestore(&slow_subchannel_lock, flags); 811 - idset_free(unreg_set); 833 + idset_free(set); 812 834 } 813 835 814 836 void css_wait_for_slow_path(void) ··· 842 820 void css_schedule_reprobe(void) 843 821 { 844 822 /* Schedule with a delay to allow merging of subsequent calls. */ 845 - css_schedule_eval_all_unreg(1 * HZ); 823 + css_schedule_eval_cond(CSS_EVAL_UNREG, 1 * HZ); 846 824 } 847 825 EXPORT_SYMBOL_GPL(css_schedule_reprobe); 848 826
+9 -1
drivers/s390/cio/css.h
··· 34 34 #define SNID_STATE3_MULTI_PATH 1 35 35 #define SNID_STATE3_SINGLE_PATH 0 36 36 37 + /* 38 + * Conditions used to specify which subchannels need evaluation 39 + */ 40 + enum css_eval_cond { 41 + CSS_EVAL_UNREG, /* unregistered subchannels */ 42 + CSS_EVAL_NOT_ONLINE /* sch without an online-device */ 43 + }; 44 + 37 45 struct path_state { 38 46 __u8 state1 : 2; /* path state value 1 */ 39 47 __u8 state2 : 2; /* path state value 2 */ ··· 144 136 /* Helper functions to build lists for the slow path. */ 145 137 void css_schedule_eval(struct subchannel_id schid); 146 138 void css_schedule_eval_all(void); 147 - void css_schedule_eval_all_unreg(unsigned long delay); 139 + void css_schedule_eval_cond(enum css_eval_cond, unsigned long delay); 148 140 int css_complete_work(void); 149 141 150 142 int sch_is_pseudo_sch(struct subchannel *);
+3 -1
drivers/s390/crypto/vfio_ap_ops.c
··· 361 361 mutex_lock(&matrix_dev->lock); 362 362 list_del(&matrix_mdev->node); 363 363 mutex_unlock(&matrix_dev->lock); 364 + vfio_uninit_group_dev(&matrix_mdev->vdev); 364 365 kfree(matrix_mdev); 365 366 err_dec_available: 366 367 atomic_inc(&matrix_dev->available_instances); ··· 377 376 mutex_lock(&matrix_dev->lock); 378 377 vfio_ap_mdev_reset_queues(matrix_mdev); 379 378 list_del(&matrix_mdev->node); 379 + mutex_unlock(&matrix_dev->lock); 380 + vfio_uninit_group_dev(&matrix_mdev->vdev); 380 381 kfree(matrix_mdev); 381 382 atomic_inc(&matrix_dev->available_instances); 382 - mutex_unlock(&matrix_dev->lock); 383 383 } 384 384 385 385 static ssize_t name_show(struct mdev_type *mtype,
+1
drivers/scsi/csiostor/csio_init.c
··· 1254 1254 MODULE_VERSION(CSIO_DRV_VERSION); 1255 1255 MODULE_FIRMWARE(FW_FNAME_T5); 1256 1256 MODULE_FIRMWARE(FW_FNAME_T6); 1257 + MODULE_SOFTDEP("pre: cxgb4");
+2 -2
drivers/scsi/qla2xxx/qla_isr.c
··· 2634 2634 } 2635 2635 2636 2636 if (unlikely(logit)) 2637 - ql_log(ql_log_warn, fcport->vha, 0x5060, 2637 + ql_log(ql_dbg_io, fcport->vha, 0x5060, 2638 2638 "NVME-%s ERR Handling - hdl=%x status(%x) tr_len:%x resid=%x ox_id=%x\n", 2639 2639 sp->name, sp->handle, comp_status, 2640 2640 fd->transferred_length, le32_to_cpu(sts->residual_len), ··· 3491 3491 3492 3492 out: 3493 3493 if (logit) 3494 - ql_log(ql_log_warn, fcport->vha, 0x3022, 3494 + ql_log(ql_dbg_io, fcport->vha, 0x3022, 3495 3495 "FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu portid=%02x%02x%02x oxid=0x%x cdb=%10phN len=0x%x rsp_info=0x%x resid=0x%x fw_resid=0x%x sp=%p cp=%p.\n", 3496 3496 comp_status, scsi_status, res, vha->host_no, 3497 3497 cp->device->id, cp->device->lun, fcport->d_id.b.domain,
+1 -1
drivers/scsi/ses.c
··· 118 118 static int ses_send_diag(struct scsi_device *sdev, int page_code, 119 119 void *buf, int bufflen) 120 120 { 121 - u32 result; 121 + int result; 122 122 123 123 unsigned char cmd[] = { 124 124 SEND_DIAGNOSTIC,
+1 -2
drivers/scsi/ufs/ufshcd.c
··· 318 318 static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, 319 319 enum ufs_trace_str_t str_t) 320 320 { 321 - int off = (int)tag - hba->nutrs; 322 - struct utp_task_req_desc *descp = &hba->utmrdl_base_addr[off]; 321 + struct utp_task_req_desc *descp = &hba->utmrdl_base_addr[tag]; 323 322 324 323 if (!trace_ufshcd_upiu_enabled()) 325 324 return;
+2 -2
drivers/scsi/virtio_scsi.c
··· 300 300 } 301 301 break; 302 302 default: 303 - pr_info("Unsupport virtio scsi event reason %x\n", event->reason); 303 + pr_info("Unsupported virtio scsi event reason %x\n", event->reason); 304 304 } 305 305 } 306 306 ··· 392 392 virtscsi_handle_param_change(vscsi, event); 393 393 break; 394 394 default: 395 - pr_err("Unsupport virtio scsi event %x\n", event->event); 395 + pr_err("Unsupported virtio scsi event %x\n", event->event); 396 396 } 397 397 virtscsi_kick_event(vscsi, event_node); 398 398 }
+1 -1
drivers/staging/media/hantro/hantro_drv.c
··· 919 919 if (!vpu->variant->irqs[i].handler) 920 920 continue; 921 921 922 - if (vpu->variant->num_clocks > 1) { 922 + if (vpu->variant->num_irqs > 1) { 923 923 irq_name = vpu->variant->irqs[i].name; 924 924 irq = platform_get_irq_byname(vpu->pdev, irq_name); 925 925 } else {
+1 -1
drivers/staging/media/sunxi/cedrus/cedrus_video.c
··· 135 135 sizeimage = bytesperline * height; 136 136 137 137 /* Chroma plane size. */ 138 - sizeimage += bytesperline * height / 2; 138 + sizeimage += bytesperline * ALIGN(height, 64) / 2; 139 139 140 140 break; 141 141
+5
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 1714 1714 struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); 1715 1715 struct mlx5_vdpa_virtqueue *mvq; 1716 1716 1717 + if (!mvdev->actual_features) 1718 + return; 1719 + 1717 1720 if (!is_index_valid(mvdev, idx)) 1718 1721 return; 1719 1722 ··· 2148 2145 2149 2146 for (i = 0; i < ndev->mvdev.max_vqs; i++) 2150 2147 ndev->vqs[i].ready = false; 2148 + 2149 + ndev->mvdev.cvq.ready = false; 2151 2150 } 2152 2151 2153 2152 static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status)
+5 -5
drivers/vdpa/vdpa_user/vduse_dev.c
··· 665 665 static int vduse_vdpa_reset(struct vdpa_device *vdpa) 666 666 { 667 667 struct vduse_dev *dev = vdpa_to_vduse(vdpa); 668 - 669 - if (vduse_dev_set_status(dev, 0)) 670 - return -EIO; 668 + int ret = vduse_dev_set_status(dev, 0); 671 669 672 670 vduse_dev_reset(dev); 673 671 674 - return 0; 672 + return ret; 675 673 } 676 674 677 675 static u32 vduse_vdpa_get_generation(struct vdpa_device *vdpa) ··· 1591 1593 1592 1594 vduse_irq_wq = alloc_workqueue("vduse-irq", 1593 1595 WQ_HIGHPRI | WQ_SYSFS | WQ_UNBOUND, 0); 1594 - if (!vduse_irq_wq) 1596 + if (!vduse_irq_wq) { 1597 + ret = -ENOMEM; 1595 1598 goto err_wq; 1599 + } 1596 1600 1597 1601 ret = vduse_domain_init(); 1598 1602 if (ret)
+1 -1
drivers/vfio/pci/vfio_pci_core.c
··· 565 565 } 566 566 567 567 struct vfio_pci_walk_info { 568 - int (*fn)(struct pci_dev *, void *data); 568 + int (*fn)(struct pci_dev *pdev, void *data); 569 569 void *data; 570 570 struct pci_dev *pdev; 571 571 bool slot;
+1 -1
drivers/vhost/vdpa.c
··· 640 640 u64 offset, map_size, map_iova = iova; 641 641 struct vdpa_map_file *map_file; 642 642 struct vm_area_struct *vma; 643 - int ret; 643 + int ret = 0; 644 644 645 645 mmap_read_lock(dev->mm); 646 646
+6 -1
drivers/virtio/virtio.c
··· 345 345 ret = snprintf(compat, sizeof(compat), "virtio,device%x", dev->id.device); 346 346 BUG_ON(ret >= sizeof(compat)); 347 347 348 + /* 349 + * On powerpc/pseries virtio devices are PCI devices so PCI 350 + * vendor/device ids play the role of the "compatible" property. 351 + * Simply don't init of_node in this case. 352 + */ 348 353 if (!of_device_is_compatible(np, compat)) { 349 - ret = -EINVAL; 354 + ret = 0; 350 355 goto out; 351 356 } 352 357
+1 -1
drivers/watchdog/Kconfig
··· 1666 1666 1667 1667 config SIBYTE_WDOG 1668 1668 tristate "Sibyte SoC hardware watchdog" 1669 - depends on CPU_SB1 || (MIPS && COMPILE_TEST) 1669 + depends on CPU_SB1 1670 1670 help 1671 1671 Watchdog driver for the built in watchdog hardware in Sibyte 1672 1672 SoC processors. There are apparently two watchdog timers
+1 -1
fs/binfmt_elf.c
··· 630 630 631 631 vaddr = eppnt->p_vaddr; 632 632 if (interp_elf_ex->e_type == ET_EXEC || load_addr_set) 633 - elf_type |= MAP_FIXED_NOREPLACE; 633 + elf_type |= MAP_FIXED; 634 634 else if (no_base && interp_elf_ex->e_type == ET_DYN) 635 635 load_addr = -vaddr; 636 636
+1 -1
fs/debugfs/inode.c
··· 528 528 { 529 529 struct dentry *de = debugfs_create_file(name, mode, parent, data, fops); 530 530 531 - if (de) 531 + if (!IS_ERR(de)) 532 532 d_inode(de)->i_size = file_size; 533 533 } 534 534 EXPORT_SYMBOL_GPL(debugfs_create_file_size);
+3 -3
fs/ext4/dir.c
··· 551 551 struct dir_private_info *info = file->private_data; 552 552 struct inode *inode = file_inode(file); 553 553 struct fname *fname; 554 - int ret; 554 + int ret = 0; 555 555 556 556 if (!info) { 557 557 info = ext4_htree_create_dir_info(file, ctx->pos); ··· 599 599 info->curr_minor_hash, 600 600 &info->next_hash); 601 601 if (ret < 0) 602 - return ret; 602 + goto finished; 603 603 if (ret == 0) { 604 604 ctx->pos = ext4_get_htree_eof(file); 605 605 break; ··· 630 630 } 631 631 finished: 632 632 info->last_pos = ctx->pos; 633 - return 0; 633 + return ret < 0 ? ret : 0; 634 634 } 635 635 636 636 static int ext4_release_dir(struct inode *inode, struct file *filp)
-3
fs/ext4/ext4.h
··· 3593 3593 unsigned flags, 3594 3594 struct page **pagep, 3595 3595 void **fsdata); 3596 - extern int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos, 3597 - unsigned len, unsigned copied, 3598 - struct page *page); 3599 3596 extern int ext4_try_add_inline_entry(handle_t *handle, 3600 3597 struct ext4_filename *fname, 3601 3598 struct inode *dir, struct inode *inode);
+14 -5
fs/ext4/extents.c
··· 5916 5916 } 5917 5917 5918 5918 /* Check if *cur is a hole and if it is, skip it */ 5919 - static void skip_hole(struct inode *inode, ext4_lblk_t *cur) 5919 + static int skip_hole(struct inode *inode, ext4_lblk_t *cur) 5920 5920 { 5921 5921 int ret; 5922 5922 struct ext4_map_blocks map; ··· 5925 5925 map.m_len = ((inode->i_size) >> inode->i_sb->s_blocksize_bits) - *cur; 5926 5926 5927 5927 ret = ext4_map_blocks(NULL, inode, &map, 0); 5928 + if (ret < 0) 5929 + return ret; 5928 5930 if (ret != 0) 5929 - return; 5931 + return 0; 5930 5932 *cur = *cur + map.m_len; 5933 + return 0; 5931 5934 } 5932 5935 5933 5936 /* Count number of blocks used by this inode and update i_blocks */ ··· 5979 5976 * iblocks by total number of differences found. 5980 5977 */ 5981 5978 cur = 0; 5982 - skip_hole(inode, &cur); 5979 + ret = skip_hole(inode, &cur); 5980 + if (ret < 0) 5981 + goto out; 5983 5982 path = ext4_find_extent(inode, cur, NULL, 0); 5984 5983 if (IS_ERR(path)) 5985 5984 goto out; ··· 6000 5995 } 6001 5996 cur = max(cur + 1, le32_to_cpu(ex->ee_block) + 6002 5997 ext4_ext_get_actual_len(ex)); 6003 - skip_hole(inode, &cur); 6004 - 5998 + ret = skip_hole(inode, &cur); 5999 + if (ret < 0) { 6000 + ext4_ext_drop_refs(path); 6001 + kfree(path); 6002 + break; 6003 + } 6005 6004 path2 = ext4_find_extent(inode, cur, NULL, 0); 6006 6005 if (IS_ERR(path2)) { 6007 6006 ext4_ext_drop_refs(path);
+6
fs/ext4/fast_commit.c
··· 892 892 sizeof(lrange), (u8 *)&lrange, crc)) 893 893 return -ENOSPC; 894 894 } else { 895 + unsigned int max = (map.m_flags & EXT4_MAP_UNWRITTEN) ? 896 + EXT_UNWRITTEN_MAX_LEN : EXT_INIT_MAX_LEN; 897 + 898 + /* Limit the number of blocks in one extent */ 899 + map.m_len = min(max, map.m_len); 900 + 895 901 fc_ext.fc_ino = cpu_to_le32(inode->i_ino); 896 902 ex = (struct ext4_extent *)&fc_ext.fc_ex; 897 903 ex->ee_block = cpu_to_le32(map.m_lblk);
+85 -65
fs/ext4/inline.c
··· 7 7 #include <linux/iomap.h> 8 8 #include <linux/fiemap.h> 9 9 #include <linux/iversion.h> 10 + #include <linux/backing-dev.h> 10 11 11 12 #include "ext4_jbd2.h" 12 13 #include "ext4.h" ··· 734 733 int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len, 735 734 unsigned copied, struct page *page) 736 735 { 737 - int ret, no_expand; 736 + handle_t *handle = ext4_journal_current_handle(); 737 + int no_expand; 738 738 void *kaddr; 739 739 struct ext4_iloc iloc; 740 + int ret = 0, ret2; 740 741 741 - if (unlikely(copied < len)) { 742 - if (!PageUptodate(page)) { 743 - copied = 0; 742 + if (unlikely(copied < len) && !PageUptodate(page)) 743 + copied = 0; 744 + 745 + if (likely(copied)) { 746 + ret = ext4_get_inode_loc(inode, &iloc); 747 + if (ret) { 748 + unlock_page(page); 749 + put_page(page); 750 + ext4_std_error(inode->i_sb, ret); 744 751 goto out; 745 752 } 746 - } 753 + ext4_write_lock_xattr(inode, &no_expand); 754 + BUG_ON(!ext4_has_inline_data(inode)); 747 755 748 - ret = ext4_get_inode_loc(inode, &iloc); 749 - if (ret) { 750 - ext4_std_error(inode->i_sb, ret); 751 - copied = 0; 752 - goto out; 753 - } 756 + /* 757 + * ei->i_inline_off may have changed since 758 + * ext4_write_begin() called 759 + * ext4_try_to_write_inline_data() 760 + */ 761 + (void) ext4_find_inline_data_nolock(inode); 754 762 755 - ext4_write_lock_xattr(inode, &no_expand); 756 - BUG_ON(!ext4_has_inline_data(inode)); 763 + kaddr = kmap_atomic(page); 764 + ext4_write_inline_data(inode, &iloc, kaddr, pos, copied); 765 + kunmap_atomic(kaddr); 766 + SetPageUptodate(page); 767 + /* clear page dirty so that writepages wouldn't work for us. */ 768 + ClearPageDirty(page); 769 + 770 + ext4_write_unlock_xattr(inode, &no_expand); 771 + brelse(iloc.bh); 772 + 773 + /* 774 + * It's important to update i_size while still holding page 775 + * lock: page writeout could otherwise come in and zero 776 + * beyond i_size. 777 + */ 778 + ext4_update_inode_size(inode, pos + copied); 779 + } 780 + unlock_page(page); 781 + put_page(page); 757 782 758 783 /* 759 - * ei->i_inline_off may have changed since ext4_write_begin() 760 - * called ext4_try_to_write_inline_data() 784 + * Don't mark the inode dirty under page lock. First, it unnecessarily 785 + * makes the holding time of page lock longer. Second, it forces lock 786 + * ordering of page lock and transaction start for journaling 787 + * filesystems. 761 788 */ 762 - (void) ext4_find_inline_data_nolock(inode); 763 - 764 - kaddr = kmap_atomic(page); 765 - ext4_write_inline_data(inode, &iloc, kaddr, pos, len); 766 - kunmap_atomic(kaddr); 767 - SetPageUptodate(page); 768 - /* clear page dirty so that writepages wouldn't work for us. */ 769 - ClearPageDirty(page); 770 - 771 - ext4_write_unlock_xattr(inode, &no_expand); 772 - brelse(iloc.bh); 773 - mark_inode_dirty(inode); 789 + if (likely(copied)) 790 + mark_inode_dirty(inode); 774 791 out: 775 - return copied; 792 + /* 793 + * If we didn't copy as much data as expected, we need to trim back 794 + * size of xattr containing inline data. 795 + */ 796 + if (pos + len > inode->i_size && ext4_can_truncate(inode)) 797 + ext4_orphan_add(handle, inode); 798 + 799 + ret2 = ext4_journal_stop(handle); 800 + if (!ret) 801 + ret = ret2; 802 + if (pos + len > inode->i_size) { 803 + ext4_truncate_failed_write(inode); 804 + /* 805 + * If truncate failed early the inode might still be 806 + * on the orphan list; we need to make sure the inode 807 + * is removed from the orphan list in that case. 808 + */ 809 + if (inode->i_nlink) 810 + ext4_orphan_del(NULL, inode); 811 + } 812 + return ret ? ret : copied; 776 813 } 777 814 778 815 struct buffer_head * ··· 990 951 out: 991 952 brelse(iloc.bh); 992 953 return ret; 993 - } 994 - 995 - int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos, 996 - unsigned len, unsigned copied, 997 - struct page *page) 998 - { 999 - int ret; 1000 - 1001 - ret = ext4_write_inline_data_end(inode, pos, len, copied, page); 1002 - if (ret < 0) { 1003 - unlock_page(page); 1004 - put_page(page); 1005 - return ret; 1006 - } 1007 - copied = ret; 1008 - 1009 - /* 1010 - * No need to use i_size_read() here, the i_size 1011 - * cannot change under us because we hold i_mutex. 1012 - * 1013 - * But it's important to update i_size while still holding page lock: 1014 - * page writeout could otherwise come in and zero beyond i_size. 1015 - */ 1016 - if (pos+copied > inode->i_size) 1017 - i_size_write(inode, pos+copied); 1018 - unlock_page(page); 1019 - put_page(page); 1020 - 1021 - /* 1022 - * Don't mark the inode dirty under page lock. First, it unnecessarily 1023 - * makes the holding time of page lock longer. Second, it forces lock 1024 - * ordering of page lock and transaction start for journaling 1025 - * filesystems. 1026 - */ 1027 - mark_inode_dirty(inode); 1028 - 1029 - return copied; 1030 954 } 1031 955 1032 956 #ifdef INLINE_DIR_DEBUG ··· 1919 1917 EXT4_I(inode)->i_disksize = i_size; 1920 1918 1921 1919 if (i_size < inline_size) { 1920 + /* 1921 + * if there's inline data to truncate and this file was 1922 + * converted to extents after that inline data was written, 1923 + * the extent status cache must be cleared to avoid leaving 1924 + * behind stale delayed allocated extent entries 1925 + */ 1926 + if (!ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) { 1927 + retry: 1928 + err = ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS); 1929 + if (err == -ENOMEM) { 1930 + cond_resched(); 1931 + congestion_wait(BLK_RW_ASYNC, HZ/50); 1932 + goto retry; 1933 + } 1934 + if (err) 1935 + goto out_error; 1936 + } 1937 + 1922 1938 /* Clear the content in the xattr space. */ 1923 1939 if (inline_size > EXT4_MIN_INLINE_DATA_SIZE) { 1924 1940 if ((err = ext4_xattr_ibody_find(inode, &i, &is)) != 0)
+60 -118
fs/ext4/inode.c
··· 1284 1284 loff_t old_size = inode->i_size; 1285 1285 int ret = 0, ret2; 1286 1286 int i_size_changed = 0; 1287 - int inline_data = ext4_has_inline_data(inode); 1288 1287 bool verity = ext4_verity_in_progress(inode); 1289 1288 1290 1289 trace_ext4_write_end(inode, pos, len, copied); 1291 - if (inline_data) { 1292 - ret = ext4_write_inline_data_end(inode, pos, len, 1293 - copied, page); 1294 - if (ret < 0) { 1295 - unlock_page(page); 1296 - put_page(page); 1297 - goto errout; 1298 - } 1299 - copied = ret; 1300 - } else 1301 - copied = block_write_end(file, mapping, pos, 1302 - len, copied, page, fsdata); 1290 + 1291 + if (ext4_has_inline_data(inode)) 1292 + return ext4_write_inline_data_end(inode, pos, len, copied, page); 1293 + 1294 + copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); 1303 1295 /* 1304 1296 * it's important to update i_size while still holding page lock: 1305 1297 * page writeout could otherwise come in and zero beyond i_size. ··· 1312 1320 * ordering of page lock and transaction start for journaling 1313 1321 * filesystems. 1314 1322 */ 1315 - if (i_size_changed || inline_data) 1323 + if (i_size_changed) 1316 1324 ret = ext4_mark_inode_dirty(handle, inode); 1317 1325 1318 1326 if (pos + len > inode->i_size && !verity && ext4_can_truncate(inode)) ··· 1321 1329 * inode->i_size. So truncate them 1322 1330 */ 1323 1331 ext4_orphan_add(handle, inode); 1324 - errout: 1332 + 1325 1333 ret2 = ext4_journal_stop(handle); 1326 1334 if (!ret) 1327 1335 ret = ret2; ··· 1387 1395 int partial = 0; 1388 1396 unsigned from, to; 1389 1397 int size_changed = 0; 1390 - int inline_data = ext4_has_inline_data(inode); 1391 1398 bool verity = ext4_verity_in_progress(inode); 1392 1399 1393 1400 trace_ext4_journalled_write_end(inode, pos, len, copied); ··· 1395 1404 1396 1405 BUG_ON(!ext4_handle_valid(handle)); 1397 1406 1398 - if (inline_data) { 1399 - ret = ext4_write_inline_data_end(inode, pos, len, 1400 - copied, page); 1401 - if (ret < 0) { 1402 - unlock_page(page); 1403 - put_page(page); 1404 - goto errout; 1405 - } 1406 - copied = ret; 1407 - } else if (unlikely(copied < len) && !PageUptodate(page)) { 1407 + if (ext4_has_inline_data(inode)) 1408 + return ext4_write_inline_data_end(inode, pos, len, copied, page); 1409 + 1410 + if (unlikely(copied < len) && !PageUptodate(page)) { 1408 1411 copied = 0; 1409 1412 ext4_journalled_zero_new_buffers(handle, inode, page, from, to); 1410 1413 } else { ··· 1421 1436 if (old_size < pos && !verity) 1422 1437 pagecache_isize_extended(inode, old_size, pos); 1423 1438 1424 - if (size_changed || inline_data) { 1439 + if (size_changed) { 1425 1440 ret2 = ext4_mark_inode_dirty(handle, inode); 1426 1441 if (!ret) 1427 1442 ret = ret2; ··· 1434 1449 */ 1435 1450 ext4_orphan_add(handle, inode); 1436 1451 1437 - errout: 1438 1452 ret2 = ext4_journal_stop(handle); 1439 1453 if (!ret) 1440 1454 ret = ret2; ··· 1628 1644 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 1629 1645 int ret; 1630 1646 bool allocated = false; 1647 + bool reserved = false; 1631 1648 1632 1649 /* 1633 1650 * If the cluster containing lblk is shared with a delayed, ··· 1645 1660 ret = ext4_da_reserve_space(inode); 1646 1661 if (ret != 0) /* ENOSPC */ 1647 1662 goto errout; 1663 + reserved = true; 1648 1664 } else { /* bigalloc */ 1649 1665 if (!ext4_es_scan_clu(inode, &ext4_es_is_delonly, lblk)) { 1650 1666 if (!ext4_es_scan_clu(inode, ··· 1658 1672 ret = ext4_da_reserve_space(inode); 1659 1673 if (ret != 0) /* ENOSPC */ 1660 1674 goto errout; 1675 + reserved = true; 1661 1676 } else { 1662 1677 allocated = true; 1663 1678 } ··· 1669 1682 } 1670 1683 1671 1684 ret = ext4_es_insert_delayed_block(inode, lblk, allocated); 1685 + if (ret && reserved) 1686 + ext4_da_release_space(inode, 1); 1672 1687 1673 1688 errout: 1674 1689 return ret; ··· 1711 1722 } 1712 1723 1713 1724 /* 1714 - * Delayed extent could be allocated by fallocate. 1715 - * So we need to check it. 1725 + * the buffer head associated with a delayed and not unwritten 1726 + * block found in the extent status cache must contain an 1727 + * invalid block number and have its BH_New and BH_Delay bits 1728 + * set, reflecting the state assigned when the block was 1729 + * initially delayed allocated 1716 1730 */ 1717 - if (ext4_es_is_delayed(&es) && !ext4_es_is_unwritten(&es)) { 1718 - map_bh(bh, inode->i_sb, invalid_block); 1719 - set_buffer_new(bh); 1720 - set_buffer_delay(bh); 1731 + if (ext4_es_is_delonly(&es)) { 1732 + BUG_ON(bh->b_blocknr != invalid_block); 1733 + BUG_ON(!buffer_new(bh)); 1734 + BUG_ON(!buffer_delay(bh)); 1721 1735 return 0; 1722 1736 } 1723 1737 ··· 2924 2932 return 0; 2925 2933 } 2926 2934 2927 - /* We always reserve for an inode update; the superblock could be there too */ 2928 - static int ext4_da_write_credits(struct inode *inode, loff_t pos, unsigned len) 2929 - { 2930 - if (likely(ext4_has_feature_large_file(inode->i_sb))) 2931 - return 1; 2932 - 2933 - if (pos + len <= 0x7fffffffULL) 2934 - return 1; 2935 - 2936 - /* We might need to update the superblock to set LARGE_FILE */ 2937 - return 2; 2938 - } 2939 - 2940 2935 static int ext4_da_write_begin(struct file *file, struct address_space *mapping, 2941 2936 loff_t pos, unsigned len, unsigned flags, 2942 2937 struct page **pagep, void **fsdata) ··· 2932 2953 struct page *page; 2933 2954 pgoff_t index; 2934 2955 struct inode *inode = mapping->host; 2935 - handle_t *handle; 2936 2956 2937 2957 if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 2938 2958 return -EIO; ··· 2957 2979 return 0; 2958 2980 } 2959 2981 2960 - /* 2961 - * grab_cache_page_write_begin() can take a long time if the 2962 - * system is thrashing due to memory pressure, or if the page 2963 - * is being written back. So grab it first before we start 2964 - * the transaction handle. This also allows us to allocate 2965 - * the page (if needed) without using GFP_NOFS. 2966 - */ 2967 - retry_grab: 2982 + retry: 2968 2983 page = grab_cache_page_write_begin(mapping, index, flags); 2969 2984 if (!page) 2970 2985 return -ENOMEM; 2971 - unlock_page(page); 2972 2986 2973 - /* 2974 - * With delayed allocation, we don't log the i_disksize update 2975 - * if there is delayed block allocation. But we still need 2976 - * to journalling the i_disksize update if writes to the end 2977 - * of file which has an already mapped buffer. 2978 - */ 2979 - retry_journal: 2980 - handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, 2981 - ext4_da_write_credits(inode, pos, len)); 2982 - if (IS_ERR(handle)) { 2983 - put_page(page); 2984 - return PTR_ERR(handle); 2985 - } 2986 - 2987 - lock_page(page); 2988 - if (page->mapping != mapping) { 2989 - /* The page got truncated from under us */ 2990 - unlock_page(page); 2991 - put_page(page); 2992 - ext4_journal_stop(handle); 2993 - goto retry_grab; 2994 - } 2995 2987 /* In case writeback began while the page was unlocked */ 2996 2988 wait_for_stable_page(page); 2997 2989 ··· 2973 3025 #endif 2974 3026 if (ret < 0) { 2975 3027 unlock_page(page); 2976 - ext4_journal_stop(handle); 3028 + put_page(page); 2977 3029 /* 2978 3030 * block_write_begin may have instantiated a few blocks 2979 3031 * outside i_size. Trim these off again. Don't need 2980 - * i_size_read because we hold i_mutex. 3032 + * i_size_read because we hold inode lock. 2981 3033 */ 2982 3034 if (pos + len > inode->i_size) 2983 3035 ext4_truncate_failed_write(inode); 2984 3036 2985 3037 if (ret == -ENOSPC && 2986 3038 ext4_should_retry_alloc(inode->i_sb, &retries)) 2987 - goto retry_journal; 2988 - 2989 - put_page(page); 3039 + goto retry; 2990 3040 return ret; 2991 3041 } 2992 3042 ··· 3021 3075 struct page *page, void *fsdata) 3022 3076 { 3023 3077 struct inode *inode = mapping->host; 3024 - int ret = 0, ret2; 3025 - handle_t *handle = ext4_journal_current_handle(); 3026 3078 loff_t new_i_size; 3027 3079 unsigned long start, end; 3028 3080 int write_mode = (int)(unsigned long)fsdata; ··· 3030 3086 len, copied, page, fsdata); 3031 3087 3032 3088 trace_ext4_da_write_end(inode, pos, len, copied); 3033 - start = pos & (PAGE_SIZE - 1); 3034 - end = start + copied - 1; 3035 - 3036 - /* 3037 - * generic_write_end() will run mark_inode_dirty() if i_size 3038 - * changes. So let's piggyback the i_disksize mark_inode_dirty 3039 - * into that. 3040 - */ 3041 - new_i_size = pos + copied; 3042 - if (copied && new_i_size > EXT4_I(inode)->i_disksize) { 3043 - if (ext4_has_inline_data(inode) || 3044 - ext4_da_should_update_i_disksize(page, end)) { 3045 - ext4_update_i_disksize(inode, new_i_size); 3046 - /* We need to mark inode dirty even if 3047 - * new_i_size is less that inode->i_size 3048 - * bu greater than i_disksize.(hint delalloc) 3049 - */ 3050 - ret = ext4_mark_inode_dirty(handle, inode); 3051 - } 3052 - } 3053 3089 3054 3090 if (write_mode != CONVERT_INLINE_DATA && 3055 3091 ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA) && 3056 3092 ext4_has_inline_data(inode)) 3057 - ret2 = ext4_da_write_inline_data_end(inode, pos, len, copied, 3058 - page); 3059 - else 3060 - ret2 = generic_write_end(file, mapping, pos, len, copied, 3061 - page, fsdata); 3093 + return ext4_write_inline_data_end(inode, pos, len, copied, page); 3062 3094 3063 - copied = ret2; 3064 - if (ret2 < 0) 3065 - ret = ret2; 3066 - ret2 = ext4_journal_stop(handle); 3067 - if (unlikely(ret2 && !ret)) 3068 - ret = ret2; 3095 + start = pos & (PAGE_SIZE - 1); 3096 + end = start + copied - 1; 3069 3097 3070 - return ret ? ret : copied; 3098 + /* 3099 + * Since we are holding inode lock, we are sure i_disksize <= 3100 + * i_size. We also know that if i_disksize < i_size, there are 3101 + * delalloc writes pending in the range upto i_size. If the end of 3102 + * the current write is <= i_size, there's no need to touch 3103 + * i_disksize since writeback will push i_disksize upto i_size 3104 + * eventually. If the end of the current write is > i_size and 3105 + * inside an allocated block (ext4_da_should_update_i_disksize() 3106 + * check), we need to update i_disksize here as neither 3107 + * ext4_writepage() nor certain ext4_writepages() paths not 3108 + * allocating blocks update i_disksize. 3109 + * 3110 + * Note that we defer inode dirtying to generic_write_end() / 3111 + * ext4_da_write_inline_data_end(). 3112 + */ 3113 + new_i_size = pos + copied; 3114 + if (copied && new_i_size > inode->i_size && 3115 + ext4_da_should_update_i_disksize(page, end)) 3116 + ext4_update_i_disksize(inode, new_i_size); 3117 + 3118 + return generic_write_end(file, mapping, pos, len, copied, page, fsdata); 3071 3119 } 3072 3120 3073 3121 /* ··· 4276 4340 goto has_buffer; 4277 4341 4278 4342 lock_buffer(bh); 4343 + if (ext4_buffer_uptodate(bh)) { 4344 + /* Someone brought it uptodate while we waited */ 4345 + unlock_buffer(bh); 4346 + goto has_buffer; 4347 + } 4348 + 4279 4349 /* 4280 4350 * If we have all information of the inode in memory and this 4281 4351 * is the only valid inode in the block, we need not read the
+15 -6
fs/ext4/super.c
··· 658 658 * constraints, it may not be safe to do it right here so we 659 659 * defer superblock flushing to a workqueue. 660 660 */ 661 - if (continue_fs) 661 + if (continue_fs && journal) 662 662 schedule_work(&EXT4_SB(sb)->s_error_work); 663 663 else 664 664 ext4_commit_super(sb); ··· 1350 1350 true); 1351 1351 dump_stack(); 1352 1352 } 1353 + 1354 + if (EXT4_I(inode)->i_reserved_data_blocks) 1355 + ext4_msg(inode->i_sb, KERN_ERR, 1356 + "Inode %lu (%p): i_reserved_data_blocks (%u) not cleared!", 1357 + inode->i_ino, EXT4_I(inode), 1358 + EXT4_I(inode)->i_reserved_data_blocks); 1353 1359 } 1354 1360 1355 1361 static void init_once(void *foo) ··· 3027 3021 */ 3028 3022 static loff_t ext4_max_bitmap_size(int bits, int has_huge_files) 3029 3023 { 3030 - loff_t res = EXT4_NDIR_BLOCKS; 3024 + unsigned long long upper_limit, res = EXT4_NDIR_BLOCKS; 3031 3025 int meta_blocks; 3032 - loff_t upper_limit; 3033 - /* This is calculated to be the largest file size for a dense, block 3026 + 3027 + /* 3028 + * This is calculated to be the largest file size for a dense, block 3034 3029 * mapped file such that the file's total number of 512-byte sectors, 3035 3030 * including data and all indirect blocks, does not exceed (2^48 - 1). 3036 3031 * 3037 3032 * __u32 i_blocks_lo and _u16 i_blocks_high represent the total 3038 3033 * number of 512-byte sectors of the file. 3039 3034 */ 3040 - 3041 3035 if (!has_huge_files) { 3042 3036 /* 3043 3037 * !has_huge_files or implies that the inode i_block field ··· 3080 3074 if (res > MAX_LFS_FILESIZE) 3081 3075 res = MAX_LFS_FILESIZE; 3082 3076 3083 - return res; 3077 + return (loff_t)res; 3084 3078 } 3085 3079 3086 3080 static ext4_fsblk_t descriptor_loc(struct super_block *sb, ··· 5048 5042 sbi->s_ea_block_cache = NULL; 5049 5043 5050 5044 if (sbi->s_journal) { 5045 + /* flush s_error_work before journal destroy. */ 5046 + flush_work(&sbi->s_error_work); 5051 5047 jbd2_journal_destroy(sbi->s_journal); 5052 5048 sbi->s_journal = NULL; 5053 5049 } 5054 5050 failed_mount3a: 5055 5051 ext4_es_unregister_shrinker(sbi); 5056 5052 failed_mount3: 5053 + /* flush s_error_work before sbi destroy */ 5057 5054 flush_work(&sbi->s_error_work); 5058 5055 del_timer_sync(&sbi->s_err_report); 5059 5056 ext4_stop_mmpd(sbi);
+1 -4
fs/io-wq.c
··· 584 584 585 585 if (!get_signal(&ksig)) 586 586 continue; 587 - if (fatal_signal_pending(current) || 588 - signal_group_exit(current->signal)) 589 - break; 590 - continue; 587 + break; 591 588 } 592 589 last_timeout = !ret; 593 590 }
+2 -15
fs/io_uring.c
··· 403 403 struct wait_queue_head cq_wait; 404 404 unsigned cq_extra; 405 405 atomic_t cq_timeouts; 406 - struct fasync_struct *cq_fasync; 407 406 unsigned cq_last_tm_flush; 408 407 } ____cacheline_aligned_in_smp; 409 408 ··· 1613 1614 wake_up(&ctx->sq_data->wait); 1614 1615 if (io_should_trigger_evfd(ctx)) 1615 1616 eventfd_signal(ctx->cq_ev_fd, 1); 1616 - if (waitqueue_active(&ctx->poll_wait)) { 1617 + if (waitqueue_active(&ctx->poll_wait)) 1617 1618 wake_up_interruptible(&ctx->poll_wait); 1618 - kill_fasync(&ctx->cq_fasync, SIGIO, POLL_IN); 1619 - } 1620 1619 } 1621 1620 1622 1621 static void io_cqring_ev_posted_iopoll(struct io_ring_ctx *ctx) ··· 1628 1631 } 1629 1632 if (io_should_trigger_evfd(ctx)) 1630 1633 eventfd_signal(ctx->cq_ev_fd, 1); 1631 - if (waitqueue_active(&ctx->poll_wait)) { 1634 + if (waitqueue_active(&ctx->poll_wait)) 1632 1635 wake_up_interruptible(&ctx->poll_wait); 1633 - kill_fasync(&ctx->cq_fasync, SIGIO, POLL_IN); 1634 - } 1635 1636 } 1636 1637 1637 1638 /* Returns true if there are no backlogged entries after the flush */ ··· 9340 9345 return mask; 9341 9346 } 9342 9347 9343 - static int io_uring_fasync(int fd, struct file *file, int on) 9344 - { 9345 - struct io_ring_ctx *ctx = file->private_data; 9346 - 9347 - return fasync_helper(fd, file, on, &ctx->cq_fasync); 9348 - } 9349 - 9350 9348 static int io_unregister_personality(struct io_ring_ctx *ctx, unsigned id) 9351 9349 { 9352 9350 const struct cred *creds; ··· 10133 10145 .mmap_capabilities = io_uring_nommu_mmap_capabilities, 10134 10146 #endif 10135 10147 .poll = io_uring_poll, 10136 - .fasync = io_uring_fasync, 10137 10148 #ifdef CONFIG_PROC_FS 10138 10149 .show_fdinfo = io_uring_show_fdinfo, 10139 10150 #endif
+7 -2
fs/kernfs/dir.c
··· 1116 1116 if (!inode) 1117 1117 inode = ERR_PTR(-ENOMEM); 1118 1118 } 1119 - /* Needed only for negative dentry validation */ 1120 - if (!inode) 1119 + /* 1120 + * Needed for negative dentry validation. 1121 + * The negative dentry can be created in kernfs_iop_lookup() 1122 + * or transforms from positive dentry in dentry_unlink_inode() 1123 + * called from vfs_rmdir(). 1124 + */ 1125 + if (!IS_ERR(inode)) 1121 1126 kernfs_set_rev(parent, dentry); 1122 1127 up_read(&kernfs_rwsem); 1123 1128
-205
fs/ksmbd/auth.c
··· 68 68 memcpy(buf, NEGOTIATE_GSS_HEADER, AUTH_GSS_LENGTH); 69 69 } 70 70 71 - static void 72 - str_to_key(unsigned char *str, unsigned char *key) 73 - { 74 - int i; 75 - 76 - key[0] = str[0] >> 1; 77 - key[1] = ((str[0] & 0x01) << 6) | (str[1] >> 2); 78 - key[2] = ((str[1] & 0x03) << 5) | (str[2] >> 3); 79 - key[3] = ((str[2] & 0x07) << 4) | (str[3] >> 4); 80 - key[4] = ((str[3] & 0x0F) << 3) | (str[4] >> 5); 81 - key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6); 82 - key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7); 83 - key[7] = str[6] & 0x7F; 84 - for (i = 0; i < 8; i++) 85 - key[i] = (key[i] << 1); 86 - } 87 - 88 - static int 89 - smbhash(unsigned char *out, const unsigned char *in, unsigned char *key) 90 - { 91 - unsigned char key2[8]; 92 - struct des_ctx ctx; 93 - 94 - if (fips_enabled) { 95 - ksmbd_debug(AUTH, "FIPS compliance enabled: DES not permitted\n"); 96 - return -ENOENT; 97 - } 98 - 99 - str_to_key(key, key2); 100 - des_expand_key(&ctx, key2, DES_KEY_SIZE); 101 - des_encrypt(&ctx, out, in); 102 - memzero_explicit(&ctx, sizeof(ctx)); 103 - return 0; 104 - } 105 - 106 - static int ksmbd_enc_p24(unsigned char *p21, const unsigned char *c8, unsigned char *p24) 107 - { 108 - int rc; 109 - 110 - rc = smbhash(p24, c8, p21); 111 - if (rc) 112 - return rc; 113 - rc = smbhash(p24 + 8, c8, p21 + 7); 114 - if (rc) 115 - return rc; 116 - return smbhash(p24 + 16, c8, p21 + 14); 117 - } 118 - 119 - /* produce a md4 message digest from data of length n bytes */ 120 - static int ksmbd_enc_md4(unsigned char *md4_hash, unsigned char *link_str, 121 - int link_len) 122 - { 123 - int rc; 124 - struct ksmbd_crypto_ctx *ctx; 125 - 126 - ctx = ksmbd_crypto_ctx_find_md4(); 127 - if (!ctx) { 128 - ksmbd_debug(AUTH, "Crypto md4 allocation error\n"); 129 - return -ENOMEM; 130 - } 131 - 132 - rc = crypto_shash_init(CRYPTO_MD4(ctx)); 133 - if (rc) { 134 - ksmbd_debug(AUTH, "Could not init md4 shash\n"); 135 - goto out; 136 - } 137 - 138 - rc = crypto_shash_update(CRYPTO_MD4(ctx), link_str, link_len); 139 - if (rc) { 140 - ksmbd_debug(AUTH, "Could not update with link_str\n"); 141 - goto out; 142 - } 143 - 144 - rc = crypto_shash_final(CRYPTO_MD4(ctx), md4_hash); 145 - if (rc) 146 - ksmbd_debug(AUTH, "Could not generate md4 hash\n"); 147 - out: 148 - ksmbd_release_crypto_ctx(ctx); 149 - return rc; 150 - } 151 - 152 - static int ksmbd_enc_update_sess_key(unsigned char *md5_hash, char *nonce, 153 - char *server_challenge, int len) 154 - { 155 - int rc; 156 - struct ksmbd_crypto_ctx *ctx; 157 - 158 - ctx = ksmbd_crypto_ctx_find_md5(); 159 - if (!ctx) { 160 - ksmbd_debug(AUTH, "Crypto md5 allocation error\n"); 161 - return -ENOMEM; 162 - } 163 - 164 - rc = crypto_shash_init(CRYPTO_MD5(ctx)); 165 - if (rc) { 166 - ksmbd_debug(AUTH, "Could not init md5 shash\n"); 167 - goto out; 168 - } 169 - 170 - rc = crypto_shash_update(CRYPTO_MD5(ctx), server_challenge, len); 171 - if (rc) { 172 - ksmbd_debug(AUTH, "Could not update with challenge\n"); 173 - goto out; 174 - } 175 - 176 - rc = crypto_shash_update(CRYPTO_MD5(ctx), nonce, len); 177 - if (rc) { 178 - ksmbd_debug(AUTH, "Could not update with nonce\n"); 179 - goto out; 180 - } 181 - 182 - rc = crypto_shash_final(CRYPTO_MD5(ctx), md5_hash); 183 - if (rc) 184 - ksmbd_debug(AUTH, "Could not generate md5 hash\n"); 185 - out: 186 - ksmbd_release_crypto_ctx(ctx); 187 - return rc; 188 - } 189 - 190 71 /** 191 72 * ksmbd_gen_sess_key() - function to generate session key 192 73 * @sess: session of connection ··· 206 325 } 207 326 208 327 /** 209 - * ksmbd_auth_ntlm() - NTLM authentication handler 210 - * @sess: session of connection 211 - * @pw_buf: NTLM challenge response 212 - * @passkey: user password 213 - * 214 - * Return: 0 on success, error number on error 215 - */ 216 - int ksmbd_auth_ntlm(struct ksmbd_session *sess, char *pw_buf) 217 - { 218 - int rc; 219 - unsigned char p21[21]; 220 - char key[CIFS_AUTH_RESP_SIZE]; 221 - 222 - memset(p21, '\0', 21); 223 - memcpy(p21, user_passkey(sess->user), CIFS_NTHASH_SIZE); 224 - rc = ksmbd_enc_p24(p21, sess->ntlmssp.cryptkey, key); 225 - if (rc) { 226 - pr_err("password processing failed\n"); 227 - return rc; 228 - } 229 - 230 - ksmbd_enc_md4(sess->sess_key, user_passkey(sess->user), 231 - CIFS_SMB1_SESSKEY_SIZE); 232 - memcpy(sess->sess_key + CIFS_SMB1_SESSKEY_SIZE, key, 233 - CIFS_AUTH_RESP_SIZE); 234 - sess->sequence_number = 1; 235 - 236 - if (strncmp(pw_buf, key, CIFS_AUTH_RESP_SIZE) != 0) { 237 - ksmbd_debug(AUTH, "ntlmv1 authentication failed\n"); 238 - return -EINVAL; 239 - } 240 - 241 - ksmbd_debug(AUTH, "ntlmv1 authentication pass\n"); 242 - return 0; 243 - } 244 - 245 - /** 246 328 * ksmbd_auth_ntlmv2() - NTLMv2 authentication handler 247 329 * @sess: session of connection 248 330 * @ntlmv2: NTLMv2 challenge response ··· 286 442 } 287 443 288 444 /** 289 - * __ksmbd_auth_ntlmv2() - NTLM2(extended security) authentication handler 290 - * @sess: session of connection 291 - * @client_nonce: client nonce from LM response. 292 - * @ntlm_resp: ntlm response data from client. 293 - * 294 - * Return: 0 on success, error number on error 295 - */ 296 - static int __ksmbd_auth_ntlmv2(struct ksmbd_session *sess, char *client_nonce, 297 - char *ntlm_resp) 298 - { 299 - char sess_key[CIFS_SMB1_SESSKEY_SIZE] = {0}; 300 - int rc; 301 - unsigned char p21[21]; 302 - char key[CIFS_AUTH_RESP_SIZE]; 303 - 304 - rc = ksmbd_enc_update_sess_key(sess_key, 305 - client_nonce, 306 - (char *)sess->ntlmssp.cryptkey, 8); 307 - if (rc) { 308 - pr_err("password processing failed\n"); 309 - goto out; 310 - } 311 - 312 - memset(p21, '\0', 21); 313 - memcpy(p21, user_passkey(sess->user), CIFS_NTHASH_SIZE); 314 - rc = ksmbd_enc_p24(p21, sess_key, key); 315 - if (rc) { 316 - pr_err("password processing failed\n"); 317 - goto out; 318 - } 319 - 320 - if (memcmp(ntlm_resp, key, CIFS_AUTH_RESP_SIZE) != 0) 321 - rc = -EINVAL; 322 - out: 323 - return rc; 324 - } 325 - 326 - /** 327 445 * ksmbd_decode_ntlmssp_auth_blob() - helper function to construct 328 446 * authenticate blob 329 447 * @authblob: authenticate blob source pointer ··· 317 511 lm_off = le32_to_cpu(authblob->LmChallengeResponse.BufferOffset); 318 512 nt_off = le32_to_cpu(authblob->NtChallengeResponse.BufferOffset); 319 513 nt_len = le16_to_cpu(authblob->NtChallengeResponse.Length); 320 - 321 - /* process NTLM authentication */ 322 - if (nt_len == CIFS_AUTH_RESP_SIZE) { 323 - if (le32_to_cpu(authblob->NegotiateFlags) & 324 - NTLMSSP_NEGOTIATE_EXTENDED_SEC) 325 - return __ksmbd_auth_ntlmv2(sess, (char *)authblob + 326 - lm_off, (char *)authblob + nt_off); 327 - else 328 - return ksmbd_auth_ntlm(sess, (char *)authblob + 329 - nt_off); 330 - } 331 514 332 515 /* TODO : use domain name that imported from configuration file */ 333 516 domain_name = smb_strndup_from_utf16((const char *)authblob +
-16
fs/ksmbd/crypto_ctx.c
··· 81 81 case CRYPTO_SHASH_SHA512: 82 82 tfm = crypto_alloc_shash("sha512", 0, 0); 83 83 break; 84 - case CRYPTO_SHASH_MD4: 85 - tfm = crypto_alloc_shash("md4", 0, 0); 86 - break; 87 - case CRYPTO_SHASH_MD5: 88 - tfm = crypto_alloc_shash("md5", 0, 0); 89 - break; 90 84 default: 91 85 return NULL; 92 86 } ··· 206 212 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha512(void) 207 213 { 208 214 return ____crypto_shash_ctx_find(CRYPTO_SHASH_SHA512); 209 - } 210 - 211 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md4(void) 212 - { 213 - return ____crypto_shash_ctx_find(CRYPTO_SHASH_MD4); 214 - } 215 - 216 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md5(void) 217 - { 218 - return ____crypto_shash_ctx_find(CRYPTO_SHASH_MD5); 219 215 } 220 216 221 217 static struct ksmbd_crypto_ctx *____crypto_aead_ctx_find(int id)
-8
fs/ksmbd/crypto_ctx.h
··· 15 15 CRYPTO_SHASH_CMACAES, 16 16 CRYPTO_SHASH_SHA256, 17 17 CRYPTO_SHASH_SHA512, 18 - CRYPTO_SHASH_MD4, 19 - CRYPTO_SHASH_MD5, 20 18 CRYPTO_SHASH_MAX, 21 19 }; 22 20 ··· 41 43 #define CRYPTO_CMACAES(c) ((c)->desc[CRYPTO_SHASH_CMACAES]) 42 44 #define CRYPTO_SHA256(c) ((c)->desc[CRYPTO_SHASH_SHA256]) 43 45 #define CRYPTO_SHA512(c) ((c)->desc[CRYPTO_SHASH_SHA512]) 44 - #define CRYPTO_MD4(c) ((c)->desc[CRYPTO_SHASH_MD4]) 45 - #define CRYPTO_MD5(c) ((c)->desc[CRYPTO_SHASH_MD5]) 46 46 47 47 #define CRYPTO_HMACMD5_TFM(c) ((c)->desc[CRYPTO_SHASH_HMACMD5]->tfm) 48 48 #define CRYPTO_HMACSHA256_TFM(c)\ ··· 48 52 #define CRYPTO_CMACAES_TFM(c) ((c)->desc[CRYPTO_SHASH_CMACAES]->tfm) 49 53 #define CRYPTO_SHA256_TFM(c) ((c)->desc[CRYPTO_SHASH_SHA256]->tfm) 50 54 #define CRYPTO_SHA512_TFM(c) ((c)->desc[CRYPTO_SHASH_SHA512]->tfm) 51 - #define CRYPTO_MD4_TFM(c) ((c)->desc[CRYPTO_SHASH_MD4]->tfm) 52 - #define CRYPTO_MD5_TFM(c) ((c)->desc[CRYPTO_SHASH_MD5]->tfm) 53 55 54 56 #define CRYPTO_GCM(c) ((c)->ccmaes[CRYPTO_AEAD_AES_GCM]) 55 57 #define CRYPTO_CCM(c) ((c)->ccmaes[CRYPTO_AEAD_AES_CCM]) ··· 58 64 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_cmacaes(void); 59 65 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha512(void); 60 66 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha256(void); 61 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md4(void); 62 - struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md5(void); 63 67 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_gcm(void); 64 68 struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_ccm(void); 65 69 void ksmbd_crypto_destroy(void);
+7 -10
fs/ksmbd/misc.c
··· 162 162 { 163 163 char *ab_pathname; 164 164 165 - if (strlen(filename) == 0) { 166 - ab_pathname = kmalloc(2, GFP_KERNEL); 167 - ab_pathname[0] = '\\'; 168 - ab_pathname[1] = '\0'; 169 - } else { 170 - ab_pathname = kstrdup(filename, GFP_KERNEL); 171 - if (!ab_pathname) 172 - return NULL; 165 + if (strlen(filename) == 0) 166 + filename = "\\"; 173 167 174 - ksmbd_conv_path_to_windows(ab_pathname); 175 - } 168 + ab_pathname = kstrdup(filename, GFP_KERNEL); 169 + if (!ab_pathname) 170 + return NULL; 171 + 172 + ksmbd_conv_path_to_windows(ab_pathname); 176 173 return ab_pathname; 177 174 } 178 175
+31 -10
fs/ksmbd/oplock.c
··· 1451 1451 */ 1452 1452 struct create_context *smb2_find_context_vals(void *open_req, const char *tag) 1453 1453 { 1454 - char *data_offset; 1455 1454 struct create_context *cc; 1456 1455 unsigned int next = 0; 1457 1456 char *name; 1458 1457 struct smb2_create_req *req = (struct smb2_create_req *)open_req; 1458 + unsigned int remain_len, name_off, name_len, value_off, value_len, 1459 + cc_len; 1459 1460 1460 - data_offset = (char *)req + 4 + le32_to_cpu(req->CreateContextsOffset); 1461 - cc = (struct create_context *)data_offset; 1461 + /* 1462 + * CreateContextsOffset and CreateContextsLength are guaranteed to 1463 + * be valid because of ksmbd_smb2_check_message(). 1464 + */ 1465 + cc = (struct create_context *)((char *)req + 4 + 1466 + le32_to_cpu(req->CreateContextsOffset)); 1467 + remain_len = le32_to_cpu(req->CreateContextsLength); 1462 1468 do { 1463 - int val; 1464 - 1465 1469 cc = (struct create_context *)((char *)cc + next); 1466 - name = le16_to_cpu(cc->NameOffset) + (char *)cc; 1467 - val = le16_to_cpu(cc->NameLength); 1468 - if (val < 4) 1470 + if (remain_len < offsetof(struct create_context, Buffer)) 1469 1471 return ERR_PTR(-EINVAL); 1470 1472 1471 - if (memcmp(name, tag, val) == 0) 1472 - return cc; 1473 1473 next = le32_to_cpu(cc->Next); 1474 + name_off = le16_to_cpu(cc->NameOffset); 1475 + name_len = le16_to_cpu(cc->NameLength); 1476 + value_off = le16_to_cpu(cc->DataOffset); 1477 + value_len = le32_to_cpu(cc->DataLength); 1478 + cc_len = next ? next : remain_len; 1479 + 1480 + if ((next & 0x7) != 0 || 1481 + next > remain_len || 1482 + name_off != offsetof(struct create_context, Buffer) || 1483 + name_len < 4 || 1484 + name_off + name_len > cc_len || 1485 + (value_off & 0x7) != 0 || 1486 + (value_off && (value_off < name_off + name_len)) || 1487 + ((u64)value_off + value_len > cc_len)) 1488 + return ERR_PTR(-EINVAL); 1489 + 1490 + name = (char *)cc + name_off; 1491 + if (memcmp(name, tag, name_len) == 0) 1492 + return cc; 1493 + 1494 + remain_len -= next; 1474 1495 } while (next != 0); 1475 1496 1476 1497 return NULL;
+197 -61
fs/ksmbd/smb2pdu.c
··· 459 459 bool is_chained_smb2_message(struct ksmbd_work *work) 460 460 { 461 461 struct smb2_hdr *hdr = work->request_buf; 462 - unsigned int len; 462 + unsigned int len, next_cmd; 463 463 464 464 if (hdr->ProtocolId != SMB2_PROTO_NUMBER) 465 465 return false; 466 466 467 467 hdr = ksmbd_req_buf_next(work); 468 - if (le32_to_cpu(hdr->NextCommand) > 0) { 468 + next_cmd = le32_to_cpu(hdr->NextCommand); 469 + if (next_cmd > 0) { 470 + if ((u64)work->next_smb2_rcv_hdr_off + next_cmd + 471 + __SMB2_HEADER_STRUCTURE_SIZE > 472 + get_rfc1002_len(work->request_buf)) { 473 + pr_err("next command(%u) offset exceeds smb msg size\n", 474 + next_cmd); 475 + return false; 476 + } 477 + 469 478 ksmbd_debug(SMB, "got SMB2 chained command\n"); 470 479 init_chained_smb2_rsp(work); 471 480 return true; ··· 1067 1058 struct smb2_negotiate_req *req = work->request_buf; 1068 1059 struct smb2_negotiate_rsp *rsp = work->response_buf; 1069 1060 int rc = 0; 1061 + unsigned int smb2_buf_len, smb2_neg_size; 1070 1062 __le32 status; 1071 1063 1072 1064 ksmbd_debug(SMB, "Received negotiate request\n"); ··· 1083 1073 rsp->hdr.Status = STATUS_INVALID_PARAMETER; 1084 1074 rc = -EINVAL; 1085 1075 goto err_out; 1076 + } 1077 + 1078 + smb2_buf_len = get_rfc1002_len(work->request_buf); 1079 + smb2_neg_size = offsetof(struct smb2_negotiate_req, Dialects) - 4; 1080 + if (smb2_neg_size > smb2_buf_len) { 1081 + rsp->hdr.Status = STATUS_INVALID_PARAMETER; 1082 + rc = -EINVAL; 1083 + goto err_out; 1084 + } 1085 + 1086 + if (conn->dialect == SMB311_PROT_ID) { 1087 + unsigned int nego_ctxt_off = le32_to_cpu(req->NegotiateContextOffset); 1088 + 1089 + if (smb2_buf_len < nego_ctxt_off) { 1090 + rsp->hdr.Status = STATUS_INVALID_PARAMETER; 1091 + rc = -EINVAL; 1092 + goto err_out; 1093 + } 1094 + 1095 + if (smb2_neg_size > nego_ctxt_off) { 1096 + rsp->hdr.Status = STATUS_INVALID_PARAMETER; 1097 + rc = -EINVAL; 1098 + goto err_out; 1099 + } 1100 + 1101 + if (smb2_neg_size + le16_to_cpu(req->DialectCount) * sizeof(__le16) > 1102 + nego_ctxt_off) { 1103 + rsp->hdr.Status = STATUS_INVALID_PARAMETER; 1104 + rc = -EINVAL; 1105 + goto err_out; 1106 + } 1107 + } else { 1108 + if (smb2_neg_size + le16_to_cpu(req->DialectCount) * sizeof(__le16) > 1109 + smb2_buf_len) { 1110 + rsp->hdr.Status = STATUS_INVALID_PARAMETER; 1111 + rc = -EINVAL; 1112 + goto err_out; 1113 + } 1086 1114 } 1087 1115 1088 1116 conn->cli_cap = le32_to_cpu(req->Capabilities); ··· 2141 2093 * smb2_set_ea() - handler for setting extended attributes using set 2142 2094 * info command 2143 2095 * @eabuf: set info command buffer 2096 + * @buf_len: set info command buffer length 2144 2097 * @path: dentry path for get ea 2145 2098 * 2146 2099 * Return: 0 on success, otherwise error 2147 2100 */ 2148 - static int smb2_set_ea(struct smb2_ea_info *eabuf, struct path *path) 2101 + static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, 2102 + struct path *path) 2149 2103 { 2150 2104 struct user_namespace *user_ns = mnt_user_ns(path->mnt); 2151 2105 char *attr_name = NULL, *value; 2152 2106 int rc = 0; 2153 - int next = 0; 2107 + unsigned int next = 0; 2108 + 2109 + if (buf_len < sizeof(struct smb2_ea_info) + eabuf->EaNameLength + 2110 + le16_to_cpu(eabuf->EaValueLength)) 2111 + return -EINVAL; 2154 2112 2155 2113 attr_name = kmalloc(XATTR_NAME_MAX + 1, GFP_KERNEL); 2156 2114 if (!attr_name) ··· 2221 2167 2222 2168 next: 2223 2169 next = le32_to_cpu(eabuf->NextEntryOffset); 2170 + if (next == 0 || buf_len < next) 2171 + break; 2172 + buf_len -= next; 2224 2173 eabuf = (struct smb2_ea_info *)((char *)eabuf + next); 2174 + if (next < (u32)eabuf->EaNameLength + le16_to_cpu(eabuf->EaValueLength)) 2175 + break; 2176 + 2225 2177 } while (next != 0); 2226 2178 2227 2179 kfree(attr_name); ··· 2427 2367 ksmbd_debug(SMB, 2428 2368 "Set ACLs using SMB2_CREATE_SD_BUFFER context\n"); 2429 2369 sd_buf = (struct create_sd_buf_req *)context; 2370 + if (le16_to_cpu(context->DataOffset) + 2371 + le32_to_cpu(context->DataLength) < 2372 + sizeof(struct create_sd_buf_req)) 2373 + return -EINVAL; 2430 2374 return set_info_sec(work->conn, work->tcon, path, &sd_buf->ntsd, 2431 2375 le32_to_cpu(sd_buf->ccontext.DataLength), true); 2432 2376 } ··· 2625 2561 goto err_out1; 2626 2562 } else if (context) { 2627 2563 ea_buf = (struct create_ea_buf_req *)context; 2564 + if (le16_to_cpu(context->DataOffset) + 2565 + le32_to_cpu(context->DataLength) < 2566 + sizeof(struct create_ea_buf_req)) { 2567 + rc = -EINVAL; 2568 + goto err_out1; 2569 + } 2628 2570 if (req->CreateOptions & FILE_NO_EA_KNOWLEDGE_LE) { 2629 2571 rsp->hdr.Status = STATUS_ACCESS_DENIED; 2630 2572 rc = -EACCES; ··· 2669 2599 } else if (context) { 2670 2600 struct create_posix *posix = 2671 2601 (struct create_posix *)context; 2602 + if (le16_to_cpu(context->DataOffset) + 2603 + le32_to_cpu(context->DataLength) < 2604 + sizeof(struct create_posix)) { 2605 + rc = -EINVAL; 2606 + goto err_out1; 2607 + } 2672 2608 ksmbd_debug(SMB, "get posix context\n"); 2673 2609 2674 2610 posix_mode = le32_to_cpu(posix->Mode); ··· 2824 2748 created = true; 2825 2749 user_ns = mnt_user_ns(path.mnt); 2826 2750 if (ea_buf) { 2827 - rc = smb2_set_ea(&ea_buf->ea, &path); 2751 + if (le32_to_cpu(ea_buf->ccontext.DataLength) < 2752 + sizeof(struct smb2_ea_info)) { 2753 + rc = -EINVAL; 2754 + goto err_out; 2755 + } 2756 + 2757 + rc = smb2_set_ea(&ea_buf->ea, 2758 + le32_to_cpu(ea_buf->ccontext.DataLength), 2759 + &path); 2828 2760 if (rc == -EOPNOTSUPP) 2829 2761 rc = 0; 2830 2762 else if (rc) ··· 3065 2981 rc = PTR_ERR(az_req); 3066 2982 goto err_out; 3067 2983 } else if (az_req) { 3068 - loff_t alloc_size = le64_to_cpu(az_req->AllocationSize); 2984 + loff_t alloc_size; 3069 2985 int err; 3070 2986 2987 + if (le16_to_cpu(az_req->ccontext.DataOffset) + 2988 + le32_to_cpu(az_req->ccontext.DataLength) < 2989 + sizeof(struct create_alloc_size_req)) { 2990 + rc = -EINVAL; 2991 + goto err_out; 2992 + } 2993 + alloc_size = le64_to_cpu(az_req->AllocationSize); 3071 2994 ksmbd_debug(SMB, 3072 2995 "request smb2 create allocate size : %llu\n", 3073 2996 alloc_size); ··· 4243 4152 static int get_file_basic_info(struct smb2_query_info_rsp *rsp, 4244 4153 struct ksmbd_file *fp, void *rsp_org) 4245 4154 { 4246 - struct smb2_file_all_info *basic_info; 4155 + struct smb2_file_basic_info *basic_info; 4247 4156 struct kstat stat; 4248 4157 u64 time; 4249 4158 ··· 4253 4162 return -EACCES; 4254 4163 } 4255 4164 4256 - basic_info = (struct smb2_file_all_info *)rsp->Buffer; 4165 + basic_info = (struct smb2_file_basic_info *)rsp->Buffer; 4257 4166 generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), 4258 4167 &stat); 4259 4168 basic_info->CreationTime = cpu_to_le64(fp->create_time); ··· 4266 4175 basic_info->Attributes = fp->f_ci->m_fattr; 4267 4176 basic_info->Pad1 = 0; 4268 4177 rsp->OutputBufferLength = 4269 - cpu_to_le32(offsetof(struct smb2_file_all_info, AllocationSize)); 4270 - inc_rfc1001_len(rsp_org, offsetof(struct smb2_file_all_info, 4271 - AllocationSize)); 4178 + cpu_to_le32(sizeof(struct smb2_file_basic_info)); 4179 + inc_rfc1001_len(rsp_org, sizeof(struct smb2_file_basic_info)); 4272 4180 return 0; 4273 4181 } 4274 4182 ··· 5423 5333 static int smb2_create_link(struct ksmbd_work *work, 5424 5334 struct ksmbd_share_config *share, 5425 5335 struct smb2_file_link_info *file_info, 5426 - struct file *filp, 5336 + unsigned int buf_len, struct file *filp, 5427 5337 struct nls_table *local_nls) 5428 5338 { 5429 5339 char *link_name = NULL, *target_name = NULL, *pathname = NULL; 5430 5340 struct path path; 5431 5341 bool file_present = true; 5432 5342 int rc; 5343 + 5344 + if (buf_len < (u64)sizeof(struct smb2_file_link_info) + 5345 + le32_to_cpu(file_info->FileNameLength)) 5346 + return -EINVAL; 5433 5347 5434 5348 ksmbd_debug(SMB, "setting FILE_LINK_INFORMATION\n"); 5435 5349 pathname = kmalloc(PATH_MAX, GFP_KERNEL); ··· 5494 5400 return rc; 5495 5401 } 5496 5402 5497 - static int set_file_basic_info(struct ksmbd_file *fp, char *buf, 5403 + static int set_file_basic_info(struct ksmbd_file *fp, 5404 + struct smb2_file_basic_info *file_info, 5498 5405 struct ksmbd_share_config *share) 5499 5406 { 5500 - struct smb2_file_all_info *file_info; 5501 5407 struct iattr attrs; 5502 5408 struct timespec64 ctime; 5503 5409 struct file *filp; ··· 5508 5414 if (!(fp->daccess & FILE_WRITE_ATTRIBUTES_LE)) 5509 5415 return -EACCES; 5510 5416 5511 - file_info = (struct smb2_file_all_info *)buf; 5512 5417 attrs.ia_valid = 0; 5513 5418 filp = fp->filp; 5514 5419 inode = file_inode(filp); ··· 5584 5491 } 5585 5492 5586 5493 static int set_file_allocation_info(struct ksmbd_work *work, 5587 - struct ksmbd_file *fp, char *buf) 5494 + struct ksmbd_file *fp, 5495 + struct smb2_file_alloc_info *file_alloc_info) 5588 5496 { 5589 5497 /* 5590 5498 * TODO : It's working fine only when store dos attributes ··· 5593 5499 * properly with any smb.conf option 5594 5500 */ 5595 5501 5596 - struct smb2_file_alloc_info *file_alloc_info; 5597 5502 loff_t alloc_blks; 5598 5503 struct inode *inode; 5599 5504 int rc; ··· 5600 5507 if (!(fp->daccess & FILE_WRITE_DATA_LE)) 5601 5508 return -EACCES; 5602 5509 5603 - file_alloc_info = (struct smb2_file_alloc_info *)buf; 5604 5510 alloc_blks = (le64_to_cpu(file_alloc_info->AllocationSize) + 511) >> 9; 5605 5511 inode = file_inode(fp->filp); 5606 5512 ··· 5635 5543 } 5636 5544 5637 5545 static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp, 5638 - char *buf) 5546 + struct smb2_file_eof_info *file_eof_info) 5639 5547 { 5640 - struct smb2_file_eof_info *file_eof_info; 5641 5548 loff_t newsize; 5642 5549 struct inode *inode; 5643 5550 int rc; ··· 5644 5553 if (!(fp->daccess & FILE_WRITE_DATA_LE)) 5645 5554 return -EACCES; 5646 5555 5647 - file_eof_info = (struct smb2_file_eof_info *)buf; 5648 5556 newsize = le64_to_cpu(file_eof_info->EndOfFile); 5649 5557 inode = file_inode(fp->filp); 5650 5558 ··· 5670 5580 } 5671 5581 5672 5582 static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp, 5673 - char *buf) 5583 + struct smb2_file_rename_info *rename_info, 5584 + unsigned int buf_len) 5674 5585 { 5675 5586 struct user_namespace *user_ns; 5676 5587 struct ksmbd_file *parent_fp; ··· 5683 5592 pr_err("no right to delete : 0x%x\n", fp->daccess); 5684 5593 return -EACCES; 5685 5594 } 5595 + 5596 + if (buf_len < (u64)sizeof(struct smb2_file_rename_info) + 5597 + le32_to_cpu(rename_info->FileNameLength)) 5598 + return -EINVAL; 5686 5599 5687 5600 user_ns = file_mnt_user_ns(fp->filp); 5688 5601 if (ksmbd_stream_fd(fp)) ··· 5710 5615 } 5711 5616 } 5712 5617 next: 5713 - return smb2_rename(work, fp, user_ns, 5714 - (struct smb2_file_rename_info *)buf, 5618 + return smb2_rename(work, fp, user_ns, rename_info, 5715 5619 work->sess->conn->local_nls); 5716 5620 } 5717 5621 5718 - static int set_file_disposition_info(struct ksmbd_file *fp, char *buf) 5622 + static int set_file_disposition_info(struct ksmbd_file *fp, 5623 + struct smb2_file_disposition_info *file_info) 5719 5624 { 5720 - struct smb2_file_disposition_info *file_info; 5721 5625 struct inode *inode; 5722 5626 5723 5627 if (!(fp->daccess & FILE_DELETE_LE)) { ··· 5725 5631 } 5726 5632 5727 5633 inode = file_inode(fp->filp); 5728 - file_info = (struct smb2_file_disposition_info *)buf; 5729 5634 if (file_info->DeletePending) { 5730 5635 if (S_ISDIR(inode->i_mode) && 5731 5636 ksmbd_vfs_empty_dir(fp) == -ENOTEMPTY) ··· 5736 5643 return 0; 5737 5644 } 5738 5645 5739 - static int set_file_position_info(struct ksmbd_file *fp, char *buf) 5646 + static int set_file_position_info(struct ksmbd_file *fp, 5647 + struct smb2_file_pos_info *file_info) 5740 5648 { 5741 - struct smb2_file_pos_info *file_info; 5742 5649 loff_t current_byte_offset; 5743 5650 unsigned long sector_size; 5744 5651 struct inode *inode; 5745 5652 5746 5653 inode = file_inode(fp->filp); 5747 - file_info = (struct smb2_file_pos_info *)buf; 5748 5654 current_byte_offset = le64_to_cpu(file_info->CurrentByteOffset); 5749 5655 sector_size = inode->i_sb->s_blocksize; 5750 5656 ··· 5759 5667 return 0; 5760 5668 } 5761 5669 5762 - static int set_file_mode_info(struct ksmbd_file *fp, char *buf) 5670 + static int set_file_mode_info(struct ksmbd_file *fp, 5671 + struct smb2_file_mode_info *file_info) 5763 5672 { 5764 - struct smb2_file_mode_info *file_info; 5765 5673 __le32 mode; 5766 5674 5767 - file_info = (struct smb2_file_mode_info *)buf; 5768 5675 mode = file_info->Mode; 5769 5676 5770 5677 if ((mode & ~FILE_MODE_INFO_MASK) || ··· 5793 5702 * TODO: need to implement an error handling for STATUS_INFO_LENGTH_MISMATCH 5794 5703 */ 5795 5704 static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp, 5796 - int info_class, char *buf, 5705 + struct smb2_set_info_req *req, 5797 5706 struct ksmbd_share_config *share) 5798 5707 { 5799 - switch (info_class) { 5708 + unsigned int buf_len = le32_to_cpu(req->BufferLength); 5709 + 5710 + switch (req->FileInfoClass) { 5800 5711 case FILE_BASIC_INFORMATION: 5801 - return set_file_basic_info(fp, buf, share); 5712 + { 5713 + if (buf_len < sizeof(struct smb2_file_basic_info)) 5714 + return -EINVAL; 5802 5715 5716 + return set_file_basic_info(fp, (struct smb2_file_basic_info *)req->Buffer, share); 5717 + } 5803 5718 case FILE_ALLOCATION_INFORMATION: 5804 - return set_file_allocation_info(work, fp, buf); 5719 + { 5720 + if (buf_len < sizeof(struct smb2_file_alloc_info)) 5721 + return -EINVAL; 5805 5722 5723 + return set_file_allocation_info(work, fp, 5724 + (struct smb2_file_alloc_info *)req->Buffer); 5725 + } 5806 5726 case FILE_END_OF_FILE_INFORMATION: 5807 - return set_end_of_file_info(work, fp, buf); 5727 + { 5728 + if (buf_len < sizeof(struct smb2_file_eof_info)) 5729 + return -EINVAL; 5808 5730 5731 + return set_end_of_file_info(work, fp, 5732 + (struct smb2_file_eof_info *)req->Buffer); 5733 + } 5809 5734 case FILE_RENAME_INFORMATION: 5735 + { 5810 5736 if (!test_tree_conn_flag(work->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE)) { 5811 5737 ksmbd_debug(SMB, 5812 5738 "User does not have write permission\n"); 5813 5739 return -EACCES; 5814 5740 } 5815 - return set_rename_info(work, fp, buf); 5816 5741 5742 + if (buf_len < sizeof(struct smb2_file_rename_info)) 5743 + return -EINVAL; 5744 + 5745 + return set_rename_info(work, fp, 5746 + (struct smb2_file_rename_info *)req->Buffer, 5747 + buf_len); 5748 + } 5817 5749 case FILE_LINK_INFORMATION: 5818 - return smb2_create_link(work, work->tcon->share_conf, 5819 - (struct smb2_file_link_info *)buf, fp->filp, 5820 - work->sess->conn->local_nls); 5750 + { 5751 + if (buf_len < sizeof(struct smb2_file_link_info)) 5752 + return -EINVAL; 5821 5753 5754 + return smb2_create_link(work, work->tcon->share_conf, 5755 + (struct smb2_file_link_info *)req->Buffer, 5756 + buf_len, fp->filp, 5757 + work->sess->conn->local_nls); 5758 + } 5822 5759 case FILE_DISPOSITION_INFORMATION: 5760 + { 5823 5761 if (!test_tree_conn_flag(work->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE)) { 5824 5762 ksmbd_debug(SMB, 5825 5763 "User does not have write permission\n"); 5826 5764 return -EACCES; 5827 5765 } 5828 - return set_file_disposition_info(fp, buf); 5829 5766 5767 + if (buf_len < sizeof(struct smb2_file_disposition_info)) 5768 + return -EINVAL; 5769 + 5770 + return set_file_disposition_info(fp, 5771 + (struct smb2_file_disposition_info *)req->Buffer); 5772 + } 5830 5773 case FILE_FULL_EA_INFORMATION: 5831 5774 { 5832 5775 if (!(fp->daccess & FILE_WRITE_EA_LE)) { ··· 5869 5744 return -EACCES; 5870 5745 } 5871 5746 5872 - return smb2_set_ea((struct smb2_ea_info *)buf, 5873 - &fp->filp->f_path); 5874 - } 5747 + if (buf_len < sizeof(struct smb2_ea_info)) 5748 + return -EINVAL; 5875 5749 5750 + return smb2_set_ea((struct smb2_ea_info *)req->Buffer, 5751 + buf_len, &fp->filp->f_path); 5752 + } 5876 5753 case FILE_POSITION_INFORMATION: 5877 - return set_file_position_info(fp, buf); 5754 + { 5755 + if (buf_len < sizeof(struct smb2_file_pos_info)) 5756 + return -EINVAL; 5878 5757 5758 + return set_file_position_info(fp, (struct smb2_file_pos_info *)req->Buffer); 5759 + } 5879 5760 case FILE_MODE_INFORMATION: 5880 - return set_file_mode_info(fp, buf); 5761 + { 5762 + if (buf_len < sizeof(struct smb2_file_mode_info)) 5763 + return -EINVAL; 5764 + 5765 + return set_file_mode_info(fp, (struct smb2_file_mode_info *)req->Buffer); 5766 + } 5881 5767 } 5882 5768 5883 - pr_err("Unimplemented Fileinfoclass :%d\n", info_class); 5769 + pr_err("Unimplemented Fileinfoclass :%d\n", req->FileInfoClass); 5884 5770 return -EOPNOTSUPP; 5885 5771 } 5886 5772 ··· 5952 5816 switch (req->InfoType) { 5953 5817 case SMB2_O_INFO_FILE: 5954 5818 ksmbd_debug(SMB, "GOT SMB2_O_INFO_FILE\n"); 5955 - rc = smb2_set_info_file(work, fp, req->FileInfoClass, 5956 - req->Buffer, work->tcon->share_conf); 5819 + rc = smb2_set_info_file(work, fp, req, work->tcon->share_conf); 5957 5820 break; 5958 5821 case SMB2_O_INFO_SECURITY: 5959 5822 ksmbd_debug(SMB, "GOT SMB2_O_INFO_SECURITY\n"); ··· 8306 8171 8307 8172 WORK_BUFFERS(work, req, rsp); 8308 8173 8309 - if (le16_to_cpu(req->Command) == SMB2_NEGOTIATE_HE) 8174 + if (le16_to_cpu(req->Command) == SMB2_NEGOTIATE_HE && 8175 + conn->preauth_info) 8310 8176 ksmbd_gen_preauth_integrity_hash(conn, (char *)rsp, 8311 8177 conn->preauth_info->Preauth_HashValue); 8312 8178 ··· 8414 8278 unsigned int buf_data_size = pdu_length + 4 - 8415 8279 sizeof(struct smb2_transform_hdr); 8416 8280 struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)buf; 8417 - unsigned int orig_len = le32_to_cpu(tr_hdr->OriginalMessageSize); 8418 8281 int rc = 0; 8419 - 8420 - sess = ksmbd_session_lookup_all(conn, le64_to_cpu(tr_hdr->SessionId)); 8421 - if (!sess) { 8422 - pr_err("invalid session id(%llx) in transform header\n", 8423 - le64_to_cpu(tr_hdr->SessionId)); 8424 - return -ECONNABORTED; 8425 - } 8426 8282 8427 8283 if (pdu_length + 4 < 8428 8284 sizeof(struct smb2_transform_hdr) + sizeof(struct smb2_hdr)) { ··· 8423 8295 return -ECONNABORTED; 8424 8296 } 8425 8297 8426 - if (pdu_length + 4 < orig_len + sizeof(struct smb2_transform_hdr)) { 8298 + if (pdu_length + 4 < 8299 + le32_to_cpu(tr_hdr->OriginalMessageSize) + sizeof(struct smb2_transform_hdr)) { 8427 8300 pr_err("Transform message is broken\n"); 8301 + return -ECONNABORTED; 8302 + } 8303 + 8304 + sess = ksmbd_session_lookup_all(conn, le64_to_cpu(tr_hdr->SessionId)); 8305 + if (!sess) { 8306 + pr_err("invalid session id(%llx) in transform header\n", 8307 + le64_to_cpu(tr_hdr->SessionId)); 8428 8308 return -ECONNABORTED; 8429 8309 } 8430 8310
+9
fs/ksmbd/smb2pdu.h
··· 1464 1464 char FileName[1]; 1465 1465 } __packed; /* level 18 Query */ 1466 1466 1467 + struct smb2_file_basic_info { /* data block encoding of response to level 18 */ 1468 + __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ 1469 + __le64 LastAccessTime; 1470 + __le64 LastWriteTime; 1471 + __le64 ChangeTime; 1472 + __le32 Attributes; 1473 + __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ 1474 + } __packed; 1475 + 1467 1476 struct smb2_file_alt_name_info { 1468 1477 __le32 FileNameLength; 1469 1478 char FileName[0];
+28 -19
fs/ksmbd/smb_common.c
··· 155 155 */ 156 156 bool ksmbd_smb_request(struct ksmbd_conn *conn) 157 157 { 158 - int type = *(char *)conn->request_buf; 159 - 160 - switch (type) { 161 - case RFC1002_SESSION_MESSAGE: 162 - /* Regular SMB request */ 163 - return true; 164 - case RFC1002_SESSION_KEEP_ALIVE: 165 - ksmbd_debug(SMB, "RFC 1002 session keep alive\n"); 166 - break; 167 - default: 168 - ksmbd_debug(SMB, "RFC 1002 unknown request type 0x%x\n", type); 169 - } 170 - 171 - return false; 158 + return conn->request_buf[0] == 0; 172 159 } 173 160 174 161 static bool supported_protocol(int idx) ··· 169 182 idx <= server_conf.max_protocol); 170 183 } 171 184 172 - static char *next_dialect(char *dialect, int *next_off) 185 + static char *next_dialect(char *dialect, int *next_off, int bcount) 173 186 { 174 187 dialect = dialect + *next_off; 175 - *next_off = strlen(dialect); 188 + *next_off = strnlen(dialect, bcount); 189 + if (dialect[*next_off] != '\0') 190 + return NULL; 176 191 return dialect; 177 192 } 178 193 ··· 189 200 dialect = cli_dialects; 190 201 bcount = le16_to_cpu(byte_count); 191 202 do { 192 - dialect = next_dialect(dialect, &next); 203 + dialect = next_dialect(dialect, &next, bcount); 204 + if (!dialect) 205 + break; 193 206 ksmbd_debug(SMB, "client requested dialect %s\n", 194 207 dialect); 195 208 if (!strcmp(dialect, smb1_protos[i].name)) { ··· 239 248 240 249 static int ksmbd_negotiate_smb_dialect(void *buf) 241 250 { 242 - __le32 proto; 251 + int smb_buf_length = get_rfc1002_len(buf); 252 + __le32 proto = ((struct smb2_hdr *)buf)->ProtocolId; 243 253 244 - proto = ((struct smb2_hdr *)buf)->ProtocolId; 245 254 if (proto == SMB2_PROTO_NUMBER) { 246 255 struct smb2_negotiate_req *req; 256 + int smb2_neg_size = 257 + offsetof(struct smb2_negotiate_req, Dialects) - 4; 247 258 248 259 req = (struct smb2_negotiate_req *)buf; 260 + if (smb2_neg_size > smb_buf_length) 261 + goto err_out; 262 + 263 + if (smb2_neg_size + le16_to_cpu(req->DialectCount) * sizeof(__le16) > 264 + smb_buf_length) 265 + goto err_out; 266 + 249 267 return ksmbd_lookup_dialect_by_id(req->Dialects, 250 268 req->DialectCount); 251 269 } ··· 264 264 struct smb_negotiate_req *req; 265 265 266 266 req = (struct smb_negotiate_req *)buf; 267 + if (le16_to_cpu(req->ByteCount) < 2) 268 + goto err_out; 269 + 270 + if (offsetof(struct smb_negotiate_req, DialectsArray) - 4 + 271 + le16_to_cpu(req->ByteCount) > smb_buf_length) { 272 + goto err_out; 273 + } 274 + 267 275 return ksmbd_lookup_dialect_by_name(req->DialectsArray, 268 276 req->ByteCount); 269 277 } 270 278 279 + err_out: 271 280 return BAD_PROT_ID; 272 281 } 273 282
-8
fs/ksmbd/smb_common.h
··· 48 48 #define CIFS_DEFAULT_IOSIZE (64 * 1024) 49 49 #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */ 50 50 51 - /* RFC 1002 session packet types */ 52 - #define RFC1002_SESSION_MESSAGE 0x00 53 - #define RFC1002_SESSION_REQUEST 0x81 54 - #define RFC1002_POSITIVE_SESSION_RESPONSE 0x82 55 - #define RFC1002_NEGATIVE_SESSION_RESPONSE 0x83 56 - #define RFC1002_RETARGET_SESSION_RESPONSE 0x84 57 - #define RFC1002_SESSION_KEEP_ALIVE 0x85 58 - 59 51 /* Responses when opening a file. */ 60 52 #define F_SUPERSEDED 0 61 53 #define F_OPENED 1
+19 -2
fs/ksmbd/smbacl.c
··· 380 380 { 381 381 int i, ret; 382 382 int num_aces = 0; 383 - int acl_size; 383 + unsigned int acl_size; 384 384 char *acl_base; 385 385 struct smb_ace **ppace; 386 386 struct posix_acl_entry *cf_pace, *cf_pdace; ··· 392 392 return; 393 393 394 394 /* validate that we do not go past end of acl */ 395 - if (end_of_acl <= (char *)pdacl || 395 + if (end_of_acl < (char *)pdacl + sizeof(struct smb_acl) || 396 396 end_of_acl < (char *)pdacl + le16_to_cpu(pdacl->size)) { 397 397 pr_err("ACL too small to parse DACL\n"); 398 398 return; ··· 431 431 * user/group/other have no permissions 432 432 */ 433 433 for (i = 0; i < num_aces; ++i) { 434 + if (end_of_acl - acl_base < acl_size) 435 + break; 436 + 434 437 ppace[i] = (struct smb_ace *)(acl_base + acl_size); 435 438 acl_base = (char *)ppace[i]; 439 + acl_size = offsetof(struct smb_ace, sid) + 440 + offsetof(struct smb_sid, sub_auth); 441 + 442 + if (end_of_acl - acl_base < acl_size || 443 + ppace[i]->sid.num_subauth > SID_MAX_SUB_AUTHORITIES || 444 + (end_of_acl - acl_base < 445 + acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth) || 446 + (le16_to_cpu(ppace[i]->size) < 447 + acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth)) 448 + break; 449 + 436 450 acl_size = le16_to_cpu(ppace[i]->size); 437 451 ppace[i]->access_req = 438 452 smb_map_generic_desired_access(ppace[i]->access_req); ··· 820 806 821 807 if (!pntsd) 822 808 return -EIO; 809 + 810 + if (acl_len < sizeof(struct smb_ntsd)) 811 + return -EINVAL; 823 812 824 813 owner_sid_ptr = (struct smb_sid *)((char *)pntsd + 825 814 le32_to_cpu(pntsd->osidoffset));
+2 -2
fs/ksmbd/transport_tcp.c
··· 215 215 * ksmbd_kthread_fn() - listen to new SMB connections and callback server 216 216 * @p: arguments to forker thread 217 217 * 218 - * Return: Returns a task_struct or ERR_PTR 218 + * Return: 0 on success, error number otherwise 219 219 */ 220 220 static int ksmbd_kthread_fn(void *p) 221 221 { ··· 387 387 /** 388 388 * create_socket - create socket for ksmbd/0 389 389 * 390 - * Return: Returns a task_struct or ERR_PTR 390 + * Return: 0 on success, error number otherwise 391 391 */ 392 392 static int create_socket(struct interface *iface) 393 393 {
+2 -10
fs/vboxsf/super.c
··· 21 21 22 22 #define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */ 23 23 24 - #define VBSF_MOUNT_SIGNATURE_BYTE_0 ('\000') 25 - #define VBSF_MOUNT_SIGNATURE_BYTE_1 ('\377') 26 - #define VBSF_MOUNT_SIGNATURE_BYTE_2 ('\376') 27 - #define VBSF_MOUNT_SIGNATURE_BYTE_3 ('\375') 24 + static const unsigned char VBSF_MOUNT_SIGNATURE[4] = "\000\377\376\375"; 28 25 29 26 static int follow_symlinks; 30 27 module_param(follow_symlinks, int, 0444); ··· 383 386 384 387 static int vboxsf_parse_monolithic(struct fs_context *fc, void *data) 385 388 { 386 - unsigned char *options = data; 387 - 388 - if (options && options[0] == VBSF_MOUNT_SIGNATURE_BYTE_0 && 389 - options[1] == VBSF_MOUNT_SIGNATURE_BYTE_1 && 390 - options[2] == VBSF_MOUNT_SIGNATURE_BYTE_2 && 391 - options[3] == VBSF_MOUNT_SIGNATURE_BYTE_3) { 389 + if (data && !memcmp(data, VBSF_MOUNT_SIGNATURE, 4)) { 392 390 vbg_err("vboxsf: Old binary mount data not supported, remove obsolete mount.vboxsf and/or update your VBoxService.\n"); 393 391 return -EINVAL; 394 392 }
+1 -1
fs/verity/enable.c
··· 177 177 * (level 0) and ascending to the root node (level 'num_levels - 1'). 178 178 * Then at the end (level 'num_levels'), calculate the root hash. 179 179 */ 180 - blocks = (inode->i_size + params->block_size - 1) >> 180 + blocks = ((u64)inode->i_size + params->block_size - 1) >> 181 181 params->log_blocksize; 182 182 for (level = 0; level <= params->num_levels; level++) { 183 183 err = build_merkle_tree_level(filp, level, blocks, params,
+1 -1
fs/verity/open.c
··· 89 89 */ 90 90 91 91 /* Compute number of levels and the number of blocks in each level */ 92 - blocks = (inode->i_size + params->block_size - 1) >> log_blocksize; 92 + blocks = ((u64)inode->i_size + params->block_size - 1) >> log_blocksize; 93 93 pr_debug("Data is %lld bytes (%llu blocks)\n", inode->i_size, blocks); 94 94 while (blocks > 1) { 95 95 if (params->num_levels >= FS_VERITY_MAX_LEVELS) {
-3
include/kvm/arm_pmu.h
··· 61 61 int kvm_arm_pmu_v3_has_attr(struct kvm_vcpu *vcpu, 62 62 struct kvm_device_attr *attr); 63 63 int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu); 64 - int kvm_pmu_probe_pmuver(void); 65 64 #else 66 65 struct kvm_pmu { 67 66 }; ··· 116 117 { 117 118 return 0; 118 119 } 119 - 120 - static inline int kvm_pmu_probe_pmuver(void) { return 0xf; } 121 120 122 121 #endif 123 122
+2 -1
include/linux/bpf.h
··· 578 578 * programs only. Should not be used with normal calls and indirect calls. 579 579 */ 580 580 #define BPF_TRAMP_F_SKIP_FRAME BIT(2) 581 - 582 581 /* Store IP address of the caller on the trampoline stack, 583 582 * so it's available for trampoline's programs. 584 583 */ 585 584 #define BPF_TRAMP_F_IP_ARG BIT(3) 585 + /* Return the return value of fentry prog. Only used by bpf_struct_ops. */ 586 + #define BPF_TRAMP_F_RET_FENTRY_RET BIT(4) 586 587 587 588 /* Each call __bpf_prog_enter + call bpf_func + call __bpf_prog_exit is ~50 588 589 * bytes on x86. Pick a number to fit into BPF_IMAGE_SIZE / 2
+4 -3
include/linux/cpumask.h
··· 996 996 * cpumask; Typically used by bin_attribute to export cpumask bitmask 997 997 * ABI. 998 998 * 999 - * Returns the length of how many bytes have been copied. 999 + * Returns the length of how many bytes have been copied, excluding 1000 + * terminating '\0'. 1000 1001 */ 1001 1002 static inline ssize_t 1002 1003 cpumap_print_bitmask_to_buf(char *buf, const struct cpumask *mask, 1003 1004 loff_t off, size_t count) 1004 1005 { 1005 1006 return bitmap_print_bitmask_to_buf(buf, cpumask_bits(mask), 1006 - nr_cpu_ids, off, count); 1007 + nr_cpu_ids, off, count) - 1; 1007 1008 } 1008 1009 1009 1010 /** ··· 1019 1018 loff_t off, size_t count) 1020 1019 { 1021 1020 return bitmap_print_list_to_buf(buf, cpumask_bits(mask), 1022 - nr_cpu_ids, off, count); 1021 + nr_cpu_ids, off, count) - 1; 1023 1022 } 1024 1023 1025 1024 #if NR_CPUS <= BITS_PER_LONG
+8 -3
include/linux/fwnode.h
··· 22 22 * LINKS_ADDED: The fwnode has already be parsed to add fwnode links. 23 23 * NOT_DEVICE: The fwnode will never be populated as a struct device. 24 24 * INITIALIZED: The hardware corresponding to fwnode has been initialized. 25 + * NEEDS_CHILD_BOUND_ON_ADD: For this fwnode/device to probe successfully, its 26 + * driver needs its child devices to be bound with 27 + * their respective drivers as soon as they are 28 + * added. 25 29 */ 26 - #define FWNODE_FLAG_LINKS_ADDED BIT(0) 27 - #define FWNODE_FLAG_NOT_DEVICE BIT(1) 28 - #define FWNODE_FLAG_INITIALIZED BIT(2) 30 + #define FWNODE_FLAG_LINKS_ADDED BIT(0) 31 + #define FWNODE_FLAG_NOT_DEVICE BIT(1) 32 + #define FWNODE_FLAG_INITIALIZED BIT(2) 33 + #define FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD BIT(3) 29 34 30 35 struct fwnode_handle { 31 36 struct fwnode_handle *secondary;
-6
include/linux/kvm_host.h
··· 608 608 unsigned long mmu_notifier_range_start; 609 609 unsigned long mmu_notifier_range_end; 610 610 #endif 611 - long tlbs_dirty; 612 611 struct list_head devices; 613 612 u64 manual_dirty_log_protect; 614 613 struct dentry *debugfs_dentry; ··· 718 719 if (vcpu->vcpu_id == id) 719 720 return vcpu; 720 721 return NULL; 721 - } 722 - 723 - static inline int kvm_vcpu_get_idx(struct kvm_vcpu *vcpu) 724 - { 725 - return vcpu->vcpu_idx; 726 722 } 727 723 728 724 #define kvm_for_each_memslot(memslot, slots) \
+6
include/linux/perf/arm_pmu.h
··· 163 163 static inline int arm_pmu_acpi_probe(armpmu_init_fn init_fn) { return 0; } 164 164 #endif 165 165 166 + #ifdef CONFIG_KVM 167 + void kvm_host_pmu_init(struct arm_pmu *pmu); 168 + #else 169 + #define kvm_host_pmu_init(x) do { } while(0) 170 + #endif 171 + 166 172 /* Internal functions only for core arm_pmu code */ 167 173 struct arm_pmu *armpmu_alloc(void); 168 174 struct arm_pmu *armpmu_alloc_atomic(void);
+3 -1
include/linux/perf_event.h
··· 683 683 /* 684 684 * timestamp shadows the actual context timing but it can 685 685 * be safely used in NMI interrupt context. It reflects the 686 - * context time as it was when the event was last scheduled in. 686 + * context time as it was when the event was last scheduled in, 687 + * or when ctx_sched_in failed to schedule the event because we 688 + * run out of PMC. 687 689 * 688 690 * ctx_time already accounts for ctx->timestamp. Therefore to 689 691 * compute ctx_time for a sample, simply add perf_clock().
+1 -1
include/linux/sched.h
··· 1720 1720 #define tsk_used_math(p) ((p)->flags & PF_USED_MATH) 1721 1721 #define used_math() tsk_used_math(current) 1722 1722 1723 - static inline bool is_percpu_thread(void) 1723 + static __always_inline bool is_percpu_thread(void) 1724 1724 { 1725 1725 #ifdef CONFIG_SMP 1726 1726 return (current->flags & PF_NO_SETAFFINITY) &&
+1 -1
include/net/ip_fib.h
··· 597 597 int fib_nexthop_info(struct sk_buff *skb, const struct fib_nh_common *nh, 598 598 u8 rt_family, unsigned char *flags, bool skip_oif); 599 599 int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nh, 600 - int nh_weight, u8 rt_family); 600 + int nh_weight, u8 rt_family, u32 nh_tclassid); 601 601 #endif /* _NET_FIB_H */
+4 -4
include/net/mac80211.h
··· 2818 2818 * Mac80211 drivers should set the @NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 flag 2819 2819 * when they are able to replace in-use PTK keys according to the following 2820 2820 * requirements: 2821 - * 1) They do not hand over frames decrypted with the old key to 2822 - mac80211 once the call to set_key() with command %DISABLE_KEY has been 2823 - completed when also setting @IEEE80211_KEY_FLAG_GENERATE_IV for any key, 2821 + * 1) They do not hand over frames decrypted with the old key to mac80211 2822 + once the call to set_key() with command %DISABLE_KEY has been completed, 2824 2823 2) either drop or continue to use the old key for any outgoing frames queued 2825 2824 at the time of the key deletion (including re-transmits), 2826 2825 3) never send out a frame queued prior to the set_key() %SET_KEY command 2827 - encrypted with the new key and 2826 + encrypted with the new key when also needing 2827 + @IEEE80211_KEY_FLAG_GENERATE_IV and 2828 2828 4) never send out a frame unencrypted when it should be encrypted. 2829 2829 Mac80211 will not queue any new frames for a deleted key to the driver. 2830 2830 */
+1 -1
include/net/nexthop.h
··· 325 325 struct fib_nh_common *nhc = &nhi->fib_nhc; 326 326 int weight = nhg->nh_entries[i].weight; 327 327 328 - if (fib_add_nexthop(skb, nhc, weight, rt_family) < 0) 328 + if (fib_add_nexthop(skb, nhc, weight, rt_family, 0) < 0) 329 329 return -EMSGSIZE; 330 330 } 331 331
+1
include/net/pkt_sched.h
··· 11 11 #include <uapi/linux/pkt_sched.h> 12 12 13 13 #define DEFAULT_TX_QUEUE_LEN 1000 14 + #define STAB_SIZE_LOG_MAX 30 14 15 15 16 struct qdisc_walker { 16 17 int stop;
+32 -1
include/net/sock.h
··· 488 488 u8 sk_prefer_busy_poll; 489 489 u16 sk_busy_poll_budget; 490 490 #endif 491 + spinlock_t sk_peer_lock; 491 492 struct pid *sk_peer_pid; 492 493 const struct cred *sk_peer_cred; 494 + 493 495 long sk_rcvtimeo; 494 496 ktime_t sk_stamp; 495 497 #if BITS_PER_LONG==32 ··· 1625 1623 SINGLE_DEPTH_NESTING) 1626 1624 #define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock)) 1627 1625 1628 - bool lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock); 1626 + bool __lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock); 1627 + 1628 + /** 1629 + * lock_sock_fast - fast version of lock_sock 1630 + * @sk: socket 1631 + * 1632 + * This version should be used for very small section, where process wont block 1633 + * return false if fast path is taken: 1634 + * 1635 + * sk_lock.slock locked, owned = 0, BH disabled 1636 + * 1637 + * return true if slow path is taken: 1638 + * 1639 + * sk_lock.slock unlocked, owned = 1, BH enabled 1640 + */ 1641 + static inline bool lock_sock_fast(struct sock *sk) 1642 + { 1643 + /* The sk_lock has mutex_lock() semantics here. */ 1644 + mutex_acquire(&sk->sk_lock.dep_map, 0, 0, _RET_IP_); 1645 + 1646 + return __lock_sock_fast(sk); 1647 + } 1648 + 1649 + /* fast socket lock variant for caller already holding a [different] socket lock */ 1650 + static inline bool lock_sock_fast_nested(struct sock *sk) 1651 + { 1652 + mutex_acquire(&sk->sk_lock.dep_map, SINGLE_DEPTH_NESTING, 0, _RET_IP_); 1653 + 1654 + return __lock_sock_fast(sk); 1655 + } 1629 1656 1630 1657 /** 1631 1658 * unlock_sock_fast - complement of lock_sock_fast
+1
include/sound/rawmidi.h
··· 98 98 struct snd_rawmidi *rmidi; 99 99 struct snd_rawmidi_substream *input; 100 100 struct snd_rawmidi_substream *output; 101 + unsigned int user_pversion; /* supported protocol version */ 101 102 }; 102 103 103 104 struct snd_rawmidi_str {
+1 -1
include/trace/events/cachefiles.h
··· 305 305 ), 306 306 307 307 TP_fast_assign( 308 - __entry->obj = obj->fscache.debug_id; 308 + __entry->obj = obj ? obj->fscache.debug_id : UINT_MAX; 309 309 __entry->de = de; 310 310 __entry->why = why; 311 311 ),
+1
include/uapi/sound/asound.h
··· 784 784 785 785 #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int) 786 786 #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info) 787 + #define SNDRV_RAWMIDI_IOCTL_USER_PVERSION _IOW('W', 0x02, int) 787 788 #define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params) 788 789 #define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status) 789 790 #define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int)
+5 -2
kernel/bpf/bpf_struct_ops.c
··· 368 368 const struct btf_type *mtype, *ptype; 369 369 struct bpf_prog *prog; 370 370 u32 moff; 371 + u32 flags; 371 372 372 373 moff = btf_member_bit_offset(t, member) / 8; 373 374 ptype = btf_type_resolve_ptr(btf_vmlinux, member->type, NULL); ··· 432 431 433 432 tprogs[BPF_TRAMP_FENTRY].progs[0] = prog; 434 433 tprogs[BPF_TRAMP_FENTRY].nr_progs = 1; 434 + flags = st_ops->func_models[i].ret_size > 0 ? 435 + BPF_TRAMP_F_RET_FENTRY_RET : 0; 435 436 err = arch_prepare_bpf_trampoline(NULL, image, 436 437 st_map->image + PAGE_SIZE, 437 - &st_ops->func_models[i], 0, 438 - tprogs, NULL); 438 + &st_ops->func_models[i], 439 + flags, tprogs, NULL); 439 440 if (err < 0) 440 441 goto reset_unlock; 441 442
+1 -1
kernel/bpf/core.c
··· 827 827 { 828 828 if (atomic_long_add_return(pages, &bpf_jit_current) > 829 829 (bpf_jit_limit >> PAGE_SHIFT)) { 830 - if (!capable(CAP_SYS_ADMIN)) { 830 + if (!bpf_capable()) { 831 831 atomic_long_sub(pages, &bpf_jit_current); 832 832 return -EPERM; 833 833 }
+12 -5
kernel/cgroup/cgroup.c
··· 6574 6574 6575 6575 void cgroup_sk_alloc(struct sock_cgroup_data *skcd) 6576 6576 { 6577 - /* Don't associate the sock with unrelated interrupted task's cgroup. */ 6578 - if (in_interrupt()) 6579 - return; 6577 + struct cgroup *cgroup; 6580 6578 6581 6579 rcu_read_lock(); 6580 + /* Don't associate the sock with unrelated interrupted task's cgroup. */ 6581 + if (in_interrupt()) { 6582 + cgroup = &cgrp_dfl_root.cgrp; 6583 + cgroup_get(cgroup); 6584 + goto out; 6585 + } 6586 + 6582 6587 while (true) { 6583 6588 struct css_set *cset; 6584 6589 6585 6590 cset = task_css_set(current); 6586 6591 if (likely(cgroup_tryget(cset->dfl_cgrp))) { 6587 - skcd->cgroup = cset->dfl_cgrp; 6588 - cgroup_bpf_get(cset->dfl_cgrp); 6592 + cgroup = cset->dfl_cgrp; 6589 6593 break; 6590 6594 } 6591 6595 cpu_relax(); 6592 6596 } 6597 + out: 6598 + skcd->cgroup = cgroup; 6599 + cgroup_bpf_get(cgroup); 6593 6600 rcu_read_unlock(); 6594 6601 } 6595 6602
+30 -4
kernel/events/core.c
··· 3707 3707 return 0; 3708 3708 } 3709 3709 3710 + static inline bool event_update_userpage(struct perf_event *event) 3711 + { 3712 + if (likely(!atomic_read(&event->mmap_count))) 3713 + return false; 3714 + 3715 + perf_event_update_time(event); 3716 + perf_set_shadow_time(event, event->ctx); 3717 + perf_event_update_userpage(event); 3718 + 3719 + return true; 3720 + } 3721 + 3722 + static inline void group_update_userpage(struct perf_event *group_event) 3723 + { 3724 + struct perf_event *event; 3725 + 3726 + if (!event_update_userpage(group_event)) 3727 + return; 3728 + 3729 + for_each_sibling_event(event, group_event) 3730 + event_update_userpage(event); 3731 + } 3732 + 3710 3733 static int merge_sched_in(struct perf_event *event, void *data) 3711 3734 { 3712 3735 struct perf_event_context *ctx = event->ctx; ··· 3748 3725 } 3749 3726 3750 3727 if (event->state == PERF_EVENT_STATE_INACTIVE) { 3728 + *can_add_hw = 0; 3751 3729 if (event->attr.pinned) { 3752 3730 perf_cgroup_event_disable(event, ctx); 3753 3731 perf_event_set_state(event, PERF_EVENT_STATE_ERROR); 3732 + } else { 3733 + ctx->rotate_necessary = 1; 3734 + perf_mux_hrtimer_restart(cpuctx); 3735 + group_update_userpage(event); 3754 3736 } 3755 - 3756 - *can_add_hw = 0; 3757 - ctx->rotate_necessary = 1; 3758 - perf_mux_hrtimer_restart(cpuctx); 3759 3737 } 3760 3738 3761 3739 return 0; ··· 6348 6324 6349 6325 ring_buffer_attach(event, rb); 6350 6326 6327 + perf_event_update_time(event); 6328 + perf_set_shadow_time(event, event->ctx); 6351 6329 perf_event_init_userpage(event); 6352 6330 perf_event_update_userpage(event); 6353 6331 } else {
+7 -1
kernel/sched/debug.c
··· 173 173 size_t cnt, loff_t *ppos) 174 174 { 175 175 char buf[16]; 176 + unsigned int scaling; 176 177 177 178 if (cnt > 15) 178 179 cnt = 15; 179 180 180 181 if (copy_from_user(&buf, ubuf, cnt)) 181 182 return -EFAULT; 183 + buf[cnt] = '\0'; 182 184 183 - if (kstrtouint(buf, 10, &sysctl_sched_tunable_scaling)) 185 + if (kstrtouint(buf, 10, &scaling)) 184 186 return -EINVAL; 185 187 188 + if (scaling >= SCHED_TUNABLESCALING_END) 189 + return -EINVAL; 190 + 191 + sysctl_sched_tunable_scaling = scaling; 186 192 if (sched_update_scaling()) 187 193 return -EINVAL; 188 194
+5 -1
kernel/sched/fair.c
··· 4936 4936 /* update hierarchical throttle state */ 4937 4937 walk_tg_tree_from(cfs_rq->tg, tg_nop, tg_unthrottle_up, (void *)rq); 4938 4938 4939 - if (!cfs_rq->load.weight) 4939 + /* Nothing to run but something to decay (on_list)? Complete the branch */ 4940 + if (!cfs_rq->load.weight) { 4941 + if (cfs_rq->on_list) 4942 + goto unthrottle_throttle; 4940 4943 return; 4944 + } 4941 4945 4942 4946 task_delta = cfs_rq->h_nr_running; 4943 4947 idle_task_delta = cfs_rq->idle_h_nr_running;
+9 -5
net/bpf/test_run.c
··· 552 552 __skb->gso_segs = skb_shinfo(skb)->gso_segs; 553 553 } 554 554 555 + static struct proto bpf_dummy_proto = { 556 + .name = "bpf_dummy", 557 + .owner = THIS_MODULE, 558 + .obj_size = sizeof(struct sock), 559 + }; 560 + 555 561 int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr, 556 562 union bpf_attr __user *uattr) 557 563 { ··· 602 596 break; 603 597 } 604 598 605 - sk = kzalloc(sizeof(struct sock), GFP_USER); 599 + sk = sk_alloc(net, AF_UNSPEC, GFP_USER, &bpf_dummy_proto, 1); 606 600 if (!sk) { 607 601 kfree(data); 608 602 kfree(ctx); 609 603 return -ENOMEM; 610 604 } 611 - sock_net_set(sk, net); 612 605 sock_init_data(NULL, sk); 613 606 614 607 skb = build_skb(data, 0); 615 608 if (!skb) { 616 609 kfree(data); 617 610 kfree(ctx); 618 - kfree(sk); 611 + sk_free(sk); 619 612 return -ENOMEM; 620 613 } 621 614 skb->sk = sk; ··· 687 682 if (dev && dev != net->loopback_dev) 688 683 dev_put(dev); 689 684 kfree_skb(skb); 690 - bpf_sk_storage_free(sk); 691 - kfree(sk); 685 + sk_free(sk); 692 686 kfree(ctx); 693 687 return ret; 694 688 }
+2 -4
net/bridge/br_multicast.c
··· 1677 1677 int ifindex, 1678 1678 struct br_ip *saddr) 1679 1679 { 1680 - lockdep_assert_held_once(&brmctx->br->multicast_lock); 1681 - 1682 1680 write_seqcount_begin(&querier->seq); 1683 1681 querier->port_ifidx = ifindex; 1684 1682 memcpy(&querier->addr, saddr, sizeof(*saddr)); ··· 3865 3867 3866 3868 brmctx->ip4_other_query.delay_time = 0; 3867 3869 brmctx->ip4_querier.port_ifidx = 0; 3868 - seqcount_init(&brmctx->ip4_querier.seq); 3870 + seqcount_spinlock_init(&brmctx->ip4_querier.seq, &br->multicast_lock); 3869 3871 brmctx->multicast_igmp_version = 2; 3870 3872 #if IS_ENABLED(CONFIG_IPV6) 3871 3873 brmctx->multicast_mld_version = 1; 3872 3874 brmctx->ip6_other_query.delay_time = 0; 3873 3875 brmctx->ip6_querier.port_ifidx = 0; 3874 - seqcount_init(&brmctx->ip6_querier.seq); 3876 + seqcount_spinlock_init(&brmctx->ip6_querier.seq, &br->multicast_lock); 3875 3877 #endif 3876 3878 3877 3879 timer_setup(&brmctx->ip4_mc_router_timer,
+1 -1
net/bridge/br_private.h
··· 82 82 struct bridge_mcast_querier { 83 83 struct br_ip addr; 84 84 int port_ifidx; 85 - seqcount_t seq; 85 + seqcount_spinlock_t seq; 86 86 }; 87 87 88 88 /* IGMP/MLD statistics */
+6
net/core/dev_addr_lists.c
··· 50 50 if (addr_len > MAX_ADDR_LEN) 51 51 return -EINVAL; 52 52 53 + ha = list_first_entry(&list->list, struct netdev_hw_addr, list); 54 + if (ha && !memcmp(addr, ha->addr, addr_len) && 55 + (!addr_type || addr_type == ha->type)) 56 + goto found_it; 57 + 53 58 while (*ins_point) { 54 59 int diff; 55 60 ··· 69 64 } else if (diff > 0) { 70 65 ins_point = &parent->rb_right; 71 66 } else { 67 + found_it: 72 68 if (exclusive) 73 69 return -EEXIST; 74 70 if (global) {
+28 -24
net/core/sock.c
··· 1376 1376 } 1377 1377 EXPORT_SYMBOL(sock_setsockopt); 1378 1378 1379 + static const struct cred *sk_get_peer_cred(struct sock *sk) 1380 + { 1381 + const struct cred *cred; 1382 + 1383 + spin_lock(&sk->sk_peer_lock); 1384 + cred = get_cred(sk->sk_peer_cred); 1385 + spin_unlock(&sk->sk_peer_lock); 1386 + 1387 + return cred; 1388 + } 1379 1389 1380 1390 static void cred_to_ucred(struct pid *pid, const struct cred *cred, 1381 1391 struct ucred *ucred) ··· 1562 1552 struct ucred peercred; 1563 1553 if (len > sizeof(peercred)) 1564 1554 len = sizeof(peercred); 1555 + 1556 + spin_lock(&sk->sk_peer_lock); 1565 1557 cred_to_ucred(sk->sk_peer_pid, sk->sk_peer_cred, &peercred); 1558 + spin_unlock(&sk->sk_peer_lock); 1559 + 1566 1560 if (copy_to_user(optval, &peercred, len)) 1567 1561 return -EFAULT; 1568 1562 goto lenout; ··· 1574 1560 1575 1561 case SO_PEERGROUPS: 1576 1562 { 1563 + const struct cred *cred; 1577 1564 int ret, n; 1578 1565 1579 - if (!sk->sk_peer_cred) 1566 + cred = sk_get_peer_cred(sk); 1567 + if (!cred) 1580 1568 return -ENODATA; 1581 1569 1582 - n = sk->sk_peer_cred->group_info->ngroups; 1570 + n = cred->group_info->ngroups; 1583 1571 if (len < n * sizeof(gid_t)) { 1584 1572 len = n * sizeof(gid_t); 1573 + put_cred(cred); 1585 1574 return put_user(len, optlen) ? -EFAULT : -ERANGE; 1586 1575 } 1587 1576 len = n * sizeof(gid_t); 1588 1577 1589 - ret = groups_to_user((gid_t __user *)optval, 1590 - sk->sk_peer_cred->group_info); 1578 + ret = groups_to_user((gid_t __user *)optval, cred->group_info); 1579 + put_cred(cred); 1591 1580 if (ret) 1592 1581 return ret; 1593 1582 goto lenout; ··· 1952 1935 sk->sk_frag.page = NULL; 1953 1936 } 1954 1937 1955 - if (sk->sk_peer_cred) 1956 - put_cred(sk->sk_peer_cred); 1938 + /* We do not need to acquire sk->sk_peer_lock, we are the last user. */ 1939 + put_cred(sk->sk_peer_cred); 1957 1940 put_pid(sk->sk_peer_pid); 1941 + 1958 1942 if (likely(sk->sk_net_refcnt)) 1959 1943 put_net(sock_net(sk)); 1960 1944 sk_prot_free(sk->sk_prot_creator, sk); ··· 3163 3145 3164 3146 sk->sk_peer_pid = NULL; 3165 3147 sk->sk_peer_cred = NULL; 3148 + spin_lock_init(&sk->sk_peer_lock); 3149 + 3166 3150 sk->sk_write_pending = 0; 3167 3151 sk->sk_rcvlowat = 1; 3168 3152 sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT; ··· 3230 3210 } 3231 3211 EXPORT_SYMBOL(release_sock); 3232 3212 3233 - /** 3234 - * lock_sock_fast - fast version of lock_sock 3235 - * @sk: socket 3236 - * 3237 - * This version should be used for very small section, where process wont block 3238 - * return false if fast path is taken: 3239 - * 3240 - * sk_lock.slock locked, owned = 0, BH disabled 3241 - * 3242 - * return true if slow path is taken: 3243 - * 3244 - * sk_lock.slock unlocked, owned = 1, BH enabled 3245 - */ 3246 - bool lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock) 3213 + bool __lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock) 3247 3214 { 3248 - /* The sk_lock has mutex_lock() semantics here. */ 3249 - mutex_acquire(&sk->sk_lock.dep_map, 0, 0, _RET_IP_); 3250 - 3251 3215 might_sleep(); 3252 3216 spin_lock_bh(&sk->sk_lock.slock); 3253 3217 ··· 3260 3256 spin_unlock_bh(&sk->sk_lock.slock); 3261 3257 return true; 3262 3258 } 3263 - EXPORT_SYMBOL(lock_sock_fast); 3259 + EXPORT_SYMBOL(__lock_sock_fast); 3264 3260 3265 3261 int sock_gettstamp(struct socket *sock, void __user *userstamp, 3266 3262 bool timeval, bool time32)
+9 -7
net/ipv4/fib_semantics.c
··· 1661 1661 1662 1662 #if IS_ENABLED(CONFIG_IP_ROUTE_MULTIPATH) || IS_ENABLED(CONFIG_IPV6) 1663 1663 int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nhc, 1664 - int nh_weight, u8 rt_family) 1664 + int nh_weight, u8 rt_family, u32 nh_tclassid) 1665 1665 { 1666 1666 const struct net_device *dev = nhc->nhc_dev; 1667 1667 struct rtnexthop *rtnh; ··· 1678 1678 goto nla_put_failure; 1679 1679 1680 1680 rtnh->rtnh_flags = flags; 1681 + 1682 + if (nh_tclassid && nla_put_u32(skb, RTA_FLOW, nh_tclassid)) 1683 + goto nla_put_failure; 1681 1684 1682 1685 /* length of rtnetlink header + attributes */ 1683 1686 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *)rtnh; ··· 1709 1706 } 1710 1707 1711 1708 for_nexthops(fi) { 1712 - if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight, 1713 - AF_INET) < 0) 1714 - goto nla_put_failure; 1709 + u32 nh_tclassid = 0; 1715 1710 #ifdef CONFIG_IP_ROUTE_CLASSID 1716 - if (nh->nh_tclassid && 1717 - nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) 1718 - goto nla_put_failure; 1711 + nh_tclassid = nh->nh_tclassid; 1719 1712 #endif 1713 + if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight, 1714 + AF_INET, nh_tclassid) < 0) 1715 + goto nla_put_failure; 1720 1716 } endfor_nexthops(fi); 1721 1717 1722 1718 mp_end:
+1 -1
net/ipv4/netfilter/iptable_raw.c
··· 42 42 43 43 static struct nf_hook_ops *rawtable_ops __read_mostly; 44 44 45 - static int __net_init iptable_raw_table_init(struct net *net) 45 + static int iptable_raw_table_init(struct net *net) 46 46 { 47 47 struct ipt_replace *repl; 48 48 const struct xt_table *table = &packet_raw;
+5 -5
net/ipv4/udp.c
··· 1053 1053 __be16 dport; 1054 1054 u8 tos; 1055 1055 int err, is_udplite = IS_UDPLITE(sk); 1056 - int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; 1056 + int corkreq = READ_ONCE(up->corkflag) || msg->msg_flags&MSG_MORE; 1057 1057 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *); 1058 1058 struct sk_buff *skb; 1059 1059 struct ip_options_data opt_copy; ··· 1361 1361 } 1362 1362 1363 1363 up->len += size; 1364 - if (!(up->corkflag || (flags&MSG_MORE))) 1364 + if (!(READ_ONCE(up->corkflag) || (flags&MSG_MORE))) 1365 1365 ret = udp_push_pending_frames(sk); 1366 1366 if (!ret) 1367 1367 ret = size; ··· 2662 2662 switch (optname) { 2663 2663 case UDP_CORK: 2664 2664 if (val != 0) { 2665 - up->corkflag = 1; 2665 + WRITE_ONCE(up->corkflag, 1); 2666 2666 } else { 2667 - up->corkflag = 0; 2667 + WRITE_ONCE(up->corkflag, 0); 2668 2668 lock_sock(sk); 2669 2669 push_pending_frames(sk); 2670 2670 release_sock(sk); ··· 2787 2787 2788 2788 switch (optname) { 2789 2789 case UDP_CORK: 2790 - val = up->corkflag; 2790 + val = READ_ONCE(up->corkflag); 2791 2791 break; 2792 2792 2793 2793 case UDP_ENCAP:
+1
net/ipv6/netfilter/ip6_tables.c
··· 273 273 * things we don't know, ie. tcp syn flag or ports). If the 274 274 * rule is also a fragment-specific rule, non-fragments won't 275 275 * match it. */ 276 + acpar.fragoff = 0; 276 277 acpar.hotdrop = false; 277 278 acpar.state = state; 278 279
+3 -2
net/ipv6/route.c
··· 5681 5681 goto nla_put_failure; 5682 5682 5683 5683 if (fib_add_nexthop(skb, &rt->fib6_nh->nh_common, 5684 - rt->fib6_nh->fib_nh_weight, AF_INET6) < 0) 5684 + rt->fib6_nh->fib_nh_weight, AF_INET6, 5685 + 0) < 0) 5685 5686 goto nla_put_failure; 5686 5687 5687 5688 list_for_each_entry_safe(sibling, next_sibling, 5688 5689 &rt->fib6_siblings, fib6_siblings) { 5689 5690 if (fib_add_nexthop(skb, &sibling->fib6_nh->nh_common, 5690 5691 sibling->fib6_nh->fib_nh_weight, 5691 - AF_INET6) < 0) 5692 + AF_INET6, 0) < 0) 5692 5693 goto nla_put_failure; 5693 5694 } 5694 5695
+1 -1
net/ipv6/udp.c
··· 1303 1303 int addr_len = msg->msg_namelen; 1304 1304 bool connected = false; 1305 1305 int ulen = len; 1306 - int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; 1306 + int corkreq = READ_ONCE(up->corkflag) || msg->msg_flags&MSG_MORE; 1307 1307 int err; 1308 1308 int is_udplite = IS_UDPLITE(sk); 1309 1309 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
+4 -1
net/mac80211/mesh_pathtbl.c
··· 60 60 atomic_set(&newtbl->entries, 0); 61 61 spin_lock_init(&newtbl->gates_lock); 62 62 spin_lock_init(&newtbl->walk_lock); 63 - rhashtable_init(&newtbl->rhead, &mesh_rht_params); 63 + if (rhashtable_init(&newtbl->rhead, &mesh_rht_params)) { 64 + kfree(newtbl); 65 + return NULL; 66 + } 64 67 65 68 return newtbl; 66 69 }
+2 -1
net/mac80211/mesh_ps.c
··· 2 2 /* 3 3 * Copyright 2012-2013, Marco Porsch <marco.porsch@s2005.tu-chemnitz.de> 4 4 * Copyright 2012-2013, cozybit Inc. 5 + * Copyright (C) 2021 Intel Corporation 5 6 */ 6 7 7 8 #include "mesh.h" ··· 589 588 590 589 /* only transmit to PS STA with announced, non-zero awake window */ 591 590 if (test_sta_flag(sta, WLAN_STA_PS_STA) && 592 - (!elems->awake_window || !le16_to_cpu(*elems->awake_window))) 591 + (!elems->awake_window || !get_unaligned_le16(elems->awake_window))) 593 592 return; 594 593 595 594 if (!test_sta_flag(sta, WLAN_STA_MPSP_OWNER))
-4
net/mac80211/rate.c
··· 392 392 int mcast_rate; 393 393 bool use_basicrate = false; 394 394 395 - if (ieee80211_is_tx_data(txrc->skb) && 396 - info->flags & IEEE80211_TX_CTL_NO_ACK) 397 - return false; 398 - 399 395 if (!pubsta || rc_no_data_or_no_ack_use_min(txrc)) { 400 396 __rate_control_send_low(txrc->hw, sband, pubsta, info, 401 397 txrc->rate_idx_mask);
+2 -1
net/mac80211/rx.c
··· 4131 4131 if (!bssid) 4132 4132 return false; 4133 4133 if (ether_addr_equal(sdata->vif.addr, hdr->addr2) || 4134 - ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2)) 4134 + ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2) || 4135 + !is_valid_ether_addr(hdr->addr2)) 4135 4136 return false; 4136 4137 if (ieee80211_is_beacon(hdr->frame_control)) 4137 4138 return true;
+12
net/mac80211/tx.c
··· 2209 2209 } 2210 2210 2211 2211 vht_mcs = iterator.this_arg[4] >> 4; 2212 + if (vht_mcs > 11) 2213 + vht_mcs = 0; 2212 2214 vht_nss = iterator.this_arg[4] & 0xF; 2215 + if (!vht_nss || vht_nss > 8) 2216 + vht_nss = 1; 2213 2217 break; 2214 2218 2215 2219 /* ··· 3383 3379 3384 3380 if (!ieee80211_amsdu_prepare_head(sdata, fast_tx, head)) 3385 3381 goto out; 3382 + 3383 + /* If n == 2, the "while (*frag_tail)" loop above didn't execute 3384 + * and frag_tail should be &skb_shinfo(head)->frag_list. 3385 + * However, ieee80211_amsdu_prepare_head() can reallocate it. 3386 + * Reload frag_tail to have it pointing to the correct place. 3387 + */ 3388 + if (n == 2) 3389 + frag_tail = &skb_shinfo(head)->frag_list; 3386 3390 3387 3391 /* 3388 3392 * Pad out the previous subframe to a multiple of 4 by adding the
+6
net/mac80211/wpa.c
··· 520 520 return RX_DROP_UNUSABLE; 521 521 } 522 522 523 + /* reload hdr - skb might have been reallocated */ 524 + hdr = (void *)rx->skb->data; 525 + 523 526 data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - mic_len; 524 527 if (!rx->sta || data_len < 0) 525 528 return RX_DROP_UNUSABLE; ··· 751 748 if (skb_linearize(rx->skb)) 752 749 return RX_DROP_UNUSABLE; 753 750 } 751 + 752 + /* reload hdr - skb might have been reallocated */ 753 + hdr = (void *)rx->skb->data; 754 754 755 755 data_len = skb->len - hdrlen - IEEE80211_GCMP_HDR_LEN - mic_len; 756 756 if (!rx->sta || data_len < 0)
+1 -1
net/mptcp/mptcp_diag.c
··· 36 36 struct sock *sk; 37 37 38 38 net = sock_net(in_skb->sk); 39 - msk = mptcp_token_get_sock(req->id.idiag_cookie[0]); 39 + msk = mptcp_token_get_sock(net, req->id.idiag_cookie[0]); 40 40 if (!msk) 41 41 goto out_nosk; 42 42
+1 -3
net/mptcp/pm_netlink.c
··· 1718 1718 1719 1719 list_for_each_entry(entry, &pernet->local_addr_list, list) { 1720 1720 if (addresses_equal(&entry->addr, &addr.addr, true)) { 1721 - ret = mptcp_nl_addr_backup(net, &entry->addr, bkup); 1722 - if (ret) 1723 - return ret; 1721 + mptcp_nl_addr_backup(net, &entry->addr, bkup); 1724 1722 1725 1723 if (bkup) 1726 1724 entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
+1 -1
net/mptcp/protocol.c
··· 2735 2735 inet_csk(sk)->icsk_mtup.probe_timestamp = tcp_jiffies32; 2736 2736 mptcp_for_each_subflow(mptcp_sk(sk), subflow) { 2737 2737 struct sock *ssk = mptcp_subflow_tcp_sock(subflow); 2738 - bool slow = lock_sock_fast(ssk); 2738 + bool slow = lock_sock_fast_nested(ssk); 2739 2739 2740 2740 sock_orphan(ssk); 2741 2741 unlock_sock_fast(ssk, slow);
+1 -1
net/mptcp/protocol.h
··· 709 709 void mptcp_token_accept(struct mptcp_subflow_request_sock *r, 710 710 struct mptcp_sock *msk); 711 711 bool mptcp_token_exists(u32 token); 712 - struct mptcp_sock *mptcp_token_get_sock(u32 token); 712 + struct mptcp_sock *mptcp_token_get_sock(struct net *net, u32 token); 713 713 struct mptcp_sock *mptcp_token_iter_next(const struct net *net, long *s_slot, 714 714 long *s_num); 715 715 void mptcp_token_destroy(struct mptcp_sock *msk);
+1 -1
net/mptcp/subflow.c
··· 86 86 struct mptcp_sock *msk; 87 87 int local_id; 88 88 89 - msk = mptcp_token_get_sock(subflow_req->token); 89 + msk = mptcp_token_get_sock(sock_net(req_to_sk(req)), subflow_req->token); 90 90 if (!msk) { 91 91 SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINNOTOKEN); 92 92 return NULL;
+1 -12
net/mptcp/syncookies.c
··· 108 108 109 109 e->valid = 0; 110 110 111 - msk = mptcp_token_get_sock(e->token); 111 + msk = mptcp_token_get_sock(net, e->token); 112 112 if (!msk) { 113 113 spin_unlock_bh(&join_entry_locks[i]); 114 114 return false; 115 115 } 116 - 117 - /* If this fails, the token got re-used in the mean time by another 118 - * mptcp socket in a different netns, i.e. entry is outdated. 119 - */ 120 - if (!net_eq(sock_net((struct sock *)msk), net)) 121 - goto err_put; 122 116 123 117 subflow_req->remote_nonce = e->remote_nonce; 124 118 subflow_req->local_nonce = e->local_nonce; ··· 122 128 subflow_req->msk = msk; 123 129 spin_unlock_bh(&join_entry_locks[i]); 124 130 return true; 125 - 126 - err_put: 127 - spin_unlock_bh(&join_entry_locks[i]); 128 - sock_put((struct sock *)msk); 129 - return false; 130 131 } 131 132 132 133 void __init mptcp_join_cookie_init(void)
+8 -3
net/mptcp/token.c
··· 231 231 232 232 /** 233 233 * mptcp_token_get_sock - retrieve mptcp connection sock using its token 234 + * @net: restrict to this namespace 234 235 * @token: token of the mptcp connection to retrieve 235 236 * 236 237 * This function returns the mptcp connection structure with the given token. ··· 239 238 * 240 239 * returns NULL if no connection with the given token value exists. 241 240 */ 242 - struct mptcp_sock *mptcp_token_get_sock(u32 token) 241 + struct mptcp_sock *mptcp_token_get_sock(struct net *net, u32 token) 243 242 { 244 243 struct hlist_nulls_node *pos; 245 244 struct token_bucket *bucket; ··· 252 251 again: 253 252 sk_nulls_for_each_rcu(sk, pos, &bucket->msk_chain) { 254 253 msk = mptcp_sk(sk); 255 - if (READ_ONCE(msk->token) != token) 254 + if (READ_ONCE(msk->token) != token || 255 + !net_eq(sock_net(sk), net)) 256 256 continue; 257 + 257 258 if (!refcount_inc_not_zero(&sk->sk_refcnt)) 258 259 goto not_found; 259 - if (READ_ONCE(msk->token) != token) { 260 + 261 + if (READ_ONCE(msk->token) != token || 262 + !net_eq(sock_net(sk), net)) { 260 263 sock_put(sk); 261 264 goto again; 262 265 }
+8 -6
net/mptcp/token_test.c
··· 11 11 GFP_USER); 12 12 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, req); 13 13 mptcp_token_init_request((struct request_sock *)req); 14 + sock_net_set((struct sock *)req, &init_net); 14 15 return req; 15 16 } 16 17 ··· 23 22 KUNIT_ASSERT_EQ(test, 0, 24 23 mptcp_token_new_request((struct request_sock *)req)); 25 24 KUNIT_EXPECT_NE(test, 0, (int)req->token); 26 - KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(req->token)); 25 + KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(&init_net, req->token)); 27 26 28 27 /* cleanup */ 29 28 mptcp_token_destroy_request((struct request_sock *)req); ··· 56 55 msk = kunit_kzalloc(test, sizeof(struct mptcp_sock), GFP_USER); 57 56 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, msk); 58 57 refcount_set(&((struct sock *)msk)->sk_refcnt, 1); 58 + sock_net_set((struct sock *)msk, &init_net); 59 59 return msk; 60 60 } 61 61 ··· 76 74 mptcp_token_new_connect((struct sock *)icsk)); 77 75 KUNIT_EXPECT_NE(test, 0, (int)ctx->token); 78 76 KUNIT_EXPECT_EQ(test, ctx->token, msk->token); 79 - KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(ctx->token)); 77 + KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(&init_net, ctx->token)); 80 78 KUNIT_EXPECT_EQ(test, 2, (int)refcount_read(&sk->sk_refcnt)); 81 79 82 80 mptcp_token_destroy(msk); 83 - KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(ctx->token)); 81 + KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(&init_net, ctx->token)); 84 82 } 85 83 86 84 static void mptcp_token_test_accept(struct kunit *test) ··· 92 90 mptcp_token_new_request((struct request_sock *)req)); 93 91 msk->token = req->token; 94 92 mptcp_token_accept(req, msk); 95 - KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(msk->token)); 93 + KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(&init_net, msk->token)); 96 94 97 95 /* this is now a no-op */ 98 96 mptcp_token_destroy_request((struct request_sock *)req); 99 - KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(msk->token)); 97 + KUNIT_EXPECT_PTR_EQ(test, msk, mptcp_token_get_sock(&init_net, msk->token)); 100 98 101 99 /* cleanup */ 102 100 mptcp_token_destroy(msk); ··· 118 116 119 117 /* simulate race on removal */ 120 118 refcount_set(&sk->sk_refcnt, 0); 121 - KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(msk->token)); 119 + KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(&init_net, msk->token)); 122 120 123 121 /* cleanup */ 124 122 mptcp_token_destroy(msk);
+2 -2
net/netfilter/ipset/ip_set_hash_gen.h
··· 130 130 { 131 131 size_t hsize; 132 132 133 - /* We must fit both into u32 in jhash and size_t */ 133 + /* We must fit both into u32 in jhash and INT_MAX in kvmalloc_node() */ 134 134 if (hbits > 31) 135 135 return 0; 136 136 hsize = jhash_size(hbits); 137 - if ((((size_t)-1) - sizeof(struct htable)) / sizeof(struct hbucket *) 137 + if ((INT_MAX - sizeof(struct htable)) / sizeof(struct hbucket *) 138 138 < hsize) 139 139 return 0; 140 140
+4
net/netfilter/ipvs/ip_vs_conn.c
··· 1468 1468 int idx; 1469 1469 1470 1470 /* Compute size and mask */ 1471 + if (ip_vs_conn_tab_bits < 8 || ip_vs_conn_tab_bits > 20) { 1472 + pr_info("conn_tab_bits not in [8, 20]. Using default value\n"); 1473 + ip_vs_conn_tab_bits = CONFIG_IP_VS_TAB_BITS; 1474 + } 1471 1475 ip_vs_conn_tab_size = 1 << ip_vs_conn_tab_bits; 1472 1476 ip_vs_conn_tab_mask = ip_vs_conn_tab_size - 1; 1473 1477
+100 -54
net/netfilter/nf_conntrack_core.c
··· 74 74 static DEFINE_SPINLOCK(nf_conntrack_locks_all_lock); 75 75 static __read_mostly bool nf_conntrack_locks_all; 76 76 77 + /* serialize hash resizes and nf_ct_iterate_cleanup */ 78 + static DEFINE_MUTEX(nf_conntrack_mutex); 79 + 77 80 #define GC_SCAN_INTERVAL (120u * HZ) 78 81 #define GC_SCAN_MAX_DURATION msecs_to_jiffies(10) 79 82 80 - #define MAX_CHAINLEN 64u 83 + #define MIN_CHAINLEN 8u 84 + #define MAX_CHAINLEN (32u - MIN_CHAINLEN) 81 85 82 86 static struct conntrack_gc_work conntrack_gc_work; 83 87 ··· 192 188 static siphash_key_t nf_conntrack_hash_rnd __read_mostly; 193 189 194 190 static u32 hash_conntrack_raw(const struct nf_conntrack_tuple *tuple, 191 + unsigned int zoneid, 195 192 const struct net *net) 196 193 { 197 194 struct { 198 195 struct nf_conntrack_man src; 199 196 union nf_inet_addr dst_addr; 197 + unsigned int zone; 200 198 u32 net_mix; 201 199 u16 dport; 202 200 u16 proto; ··· 211 205 /* The direction must be ignored, so handle usable members manually. */ 212 206 combined.src = tuple->src; 213 207 combined.dst_addr = tuple->dst.u3; 208 + combined.zone = zoneid; 214 209 combined.net_mix = net_hash_mix(net); 215 210 combined.dport = (__force __u16)tuple->dst.u.all; 216 211 combined.proto = tuple->dst.protonum; ··· 226 219 227 220 static u32 __hash_conntrack(const struct net *net, 228 221 const struct nf_conntrack_tuple *tuple, 222 + unsigned int zoneid, 229 223 unsigned int size) 230 224 { 231 - return reciprocal_scale(hash_conntrack_raw(tuple, net), size); 225 + return reciprocal_scale(hash_conntrack_raw(tuple, zoneid, net), size); 232 226 } 233 227 234 228 static u32 hash_conntrack(const struct net *net, 235 - const struct nf_conntrack_tuple *tuple) 229 + const struct nf_conntrack_tuple *tuple, 230 + unsigned int zoneid) 236 231 { 237 - return scale_hash(hash_conntrack_raw(tuple, net)); 232 + return scale_hash(hash_conntrack_raw(tuple, zoneid, net)); 238 233 } 239 234 240 235 static bool nf_ct_get_tuple_ports(const struct sk_buff *skb, ··· 659 650 do { 660 651 sequence = read_seqcount_begin(&nf_conntrack_generation); 661 652 hash = hash_conntrack(net, 662 - &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 653 + &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, 654 + nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_ORIGINAL)); 663 655 reply_hash = hash_conntrack(net, 664 - &ct->tuplehash[IP_CT_DIR_REPLY].tuple); 656 + &ct->tuplehash[IP_CT_DIR_REPLY].tuple, 657 + nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_REPLY)); 665 658 } while (nf_conntrack_double_lock(net, hash, reply_hash, sequence)); 666 659 667 660 clean_from_lists(ct); ··· 830 819 nf_conntrack_find_get(struct net *net, const struct nf_conntrack_zone *zone, 831 820 const struct nf_conntrack_tuple *tuple) 832 821 { 833 - return __nf_conntrack_find_get(net, zone, tuple, 834 - hash_conntrack_raw(tuple, net)); 822 + unsigned int rid, zone_id = nf_ct_zone_id(zone, IP_CT_DIR_ORIGINAL); 823 + struct nf_conntrack_tuple_hash *thash; 824 + 825 + thash = __nf_conntrack_find_get(net, zone, tuple, 826 + hash_conntrack_raw(tuple, zone_id, net)); 827 + 828 + if (thash) 829 + return thash; 830 + 831 + rid = nf_ct_zone_id(zone, IP_CT_DIR_REPLY); 832 + if (rid != zone_id) 833 + return __nf_conntrack_find_get(net, zone, tuple, 834 + hash_conntrack_raw(tuple, rid, net)); 835 + return thash; 835 836 } 836 837 EXPORT_SYMBOL_GPL(nf_conntrack_find_get); 837 838 ··· 865 842 unsigned int hash, reply_hash; 866 843 struct nf_conntrack_tuple_hash *h; 867 844 struct hlist_nulls_node *n; 845 + unsigned int max_chainlen; 868 846 unsigned int chainlen = 0; 869 847 unsigned int sequence; 870 848 int err = -EEXIST; ··· 876 852 do { 877 853 sequence = read_seqcount_begin(&nf_conntrack_generation); 878 854 hash = hash_conntrack(net, 879 - &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 855 + &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, 856 + nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_ORIGINAL)); 880 857 reply_hash = hash_conntrack(net, 881 - &ct->tuplehash[IP_CT_DIR_REPLY].tuple); 858 + &ct->tuplehash[IP_CT_DIR_REPLY].tuple, 859 + nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_REPLY)); 882 860 } while (nf_conntrack_double_lock(net, hash, reply_hash, sequence)); 861 + 862 + max_chainlen = MIN_CHAINLEN + prandom_u32_max(MAX_CHAINLEN); 883 863 884 864 /* See if there's one in the list already, including reverse */ 885 865 hlist_nulls_for_each_entry(h, n, &nf_conntrack_hash[hash], hnnode) { ··· 891 863 zone, net)) 892 864 goto out; 893 865 894 - if (chainlen++ > MAX_CHAINLEN) 866 + if (chainlen++ > max_chainlen) 895 867 goto chaintoolong; 896 868 } 897 869 ··· 901 873 if (nf_ct_key_equal(h, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, 902 874 zone, net)) 903 875 goto out; 904 - if (chainlen++ > MAX_CHAINLEN) 876 + if (chainlen++ > max_chainlen) 905 877 goto chaintoolong; 906 878 } 907 879 ··· 1131 1103 int 1132 1104 __nf_conntrack_confirm(struct sk_buff *skb) 1133 1105 { 1106 + unsigned int chainlen = 0, sequence, max_chainlen; 1134 1107 const struct nf_conntrack_zone *zone; 1135 - unsigned int chainlen = 0, sequence; 1136 1108 unsigned int hash, reply_hash; 1137 1109 struct nf_conntrack_tuple_hash *h; 1138 1110 struct nf_conn *ct; ··· 1161 1133 hash = *(unsigned long *)&ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev; 1162 1134 hash = scale_hash(hash); 1163 1135 reply_hash = hash_conntrack(net, 1164 - &ct->tuplehash[IP_CT_DIR_REPLY].tuple); 1165 - 1136 + &ct->tuplehash[IP_CT_DIR_REPLY].tuple, 1137 + nf_ct_zone_id(nf_ct_zone(ct), IP_CT_DIR_REPLY)); 1166 1138 } while (nf_conntrack_double_lock(net, hash, reply_hash, sequence)); 1167 1139 1168 1140 /* We're not in hash table, and we refuse to set up related ··· 1196 1168 goto dying; 1197 1169 } 1198 1170 1171 + max_chainlen = MIN_CHAINLEN + prandom_u32_max(MAX_CHAINLEN); 1199 1172 /* See if there's one in the list already, including reverse: 1200 1173 NAT could have grabbed it without realizing, since we're 1201 1174 not in the hash. If there is, we lost race. */ ··· 1204 1175 if (nf_ct_key_equal(h, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, 1205 1176 zone, net)) 1206 1177 goto out; 1207 - if (chainlen++ > MAX_CHAINLEN) 1178 + if (chainlen++ > max_chainlen) 1208 1179 goto chaintoolong; 1209 1180 } 1210 1181 ··· 1213 1184 if (nf_ct_key_equal(h, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, 1214 1185 zone, net)) 1215 1186 goto out; 1216 - if (chainlen++ > MAX_CHAINLEN) { 1187 + if (chainlen++ > max_chainlen) { 1217 1188 chaintoolong: 1218 1189 nf_ct_add_to_dying_list(ct); 1219 1190 NF_CT_STAT_INC(net, chaintoolong); ··· 1275 1246 rcu_read_lock(); 1276 1247 begin: 1277 1248 nf_conntrack_get_ht(&ct_hash, &hsize); 1278 - hash = __hash_conntrack(net, tuple, hsize); 1249 + hash = __hash_conntrack(net, tuple, nf_ct_zone_id(zone, IP_CT_DIR_REPLY), hsize); 1279 1250 1280 1251 hlist_nulls_for_each_entry_rcu(h, n, &ct_hash[hash], hnnode) { 1281 1252 ct = nf_ct_tuplehash_to_ctrack(h); ··· 1716 1687 struct nf_conntrack_tuple_hash *h; 1717 1688 enum ip_conntrack_info ctinfo; 1718 1689 struct nf_conntrack_zone tmp; 1690 + u32 hash, zone_id, rid; 1719 1691 struct nf_conn *ct; 1720 - u32 hash; 1721 1692 1722 1693 if (!nf_ct_get_tuple(skb, skb_network_offset(skb), 1723 1694 dataoff, state->pf, protonum, state->net, ··· 1728 1699 1729 1700 /* look for tuple match */ 1730 1701 zone = nf_ct_zone_tmpl(tmpl, skb, &tmp); 1731 - hash = hash_conntrack_raw(&tuple, state->net); 1702 + 1703 + zone_id = nf_ct_zone_id(zone, IP_CT_DIR_ORIGINAL); 1704 + hash = hash_conntrack_raw(&tuple, zone_id, state->net); 1732 1705 h = __nf_conntrack_find_get(state->net, zone, &tuple, hash); 1706 + 1707 + if (!h) { 1708 + rid = nf_ct_zone_id(zone, IP_CT_DIR_REPLY); 1709 + if (zone_id != rid) { 1710 + u32 tmp = hash_conntrack_raw(&tuple, rid, state->net); 1711 + 1712 + h = __nf_conntrack_find_get(state->net, zone, &tuple, tmp); 1713 + } 1714 + } 1715 + 1733 1716 if (!h) { 1734 1717 h = init_conntrack(state->net, tmpl, &tuple, 1735 1718 skb, dataoff, hash); ··· 2266 2225 spinlock_t *lockp; 2267 2226 2268 2227 for (; *bucket < nf_conntrack_htable_size; (*bucket)++) { 2228 + struct hlist_nulls_head *hslot = &nf_conntrack_hash[*bucket]; 2229 + 2230 + if (hlist_nulls_empty(hslot)) 2231 + continue; 2232 + 2269 2233 lockp = &nf_conntrack_locks[*bucket % CONNTRACK_LOCKS]; 2270 2234 local_bh_disable(); 2271 2235 nf_conntrack_lock(lockp); 2272 - if (*bucket < nf_conntrack_htable_size) { 2273 - hlist_nulls_for_each_entry(h, n, &nf_conntrack_hash[*bucket], hnnode) { 2274 - if (NF_CT_DIRECTION(h) != IP_CT_DIR_REPLY) 2275 - continue; 2276 - /* All nf_conn objects are added to hash table twice, one 2277 - * for original direction tuple, once for the reply tuple. 2278 - * 2279 - * Exception: In the IPS_NAT_CLASH case, only the reply 2280 - * tuple is added (the original tuple already existed for 2281 - * a different object). 2282 - * 2283 - * We only need to call the iterator once for each 2284 - * conntrack, so we just use the 'reply' direction 2285 - * tuple while iterating. 2286 - */ 2287 - ct = nf_ct_tuplehash_to_ctrack(h); 2288 - if (iter(ct, data)) 2289 - goto found; 2290 - } 2236 + hlist_nulls_for_each_entry(h, n, hslot, hnnode) { 2237 + if (NF_CT_DIRECTION(h) != IP_CT_DIR_REPLY) 2238 + continue; 2239 + /* All nf_conn objects are added to hash table twice, one 2240 + * for original direction tuple, once for the reply tuple. 2241 + * 2242 + * Exception: In the IPS_NAT_CLASH case, only the reply 2243 + * tuple is added (the original tuple already existed for 2244 + * a different object). 2245 + * 2246 + * We only need to call the iterator once for each 2247 + * conntrack, so we just use the 'reply' direction 2248 + * tuple while iterating. 2249 + */ 2250 + ct = nf_ct_tuplehash_to_ctrack(h); 2251 + if (iter(ct, data)) 2252 + goto found; 2291 2253 } 2292 2254 spin_unlock(lockp); 2293 2255 local_bh_enable(); ··· 2308 2264 static void nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), 2309 2265 void *data, u32 portid, int report) 2310 2266 { 2311 - unsigned int bucket = 0, sequence; 2267 + unsigned int bucket = 0; 2312 2268 struct nf_conn *ct; 2313 2269 2314 2270 might_sleep(); 2315 2271 2316 - for (;;) { 2317 - sequence = read_seqcount_begin(&nf_conntrack_generation); 2272 + mutex_lock(&nf_conntrack_mutex); 2273 + while ((ct = get_next_corpse(iter, data, &bucket)) != NULL) { 2274 + /* Time to push up daises... */ 2318 2275 2319 - while ((ct = get_next_corpse(iter, data, &bucket)) != NULL) { 2320 - /* Time to push up daises... */ 2321 - 2322 - nf_ct_delete(ct, portid, report); 2323 - nf_ct_put(ct); 2324 - cond_resched(); 2325 - } 2326 - 2327 - if (!read_seqcount_retry(&nf_conntrack_generation, sequence)) 2328 - break; 2329 - bucket = 0; 2276 + nf_ct_delete(ct, portid, report); 2277 + nf_ct_put(ct); 2278 + cond_resched(); 2330 2279 } 2280 + mutex_unlock(&nf_conntrack_mutex); 2331 2281 } 2332 2282 2333 2283 struct iter_data { ··· 2557 2519 if (!hash) 2558 2520 return -ENOMEM; 2559 2521 2522 + mutex_lock(&nf_conntrack_mutex); 2560 2523 old_size = nf_conntrack_htable_size; 2561 2524 if (old_size == hashsize) { 2525 + mutex_unlock(&nf_conntrack_mutex); 2562 2526 kvfree(hash); 2563 2527 return 0; 2564 2528 } ··· 2577 2537 2578 2538 for (i = 0; i < nf_conntrack_htable_size; i++) { 2579 2539 while (!hlist_nulls_empty(&nf_conntrack_hash[i])) { 2540 + unsigned int zone_id; 2541 + 2580 2542 h = hlist_nulls_entry(nf_conntrack_hash[i].first, 2581 2543 struct nf_conntrack_tuple_hash, hnnode); 2582 2544 ct = nf_ct_tuplehash_to_ctrack(h); 2583 2545 hlist_nulls_del_rcu(&h->hnnode); 2546 + 2547 + zone_id = nf_ct_zone_id(nf_ct_zone(ct), NF_CT_DIRECTION(h)); 2584 2548 bucket = __hash_conntrack(nf_ct_net(ct), 2585 - &h->tuple, hashsize); 2549 + &h->tuple, zone_id, hashsize); 2586 2550 hlist_nulls_add_head_rcu(&h->hnnode, &hash[bucket]); 2587 2551 } 2588 2552 } ··· 2599 2555 write_seqcount_end(&nf_conntrack_generation); 2600 2556 nf_conntrack_all_unlock(); 2601 2557 local_bh_enable(); 2558 + 2559 + mutex_unlock(&nf_conntrack_mutex); 2602 2560 2603 2561 synchronize_net(); 2604 2562 kvfree(old_hash);
+12 -5
net/netfilter/nf_nat_core.c
··· 150 150 151 151 /* We keep an extra hash for each conntrack, for fast searching. */ 152 152 static unsigned int 153 - hash_by_src(const struct net *n, const struct nf_conntrack_tuple *tuple) 153 + hash_by_src(const struct net *net, 154 + const struct nf_conntrack_zone *zone, 155 + const struct nf_conntrack_tuple *tuple) 154 156 { 155 157 unsigned int hash; 156 158 struct { 157 159 struct nf_conntrack_man src; 158 160 u32 net_mix; 159 161 u32 protonum; 162 + u32 zone; 160 163 } __aligned(SIPHASH_ALIGNMENT) combined; 161 164 162 165 get_random_once(&nf_nat_hash_rnd, sizeof(nf_nat_hash_rnd)); ··· 168 165 169 166 /* Original src, to ensure we map it consistently if poss. */ 170 167 combined.src = tuple->src; 171 - combined.net_mix = net_hash_mix(n); 168 + combined.net_mix = net_hash_mix(net); 172 169 combined.protonum = tuple->dst.protonum; 170 + 171 + /* Zone ID can be used provided its valid for both directions */ 172 + if (zone->dir == NF_CT_DEFAULT_ZONE_DIR) 173 + combined.zone = zone->id; 173 174 174 175 hash = siphash(&combined, sizeof(combined), &nf_nat_hash_rnd); 175 176 ··· 279 272 struct nf_conntrack_tuple *result, 280 273 const struct nf_nat_range2 *range) 281 274 { 282 - unsigned int h = hash_by_src(net, tuple); 275 + unsigned int h = hash_by_src(net, zone, tuple); 283 276 const struct nf_conn *ct; 284 277 285 278 hlist_for_each_entry_rcu(ct, &nf_nat_bysource[h], nat_bysource) { ··· 626 619 unsigned int srchash; 627 620 spinlock_t *lock; 628 621 629 - srchash = hash_by_src(net, 622 + srchash = hash_by_src(net, nf_ct_zone(ct), 630 623 &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 631 624 lock = &nf_nat_locks[srchash % CONNTRACK_LOCKS]; 632 625 spin_lock_bh(lock); ··· 795 788 { 796 789 unsigned int h; 797 790 798 - h = hash_by_src(nf_ct_net(ct), &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 791 + h = hash_by_src(nf_ct_net(ct), nf_ct_zone(ct), &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 799 792 spin_lock_bh(&nf_nat_locks[h % CONNTRACK_LOCKS]); 800 793 hlist_del_rcu(&ct->nat_bysource); 801 794 spin_unlock_bh(&nf_nat_locks[h % CONNTRACK_LOCKS]);
+97 -71
net/netfilter/nf_nat_masquerade.c
··· 9 9 10 10 #include <net/netfilter/nf_nat_masquerade.h> 11 11 12 + struct masq_dev_work { 13 + struct work_struct work; 14 + struct net *net; 15 + union nf_inet_addr addr; 16 + int ifindex; 17 + int (*iter)(struct nf_conn *i, void *data); 18 + }; 19 + 20 + #define MAX_MASQ_WORKER_COUNT 16 21 + 12 22 static DEFINE_MUTEX(masq_mutex); 13 23 static unsigned int masq_refcnt __read_mostly; 24 + static atomic_t masq_worker_count __read_mostly; 14 25 15 26 unsigned int 16 27 nf_nat_masquerade_ipv4(struct sk_buff *skb, unsigned int hooknum, ··· 74 63 } 75 64 EXPORT_SYMBOL_GPL(nf_nat_masquerade_ipv4); 76 65 77 - static int device_cmp(struct nf_conn *i, void *ifindex) 66 + static void iterate_cleanup_work(struct work_struct *work) 67 + { 68 + struct masq_dev_work *w; 69 + 70 + w = container_of(work, struct masq_dev_work, work); 71 + 72 + nf_ct_iterate_cleanup_net(w->net, w->iter, (void *)w, 0, 0); 73 + 74 + put_net(w->net); 75 + kfree(w); 76 + atomic_dec(&masq_worker_count); 77 + module_put(THIS_MODULE); 78 + } 79 + 80 + /* Iterate conntrack table in the background and remove conntrack entries 81 + * that use the device/address being removed. 82 + * 83 + * In case too many work items have been queued already or memory allocation 84 + * fails iteration is skipped, conntrack entries will time out eventually. 85 + */ 86 + static void nf_nat_masq_schedule(struct net *net, union nf_inet_addr *addr, 87 + int ifindex, 88 + int (*iter)(struct nf_conn *i, void *data), 89 + gfp_t gfp_flags) 90 + { 91 + struct masq_dev_work *w; 92 + 93 + if (atomic_read(&masq_worker_count) > MAX_MASQ_WORKER_COUNT) 94 + return; 95 + 96 + net = maybe_get_net(net); 97 + if (!net) 98 + return; 99 + 100 + if (!try_module_get(THIS_MODULE)) 101 + goto err_module; 102 + 103 + w = kzalloc(sizeof(*w), gfp_flags); 104 + if (w) { 105 + /* We can overshoot MAX_MASQ_WORKER_COUNT, no big deal */ 106 + atomic_inc(&masq_worker_count); 107 + 108 + INIT_WORK(&w->work, iterate_cleanup_work); 109 + w->ifindex = ifindex; 110 + w->net = net; 111 + w->iter = iter; 112 + if (addr) 113 + w->addr = *addr; 114 + schedule_work(&w->work); 115 + return; 116 + } 117 + 118 + module_put(THIS_MODULE); 119 + err_module: 120 + put_net(net); 121 + } 122 + 123 + static int device_cmp(struct nf_conn *i, void *arg) 78 124 { 79 125 const struct nf_conn_nat *nat = nfct_nat(i); 126 + const struct masq_dev_work *w = arg; 80 127 81 128 if (!nat) 82 129 return 0; 83 - return nat->masq_index == (int)(long)ifindex; 130 + return nat->masq_index == w->ifindex; 84 131 } 85 132 86 133 static int masq_device_event(struct notifier_block *this, ··· 154 85 * and forget them. 155 86 */ 156 87 157 - nf_ct_iterate_cleanup_net(net, device_cmp, 158 - (void *)(long)dev->ifindex, 0, 0); 88 + nf_nat_masq_schedule(net, NULL, dev->ifindex, 89 + device_cmp, GFP_KERNEL); 159 90 } 160 91 161 92 return NOTIFY_DONE; ··· 163 94 164 95 static int inet_cmp(struct nf_conn *ct, void *ptr) 165 96 { 166 - struct in_ifaddr *ifa = (struct in_ifaddr *)ptr; 167 - struct net_device *dev = ifa->ifa_dev->dev; 168 97 struct nf_conntrack_tuple *tuple; 98 + struct masq_dev_work *w = ptr; 169 99 170 - if (!device_cmp(ct, (void *)(long)dev->ifindex)) 100 + if (!device_cmp(ct, ptr)) 171 101 return 0; 172 102 173 103 tuple = &ct->tuplehash[IP_CT_DIR_REPLY].tuple; 174 104 175 - return ifa->ifa_address == tuple->dst.u3.ip; 105 + return nf_inet_addr_cmp(&w->addr, &tuple->dst.u3); 176 106 } 177 107 178 108 static int masq_inet_event(struct notifier_block *this, 179 109 unsigned long event, 180 110 void *ptr) 181 111 { 182 - struct in_device *idev = ((struct in_ifaddr *)ptr)->ifa_dev; 183 - struct net *net = dev_net(idev->dev); 112 + const struct in_ifaddr *ifa = ptr; 113 + const struct in_device *idev; 114 + const struct net_device *dev; 115 + union nf_inet_addr addr; 116 + 117 + if (event != NETDEV_DOWN) 118 + return NOTIFY_DONE; 184 119 185 120 /* The masq_dev_notifier will catch the case of the device going 186 121 * down. So if the inetdev is dead and being destroyed we have 187 122 * no work to do. Otherwise this is an individual address removal 188 123 * and we have to perform the flush. 189 124 */ 125 + idev = ifa->ifa_dev; 190 126 if (idev->dead) 191 127 return NOTIFY_DONE; 192 128 193 - if (event == NETDEV_DOWN) 194 - nf_ct_iterate_cleanup_net(net, inet_cmp, ptr, 0, 0); 129 + memset(&addr, 0, sizeof(addr)); 130 + 131 + addr.ip = ifa->ifa_address; 132 + 133 + dev = idev->dev; 134 + nf_nat_masq_schedule(dev_net(idev->dev), &addr, dev->ifindex, 135 + inet_cmp, GFP_KERNEL); 195 136 196 137 return NOTIFY_DONE; 197 138 } ··· 215 136 }; 216 137 217 138 #if IS_ENABLED(CONFIG_IPV6) 218 - static atomic_t v6_worker_count __read_mostly; 219 - 220 139 static int 221 140 nat_ipv6_dev_get_saddr(struct net *net, const struct net_device *dev, 222 141 const struct in6_addr *daddr, unsigned int srcprefs, ··· 264 187 } 265 188 EXPORT_SYMBOL_GPL(nf_nat_masquerade_ipv6); 266 189 267 - struct masq_dev_work { 268 - struct work_struct work; 269 - struct net *net; 270 - struct in6_addr addr; 271 - int ifindex; 272 - }; 273 - 274 - static int inet6_cmp(struct nf_conn *ct, void *work) 275 - { 276 - struct masq_dev_work *w = (struct masq_dev_work *)work; 277 - struct nf_conntrack_tuple *tuple; 278 - 279 - if (!device_cmp(ct, (void *)(long)w->ifindex)) 280 - return 0; 281 - 282 - tuple = &ct->tuplehash[IP_CT_DIR_REPLY].tuple; 283 - 284 - return ipv6_addr_equal(&w->addr, &tuple->dst.u3.in6); 285 - } 286 - 287 - static void iterate_cleanup_work(struct work_struct *work) 288 - { 289 - struct masq_dev_work *w; 290 - 291 - w = container_of(work, struct masq_dev_work, work); 292 - 293 - nf_ct_iterate_cleanup_net(w->net, inet6_cmp, (void *)w, 0, 0); 294 - 295 - put_net(w->net); 296 - kfree(w); 297 - atomic_dec(&v6_worker_count); 298 - module_put(THIS_MODULE); 299 - } 300 - 301 190 /* atomic notifier; can't call nf_ct_iterate_cleanup_net (it can sleep). 302 191 * 303 192 * Defer it to the system workqueue. ··· 276 233 { 277 234 struct inet6_ifaddr *ifa = ptr; 278 235 const struct net_device *dev; 279 - struct masq_dev_work *w; 280 - struct net *net; 236 + union nf_inet_addr addr; 281 237 282 - if (event != NETDEV_DOWN || atomic_read(&v6_worker_count) >= 16) 238 + if (event != NETDEV_DOWN) 283 239 return NOTIFY_DONE; 284 240 285 241 dev = ifa->idev->dev; 286 - net = maybe_get_net(dev_net(dev)); 287 - if (!net) 288 - return NOTIFY_DONE; 289 242 290 - if (!try_module_get(THIS_MODULE)) 291 - goto err_module; 243 + memset(&addr, 0, sizeof(addr)); 292 244 293 - w = kmalloc(sizeof(*w), GFP_ATOMIC); 294 - if (w) { 295 - atomic_inc(&v6_worker_count); 245 + addr.in6 = ifa->addr; 296 246 297 - INIT_WORK(&w->work, iterate_cleanup_work); 298 - w->ifindex = dev->ifindex; 299 - w->net = net; 300 - w->addr = ifa->addr; 301 - schedule_work(&w->work); 302 - 303 - return NOTIFY_DONE; 304 - } 305 - 306 - module_put(THIS_MODULE); 307 - err_module: 308 - put_net(net); 247 + nf_nat_masq_schedule(dev_net(dev), &addr, dev->ifindex, inet_cmp, 248 + GFP_ATOMIC); 309 249 return NOTIFY_DONE; 310 250 } 311 251
+19 -11
net/netfilter/nf_tables_api.c
··· 4336 4336 if (ops->privsize != NULL) 4337 4337 size = ops->privsize(nla, &desc); 4338 4338 alloc_size = sizeof(*set) + size + udlen; 4339 - if (alloc_size < size) 4339 + if (alloc_size < size || alloc_size > INT_MAX) 4340 4340 return -ENOMEM; 4341 4341 set = kvzalloc(alloc_size, GFP_KERNEL); 4342 4342 if (!set) ··· 9599 9599 table->use--; 9600 9600 nf_tables_chain_destroy(&ctx); 9601 9601 } 9602 - list_del(&table->list); 9603 9602 nf_tables_table_destroy(&ctx); 9604 9603 } 9605 9604 ··· 9611 9612 if (nft_table_has_owner(table)) 9612 9613 continue; 9613 9614 9615 + list_del(&table->list); 9616 + 9614 9617 __nft_release_table(net, table); 9615 9618 } 9616 9619 } ··· 9620 9619 static int nft_rcv_nl_event(struct notifier_block *this, unsigned long event, 9621 9620 void *ptr) 9622 9621 { 9622 + struct nft_table *table, *to_delete[8]; 9623 9623 struct nftables_pernet *nft_net; 9624 9624 struct netlink_notify *n = ptr; 9625 - struct nft_table *table, *nt; 9626 9625 struct net *net = n->net; 9627 - bool release = false; 9626 + unsigned int deleted; 9627 + bool restart = false; 9628 9628 9629 9629 if (event != NETLINK_URELEASE || n->protocol != NETLINK_NETFILTER) 9630 9630 return NOTIFY_DONE; 9631 9631 9632 9632 nft_net = nft_pernet(net); 9633 + deleted = 0; 9633 9634 mutex_lock(&nft_net->commit_mutex); 9635 + again: 9634 9636 list_for_each_entry(table, &nft_net->tables, list) { 9635 9637 if (nft_table_has_owner(table) && 9636 9638 n->portid == table->nlpid) { 9637 9639 __nft_release_hook(net, table); 9638 - release = true; 9640 + list_del_rcu(&table->list); 9641 + to_delete[deleted++] = table; 9642 + if (deleted >= ARRAY_SIZE(to_delete)) 9643 + break; 9639 9644 } 9640 9645 } 9641 - if (release) { 9646 + if (deleted) { 9647 + restart = deleted >= ARRAY_SIZE(to_delete); 9642 9648 synchronize_rcu(); 9643 - list_for_each_entry_safe(table, nt, &nft_net->tables, list) { 9644 - if (nft_table_has_owner(table) && 9645 - n->portid == table->nlpid) 9646 - __nft_release_table(net, table); 9647 - } 9649 + while (deleted) 9650 + __nft_release_table(net, to_delete[--deleted]); 9651 + 9652 + if (restart) 9653 + goto again; 9648 9654 } 9649 9655 mutex_unlock(&nft_net->commit_mutex); 9650 9656
+16 -1
net/netfilter/nft_compat.c
··· 19 19 #include <linux/netfilter_bridge/ebtables.h> 20 20 #include <linux/netfilter_arp/arp_tables.h> 21 21 #include <net/netfilter/nf_tables.h> 22 + #include <net/netfilter/nf_log.h> 22 23 23 24 /* Used for matches where *info is larger than X byte */ 24 25 #define NFT_MATCH_LARGE_THRESH 192 ··· 258 257 nft_compat_wait_for_destructors(); 259 258 260 259 ret = xt_check_target(&par, size, proto, inv); 261 - if (ret < 0) 260 + if (ret < 0) { 261 + if (ret == -ENOENT) { 262 + const char *modname = NULL; 263 + 264 + if (strcmp(target->name, "LOG") == 0) 265 + modname = "nf_log_syslog"; 266 + else if (strcmp(target->name, "NFLOG") == 0) 267 + modname = "nfnetlink_log"; 268 + 269 + if (modname && 270 + nft_request_module(ctx->net, "%s", modname) == -EAGAIN) 271 + return -EAGAIN; 272 + } 273 + 262 274 return ret; 275 + } 263 276 264 277 /* The standard target cannot be used */ 265 278 if (!target->target)
+9 -1
net/netfilter/xt_LOG.c
··· 44 44 static int log_tg_check(const struct xt_tgchk_param *par) 45 45 { 46 46 const struct xt_log_info *loginfo = par->targinfo; 47 + int ret; 47 48 48 49 if (par->family != NFPROTO_IPV4 && par->family != NFPROTO_IPV6) 49 50 return -EINVAL; ··· 59 58 return -EINVAL; 60 59 } 61 60 62 - return nf_logger_find_get(par->family, NF_LOG_TYPE_LOG); 61 + ret = nf_logger_find_get(par->family, NF_LOG_TYPE_LOG); 62 + if (ret != 0 && !par->nft_compat) { 63 + request_module("%s", "nf_log_syslog"); 64 + 65 + ret = nf_logger_find_get(par->family, NF_LOG_TYPE_LOG); 66 + } 67 + 68 + return ret; 63 69 } 64 70 65 71 static void log_tg_destroy(const struct xt_tgdtor_param *par)
+9 -1
net/netfilter/xt_NFLOG.c
··· 42 42 static int nflog_tg_check(const struct xt_tgchk_param *par) 43 43 { 44 44 const struct xt_nflog_info *info = par->targinfo; 45 + int ret; 45 46 46 47 if (info->flags & ~XT_NFLOG_MASK) 47 48 return -EINVAL; 48 49 if (info->prefix[sizeof(info->prefix) - 1] != '\0') 49 50 return -EINVAL; 50 51 51 - return nf_logger_find_get(par->family, NF_LOG_TYPE_ULOG); 52 + ret = nf_logger_find_get(par->family, NF_LOG_TYPE_ULOG); 53 + if (ret != 0 && !par->nft_compat) { 54 + request_module("%s", "nfnetlink_log"); 55 + 56 + ret = nf_logger_find_get(par->family, NF_LOG_TYPE_ULOG); 57 + } 58 + 59 + return ret; 52 60 } 53 61 54 62 static void nflog_tg_destroy(const struct xt_tgdtor_param *par)
+6
net/sched/cls_flower.c
··· 2188 2188 2189 2189 arg->count = arg->skip; 2190 2190 2191 + rcu_read_lock(); 2191 2192 idr_for_each_entry_continue_ul(&head->handle_idr, f, tmp, id) { 2192 2193 /* don't return filters that are being deleted */ 2193 2194 if (!refcount_inc_not_zero(&f->refcnt)) 2194 2195 continue; 2196 + rcu_read_unlock(); 2197 + 2195 2198 if (arg->fn(tp, f, arg) < 0) { 2196 2199 __fl_put(f); 2197 2200 arg->stop = 1; 2201 + rcu_read_lock(); 2198 2202 break; 2199 2203 } 2200 2204 __fl_put(f); 2201 2205 arg->count++; 2206 + rcu_read_lock(); 2202 2207 } 2208 + rcu_read_unlock(); 2203 2209 arg->cookie = id; 2204 2210 } 2205 2211
+6
net/sched/sch_api.c
··· 513 513 return stab; 514 514 } 515 515 516 + if (s->size_log > STAB_SIZE_LOG_MAX || 517 + s->cell_log > STAB_SIZE_LOG_MAX) { 518 + NL_SET_ERR_MSG(extack, "Invalid logarithmic size of size table"); 519 + return ERR_PTR(-EINVAL); 520 + } 521 + 516 522 stab = kmalloc(sizeof(*stab) + tsize * sizeof(u16), GFP_KERNEL); 517 523 if (!stab) 518 524 return ERR_PTR(-ENOMEM);
+1 -1
net/sctp/input.c
··· 702 702 ch = skb_header_pointer(skb, offset, sizeof(*ch), &_ch); 703 703 704 704 /* Break out if chunk length is less then minimal. */ 705 - if (ntohs(ch->length) < sizeof(_ch)) 705 + if (!ch || ntohs(ch->length) < sizeof(_ch)) 706 706 break; 707 707 708 708 ch_end = offset + SCTP_PAD4(ntohs(ch->length));
+60 -23
net/unix/af_unix.c
··· 608 608 609 609 static void init_peercred(struct sock *sk) 610 610 { 611 - put_pid(sk->sk_peer_pid); 612 - if (sk->sk_peer_cred) 613 - put_cred(sk->sk_peer_cred); 611 + const struct cred *old_cred; 612 + struct pid *old_pid; 613 + 614 + spin_lock(&sk->sk_peer_lock); 615 + old_pid = sk->sk_peer_pid; 616 + old_cred = sk->sk_peer_cred; 614 617 sk->sk_peer_pid = get_pid(task_tgid(current)); 615 618 sk->sk_peer_cred = get_current_cred(); 619 + spin_unlock(&sk->sk_peer_lock); 620 + 621 + put_pid(old_pid); 622 + put_cred(old_cred); 616 623 } 617 624 618 625 static void copy_peercred(struct sock *sk, struct sock *peersk) 619 626 { 620 - put_pid(sk->sk_peer_pid); 621 - if (sk->sk_peer_cred) 622 - put_cred(sk->sk_peer_cred); 627 + const struct cred *old_cred; 628 + struct pid *old_pid; 629 + 630 + if (sk < peersk) { 631 + spin_lock(&sk->sk_peer_lock); 632 + spin_lock_nested(&peersk->sk_peer_lock, SINGLE_DEPTH_NESTING); 633 + } else { 634 + spin_lock(&peersk->sk_peer_lock); 635 + spin_lock_nested(&sk->sk_peer_lock, SINGLE_DEPTH_NESTING); 636 + } 637 + old_pid = sk->sk_peer_pid; 638 + old_cred = sk->sk_peer_cred; 623 639 sk->sk_peer_pid = get_pid(peersk->sk_peer_pid); 624 640 sk->sk_peer_cred = get_cred(peersk->sk_peer_cred); 641 + 642 + spin_unlock(&sk->sk_peer_lock); 643 + spin_unlock(&peersk->sk_peer_lock); 644 + 645 + put_pid(old_pid); 646 + put_cred(old_cred); 625 647 } 626 648 627 649 static int unix_listen(struct socket *sock, int backlog) ··· 850 828 851 829 static struct sock *unix_create1(struct net *net, struct socket *sock, int kern, int type) 852 830 { 853 - struct sock *sk = NULL; 854 831 struct unix_sock *u; 832 + struct sock *sk; 833 + int err; 855 834 856 835 atomic_long_inc(&unix_nr_socks); 857 - if (atomic_long_read(&unix_nr_socks) > 2 * get_max_files()) 858 - goto out; 836 + if (atomic_long_read(&unix_nr_socks) > 2 * get_max_files()) { 837 + err = -ENFILE; 838 + goto err; 839 + } 859 840 860 841 if (type == SOCK_STREAM) 861 842 sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_stream_proto, kern); 862 843 else /*dgram and seqpacket */ 863 844 sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_dgram_proto, kern); 864 845 865 - if (!sk) 866 - goto out; 846 + if (!sk) { 847 + err = -ENOMEM; 848 + goto err; 849 + } 867 850 868 851 sock_init_data(sock, sk); 869 852 ··· 888 861 init_waitqueue_func_entry(&u->peer_wake, unix_dgram_peer_wake_relay); 889 862 memset(&u->scm_stat, 0, sizeof(struct scm_stat)); 890 863 unix_insert_socket(unix_sockets_unbound(sk), sk); 891 - out: 892 - if (sk == NULL) 893 - atomic_long_dec(&unix_nr_socks); 894 - else { 895 - local_bh_disable(); 896 - sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 897 - local_bh_enable(); 898 - } 864 + 865 + local_bh_disable(); 866 + sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 867 + local_bh_enable(); 868 + 899 869 return sk; 870 + 871 + err: 872 + atomic_long_dec(&unix_nr_socks); 873 + return ERR_PTR(err); 900 874 } 901 875 902 876 static int unix_create(struct net *net, struct socket *sock, int protocol, 903 877 int kern) 904 878 { 879 + struct sock *sk; 880 + 905 881 if (protocol && protocol != PF_UNIX) 906 882 return -EPROTONOSUPPORT; 907 883 ··· 931 901 return -ESOCKTNOSUPPORT; 932 902 } 933 903 934 - return unix_create1(net, sock, kern, sock->type) ? 0 : -ENOMEM; 904 + sk = unix_create1(net, sock, kern, sock->type); 905 + if (IS_ERR(sk)) 906 + return PTR_ERR(sk); 907 + 908 + return 0; 935 909 } 936 910 937 911 static int unix_release(struct socket *sock) ··· 1348 1314 we will have to recheck all again in any case. 1349 1315 */ 1350 1316 1351 - err = -ENOMEM; 1352 - 1353 1317 /* create new sock for complete connection */ 1354 1318 newsk = unix_create1(sock_net(sk), NULL, 0, sock->type); 1355 - if (newsk == NULL) 1319 + if (IS_ERR(newsk)) { 1320 + err = PTR_ERR(newsk); 1321 + newsk = NULL; 1356 1322 goto out; 1323 + } 1324 + 1325 + err = -ENOMEM; 1357 1326 1358 1327 /* Allocate skb for sending to listening sock */ 1359 1328 skb = sock_wmalloc(newsk, 1, 0, GFP_KERNEL);
+9
sound/core/rawmidi.c
··· 873 873 return -EINVAL; 874 874 } 875 875 } 876 + case SNDRV_RAWMIDI_IOCTL_USER_PVERSION: 877 + if (get_user(rfile->user_pversion, (unsigned int __user *)arg)) 878 + return -EFAULT; 879 + return 0; 880 + 876 881 case SNDRV_RAWMIDI_IOCTL_PARAMS: 877 882 { 878 883 struct snd_rawmidi_params params; 879 884 880 885 if (copy_from_user(&params, argp, sizeof(struct snd_rawmidi_params))) 881 886 return -EFAULT; 887 + if (rfile->user_pversion < SNDRV_PROTOCOL_VERSION(2, 0, 2)) { 888 + params.mode = 0; 889 + memset(params.reserved, 0, sizeof(params.reserved)); 890 + } 882 891 switch (params.stream) { 883 892 case SNDRV_RAWMIDI_STREAM_OUTPUT: 884 893 if (rfile->output == NULL)
+1 -1
sound/drivers/pcsp/pcsp_lib.c
··· 143 143 if (pointer_update) 144 144 pcsp_pointer_update(chip); 145 145 146 - hrtimer_forward(handle, hrtimer_get_expires(handle), ns_to_ktime(ns)); 146 + hrtimer_forward_now(handle, ns_to_ktime(ns)); 147 147 148 148 return HRTIMER_RESTART; 149 149 }
+4 -3
sound/firewire/motu/amdtp-motu.c
··· 276 276 277 277 /* This is just for v2/v3 protocol. */ 278 278 for (i = 0; i < data_blocks; ++i) { 279 - *frames = (be32_to_cpu(buffer[1]) << 16) | 280 - (be32_to_cpu(buffer[2]) >> 16); 279 + *frames = be32_to_cpu(buffer[1]); 280 + *frames <<= 16; 281 + *frames |= be32_to_cpu(buffer[2]) >> 16; 282 + ++frames; 281 283 buffer += data_block_quadlets; 282 - frames++; 283 284 } 284 285 } 285 286
+8 -5
sound/firewire/oxfw/oxfw.c
··· 184 184 model = val; 185 185 } 186 186 187 - /* 188 - * Mackie Onyx Satellite with base station has a quirk to report a wrong 189 - * value in 'dbs' field of CIP header against its format information. 190 - */ 191 - if (vendor == VENDOR_LOUD && model == MODEL_SATELLITE) 187 + if (vendor == VENDOR_LOUD) { 188 + // Mackie Onyx Satellite with base station has a quirk to report a wrong 189 + // value in 'dbs' field of CIP header against its format information. 192 190 oxfw->quirks |= SND_OXFW_QUIRK_WRONG_DBS; 191 + 192 + // OXFW971-based models may transfer events by blocking method. 193 + if (!(oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD)) 194 + oxfw->quirks |= SND_OXFW_QUIRK_BLOCKING_TRANSMISSION; 195 + } 193 196 194 197 return 0; 195 198 }
+9 -3
sound/pci/hda/hda_intel.c
··· 883 883 return azx_get_pos_posbuf(chip, azx_dev); 884 884 } 885 885 886 - static void azx_shutdown_chip(struct azx *chip) 886 + static void __azx_shutdown_chip(struct azx *chip, bool skip_link_reset) 887 887 { 888 888 azx_stop_chip(chip); 889 - azx_enter_link_reset(chip); 889 + if (!skip_link_reset) 890 + azx_enter_link_reset(chip); 890 891 azx_clear_irq_pending(chip); 891 892 display_power(chip, false); 892 893 } ··· 895 894 #ifdef CONFIG_PM 896 895 static DEFINE_MUTEX(card_list_lock); 897 896 static LIST_HEAD(card_list); 897 + 898 + static void azx_shutdown_chip(struct azx *chip) 899 + { 900 + __azx_shutdown_chip(chip, false); 901 + } 898 902 899 903 static void azx_add_card_list(struct azx *chip) 900 904 { ··· 2363 2357 return; 2364 2358 chip = card->private_data; 2365 2359 if (chip && chip->running) 2366 - azx_shutdown_chip(chip); 2360 + __azx_shutdown_chip(chip, true); 2367 2361 } 2368 2362 2369 2363 /* PCI IDs */
+3
sound/pci/hda/patch_cs8409.c
··· 1207 1207 snd_hda_jack_add_kctl(codec, DOLPHIN_LO_PIN_NID, "Line Out", true, 1208 1208 SND_JACK_HEADPHONE, NULL); 1209 1209 1210 + snd_hda_jack_add_kctl(codec, DOLPHIN_AMIC_PIN_NID, "Microphone", true, 1211 + SND_JACK_MICROPHONE, NULL); 1212 + 1210 1213 cs8409_fix_caps(codec, DOLPHIN_HP_PIN_NID); 1211 1214 cs8409_fix_caps(codec, DOLPHIN_LO_PIN_NID); 1212 1215 cs8409_fix_caps(codec, DOLPHIN_AMIC_PIN_NID);
+129
sound/pci/hda/patch_realtek.c
··· 6429 6429 hda_fixup_thinkpad_acpi(codec, fix, action); 6430 6430 } 6431 6431 6432 + /* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */ 6433 + static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec, 6434 + const struct hda_fixup *fix, 6435 + int action) 6436 + { 6437 + struct alc_spec *spec = codec->spec; 6438 + 6439 + switch (action) { 6440 + case HDA_FIXUP_ACT_PRE_PROBE: 6441 + spec->gen.suppress_auto_mute = 1; 6442 + break; 6443 + } 6444 + } 6445 + 6432 6446 /* for alc295_fixup_hp_top_speakers */ 6433 6447 #include "hp_x360_helper.c" 6434 6448 ··· 6660 6646 ALC623_FIXUP_LENOVO_THINKSTATION_P340, 6661 6647 ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, 6662 6648 ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST, 6649 + ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS, 6650 + ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE, 6651 + ALC287_FIXUP_YOGA7_14ITL_SPEAKERS, 6652 + ALC287_FIXUP_13S_GEN2_SPEAKERS 6663 6653 }; 6664 6654 6665 6655 static const struct hda_fixup alc269_fixups[] = { ··· 8254 8236 .chained = true, 8255 8237 .chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF, 8256 8238 }, 8239 + [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = { 8240 + .type = HDA_FIXUP_VERBS, 8241 + //.v.verbs = legion_15imhg05_coefs, 8242 + .v.verbs = (const struct hda_verb[]) { 8243 + // set left speaker Legion 7i. 8244 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 8245 + { 0x20, AC_VERB_SET_PROC_COEF, 0x41 }, 8246 + 8247 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 8248 + { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, 8249 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8250 + { 0x20, AC_VERB_SET_PROC_COEF, 0x1a }, 8251 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8252 + 8253 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 8254 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 8255 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8256 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8257 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8258 + 8259 + // set right speaker Legion 7i. 8260 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 8261 + { 0x20, AC_VERB_SET_PROC_COEF, 0x42 }, 8262 + 8263 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 8264 + { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, 8265 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8266 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2a }, 8267 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8268 + 8269 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 8270 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 8271 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8272 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8273 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8274 + {} 8275 + }, 8276 + .chained = true, 8277 + .chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE, 8278 + }, 8279 + [ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = { 8280 + .type = HDA_FIXUP_FUNC, 8281 + .v.func = alc287_fixup_legion_15imhg05_speakers, 8282 + .chained = true, 8283 + .chain_id = ALC269_FIXUP_HEADSET_MODE, 8284 + }, 8285 + [ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = { 8286 + .type = HDA_FIXUP_VERBS, 8287 + .v.verbs = (const struct hda_verb[]) { 8288 + // set left speaker Yoga 7i. 8289 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 8290 + { 0x20, AC_VERB_SET_PROC_COEF, 0x41 }, 8291 + 8292 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 8293 + { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, 8294 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8295 + { 0x20, AC_VERB_SET_PROC_COEF, 0x1a }, 8296 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8297 + 8298 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 8299 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 8300 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8301 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8302 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8303 + 8304 + // set right speaker Yoga 7i. 8305 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 8306 + { 0x20, AC_VERB_SET_PROC_COEF, 0x46 }, 8307 + 8308 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 8309 + { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, 8310 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8311 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2a }, 8312 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8313 + 8314 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 8315 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 8316 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8317 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8318 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8319 + {} 8320 + }, 8321 + .chained = true, 8322 + .chain_id = ALC269_FIXUP_HEADSET_MODE, 8323 + }, 8324 + [ALC287_FIXUP_13S_GEN2_SPEAKERS] = { 8325 + .type = HDA_FIXUP_VERBS, 8326 + .v.verbs = (const struct hda_verb[]) { 8327 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 8328 + { 0x20, AC_VERB_SET_PROC_COEF, 0x41 }, 8329 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8330 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 8331 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8332 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8333 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8334 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 8335 + { 0x20, AC_VERB_SET_PROC_COEF, 0x42 }, 8336 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 8337 + { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 8338 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8339 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 8340 + { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 8341 + {} 8342 + }, 8343 + .chained = true, 8344 + .chain_id = ALC269_FIXUP_HEADSET_MODE, 8345 + }, 8257 8346 }; 8258 8347 8259 8348 static const struct snd_pci_quirk alc269_fixup_tbl[] = { ··· 8755 8630 SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME), 8756 8631 SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF), 8757 8632 SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP), 8633 + SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS), 8634 + SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 8635 + SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 8636 + SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS), 8758 8637 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 8759 8638 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), 8760 8639 SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
+1 -1
sound/pci/pcxhr/pcxhr_core.c
··· 52 52 #define PCXHR_DSP 2 53 53 54 54 #if (PCXHR_DSP_OFFSET_MAX > PCXHR_PLX_OFFSET_MIN) 55 - #undef PCXHR_REG_TO_PORT(x) 55 + #error PCXHR_REG_TO_PORT(x) 56 56 #else 57 57 #define PCXHR_REG_TO_PORT(x) ((x)>PCXHR_DSP_OFFSET_MAX ? PCXHR_PLX : PCXHR_DSP) 58 58 #endif
+10 -6
sound/soc/fsl/fsl_esai.c
··· 1073 1073 if (ret < 0) 1074 1074 goto err_pm_get_sync; 1075 1075 1076 + /* 1077 + * Register platform component before registering cpu dai for there 1078 + * is not defer probe for platform component in snd_soc_add_pcm_runtime(). 1079 + */ 1080 + ret = imx_pcm_dma_init(pdev, IMX_ESAI_DMABUF_SIZE); 1081 + if (ret) { 1082 + dev_err(&pdev->dev, "failed to init imx pcm dma: %d\n", ret); 1083 + goto err_pm_get_sync; 1084 + } 1085 + 1076 1086 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_esai_component, 1077 1087 &fsl_esai_dai, 1); 1078 1088 if (ret) { ··· 1091 1081 } 1092 1082 1093 1083 INIT_WORK(&esai_priv->work, fsl_esai_hw_reset); 1094 - 1095 - ret = imx_pcm_dma_init(pdev, IMX_ESAI_DMABUF_SIZE); 1096 - if (ret) { 1097 - dev_err(&pdev->dev, "failed to init imx pcm dma: %d\n", ret); 1098 - goto err_pm_get_sync; 1099 - } 1100 1084 1101 1085 return ret; 1102 1086
+10 -5
sound/soc/fsl/fsl_micfil.c
··· 737 737 pm_runtime_enable(&pdev->dev); 738 738 regcache_cache_only(micfil->regmap, true); 739 739 740 + /* 741 + * Register platform component before registering cpu dai for there 742 + * is not defer probe for platform component in snd_soc_add_pcm_runtime(). 743 + */ 744 + ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); 745 + if (ret) { 746 + dev_err(&pdev->dev, "failed to pcm register\n"); 747 + return ret; 748 + } 749 + 740 750 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_micfil_component, 741 751 &fsl_micfil_dai, 1); 742 752 if (ret) { 743 753 dev_err(&pdev->dev, "failed to register component %s\n", 744 754 fsl_micfil_component.name); 745 - return ret; 746 755 } 747 - 748 - ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); 749 - if (ret) 750 - dev_err(&pdev->dev, "failed to pcm register\n"); 751 756 752 757 return ret; 753 758 }
+9 -5
sound/soc/fsl/fsl_sai.c
··· 1152 1152 if (ret < 0) 1153 1153 goto err_pm_get_sync; 1154 1154 1155 - ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component, 1156 - &sai->cpu_dai_drv, 1); 1157 - if (ret) 1158 - goto err_pm_get_sync; 1159 - 1155 + /* 1156 + * Register platform component before registering cpu dai for there 1157 + * is not defer probe for platform component in snd_soc_add_pcm_runtime(). 1158 + */ 1160 1159 if (sai->soc_data->use_imx_pcm) { 1161 1160 ret = imx_pcm_dma_init(pdev, IMX_SAI_DMABUF_SIZE); 1162 1161 if (ret) ··· 1165 1166 if (ret) 1166 1167 goto err_pm_get_sync; 1167 1168 } 1169 + 1170 + ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component, 1171 + &sai->cpu_dai_drv, 1); 1172 + if (ret) 1173 + goto err_pm_get_sync; 1168 1174 1169 1175 return ret; 1170 1176
+10 -6
sound/soc/fsl/fsl_spdif.c
··· 1434 1434 pm_runtime_enable(&pdev->dev); 1435 1435 regcache_cache_only(spdif_priv->regmap, true); 1436 1436 1437 + /* 1438 + * Register platform component before registering cpu dai for there 1439 + * is not defer probe for platform component in snd_soc_add_pcm_runtime(). 1440 + */ 1441 + ret = imx_pcm_dma_init(pdev, IMX_SPDIF_DMABUF_SIZE); 1442 + if (ret) { 1443 + dev_err_probe(&pdev->dev, ret, "imx_pcm_dma_init failed\n"); 1444 + goto err_pm_disable; 1445 + } 1446 + 1437 1447 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_spdif_component, 1438 1448 &spdif_priv->cpu_dai_drv, 1); 1439 1449 if (ret) { 1440 1450 dev_err(&pdev->dev, "failed to register DAI: %d\n", ret); 1441 - goto err_pm_disable; 1442 - } 1443 - 1444 - ret = imx_pcm_dma_init(pdev, IMX_SPDIF_DMABUF_SIZE); 1445 - if (ret) { 1446 - dev_err_probe(&pdev->dev, ret, "imx_pcm_dma_init failed\n"); 1447 1451 goto err_pm_disable; 1448 1452 } 1449 1453
+10 -5
sound/soc/fsl/fsl_xcvr.c
··· 1215 1215 pm_runtime_enable(dev); 1216 1216 regcache_cache_only(xcvr->regmap, true); 1217 1217 1218 + /* 1219 + * Register platform component before registering cpu dai for there 1220 + * is not defer probe for platform component in snd_soc_add_pcm_runtime(). 1221 + */ 1222 + ret = devm_snd_dmaengine_pcm_register(dev, NULL, 0); 1223 + if (ret) { 1224 + dev_err(dev, "failed to pcm register\n"); 1225 + return ret; 1226 + } 1227 + 1218 1228 ret = devm_snd_soc_register_component(dev, &fsl_xcvr_comp, 1219 1229 &fsl_xcvr_dai, 1); 1220 1230 if (ret) { 1221 1231 dev_err(dev, "failed to register component %s\n", 1222 1232 fsl_xcvr_comp.name); 1223 - return ret; 1224 1233 } 1225 - 1226 - ret = devm_snd_dmaengine_pcm_register(dev, NULL, 0); 1227 - if (ret) 1228 - dev_err(dev, "failed to pcm register\n"); 1229 1234 1230 1235 return ret; 1231 1236 }
+5
sound/soc/intel/boards/sof_sdw.c
··· 929 929 cpus + *cpu_id, cpu_dai_num, 930 930 codecs, codec_num, 931 931 NULL, &sdw_ops); 932 + /* 933 + * SoundWire DAILINKs use 'stream' functions and Bank Switch operations 934 + * based on wait_for_completion(), tag them as 'nonatomic'. 935 + */ 936 + dai_links[*be_index].nonatomic = true; 932 937 933 938 ret = set_codec_init_func(card, link, dai_links + (*be_index)++, 934 939 playback, group_id);
+3
sound/soc/mediatek/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 config SND_SOC_MEDIATEK 3 3 tristate 4 + select REGMAP_MMIO 4 5 5 6 config SND_SOC_MT2701 6 7 tristate "ASoC support for Mediatek MT2701 chip" ··· 189 188 config SND_SOC_MT8195 190 189 tristate "ASoC support for Mediatek MT8195 chip" 191 190 depends on ARCH_MEDIATEK || COMPILE_TEST 191 + depends on COMMON_CLK 192 192 select SND_SOC_MEDIATEK 193 + select MFD_SYSCON if SND_SOC_MT6359 193 194 help 194 195 This adds ASoC platform driver support for Mediatek MT8195 chip 195 196 that can be used with other codecs.
+11 -8
sound/soc/mediatek/common/mtk-afe-fe-dai.c
··· 334 334 devm_kcalloc(dev, afe->reg_back_up_list_num, 335 335 sizeof(unsigned int), GFP_KERNEL); 336 336 337 - for (i = 0; i < afe->reg_back_up_list_num; i++) 338 - regmap_read(regmap, afe->reg_back_up_list[i], 339 - &afe->reg_back_up[i]); 337 + if (afe->reg_back_up) { 338 + for (i = 0; i < afe->reg_back_up_list_num; i++) 339 + regmap_read(regmap, afe->reg_back_up_list[i], 340 + &afe->reg_back_up[i]); 341 + } 340 342 341 343 afe->suspended = true; 342 344 afe->runtime_suspend(dev); ··· 358 356 359 357 afe->runtime_resume(dev); 360 358 361 - if (!afe->reg_back_up) 359 + if (!afe->reg_back_up) { 362 360 dev_dbg(dev, "%s no reg_backup\n", __func__); 363 - 364 - for (i = 0; i < afe->reg_back_up_list_num; i++) 365 - mtk_regmap_write(regmap, afe->reg_back_up_list[i], 366 - afe->reg_back_up[i]); 361 + } else { 362 + for (i = 0; i < afe->reg_back_up_list_num; i++) 363 + mtk_regmap_write(regmap, afe->reg_back_up_list[i], 364 + afe->reg_back_up[i]); 365 + } 367 366 368 367 afe->suspended = false; 369 368 return 0;
+3 -4
sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c
··· 424 424 return snd_soc_component_set_jack(cmpnt_codec, &priv->hdmi_jack, NULL); 425 425 } 426 426 427 - static int mt8195_hdmitx_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, 428 - struct snd_pcm_hw_params *params) 427 + static int mt8195_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, 428 + struct snd_pcm_hw_params *params) 429 429 430 430 { 431 431 /* fix BE i2s format to 32bit, clean param mask first */ ··· 902 902 .no_pcm = 1, 903 903 .dpcm_playback = 1, 904 904 .ops = &mt8195_dptx_ops, 905 - .be_hw_params_fixup = mt8195_hdmitx_dptx_hw_params_fixup, 905 + .be_hw_params_fixup = mt8195_dptx_hw_params_fixup, 906 906 SND_SOC_DAILINK_REG(DPTX_BE), 907 907 }, 908 908 [DAI_LINK_ETDM1_IN_BE] = { ··· 953 953 SND_SOC_DAIFMT_NB_NF | 954 954 SND_SOC_DAIFMT_CBS_CFS, 955 955 .dpcm_playback = 1, 956 - .be_hw_params_fixup = mt8195_hdmitx_dptx_hw_params_fixup, 957 956 SND_SOC_DAILINK_REG(ETDM3_OUT_BE), 958 957 }, 959 958 [DAI_LINK_PCM1_BE] = {
+1 -3
sound/soc/sof/core.c
··· 371 371 dev_warn(dev, "error: %d failed to prepare DSP for device removal", 372 372 ret); 373 373 374 - snd_sof_fw_unload(sdev); 375 374 snd_sof_ipc_free(sdev); 376 375 snd_sof_free_debug(sdev); 377 376 snd_sof_free_trace(sdev); ··· 393 394 snd_sof_remove(sdev); 394 395 395 396 /* release firmware */ 396 - release_firmware(pdata->fw); 397 - pdata->fw = NULL; 397 + snd_sof_fw_unload(sdev); 398 398 399 399 return 0; 400 400 }
+8 -1
sound/soc/sof/imx/imx8.c
··· 365 365 /* on i.MX8 there is 1 to 1 match between type and BAR idx */ 366 366 static int imx8_get_bar_index(struct snd_sof_dev *sdev, u32 type) 367 367 { 368 - return type; 368 + /* Only IRAM and SRAM bars are valid */ 369 + switch (type) { 370 + case SOF_FW_BLK_TYPE_IRAM: 371 + case SOF_FW_BLK_TYPE_SRAM: 372 + return type; 373 + default: 374 + return -EINVAL; 375 + } 369 376 } 370 377 371 378 static void imx8_ipc_msg_data(struct snd_sof_dev *sdev,
+8 -1
sound/soc/sof/imx/imx8m.c
··· 228 228 /* on i.MX8 there is 1 to 1 match between type and BAR idx */ 229 229 static int imx8m_get_bar_index(struct snd_sof_dev *sdev, u32 type) 230 230 { 231 - return type; 231 + /* Only IRAM and SRAM bars are valid */ 232 + switch (type) { 233 + case SOF_FW_BLK_TYPE_IRAM: 234 + case SOF_FW_BLK_TYPE_SRAM: 235 + return type; 236 + default: 237 + return -EINVAL; 238 + } 232 239 } 233 240 234 241 static void imx8m_ipc_msg_data(struct snd_sof_dev *sdev,
+5 -3
sound/soc/sof/loader.c
··· 729 729 ret = request_firmware(&plat_data->fw, fw_filename, sdev->dev); 730 730 731 731 if (ret < 0) { 732 - dev_err(sdev->dev, "error: request firmware %s failed err: %d\n", 733 - fw_filename, ret); 734 732 dev_err(sdev->dev, 735 - "you may need to download the firmware from https://github.com/thesofproject/sof-bin/\n"); 733 + "error: sof firmware file is missing, you might need to\n"); 734 + dev_err(sdev->dev, 735 + " download it from https://github.com/thesofproject/sof-bin/\n"); 736 736 goto err; 737 737 } else { 738 738 dev_dbg(sdev->dev, "request_firmware %s successful\n", ··· 880 880 void snd_sof_fw_unload(struct snd_sof_dev *sdev) 881 881 { 882 882 /* TODO: support module unloading at runtime */ 883 + release_firmware(sdev->pdata->fw); 884 + sdev->pdata->fw = NULL; 883 885 } 884 886 EXPORT_SYMBOL(snd_sof_fw_unload);
-1
sound/soc/sof/trace.c
··· 530 530 return; 531 531 532 532 if (sdev->dtrace_is_enabled) { 533 - dev_err(sdev->dev, "error: waking up any trace sleepers\n"); 534 533 sdev->dtrace_error = true; 535 534 wake_up(&sdev->trace_sleep); 536 535 }
+2 -2
sound/soc/sof/xtensa/core.c
··· 122 122 * 0x0049fbb0: 8000f2d0 0049fc00 6f6c6c61 00632e63 123 123 */ 124 124 for (i = 0; i < stack_words; i += 4) { 125 - hex_dump_to_buffer(stack + i * 4, 16, 16, 4, 125 + hex_dump_to_buffer(stack + i, 16, 16, 4, 126 126 buf, sizeof(buf), false); 127 - dev_err(sdev->dev, "0x%08x: %s\n", stack_ptr + i, buf); 127 + dev_err(sdev->dev, "0x%08x: %s\n", stack_ptr + i * 4, buf); 128 128 } 129 129 } 130 130
+4 -14
sound/usb/card.c
··· 1054 1054 return 0; 1055 1055 } 1056 1056 1057 - static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume) 1057 + static int usb_audio_resume(struct usb_interface *intf) 1058 1058 { 1059 1059 struct snd_usb_audio *chip = usb_get_intfdata(intf); 1060 1060 struct snd_usb_stream *as; ··· 1080 1080 * we just notify and restart the mixers 1081 1081 */ 1082 1082 list_for_each_entry(mixer, &chip->mixer_list, list) { 1083 - err = snd_usb_mixer_resume(mixer, reset_resume); 1083 + err = snd_usb_mixer_resume(mixer); 1084 1084 if (err < 0) 1085 1085 goto err_out; 1086 1086 } ··· 1100 1100 atomic_dec(&chip->active); /* allow autopm after this point */ 1101 1101 return err; 1102 1102 } 1103 - 1104 - static int usb_audio_resume(struct usb_interface *intf) 1105 - { 1106 - return __usb_audio_resume(intf, false); 1107 - } 1108 - 1109 - static int usb_audio_reset_resume(struct usb_interface *intf) 1110 - { 1111 - return __usb_audio_resume(intf, true); 1112 - } 1113 1103 #else 1114 1104 #define usb_audio_suspend NULL 1115 1105 #define usb_audio_resume NULL 1116 - #define usb_audio_reset_resume NULL 1106 + #define usb_audio_resume NULL 1117 1107 #endif /* CONFIG_PM */ 1118 1108 1119 1109 static const struct usb_device_id usb_audio_ids [] = { ··· 1125 1135 .disconnect = usb_audio_disconnect, 1126 1136 .suspend = usb_audio_suspend, 1127 1137 .resume = usb_audio_resume, 1128 - .reset_resume = usb_audio_reset_resume, 1138 + .reset_resume = usb_audio_resume, 1129 1139 .id_table = usb_audio_ids, 1130 1140 .supports_autosuspend = 1, 1131 1141 };
+4 -22
sound/usb/mixer.c
··· 3653 3653 return 0; 3654 3654 } 3655 3655 3656 - static int default_mixer_reset_resume(struct usb_mixer_elem_list *list) 3657 - { 3658 - int err; 3659 - 3660 - if (list->resume) { 3661 - err = list->resume(list); 3662 - if (err < 0) 3663 - return err; 3664 - } 3665 - return restore_mixer_value(list); 3666 - } 3667 - 3668 - int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume) 3656 + int snd_usb_mixer_resume(struct usb_mixer_interface *mixer) 3669 3657 { 3670 3658 struct usb_mixer_elem_list *list; 3671 - usb_mixer_elem_resume_func_t f; 3672 3659 int id, err; 3673 3660 3674 3661 /* restore cached mixer values */ 3675 3662 for (id = 0; id < MAX_ID_ELEMS; id++) { 3676 3663 for_each_mixer_elem(list, mixer, id) { 3677 - if (reset_resume) 3678 - f = list->reset_resume; 3679 - else 3680 - f = list->resume; 3681 - if (f) { 3682 - err = f(list); 3664 + if (list->resume) { 3665 + err = list->resume(list); 3683 3666 if (err < 0) 3684 3667 return err; 3685 3668 } ··· 3683 3700 list->id = unitid; 3684 3701 list->dump = snd_usb_mixer_dump_cval; 3685 3702 #ifdef CONFIG_PM 3686 - list->resume = NULL; 3687 - list->reset_resume = default_mixer_reset_resume; 3703 + list->resume = restore_mixer_value; 3688 3704 #endif 3689 3705 }
+1 -2
sound/usb/mixer.h
··· 70 70 bool is_std_info; 71 71 usb_mixer_elem_dump_func_t dump; 72 72 usb_mixer_elem_resume_func_t resume; 73 - usb_mixer_elem_resume_func_t reset_resume; 74 73 }; 75 74 76 75 /* iterate over mixer element list of the given unit id */ ··· 120 121 121 122 #ifdef CONFIG_PM 122 123 int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer); 123 - int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume); 124 + int snd_usb_mixer_resume(struct usb_mixer_interface *mixer); 124 125 #endif 125 126 126 127 int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
+1 -1
sound/usb/mixer_quirks.c
··· 151 151 *listp = list; 152 152 list->mixer = mixer; 153 153 list->id = id; 154 - list->reset_resume = resume; 154 + list->resume = resume; 155 155 kctl = snd_ctl_new1(knew, list); 156 156 if (!kctl) { 157 157 kfree(list);
+7 -1
tools/lib/bpf/linker.c
··· 1649 1649 static int find_glob_sym_btf(struct src_obj *obj, Elf64_Sym *sym, const char *sym_name, 1650 1650 int *out_btf_sec_id, int *out_btf_id) 1651 1651 { 1652 - int i, j, n = btf__get_nr_types(obj->btf), m, btf_id = 0; 1652 + int i, j, n, m, btf_id = 0; 1653 1653 const struct btf_type *t; 1654 1654 const struct btf_var_secinfo *vi; 1655 1655 const char *name; 1656 1656 1657 + if (!obj->btf) { 1658 + pr_warn("failed to find BTF info for object '%s'\n", obj->filename); 1659 + return -EINVAL; 1660 + } 1661 + 1662 + n = btf__get_nr_types(obj->btf); 1657 1663 for (i = 1; i <= n; i++) { 1658 1664 t = btf__type_by_id(obj->btf, i); 1659 1665
+30 -8
tools/objtool/special.c
··· 58 58 { 59 59 } 60 60 61 + static bool reloc2sec_off(struct reloc *reloc, struct section **sec, unsigned long *off) 62 + { 63 + switch (reloc->sym->type) { 64 + case STT_FUNC: 65 + *sec = reloc->sym->sec; 66 + *off = reloc->sym->offset + reloc->addend; 67 + return true; 68 + 69 + case STT_SECTION: 70 + *sec = reloc->sym->sec; 71 + *off = reloc->addend; 72 + return true; 73 + 74 + default: 75 + return false; 76 + } 77 + } 78 + 61 79 static int get_alt_entry(struct elf *elf, struct special_entry *entry, 62 80 struct section *sec, int idx, 63 81 struct special_alt *alt) ··· 109 91 WARN_FUNC("can't find orig reloc", sec, offset + entry->orig); 110 92 return -1; 111 93 } 112 - if (orig_reloc->sym->type != STT_SECTION) { 113 - WARN_FUNC("don't know how to handle non-section reloc symbol %s", 114 - sec, offset + entry->orig, orig_reloc->sym->name); 94 + if (!reloc2sec_off(orig_reloc, &alt->orig_sec, &alt->orig_off)) { 95 + WARN_FUNC("don't know how to handle reloc symbol type %d: %s", 96 + sec, offset + entry->orig, 97 + orig_reloc->sym->type, 98 + orig_reloc->sym->name); 115 99 return -1; 116 100 } 117 - 118 - alt->orig_sec = orig_reloc->sym->sec; 119 - alt->orig_off = orig_reloc->addend; 120 101 121 102 if (!entry->group || alt->new_len) { 122 103 new_reloc = find_reloc_by_dest(elf, sec, offset + entry->new); ··· 133 116 if (arch_is_retpoline(new_reloc->sym)) 134 117 return 1; 135 118 136 - alt->new_sec = new_reloc->sym->sec; 137 - alt->new_off = (unsigned int)new_reloc->addend; 119 + if (!reloc2sec_off(new_reloc, &alt->new_sec, &alt->new_off)) { 120 + WARN_FUNC("don't know how to handle reloc symbol type %d: %s", 121 + sec, offset + entry->new, 122 + new_reloc->sym->type, 123 + new_reloc->sym->name); 124 + return -1; 125 + } 138 126 139 127 /* _ASM_EXTABLE_EX hack */ 140 128 if (alt->new_off >= 0x7ffffff0)
+1 -1
tools/perf/Documentation/jitdump-specification.txt
··· 164 164 The EH Frame header follows the Linux Standard Base (LSB) specification as described in the document at https://refspecs.linuxfoundation.org/LSB_1.3.0/gLSB/gLSB/ehframehdr.html 165 165 166 166 167 - The EH Frame follows the LSB specicfication as described in the document at https://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/ehframechpt.html 167 + The EH Frame follows the LSB specification as described in the document at https://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/ehframechpt.html 168 168 169 169 170 170 NOTE: The mapped_size is generally either the same as unwind_data_size (if the unwinding data was mapped in memory by the running process) or zero (if the unwinding data is not mapped by the process). If the unwinding data was not mapped, then only the EH Frame Header will be read, which can be used to specify FP based unwinding for a function which does not have unwinding information.
+1 -1
tools/perf/Documentation/perf-c2c.txt
··· 261 261 User can specify how to sort offsets for cacheline. 262 262 263 263 Following fields are available and governs the final 264 - output fields set for caheline offsets output: 264 + output fields set for cacheline offsets output: 265 265 266 266 tid - coalesced by process TIDs 267 267 pid - coalesced by process PIDs
+1 -1
tools/perf/Documentation/perf-intel-pt.txt
··· 883 883 884 884 "Transactions" events correspond to the start or end of transactions. The 885 885 'flags' field can be used in perf script to determine whether the event is a 886 - tranasaction start, commit or abort. 886 + transaction start, commit or abort. 887 887 888 888 Note that "instructions", "branches" and "transactions" events depend on code 889 889 flow packets which can be disabled by using the config term "branch=0". Refer
+1 -1
tools/perf/Documentation/perf-lock.txt
··· 44 44 45 45 -f:: 46 46 --force:: 47 - Don't complan, do it. 47 + Don't complain, do it. 48 48 49 49 REPORT OPTIONS 50 50 --------------
+1 -1
tools/perf/Documentation/perf-script-perl.txt
··· 54 54 Traces meant to be processed using a script should be recorded with 55 55 the above option: -a to enable system-wide collection. 56 56 57 - The format file for the sched_wakep event defines the following fields 57 + The format file for the sched_wakeup event defines the following fields 58 58 (see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format): 59 59 60 60 ----
+1 -1
tools/perf/Documentation/perf-script-python.txt
··· 448 448 Traces meant to be processed using a script should be recorded with 449 449 the above option: -a to enable system-wide collection. 450 450 451 - The format file for the sched_wakep event defines the following fields 451 + The format file for the sched_wakeup event defines the following fields 452 452 (see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format): 453 453 454 454 ----
+1 -1
tools/perf/Documentation/perf-stat.txt
··· 385 385 Print metrics or metricgroups specified in a comma separated list. 386 386 For a group all metrics from the group are added. 387 387 The events from the metrics are automatically measured. 388 - See perf list output for the possble metrics and metricgroups. 388 + See perf list output for the possible metrics and metricgroups. 389 389 390 390 -A:: 391 391 --no-aggr::
+1 -1
tools/perf/Documentation/topdown.txt
··· 2 2 ----------------------------------- 3 3 4 4 Intel CPUs (since Sandy Bridge and Silvermont) support a TopDown 5 - methology to break down CPU pipeline execution into 4 bottlenecks: 5 + methodology to break down CPU pipeline execution into 4 bottlenecks: 6 6 frontend bound, backend bound, bad speculation, retiring. 7 7 8 8 For more details on Topdown see [1][5]
+4 -4
tools/perf/arch/arm/util/auxtrace.c
··· 8 8 #include <linux/coresight-pmu.h> 9 9 #include <linux/zalloc.h> 10 10 11 - #include "../../util/auxtrace.h" 12 - #include "../../util/debug.h" 13 - #include "../../util/evlist.h" 14 - #include "../../util/pmu.h" 11 + #include "../../../util/auxtrace.h" 12 + #include "../../../util/debug.h" 13 + #include "../../../util/evlist.h" 14 + #include "../../../util/pmu.h" 15 15 #include "cs-etm.h" 16 16 #include "arm-spe.h" 17 17
+12 -12
tools/perf/arch/arm/util/cs-etm.c
··· 16 16 #include <linux/zalloc.h> 17 17 18 18 #include "cs-etm.h" 19 - #include "../../util/debug.h" 20 - #include "../../util/record.h" 21 - #include "../../util/auxtrace.h" 22 - #include "../../util/cpumap.h" 23 - #include "../../util/event.h" 24 - #include "../../util/evlist.h" 25 - #include "../../util/evsel.h" 26 - #include "../../util/perf_api_probe.h" 27 - #include "../../util/evsel_config.h" 28 - #include "../../util/pmu.h" 29 - #include "../../util/cs-etm.h" 19 + #include "../../../util/debug.h" 20 + #include "../../../util/record.h" 21 + #include "../../../util/auxtrace.h" 22 + #include "../../../util/cpumap.h" 23 + #include "../../../util/event.h" 24 + #include "../../../util/evlist.h" 25 + #include "../../../util/evsel.h" 26 + #include "../../../util/perf_api_probe.h" 27 + #include "../../../util/evsel_config.h" 28 + #include "../../../util/pmu.h" 29 + #include "../../../util/cs-etm.h" 30 30 #include <internal/lib.h> // page_size 31 - #include "../../util/session.h" 31 + #include "../../../util/session.h" 32 32 33 33 #include <errno.h> 34 34 #include <stdlib.h>
+1 -1
tools/perf/arch/arm/util/perf_regs.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - #include "../../util/perf_regs.h" 2 + #include "../../../util/perf_regs.h" 3 3 4 4 const struct sample_reg sample_reg_masks[] = { 5 5 SMPL_REG_END
+1 -1
tools/perf/arch/arm/util/pmu.c
··· 10 10 #include <linux/string.h> 11 11 12 12 #include "arm-spe.h" 13 - #include "../../util/pmu.h" 13 + #include "../../../util/pmu.h" 14 14 15 15 struct perf_event_attr 16 16 *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
+3 -3
tools/perf/arch/arm/util/unwind-libdw.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <elfutils/libdwfl.h> 3 - #include "../../util/unwind-libdw.h" 4 - #include "../../util/perf_regs.h" 5 - #include "../../util/event.h" 3 + #include "../../../util/unwind-libdw.h" 4 + #include "../../../util/perf_regs.h" 5 + #include "../../../util/event.h" 6 6 7 7 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) 8 8 {
+2 -2
tools/perf/arch/arm/util/unwind-libunwind.c
··· 3 3 #include <errno.h> 4 4 #include <libunwind.h> 5 5 #include "perf_regs.h" 6 - #include "../../util/unwind.h" 7 - #include "../../util/debug.h" 6 + #include "../../../util/unwind.h" 7 + #include "../../../util/debug.h" 8 8 9 9 int libunwind__arch_reg_id(int regnum) 10 10 {
+1 -1
tools/perf/arch/x86/util/iostat.c
··· 432 432 u8 die = ((struct iio_root_port *)evsel->priv)->die; 433 433 struct perf_counts_values *count = perf_counts(evsel->counts, die, 0); 434 434 435 - if (count->run && count->ena) { 435 + if (count && count->run && count->ena) { 436 436 if (evsel->prev_raw_counts && !out->force_header) { 437 437 struct perf_counts_values *prev_count = 438 438 perf_counts(evsel->prev_raw_counts, die, 0);
+2
tools/perf/builtin-stat.c
··· 2408 2408 goto out; 2409 2409 } else if (verbose) 2410 2410 iostat_list(evsel_list, &stat_config); 2411 + if (iostat_mode == IOSTAT_RUN && !target__has_cpu(&target)) 2412 + target.system_wide = true; 2411 2413 } 2412 2414 2413 2415 if (add_default_attributes())
+1 -1
tools/perf/pmu-events/arch/powerpc/power8/other.json
··· 1046 1046 { 1047 1047 "EventCode": "0x4e010", 1048 1048 "EventName": "PM_GCT_NOSLOT_IC_L3MISS", 1049 - "BriefDescription": "Gct empty for this thread due to icach l3 miss", 1049 + "BriefDescription": "Gct empty for this thread due to icache l3 miss", 1050 1050 "PublicDescription": "" 1051 1051 }, 1052 1052 {
+2 -2
tools/perf/tests/code-reading.c
··· 229 229 struct thread *thread, struct state *state) 230 230 { 231 231 struct addr_location al; 232 - unsigned char buf1[BUFSZ]; 233 - unsigned char buf2[BUFSZ]; 232 + unsigned char buf1[BUFSZ] = {0}; 233 + unsigned char buf2[BUFSZ] = {0}; 234 234 size_t ret_len; 235 235 u64 objdump_addr; 236 236 const char *objdump_name;
+32 -7
tools/perf/tests/dwarf-unwind.c
··· 20 20 /* For bsearch. We try to unwind functions in shared object. */ 21 21 #include <stdlib.h> 22 22 23 + /* 24 + * The test will assert frames are on the stack but tail call optimizations lose 25 + * the frame of the caller. Clang can disable this optimization on a called 26 + * function but GCC currently (11/2020) lacks this attribute. The barrier is 27 + * used to inhibit tail calls in these cases. 28 + */ 29 + #ifdef __has_attribute 30 + #if __has_attribute(disable_tail_calls) 31 + #define NO_TAIL_CALL_ATTRIBUTE __attribute__((disable_tail_calls)) 32 + #define NO_TAIL_CALL_BARRIER 33 + #endif 34 + #endif 35 + #ifndef NO_TAIL_CALL_ATTRIBUTE 36 + #define NO_TAIL_CALL_ATTRIBUTE 37 + #define NO_TAIL_CALL_BARRIER __asm__ __volatile__("" : : : "memory"); 38 + #endif 39 + 23 40 static int mmap_handler(struct perf_tool *tool __maybe_unused, 24 41 union perf_event *event, 25 42 struct perf_sample *sample, ··· 108 91 return strcmp((const char *) symbol, funcs[idx]); 109 92 } 110 93 111 - noinline int test_dwarf_unwind__thread(struct thread *thread) 94 + NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__thread(struct thread *thread) 112 95 { 113 96 struct perf_sample sample; 114 97 unsigned long cnt = 0; ··· 139 122 140 123 static int global_unwind_retval = -INT_MAX; 141 124 142 - noinline int test_dwarf_unwind__compare(void *p1, void *p2) 125 + NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__compare(void *p1, void *p2) 143 126 { 144 127 /* Any possible value should be 'thread' */ 145 128 struct thread *thread = *(struct thread **)p1; ··· 158 141 return p1 - p2; 159 142 } 160 143 161 - noinline int test_dwarf_unwind__krava_3(struct thread *thread) 144 + NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_3(struct thread *thread) 162 145 { 163 146 struct thread *array[2] = {thread, thread}; 164 147 void *fp = &bsearch; ··· 177 160 return global_unwind_retval; 178 161 } 179 162 180 - noinline int test_dwarf_unwind__krava_2(struct thread *thread) 163 + NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_2(struct thread *thread) 181 164 { 182 - return test_dwarf_unwind__krava_3(thread); 165 + int ret; 166 + 167 + ret = test_dwarf_unwind__krava_3(thread); 168 + NO_TAIL_CALL_BARRIER; 169 + return ret; 183 170 } 184 171 185 - noinline int test_dwarf_unwind__krava_1(struct thread *thread) 172 + NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_1(struct thread *thread) 186 173 { 187 - return test_dwarf_unwind__krava_2(thread); 174 + int ret; 175 + 176 + ret = test_dwarf_unwind__krava_2(thread); 177 + NO_TAIL_CALL_BARRIER; 178 + return ret; 188 179 } 189 180 190 181 int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __maybe_unused)
+1 -1
tools/perf/util/config.c
··· 801 801 section->name, item->name); 802 802 ret = fn(key, value, data); 803 803 if (ret < 0) { 804 - pr_err("Error: wrong config key-value pair %s=%s\n", 804 + pr_err("Error in the given config file: wrong config key-value pair %s=%s\n", 805 805 key, value); 806 806 /* 807 807 * Can't be just a 'break', as perf_config_set__for_each_entry()
+2 -1
tools/testing/selftests/bpf/Makefile
··· 375 375 $(TRUNNER_BPF_PROGS_DIR)/%.c \ 376 376 $(TRUNNER_BPF_PROGS_DIR)/*.h \ 377 377 $$(INCLUDE_DIR)/vmlinux.h \ 378 - $(wildcard $(BPFDIR)/bpf_*.h) | $(TRUNNER_OUTPUT) 378 + $(wildcard $(BPFDIR)/bpf_*.h) \ 379 + | $(TRUNNER_OUTPUT) $$(BPFOBJ) 379 380 $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \ 380 381 $(TRUNNER_BPF_CFLAGS)) 381 382
+8 -5
tools/testing/selftests/bpf/test_lwt_ip_encap.sh
··· 112 112 ip netns add "${NS2}" 113 113 ip netns add "${NS3}" 114 114 115 + # rp_filter gets confused by what these tests are doing, so disable it 116 + ip netns exec ${NS1} sysctl -wq net.ipv4.conf.all.rp_filter=0 117 + ip netns exec ${NS2} sysctl -wq net.ipv4.conf.all.rp_filter=0 118 + ip netns exec ${NS3} sysctl -wq net.ipv4.conf.all.rp_filter=0 119 + ip netns exec ${NS1} sysctl -wq net.ipv4.conf.default.rp_filter=0 120 + ip netns exec ${NS2} sysctl -wq net.ipv4.conf.default.rp_filter=0 121 + ip netns exec ${NS3} sysctl -wq net.ipv4.conf.default.rp_filter=0 122 + 115 123 ip link add veth1 type veth peer name veth2 116 124 ip link add veth3 type veth peer name veth4 117 125 ip link add veth5 type veth peer name veth6 ··· 243 235 ip -netns ${NS3} -6 addr add ${IPv6_GRE} nodad dev gre6_dev 244 236 ip -netns ${NS1} -6 route add ${IPv6_GRE}/128 dev veth5 via ${IPv6_6} ${VRF} 245 237 ip -netns ${NS2} -6 route add ${IPv6_GRE}/128 dev veth7 via ${IPv6_8} ${VRF} 246 - 247 - # rp_filter gets confused by what these tests are doing, so disable it 248 - ip netns exec ${NS1} sysctl -wq net.ipv4.conf.all.rp_filter=0 249 - ip netns exec ${NS2} sysctl -wq net.ipv4.conf.all.rp_filter=0 250 - ip netns exec ${NS3} sysctl -wq net.ipv4.conf.all.rp_filter=0 251 238 252 239 TMPFILE=$(mktemp /tmp/test_lwt_ip_encap.XXXXXX) 253 240
+1
tools/testing/selftests/kvm/.gitignore
··· 24 24 /x86_64/smm_test 25 25 /x86_64/state_test 26 26 /x86_64/svm_vmcall_test 27 + /x86_64/svm_int_ctl_test 27 28 /x86_64/sync_regs_test 28 29 /x86_64/tsc_msrs_test 29 30 /x86_64/userspace_msr_exit_test
+1
tools/testing/selftests/kvm/Makefile
··· 56 56 TEST_GEN_PROGS_x86_64 += x86_64/state_test 57 57 TEST_GEN_PROGS_x86_64 += x86_64/vmx_preemption_timer_test 58 58 TEST_GEN_PROGS_x86_64 += x86_64/svm_vmcall_test 59 + TEST_GEN_PROGS_x86_64 += x86_64/svm_int_ctl_test 59 60 TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test 60 61 TEST_GEN_PROGS_x86_64 += x86_64/userspace_msr_exit_test 61 62 TEST_GEN_PROGS_x86_64 += x86_64/vmx_apic_access_test
+2 -4
tools/testing/selftests/kvm/access_tracking_perf_test.c
··· 371 371 printf(" -v: specify the number of vCPUs to run.\n"); 372 372 printf(" -o: Overlap guest memory accesses instead of partitioning\n" 373 373 " them into a separate region of memory for each vCPU.\n"); 374 - printf(" -s: specify the type of memory that should be used to\n" 375 - " back the guest data region.\n\n"); 376 - backing_src_help(); 374 + backing_src_help("-s"); 377 375 puts(""); 378 376 exit(0); 379 377 } ··· 379 381 int main(int argc, char *argv[]) 380 382 { 381 383 struct test_params params = { 382 - .backing_src = VM_MEM_SRC_ANONYMOUS, 384 + .backing_src = DEFAULT_VM_MEM_SRC, 383 385 .vcpu_memory_bytes = DEFAULT_PER_VCPU_MEM_SIZE, 384 386 .vcpus = 1, 385 387 };
+7 -8
tools/testing/selftests/kvm/demand_paging_test.c
··· 179 179 return NULL; 180 180 } 181 181 182 - if (!pollfd[0].revents & POLLIN) 182 + if (!(pollfd[0].revents & POLLIN)) 183 183 continue; 184 184 185 185 r = read(uffd, &msg, sizeof(msg)); ··· 416 416 { 417 417 puts(""); 418 418 printf("usage: %s [-h] [-m vm_mode] [-u uffd_mode] [-d uffd_delay_usec]\n" 419 - " [-b memory] [-t type] [-v vcpus] [-o]\n", name); 419 + " [-b memory] [-s type] [-v vcpus] [-o]\n", name); 420 420 guest_modes_help(); 421 421 printf(" -u: use userfaultfd to handle vCPU page faults. Mode is a\n" 422 422 " UFFD registration mode: 'MISSING' or 'MINOR'.\n"); ··· 426 426 printf(" -b: specify the size of the memory region which should be\n" 427 427 " demand paged by each vCPU. e.g. 10M or 3G.\n" 428 428 " Default: 1G\n"); 429 - printf(" -t: The type of backing memory to use. Default: anonymous\n"); 430 - backing_src_help(); 429 + backing_src_help("-s"); 431 430 printf(" -v: specify the number of vCPUs to run.\n"); 432 431 printf(" -o: Overlap guest memory accesses instead of partitioning\n" 433 432 " them into a separate region of memory for each vCPU.\n"); ··· 438 439 { 439 440 int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS); 440 441 struct test_params p = { 441 - .src_type = VM_MEM_SRC_ANONYMOUS, 442 + .src_type = DEFAULT_VM_MEM_SRC, 442 443 .partition_vcpu_memory_access = true, 443 444 }; 444 445 int opt; 445 446 446 447 guest_modes_append_default(); 447 448 448 - while ((opt = getopt(argc, argv, "hm:u:d:b:t:v:o")) != -1) { 449 + while ((opt = getopt(argc, argv, "hm:u:d:b:s:v:o")) != -1) { 449 450 switch (opt) { 450 451 case 'm': 451 452 guest_modes_cmdline(optarg); ··· 464 465 case 'b': 465 466 guest_percpu_mem_size = parse_size(optarg); 466 467 break; 467 - case 't': 468 + case 's': 468 469 p.src_type = parse_backing_src_type(optarg); 469 470 break; 470 471 case 'v': ··· 484 485 485 486 if (p.uffd_mode == UFFDIO_REGISTER_MODE_MINOR && 486 487 !backing_src_is_shared(p.src_type)) { 487 - TEST_FAIL("userfaultfd MINOR mode requires shared memory; pick a different -t"); 488 + TEST_FAIL("userfaultfd MINOR mode requires shared memory; pick a different -s"); 488 489 } 489 490 490 491 for_each_guest_mode(run_test, &p);
+42 -20
tools/testing/selftests/kvm/dirty_log_perf_test.c
··· 118 118 toggle_dirty_logging(vm, slots, false); 119 119 } 120 120 121 - static void get_dirty_log(struct kvm_vm *vm, int slots, unsigned long *bitmap, 122 - uint64_t nr_pages) 121 + static void get_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[], int slots) 123 122 { 124 - uint64_t slot_pages = nr_pages / slots; 125 123 int i; 126 124 127 125 for (i = 0; i < slots; i++) { 128 126 int slot = PERF_TEST_MEM_SLOT_INDEX + i; 129 - unsigned long *slot_bitmap = bitmap + i * slot_pages; 130 127 131 - kvm_vm_get_dirty_log(vm, slot, slot_bitmap); 128 + kvm_vm_get_dirty_log(vm, slot, bitmaps[i]); 132 129 } 133 130 } 134 131 135 - static void clear_dirty_log(struct kvm_vm *vm, int slots, unsigned long *bitmap, 136 - uint64_t nr_pages) 132 + static void clear_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[], 133 + int slots, uint64_t pages_per_slot) 137 134 { 138 - uint64_t slot_pages = nr_pages / slots; 139 135 int i; 140 136 141 137 for (i = 0; i < slots; i++) { 142 138 int slot = PERF_TEST_MEM_SLOT_INDEX + i; 143 - unsigned long *slot_bitmap = bitmap + i * slot_pages; 144 139 145 - kvm_vm_clear_dirty_log(vm, slot, slot_bitmap, 0, slot_pages); 140 + kvm_vm_clear_dirty_log(vm, slot, bitmaps[i], 0, pages_per_slot); 146 141 } 142 + } 143 + 144 + static unsigned long **alloc_bitmaps(int slots, uint64_t pages_per_slot) 145 + { 146 + unsigned long **bitmaps; 147 + int i; 148 + 149 + bitmaps = malloc(slots * sizeof(bitmaps[0])); 150 + TEST_ASSERT(bitmaps, "Failed to allocate bitmaps array."); 151 + 152 + for (i = 0; i < slots; i++) { 153 + bitmaps[i] = bitmap_zalloc(pages_per_slot); 154 + TEST_ASSERT(bitmaps[i], "Failed to allocate slot bitmap."); 155 + } 156 + 157 + return bitmaps; 158 + } 159 + 160 + static void free_bitmaps(unsigned long *bitmaps[], int slots) 161 + { 162 + int i; 163 + 164 + for (i = 0; i < slots; i++) 165 + free(bitmaps[i]); 166 + 167 + free(bitmaps); 147 168 } 148 169 149 170 static void run_test(enum vm_guest_mode mode, void *arg) ··· 172 151 struct test_params *p = arg; 173 152 pthread_t *vcpu_threads; 174 153 struct kvm_vm *vm; 175 - unsigned long *bmap; 154 + unsigned long **bitmaps; 176 155 uint64_t guest_num_pages; 177 156 uint64_t host_num_pages; 157 + uint64_t pages_per_slot; 178 158 int vcpu_id; 179 159 struct timespec start; 180 160 struct timespec ts_diff; ··· 193 171 guest_num_pages = (nr_vcpus * guest_percpu_mem_size) >> vm_get_page_shift(vm); 194 172 guest_num_pages = vm_adjust_num_guest_pages(mode, guest_num_pages); 195 173 host_num_pages = vm_num_host_pages(mode, guest_num_pages); 196 - bmap = bitmap_zalloc(host_num_pages); 174 + pages_per_slot = host_num_pages / p->slots; 175 + 176 + bitmaps = alloc_bitmaps(p->slots, pages_per_slot); 197 177 198 178 if (dirty_log_manual_caps) { 199 179 cap.cap = KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2; ··· 263 239 iteration, ts_diff.tv_sec, ts_diff.tv_nsec); 264 240 265 241 clock_gettime(CLOCK_MONOTONIC, &start); 266 - get_dirty_log(vm, p->slots, bmap, host_num_pages); 242 + get_dirty_log(vm, bitmaps, p->slots); 267 243 ts_diff = timespec_elapsed(start); 268 244 get_dirty_log_total = timespec_add(get_dirty_log_total, 269 245 ts_diff); ··· 272 248 273 249 if (dirty_log_manual_caps) { 274 250 clock_gettime(CLOCK_MONOTONIC, &start); 275 - clear_dirty_log(vm, p->slots, bmap, host_num_pages); 251 + clear_dirty_log(vm, bitmaps, p->slots, pages_per_slot); 276 252 ts_diff = timespec_elapsed(start); 277 253 clear_dirty_log_total = timespec_add(clear_dirty_log_total, 278 254 ts_diff); ··· 305 281 clear_dirty_log_total.tv_nsec, avg.tv_sec, avg.tv_nsec); 306 282 } 307 283 308 - free(bmap); 284 + free_bitmaps(bitmaps, p->slots); 309 285 free(vcpu_threads); 310 286 perf_test_destroy_vm(vm); 311 287 } ··· 332 308 printf(" -v: specify the number of vCPUs to run.\n"); 333 309 printf(" -o: Overlap guest memory accesses instead of partitioning\n" 334 310 " them into a separate region of memory for each vCPU.\n"); 335 - printf(" -s: specify the type of memory that should be used to\n" 336 - " back the guest data region.\n\n"); 311 + backing_src_help("-s"); 337 312 printf(" -x: Split the memory region into this number of memslots.\n" 338 - " (default: 1)"); 339 - backing_src_help(); 313 + " (default: 1)\n"); 340 314 puts(""); 341 315 exit(0); 342 316 } ··· 346 324 .iterations = TEST_HOST_LOOP_N, 347 325 .wr_fract = 1, 348 326 .partition_vcpu_memory_access = true, 349 - .backing_src = VM_MEM_SRC_ANONYMOUS, 327 + .backing_src = DEFAULT_VM_MEM_SRC, 350 328 .slots = 1, 351 329 }; 352 330 int opt;
+3 -1
tools/testing/selftests/kvm/include/test_util.h
··· 90 90 NUM_SRC_TYPES, 91 91 }; 92 92 93 + #define DEFAULT_VM_MEM_SRC VM_MEM_SRC_ANONYMOUS 94 + 93 95 struct vm_mem_backing_src_alias { 94 96 const char *name; 95 97 uint32_t flag; ··· 104 102 size_t get_def_hugetlb_pagesz(void); 105 103 const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i); 106 104 size_t get_backing_src_pagesz(uint32_t i); 107 - void backing_src_help(void); 105 + void backing_src_help(const char *flag); 108 106 enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name); 109 107 long get_run_delay(void); 110 108
+17 -17
tools/testing/selftests/kvm/include/x86_64/processor.h
··· 312 312 } 313 313 } 314 314 315 - typedef unsigned long v1di __attribute__ ((vector_size (8))); 315 + #define GET_XMM(__xmm) \ 316 + ({ \ 317 + unsigned long __val; \ 318 + asm volatile("movq %%"#__xmm", %0" : "=r"(__val)); \ 319 + __val; \ 320 + }) 321 + 316 322 static inline unsigned long get_xmm(int n) 317 323 { 318 324 assert(n >= 0 && n <= 7); 319 325 320 - register v1di xmm0 __asm__("%xmm0"); 321 - register v1di xmm1 __asm__("%xmm1"); 322 - register v1di xmm2 __asm__("%xmm2"); 323 - register v1di xmm3 __asm__("%xmm3"); 324 - register v1di xmm4 __asm__("%xmm4"); 325 - register v1di xmm5 __asm__("%xmm5"); 326 - register v1di xmm6 __asm__("%xmm6"); 327 - register v1di xmm7 __asm__("%xmm7"); 328 326 switch (n) { 329 327 case 0: 330 - return (unsigned long)xmm0; 328 + return GET_XMM(xmm0); 331 329 case 1: 332 - return (unsigned long)xmm1; 330 + return GET_XMM(xmm1); 333 331 case 2: 334 - return (unsigned long)xmm2; 332 + return GET_XMM(xmm2); 335 333 case 3: 336 - return (unsigned long)xmm3; 334 + return GET_XMM(xmm3); 337 335 case 4: 338 - return (unsigned long)xmm4; 336 + return GET_XMM(xmm4); 339 337 case 5: 340 - return (unsigned long)xmm5; 338 + return GET_XMM(xmm5); 341 339 case 6: 342 - return (unsigned long)xmm6; 340 + return GET_XMM(xmm6); 343 341 case 7: 344 - return (unsigned long)xmm7; 342 + return GET_XMM(xmm7); 345 343 } 344 + 345 + /* never reached */ 346 346 return 0; 347 347 } 348 348
+2 -5
tools/testing/selftests/kvm/kvm_page_table_test.c
··· 456 456 " (default: 1G)\n"); 457 457 printf(" -v: specify the number of vCPUs to run\n" 458 458 " (default: 1)\n"); 459 - printf(" -s: specify the type of memory that should be used to\n" 460 - " back the guest data region.\n" 461 - " (default: anonymous)\n\n"); 462 - backing_src_help(); 459 + backing_src_help("-s"); 463 460 puts(""); 464 461 } 465 462 ··· 465 468 int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS); 466 469 struct test_params p = { 467 470 .test_mem_size = DEFAULT_TEST_MEM_SIZE, 468 - .src_type = VM_MEM_SRC_ANONYMOUS, 471 + .src_type = DEFAULT_VM_MEM_SRC, 469 472 }; 470 473 int opt; 471 474
+13 -4
tools/testing/selftests/kvm/lib/test_util.c
··· 283 283 } 284 284 } 285 285 286 - void backing_src_help(void) 286 + static void print_available_backing_src_types(const char *prefix) 287 287 { 288 288 int i; 289 289 290 - printf("Available backing src types:\n"); 290 + printf("%sAvailable backing src types:\n", prefix); 291 + 291 292 for (i = 0; i < NUM_SRC_TYPES; i++) 292 - printf("\t%s\n", vm_mem_backing_src_alias(i)->name); 293 + printf("%s %s\n", prefix, vm_mem_backing_src_alias(i)->name); 294 + } 295 + 296 + void backing_src_help(const char *flag) 297 + { 298 + printf(" %s: specify the type of memory that should be used to\n" 299 + " back the guest data region. (default: %s)\n", 300 + flag, vm_mem_backing_src_alias(DEFAULT_VM_MEM_SRC)->name); 301 + print_available_backing_src_types(" "); 293 302 } 294 303 295 304 enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name) ··· 309 300 if (!strcmp(type_name, vm_mem_backing_src_alias(i)->name)) 310 301 return i; 311 302 312 - backing_src_help(); 303 + print_available_backing_src_types(""); 313 304 TEST_FAIL("Unknown backing src type: %s", type_name); 314 305 return -1; 315 306 }
+60 -10
tools/testing/selftests/kvm/rseq_test.c
··· 10 10 #include <signal.h> 11 11 #include <syscall.h> 12 12 #include <sys/ioctl.h> 13 + #include <sys/sysinfo.h> 13 14 #include <asm/barrier.h> 14 15 #include <linux/atomic.h> 15 16 #include <linux/rseq.h> ··· 40 39 41 40 static pthread_t migration_thread; 42 41 static cpu_set_t possible_mask; 42 + static int min_cpu, max_cpu; 43 43 static bool done; 44 44 45 45 static atomic_t seq_cnt; ··· 59 57 TEST_ASSERT(!r, "rseq failed, errno = %d (%s)", errno, strerror(errno)); 60 58 } 61 59 60 + static int next_cpu(int cpu) 61 + { 62 + /* 63 + * Advance to the next CPU, skipping those that weren't in the original 64 + * affinity set. Sadly, there is no CPU_SET_FOR_EACH, and cpu_set_t's 65 + * data storage is considered as opaque. Note, if this task is pinned 66 + * to a small set of discontigous CPUs, e.g. 2 and 1023, this loop will 67 + * burn a lot cycles and the test will take longer than normal to 68 + * complete. 69 + */ 70 + do { 71 + cpu++; 72 + if (cpu > max_cpu) { 73 + cpu = min_cpu; 74 + TEST_ASSERT(CPU_ISSET(cpu, &possible_mask), 75 + "Min CPU = %d must always be usable", cpu); 76 + break; 77 + } 78 + } while (!CPU_ISSET(cpu, &possible_mask)); 79 + 80 + return cpu; 81 + } 82 + 62 83 static void *migration_worker(void *ign) 63 84 { 64 85 cpu_set_t allowed_mask; 65 - int r, i, nr_cpus, cpu; 86 + int r, i, cpu; 66 87 67 88 CPU_ZERO(&allowed_mask); 68 89 69 - nr_cpus = CPU_COUNT(&possible_mask); 70 - 71 - for (i = 0; i < NR_TASK_MIGRATIONS; i++) { 72 - cpu = i % nr_cpus; 73 - if (!CPU_ISSET(cpu, &possible_mask)) 74 - continue; 75 - 90 + for (i = 0, cpu = min_cpu; i < NR_TASK_MIGRATIONS; i++, cpu = next_cpu(cpu)) { 76 91 CPU_SET(cpu, &allowed_mask); 77 92 78 93 /* ··· 173 154 return NULL; 174 155 } 175 156 157 + static int calc_min_max_cpu(void) 158 + { 159 + int i, cnt, nproc; 160 + 161 + if (CPU_COUNT(&possible_mask) < 2) 162 + return -EINVAL; 163 + 164 + /* 165 + * CPU_SET doesn't provide a FOR_EACH helper, get the min/max CPU that 166 + * this task is affined to in order to reduce the time spent querying 167 + * unusable CPUs, e.g. if this task is pinned to a small percentage of 168 + * total CPUs. 169 + */ 170 + nproc = get_nprocs_conf(); 171 + min_cpu = -1; 172 + max_cpu = -1; 173 + cnt = 0; 174 + 175 + for (i = 0; i < nproc; i++) { 176 + if (!CPU_ISSET(i, &possible_mask)) 177 + continue; 178 + if (min_cpu == -1) 179 + min_cpu = i; 180 + max_cpu = i; 181 + cnt++; 182 + } 183 + 184 + return (cnt < 2) ? -EINVAL : 0; 185 + } 186 + 176 187 int main(int argc, char *argv[]) 177 188 { 178 189 int r, i, snapshot; ··· 216 167 TEST_ASSERT(!r, "sched_getaffinity failed, errno = %d (%s)", errno, 217 168 strerror(errno)); 218 169 219 - if (CPU_COUNT(&possible_mask) < 2) { 220 - print_skip("Only one CPU, task migration not possible\n"); 170 + if (calc_min_max_cpu()) { 171 + print_skip("Only one usable CPU, task migration not possible"); 221 172 exit(KSFT_SKIP); 222 173 } 223 174 ··· 229 180 * CPU affinity. 230 181 */ 231 182 vm = vm_create_default(VCPU_ID, 0, guest_code); 183 + ucall_init(vm, NULL); 232 184 233 185 pthread_create(&migration_thread, NULL, migration_worker, 0); 234 186
+2 -2
tools/testing/selftests/kvm/steal_time.c
··· 116 116 uint64_t st_time; 117 117 }; 118 118 119 - static int64_t smccc(uint32_t func, uint32_t arg) 119 + static int64_t smccc(uint32_t func, uint64_t arg) 120 120 { 121 121 unsigned long ret; 122 122 123 123 asm volatile( 124 - "mov x0, %1\n" 124 + "mov w0, %w1\n" 125 125 "mov x1, %2\n" 126 126 "hvc #0\n" 127 127 "mov %0, x0\n"
+128
tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * svm_int_ctl_test 4 + * 5 + * Copyright (C) 2021, Red Hat, Inc. 6 + * 7 + * Nested SVM testing: test simultaneous use of V_IRQ from L1 and L0. 8 + */ 9 + 10 + #include "test_util.h" 11 + #include "kvm_util.h" 12 + #include "processor.h" 13 + #include "svm_util.h" 14 + #include "apic.h" 15 + 16 + #define VCPU_ID 0 17 + 18 + static struct kvm_vm *vm; 19 + 20 + bool vintr_irq_called; 21 + bool intr_irq_called; 22 + 23 + #define VINTR_IRQ_NUMBER 0x20 24 + #define INTR_IRQ_NUMBER 0x30 25 + 26 + static void vintr_irq_handler(struct ex_regs *regs) 27 + { 28 + vintr_irq_called = true; 29 + } 30 + 31 + static void intr_irq_handler(struct ex_regs *regs) 32 + { 33 + x2apic_write_reg(APIC_EOI, 0x00); 34 + intr_irq_called = true; 35 + } 36 + 37 + static void l2_guest_code(struct svm_test_data *svm) 38 + { 39 + /* This code raises interrupt INTR_IRQ_NUMBER in the L1's LAPIC, 40 + * and since L1 didn't enable virtual interrupt masking, 41 + * L2 should receive it and not L1. 42 + * 43 + * L2 also has virtual interrupt 'VINTR_IRQ_NUMBER' pending in V_IRQ 44 + * so it should also receive it after the following 'sti'. 45 + */ 46 + x2apic_write_reg(APIC_ICR, 47 + APIC_DEST_SELF | APIC_INT_ASSERT | INTR_IRQ_NUMBER); 48 + 49 + __asm__ __volatile__( 50 + "sti\n" 51 + "nop\n" 52 + ); 53 + 54 + GUEST_ASSERT(vintr_irq_called); 55 + GUEST_ASSERT(intr_irq_called); 56 + 57 + __asm__ __volatile__( 58 + "vmcall\n" 59 + ); 60 + } 61 + 62 + static void l1_guest_code(struct svm_test_data *svm) 63 + { 64 + #define L2_GUEST_STACK_SIZE 64 65 + unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE]; 66 + struct vmcb *vmcb = svm->vmcb; 67 + 68 + x2apic_enable(); 69 + 70 + /* Prepare for L2 execution. */ 71 + generic_svm_setup(svm, l2_guest_code, 72 + &l2_guest_stack[L2_GUEST_STACK_SIZE]); 73 + 74 + /* No virtual interrupt masking */ 75 + vmcb->control.int_ctl &= ~V_INTR_MASKING_MASK; 76 + 77 + /* No intercepts for real and virtual interrupts */ 78 + vmcb->control.intercept &= ~(1ULL << INTERCEPT_INTR | INTERCEPT_VINTR); 79 + 80 + /* Make a virtual interrupt VINTR_IRQ_NUMBER pending */ 81 + vmcb->control.int_ctl |= V_IRQ_MASK | (0x1 << V_INTR_PRIO_SHIFT); 82 + vmcb->control.int_vector = VINTR_IRQ_NUMBER; 83 + 84 + run_guest(vmcb, svm->vmcb_gpa); 85 + GUEST_ASSERT(vmcb->control.exit_code == SVM_EXIT_VMMCALL); 86 + GUEST_DONE(); 87 + } 88 + 89 + int main(int argc, char *argv[]) 90 + { 91 + vm_vaddr_t svm_gva; 92 + 93 + nested_svm_check_supported(); 94 + 95 + vm = vm_create_default(VCPU_ID, 0, (void *) l1_guest_code); 96 + 97 + vm_init_descriptor_tables(vm); 98 + vcpu_init_descriptor_tables(vm, VCPU_ID); 99 + 100 + vm_install_exception_handler(vm, VINTR_IRQ_NUMBER, vintr_irq_handler); 101 + vm_install_exception_handler(vm, INTR_IRQ_NUMBER, intr_irq_handler); 102 + 103 + vcpu_alloc_svm(vm, &svm_gva); 104 + vcpu_args_set(vm, VCPU_ID, 1, svm_gva); 105 + 106 + struct kvm_run *run = vcpu_state(vm, VCPU_ID); 107 + struct ucall uc; 108 + 109 + vcpu_run(vm, VCPU_ID); 110 + TEST_ASSERT(run->exit_reason == KVM_EXIT_IO, 111 + "Got exit_reason other than KVM_EXIT_IO: %u (%s)\n", 112 + run->exit_reason, 113 + exit_reason_str(run->exit_reason)); 114 + 115 + switch (get_ucall(vm, VCPU_ID, &uc)) { 116 + case UCALL_ABORT: 117 + TEST_FAIL("%s", (const char *)uc.args[0]); 118 + break; 119 + /* NOT REACHED */ 120 + case UCALL_DONE: 121 + goto done; 122 + default: 123 + TEST_FAIL("Unknown ucall 0x%lx.", uc.cmd); 124 + } 125 + done: 126 + kvm_vm_free(vm); 127 + return 0; 128 + }
+309
tools/testing/selftests/netfilter/nft_nat_zones.sh
··· 1 + #!/bin/bash 2 + # 3 + # Test connection tracking zone and NAT source port reallocation support. 4 + # 5 + 6 + # Kselftest framework requirement - SKIP code is 4. 7 + ksft_skip=4 8 + 9 + # Don't increase too much, 2000 clients should work 10 + # just fine but script can then take several minutes with 11 + # KASAN/debug builds. 12 + maxclients=100 13 + 14 + have_iperf=1 15 + ret=0 16 + 17 + # client1---. 18 + # veth1-. 19 + # | 20 + # NAT Gateway --veth0--> Server 21 + # | | 22 + # veth2-' | 23 + # client2---' | 24 + # .... | 25 + # clientX----vethX---' 26 + 27 + # All clients share identical IP address. 28 + # NAT Gateway uses policy routing and conntrack zones to isolate client 29 + # namespaces. Each client connects to Server, each with colliding tuples: 30 + # clientsaddr:10000 -> serveraddr:dport 31 + # NAT Gateway is supposed to do port reallocation for each of the 32 + # connections. 33 + 34 + sfx=$(mktemp -u "XXXXXXXX") 35 + gw="ns-gw-$sfx" 36 + cl1="ns-cl1-$sfx" 37 + cl2="ns-cl2-$sfx" 38 + srv="ns-srv-$sfx" 39 + 40 + v4gc1=$(sysctl -n net.ipv4.neigh.default.gc_thresh1 2>/dev/null) 41 + v4gc2=$(sysctl -n net.ipv4.neigh.default.gc_thresh2 2>/dev/null) 42 + v4gc3=$(sysctl -n net.ipv4.neigh.default.gc_thresh3 2>/dev/null) 43 + v6gc1=$(sysctl -n net.ipv6.neigh.default.gc_thresh1 2>/dev/null) 44 + v6gc2=$(sysctl -n net.ipv6.neigh.default.gc_thresh2 2>/dev/null) 45 + v6gc3=$(sysctl -n net.ipv6.neigh.default.gc_thresh3 2>/dev/null) 46 + 47 + cleanup() 48 + { 49 + ip netns del $gw 50 + ip netns del $srv 51 + for i in $(seq 1 $maxclients); do 52 + ip netns del ns-cl$i-$sfx 2>/dev/null 53 + done 54 + 55 + sysctl -q net.ipv4.neigh.default.gc_thresh1=$v4gc1 2>/dev/null 56 + sysctl -q net.ipv4.neigh.default.gc_thresh2=$v4gc2 2>/dev/null 57 + sysctl -q net.ipv4.neigh.default.gc_thresh3=$v4gc3 2>/dev/null 58 + sysctl -q net.ipv6.neigh.default.gc_thresh1=$v6gc1 2>/dev/null 59 + sysctl -q net.ipv6.neigh.default.gc_thresh2=$v6gc2 2>/dev/null 60 + sysctl -q net.ipv6.neigh.default.gc_thresh3=$v6gc3 2>/dev/null 61 + } 62 + 63 + nft --version > /dev/null 2>&1 64 + if [ $? -ne 0 ];then 65 + echo "SKIP: Could not run test without nft tool" 66 + exit $ksft_skip 67 + fi 68 + 69 + ip -Version > /dev/null 2>&1 70 + if [ $? -ne 0 ];then 71 + echo "SKIP: Could not run test without ip tool" 72 + exit $ksft_skip 73 + fi 74 + 75 + conntrack -V > /dev/null 2>&1 76 + if [ $? -ne 0 ];then 77 + echo "SKIP: Could not run test without conntrack tool" 78 + exit $ksft_skip 79 + fi 80 + 81 + iperf3 -v >/dev/null 2>&1 82 + if [ $? -ne 0 ];then 83 + have_iperf=0 84 + fi 85 + 86 + ip netns add "$gw" 87 + if [ $? -ne 0 ];then 88 + echo "SKIP: Could not create net namespace $gw" 89 + exit $ksft_skip 90 + fi 91 + ip -net "$gw" link set lo up 92 + 93 + trap cleanup EXIT 94 + 95 + ip netns add "$srv" 96 + if [ $? -ne 0 ];then 97 + echo "SKIP: Could not create server netns $srv" 98 + exit $ksft_skip 99 + fi 100 + 101 + ip link add veth0 netns "$gw" type veth peer name eth0 netns "$srv" 102 + ip -net "$gw" link set veth0 up 103 + ip -net "$srv" link set lo up 104 + ip -net "$srv" link set eth0 up 105 + 106 + sysctl -q net.ipv6.neigh.default.gc_thresh1=512 2>/dev/null 107 + sysctl -q net.ipv6.neigh.default.gc_thresh2=1024 2>/dev/null 108 + sysctl -q net.ipv6.neigh.default.gc_thresh3=4096 2>/dev/null 109 + sysctl -q net.ipv4.neigh.default.gc_thresh1=512 2>/dev/null 110 + sysctl -q net.ipv4.neigh.default.gc_thresh2=1024 2>/dev/null 111 + sysctl -q net.ipv4.neigh.default.gc_thresh3=4096 2>/dev/null 112 + 113 + for i in $(seq 1 $maxclients);do 114 + cl="ns-cl$i-$sfx" 115 + 116 + ip netns add "$cl" 117 + if [ $? -ne 0 ];then 118 + echo "SKIP: Could not create client netns $cl" 119 + exit $ksft_skip 120 + fi 121 + ip link add veth$i netns "$gw" type veth peer name eth0 netns "$cl" > /dev/null 2>&1 122 + if [ $? -ne 0 ];then 123 + echo "SKIP: No virtual ethernet pair device support in kernel" 124 + exit $ksft_skip 125 + fi 126 + done 127 + 128 + for i in $(seq 1 $maxclients);do 129 + cl="ns-cl$i-$sfx" 130 + echo netns exec "$cl" ip link set lo up 131 + echo netns exec "$cl" ip link set eth0 up 132 + echo netns exec "$cl" sysctl -q net.ipv4.tcp_syn_retries=2 133 + echo netns exec "$gw" ip link set veth$i up 134 + echo netns exec "$gw" sysctl -q net.ipv4.conf.veth$i.arp_ignore=2 135 + echo netns exec "$gw" sysctl -q net.ipv4.conf.veth$i.rp_filter=0 136 + 137 + # clients have same IP addresses. 138 + echo netns exec "$cl" ip addr add 10.1.0.3/24 dev eth0 139 + echo netns exec "$cl" ip addr add dead:1::3/64 dev eth0 140 + echo netns exec "$cl" ip route add default via 10.1.0.2 dev eth0 141 + echo netns exec "$cl" ip route add default via dead:1::2 dev eth0 142 + 143 + # NB: same addresses on client-facing interfaces. 144 + echo netns exec "$gw" ip addr add 10.1.0.2/24 dev veth$i 145 + echo netns exec "$gw" ip addr add dead:1::2/64 dev veth$i 146 + 147 + # gw: policy routing 148 + echo netns exec "$gw" ip route add 10.1.0.0/24 dev veth$i table $((1000+i)) 149 + echo netns exec "$gw" ip route add dead:1::0/64 dev veth$i table $((1000+i)) 150 + echo netns exec "$gw" ip route add 10.3.0.0/24 dev veth0 table $((1000+i)) 151 + echo netns exec "$gw" ip route add dead:3::0/64 dev veth0 table $((1000+i)) 152 + echo netns exec "$gw" ip rule add fwmark $i lookup $((1000+i)) 153 + done | ip -batch /dev/stdin 154 + 155 + ip -net "$gw" addr add 10.3.0.1/24 dev veth0 156 + ip -net "$gw" addr add dead:3::1/64 dev veth0 157 + 158 + ip -net "$srv" addr add 10.3.0.99/24 dev eth0 159 + ip -net "$srv" addr add dead:3::99/64 dev eth0 160 + 161 + ip netns exec $gw nft -f /dev/stdin<<EOF 162 + table inet raw { 163 + map iiftomark { 164 + type ifname : mark 165 + } 166 + 167 + map iiftozone { 168 + typeof iifname : ct zone 169 + } 170 + 171 + set inicmp { 172 + flags dynamic 173 + type ipv4_addr . ifname . ipv4_addr 174 + } 175 + set inflows { 176 + flags dynamic 177 + type ipv4_addr . inet_service . ifname . ipv4_addr . inet_service 178 + } 179 + 180 + set inflows6 { 181 + flags dynamic 182 + type ipv6_addr . inet_service . ifname . ipv6_addr . inet_service 183 + } 184 + 185 + chain prerouting { 186 + type filter hook prerouting priority -64000; policy accept; 187 + ct original zone set meta iifname map @iiftozone 188 + meta mark set meta iifname map @iiftomark 189 + 190 + tcp flags & (syn|ack) == ack add @inflows { ip saddr . tcp sport . meta iifname . ip daddr . tcp dport counter } 191 + add @inflows6 { ip6 saddr . tcp sport . meta iifname . ip6 daddr . tcp dport counter } 192 + ip protocol icmp add @inicmp { ip saddr . meta iifname . ip daddr counter } 193 + } 194 + 195 + chain nat_postrouting { 196 + type nat hook postrouting priority 0; policy accept; 197 + ct mark set meta mark meta oifname veth0 masquerade 198 + } 199 + 200 + chain mangle_prerouting { 201 + type filter hook prerouting priority -100; policy accept; 202 + ct direction reply meta mark set ct mark 203 + } 204 + } 205 + EOF 206 + 207 + ( echo add element inet raw iiftomark \{ 208 + for i in $(seq 1 $((maxclients-1))); do 209 + echo \"veth$i\" : $i, 210 + done 211 + echo \"veth$maxclients\" : $maxclients \} 212 + echo add element inet raw iiftozone \{ 213 + for i in $(seq 1 $((maxclients-1))); do 214 + echo \"veth$i\" : $i, 215 + done 216 + echo \"veth$maxclients\" : $maxclients \} 217 + ) | ip netns exec $gw nft -f /dev/stdin 218 + 219 + ip netns exec "$gw" sysctl -q net.ipv4.conf.all.forwarding=1 > /dev/null 220 + ip netns exec "$gw" sysctl -q net.ipv6.conf.all.forwarding=1 > /dev/null 221 + ip netns exec "$gw" sysctl -q net.ipv4.conf.all.rp_filter=0 >/dev/null 222 + 223 + # useful for debugging: allows to use 'ping' from clients to gateway. 224 + ip netns exec "$gw" sysctl -q net.ipv4.fwmark_reflect=1 > /dev/null 225 + ip netns exec "$gw" sysctl -q net.ipv6.fwmark_reflect=1 > /dev/null 226 + 227 + for i in $(seq 1 $maxclients); do 228 + cl="ns-cl$i-$sfx" 229 + ip netns exec $cl ping -i 0.5 -q -c 3 10.3.0.99 > /dev/null 2>&1 & 230 + if [ $? -ne 0 ]; then 231 + echo FAIL: Ping failure from $cl 1>&2 232 + ret=1 233 + break 234 + fi 235 + done 236 + 237 + wait 238 + 239 + for i in $(seq 1 $maxclients); do 240 + ip netns exec $gw nft get element inet raw inicmp "{ 10.1.0.3 . \"veth$i\" . 10.3.0.99 }" | grep -q "{ 10.1.0.3 . \"veth$i\" . 10.3.0.99 counter packets 3 bytes 252 }" 241 + if [ $? -ne 0 ];then 242 + ret=1 243 + echo "FAIL: counter icmp mismatch for veth$i" 1>&2 244 + ip netns exec $gw nft get element inet raw inicmp "{ 10.1.0.3 . \"veth$i\" . 10.3.0.99 }" 1>&2 245 + break 246 + fi 247 + done 248 + 249 + ip netns exec $gw nft get element inet raw inicmp "{ 10.3.0.99 . \"veth0\" . 10.3.0.1 }" | grep -q "{ 10.3.0.99 . \"veth0\" . 10.3.0.1 counter packets $((3 * $maxclients)) bytes $((252 * $maxclients)) }" 250 + if [ $? -ne 0 ];then 251 + ret=1 252 + echo "FAIL: counter icmp mismatch for veth0: { 10.3.0.99 . \"veth0\" . 10.3.0.1 counter packets $((3 * $maxclients)) bytes $((252 * $maxclients)) }" 253 + ip netns exec $gw nft get element inet raw inicmp "{ 10.3.99 . \"veth0\" . 10.3.0.1 }" 1>&2 254 + fi 255 + 256 + if [ $ret -eq 0 ]; then 257 + echo "PASS: ping test from all $maxclients namespaces" 258 + fi 259 + 260 + if [ $have_iperf -eq 0 ];then 261 + echo "SKIP: iperf3 not installed" 262 + if [ $ret -ne 0 ];then 263 + exit $ret 264 + fi 265 + exit $ksft_skip 266 + fi 267 + 268 + ip netns exec $srv iperf3 -s > /dev/null 2>&1 & 269 + iperfpid=$! 270 + sleep 1 271 + 272 + for i in $(seq 1 $maxclients); do 273 + if [ $ret -ne 0 ]; then 274 + break 275 + fi 276 + cl="ns-cl$i-$sfx" 277 + ip netns exec $cl iperf3 -c 10.3.0.99 --cport 10000 -n 1 > /dev/null 278 + if [ $? -ne 0 ]; then 279 + echo FAIL: Failure to connect for $cl 1>&2 280 + ip netns exec $gw conntrack -S 1>&2 281 + ret=1 282 + fi 283 + done 284 + if [ $ret -eq 0 ];then 285 + echo "PASS: iperf3 connections for all $maxclients net namespaces" 286 + fi 287 + 288 + kill $iperfpid 289 + wait 290 + 291 + for i in $(seq 1 $maxclients); do 292 + ip netns exec $gw nft get element inet raw inflows "{ 10.1.0.3 . 10000 . \"veth$i\" . 10.3.0.99 . 5201 }" > /dev/null 293 + if [ $? -ne 0 ];then 294 + ret=1 295 + echo "FAIL: can't find expected tcp entry for veth$i" 1>&2 296 + break 297 + fi 298 + done 299 + if [ $ret -eq 0 ];then 300 + echo "PASS: Found client connection for all $maxclients net namespaces" 301 + fi 302 + 303 + ip netns exec $gw nft get element inet raw inflows "{ 10.3.0.99 . 5201 . \"veth0\" . 10.3.0.1 . 10000 }" > /dev/null 304 + if [ $? -ne 0 ];then 305 + ret=1 306 + echo "FAIL: cannot find return entry on veth0" 1>&2 307 + fi 308 + 309 + exit $ret
+156
tools/testing/selftests/netfilter/nft_zones_many.sh
··· 1 + #!/bin/bash 2 + 3 + # Test insertion speed for packets with identical addresses/ports 4 + # that are all placed in distinct conntrack zones. 5 + 6 + sfx=$(mktemp -u "XXXXXXXX") 7 + ns="ns-$sfx" 8 + 9 + # Kselftest framework requirement - SKIP code is 4. 10 + ksft_skip=4 11 + 12 + zones=20000 13 + have_ct_tool=0 14 + ret=0 15 + 16 + cleanup() 17 + { 18 + ip netns del $ns 19 + } 20 + 21 + ip netns add $ns 22 + if [ $? -ne 0 ];then 23 + echo "SKIP: Could not create net namespace $gw" 24 + exit $ksft_skip 25 + fi 26 + 27 + trap cleanup EXIT 28 + 29 + conntrack -V > /dev/null 2>&1 30 + if [ $? -eq 0 ];then 31 + have_ct_tool=1 32 + fi 33 + 34 + ip -net "$ns" link set lo up 35 + 36 + test_zones() { 37 + local max_zones=$1 38 + 39 + ip netns exec $ns sysctl -q net.netfilter.nf_conntrack_udp_timeout=3600 40 + ip netns exec $ns nft -f /dev/stdin<<EOF 41 + flush ruleset 42 + table inet raw { 43 + map rndzone { 44 + typeof numgen inc mod $max_zones : ct zone 45 + } 46 + 47 + chain output { 48 + type filter hook output priority -64000; policy accept; 49 + udp dport 12345 ct zone set numgen inc mod 65536 map @rndzone 50 + } 51 + } 52 + EOF 53 + ( 54 + echo "add element inet raw rndzone {" 55 + for i in $(seq 1 $max_zones);do 56 + echo -n "$i : $i" 57 + if [ $i -lt $max_zones ]; then 58 + echo "," 59 + else 60 + echo "}" 61 + fi 62 + done 63 + ) | ip netns exec $ns nft -f /dev/stdin 64 + 65 + local i=0 66 + local j=0 67 + local outerstart=$(date +%s%3N) 68 + local stop=$outerstart 69 + 70 + while [ $i -lt $max_zones ]; do 71 + local start=$(date +%s%3N) 72 + i=$((i + 10000)) 73 + j=$((j + 1)) 74 + dd if=/dev/zero of=/dev/stdout bs=8k count=10000 2>/dev/null | ip netns exec "$ns" nc -w 1 -q 1 -u -p 12345 127.0.0.1 12345 > /dev/null 75 + if [ $? -ne 0 ] ;then 76 + ret=1 77 + break 78 + fi 79 + 80 + stop=$(date +%s%3N) 81 + local duration=$((stop-start)) 82 + echo "PASS: added 10000 entries in $duration ms (now $i total, loop $j)" 83 + done 84 + 85 + if [ $have_ct_tool -eq 1 ]; then 86 + local count=$(ip netns exec "$ns" conntrack -C) 87 + local duration=$((stop-outerstart)) 88 + 89 + if [ $count -eq $max_zones ]; then 90 + echo "PASS: inserted $count entries from packet path in $duration ms total" 91 + else 92 + ip netns exec $ns conntrack -S 1>&2 93 + echo "FAIL: inserted $count entries from packet path in $duration ms total, expected $max_zones entries" 94 + ret=1 95 + fi 96 + fi 97 + 98 + if [ $ret -ne 0 ];then 99 + echo "FAIL: insert $max_zones entries from packet path" 1>&2 100 + fi 101 + } 102 + 103 + test_conntrack_tool() { 104 + local max_zones=$1 105 + 106 + ip netns exec $ns conntrack -F >/dev/null 2>/dev/null 107 + 108 + local outerstart=$(date +%s%3N) 109 + local start=$(date +%s%3N) 110 + local stop=$start 111 + local i=0 112 + while [ $i -lt $max_zones ]; do 113 + i=$((i + 1)) 114 + ip netns exec "$ns" conntrack -I -s 1.1.1.1 -d 2.2.2.2 --protonum 6 \ 115 + --timeout 3600 --state ESTABLISHED --sport 12345 --dport 1000 --zone $i >/dev/null 2>&1 116 + if [ $? -ne 0 ];then 117 + ip netns exec "$ns" conntrack -I -s 1.1.1.1 -d 2.2.2.2 --protonum 6 \ 118 + --timeout 3600 --state ESTABLISHED --sport 12345 --dport 1000 --zone $i > /dev/null 119 + echo "FAIL: conntrack -I returned an error" 120 + ret=1 121 + break 122 + fi 123 + 124 + if [ $((i%10000)) -eq 0 ];then 125 + stop=$(date +%s%3N) 126 + 127 + local duration=$((stop-start)) 128 + echo "PASS: added 10000 entries in $duration ms (now $i total)" 129 + start=$stop 130 + fi 131 + done 132 + 133 + local count=$(ip netns exec "$ns" conntrack -C) 134 + local duration=$((stop-outerstart)) 135 + 136 + if [ $count -eq $max_zones ]; then 137 + echo "PASS: inserted $count entries via ctnetlink in $duration ms" 138 + else 139 + ip netns exec $ns conntrack -S 1>&2 140 + echo "FAIL: inserted $count entries via ctnetlink in $duration ms, expected $max_zones entries ($duration ms)" 141 + ret=1 142 + fi 143 + } 144 + 145 + test_zones $zones 146 + 147 + if [ $have_ct_tool -eq 1 ];then 148 + test_conntrack_tool $zones 149 + else 150 + echo "SKIP: Could not run ctnetlink insertion test without conntrack tool" 151 + if [ $ret -eq 0 ];then 152 + exit $ksft_skip 153 + fi 154 + fi 155 + 156 + exit $ret
+49 -19
virt/kvm/kvm_main.c
··· 235 235 { 236 236 } 237 237 238 - static inline bool kvm_kick_many_cpus(const struct cpumask *cpus, bool wait) 238 + static inline bool kvm_kick_many_cpus(cpumask_var_t tmp, bool wait) 239 239 { 240 - if (unlikely(!cpus)) 240 + const struct cpumask *cpus; 241 + 242 + if (likely(cpumask_available(tmp))) 243 + cpus = tmp; 244 + else 241 245 cpus = cpu_online_mask; 242 246 243 247 if (cpumask_empty(cpus)) ··· 267 263 continue; 268 264 269 265 kvm_make_request(req, vcpu); 270 - cpu = vcpu->cpu; 271 266 272 267 if (!(req & KVM_REQUEST_NO_WAKEUP) && kvm_vcpu_wake_up(vcpu)) 273 268 continue; 274 269 275 - if (tmp != NULL && cpu != -1 && cpu != me && 276 - kvm_request_needs_ipi(vcpu, req)) 277 - __cpumask_set_cpu(cpu, tmp); 270 + /* 271 + * tmp can be "unavailable" if cpumasks are allocated off stack 272 + * as allocation of the mask is deliberately not fatal and is 273 + * handled by falling back to kicking all online CPUs. 274 + */ 275 + if (!cpumask_available(tmp)) 276 + continue; 277 + 278 + /* 279 + * Note, the vCPU could get migrated to a different pCPU at any 280 + * point after kvm_request_needs_ipi(), which could result in 281 + * sending an IPI to the previous pCPU. But, that's ok because 282 + * the purpose of the IPI is to ensure the vCPU returns to 283 + * OUTSIDE_GUEST_MODE, which is satisfied if the vCPU migrates. 284 + * Entering READING_SHADOW_PAGE_TABLES after this point is also 285 + * ok, as the requirement is only that KVM wait for vCPUs that 286 + * were reading SPTEs _before_ any changes were finalized. See 287 + * kvm_vcpu_kick() for more details on handling requests. 288 + */ 289 + if (kvm_request_needs_ipi(vcpu, req)) { 290 + cpu = READ_ONCE(vcpu->cpu); 291 + if (cpu != -1 && cpu != me) 292 + __cpumask_set_cpu(cpu, tmp); 293 + } 278 294 } 279 295 280 296 called = kvm_kick_many_cpus(tmp, !!(req & KVM_REQUEST_WAIT)); ··· 326 302 #ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL 327 303 void kvm_flush_remote_tlbs(struct kvm *kvm) 328 304 { 329 - /* 330 - * Read tlbs_dirty before setting KVM_REQ_TLB_FLUSH in 331 - * kvm_make_all_cpus_request. 332 - */ 333 - long dirty_count = smp_load_acquire(&kvm->tlbs_dirty); 334 - 335 305 ++kvm->stat.generic.remote_tlb_flush_requests; 306 + 336 307 /* 337 308 * We want to publish modifications to the page tables before reading 338 309 * mode. Pairs with a memory barrier in arch-specific code. ··· 342 323 if (!kvm_arch_flush_remote_tlb(kvm) 343 324 || kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH)) 344 325 ++kvm->stat.generic.remote_tlb_flush; 345 - cmpxchg(&kvm->tlbs_dirty, dirty_count, 0); 346 326 } 347 327 EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs); 348 328 #endif ··· 546 528 } 547 529 } 548 530 549 - if (range->flush_on_ret && (ret || kvm->tlbs_dirty)) 531 + if (range->flush_on_ret && ret) 550 532 kvm_flush_remote_tlbs(kvm); 551 533 552 534 if (locked) ··· 3152 3134 3153 3135 static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu) 3154 3136 { 3155 - unsigned int old, val, shrink; 3137 + unsigned int old, val, shrink, grow_start; 3156 3138 3157 3139 old = val = vcpu->halt_poll_ns; 3158 3140 shrink = READ_ONCE(halt_poll_ns_shrink); 3141 + grow_start = READ_ONCE(halt_poll_ns_grow_start); 3159 3142 if (shrink == 0) 3160 3143 val = 0; 3161 3144 else 3162 3145 val /= shrink; 3146 + 3147 + if (val < grow_start) 3148 + val = 0; 3163 3149 3164 3150 vcpu->halt_poll_ns = val; 3165 3151 trace_kvm_halt_poll_ns_shrink(vcpu->vcpu_id, val, old); ··· 3312 3290 */ 3313 3291 void kvm_vcpu_kick(struct kvm_vcpu *vcpu) 3314 3292 { 3315 - int me; 3316 - int cpu = vcpu->cpu; 3293 + int me, cpu; 3317 3294 3318 3295 if (kvm_vcpu_wake_up(vcpu)) 3319 3296 return; 3320 3297 3298 + /* 3299 + * Note, the vCPU could get migrated to a different pCPU at any point 3300 + * after kvm_arch_vcpu_should_kick(), which could result in sending an 3301 + * IPI to the previous pCPU. But, that's ok because the purpose of the 3302 + * IPI is to force the vCPU to leave IN_GUEST_MODE, and migrating the 3303 + * vCPU also requires it to leave IN_GUEST_MODE. 3304 + */ 3321 3305 me = get_cpu(); 3322 - if (cpu != me && (unsigned)cpu < nr_cpu_ids && cpu_online(cpu)) 3323 - if (kvm_arch_vcpu_should_kick(vcpu)) 3306 + if (kvm_arch_vcpu_should_kick(vcpu)) { 3307 + cpu = READ_ONCE(vcpu->cpu); 3308 + if (cpu != me && (unsigned)cpu < nr_cpu_ids && cpu_online(cpu)) 3324 3309 smp_send_reschedule(cpu); 3310 + } 3325 3311 put_cpu(); 3326 3312 } 3327 3313 EXPORT_SYMBOL_GPL(kvm_vcpu_kick);