Compare

2f2f7eeef8b0a1a9b9ca998231419873ccae8d4e..a291a5cf0023ef3a854a85549f2301da9f24d55b

fs: drop the smp_mb()s that mnt_get_count() made redundant

Both mntput_no_expire_slowpath() and do_umount() have an smp_mb()
between taking mount_lock and summing up the reference count. They pair
with the smp_mb() in __legitimize_mnt().

A walker in __legitimize_mnt() increments the count and then re-reads
the seqcount of mount_lock. The unmounter writes the seqcount when it
takes mount_lock and then sums up the count. They must not both miss
each other's store. Otherwise the walker keeps a reference to a mount
that the unmounter finishes off. That's the store buffering pattern and
it needs a full barrier between the store and the load on both sides.

In commit 119e1ef80ecf ("fix __legitimize_mnt()/mntput() race") the
barrier in the slow path of mntput_no_expire() as added and the one in
do_umount() in commit 65781e19dcfc ("do_umount(): add missing barrier
before refcount checks in sync case"). Back then mnt_get_count() didn't
have a barrier of its own.

Since commit 7eb84d54fac5 ("fs: don't let a migrating task hide its
reference from do_umount()") it does. It sums up the puts, does an
smp_mb() and then sums up the gets. In program order that barrier sits
after the seqcount write in lock_mount_hash() and before the loads of
the gets. That's all the walker needs. If the sum misses the walker's
increment the walker sees the seqcount change and drops its reference
under mount_lock where it finds MNT_DOOMED or MNT_SYNC_UMOUNT.

The only thing the outer barrier orders on top of that is the seqcount
write against the loads of the puts and nothing relies on it:

(1) A put from the fast path of mntput_no_expire() never looks at the
    seqcount. If the sum misses such a put that's what the grace period
    is for.

(2) All other puts happen under mount_lock and are ordered by it.

(3) The slow path's own decrement right before the sum is a store on the
    same cpu and is read back in program order.

So the outer barriers don't order anything that the inner one doesn't.
That argument is made in the kernel memory model and every architecture
has to implement its barriers according to it. herd7 against
tools/memory-model agrees. Without the outer smp_mb() the walker against
the slow path and against the busy check in do_umount() is "Never". If
the inner smp_mb() goes as well it's "Sometimes". The litmus tests for
this are in the next patch.

Make the comments in __legitimize_mnt() and mnt_get_count() point at
each other.

Link: https://patch.msgid.link/20261011-work-mount-fixes-5-v1-1-a9b9a8ecf565@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>

Christian Brauner <brauner@kernel.org> · 2026-10-11 15:30 UTC

Browse files
96 files changed, +427 −841
modified MAINTAINERS
@@ -8170,6 +8170,7 @@ F: drivers/gpu/drm/tiny/hx8357d.c
8170 8170
8171 8171 DRM DRIVER FOR HYPERV SYNTHETIC VIDEO DEVICE
8172 8172 M: Dexuan Cui <decui@microsoft.com>
8173 + M: Long Li <longli@microsoft.com>
8173 8174 M: Saurabh Sengar <ssengar@linux.microsoft.com>
8174 8175 L: linux-hyperv@vger.kernel.org
8175 8176 L: dri-devel@lists.freedesktop.org
@@ -12160,9 +12161,11 @@ S: Maintained
12160 12161 F: drivers/media/i2c/hi847.c
12161 12162
12162 12163 Hyper-V/Azure CORE AND DRIVERS
12164 + M: "K. Y. Srinivasan" <kys@microsoft.com>
12163 12165 M: Haiyang Zhang <haiyangz@microsoft.com>
12164 12166 M: Wei Liu <wei.liu@kernel.org>
12165 12167 M: Dexuan Cui <decui@microsoft.com>
12168 + M: Long Li <longli@microsoft.com>
12166 12169 L: linux-hyperv@vger.kernel.org
12167 12170 S: Supported
12168 12171 T: git git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
@@ -18815,7 +18818,6 @@ F: drivers/hwmon/nct7363.c
18815 18818
18816 18819 NETCONSOLE
18817 18820 M: Breno Leitao <leitao@debian.org>
18818 - R: Gustavo Luiz Duarte <gustavold@gmail.com>
18819 18821 S: Maintained
18820 18822 F: Documentation/networking/netconsole.rst
18821 18823 F: drivers/net/netconsole.c
modified arch/arm/boot/dts/ti/omap/dra7xx-clocks.dtsi
@@ -1376,8 +1376,8 @@
1376 1376 clocks = <&apll_pcie_ck>;
1377 1377 #clock-cells = <0>;
1378 1378 reg = <0x021c>;
1379 - ti,dividers = <2>, <1>;
1380 1379 ti,bit-shift = <8>;
1380 + ti,max-div = <2>;
1381 1381 };
1382 1382
1383 1383 apll_pcie_clkvcoldo: clock-apll-pcie-clkvcoldo {
modified arch/arm/configs/sama5_defconfig
@@ -69,8 +69,8 @@ CONFIG_BLK_DEV_SD=y
69 69 # CONFIG_BLK_DEV_BSG is not set
70 70 # CONFIG_SCSI_LOWLEVEL is not set
71 71 CONFIG_NETDEVICES=y
72 - CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON=m
73 - CONFIG_NET_DSA_MICROCHIP_KSZ_SPI=m
72 + CONFIG_NET_DSA_MICROCHIP_KSZ9477=m
73 + CONFIG_NET_DSA_MICROCHIP_KSZ9477_SPI=m
74 74 # CONFIG_NET_VENDOR_BROADCOM is not set
75 75 CONFIG_MACB=y
76 76 # CONFIG_NET_VENDOR_CIRRUS is not set
modified arch/arm64/boot/dts/nvidia/tegra264-p4071-0000+p3834.dtsi
@@ -9,17 +9,4 @@
9 9 chosen {
10 10 stdout-path = "serial0:115200n8";
11 11 };
12 -
13 - bus@0 {
14 - pwm@c6a0000 {
15 - status = "okay";
16 - };
17 - };
18 -
19 - fan: pwm-fan {
20 - compatible = "pwm-fan";
21 - cooling-levels = <77 102 140 192 255>;
22 - pwms = <&pwm4 0 40000>;
23 - #cooling-cells = <2>;
24 - };
25 12 };
modified arch/arm64/boot/dts/nvidia/tegra264.dtsi
@@ -3356,18 +3356,6 @@
3356 3356 status = "disabled";
3357 3357 };
3358 3358
3359 - pwm4: pwm@c6a0000 {
3360 - compatible = "nvidia,tegra264-pwm";
3361 - reg = <0x0 0xc6a0000 0x0 0x10000>;
3362 - status = "disabled";
3363 -
3364 - clocks = <&bpmp TEGRA264_CLK_PWM4>;
3365 - resets = <&bpmp TEGRA264_RESET_PWM4>;
3366 - reset-names = "pwm";
3367 -
3368 - #pwm-cells = <2>;
3369 - };
3370 -
3371 3359 pinmux_aon: pinmux@c7a2000 {
3372 3360 compatible = "nvidia,tegra264-pinmux-aon";
3373 3361 reg = <0x0 0x0c7a2000 0x0 0x2000>;
@@ -3549,11 +3537,11 @@
3549 3537
3550 3538 pci@c000000 {
3551 3539 compatible = "nvidia,tegra264-pcie";
3552 - reg = <0x00 0x0c000000 0x0 0x00004000>,
3540 + reg = <0xd0 0xb0000000 0x0 0x10000000>,
3541 + <0x00 0x0c000000 0x0 0x00004000>,
3553 3542 <0x00 0x0c004000 0x0 0x00001000>,
3554 - <0x00 0x0c005000 0x0 0x00001000>,
3555 - <0xd0 0xb0000000 0x0 0x10000000>;
3556 - reg-names = "xal", "xtl", "xtl-pri", "ecam";
3543 + <0x00 0x0c005000 0x0 0x00001000>;
3544 + reg-names = "ecam", "xal", "xtl", "xtl-pri";
3557 3545 #address-cells = <3>;
3558 3546 #size-cells = <2>;
3559 3547 device_type = "pci";
@@ -3577,16 +3565,6 @@
3577 3565
3578 3566 nvidia,bpmp = <&bpmp 0>;
3579 3567 status = "disabled";
3580 -
3581 - pcie@0 {
3582 - device_type = "pci";
3583 - compatible = "pciclass,0604";
3584 - reg = <0x0 0x0 0x0 0x0 0x0>;
3585 - bus-range = <0x01 0xff>;
3586 - #address-cells = <3>;
3587 - #size-cells = <2>;
3588 - ranges;
3589 - };
3590 3568 };
3591 3569
3592 3570 pinmux_main: pinmux@c281000 {
@@ -3683,66 +3661,6 @@
3683 3661 status = "disabled";
3684 3662 };
3685 3663
3686 - pwm2: pwm@c5e0000 {
3687 - compatible = "nvidia,tegra264-pwm";
3688 - reg = <0x0 0xc5e0000 0x0 0x10000>;
3689 - status = "disabled";
3690 -
3691 - clocks = <&bpmp TEGRA264_CLK_PWM2>;
3692 - resets = <&bpmp TEGRA264_RESET_PWM2>;
3693 - reset-names = "pwm";
3694 -
3695 - #pwm-cells = <2>;
3696 - };
3697 -
3698 - pwm3: pwm@c5f0000 {
3699 - compatible = "nvidia,tegra264-pwm";
3700 - reg = <0x0 0xc5f0000 0x0 0x10000>;
3701 - status = "disabled";
3702 -
3703 - clocks = <&bpmp TEGRA264_CLK_PWM3>;
3704 - resets = <&bpmp TEGRA264_RESET_PWM3>;
3705 - reset-names = "pwm";
3706 -
3707 - #pwm-cells = <2>;
3708 - };
3709 -
3710 - pwm5: pwm@c600000 {
3711 - compatible = "nvidia,tegra264-pwm";
3712 - reg = <0x0 0xc600000 0x0 0x10000>;
3713 - status = "disabled";
3714 -
3715 - clocks = <&bpmp TEGRA264_CLK_PWM5>;
3716 - resets = <&bpmp TEGRA264_RESET_PWM5>;
3717 - reset-names = "pwm";
3718 -
3719 - #pwm-cells = <2>;
3720 - };
3721 -
3722 - pwm9: pwm@c610000 {
3723 - compatible = "nvidia,tegra264-pwm";
3724 - reg = <0x0 0xc610000 0x0 0x10000>;
3725 - status = "disabled";
3726 -
3727 - clocks = <&bpmp TEGRA264_CLK_PWM9>;
3728 - resets = <&bpmp TEGRA264_RESET_PWM9>;
3729 - reset-names = "pwm";
3730 -
3731 - #pwm-cells = <2>;
3732 - };
3733 -
3734 - pwm10: pwm@c620000 {
3735 - compatible = "nvidia,tegra264-pwm";
3736 - reg = <0x0 0xc620000 0x0 0x10000>;
3737 - status = "disabled";
3738 -
3739 - clocks = <&bpmp TEGRA264_CLK_PWM10>;
3740 - resets = <&bpmp TEGRA264_RESET_PWM10>;
3741 - reset-names = "pwm";
3742 -
3743 - #pwm-cells = <2>;
3744 - };
3745 -
3746 3664 i2c0: i2c@c630000 {
3747 3665 compatible = "nvidia,tegra264-i2c";
3748 3666 reg = <0x00 0x0c630000 0x0 0x10000>;
@@ -4072,12 +3990,12 @@
4072 3990
4073 3991 pci@8400000 {
4074 3992 compatible = "nvidia,tegra264-pcie";
4075 - reg = <0x00 0x08400000 0x0 0x00004000>,
3993 + reg = <0xa8 0xb0000000 0x0 0x10000000>,
3994 + <0x00 0x08400000 0x0 0x00004000>,
4076 3995 <0x00 0x08404000 0x0 0x00001000>,
4077 3996 <0x00 0x08405000 0x0 0x00001000>,
4078 - <0x00 0x08410000 0x0 0x00010000>,
4079 - <0xa8 0xb0000000 0x0 0x10000000>;
4080 - reg-names = "xal", "xtl", "xtl-pri", "xpl", "ecam";
3997 + <0x00 0x08410000 0x0 0x00010000>;
3998 + reg-names = "ecam", "xal", "xtl", "xtl-pri", "xpl";
4081 3999 #address-cells = <3>;
4082 4000 #size-cells = <2>;
4083 4001 device_type = "pci";
@@ -4100,26 +4018,16 @@
4100 4018
4101 4019 nvidia,bpmp = <&bpmp 1>;
4102 4020 status = "disabled";
4103 -
4104 - pcie@0 {
4105 - device_type = "pci";
4106 - compatible = "pciclass,0604";
4107 - reg = <0x0 0x0 0x0 0x0 0x0>;
4108 - bus-range = <0x01 0xff>;
4109 - #address-cells = <3>;
4110 - #size-cells = <2>;
4111 - ranges;
4112 - };
4113 4021 };
4114 4022
4115 4023 pci@8420000 {
4116 4024 compatible = "nvidia,tegra264-pcie";
4117 - reg = <0x00 0x08420000 0x0 0x00004000>,
4025 + reg = <0xb0 0xb0000000 0x0 0x10000000>,
4026 + <0x00 0x08420000 0x0 0x00004000>,
4118 4027 <0x00 0x08424000 0x0 0x00001000>,
4119 4028 <0x00 0x08425000 0x0 0x00001000>,
4120 - <0x00 0x08430000 0x0 0x00010000>,
4121 - <0xb0 0xb0000000 0x0 0x10000000>;
4122 - reg-names = "xal", "xtl", "xtl-pri", "xpl", "ecam";
4029 + <0x00 0x08430000 0x0 0x00010000>;
4030 + reg-names = "ecam", "xal", "xtl", "xtl-pri", "xpl";
4123 4031 #address-cells = <3>;
4124 4032 #size-cells = <2>;
4125 4033 device_type = "pci";
@@ -4142,26 +4050,16 @@
4142 4050
4143 4051 nvidia,bpmp = <&bpmp 2>;
4144 4052 status = "disabled";
4145 -
4146 - pcie@0 {
4147 - device_type = "pci";
4148 - compatible = "pciclass,0604";
4149 - reg = <0x0 0x0 0x0 0x0 0x0>;
4150 - bus-range = <0x01 0xff>;
4151 - #address-cells = <3>;
4152 - #size-cells = <2>;
4153 - ranges;
4154 - };
4155 4053 };
4156 4054
4157 4055 pci@8440000 {
4158 4056 compatible = "nvidia,tegra264-pcie";
4159 - reg = <0x00 0x08440000 0x0 0x00004000>,
4057 + reg = <0xb8 0xb0000000 0x0 0x10000000>,
4058 + <0x00 0x08440000 0x0 0x00004000>,
4160 4059 <0x00 0x08444000 0x0 0x00001000>,
4161 4060 <0x00 0x08445000 0x0 0x00001000>,
4162 - <0x00 0x08450000 0x0 0x00010000>,
4163 - <0xb8 0xb0000000 0x0 0x10000000>;
4164 - reg-names = "xal", "xtl", "xtl-pri", "xpl", "ecam";
4061 + <0x00 0x08450000 0x0 0x00010000>;
4062 + reg-names = "ecam", "xal", "xtl", "xtl-pri", "xpl";
4165 4063 #address-cells = <3>;
4166 4064 #size-cells = <2>;
4167 4065 device_type = "pci";
@@ -4184,26 +4082,16 @@
4184 4082
4185 4083 nvidia,bpmp = <&bpmp 3>;
4186 4084 status = "disabled";
4187 -
4188 - pcie@0 {
4189 - device_type = "pci";
4190 - compatible = "pciclass,0604";
4191 - reg = <0x0 0x0 0x0 0x0 0x0>;
4192 - bus-range = <0x01 0xff>;
4193 - #address-cells = <3>;
4194 - #size-cells = <2>;
4195 - ranges;
4196 - };
4197 4085 };
4198 4086
4199 4087 pci@8460000 {
4200 4088 compatible = "nvidia,tegra264-pcie";
4201 - reg = <0x00 0x08460000 0x0 0x00004000>,
4089 + reg = <0xc0 0xb0000000 0x0 0x10000000>,
4090 + <0x00 0x08460000 0x0 0x00004000>,
4202 4091 <0x00 0x08464000 0x0 0x00001000>,
4203 4092 <0x00 0x08465000 0x0 0x00001000>,
4204 - <0x00 0x08470000 0x0 0x00010000>,
4205 - <0xc0 0xb0000000 0x0 0x10000000>;
4206 - reg-names = "xal", "xtl", "xtl-pri", "xpl", "ecam";
4093 + <0x00 0x08470000 0x0 0x00010000>;
4094 + reg-names = "ecam", "xal", "xtl", "xtl-pri", "xpl";
4207 4095 #address-cells = <3>;
4208 4096 #size-cells = <2>;
4209 4097 device_type = "pci";
@@ -4226,26 +4114,16 @@
4226 4114
4227 4115 nvidia,bpmp = <&bpmp 4>;
4228 4116 status = "disabled";
4229 -
4230 - pcie@0 {
4231 - device_type = "pci";
4232 - compatible = "pciclass,0604";
4233 - reg = <0x0 0x0 0x0 0x0 0x0>;
4234 - bus-range = <0x01 0xff>;
4235 - #address-cells = <3>;
4236 - #size-cells = <2>;
4237 - ranges;
4238 - };
4239 4117 };
4240 4118
4241 4119 pci@8480000 {
4242 4120 compatible = "nvidia,tegra264-pcie";
4243 - reg = <0x00 0x08480000 0x0 0x00004000>,
4121 + reg = <0xc8 0xb0000000 0x0 0x10000000>,
4122 + <0x00 0x08480000 0x0 0x00004000>,
4244 4123 <0x00 0x08484000 0x0 0x00001000>,
4245 4124 <0x00 0x08485000 0x0 0x00001000>,
4246 - <0x00 0x08490000 0x0 0x00010000>,
4247 - <0xc8 0xb0000000 0x0 0x10000000>;
4248 - reg-names = "xal", "xtl", "xtl-pri", "xpl", "ecam";
4125 + <0x00 0x08490000 0x0 0x00010000>;
4126 + reg-names = "ecam", "xal", "xtl", "xtl-pri", "xpl";
4249 4127 #address-cells = <3>;
4250 4128 #size-cells = <2>;
4251 4129 device_type = "pci";
@@ -4268,16 +4146,6 @@
4268 4146
4269 4147 nvidia,bpmp = <&bpmp 5>;
4270 4148 status = "disabled";
4271 -
4272 - pcie@0 {
4273 - device_type = "pci";
4274 - compatible = "pciclass,0604";
4275 - reg = <0x0 0x0 0x0 0x0 0x0>;
4276 - bus-range = <0x01 0xff>;
4277 - #address-cells = <3>;
4278 - #size-cells = <2>;
4279 - ranges;
4280 - };
4281 4149 };
4282 4150 };
4283 4151
modified arch/nios2/include/asm/checksum.h
@@ -27,7 +27,7 @@ static inline __sum16 csum_fold(__wsum sum)
27 27 "add %0, %0, r8\n"
28 28 "nor %0, %0, %0\n"
29 29 : "=r" (sum)
30 - : "r" ((__force u32)sum << 16), "0" (sum)
30 + : "r" (sum << 16), "0" (sum)
31 31 : "r8");
32 32 return (__force __sum16) sum;
33 33 }
modified arch/riscv/boot/dts/microchip/mpfs-beaglev-fire.dts
@@ -90,6 +90,10 @@
90 90 };
91 91
92 92 &gpio0 {
93 + interrupts = <13>, <14>, <15>, <16>,
94 + <17>, <18>, <19>, <20>,
95 + <21>, <22>, <23>, <24>,
96 + <25>, <26>;
93 97 ngpios = <14>;
94 98 gpio-line-names = "", "", "", "", "", "", "",
95 99 "", "", "", "", "", "SD_CARD_CS", "USER_BUTTON";
@@ -97,6 +101,12 @@
97 101 };
98 102
99 103 &gpio1 {
104 + interrupts = <27>, <28>, <29>, <30>,
105 + <31>, <32>, <33>, <34>,
106 + <35>, <36>, <37>, <38>,
107 + <39>, <40>, <41>, <42>,
108 + <43>, <44>, <45>, <46>,
109 + <47>, <48>, <49>, <50>;
100 110 ngpios = <24>;
101 111 gpio-line-names = "", "", "", "", "", "", "", "", "", "",
102 112 "", "", "", "", "", "", "", "", "", "",
@@ -105,6 +115,14 @@
105 115 };
106 116
107 117 &gpio2 {
118 + interrupts = <53>, <53>, <53>, <53>,
119 + <53>, <53>, <53>, <53>,
120 + <53>, <53>, <53>, <53>,
121 + <53>, <53>, <53>, <53>,
122 + <53>, <53>, <53>, <53>,
123 + <53>, <53>, <53>, <53>,
124 + <53>, <53>, <53>, <53>,
125 + <53>, <53>, <53>, <53>;
108 126 ngpios = <32>;
109 127 gpio-line-names = "P8_PIN3_USER_LED_0", "P8_PIN4_USER_LED_1", "P8_PIN5_USER_LED_2",
110 128 "P8_PIN6_USER_LED_3", "P8_PIN7_USER_LED_4", "P8_PIN8_USER_LED_5",
modified arch/x86/hyperv/hv_init.c
@@ -426,7 +426,7 @@ static void __init hv_stimer_setup_percpu_clockev(void)
426 426 int ret;
427 427
428 428 /*
429 - * Continue after errors in setting up stimer clockevents
429 + * Continue afters errors in setting up stimer clockevents
430 430 * as we can run with the LAPIC timer as a fallback.
431 431 */
432 432 ret = hv_stimer_alloc(false);
@@ -434,7 +434,7 @@ static void __init hv_stimer_setup_percpu_clockev(void)
434 434 pr_warn("stimer setup failed with error %d\n", ret);
435 435
436 436 /*
437 - * Still register the LAPIC timer to allow users
437 + * Still register the LAPIC timer to allows users
438 438 * to switch to LAPIC timer via /sys, if they want to.
439 439 */
440 440 if (old_setup_percpu_clockev)
@@ -727,8 +727,7 @@ int hv_apicid_to_vp_index(u32 apic_id)
727 727 input->partition_id = HV_PARTITION_ID_SELF;
728 728 input->apic_ids[0] = apic_id;
729 729
730 - /* Treat input as having 2 APIC IDs so output is 64-bit aligned */
731 - output = (void *)input + struct_size(input, apic_ids, 2);
730 + output = *this_cpu_ptr(hyperv_pcpu_output_arg);
732 731
733 732 control = HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_INDEX_FROM_APIC_ID;
734 733 status = hv_do_hypercall(control, input, output);
modified arch/x86/kernel/kvm.c
@@ -265,39 +265,11 @@ noinstr u32 kvm_read_and_reset_apf_flags(void)
265 265 }
266 266 EXPORT_SYMBOL_FOR_KVM(kvm_read_and_reset_apf_flags);
267 267
268 - static __always_inline bool kvm_apf_reason_pending(void)
269 - {
270 - return __this_cpu_read(async_pf_enabled) &&
271 - __this_cpu_read(apf_reason.flags);
272 - }
273 -
274 268 noinstr bool __kvm_handle_async_pf(struct pt_regs *regs, u32 token)
275 269 {
270 + u32 flags = kvm_read_and_reset_apf_flags();
276 271 irqentry_state_t state;
277 - u32 flags;
278 -
279 - if (!kvm_apf_reason_pending())
280 - return false;
281 -
282 - /*
283 - * The guest does not enable KVM_ASYNC_PF_SEND_ALWAYS, so the host
284 - * delivers async #PF only to user mode (or as a #PF VM-exit, which KVM
285 - * reads itself). A #PF from kernel mode can still arrive between that
286 - * delivery and the read of the reason flags, inside an NMI that
287 - * interrupted it, for instance perf reading user memory for a call
288 - * chain. Such a fault is not async, so leave the async PF flags
289 - * untouched for the outer handler. Outside NMI context, on the other
290 - * hand, async PF flags on a kernel-mode fault mean the host is broken.
291 - */
292 - if (!user_mode(regs)) {
293 - if (likely(in_nmi()))
294 - return false;
295 - state = irqentry_enter(regs);
296 - instrumentation_begin();
297 - panic("Host injected async #PF in kernel mode\n");
298 - }
299 272
300 - flags = kvm_read_and_reset_apf_flags();
301 273 if (!flags)
302 274 return false;
303 275
@@ -313,6 +285,8 @@ noinstr bool __kvm_handle_async_pf(struct pt_regs *regs, u32 token)
313 285 panic("Host injected async #PF in interrupt disabled region\n");
314 286
315 287 if (flags & KVM_PV_REASON_PAGE_NOT_PRESENT) {
288 + if (unlikely(!(user_mode(regs))))
289 + panic("Host injected async #PF in kernel mode\n");
316 290 /* Page is swapped out by the host. */
317 291 kvm_async_pf_task_wait_schedule(token);
318 292 } else {
modified arch/x86/kvm/mmu.h
@@ -275,18 +275,8 @@ static inline u8 permission_fault(struct kvm_vcpu *vcpu, struct kvm_pagewalk *w,
275 275 unsigned pte_access, unsigned pte_pkey,
276 276 u64 access)
277 277 {
278 - /*
279 - * Of the error codes that do not contribute to the index in
280 - * fmt->permissions, PK and SS are not supported by shadow paging
281 - * and also not provided to EPT violations, but SS *is* included
282 - * in the NPT exit code. RSVD faults are handled elsewhere.
283 - */
284 - unsigned int pfec = access & ~PFERR_SS_MASK;
285 - if (WARN_ON_ONCE(pfec & ~(PFERR_PRESENT_MASK | PFERR_WRITE_MASK |
286 - PFERR_USER_MASK | PFERR_FETCH_MASK)))
287 - pfec &= (PFERR_PRESENT_MASK | PFERR_WRITE_MASK |
288 - PFERR_USER_MASK | PFERR_FETCH_MASK);
289 -
278 + /* strip nested paging fault error codes */
279 + unsigned int pfec = access;
290 280 unsigned long rflags = kvm_x86_call(get_rflags)(vcpu);
291 281
292 282 /*
@@ -311,6 +301,8 @@ static inline u8 permission_fault(struct kvm_vcpu *vcpu, struct kvm_pagewalk *w,
311 301 kvm_mmu_refresh_passthrough_bits(vcpu, w);
312 302
313 303 fault = (fmt->permissions[index] >> pte_access) & 1;
304 +
305 + WARN_ON_ONCE(pfec & (PFERR_PK_MASK | PFERR_SS_MASK | PFERR_RSVD_MASK));
314 306 if (unlikely(fmt->pkru_mask)) {
315 307 u32 pkru_bits, offset;
316 308
modified arch/x86/kvm/mmu/paging_tmpl.h
@@ -328,6 +328,7 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
328 328 int offset;
329 329 u64 walk_nx_mask = 0;
330 330 const int write_fault = access & PFERR_WRITE_MASK;
331 + const int user_fault = access & PFERR_USER_MASK;
331 332 const int fetch_fault = access & PFERR_FETCH_MASK;
332 333 /*
333 334 * Note! Track the error_code that's common to legacy shadow paging
@@ -485,7 +486,7 @@ retry_walk:
485 486 return 1;
486 487
487 488 error:
488 - errcode |= access & (PFERR_WRITE_MASK | PFERR_USER_MASK | PFERR_SS_MASK);
489 + errcode |= write_fault | user_fault;
489 490 if (fetch_fault && has_pferr_fetch(w))
490 491 errcode |= PFERR_FETCH_MASK;
491 492
modified arch/x86/kvm/svm/avic.c
@@ -395,11 +395,6 @@ static phys_addr_t avic_get_backing_page_address(struct vcpu_svm *svm)
395 395 return __sme_set(__pa(svm->vcpu.arch.apic->regs));
396 396 }
397 397
398 - static bool avic_is_addressable_vcpu(struct kvm_vcpu *vcpu)
399 - {
400 - return vcpu->vcpu_id <= __avic_get_max_physical_id(vcpu->kvm, NULL);
401 - }
402 -
403 398 void avic_init_vmcb(struct vcpu_svm *svm, struct vmcb *vmcb)
404 399 {
405 400 struct kvm_svm *kvm_svm = to_kvm_svm(svm->vcpu.kvm);
@@ -417,6 +412,7 @@ void avic_init_vmcb(struct vcpu_svm *svm, struct vmcb *vmcb)
417 412
418 413 static int avic_init_backing_page(struct kvm_vcpu *vcpu)
419 414 {
415 + u32 max_id = x2avic_enabled ? x2avic_max_physical_id : AVIC_MAX_PHYSICAL_ID;
420 416 struct kvm_svm *kvm_svm = to_kvm_svm(vcpu->kvm);
421 417 struct vcpu_svm *svm = to_svm(vcpu);
422 418 u32 id = vcpu->vcpu_id;
@@ -429,7 +425,7 @@ static int avic_init_backing_page(struct kvm_vcpu *vcpu)
429 425 * avic_vcpu_load() expects to be called if and only if the vCPU has
430 426 * fully initialized AVIC.
431 427 */
432 - if (!avic_is_addressable_vcpu(vcpu)) {
428 + if (id > max_id) {
433 429 kvm_set_apicv_inhibit(vcpu->kvm, APICV_INHIBIT_REASON_PHYSICAL_ID_TOO_BIG);
434 430 vcpu->arch.apic->apicv_active = false;
435 431 return 0;
@@ -889,14 +885,6 @@ int avic_init_vcpu(struct vcpu_svm *svm)
889 885 return ret;
890 886 }
891 887
892 - void avic_vcpu_free(struct kvm_vcpu *vcpu)
893 - {
894 - struct kvm_svm *kvm_svm = to_kvm_svm(vcpu->kvm);
895 -
896 - if (kvm_svm->avic_physical_id_table && avic_is_addressable_vcpu(vcpu))
897 - WRITE_ONCE(kvm_svm->avic_physical_id_table[vcpu->vcpu_id], 0);
898 - }
899 -
900 888 void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu)
901 889 {
902 890 avic_handle_dfr_update(vcpu);
@@ -1057,7 +1045,8 @@ static void __avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu,
1057 1045 if (WARN_ON(h_physical_id & ~AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK))
1058 1046 return;
1059 1047
1060 - if (WARN_ON_ONCE(!avic_is_addressable_vcpu(vcpu)))
1048 + if (WARN_ON_ONCE(vcpu->vcpu_id * sizeof(entry) >=
1049 + PAGE_SIZE << avic_get_physical_id_table_order(vcpu->kvm)))
1061 1050 return;
1062 1051
1063 1052 /*
@@ -1119,7 +1108,8 @@ static void __avic_vcpu_put(struct kvm_vcpu *vcpu, enum avic_vcpu_action action)
1119 1108
1120 1109 lockdep_assert_preemption_disabled();
1121 1110
1122 - if (WARN_ON_ONCE(!avic_is_addressable_vcpu(vcpu)))
1111 + if (WARN_ON_ONCE(vcpu->vcpu_id * sizeof(entry) >=
1112 + PAGE_SIZE << avic_get_physical_id_table_order(vcpu->kvm)))
1123 1113 return;
1124 1114
1125 1115 /*
modified arch/x86/kvm/svm/sev.c
@@ -2421,7 +2421,7 @@ static int sev_gmem_post_populate(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn,
2421 2421 void *dst_vaddr = kmap_local_pfn(pfn);
2422 2422
2423 2423 memcpy(src_vaddr, dst_vaddr, PAGE_SIZE);
2424 - set_page_dirty_lock(src_page);
2424 + set_page_dirty(src_page);
2425 2425
2426 2426 kunmap_local(dst_vaddr);
2427 2427 kunmap_local(src_vaddr);
modified arch/x86/kvm/svm/svm.c
@@ -1328,7 +1328,7 @@ static int svm_vcpu_create(struct kvm_vcpu *vcpu)
1328 1328 svm->msrpm = svm_vcpu_alloc_msrpm();
1329 1329 if (!svm->msrpm) {
1330 1330 err = -ENOMEM;
1331 - goto error_free_avic;
1331 + goto error_free_sev;
1332 1332 }
1333 1333
1334 1334 svm->x2avic_msrs_intercepted = true;
@@ -1342,8 +1342,6 @@ static int svm_vcpu_create(struct kvm_vcpu *vcpu)
1342 1342
1343 1343 return 0;
1344 1344
1345 - error_free_avic:
1346 - avic_vcpu_free(vcpu);
1347 1345 error_free_sev:
1348 1346 sev_free_vcpu(vcpu);
1349 1347 error_free_vmcb_page:
@@ -1358,8 +1356,6 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu)
1358 1356
1359 1357 WARN_ON_ONCE(!list_empty(&svm->ir_list));
1360 1358
1361 - avic_vcpu_free(vcpu);
1362 -
1363 1359 svm_leave_nested(vcpu);
1364 1360 svm_free_nested(svm);
1365 1361
modified arch/x86/kvm/svm/svm.h
@@ -955,7 +955,6 @@ void avic_init_vmcb(struct vcpu_svm *svm, struct vmcb *vmcb);
955 955 int avic_incomplete_ipi_interception(struct kvm_vcpu *vcpu);
956 956 int avic_unaccelerated_access_interception(struct kvm_vcpu *vcpu);
957 957 int avic_init_vcpu(struct vcpu_svm *svm);
958 - void avic_vcpu_free(struct kvm_vcpu *vcpu);
959 958 void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
960 959 void avic_vcpu_put(struct kvm_vcpu *vcpu);
961 960 void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu);
modified arch/x86/kvm/vmx/nested.c
@@ -3770,10 +3770,8 @@ vmentry_fail_vmexit_guest_mode:
3770 3770 vmentry_fail_vmexit:
3771 3771 vmx_switch_vmcs(vcpu, &vmx->vmcs01);
3772 3772
3773 - if (!from_vmentry) {
3774 - nested_ept_uninit_mmu_context(vcpu);
3773 + if (!from_vmentry)
3775 3774 return NVMX_VMENTRY_VMEXIT;
3776 - }
3777 3775
3778 3776 nested_put_vmcs12_pages(vcpu);
3779 3777
modified arch/x86/kvm/x86.h
@@ -250,7 +250,7 @@ static inline bool is_noncanonical_invlpg_address(u64 la, struct kvm_vcpu *vcpu)
250 250 static inline void vcpu_cache_mmio_info(struct kvm_vcpu *vcpu,
251 251 gva_t gva, gfn_t gfn, unsigned access)
252 252 {
253 - u64 gen = kvm_vcpu_memslots(vcpu)->generation;
253 + u64 gen = kvm_memslots(vcpu->kvm)->generation;
254 254
255 255 if (unlikely(gen & KVM_MEMSLOT_GEN_UPDATE_IN_PROGRESS))
256 256 return;
@@ -267,7 +267,7 @@ static inline void vcpu_cache_mmio_info(struct kvm_vcpu *vcpu,
267 267
268 268 static inline bool vcpu_match_mmio_gen(struct kvm_vcpu *vcpu)
269 269 {
270 - return vcpu->arch.mmio_gen == kvm_vcpu_memslots(vcpu)->generation;
270 + return vcpu->arch.mmio_gen == kvm_memslots(vcpu->kvm)->generation;
271 271 }
272 272
273 273 /*
modified drivers/hv/channel.c
@@ -79,7 +79,7 @@ static inline u32 hv_ring_gpadl_send_hvpgoffset(u32 offset)
79 79 * therefore leaving a (PAGE_SIZE - HV_HYP_PAGE_SIZE) gap.
80 80 *
81 81 * And to calculate the effective send offset in gpadl, we need to
82 - * subtract this gap.
82 + * substract this gap.
83 83 */
84 84 return (offset - (PAGE_SIZE - HV_HYP_PAGE_SIZE)) >> HV_HYP_PAGE_SHIFT;
85 85 }
modified drivers/hv/channel_mgmt.c
@@ -752,14 +752,13 @@ static void init_vp_index(struct vmbus_channel *channel)
752 752 u32 i, ncpu = num_online_cpus();
753 753 cpumask_var_t available_mask;
754 754 struct cpumask *allocated_mask;
755 - const struct cpumask *node_mask;
756 755 const struct cpumask *hk_mask = housekeeping_cpumask(HK_TYPE_MANAGED_IRQ);
757 756 u32 target_cpu;
758 757 int numa_node;
759 758
760 759 if (!perf_chn ||
761 760 !alloc_cpumask_var(&available_mask, GFP_KERNEL) ||
762 - !cpumask_intersects(hk_mask, cpu_online_mask)) {
761 + cpumask_empty(hk_mask)) {
763 762 /*
764 763 * If the channel is not a performance critical
765 764 * channel, bind it to VMBUS_CONNECT_CPU.
@@ -781,19 +780,14 @@ static void init_vp_index(struct vmbus_channel *channel)
781 780 next_numa_node_id = 0;
782 781 continue;
783 782 }
784 - /*
785 - * Try next NUMA node if current NUMA node has no CPU
786 - * or doesn't contain any housekeeping CPU.
787 - */
788 - node_mask = cpumask_of_node(numa_node);
789 - if (!cpumask_intersects(node_mask, hk_mask))
783 + if (cpumask_empty(cpumask_of_node(numa_node)))
790 784 continue;
791 785 break;
792 786 }
793 787 allocated_mask = &hv_context.hv_numa_map[numa_node];
794 788
795 789 retry:
796 - cpumask_xor(available_mask, allocated_mask, node_mask);
790 + cpumask_xor(available_mask, allocated_mask, cpumask_of_node(numa_node));
797 791 cpumask_and(available_mask, available_mask, hk_mask);
798 792
799 793 if (cpumask_empty(available_mask)) {
modified drivers/hv/connection.c
@@ -346,6 +346,7 @@ int vmbus_connect(void)
346 346 cleanup:
347 347 pr_err("Unable to connect to host\n");
348 348
349 + vmbus_connection.conn_state = DISCONNECTED;
349 350 vmbus_disconnect();
350 351
351 352 kfree(msginfo);
modified drivers/hv/mshv_vtl_main.c
@@ -819,9 +819,6 @@ static vm_fault_t mshv_vtl_fault(struct vm_fault *vmf)
819 819 return VM_FAULT_NOPAGE;
820 820 }
821 821
822 - if (!page)
823 - return VM_FAULT_SIGBUS;
824 -
825 822 get_page(page);
826 823 vmf->page = page;
827 824
modified drivers/hv/vmbus_drv.c
@@ -2923,19 +2923,23 @@ static void hv_crash_handler(struct pt_regs *regs)
2923 2923 static int hv_synic_suspend(void *data)
2924 2924 {
2925 2925 /*
2926 - * When we reach here, all the non-boot CPUs have been offlined,
2927 - * and their stimers have been cleaned up by the cpuhp teardown
2928 - * callback hv_stimer_cleanup().
2926 + * When we reach here, all the non-boot CPUs have been offlined.
2927 + * If we're in a legacy configuration where stimer Direct Mode is
2928 + * not enabled, the stimers on the non-boot CPUs have been unbound
2929 + * in hv_synic_cleanup() -> hv_stimer_legacy_cleanup() ->
2930 + * hv_stimer_cleanup() -> clockevents_unbind_device().
2929 2931 *
2930 2932 * hv_synic_suspend() only runs on CPU0 with interrupts disabled.
2931 - * The stimer on CPU0 is not explicitly cleaned up here because:
2932 - * 1) it's harmless as interrupts remain disabled between
2933 - * syscore_suspend() and syscore_resume(), so the stimer cannot
2934 - * fire during this window: see create_image() and
2933 + * Here we do not call hv_stimer_legacy_cleanup() on CPU0 because:
2934 + * 1) it's unnecessary as interrupts remain disabled between
2935 + * syscore_suspend() and syscore_resume(): see create_image() and
2935 2936 * resume_target_kernel()
2936 2937 * 2) the stimer on CPU0 is automatically disabled later by
2937 2938 * syscore_suspend() -> timekeeping_suspend() -> tick_suspend() -> ...
2938 2939 * -> clockevents_shutdown() -> ... -> hv_ce_shutdown()
2940 + * 3) a warning would be triggered if we call
2941 + * clockevents_unbind_device(), which may sleep, in an
2942 + * interrupts-disabled context.
2939 2943 */
2940 2944
2941 2945 hv_hyp_synic_disable_regs(0);
@@ -3039,6 +3043,7 @@ static void __exit vmbus_exit(void)
3039 3043
3040 3044 hv_remove_kexec_handler();
3041 3045 hv_remove_crash_handler();
3046 + vmbus_connection.conn_state = DISCONNECTED;
3042 3047 hv_stimer_global_cleanup();
3043 3048 vmbus_disconnect();
3044 3049 if (vmbus_irq == -1)
modified drivers/iommu/amd/amd_iommu_types.h
@@ -421,9 +421,6 @@ struct irq_remap_table {
421 421 u32 *table;
422 422 };
423 423
424 - /* Interrupt remapping feature used? */
425 - extern bool amd_iommu_irq_remap;
426 -
427 424 extern const struct iommu_ops amd_iommu_ops;
428 425
429 426 /* IVRS indicates that pre-boot remapping was enabled */
modified drivers/iommu/amd/init.c
@@ -152,7 +152,7 @@ struct ivmd_header {
152 152 } __attribute__((packed));
153 153
154 154 bool amd_iommu_dump;
155 - bool amd_iommu_irq_remap __read_mostly;
155 + static bool amd_iommu_irq_remap __read_mostly;
156 156
157 157 enum protection_domain_mode amd_iommu_pgtable = PD_MODE_V1;
158 158 /* Virtual address size */
modified drivers/iommu/amd/iommu.c
@@ -3973,9 +3973,6 @@ static int irq_remapping_select(struct irq_domain *d, struct irq_fwspec *fwspec,
3973 3973 struct amd_iommu *iommu;
3974 3974 int devid = -1;
3975 3975
3976 - if (!amd_iommu_irq_remap)
3977 - return 0;
3978 -
3979 3976 if (x86_fwspec_is_ioapic(fwspec))
3980 3977 devid = get_ioapic_devid(fwspec->param[0]);
3981 3978 else if (x86_fwspec_is_hpet(fwspec))
modified drivers/iommu/generic_pt/fmt/Makefile
@@ -25,6 +25,6 @@ $(eval $(foreach fmt,$(iommu_pt_fmt-m),$(call create_format,$(fmt),m)))
25 25 # with -DGENERIC_PT_KUNIT
26 26 $(obj)/kunit_iommu_%.o: $(src)/iommu_%.c FORCE
27 27 $(call rule_mkdir)
28 - $(call if_changed_rule,cc_o_c)
28 + $(call if_changed_dep,cc_o_c)
29 29
30 30 obj-$(CONFIG_IOMMU_PT_KUNIT_TEST) += $(IOMMU_PT_KUNIT_TEST)
modified drivers/net/ethernet/actions/owl-emac.c
@@ -1552,8 +1552,6 @@ static int owl_emac_probe(struct platform_device *pdev)
1552 1552 return ret;
1553 1553 }
1554 1554
1555 - netdev->netdev_ops = &owl_emac_netdev_ops;
1556 -
1557 1555 ret = owl_emac_phy_init(netdev);
1558 1556 if (ret) {
1559 1557 dev_err(dev, "failed to initialize PHY\n");
@@ -1565,6 +1563,7 @@ static int owl_emac_probe(struct platform_device *pdev)
1565 1563 netdev->min_mtu = OWL_EMAC_MTU_MIN;
1566 1564 netdev->max_mtu = OWL_EMAC_MTU_MAX;
1567 1565 netdev->watchdog_timeo = OWL_EMAC_TX_TIMEOUT;
1566 + netdev->netdev_ops = &owl_emac_netdev_ops;
1568 1567 netdev->ethtool_ops = &owl_emac_ethtool_ops;
1569 1568 netif_napi_add(netdev, &priv->napi, owl_emac_poll);
1570 1569
modified drivers/net/ethernet/adi/adin1140.c
@@ -733,8 +733,6 @@ static int adin1140_probe(struct spi_device *spi)
733 733 if (ret)
734 734 return ret;
735 735
736 - netdev->netdev_ops = &adin1140_netdev_ops;
737 -
738 736 ret = adin1140_phy_init(priv, spi);
739 737 if (ret)
740 738 return ret;
@@ -750,6 +748,7 @@ static int adin1140_probe(struct spi_device *spi)
750 748
751 749 netdev->if_port = IF_PORT_10BASET;
752 750 netdev->irq = spi->irq;
751 + netdev->netdev_ops = &adin1140_netdev_ops;
753 752 netdev->ethtool_ops = &adin1140_ethtool_ops;
754 753 netdev->netns_immutable = true;
755 754 netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE |
modified drivers/net/ethernet/aeroflex/greth.c
@@ -1421,8 +1421,6 @@ static int greth_of_probe(struct platform_device *ofdev)
1421 1421 /* Check if MAC can handle MDIO interrupts */
1422 1422 greth->mdio_int_en = (tmp >> 26) & 1;
1423 1423
1424 - dev->netdev_ops = &greth_netdev_ops;
1425 -
1426 1424 err = greth_mdio_init(greth);
1427 1425 if (err) {
1428 1426 if (netif_msg_probe(greth))
@@ -1500,6 +1498,7 @@ static int greth_of_probe(struct platform_device *ofdev)
1500 1498 dev->flags &= ~IFF_MULTICAST;
1501 1499 }
1502 1500
1501 + dev->netdev_ops = &greth_netdev_ops;
1503 1502 dev->ethtool_ops = &greth_ethtool_ops;
1504 1503
1505 1504 err = register_netdev(dev);
modified drivers/net/ethernet/amd/au1000_eth.c
@@ -1225,8 +1225,6 @@ static int au1000_probe(struct platform_device *pdev)
1225 1225 goto err_mdiobus_reg;
1226 1226 }
1227 1227
1228 - dev->netdev_ops = &au1000_netdev_ops;
1229 -
1230 1228 err = au1000_mii_probe(dev);
1231 1229 if (err != 0)
1232 1230 goto err_out;
@@ -1265,6 +1263,7 @@ static int au1000_probe(struct platform_device *pdev)
1265 1263
1266 1264 dev->base_addr = base->start;
1267 1265 dev->irq = irq;
1266 + dev->netdev_ops = &au1000_netdev_ops;
1268 1267 dev->ethtool_ops = &au1000_ethtool_ops;
1269 1268 dev->watchdog_timeo = ETH_TX_TIMEOUT;
1270 1269
modified drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2153,16 +2153,6 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
2153 2153 goto out;
2154 2154 }
2155 2155
2156 - /* We store Tx state in the control block, so the skb must not be
2157 - * shared, but ether_setup() leaves IFF_TX_SKB_SHARING set.
2158 - */
2159 - skb = skb_share_check(skb, GFP_ATOMIC);
2160 - if (!skb) {
2161 - BCMGENET_STATS64_INC((&ring->stats64), dropped);
2162 - ret = NETDEV_TX_OK;
2163 - goto out;
2164 - }
2165 -
2166 2156 /* Retain how many bytes will be sent on the wire, without TSB inserted
2167 2157 * by transmit checksum offload
2168 2158 */
modified drivers/net/ethernet/ethoc.c
@@ -1211,8 +1211,6 @@ static int ethoc_probe(struct platform_device *pdev)
1211 1211 goto free3;
1212 1212 }
1213 1213
1214 - netdev->netdev_ops = &ethoc_netdev_ops;
1215 -
1216 1214 ret = ethoc_mdio_probe(netdev);
1217 1215 if (ret) {
1218 1216 dev_err(&netdev->dev, "failed to probe MDIO bus\n");
@@ -1220,6 +1218,7 @@ static int ethoc_probe(struct platform_device *pdev)
1220 1218 }
1221 1219
1222 1220 /* setup the net_device structure */
1221 + netdev->netdev_ops = &ethoc_netdev_ops;
1223 1222 netdev->watchdog_timeo = ETHOC_TIMEOUT;
1224 1223 netdev->features |= 0;
1225 1224 netdev->ethtool_ops = &ethoc_ethtool_ops;
modified drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -976,8 +976,6 @@ static int hip04_mac_probe(struct platform_device *pdev)
976 976 goto init_fail;
977 977 }
978 978
979 - ndev->netdev_ops = &hip04_netdev_ops;
980 -
981 979 priv->phy_node = of_parse_phandle(node, "phy-handle", 0);
982 980 if (priv->phy_node) {
983 981 priv->phy = of_phy_connect(ndev, priv->phy_node,
@@ -991,6 +989,7 @@ static int hip04_mac_probe(struct platform_device *pdev)
991 989
992 990 INIT_WORK(&priv->tx_timeout_task, hip04_tx_timeout_task);
993 991
992 + ndev->netdev_ops = &hip04_netdev_ops;
994 993 ndev->ethtool_ops = &hip04_ethtool_ops;
995 994 ndev->watchdog_timeo = TX_TIMEOUT;
996 995 ndev->priv_flags |= IFF_UNICAST_FLT;
modified drivers/net/ethernet/hisilicon/hisi_femac.c
@@ -830,8 +830,6 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
830 830 hisi_femac_phy_reset(priv);
831 831 }
832 832
833 - ndev->netdev_ops = &hisi_femac_netdev_ops;
834 -
835 833 phy = of_phy_get_and_connect(ndev, node, hisi_femac_adjust_link);
836 834 if (!phy) {
837 835 dev_err(dev, "connect to PHY failed!\n");
@@ -852,6 +850,7 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
852 850
853 851 ndev->watchdog_timeo = 6 * HZ;
854 852 ndev->priv_flags |= IFF_UNICAST_FLT;
853 + ndev->netdev_ops = &hisi_femac_netdev_ops;
855 854 ndev->ethtool_ops = &hisi_femac_ethtools_ops;
856 855 netif_napi_add_weight(ndev, &priv->napi, hisi_femac_poll,
857 856 FEMAC_POLL_WEIGHT);
modified drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -3171,8 +3171,6 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
3171 3171 netif_set_real_num_tx_queues(dev, mp->txq_count);
3172 3172 netif_set_real_num_rx_queues(dev, mp->rxq_count);
3173 3173
3174 - dev->netdev_ops = &mv643xx_eth_netdev_ops;
3175 -
3176 3174 err = 0;
3177 3175 if (pd->phy_node) {
3178 3176 phydev = of_phy_connect(mp->dev, pd->phy_node,
@@ -3223,6 +3221,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
3223 3221 }
3224 3222 dev->irq = irq;
3225 3223
3224 + dev->netdev_ops = &mv643xx_eth_netdev_ops;
3225 +
3226 3226 dev->watchdog_timeo = 2 * HZ;
3227 3227 dev->base_addr = 0;
3228 3228
modified drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
@@ -928,7 +928,6 @@ static int mlx5_fs_fte_get_hws_actions(struct mlx5_flow_root_namespace *ns,
928 928 goto free_actions;
929 929 }
930 930 (*ractions)[num_actions].aso_meter.offset =
931 - (fte_action->exe_aso.object_id - fte_action->exe_aso.base_id) * 2 +
932 931 fte_action->exe_aso.flow_meter.meter_idx;
933 932 (*ractions)[num_actions].aso_meter.init_color =
934 933 fte_action->exe_aso.flow_meter.init_color;
@@ -1399,8 +1398,8 @@ static void mlx5_cmd_hws_packet_reformat_dealloc(struct mlx5_flow_root_namespace
1399 1398 pr_data->data_size);
1400 1399 break;
1401 1400 case MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL:
1402 - pr_pool = mlx5_fs_get_pr_encap_pool(dev, &hws_pool->el2tol3tnl_pools,
1403 - MLX5HWS_ACTION_TYP_REFORMAT_L2_TO_TNL_L3,
1401 + pr_pool = mlx5_fs_get_pr_encap_pool(dev, &hws_pool->el2tol2tnl_pools,
1402 + MLX5HWS_ACTION_TYP_REFORMAT_L2_TO_TNL_L2,
1404 1403 pr_data->data_size);
1405 1404 break;
1406 1405 case MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2:
modified drivers/net/ethernet/microchip/lan865x/lan865x.c
@@ -346,8 +346,6 @@ static int lan865x_probe(struct spi_device *spi)
346 346 spi_set_drvdata(spi, priv);
347 347 INIT_WORK(&priv->multicast_work, lan865x_multicast_work_handler);
348 348
349 - netdev->netdev_ops = &lan865x_netdev_ops;
350 -
351 349 priv->tc6 = oa_tc6_init(spi, netdev, NULL);
352 350 if (!priv->tc6) {
353 351 ret = -ENODEV;
@@ -399,6 +397,7 @@ static int lan865x_probe(struct spi_device *spi)
399 397
400 398 netdev->if_port = IF_PORT_10BASET;
401 399 netdev->irq = spi->irq;
400 + netdev->netdev_ops = &lan865x_netdev_ops;
402 401 netdev->ethtool_ops = &lan865x_ethtool_ops;
403 402
404 403 ret = register_netdev(netdev);
modified drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -312,12 +312,6 @@ static int dwmac1000_irq_status(struct stmmac_priv *priv,
312 312 if (intr_status & (PCS_ANE_IRQ | PCS_LINK_IRQ))
313 313 stmmac_integrated_pcs_irq(priv, intr_status, x);
314 314
315 - /* Reading RGSMIIIS clears the interrupt the MAC reset unmasks. */
316 - if (intr_status & PCS_RGSMIIIS_IRQ) {
317 - readl(ioaddr + GMAC_RGSMIIIS);
318 - x->irq_rgmii_n++;
319 - }
320 -
321 315 return ret;
322 316 }
323 317
modified drivers/net/ethernet/ti/icssm/icssm_prueth.c
@@ -1563,8 +1563,6 @@ static int icssm_prueth_netdev_init(struct prueth *prueth,
1563 1563 }
1564 1564 ether_addr_copy(emac->mac_addr, ndev->dev_addr);
1565 1565
1566 - ndev->netdev_ops = &emac_netdev_ops;
1567 -
1568 1566 /* connect PHY */
1569 1567 emac->phydev = of_phy_get_and_connect(ndev, eth_node,
1570 1568 icssm_emac_adjust_link);
@@ -1592,6 +1590,7 @@ static int icssm_prueth_netdev_init(struct prueth *prueth,
1592 1590 }
1593 1591
1594 1592 ndev->dev.of_node = eth_node;
1593 + ndev->netdev_ops = &emac_netdev_ops;
1595 1594
1596 1595 netif_napi_add(ndev, &emac->napi, icssm_emac_napi_poll);
1597 1596
modified drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -421,9 +421,23 @@ static void rockchip_pcie_stop_link(struct dw_pcie *pci)
421 421 static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
422 422 {
423 423 struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
424 + struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
425 + struct device *dev = rockchip->pci.dev;
426 + int irq, ret;
427 +
428 + irq = of_irq_get_byname(dev->of_node, "legacy");
429 + if (irq < 0)
430 + return irq;
424 431
425 432 pci->dbi_base2 = pci->dbi_base + PCIE_TYPE0_HDR_DBI2_OFFSET;
426 433
434 + ret = rockchip_pcie_init_irq_domain(rockchip);
435 + if (ret < 0)
436 + dev_err(dev, "failed to init irq domain\n");
437 +
438 + irq_set_chained_handler_and_data(irq, rockchip_pcie_intx_handler,
439 + rockchip);
440 +
427 441 rockchip_pcie_configure_l1ss(pci);
428 442 rockchip_pcie_enable_l0s(pci);
429 443 pp->bridge->reset_root_port = rockchip_pcie_rc_reset_root_port;
@@ -716,19 +730,6 @@ static int rockchip_pcie_configure_rc(struct platform_device *pdev,
716 730 PCIE_CLIENT_SET_MODE(PCIE_CLIENT_MODE_RC),
717 731 PCIE_CLIENT_GENERAL_CON);
718 732
719 - irq = of_irq_get_byname(dev->of_node, "legacy");
720 - if (irq < 0)
721 - return irq;
722 -
723 - ret = rockchip_pcie_init_irq_domain(rockchip);
724 - if (ret < 0) {
725 - dev_err(dev, "failed to init irq domain\n");
726 - return ret;
727 - }
728 -
729 - irq_set_chained_handler_and_data(irq, rockchip_pcie_intx_handler,
730 - rockchip);
731 -
732 733 pp = &rockchip->pci.pp;
733 734 pp->ops = &rockchip_pcie_host_ops;
734 735
modified drivers/pci/controller/pci-hyperv.c
@@ -1040,38 +1040,19 @@ static void put_pcichild(struct hv_pci_dev *hpdev)
1040 1040
1041 1041 /*
1042 1042 * There is no good way to get notified from vmbus_onoffer_rescind(),
1043 - * so let's use polling here, since this is not a hot path. If
1044 - * wait_for_response() has been polling for 2 minutes
1045 - * without either a rescind or completion, add a warning.
1043 + * so let's use polling here, since this is not a hot path.
1046 1044 */
1047 - #define PCI_RESPONSE_WARN_POLL_COUNT 1200
1048 -
1049 1045 static int wait_for_response(struct hv_device *hdev,
1050 - struct completion *comp,
1051 - const char *msg_type)
1046 + struct completion *comp)
1052 1047 {
1053 - u64 counter = 0;
1054 -
1055 1048 while (true) {
1056 1049 if (hdev->channel->rescind) {
1057 1050 dev_warn_once(&hdev->device, "The device is gone.\n");
1058 1051 return -ENODEV;
1059 1052 }
1060 1053
1061 - counter++;
1062 -
1063 - if (wait_for_completion_timeout(comp, HZ / 10)) {
1064 - if (counter > PCI_RESPONSE_WARN_POLL_COUNT)
1065 - dev_warn(&hdev->device,
1066 - "Late %s completion arrived.\n", msg_type);
1054 + if (wait_for_completion_timeout(comp, HZ / 10))
1067 1055 break;
1068 - }
1069 -
1070 - if (counter == PCI_RESPONSE_WARN_POLL_COUNT) {
1071 - dev_err(&hdev->device,
1072 - "%s stuck waiting for response, relid = %u\n",
1073 - msg_type, hdev->channel->offermsg.child_relid);
1074 - }
1075 1056 }
1076 1057
1077 1058 return 0;
@@ -1537,8 +1518,7 @@ static int hv_read_config_block(struct pci_dev *pdev, void *buf,
1537 1518 if (ret)
1538 1519 return ret;
1539 1520
1540 - ret = wait_for_response(hbus->hdev, &comp_pkt.comp_pkt.host_event,
1541 - "PCI_READ_BLOCK");
1521 + ret = wait_for_response(hbus->hdev, &comp_pkt.comp_pkt.host_event);
1542 1522 if (ret)
1543 1523 return ret;
1544 1524
@@ -1627,8 +1607,7 @@ static int hv_write_config_block(struct pci_dev *pdev, void *buf,
1627 1607 if (ret)
1628 1608 return ret;
1629 1609
1630 - ret = wait_for_response(hbus->hdev, &comp_pkt.host_event,
1631 - "PCI_WRITE_BLOCK");
1610 + ret = wait_for_response(hbus->hdev, &comp_pkt.host_event);
1632 1611 if (ret)
1633 1612 return ret;
1634 1613
@@ -2645,8 +2624,7 @@ static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus,
2645 2624 if (ret)
2646 2625 goto error;
2647 2626
2648 - if (wait_for_response(hbus->hdev, &comp_pkt.host_event,
2649 - "PCI_QUERY_RESOURCE_REQUIREMENTS"))
2627 + if (wait_for_response(hbus->hdev, &comp_pkt.host_event))
2650 2628 goto error;
2651 2629
2652 2630 hpdev->desc = *desc;
@@ -3278,8 +3256,7 @@ static int hv_pci_protocol_negotiation(struct hv_device *hdev,
3278 3256 (unsigned long)pkt, VM_PKT_DATA_INBAND,
3279 3257 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
3280 3258 if (!ret)
3281 - ret = wait_for_response(hdev, &comp_pkt.host_event,
3282 - "PCI_QUERY_PROTOCOL_VERSION");
3259 + ret = wait_for_response(hdev, &comp_pkt.host_event);
3283 3260
3284 3261 if (ret) {
3285 3262 dev_err(&hdev->device,
@@ -3499,8 +3476,7 @@ enter_d0_retry:
3499 3476 (unsigned long)pkt, VM_PKT_DATA_INBAND,
3500 3477 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
3501 3478 if (!ret)
3502 - ret = wait_for_response(hdev, &comp_pkt.host_event,
3503 - "PCI_BUS_D0ENTRY");
3479 + ret = wait_for_response(hdev, &comp_pkt.host_event);
3504 3480
3505 3481 if (ret)
3506 3482 goto exit;
@@ -3577,8 +3553,7 @@ static int hv_pci_query_relations(struct hv_device *hdev)
3577 3553 ret = vmbus_sendpacket(hdev->channel, &message, sizeof(message),
3578 3554 0, VM_PKT_DATA_INBAND, 0);
3579 3555 if (!ret)
3580 - ret = wait_for_response(hdev, &comp,
3581 - "PCI_QUERY_BUS_RELATIONS");
3556 + ret = wait_for_response(hdev, &comp);
3582 3557
3583 3558 /*
3584 3559 * In the case of fast device addition/removal, it's possible that
@@ -3669,8 +3644,7 @@ static int hv_send_resources_allocated(struct hv_device *hdev)
3669 3644 VM_PKT_DATA_INBAND,
3670 3645 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
3671 3646 if (!ret)
3672 - ret = wait_for_response(hdev, &comp_pkt.host_event,
3673 - "PCI_RESOURCE_ASSIGNED");
3647 + ret = wait_for_response(hdev, &comp_pkt.host_event);
3674 3648 if (ret)
3675 3649 break;
3676 3650
@@ -4181,9 +4155,6 @@ static struct hv_driver hv_pci_drv = {
4181 4155 .remove = hv_pci_remove,
4182 4156 .suspend = hv_pci_suspend,
4183 4157 .resume = hv_pci_resume,
4184 - .driver = {
4185 - .probe_type = PROBE_PREFER_ASYNCHRONOUS,
4186 - },
4187 4158 };
4188 4159
4189 4160 static void __exit exit_hv_pci_drv(void)
modified drivers/pci/pcie/aer.c
@@ -428,8 +428,7 @@ void pci_aer_init(struct pci_dev *dev)
428 428 * Advisory Non-Fatal Errors are masked by default (PCIe r7.0, sec
429 429 * 7.8.4.6).
430 430 */
431 - if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER &&
432 - !dev->no_aer_anfe)
431 + if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER)
433 432 pci_clear_and_set_config_dword(dev,
434 433 dev->aer_cap + PCI_ERR_COR_MASK,
435 434 PCI_ERR_COR_ADV_NFAT, 0);
modified drivers/pci/quirks.c
@@ -2574,17 +2574,6 @@ static void quirk_p64h2_1k_io(struct pci_dev *dev)
2574 2574 }
2575 2575 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1460, quirk_p64h2_1k_io);
2576 2576
2577 - /*
2578 - * Unmasking Advisory Non-Fatal Errors on the Apple T2 Secure Enclave
2579 - * causes a MacBookPro16,1 to lose power. Set this before pci_aer_init()
2580 - * so that it leaves the ANFE mask bit unchanged.
2581 - */
2582 - static void quirk_no_aer_anfe(struct pci_dev *dev)
2583 - {
2584 - dev->no_aer_anfe = 1;
2585 - }
2586 - DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_APPLE, 0x1802, quirk_no_aer_anfe);
2587 -
2588 2577 /*
2589 2578 * Under some circumstances, AER is not linked with extended capabilities.
2590 2579 * Force it to be linked by setting the corresponding control bit in the
modified drivers/power/supply/ds2780_battery.c
@@ -304,7 +304,7 @@ static int ds2780_get_capacity(struct ds2780_device_info *dev_info,
304 304 return ret;
305 305
306 306 *capacity = raw;
307 - return 0;
307 + return raw;
308 308 }
309 309
310 310 static int ds2780_get_status(struct ds2780_device_info *dev_info, int *status)
modified drivers/power/supply/generic-adc-battery.c
@@ -90,17 +90,12 @@ static int gab_read_channel(struct gab *adc_bat, enum gab_chan_type channel,
90 90 int ret;
91 91
92 92 ret = iio_read_channel_processed(adc_bat->channel[channel], result);
93 - if (ret < 0) {
93 + if (ret < 0)
94 94 dev_err(&adc_bat->psy->dev, "read channel error: %d\n", ret);
95 - return ret;
96 - }
97 -
98 - if (channel == GAB_TEMP)
99 - *result /= 100; /* Convert from milli- to deci-degree */
100 95 else
101 96 *result *= 1000;
102 97
103 - return 0;
98 + return ret;
104 99 }
105 100
106 101 static int gab_get_property(struct power_supply *psy,
modified drivers/power/supply/max17042_battery.c
@@ -1233,7 +1233,7 @@ static int max17042_parse_dt(struct max17042_chip *chip)
1233 1233 if (of_property_read_u32(np, "maxim,over-volt", &prop))
1234 1234 chip->vmax = INT_MAX;
1235 1235 else
1236 - chip->vmax = prop;
1236 + chip->vmin = prop;
1237 1237
1238 1238 return 0;
1239 1239 }
modified drivers/power/supply/power_supply_core.c
@@ -1530,19 +1530,6 @@ void power_supply_external_power_changed(struct power_supply *psy)
1530 1530 !psy->desc->external_power_changed)
1531 1531 return;
1532 1532
1533 - /*
1534 - * Keep power_supply_unregister() from returning, and thus from letting
1535 - * the driver's data be freed, while the callback is running. The
1536 - * ->removing check has to happen under the lock: on its own, just like
1537 - * the use_cnt check above, it only tells us the supply was still there
1538 - * when we looked, not that it still is by the time the callback
1539 - * dereferences its driver data.
1540 - */
1541 - guard(rwsem_read)(&psy->epc_sem);
1542 -
1543 - if (psy->removing)
1544 - return;
1545 -
1546 1533 psy->desc->external_power_changed(psy);
1547 1534 }
1548 1535 EXPORT_SYMBOL_GPL(power_supply_external_power_changed);
@@ -1787,7 +1774,6 @@ __power_supply_register(struct device *parent,
1787 1774 }
1788 1775
1789 1776 spin_lock_init(&psy->changed_lock);
1790 - init_rwsem(&psy->epc_sem);
1791 1777 init_rwsem(&psy->extensions_sem);
1792 1778 INIT_LIST_HEAD(&psy->extensions);
1793 1779
@@ -1928,17 +1914,7 @@ EXPORT_SYMBOL_GPL(devm_power_supply_register);
1928 1914 void power_supply_unregister(struct power_supply *psy)
1929 1915 {
1930 1916 WARN_ON(atomic_dec_return(&psy->use_cnt));
1931 -
1932 - /*
1933 - * Publish ->removing so that no new ->external_power_changed() call can
1934 - * start, and wait via semaphore for one that is already running: it may
1935 - * be a supplier's changed_work, which cancel_work_sync() below does not
1936 - * cover, and it may still dereference driver data that the caller is
1937 - * about to free.
1938 - */
1939 - scoped_guard(rwsem_write, &psy->epc_sem)
1940 - psy->removing = true;
1941 -
1917 + psy->removing = true;
1942 1918 cancel_work_sync(&psy->changed_work);
1943 1919 cancel_delayed_work_sync(&psy->deferred_register_work);
1944 1920 sysfs_remove_link(&psy->dev.kobj, "powers");
modified drivers/soc/tegra/fuse/tegra-apbmisc.c
@@ -309,7 +309,7 @@ void tegra_acpi_init_apbmisc(void)
309 309
310 310 ret = acpi_dev_get_memory_resources(adev, &resource_list);
311 311 if (ret < 0) {
312 - pr_err("failed to get APBMISC memory resources\n");
312 + pr_err("failed to get APBMISC memory resources");
313 313 goto out_put_acpi_dev;
314 314 }
315 315
modified drivers/soc/tegra/pmc.c
@@ -3151,7 +3151,6 @@ static int tegra_pmc_probe(struct platform_device *pdev)
3151 3151
3152 3152 #if defined(CONFIG_ARM)
3153 3153 mutex_lock(&early_pmc->powergates_lock);
3154 - early_pmc->rate = pmc->rate;
3155 3154 iounmap(early_pmc->base);
3156 3155 early_pmc->base = pmc->base;
3157 3156 mutex_unlock(&early_pmc->powergates_lock);
modified fs/9p/v9fs.h
@@ -137,6 +137,7 @@ struct v9fs_session_info {
137 137 struct list_head slist; /* list of sessions registered with v9fs */
138 138 struct rw_semaphore rename_sem;
139 139 long session_lock_timeout; /* retry interval for blocking locks */
140 + struct rcu_head rcu; /* v9fs_vfs_get_link_dotl() reads ->cache in rcu pathwalk */
140 141 };
141 142
142 143 #define NDENTRY_TIMEOUT_NEVER (-1U)
modified fs/9p/vfs_super.c
@@ -173,8 +173,8 @@ static void v9fs_kill_super(struct super_block *s)
173 173
174 174 v9fs_session_cancel(v9ses);
175 175 v9fs_session_close(v9ses);
176 - kfree(v9ses);
177 - s->s_fs_info = NULL;
176 + /* v9fs_vfs_get_link_dotl() may still read ->cache in rcu pathwalk */
177 + kfree_rcu(v9ses, rcu);
178 178 p9_debug(P9_DEBUG_VFS, "exiting kill_super\n");
179 179 }
180 180
modified fs/afs/internal.h
@@ -251,6 +251,8 @@ struct afs_super_info {
251 251 struct afs_volume *volume; /* volume record */
252 252 enum afs_flock_mode flock_mode:8; /* File locking emulation mode */
253 253 bool dyn_root; /* True if dynamic root */
254 + /* afs_atcell_get_link() reads ->net_ns in rcu pathwalk */
255 + struct rcu_head rcu;
254 256 };
255 257
256 258 static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
modified fs/afs/super.c
@@ -523,7 +523,7 @@ static void afs_destroy_sbi(struct afs_super_info *as)
523 523 afs_put_volume(as->volume, afs_volume_trace_put_destroy_sbi);
524 524 afs_unuse_cell(as->cell, afs_cell_trace_unuse_sbi);
525 525 put_net(as->net_ns);
526 - kfree(as);
526 + kfree_rcu(as, rcu);
527 527 }
528 528 }
529 529
modified fs/autofs/waitq.c
@@ -12,15 +12,13 @@
12 12 */
13 13 static autofs_wqt_t autofs_next_wait_queue = 1;
14 14
15 - void autofs_catatonic_mode(struct autofs_sb_info *sbi)
15 + static void autofs_catatonic_mode_locked(struct autofs_sb_info *sbi)
16 16 {
17 17 struct autofs_wait_queue *wq, *nwq;
18 18
19 - mutex_lock(&sbi->wq_mutex);
20 - if (sbi->flags & AUTOFS_SBI_CATATONIC) {
21 - mutex_unlock(&sbi->wq_mutex);
19 + lockdep_assert_held(&sbi->wq_mutex);
20 + if (sbi->flags & AUTOFS_SBI_CATATONIC)
22 21 return;
23 - }
24 22
25 23 pr_debug("entering catatonic mode\n");
26 24
@@ -40,6 +38,21 @@ void autofs_catatonic_mode(struct autofs_sb_info *sbi)
40 38 fput(sbi->pipe); /* Close the pipe */
41 39 sbi->pipe = NULL;
42 40 sbi->pipefd = -1;
41 + }
42 +
43 + void autofs_catatonic_mode(struct autofs_sb_info *sbi)
44 + {
45 + mutex_lock(&sbi->wq_mutex);
46 + autofs_catatonic_mode_locked(sbi);
47 + mutex_unlock(&sbi->wq_mutex);
48 + }
49 +
50 + static void autofs_catatonic_mode_for_pipe(struct autofs_sb_info *sbi,
51 + struct file *pipe)
52 + {
53 + mutex_lock(&sbi->wq_mutex);
54 + if (sbi->pipe == pipe)
55 + autofs_catatonic_mode_locked(sbi);
43 56 mutex_unlock(&sbi->wq_mutex);
44 57 }
45 58
@@ -170,7 +183,7 @@ static void autofs_notify_daemon(struct autofs_sb_info *sbi,
170 183 autofs_wait_release(sbi, wq->wait_queue_token, ret);
171 184 break;
172 185 default:
173 - autofs_catatonic_mode(sbi);
186 + autofs_catatonic_mode_for_pipe(sbi, pipe);
174 187 break;
175 188 }
176 189 fput(pipe);
modified fs/ext4/ext4.h
@@ -1774,6 +1774,8 @@ struct ext4_sb_info {
1774 1774 struct list_head s_es_list; /* List of inodes with reclaimable extents */
1775 1775 long s_es_nr_inode;
1776 1776 struct ext4_es_stats s_es_stats;
1777 + /* ext4_get_link() reads the sbi in rcu pathwalk */
1778 + struct rcu_head s_rcu;
1777 1779 struct mb_cache *s_ea_block_cache;
1778 1780 struct mb_cache *s_ea_inode_cache;
1779 1781
modified fs/ext4/extents-test.c
@@ -151,6 +151,7 @@ static void extents_kunit_exit(struct kunit *test)
151 151
152 152 sbi = k_ctx.k_ei->vfs_inode.i_sb->s_fs_info;
153 153 ext4_es_unregister_shrinker(sbi);
154 + ext4_es_destroy_stats(sbi);
154 155 deactivate_super(sbi->s_sb);
155 156 kfree(sbi);
156 157 kfree(k_ctx.k_ei);
@@ -340,6 +341,7 @@ out:
340 341 k_ctx.k_data = NULL;
341 342
342 343 ext4_es_unregister_shrinker(sbi);
344 + ext4_es_destroy_stats(sbi);
343 345 out_deactivate:
344 346 deactivate_locked_super(sb);
345 347 kfree(sbi);
modified fs/ext4/extents.c
@@ -6409,6 +6409,7 @@ EXPORT_SYMBOL_FOR_EXT4_TEST(__ext4_ext_dirty);
6409 6409 EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_zeroout);
6410 6410 EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_register_shrinker);
6411 6411 EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_unregister_shrinker);
6412 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_destroy_stats);
6412 6413 EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_map_create_blocks);
6413 6414 EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_init_tree);
6414 6415 EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_lookup_extent);
modified fs/ext4/extents_status.c
@@ -1881,12 +1881,17 @@ err1:
1881 1881 }
1882 1882
1883 1883 void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi)
1884 + {
1885 + shrinker_free(sbi->s_es_shrinker);
1886 + }
1887 +
1888 + /* ext4_get_link() bumps the hit and miss counters in rcu pathwalk */
1889 + void ext4_es_destroy_stats(struct ext4_sb_info *sbi)
1884 1890 {
1885 1891 percpu_counter_destroy(&sbi->s_es_stats.es_stats_cache_hits);
1886 1892 percpu_counter_destroy(&sbi->s_es_stats.es_stats_cache_misses);
1887 1893 percpu_counter_destroy(&sbi->s_es_stats.es_stats_all_cnt);
1888 1894 percpu_counter_destroy(&sbi->s_es_stats.es_stats_shk_cnt);
1889 - shrinker_free(sbi->s_es_shrinker);
1890 1895 }
1891 1896
1892 1897 /*
modified fs/ext4/extents_status.h
@@ -238,6 +238,7 @@ static inline void ext4_es_store_pblock_status(struct extent_status *es,
238 238
239 239 extern int ext4_es_register_shrinker(struct ext4_sb_info *sbi);
240 240 extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi);
241 + extern void ext4_es_destroy_stats(struct ext4_sb_info *sbi);
241 242
242 243 extern int ext4_seq_es_shrinker_info_show(struct seq_file *seq, void *v);
243 244
modified fs/ext4/super.c
@@ -1279,6 +1279,14 @@ static void ext4_flex_groups_free(struct ext4_sb_info *sbi)
1279 1279 }
1280 1280 }
1281 1281
1282 + static void ext4_put_sbi_rcu(struct rcu_head *head)
1283 + {
1284 + struct ext4_sb_info *sbi = container_of(head, struct ext4_sb_info, s_rcu);
1285 +
1286 + ext4_es_destroy_stats(sbi);
1287 + kfree(sbi);
1288 + }
1289 +
1282 1290 static void ext4_put_super(struct super_block *sb)
1283 1291 {
1284 1292 struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -1374,7 +1382,6 @@ static void ext4_put_super(struct super_block *sb)
1374 1382 ext4_stop_mmpd(sbi);
1375 1383
1376 1384 brelse(sbi->s_sbh);
1377 - sb->s_fs_info = NULL;
1378 1385 /*
1379 1386 * Now that we are completely done shutting down the
1380 1387 * superblock, we need to actually destroy the kobject.
@@ -1387,7 +1394,8 @@ static void ext4_put_super(struct super_block *sb)
1387 1394 #if IS_ENABLED(CONFIG_UNICODE)
1388 1395 utf8_unload(sb->s_encoding);
1389 1396 #endif
1390 - kfree(sbi);
1397 + /* ext4_get_link() reads the sbi and the counters in rcu pathwalk */
1398 + call_rcu(&sbi->s_rcu, ext4_put_sbi_rcu);
1391 1399 }
1392 1400
1393 1401 static struct kmem_cache *ext4_inode_cachep;
@@ -5806,6 +5814,7 @@ failed_mount3a:
5806 5814 /* Drain deferred EA inode iputs from journal replay */
5807 5815 flush_delayed_work(&sbi->s_ea_inode_work);
5808 5816 ext4_es_unregister_shrinker(sbi);
5817 + ext4_es_destroy_stats(sbi);
5809 5818 failed_mount3:
5810 5819 /* flush s_sb_upd_work before sbi destroy */
5811 5820 flush_work(&sbi->s_sb_upd_work);
modified fs/namespace.c
@@ -297,7 +297,11 @@ int mnt_get_count(struct mount *mnt)
297 297 /* puts first, so a put counted here has its get counted below */
298 298 for_each_possible_cpu(cpu)
299 299 puts += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_puts;
300 - smp_mb(); /* pairs with the smp_wmb() in mntput_no_expire() */
300 + /*
301 + * Pairs with the smp_wmb() in mntput_no_expire() and with the
302 + * smp_mb() in __legitimize_mnt().
303 + */
304 + smp_mb();
301 305 for_each_possible_cpu(cpu)
302 306 gets += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_gets;
303 307
@@ -782,7 +786,7 @@ int __legitimize_mnt(struct vfsmount *bastard, unsigned seq)
782 786 return 0;
783 787 mnt = real_mount(bastard);
784 788 mnt_inc_count(mnt);
785 - smp_mb(); /* see mntput_no_expire_slowpath() and do_umount() */
789 + smp_mb(); /* pairs with the smp_mb() in mnt_get_count() */
786 790 if (likely(!read_seqretry(&mount_lock, seq)))
787 791 return 0;
788 792 lock_mount_hash();
@@ -1419,11 +1423,6 @@ static void noinline mntput_no_expire_slowpath(struct mount *mnt)
1419 1423
1420 1424 VFS_BUG_ON(mnt->mnt_ns);
1421 1425 lock_mount_hash();
1422 - /*
1423 - * make sure that if __legitimize_mnt() has not seen us grab
1424 - * mount_lock, we'll see their refcount increment here.
1425 - */
1426 - smp_mb();
1427 1426 mnt_dec_count(mnt);
1428 1427 count = mnt_get_count(mnt);
1429 1428 if (count != 0) {
@@ -2006,7 +2005,6 @@ static int do_umount(struct mount *mnt, int flags)
2006 2005 umount_tree(mnt, UMOUNT_PROPAGATE);
2007 2006 retval = 0;
2008 2007 } else {
2009 - smp_mb(); // paired with __legitimize_mnt()
2010 2008 shrink_submounts(mnt);
2011 2009 retval = -EBUSY;
2012 2010 if (!propagate_mount_busy(mnt, 2)) {
modified fs/ntfs3/dir.c
@@ -186,11 +186,20 @@ int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len,
186 186 {
187 187 int ret, slen, i;
188 188 const u8 *end;
189 - struct nls_table *nls = sbi->options->nls;
189 + struct ntfs_mount_options *opts;
190 + struct nls_table *nls;
191 + bool ads;
190 192 u16 *uname = uni->name;
191 193
192 194 static_assert(sizeof(wchar_t) == sizeof(u16));
193 195
196 + /* ntfs_fs_reconfigure() may replace the options, but not ->nls */
197 + rcu_read_lock();
198 + opts = READ_ONCE(sbi->options);
199 + nls = opts->nls;
200 + ads = opts->ads;
201 + rcu_read_unlock();
202 +
194 203 if (!nls) {
195 204 /* utf8 -> utf16 */
196 205 ret = _utf8s_to_utf16s(name, name_len, endian, uname, max_ulen);
@@ -230,7 +239,7 @@ int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len,
230 239
231 240 uni->len = ret;
232 241 uni->ads_len = 0;
233 - if (ret > 0 && sbi->options->ads) {
242 + if (ret > 0 && ads) {
234 243 uname = uni->name;
235 244 /* Find delimiter in range [1 : ret-2). */
236 245 for (i = 1; i + 1 < ret; i++) {
modified fs/ntfs3/ntfs_fs.h
@@ -91,6 +91,8 @@ enum utf16_endian;
91 91 struct ntfs_mount_options {
92 92 char *nls_name;
93 93 struct nls_table *nls;
94 + /* ->d_hash() and ->d_compare() read the options in rcu pathwalk */
95 + struct rcu_head rcu;
94 96
95 97 kuid_t fs_uid;
96 98 kgid_t fs_gid;
@@ -211,6 +213,7 @@ struct ntfs_index {
211 213 /* Ntfs file system in-core superblock data. */
212 214 struct ntfs_sb_info {
213 215 struct super_block *sb;
216 + struct rcu_head rcu;
214 217
215 218 u32 discard_granularity;
216 219 u64 discard_granularity_mask_inv; // ~(discard_granularity_mask_inv-1)
modified fs/ntfs3/super.c
@@ -196,7 +196,7 @@ void *ntfs_set_shared(void *ptr, u32 bytes)
196 196 void *ret = NULL;
197 197 int i, j = -1;
198 198
199 - spin_lock(&s_shared_lock);
199 + spin_lock_bh(&s_shared_lock);
200 200 for (i = 0; i < ARRAY_SIZE(s_shared); i++) {
201 201 if (!s_shared[i].cnt) {
202 202 j = i;
@@ -214,7 +214,7 @@ void *ntfs_set_shared(void *ptr, u32 bytes)
214 214 s_shared[j].cnt = 1;
215 215 ret = ptr;
216 216 }
217 - spin_unlock(&s_shared_lock);
217 + spin_unlock_bh(&s_shared_lock);
218 218
219 219 return ret;
220 220 }
@@ -231,7 +231,7 @@ void *ntfs_put_shared(void *ptr)
231 231 void *ret = ptr;
232 232 int i;
233 233
234 - spin_lock(&s_shared_lock);
234 + spin_lock_bh(&s_shared_lock);
235 235 for (i = 0; i < ARRAY_SIZE(s_shared); i++) {
236 236 if (s_shared[i].cnt && s_shared[i].ptr == ptr) {
237 237 if (--s_shared[i].cnt)
@@ -239,7 +239,7 @@ void *ntfs_put_shared(void *ptr)
239 239 break;
240 240 }
241 241 }
242 - spin_unlock(&s_shared_lock);
242 + spin_unlock_bh(&s_shared_lock);
243 243
244 244 return ret;
245 245 }
@@ -251,6 +251,11 @@ static inline void put_mount_options(struct ntfs_mount_options *options)
251 251 kfree(options);
252 252 }
253 253
254 + static void put_mount_options_rcu(struct rcu_head *head)
255 + {
256 + put_mount_options(container_of(head, struct ntfs_mount_options, rcu));
257 + }
258 +
254 259 enum Opt {
255 260 Opt_uid,
256 261 Opt_gid,
@@ -444,6 +449,7 @@ static int ntfs_fs_reconfigure(struct fs_context *fc)
444 449 struct super_block *sb = fc->root->d_sb;
445 450 struct ntfs_sb_info *sbi = sb->s_fs_info;
446 451 struct ntfs_mount_options *new_opts = fc->fs_private;
452 + struct ntfs_mount_options *old_opts;
447 453 int ro_rw;
448 454
449 455 ro_rw = sb_rdonly(sb) && !(fc->sb_flags & SB_RDONLY);
@@ -473,7 +479,15 @@ static int ntfs_fs_reconfigure(struct fs_context *fc)
473 479 }
474 480
475 481 sync_filesystem(sb);
476 - swap(sbi->options, fc->fs_private);
482 + old_opts = sbi->options;
483 + /* pairs with the READ_ONCE() in ntfs_nls_to_utf16() */
484 + smp_store_release(&sbi->options, new_opts);
485 + fc->fs_private = NULL;
486 + /*
487 + * ntfs_d_hash() and ntfs_d_compare() of a pathwalk in rcu mode may
488 + * still read the old options through the sbi.
489 + */
490 + call_rcu(&old_opts->rcu, put_mount_options_rcu);
477 491
478 492 return 0;
479 493 }
@@ -708,6 +722,8 @@ static noinline void ntfs3_put_sbi(struct ntfs_sb_info *sbi)
708 722
709 723 static void ntfs3_free_sbi(struct ntfs_sb_info *sbi)
710 724 {
725 + if (sbi->options)
726 + put_mount_options(sbi->options);
711 727 kfree(sbi->new_rec);
712 728 kvfree(ntfs_put_shared(sbi->upcase));
713 729 kvfree(sbi->def_table);
@@ -719,6 +735,11 @@ static void ntfs3_free_sbi(struct ntfs_sb_info *sbi)
719 735 kfree(sbi);
720 736 }
721 737
738 + static void ntfs3_free_sbi_rcu(struct rcu_head *head)
739 + {
740 + ntfs3_free_sbi(container_of(head, struct ntfs_sb_info, rcu));
741 + }
742 +
722 743 static void ntfs_put_super(struct super_block *sb)
723 744 {
724 745 struct ntfs_sb_info *sbi = sb->s_fs_info;
@@ -728,11 +749,11 @@ static void ntfs_put_super(struct super_block *sb)
728 749 /* Mark rw ntfs as clear, if possible. */
729 750 ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);
730 751
731 - if (sbi->options) {
732 - put_mount_options(sbi->options);
733 - sbi->options = NULL;
734 - }
735 -
752 + /*
753 + * The mount options stay until the sbi is freed: ->d_hash() and
754 + * ->d_compare() of a pathwalk in rcu mode read the nls table through
755 + * them.
756 + */
736 757 ntfs3_put_sbi(sbi);
737 758 }
738 759
@@ -1939,9 +1960,11 @@ static void ntfs3_kill_sb(struct super_block *sb)
1939 1960
1940 1961 kill_block_super(sb);
1941 1962
1942 - if (sbi->options)
1943 - put_mount_options(sbi->options);
1944 - ntfs3_free_sbi(sbi);
1963 + /*
1964 + * A pathwalk in rcu mode may still be in ->d_hash() or ->d_compare()
1965 + * and read the upcase table and the nls table through the sbi.
1966 + */
1967 + call_rcu(&sbi->rcu, ntfs3_free_sbi_rcu);
1945 1968 }
1946 1969
1947 1970 // clang-format off
modified fs/ocfs2/dlm/dlmcommon.h
@@ -435,6 +435,8 @@ enum {
435 435 DLM_DEREF_LOCKRES_DONE = 522,
436 436 };
437 437
438 + extern spinlock_t dlm_reco_state_lock;
439 +
438 440 struct dlm_reco_node_data
439 441 {
440 442 int state;
modified fs/ocfs2/dlm/dlmdebug.c
@@ -736,8 +736,11 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len)
736 736 buf + out, len - out);
737 737 out += scnprintf(buf + out, len - out, "\n");
738 738
739 + spin_unlock(&dlm->spinlock);
740 +
739 741 /* Recovery Node State: */
740 742 out += scnprintf(buf + out, len - out, "Recovery Node State:\n");
743 + spin_lock(&dlm_reco_state_lock);
741 744 list_for_each_entry(node, &dlm->reco.node_data, list) {
742 745 switch (node->state) {
743 746 case DLM_RECO_NODE_DATA_INIT:
@@ -769,7 +772,7 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len)
769 772 node->node_num, state);
770 773 }
771 774
772 - spin_unlock(&dlm->spinlock);
775 + spin_unlock(&dlm_reco_state_lock);
773 776
774 777 return out;
775 778 }
modified fs/ocfs2/dlm/dlmrecovery.c
@@ -80,7 +80,7 @@ static int dlm_lockres_master_requery(struct dlm_ctxt *dlm,
80 80
81 81 static u64 dlm_get_next_mig_cookie(void);
82 82
83 - static DEFINE_SPINLOCK(dlm_reco_state_lock);
83 + DEFINE_SPINLOCK(dlm_reco_state_lock);
84 84 static DEFINE_SPINLOCK(dlm_mig_cookie_lock);
85 85 static u64 dlm_mig_cookie = 1;
86 86
modified fs/pipe.c
@@ -838,9 +838,11 @@ pipe_fasync(int fd, struct file *filp, int on)
838 838 if (filp->f_mode & FMODE_READ)
839 839 retval = fasync_helper(fd, filp, on, &pipe->fasync_readers);
840 840 if ((filp->f_mode & FMODE_WRITE) && retval >= 0) {
841 + int read_ret = retval;
842 +
841 843 retval = fasync_helper(fd, filp, on, &pipe->fasync_writers);
842 - if (retval < 0 && (filp->f_mode & FMODE_READ))
843 - /* this can happen only if on == T */
844 + /* Undo only a reader entry added by this call. */
845 + if (retval < 0 && read_ret > 0)
844 846 fasync_helper(-1, filp, 0, &pipe->fasync_readers);
845 847 }
846 848 mutex_unlock(&pipe->mutex);
modified fs/tracefs/event_inode.c
@@ -91,6 +91,14 @@ static void free_ei_rcu(struct rcu_head *rcu)
91 91 }
92 92 }
93 93
94 + /* read under eventfs_srcu and, by tracefs_d_revalidate(), in rcu pathwalk */
95 + static void free_ei_srcu(struct rcu_head *rcu)
96 + {
97 + struct eventfs_inode *ei = container_of(rcu, struct eventfs_inode, rcu);
98 +
99 + call_rcu(&ei->rcu, free_ei_rcu);
100 + }
101 +
94 102 /*
95 103 * eventfs_inode reference count management.
96 104 *
@@ -112,7 +120,7 @@ static void release_ei(struct kref *ref)
112 120 entry->release(entry->name, ei->data);
113 121 }
114 122
115 - call_srcu(&eventfs_srcu, &ei->rcu, free_ei_rcu);
123 + call_srcu(&eventfs_srcu, &ei->rcu, free_ei_srcu);
116 124 }
117 125
118 126 static inline void put_ei(struct eventfs_inode *ei)
modified fs/unicode/utf8-core.c
@@ -3,6 +3,7 @@
3 3 #include <linux/kernel.h>
4 4 #include <linux/string.h>
5 5 #include <linux/slab.h>
6 + #include <linux/rcupdate.h>
6 7 #include <linux/parser.h>
7 8 #include <linux/errno.h>
8 9 #include <linux/stringhash.h>
@@ -183,12 +184,24 @@ out_free_um:
183 184 }
184 185 EXPORT_SYMBOL(utf8_load);
185 186
187 + static void utf8_unload_rcu(struct rcu_head *head)
188 + {
189 + struct unicode_map *um = container_of(head, struct unicode_map, rcu);
190 +
191 + symbol_put(utf8_data_table);
192 + kfree(um);
193 + }
194 +
195 + /*
196 + * A pathwalk in rcu mode may still be in ->d_hash() or ->d_compare() of a
197 + * filesystem that is being torn down and read the map through its
198 + * superblock, so the map and the tables it points to have to outlive the
199 + * grace period.
200 + */
186 201 void utf8_unload(struct unicode_map *um)
187 202 {
188 - if (um) {
189 - symbol_put(utf8_data_table);
190 - kfree(um);
191 - }
203 + if (um)
204 + call_rcu(&um->rcu, utf8_unload_rcu);
192 205 }
193 206 EXPORT_SYMBOL(utf8_unload);
194 207
modified include/linux/pci.h
@@ -467,7 +467,6 @@ struct pci_dev {
467 467
468 468 unsigned int is_busmaster:1; /* Is busmaster */
469 469 unsigned int no_msi:1; /* May not use MSI */
470 - unsigned int no_aer_anfe:1; /* Do not unmask ANFE */
471 470 unsigned int block_cfg_access:1; /* Config space access blocked */
472 471 unsigned int broken_parity_status:1; /* Generates false positive parity */
473 472 unsigned int irq_reroute_variant:2; /* Needs IRQ rerouting variant */
modified include/linux/power_supply.h
@@ -351,16 +351,6 @@ struct power_supply {
351 351 bool removing;
352 352 atomic_t use_cnt;
353 353 struct power_supply_battery_info *battery_info;
354 - /*
355 - * Held for read while ->external_power_changed() runs, and for write by
356 - * power_supply_unregister() when it publishes @removing, so that it
357 - * waits for an in-flight callback to finish. Without this a driver's
358 - * data, typically devm-allocated on its own device, can be freed while
359 - * the callback is still using it.
360 - * Must not be shared with extensions_sem: callbacks may read their own
361 - * properties, which takes that one for read.
362 - */
363 - struct rw_semaphore epc_sem;
364 354 struct rw_semaphore extensions_sem; /* protects "extensions" */
365 355 struct list_head extensions;
366 356 #ifdef CONFIG_THERMAL
@@ -424,9 +414,9 @@ struct power_supply_vbat_ri_table {
424 414 * @charge_voltage_max_uv: maintenance charging voltage that is usually a bit
425 415 * lower than the constant_charge_voltage_max_uv. We can apply this settings
426 416 * charge_current_max_ua until we get back up to this voltage.
427 - * @charge_safety_timer_minutes: maintenance charging safety timer, with an
428 - * expiry time in minutes. We will only use maintenance charging in this
429 - * setting for a certain amount of time, then we will first move to the next
417 + * @safety_timer_minutes: maintenance charging safety timer, with an expiry
418 + * time in minutes. We will only use maintenance charging in this setting
419 + * for a certain amount of time, then we will first move to the next
430 420 * maintenance charge current and voltage pair in respective array and wait
431 421 * for the next safety timer timeout, or, if we reached the last maintencance
432 422 * charging setting, disable charging until we reach
modified include/linux/sched/signal.h
@@ -130,8 +130,8 @@ struct signal_struct {
130 130 * process will inherit a flag if they should look for a
131 131 * child_subreaper process at exit.
132 132 */
133 - unsigned int is_child_subreaper:1;
134 - unsigned int has_child_subreaper:1;
133 + bool is_child_subreaper;
134 + bool has_child_subreaper;
135 135 unsigned int autoreap:1;
136 136
137 137 #ifdef CONFIG_POSIX_TIMERS
modified include/linux/unicode.h
@@ -53,6 +53,7 @@ struct unicode_map {
53 53 unsigned int version;
54 54 const struct utf8data *ntab[UTF8_NMAX];
55 55 const struct utf8data_table *tables;
56 + struct rcu_head rcu;
56 57 };
57 58
58 59 int utf8_validate(const struct unicode_map *um, const struct qstr *str);
modified ipc/namespace.c
@@ -96,7 +96,7 @@ fail_ipc:
96 96 fail_mq_sysctls:
97 97 retire_mq_sysctls(ns);
98 98 fail_mq_mount:
99 - mntput(ns->mq_mnt);
99 + kern_unmount(ns->mq_mnt);
100 100 fail_put:
101 101 put_user_ns(ns->user_ns);
102 102 ns_common_free(ns);
modified kernel/exit.c
@@ -1729,7 +1729,7 @@ static long do_wait(struct wait_opts *wo)
1729 1729 add_wait_queue(&current->signal->wait_chldexit, &wo->child_wait);
1730 1730
1731 1731 do {
1732 - set_current_state(TASK_INTERRUPTIBLE);
1732 + set_current_state(TASK_INTERRUPTIBLE | TASK_FREEZABLE);
1733 1733 retval = __do_wait(wo);
1734 1734 if (retval != -ERESTARTSYS)
1735 1735 break;
modified kernel/pid_namespace.c
@@ -268,7 +268,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
268 268 * free_pid() will awaken this task.
269 269 */
270 270 for (;;) {
271 - set_current_state(TASK_INTERRUPTIBLE);
271 + set_current_state(TASK_IDLE | TASK_FREEZABLE);
272 272 if (pid_ns->pid_allocated == init_pids)
273 273 break;
274 274 schedule();
modified kernel/sched/ext/ext.c
@@ -1149,10 +1149,6 @@ void schedule_dsq_reenq(struct scx_sched *sch, struct scx_dispatch_q *dsq,
1149 1149
1150 1150 guard(raw_spinlock_irqsave)(&rq->scx.deferred_reenq_lock);
1151 1151
1152 - /* @dsq is being destroyed, see free_dsq_irq_workfn() */
1153 - if (unlikely(READ_ONCE(dsq->id) == SCX_DSQ_INVALID))
1154 - return;
1155 -
1156 1152 if (list_empty(&dru->node))
1157 1153 list_move_tail(&dru->node, &rq->scx.deferred_reenq_users);
1158 1154 WRITE_ONCE(dru->flags, dru->flags | reenq_flags);
@@ -2407,14 +2403,11 @@ static void wakeup_preempt_scx(struct rq *rq, struct task_struct *p, int wake_fl
2407 2403 void scx_move_local_task_to_local_dsq(struct scx_sched *sch, struct task_struct *p,
2408 2404 u64 enq_flags, struct rq *dst_rq)
2409 2405 {
2410 - struct scx_dispatch_q *dst_dsq;
2406 + struct scx_dispatch_q *dst_dsq = scx_resolve_local_dsq(sch, dst_rq, p, &enq_flags);
2411 2407
2412 2408 lockdep_assert_rq_held(dst_rq);
2413 2409
2414 2410 WARN_ON_ONCE(p->scx.holding_cpu >= 0);
2415 - scx_wait_dispatching(p);
2416 -
2417 - dst_dsq = scx_resolve_local_dsq(sch, dst_rq, p, &enq_flags);
2418 2411
2419 2412 if (enq_flags & (SCX_ENQ_HEAD | SCX_ENQ_PREEMPT))
2420 2413 dsq_insert_head(dst_dsq, p);
@@ -2594,12 +2587,8 @@ static bool unlink_dsq_and_switch_rq_lock(struct task_struct *p,
2594 2587 switch_rq_lock(locked_rq, src_rq);
2595 2588
2596 2589 /* task_rq couldn't have changed if we're still the holding cpu */
2597 - if (likely(p->scx.holding_cpu == cpu) && !WARN_ON_ONCE(src_rq != task_rq(p))) {
2598 - scx_wait_dispatching(p);
2599 - return true;
2600 - }
2601 -
2602 - return false;
2590 + return likely(p->scx.holding_cpu == cpu) &&
2591 + !WARN_ON_ONCE(src_rq != task_rq(p));
2603 2592 }
2604 2593
2605 2594 static bool consume_remote_task(struct scx_sched *sch, struct rq *this_rq,
@@ -2642,8 +2631,6 @@ static struct rq *move_task_between_dsqs(struct scx_sched *sch,
2642 2631 lockdep_assert_held(&src_dsq->lock);
2643 2632 lockdep_assert_rq_held(src_rq);
2644 2633
2645 - scx_wait_dispatching(p);
2646 -
2647 2634 if (dst_dsq->id == SCX_DSQ_LOCAL) {
2648 2635 dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq);
2649 2636 if (src_rq != dst_rq &&
@@ -3226,7 +3213,8 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
3226 3213 /*
3227 3214 * If @p is runnable but we're about to enter a lower
3228 3215 * sched_class, %SCX_OPS_ENQ_LAST must be set. Tell
3229 - * ops.enqueue() that @p is the only one available for this cpu.
3216 + * ops.enqueue() that @p is the only one available for this cpu,
3217 + * which should trigger an explicit follow-up scheduling event.
3230 3218 * This doesn't apply if the baseline access on the CPU is lost.
3231 3219 *
3232 3220 * Under core scheduling, a pick dispatches only when nothing is
@@ -3238,16 +3226,6 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
3238 3226 WARN_ON_ONCE(!sched_core_enabled(rq) &&
3239 3227 !(sch->ops.flags & SCX_OPS_ENQ_LAST));
3240 3228 scx_do_enqueue_task(rq, p, SCX_ENQ_LAST, -1);
3241 -
3242 - /*
3243 - * A task put on the local DSQ runs, as anywhere else.
3244 - * Here the insert can't reschedule on its own: the pick
3245 - * has settled on @next and @p is still curr, so
3246 - * resched_curr() would flag @p and __schedule() clears
3247 - * that right after the pick. Flag @next instead.
3248 - */
3249 - if (p->scx.dsq == &rq->scx.local_dsq)
3250 - set_tsk_need_resched(next);
3251 3229 } else {
3252 3230 scx_do_enqueue_task(rq, p, 0, -1);
3253 3231 }
@@ -4492,12 +4470,11 @@ static bool local_task_should_reenq(struct rq *rq, struct task_struct *p,
4492 4470 }
4493 4471
4494 4472 /*
4495 - * The dispatcher runs ops.dequeue() and stores the final ops_state after
4496 - * dropping the DSQ lock, so @p can be found on a DSQ while still
4497 - * %SCX_OPSS_DISPATCHING. Wait for the dispatch to finish before operating on
4498 - * @p.
4473 + * The dispatcher stores the final ops_state after dropping the DSQ lock, so @p
4474 + * can be found on a DSQ while still %SCX_OPSS_DISPATCHING. Reenqueueing @p
4475 + * before that store lands would have it clobber the new %SCX_OPSS_QUEUED.
4499 4476 */
4500 - void scx_wait_dispatching(struct task_struct *p)
4477 + void scx_reenq_wait_dispatching(struct task_struct *p)
4501 4478 {
4502 4479 if (unlikely(atomic_long_read_acquire(&p->scx.ops_state) == SCX_OPSS_DISPATCHING))
4503 4480 wait_ops_state(p, SCX_OPSS_DISPATCHING);
@@ -4546,7 +4523,7 @@ static u32 reenq_local(struct scx_sched *sch, struct rq *rq, u64 reenq_flags)
4546 4523 if (!local_task_should_reenq(rq, p, &reenq_flags, &reason))
4547 4524 continue;
4548 4525
4549 - scx_wait_dispatching(p);
4526 + scx_reenq_wait_dispatching(p);
4550 4527 scx_dispatch_dequeue(rq, p);
4551 4528
4552 4529 if (WARN_ON_ONCE(p->scx.flags & SCX_TASK_REENQ_REASON_MASK))
@@ -4670,7 +4647,7 @@ static void reenq_user(struct rq *rq, struct scx_dispatch_q *dsq, u64 reenq_flag
4670 4647 }
4671 4648
4672 4649 /* @p is on @dsq, its rq and @dsq are locked */
4673 - scx_wait_dispatching(p);
4650 + scx_reenq_wait_dispatching(p);
4674 4651 dispatch_dequeue_locked(p, dsq);
4675 4652 raw_spin_unlock(&dsq->lock);
4676 4653
@@ -5194,8 +5171,8 @@ static void exit_dsq(struct scx_dispatch_q *dsq)
5194 5171 struct rq *rq = cpu_rq(cpu);
5195 5172
5196 5173 /*
5197 - * free_dsq_irq_workfn() cancelled the reenqs before the grace
5198 - * period and schedule_dsq_reenq() queues nothing after that.
5174 + * There must have been a RCU grace period since the last
5175 + * insertion and @dsq should be off the deferred list by now.
5199 5176 */
5200 5177 if (WARN_ON_ONCE(!list_empty(&dru->node))) {
5201 5178 guard(raw_spinlock_irqsave)(&rq->scx.deferred_reenq_lock);
@@ -5219,26 +5196,8 @@ static void free_dsq_irq_workfn(struct irq_work *irq_work)
5219 5196 struct llist_node *to_free = llist_del_all(&dsqs_to_free);
5220 5197 struct scx_dispatch_q *dsq, *tmp_dsq;
5221 5198
5222 - llist_for_each_entry_safe(dsq, tmp_dsq, to_free, free_node) {
5223 - s32 cpu;
5224 -
5225 - /*
5226 - * Cancel pending reenqs. Only a run_deferred() that started
5227 - * before the grace period can hold one, and it keeps IRQs off,
5228 - * so the grace period waits for it. After this sweep,
5229 - * schedule_dsq_reenq() sees the invalid id under the same lock
5230 - * and queues nothing.
5231 - */
5232 - for_each_possible_cpu(cpu) {
5233 - struct scx_dsq_pcpu *pcpu = per_cpu_ptr(dsq->pcpu, cpu);
5234 - struct rq *rq = cpu_rq(cpu);
5235 -
5236 - guard(raw_spinlock_irqsave)(&rq->scx.deferred_reenq_lock);
5237 - list_del_init(&pcpu->deferred_reenq_user.node);
5238 - }
5239 -
5199 + llist_for_each_entry_safe(dsq, tmp_dsq, to_free, free_node)
5240 5200 call_rcu(&dsq->rcu, free_dsq_rcufn);
5241 - }
5242 5201 }
5243 5202
5244 5203 static DEFINE_IRQ_WORK(free_dsq_irq_work, free_dsq_irq_workfn);
@@ -6109,12 +6068,15 @@ static void enable_bypass_dsp(struct scx_sched *sch)
6109 6068
6110 6069 /*
6111 6070 * When a sub-sched bypasses, its tasks are queued on the bypass DSQs of
6112 - * the nearest non-bypassing ancestor or root. The parent hosts them
6113 - * unless it is bypassing too. Then they sit further up and the parent
6114 - * consumes only its own bypass DSQs, empty until it leaves bypass and
6115 - * becomes the host. Either way the nearest non-bypassing ancestor or
6116 - * root has bypass dispatch enabled while a descendant is bypassing,
6117 - * which is all that's required.
6071 + * the nearest non-bypassing ancestor or root. As enable_bypass_dsp() is
6072 + * called iff @sch is not already bypassed due to an ancestor bypassing,
6073 + * we can assume that the parent is not bypassing and thus will be the
6074 + * host of the bypass DSQs.
6075 + *
6076 + * While the situation may change in the future, the following
6077 + * guarantees that the nearest non-bypassing ancestor or root has bypass
6078 + * dispatch enabled while a descendant is bypassing, which is all that's
6079 + * required.
6118 6080 *
6119 6081 * scx_bypass_dsp_enabled() test is used to determine whether to enter
6120 6082 * the bypass dispatch handling path from both bypassing and hosting
@@ -6223,45 +6185,34 @@ void scx_bypass(struct scx_sched *sch, bool bypass)
6223 6185 struct scx_sched *pos;
6224 6186 unsigned long flags;
6225 6187 int cpu;
6226 - bool changed;
6227 6188
6228 6189 raw_spin_lock_irqsave(&scx_bypass_lock, flags);
6229 6190
6230 6191 if (bypass) {
6231 - changed = inc_bypass_depth(sch);
6232 - if (changed)
6233 - enable_bypass_dsp(sch);
6192 + if (!inc_bypass_depth(sch))
6193 + goto unlock;
6194 +
6195 + enable_bypass_dsp(sch);
6234 6196 } else {
6235 - changed = dec_bypass_depth(sch);
6197 + if (!dec_bypass_depth(sch))
6198 + goto unlock;
6236 6199 }
6237 6200
6238 6201 /*
6239 6202 * Bypass state is propagated to all descendants - an scx_sched bypasses
6240 - * if itself or any of its ancestors are in bypass mode. A descendant's
6241 - * depth is the sum of its own bypasses and its ancestors', so every
6242 - * call propagates whether or not @sch changed state. The descendants'
6243 - * claims are released below with @sch's, after their tasks have moved.
6203 + * if itself or any of its ancestors are in bypass mode.
6244 6204 */
6245 6205 raw_spin_lock(&scx_sched_lock);
6246 6206 scx_for_each_descendant_pre(pos, sch) {
6247 6207 if (pos == sch)
6248 6208 continue;
6249 - if (bypass) {
6250 - if (inc_bypass_depth(pos))
6251 - enable_bypass_dsp(pos);
6252 - } else {
6209 + if (bypass)
6210 + inc_bypass_depth(pos);
6211 + else
6253 6212 dec_bypass_depth(pos);
6254 - }
6255 6213 }
6256 6214 raw_spin_unlock(&scx_sched_lock);
6257 6215
6258 - /*
6259 - * A descendant's depth is at least @sch's, so no bypass state changed
6260 - * unless @sch's did.
6261 - */
6262 - if (!changed)
6263 - goto unlock;
6264 -
6265 6216 /*
6266 6217 * No task property is changing. We just need to make sure all currently
6267 6218 * queued tasks are re-queued according to the new scx_bypassing()
@@ -6340,12 +6291,8 @@ void scx_bypass(struct scx_sched *sch, bool bypass)
6340 6291 }
6341 6292
6342 6293 /* disarming must come after moving all tasks out of the bypass DSQs */
6343 - if (!bypass) {
6344 - guard(raw_spinlock)(&scx_sched_lock);
6345 - scx_for_each_descendant_pre(pos, sch)
6346 - if (!pos->bypass_depth)
6347 - scx_disable_bypass_dsp(pos);
6348 - }
6294 + if (!bypass)
6295 + scx_disable_bypass_dsp(sch);
6349 6296 unlock:
6350 6297 raw_spin_unlock_irqrestore(&scx_bypass_lock, flags);
6351 6298 }
modified kernel/sched/ext/idle.c
@@ -952,43 +952,12 @@ static bool is_bpf_migration_disabled(const struct task_struct *p)
952 952 return p->migration_disabled;
953 953 }
954 954
955 - static s32 select_cpu_restricted(struct task_struct *p, s32 prev_cpu,
956 - const struct cpumask *allowed, u64 flags,
957 - bool migration_disabled)
958 - {
959 - s32 cpu;
960 -
961 - if (migration_disabled)
962 - cpu = task_cpu(p);
963 - else
964 - cpu = cpumask_first(p->cpus_ptr);
965 -
966 - if (!cpumask_test_cpu(cpu, p->cpus_ptr))
967 - return -EBUSY;
968 -
969 - if (allowed && !cpumask_test_cpu(cpu, allowed))
970 - return -EBUSY;
971 -
972 - if (flags & SCX_PICK_IDLE_IN_NODE) {
973 - int node = scx_cpu_node_if_enabled(prev_cpu);
974 -
975 - if (scx_cpu_node_if_enabled(cpu) != node)
976 - return -EBUSY;
977 - }
978 -
979 - if (!scx_idle_test_and_clear_cpu(cpu))
980 - return -EBUSY;
981 -
982 - return cpu;
983 - }
984 -
985 955 static s32 select_cpu_from_kfunc(struct scx_sched *sch, struct task_struct *p,
986 956 s32 prev_cpu, u64 wake_flags,
987 957 const struct cpumask *allowed, u64 flags)
988 958 {
989 959 unsigned long irq_flags;
990 960 bool we_locked = false;
991 - bool migration_disabled;
992 961 s32 cpu;
993 962
994 963 if (!scx_cpu_valid(sch, prev_cpu, NULL))
@@ -1025,17 +994,20 @@ static s32 select_cpu_from_kfunc(struct scx_sched *sch, struct task_struct *p,
1025 994
1026 995 /*
1027 996 * This may also be called from ops.enqueue(), so we need to handle
1028 - * per-CPU tasks as well. For these tasks, skip general idle CPU
1029 - * selection and validate the task's only usable CPU directly.
997 + * per-CPU tasks as well. For these tasks, we can skip all idle CPU
998 + * selection optimizations and simply check whether the previously
999 + * used CPU is idle and within the allowed cpumask.
1030 1000 */
1031 - migration_disabled = is_bpf_migration_disabled(p);
1032 -
1033 - if (p->nr_cpus_allowed == 1 || migration_disabled)
1034 - cpu = select_cpu_restricted(p, prev_cpu, allowed, flags,
1035 - migration_disabled);
1036 - else
1001 + if (p->nr_cpus_allowed == 1 || is_bpf_migration_disabled(p)) {
1002 + if (cpumask_test_cpu(prev_cpu, allowed ?: p->cpus_ptr) &&
1003 + scx_idle_test_and_clear_cpu(prev_cpu))
1004 + cpu = prev_cpu;
1005 + else
1006 + cpu = -EBUSY;
1007 + } else {
1037 1008 cpu = scx_select_cpu_dfl(p, prev_cpu, wake_flags,
1038 1009 allowed ?: p->cpus_ptr, flags);
1010 + }
1039 1011
1040 1012 if (we_locked)
1041 1013 raw_spin_unlock_irqrestore(&p->pi_lock, irq_flags);
modified kernel/sched/ext/internal.h
@@ -1774,9 +1774,8 @@ enum scx_enq_flags {
1774 1774 * %SCX_OPS_ENQ_LAST is specified, they're ops.enqueue()'d with the
1775 1775 * %SCX_ENQ_LAST flag set.
1776 1776 *
1777 - * If the task is queued on the local DSQ of the CPU it was running on,
1778 - * it continues to run. Otherwise, the CPU goes idle. A scheduler that
1779 - * wants a full dispatch cycle on the CPU should kick it.
1777 + * The BPF scheduler is responsible for triggering a follow-up
1778 + * scheduling event. Otherwise, Execution may stall.
1780 1779 */
1781 1780 SCX_ENQ_LAST = 1LLU << 41,
1782 1781
@@ -2123,7 +2122,7 @@ void scx_kick_cpu(struct scx_sched *sch, s32 cpu, u64 flags);
2123 2122 u64 __scx_bpf_now(struct rq *rq);
2124 2123 void schedule_dsq_reenq(struct scx_sched *sch, struct scx_dispatch_q *dsq,
2125 2124 u64 reenq_flags, struct rq *locked_rq);
2126 - void scx_wait_dispatching(struct task_struct *p);
2125 + void scx_reenq_wait_dispatching(struct task_struct *p);
2127 2126 int __scx_init_task(struct scx_sched *sch, struct task_struct *p,
2128 2127 struct cgroup *cgrp, bool fork);
2129 2128 void scx_enable_task(struct scx_sched *sch, struct task_struct *p);
modified kernel/sched/ext/sub.c
@@ -797,7 +797,7 @@ void scx_reenq_reject(struct rq *rq)
797 797 if (WARN_ON_ONCE(p->migration_pending))
798 798 continue;
799 799
800 - scx_wait_dispatching(p);
800 + scx_reenq_wait_dispatching(p);
801 801 scx_dispatch_dequeue(rq, p);
802 802
803 803 if (WARN_ON_ONCE(p->scx.flags & SCX_TASK_REENQ_REASON_MASK))
modified kernel/watch_queue.c
@@ -101,7 +101,7 @@ static bool post_one_notification(struct watch_queue *wqueue,
101 101 struct pipe_inode_info *pipe = wqueue->pipe;
102 102 struct pipe_buffer *buf;
103 103 struct page *page;
104 - unsigned int head, tail, note, offset, len;
104 + unsigned int head, tail, note, offset, len, nr_notes;
105 105 bool done = false;
106 106
107 107 spin_lock_irq(&pipe->rd_wait.lock);
@@ -111,8 +111,10 @@ static bool post_one_notification(struct watch_queue *wqueue,
111 111 if (pipe_full(head, tail, pipe->ring_size))
112 112 goto lost;
113 113
114 - note = find_first_bit(wqueue->notes_bitmap, wqueue->nr_notes);
115 - if (note >= wqueue->nr_notes)
114 + /* Pairs with the smp_store_release() in watch_queue_set_size(). */
115 + nr_notes = smp_load_acquire(&wqueue->nr_notes);
116 + note = find_first_bit(wqueue->notes_bitmap, nr_notes);
117 + if (note >= nr_notes)
116 118 goto lost;
117 119
118 120 page = wqueue->notes[note / WATCH_QUEUE_NOTES_PER_PAGE];
@@ -297,7 +299,8 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
297 299 wqueue->notes = pages;
298 300 wqueue->notes_bitmap = bitmap;
299 301 wqueue->nr_pages = nr_pages;
300 - wqueue->nr_notes = nr_notes;
302 + /* Pairs with the smp_load_acquire() in post_one_notification(). */
303 + smp_store_release(&wqueue->nr_notes, nr_notes);
301 304 return 0;
302 305
303 306 error_p:
modified kernel/workqueue.c
@@ -6320,7 +6320,7 @@ bool current_is_workqueue_mem_reclaim(void)
6320 6320 {
6321 6321 struct worker *worker = current_wq_worker();
6322 6322
6323 - return worker && worker->current_pwq &&
6323 + return worker &&
6324 6324 ((worker->current_pwq->wq->flags &
6325 6325 (WQ_MEM_RECLAIM | __WQ_LEGACY)) == WQ_MEM_RECLAIM);
6326 6326 }
modified lib/crypto/arm64/poly1305-armv8.pl
@@ -375,7 +375,7 @@ poly1305_blocks_neon:
375 375 adc $h1,$h1,xzr
376 376 lsr $h2,x14,#24
377 377 adds $h1,$h1,x14,lsl#40
378 - adc $h2,$h2,xzr // preserve carry into top limb
378 + adc $d2,$h2,xzr // can be partially reduced...
379 379
380 380 ldp $d0,$d1,[$inp],#16 // load input
381 381 sub $len,$len,#16
modified lib/crypto/poly1305.c
@@ -78,7 +78,7 @@ void poly1305_final(struct poly1305_desc_ctx *desc, u8 *dst)
78 78 }
79 79
80 80 poly1305_emit(&desc->state.h, dst, desc->s);
81 - memzero_explicit(desc, sizeof(*desc));
81 + *desc = (struct poly1305_desc_ctx){};
82 82 }
83 83 EXPORT_SYMBOL(poly1305_final);
84 84
modified lib/crypto/tests/poly1305_kunit.c
@@ -55,17 +55,16 @@ static int poly1305_suite_init(struct kunit_suite *suite)
55 55 * - Using an all-one-bits r_key tests the key clamping.
56 56 * - Using an all-one-bits s_key tests carries in implementations of the
57 57 * addition mod 2**128 during finalization.
58 - * - Using all-one-bits message and r_key results in large values for the
59 - * internal products of r_key by (accumulator + message block). This
60 - * increases the chance of detecting bugs that occur only in rare cases where
61 - * the sum of these internal products is very large, for example the bug fixed
62 - * by commit 678cce4019d7 ("crypto: x86/poly1305 - fix overflow during partial
63 - * reduction").
58 + * - Using all-one-bits message, and to a lesser extent r_key, tends to maximize
59 + * any intermediate accumulator values. This increases the chance of
60 + * detecting bugs that occur only in rare cases where the accumulator values
61 + * get very large, for example the bug fixed by commit 678cce4019d746da
62 + * ("crypto: x86/poly1305 - fix overflow during partial reduction").
64 63 *
65 - * Bugs with the handling of large internal product sums may be specific to
66 - * particular update lengths (in blocks) and/or require that the accumulator
67 - * also have a large value. Note that the accumulator starts at 0. Thus, a
68 - * single all-one-bits test vector may be insufficient.
64 + * Accumulator overflow bugs may be specific to particular update lengths (in
65 + * blocks) and/or particular values of the previous acculumator. Note that the
66 + * accumulator starts at 0 which gives the lowest chance of an overflow. Thus,
67 + * a single all-one-bits test vector may be insufficient.
69 68 *
70 69 * Considering that, do the following test: continuously update a single
71 70 * Poly1305 context with all-one-bits data of varying lengths (0, 16, 32, ...,
@@ -142,88 +141,10 @@ static void test_poly1305_reduction_edge_cases(struct kunit *test)
142 141 }
143 142 }
144 143
145 - /*
146 - * Test that Poly1305 MACs are computed correctly when r_key=1, s_key=0, and the
147 - * message consists of all-ones blocks.
148 - *
149 - * With r_key=1 and s_key=0, Poly1305 degrades to the sum of the padded blocks
150 - * mod 2**130 - 5, then reduced mod 2**128. A padded all-ones block maps to
151 - * 2**128 + (2**128 - 1) = 2**129 - 1. Two such blocks sum to 2**130 - 2, which
152 - * is congruent to 3 mod 2**130 - 5. Thus, the expected MAC is just 3 *
153 - * floor(nblocks / 2), minus 1 if nblocks is odd, then reduced mod 2**128. If
154 - * nblocks == 1 this is 2**128 - 1, otherwise it's just a small integer.
155 - *
156 - * Inside the Poly1305 implementation in this case, the multiplication does
157 - * nothing and each block just adds 2**129 - 1 to the accumulator. Without the
158 - * multiplication to mix things up, this results in some interesting values
159 - * being reached where the limbs are at or near their maximum values, even after
160 - * (lazy) reduction. This can reproduce bugs that happen only in such cases.
161 - *
162 - * For example, this test case reproduces the bug fixed by commit 24f07e8c07a0
163 - * ("lib/crypto: arm64: Fix lost Poly1305 carry when resuming NEON state").
164 - *
165 - * However, reaching that bug required two consecutive updates: one with >= 8
166 - * blocks to cause NEON code to be used and leave the accumulator in base 2**26
167 - * with its limbs in a certain pattern, then one with an odd number of blocks >=
168 - * 9 to cause NEON to be used again, but first processing one block using scalar
169 - * code as a special case, triggering a conversion to base 2**64 where the carry
170 - * into the 2**128 bit was lost. To cover this and other similar edge cases
171 - * that may exist in other Poly1305 implementations, just test all possible
172 - * block-aligned splits between three poly1305_update() calls.
173 - */
174 - static void test_poly1305_split_update_carry(struct kunit *test)
175 - {
176 - static const u8 key[POLY1305_KEY_SIZE] = { 1 }; /* r_key=1, s_key=0 */
177 - /*
178 - * Use max_nblocks=66 so that it's a bit more than twice the AVX-512
179 - * threshold of 32 blocks.
180 - */
181 - const int max_nblocks = 66;
182 - u8 *data = alloc_buf(test, max_nblocks * POLY1305_BLOCK_SIZE);
183 - u8 expected_mac[POLY1305_DIGEST_SIZE];
184 - u8 actual_mac[POLY1305_DIGEST_SIZE];
185 - struct poly1305_desc_ctx ctx;
186 -
187 - KUNIT_ASSERT_LE(test, 3 * (max_nblocks / 2), U8_MAX);
188 -
189 - memset(data, 0xff, max_nblocks * POLY1305_BLOCK_SIZE);
190 -
191 - for (int nblocks = 0; nblocks <= max_nblocks; nblocks++) {
192 - size_t len = nblocks * POLY1305_BLOCK_SIZE;
193 -
194 - expected_mac[0] = 3 * (nblocks / 2) - (nblocks % 2);
195 - memset(&expected_mac[1], nblocks == 1 ? 0xff : 0,
196 - POLY1305_DIGEST_SIZE - 1);
197 - for (size_t part1_len = 0; part1_len <= len;
198 - part1_len += POLY1305_BLOCK_SIZE) {
199 - for (size_t part2_len = 0; part2_len <= len - part1_len;
200 - part2_len += POLY1305_BLOCK_SIZE) {
201 - size_t part3_len = len - part1_len - part2_len;
202 -
203 - poly1305_init(&ctx, key);
204 - poly1305_update(&ctx, data, part1_len);
205 - poly1305_update(&ctx, &data[part1_len],
206 - part2_len);
207 - poly1305_update(&ctx,
208 - &data[part1_len + part2_len],
209 - part3_len);
210 - poly1305_final(&ctx, actual_mac);
211 - KUNIT_ASSERT_MEMEQ_MSG(
212 - test, actual_mac, expected_mac,
213 - POLY1305_DIGEST_SIZE,
214 - "Failed with nblocks=%d, part1_len=%zu, part2_len=%zu, part3_len=%zu",
215 - nblocks, part1_len, part2_len,
216 - part3_len);
217 - }
218 - }
219 - }
220 - }
221 -
222 144 static struct kunit_case poly1305_test_cases[] = {
223 145 HASH_KUNIT_CASES,
224 146 KUNIT_CASE(test_poly1305_allones_keys_and_message),
225 147 KUNIT_CASE(test_poly1305_reduction_edge_cases),
226 - KUNIT_CASE(test_poly1305_split_update_carry),
227 148 KUNIT_CASE(benchmark_hash),
228 149 {},
229 150 };
modified net/ipv6/calipso.c
@@ -1318,7 +1318,7 @@ static int calipso_skbuff_setattr(struct sk_buff *skb,
1318 1318 struct ipv6hdr *ip6_hdr;
1319 1319 struct ipv6_opt_hdr *hop;
1320 1320 unsigned char buf[CALIPSO_MAX_BUFFER];
1321 - int len_delta, new_end, pad;
1321 + int len_delta, new_end, pad, payload;
1322 1322 unsigned int start, end;
1323 1323
1324 1324 ip6_hdr = ipv6_hdr(skb);
@@ -1357,8 +1357,8 @@ static int calipso_skbuff_setattr(struct sk_buff *skb,
1357 1357 sizeof(*ip6_hdr) + start);
1358 1358 skb_reset_network_header(skb);
1359 1359 ip6_hdr = ipv6_hdr(skb);
1360 - /* 0 above IPV6_MAXPLEN (BIG TCP), the real length otherwise */
1361 - ipv6_set_payload_len(ip6_hdr, skb->len - sizeof(*ip6_hdr));
1360 + payload = ntohs(ip6_hdr->payload_len);
1361 + ip6_hdr->payload_len = htons(payload + len_delta);
1362 1362 }
1363 1363
1364 1364 hop = (struct ipv6_opt_hdr *)(ip6_hdr + 1);
modified net/netlink/af_netlink.c
@@ -464,7 +464,7 @@ netlink_unlock_table(void)
464 464
465 465 struct netlink_compare_arg
466 466 {
467 - u64 net_cookie;
467 + possible_net_t pnet;
468 468 u32 portid;
469 469 };
470 470
@@ -479,14 +479,14 @@ static inline int netlink_compare(struct rhashtable_compare_arg *arg,
479 479 const struct netlink_sock *nlk = ptr;
480 480
481 481 return nlk->portid != x->portid ||
482 - sock_net(&nlk->sk)->net_cookie != x->net_cookie;
482 + !net_eq(sock_net(&nlk->sk), read_pnet(&x->pnet));
483 483 }
484 484
485 485 static void netlink_compare_arg_init(struct netlink_compare_arg *arg,
486 486 struct net *net, u32 portid)
487 487 {
488 488 memset(arg, 0, sizeof(*arg));
489 - arg->net_cookie = net->net_cookie;
489 + write_pnet(&arg->pnet, net);
490 490 arg->portid = portid;
491 491 }
492 492
@@ -1363,8 +1363,6 @@ retry:
1363 1363 if (netlink_is_kernel(sk))
1364 1364 return netlink_unicast_kernel(sk, skb, ssk);
1365 1365
1366 - skb_reset_network_header(skb);
1367 - skb_reset_mac_header(skb);
1368 1366 if (sk_filter(sk, skb)) {
1369 1367 err = skb->len;
1370 1368 kfree_skb(skb);
@@ -1499,8 +1497,6 @@ static void do_one_broadcast(struct sock *sk,
1499 1497 goto out;
1500 1498 }
1501 1499
1502 - skb_reset_network_header(p->skb2);
1503 - skb_reset_mac_header(p->skb2);
1504 1500 if (sk_filter(sk, p->skb2)) {
1505 1501 kfree_skb(p->skb2);
1506 1502 p->skb2 = NULL;
modified net/rds/rdma_transport.c
@@ -52,7 +52,7 @@ static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
52 52 {
53 53 /* this can be null in the listening path */
54 54 struct rds_connection *conn = cm_id->context;
55 - struct rds_transport *trans = &rds_ib_transport;
55 + struct rds_transport *trans;
56 56 int ret = 0;
57 57 int *err;
58 58 u8 len;
@@ -60,6 +60,9 @@ static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
60 60 rdsdebug("conn %p id %p handling event %u (%s)\n", conn, cm_id,
61 61 event->event, rdma_event_msg(event->event));
62 62
63 + if (cm_id->device->node_type == RDMA_NODE_IB_CA)
64 + trans = &rds_ib_transport;
65 +
63 66 /* Prevent shutdown from tearing down the connection
64 67 * while we're executing. */
65 68 if (conn) {
@@ -79,47 +82,16 @@ static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
79 82
80 83 switch (event->event) {
81 84 case RDMA_CM_EVENT_CONNECT_REQUEST:
82 - /* Only the IB transport is supported, but RDS listens on
83 - * every RDMA device: reject a request that arrived on any
84 - * other kind. A non-zero return has rdma_cm destroy the
85 - * request's id, which is what we want here and only here.
86 - */
87 - if (cm_id->device->node_type != RDMA_NODE_IB_CA) {
88 - ret = 1;
89 - break;
90 - }
91 85 ret = trans->cm_handle_connect(cm_id, event, isv6);
92 86 break;
93 87
94 88 case RDMA_CM_EVENT_ADDR_RESOLVED:
95 89 if (conn) {
96 - /* The address resolved to a device RDS has no
97 - * transport for. Do not go on to resolve a route:
98 - * an iWARP route leaves cm_id->route.path_rec
99 - * unset, which the ROUTE_RESOLVED case below
100 - * dereferences. Drop the connection instead; the
101 - * id is still ic->i_cm_id, so return 0 and let the
102 - * shutdown destroy it.
103 - */
104 - if (cm_id->device->node_type != RDMA_NODE_IB_CA) {
105 - rds_conn_drop(conn);
106 - break;
107 - }
108 90 rdma_set_service_type(cm_id, conn->c_tos);
109 91 rdma_set_min_rnr_timer(cm_id, IB_RNR_TIMER_000_32);
92 + /* XXX do we need to clean up if this fails? */
110 93 ret = rdma_resolve_route(cm_id,
111 94 RDS_RDMA_RESOLVE_TIMEOUT_MS);
112 - if (ret) {
113 - /* A non-zero return has the rdma_cm destroy
114 - * the id, but it is still ic->i_cm_id, which
115 - * the connection's shutdown would then
116 - * disconnect and destroy again. Drop the
117 - * connection and keep the id for that
118 - * shutdown.
119 - */
120 - rds_conn_drop(conn);
121 - ret = 0;
122 - }
123 95 }
124 96 break;
125 97
modified net/sched/act_api.c
@@ -372,10 +372,9 @@ static int __tcf_action_put(struct tc_action *p, bool bind)
372 372 {
373 373 struct tcf_idrinfo *idrinfo = p->idrinfo;
374 374
375 - mutex_lock(&idrinfo->lock);
376 - if (bind)
377 - atomic_dec(&p->tcfa_bindcnt);
378 - if (refcount_dec_and_test(&p->tcfa_refcnt)) {
375 + if (refcount_dec_and_mutex_lock(&p->tcfa_refcnt, &idrinfo->lock)) {
376 + if (bind)
377 + atomic_dec(&p->tcfa_bindcnt);
379 378 idr_remove(&idrinfo->action_idr, p->tcfa_index);
380 379 mutex_unlock(&idrinfo->lock);
381 380
@@ -383,7 +382,9 @@ static int __tcf_action_put(struct tc_action *p, bool bind)
383 382 return 1;
384 383 }
385 384
386 - mutex_unlock(&idrinfo->lock);
385 + if (bind)
386 + atomic_dec(&p->tcfa_bindcnt);
387 +
387 388 return 0;
388 389 }
389 390
modified net/sctp/socket.c
@@ -1786,18 +1786,6 @@ static int sctp_sendmsg_check_sflags(struct sctp_association *asoc,
1786 1786 return 1;
1787 1787 }
1788 1788
1789 - static int sctp_sendmsg_check_stream(struct sctp_association *asoc,
1790 - struct sctp_sndrcvinfo *sinfo)
1791 - {
1792 - if (unlikely(sinfo->sinfo_stream >= asoc->stream.outcnt))
1793 - return -EINVAL;
1794 -
1795 - if (unlikely(!SCTP_SO(&asoc->stream, sinfo->sinfo_stream)->ext))
1796 - return sctp_stream_init_ext(&asoc->stream, sinfo->sinfo_stream);
1797 -
1798 - return 0;
1799 - }
1800 -
1801 1789 static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,
1802 1790 struct msghdr *msg, size_t msg_len,
1803 1791 struct sctp_transport *transport,
@@ -1812,9 +1800,16 @@ static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,
1812 1800 long timeo;
1813 1801 int err;
1814 1802
1815 - err = sctp_sendmsg_check_stream(asoc, sinfo);
1816 - if (err)
1803 + if (sinfo->sinfo_stream >= asoc->stream.outcnt) {
1804 + err = -EINVAL;
1817 1805 goto err;
1806 + }
1807 +
1808 + if (unlikely(!SCTP_SO(&asoc->stream, sinfo->sinfo_stream)->ext)) {
1809 + err = sctp_stream_init_ext(&asoc->stream, sinfo->sinfo_stream);
1810 + if (err)
1811 + goto err;
1812 + }
1818 1813
1819 1814 if (sp->disable_fragments && msg_len > asoc->frag_point) {
1820 1815 err = -EMSGSIZE;
@@ -1835,9 +1830,10 @@ static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,
1835 1830 err = sctp_wait_for_sndbuf(asoc, transport, &timeo, msg_len);
1836 1831 if (err)
1837 1832 goto err;
1838 - err = sctp_sendmsg_check_stream(asoc, sinfo);
1839 - if (err)
1833 + if (unlikely(sinfo->sinfo_stream >= asoc->stream.outcnt)) {
1834 + err = -EINVAL;
1840 1835 goto err;
1836 + }
1841 1837 }
1842 1838
1843 1839 if (sctp_state(asoc, CLOSED)) {
@@ -1852,11 +1848,6 @@ static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,
1852 1848 err = -ESRCH;
1853 1849 goto err;
1854 1850 }
1855 - err = sctp_sendmsg_check_stream(asoc, sinfo);
1856 - if (err) {
1857 - err = -ESRCH;
1858 - goto err;
1859 - }
1860 1851 } else {
1861 1852 wait_connect = true;
1862 1853 }
modified net/vmw_vsock/af_vsock.c
@@ -1836,22 +1836,23 @@ static int vsock_connect(struct socket *sock, struct sockaddr_unsized *addr,
1836 1836 timeout = schedule_timeout(timeout);
1837 1837 lock_sock(sk);
1838 1838
1839 - /* Connection was established. Whatever happens to socket once
1840 - * we release it, that's not connect()'s concern. No need to go
1839 + /* Connection established. Whatever happens to socket once we
1840 + * release it, that's not connect()'s concern. No need to go
1841 1841 * into signal and timeout handling. Call it a day.
1842 1842 *
1843 1843 * Note that allowing to "reset" an already established socket
1844 1844 * here is racy and insecure.
1845 1845 */
1846 - if (sk->sk_state == TCP_ESTABLISHED ||
1847 - sk->sk_state == TCP_CLOSING) {
1848 - err = 0;
1849 - goto out_wait;
1850 - }
1846 + if (sk->sk_state == TCP_ESTABLISHED)
1847 + break;
1851 1848
1852 1849 /* If connection was _not_ established and a signal/timeout came
1853 1850 * to be, we want the socket's state reset. User space may want
1854 - * to retry, so we keep the binding and the transport assigned.
1851 + * to retry.
1852 + *
1853 + * sk_state != TCP_ESTABLISHED implies that socket is not on
1854 + * vsock_connected_table. We keep the binding and the transport
1855 + * assigned.
1855 1856 */
1856 1857 if (signal_pending(current) || timeout == 0) {
1857 1858 err = timeout == 0 ? -ETIMEDOUT : sock_intr_errno(timeout);
modified samples/pidfd/Makefile
@@ -1,4 +1,4 @@
1 1 # SPDX-License-Identifier: GPL-2.0
2 - usertprogs-always-y += pidfd-metadata
2 + userprogs-always-y += pidfd-metadata
3 3
4 4 userccflags += -I usr/include
modified tools/bootconfig/main.c
@@ -495,8 +495,7 @@ static int apply_xbc(const char *path, const char *xbc_path)
495 495 footer.size = htole32(size);
496 496 footer.csum = htole32(csum);
497 497 memcpy(footer.magic, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN);
498 - static_assert(sizeof(footer) == BOOTCONFIG_FOOTER_SIZE,
499 - "bootconfig footer size mismatch");
498 + static_assert(sizeof(footer) == BOOTCONFIG_FOOTER_SIZE);
500 499 memcpy(data + size, &footer, BOOTCONFIG_FOOTER_SIZE);
501 500
502 501 total_size = size + BOOTCONFIG_FOOTER_SIZE;
modified tools/hv/hv_get_dns_info.sh
@@ -1,6 +1,6 @@
1 1 #!/bin/sh
2 2
3 - # This example script parses /etc/resolv.conf to retrieve DNS information.
3 + # This example script parses /etc/resolv.conf to retrive DNS information.
4 4 # In the interest of keeping the KVP daemon code free of distro specific
5 5 # information; the kvp daemon code invokes this external script to gather
6 6 # DNS information.
modified tools/power/x86/turbostat/turbostat.c
@@ -2034,11 +2034,8 @@ const struct dirent *pmt_diriter_begin(struct pmt_diriter_t *iter, const char *p
2034 2034 return NULL;
2035 2035
2036 2036 num_names = scandir(pmt_root_path, &iter->namelist, pmt_telemdir_filter, pmt_telemdir_sort);
2037 - if (num_names == -1) {
2038 - closedir(iter->dir);
2039 - iter->dir = NULL;
2037 + if (num_names == -1)
2040 2038 return NULL;
2041 - }
2042 2039 }
2043 2040
2044 2041 iter->current_name_idx = 0;
@@ -2066,10 +2063,8 @@ void pmt_diriter_remove(struct pmt_diriter_t *iter)
2066 2063 iter->num_names = 0;
2067 2064 iter->current_name_idx = 0;
2068 2065
2069 - if (iter->dir) {
2070 - closedir(iter->dir);
2071 - iter->dir = NULL;
2072 - }
2066 + closedir(iter->dir);
2067 + iter->dir = NULL;
2073 2068 }
2074 2069
2075 2070 unsigned int pmt_counter_get_width(const struct pmt_counter *p)
@@ -3641,7 +3636,7 @@ int format_counters(PER_THREAD_PARAMS)
3641 3636 if (p->gfx_rc6_ms == -1) { /* detect GFX counter reset */
3642 3637 outp += sprintf(outp, "%s**.**", (printed++ ? delim : ""));
3643 3638 } else {
3644 - outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), pct(p->gfx_rc6_ms / 10.0, interval_float));
3639 + outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), p->gfx_rc6_ms / 10.0 / interval_float);
3645 3640 }
3646 3641 }
3647 3642
@@ -3658,7 +3653,7 @@ int format_counters(PER_THREAD_PARAMS)
3658 3653 if (p->sam_mc6_ms == -1) { /* detect GFX counter reset */
3659 3654 outp += sprintf(outp, "%s**.**", (printed++ ? delim : ""));
3660 3655 } else {
3661 - outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), pct(p->sam_mc6_ms / 10.0, interval_float));
3656 + outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), p->sam_mc6_ms / 10.0 / interval_float);
3662 3657 }
3663 3658 }
3664 3659
@@ -5920,7 +5915,7 @@ void free_fd_msr(void)
5920 5915 if (!msr_counter_info)
5921 5916 return;
5922 5917
5923 - for (int cpu = 0; cpu <= topo.max_cpu_num; ++cpu) {
5918 + for (int cpu = 0; cpu < topo.max_cpu_num; ++cpu) {
5924 5919 if (msr_counter_info[cpu].fd_perf != -1)
5925 5920 close(msr_counter_info[cpu].fd_perf);
5926 5921 }
@@ -6316,35 +6311,33 @@ int for_all_proc_cpus(int (func) (int))
6316 6311
6317 6312 #define PATH_EFFECTIVE_CPUS "/sys/fs/cgroup/cpuset.cpus.effective"
6318 6313
6319 - static char *cpu_effective_str;
6314 + static char cpu_effective_str[1024];
6320 6315
6321 6316 static int update_effective_str(bool startup)
6322 6317 {
6323 6318 FILE *fp;
6324 - char *buf = NULL;
6325 - size_t size = 0;
6319 + char *pos;
6320 + char buf[1024];
6326 6321 int ret;
6327 6322
6328 - if (!cpu_effective_str && !startup)
6323 + if (cpu_effective_str[0] == '\0' && !startup)
6329 6324 return 0;
6330 6325
6331 6326 fp = fopen(PATH_EFFECTIVE_CPUS, "r");
6332 6327 if (!fp)
6333 6328 return 0;
6334 6329
6335 - if (getline(&buf, &size, fp) < 0)
6330 + pos = fgets(buf, 1024, fp);
6331 + if (!pos)
6336 6332 err(1, "%s: file read failed", PATH_EFFECTIVE_CPUS);
6337 6333
6338 6334 fclose(fp);
6339 6335
6340 - ret = cpu_effective_str ? strcmp(cpu_effective_str, buf) : 1;
6341 - if (!ret) {
6342 - free(buf);
6336 + ret = strncmp(cpu_effective_str, buf, 1024);
6337 + if (!ret)
6343 6338 return 0;
6344 - }
6345 6339
6346 - free(cpu_effective_str);
6347 - cpu_effective_str = buf;
6340 + strncpy(cpu_effective_str, buf, 1024);
6348 6341 return 1;
6349 6342 }
6350 6343
@@ -8536,16 +8529,13 @@ end:
8536 8529 return ret;
8537 8530 }
8538 8531
8539 - int initialize_cpu_set_from_sysfs(cpu_set_t *cpu_set, const char *sysfs_path,
8540 - const char *sysfs_file)
8532 + char cpuset_buf[1024];
8533 + int initialize_cpu_set_from_sysfs(cpu_set_t *cpu_set, char *sysfs_path, char *sysfs_file)
8541 8534 {
8542 8535 FILE *fp;
8543 - char *cpuset_buf = NULL;
8544 - size_t size = 0;
8545 8536 char path[128];
8546 - int ret = -1;
8547 8537
8548 - if (snprintf(path, sizeof(path), "%s/%s", sysfs_path, sysfs_file) >= (int)sizeof(path))
8538 + if (snprintf(path, 128, "%s/%s", sysfs_path, sysfs_file) > 128)
8549 8539 err(-1, "%s %s", sysfs_path, sysfs_file);
8550 8540
8551 8541 fp = fopen(path, "r");
@@ -8553,20 +8543,19 @@ int initialize_cpu_set_from_sysfs(cpu_set_t *cpu_set, const char *sysfs_path,
8553 8543 warn("open %s", path);
8554 8544 return -1;
8555 8545 }
8556 - if (getline(&cpuset_buf, &size, fp) < 0) {
8546 + if (fread(cpuset_buf, sizeof(char), 1024, fp) == 0) {
8557 8547 warn("read %s", sysfs_path);
8558 - goto out;
8548 + goto err;
8559 8549 }
8560 8550 if (parse_cpu_str(cpuset_buf, cpu_set, cpu_possible_setsize)) {
8561 - warnx("%s: cpu str malformat %s\n", sysfs_path, cpuset_buf);
8562 - goto out;
8551 + warnx("%s: cpu str malformat %s\n", sysfs_path, cpu_effective_str);
8552 + goto err;
8563 8553 }
8564 - ret = 0;
8554 + return 0;
8565 8555
8566 - out:
8556 + err:
8567 8557 fclose(fp);
8568 - free(cpuset_buf);
8569 - return ret;
8558 + return -1;
8570 8559 }
8571 8560
8572 8561 void print_cpu_set(char *s, cpu_set_t *set)
@@ -8666,8 +8655,6 @@ void rapl_perf_init(void)
8666 8655 {
8667 8656 const unsigned int num_domains = get_rapl_num_domains();
8668 8657 bool *domain_visited = calloc(num_domains, sizeof(bool));
8669 - if (!domain_visited)
8670 - err(-1, "calloc domain_visited");
8671 8658
8672 8659 rapl_counter_info_perdomain = calloc(num_domains, sizeof(*rapl_counter_info_perdomain));
8673 8660 if (rapl_counter_info_perdomain == NULL)
@@ -9484,10 +9471,8 @@ void perf_l2_init(void)
9484 9471 free_fd_l2_percpu();
9485 9472 return;
9486 9473 }
9487 - } else {
9488 - warn("%s: cpu%d: type %d: Update kernel perf support or use \"--hide L2MRPS,L2%%hit\" or \"--hide cache\" or \"--no-perf\"", __func__, cpu, cpus[cpu].type);
9489 - return;
9490 - }
9474 + } else
9475 + err(-1, "%s: cpu%d: type %d", __func__, cpu, cpus[cpu].type);
9491 9476 }
9492 9477 BIC_PRESENT(BIC_L2_MRPS);
9493 9478 BIC_PRESENT(BIC_L2_HIT);
@@ -10014,8 +9999,6 @@ int added_perf_counters_init_(struct perf_counter_info *pinfo)
10014 9999 const size_t max_num_domains = MAX(topo.max_cpu_num + 1, MAX(topo.max_core_id + 1, topo.max_package_id + 1));
10015 10000
10016 10001 domain_visited = calloc(max_num_domains, sizeof(*domain_visited));
10017 - if (!domain_visited)
10018 - errx(1, "%s: alloc %s", __func__, "domain_visited");
10019 10002
10020 10003 while (pinfo) {
10021 10004 switch (pinfo->scope) {
@@ -10407,8 +10390,6 @@ int pmt_add_counter(unsigned int guid, unsigned int seq, const char *name, enum
10407 10390 pcounter = pmt_find_counter(*pmt_root, name);
10408 10391 if (!pcounter) {
10409 10392 pcounter = calloc(1, sizeof(*pcounter));
10410 - if (!pcounter)
10411 - return 1;
10412 10393 new_counter = true;
10413 10394 }
10414 10395
@@ -10458,7 +10439,7 @@ void pmt_init(void)
10458 10439 mod_num = 0; /* Relative module number for current PMT file. */
10459 10440
10460 10441 /* Open the counter for each CPU. */
10461 - for (cpu_num = 0; cpu_num <= topo.max_cpu_num;) {
10442 + for (cpu_num = 0; cpu_num < topo.max_cpu_num;) {
10462 10443
10463 10444 if (cpu_is_not_allowed(cpu_num))
10464 10445 goto next_loop_iter;
@@ -10627,7 +10608,7 @@ int get_and_dump_counters(void)
10627 10608
10628 10609 void print_version()
10629 10610 {
10630 - fprintf(outf, "turbostat version 2026.09.28 - Len Brown <lenb@kernel.org>\n");
10611 + fprintf(outf, "turbostat version 2026.04.21 - Len Brown <lenb@kernel.org>\n");
10631 10612 }
10632 10613
10633 10614 #define COMMAND_LINE_SIZE 2048
@@ -10687,11 +10668,10 @@ int add_counter(unsigned int msr_num, char *path, char *name,
10687 10668 fprintf(stderr, "%s: %s FOUND\n", __func__, name);
10688 10669 break;
10689 10670 }
10690 - if (sys.added_thread_counters >= MAX_ADDED_THREAD_COUNTERS) {
10671 + if (sys.added_thread_counters++ >= MAX_ADDED_THREAD_COUNTERS) {
10691 10672 warnx("ignoring thread counter %s", name);
10692 10673 return -1;
10693 10674 }
10694 - sys.added_thread_counters++;
10695 10675 break;
10696 10676 case SCOPE_CORE:
10697 10677 msrp = find_msrp_by_name(sys.cp, name);
@@ -10700,11 +10680,10 @@ int add_counter(unsigned int msr_num, char *path, char *name,
10700 10680 fprintf(stderr, "%s: %s FOUND\n", __func__, name);
10701 10681 break;
10702 10682 }
10703 - if (sys.added_core_counters >= MAX_ADDED_CORE_COUNTERS) {
10683 + if (sys.added_core_counters++ >= MAX_ADDED_CORE_COUNTERS) {
10704 10684 warnx("ignoring core counter %s", name);
10705 10685 return -1;
10706 10686 }
10707 - sys.added_core_counters++;
10708 10687 break;
10709 10688 case SCOPE_PACKAGE:
10710 10689 msrp = find_msrp_by_name(sys.pp, name);
@@ -10713,11 +10692,10 @@ int add_counter(unsigned int msr_num, char *path, char *name,
10713 10692 fprintf(stderr, "%s: %s FOUND\n", __func__, name);
10714 10693 break;
10715 10694 }
10716 - if (sys.added_package_counters >= MAX_ADDED_PACKAGE_COUNTERS) {
10695 + if (sys.added_package_counters++ >= MAX_ADDED_PACKAGE_COUNTERS) {
10717 10696 warnx("ignoring package counter %s", name);
10718 10697 return -1;
10719 10698 }
10720 - sys.added_package_counters++;
10721 10699 break;
10722 10700 default:
10723 10701 warnx("ignoring counter %s with unknown scope", name);